huggingface / huggingface/setfit

[FR] Use normal dict instead of `**model_kwargs` in `_from_pretrained`

Open
#216 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Jupyter Notebook
Stars
2.8k
Forks
267
Avg merge
36m
Merged PRs (30d)
5

Description

The `_from_pretrained` function of the `modeling` module has an argument called `**model_kwargs`. See here:

https://github.com/huggingface/setfit/blob/fa1021d2355f0cb3a2c85732ee7ffe44b0cef0d1/src/setfit/modeling.py#L337

IMO this should be changed. The problem I see is that it "collects" all keyword arguments from the function that are not defined. Later it only handles those assigned to `head_params`. This then swallows all other keyword args that
might have happened because of a mistype for example. This would then be a bug very hard to find.

My suggestion is to just expect a dict called `logistic_regression_kwargs` `head_kwargs` (so just a dict and no `**`).
This can then just be passed like so:

```python
clf = LogisticRegression(**head_kwargs)
```

and

```python
model_head = SetFitHead(**head_kwargs)
```

What do you think?

@lewtun and @blakechi and all others...

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.