Improving error message when using use_safetensors=True. (#24232)

This commit is contained in:
Nicolas Patry 2023-06-13 15:07:00 +02:00 committed by GitHub
parent 74b846cacf
commit fdd78d9153
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2445,6 +2445,11 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
f" {pretrained_model_name_or_path} but there is a file for Flax weights. Use `from_flax=True`"
" to load this model from those weights."
)
elif use_safetensors:
raise EnvironmentError(
f"Error no file named {_add_variant(SAFE_WEIGHTS_NAME, variant)} found in directory"
f" {pretrained_model_name_or_path}."
)
else:
raise EnvironmentError(
f"Error no file named {_add_variant(WEIGHTS_NAME, variant)}, {TF2_WEIGHTS_NAME},"