-
Notifications
You must be signed in to change notification settings - Fork 31.9k
[GenerationConfig] add additional kwargs handling #21269
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably can remove self.generation_kwargs = kwargs.pop("generation_kwargs", {}) on L277, it was intended as a restricted version on these changes
(for context, the model config has the same lines here)
|
The documentation is not available anymore as the PR was closed or merged. |
sgugger
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this!
|
Also will have to add test + this is apparently breaking a lot of things haha |
|
Okay, after talking a bit with @gante and testing, this is not the best, this PR will focus on other missing functionalities. Mostly addition of the EDIT : gonna just add a condition, if the kwargs are from a config file, they are not added. |
|
Now only thing left is to add a pretty test with all the different edge cases I encountered. |
| # remove all the arguments that are in the config_dict | ||
|
|
||
| config = cls(**config_dict, **kwargs) | ||
| unused_kwargs = config.update(**kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line now only exists to obtain unused_kwargs, as the kwargs get written to the config in the line above, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well yes, for example when _from_model_config is set to True, then it is still in the kwargs, think I saw something like this.
| self.transformers_version = kwargs.pop("transformers_version", __version__) | ||
|
|
||
| # Additional attributes without default values | ||
| if not self._from_model_config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a comment here explaining why we need this if, otherwise we may be like "wtf?" in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, thanks for the comment!
Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com>
What does this PR do?
This add the same support that we have in the
PretrainedConfig, where additional kwargs are automaticallu updated.This will allow users to re-use the
GenerationConfigclass for most of the use_cases, whithout having to add a model specific class. I was trying to load the followinggeneration_configand got half of my additional arguments deleted 😉