-
Notifications
You must be signed in to change notification settings - Fork 629
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
Making ModelHubMixin.save_pretrained
save self.config
on demand for integrated libraries
#2102
Comments
Btw I assume the |
Hi @Natooz, thanks for letting me know and sorry about the breaking change this created to MidiTok 😬 Just to be sure to understand, what was the issue you got? Was it because of a non-serializable config or a overwrite? We could fix the first one with a try/except. What do you think? |
The main issue in my case is that the child method The reason I mentioned the tokenizers from the transformers lib is that I assume that's also probably something that could be desired in the event where thy were to subclass |
Thanks for explaining! I opened a PR to fix it: #2105 :) |
Fixed by #2142. |
Hi there 👋
Problem
Since v0.21
ModelHubMixin.save_pretrained
will automatically saveself.config
after callingself._save_pretrained
.This can be problematic if an integrated library subclassing
ModelHubMixin
already handle saving itsself.config
in the childself._save_pretrained
method. This will either result in a config file saved twice, or crashing ifself.config
is not serializable.### Solution
Integrated libraries could override
ModelHubMixin.save_pretrained
to remove this part, as currently done in MidiTok Natooz/MidiTok#150.This is however not an ideal solution, as it is better for libraries to override as little as possible to benefit from the latest version updates and make sure nothing will break in the future.
To solve this, maybe
ModelHubMixin
can implement a protected attribute specifying wether to automatically saveself.config
, so that integrated libraries can control this part of the process without overriding the parent method.cc @Wauplin 🤗
The text was updated successfully, but these errors were encountered: