Improve mismatched sizes management when loading a pretrained model (#17257)

- Add --ignore_mismatched_sizes argument to classification examples

- Expand the error message when loading a model whose head dimensions are different from expected dimensions
This commit is contained in:
regisss
2022-05-17 17:58:14 +02:00
committed by GitHub
parent 1f13ba818e
commit 28a0811652
13 changed files with 64 additions and 9 deletions

View File

@@ -196,6 +196,10 @@ class ModelArguments:
)
},
)
ignore_mismatched_sizes: bool = field(
default=False,
metadata={"help": "Will enable to load a pretrained model whose head dimensions are different."},
)
def main():
@@ -364,6 +368,7 @@ def main():
cache_dir=model_args.cache_dir,
revision=model_args.model_revision,
use_auth_token=True if model_args.use_auth_token else None,
ignore_mismatched_sizes=model_args.ignore_mismatched_sizes,
)
# Preprocessing the raw_datasets