Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SetFitModel: not a dataclass, not a PyTorchModelHubMixin #505

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Wauplin
Copy link

@Wauplin Wauplin commented Mar 27, 2024

Related to discussion triggered by huggingface/huggingface_hub#2157 (also internal slack).

SetFitModel class is currently a dataclass which doesn't seem necessary and can have weird side-effect (especially with ModelHubMixin). This PR:

  • removes @dataclass from SetFitModel
  • makes SetFitModel inherit from ModelHubMixin instead of PytorchModelHubMixin. The former is the generic class. The later is a specific class for model inheriting from nn.Module which is not the case here. The only benefit of PytorchModelHubMixin is to have _from_pretrained and _save_pretrained already implemented to load torch weights but in SetFit those methods are inherited anyway (since we don't want to load torch weights)
  • adapts SpanSetFitModel and PolarityModel accordingly
  • (updates a type annotation List[str] -> Iterable[str] because it's a generator)

cc @lewtun @tomaarsen @LysandreJik changes should work correctly but I haven't tested them extensively (especially the SpanSetFitModel subclass). Please let me know if you think of any oversight/other things to change.

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@Wauplin Wauplin marked this pull request as ready for review March 27, 2024 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants