Skip to content

Conversation

@sgugger
Copy link
Collaborator

@sgugger sgugger commented Aug 9, 2022

What does this PR do?

As was reported in #18537, when using AutoConfig inside the AutoModel.from_pretrained method, some kwargs are deleted and not passed to the from_pretrained method of the model. This PR makes sure they are preserved for those calls.

Fixes #18537

@sgugger sgugger requested a review from LysandreJik August 9, 2022 15:11
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Aug 9, 2022

The documentation is not available anymore as the PR was closed or merged.

elif "model_type" in config_dict:
config_class = CONFIG_MAPPING[config_dict["model_type"]]
return config_class.from_dict(config_dict, **kwargs)
return config_class.from_dict(config_dict, **unused_kwargs)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We replicate the logic inside from_pretrained here, but duplicating some of the kwargs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, quite elegant! Thanks for catching and patching the issue.

elif "model_type" in config_dict:
config_class = CONFIG_MAPPING[config_dict["model_type"]]
return config_class.from_dict(config_dict, **kwargs)
return config_class.from_dict(config_dict, **unused_kwargs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good

@sgugger sgugger merged commit d7e2d7b into main Aug 10, 2022
@sgugger sgugger deleted the auto_config_gobbles_kwargs branch August 10, 2022 12:00
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.

AutoModel(s) do not respect the revision flag while loading custom models

4 participants