"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "6cb71873244a0b89bddfa17b43b61a0f42e86bba"
Unverified Commit a53a0c51 authored by Joao Gante's avatar Joao Gante Committed by GitHub
Browse files

Generate: `GenerationConfig.from_pretrained` can return unused kwargs (#27488)

parent 5468ab35
...@@ -750,9 +750,14 @@ class GenerationConfig(PushToHubMixin): ...@@ -750,9 +750,14 @@ class GenerationConfig(PushToHubMixin):
else: else:
logger.info(f"loading configuration file {configuration_file} from cache at {resolved_config_file}") logger.info(f"loading configuration file {configuration_file} from cache at {resolved_config_file}")
config = cls.from_dict(config_dict, **kwargs) if kwargs.get("return_unused_kwargs") is True:
config._original_object_hash = hash(config) # Hash to detect whether the instance was modified config, unused_kwargs = cls.from_dict(config_dict, **kwargs)
return config config._original_object_hash = hash(config) # Hash to detect whether the instance was modified
return config, unused_kwargs
else:
config = cls.from_dict(config_dict, **kwargs)
config._original_object_hash = hash(config) # Hash to detect whether the instance was modified
return config
@classmethod @classmethod
def _dict_from_json_file(cls, json_file: Union[str, os.PathLike]): def _dict_from_json_file(cls, json_file: Union[str, os.PathLike]):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment