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

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

Wauplin
Copy link
Contributor

@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
@tomaarsen tomaarsen merged commit 3904e53 into huggingface:main Sep 12, 2024
1 of 18 checks passed
@tomaarsen
Copy link
Member

Hello!

Apologies for the delay! I've merged these changes into main and resolved the remaining outstanding issues as well. I expect this'll all be included in a release quite soon (this week?). Thanks a bunch for making this PR!

  • Tom Aarsen

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.

3 participants