mirror of
https://github.com/saymrwulf/transformers.git
synced 2026-05-14 20:58:08 +00:00
improve rewrite state_dict missing _metadata (#14276)
This commit is contained in:
parent
d29baf69bb
commit
fd8136fa75
1 changed files with 2 additions and 1 deletions
|
|
@ -1049,7 +1049,8 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||
|
||||
# Handle the case where some state_dict keys shouldn't be saved
|
||||
if self._keys_to_ignore_on_save is not None:
|
||||
state_dict = {k: v for k, v in state_dict.items() if k not in self._keys_to_ignore_on_save}
|
||||
for ignore_key in self._keys_to_ignore_on_save:
|
||||
del state_dict[ignore_key]
|
||||
|
||||
# If we save using the predefined names, we can load using `from_pretrained`
|
||||
output_model_file = os.path.join(save_directory, WEIGHTS_NAME)
|
||||
|
|
|
|||
Loading…
Reference in a new issue