Improve error message when loading models from Hub (#13836)
* Improve error message when loading models from Hub * Adjust error message wording
This commit is contained in:
@@ -560,7 +560,8 @@ class PretrainedConfig(PushToHubMixin):
|
|||||||
logger.error(err)
|
logger.error(err)
|
||||||
msg = (
|
msg = (
|
||||||
f"Can't load config for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
f"Can't load config for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
||||||
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n\n"
|
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n"
|
||||||
|
f" (make sure '{pretrained_model_name_or_path}' is not a path to a local directory with something else, in that case)\n\n"
|
||||||
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a {CONFIG_NAME} file\n\n"
|
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a {CONFIG_NAME} file\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,8 @@ class FeatureExtractionMixin:
|
|||||||
logger.error(err)
|
logger.error(err)
|
||||||
msg = (
|
msg = (
|
||||||
f"Can't load feature extractor for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
f"Can't load feature extractor for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
||||||
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n\n"
|
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n"
|
||||||
|
f" (make sure '{pretrained_model_name_or_path}' is not a path to a local directory with something else, in that case)\n\n"
|
||||||
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a {FEATURE_EXTRACTOR_NAME} file\n\n"
|
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a {FEATURE_EXTRACTOR_NAME} file\n\n"
|
||||||
)
|
)
|
||||||
raise EnvironmentError(msg)
|
raise EnvironmentError(msg)
|
||||||
|
|||||||
@@ -328,7 +328,8 @@ class FlaxPreTrainedModel(PushToHubMixin, FlaxGenerationMixin):
|
|||||||
logger.error(err)
|
logger.error(err)
|
||||||
msg = (
|
msg = (
|
||||||
f"Can't load weights for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
f"Can't load weights for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
||||||
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n\n"
|
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n"
|
||||||
|
f" (make sure '{pretrained_model_name_or_path}' is not a path to a local directory with something else, in that case)\n\n"
|
||||||
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named {WEIGHTS_NAME}.\n\n"
|
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named {WEIGHTS_NAME}.\n\n"
|
||||||
)
|
)
|
||||||
raise EnvironmentError(msg)
|
raise EnvironmentError(msg)
|
||||||
|
|||||||
@@ -1403,7 +1403,8 @@ class TFPreTrainedModel(tf.keras.Model, TFModelUtilsMixin, TFGenerationMixin, Pu
|
|||||||
logger.error(err)
|
logger.error(err)
|
||||||
msg = (
|
msg = (
|
||||||
f"Can't load weights for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
f"Can't load weights for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
||||||
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n\n"
|
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n"
|
||||||
|
f" (make sure '{pretrained_model_name_or_path}' is not a path to a local directory with something else, in that case)\n\n"
|
||||||
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named one of {TF2_WEIGHTS_NAME}, {WEIGHTS_NAME}.\n\n"
|
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named one of {TF2_WEIGHTS_NAME}, {WEIGHTS_NAME}.\n\n"
|
||||||
)
|
)
|
||||||
raise EnvironmentError(msg)
|
raise EnvironmentError(msg)
|
||||||
|
|||||||
@@ -1308,7 +1308,8 @@ class PreTrainedModel(nn.Module, ModuleUtilsMixin, GenerationMixin, PushToHubMix
|
|||||||
logger.error(err)
|
logger.error(err)
|
||||||
msg = (
|
msg = (
|
||||||
f"Can't load weights for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
f"Can't load weights for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
||||||
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n\n"
|
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n"
|
||||||
|
f" (make sure '{pretrained_model_name_or_path}' is not a path to a local directory with something else, in that case)\n\n"
|
||||||
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named one of {WEIGHTS_NAME}, {TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME}\n\n"
|
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a file named one of {WEIGHTS_NAME}, {TF2_WEIGHTS_NAME}, {TF_WEIGHTS_NAME}\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1722,7 +1722,8 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
|
|||||||
if all(full_file_name is None for full_file_name in resolved_vocab_files.values()):
|
if all(full_file_name is None for full_file_name in resolved_vocab_files.values()):
|
||||||
msg = (
|
msg = (
|
||||||
f"Can't load tokenizer for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
f"Can't load tokenizer for '{pretrained_model_name_or_path}'. Make sure that:\n\n"
|
||||||
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n\n"
|
f"- '{pretrained_model_name_or_path}' is a correct model identifier listed on 'https://huggingface.co/models'\n"
|
||||||
|
f" (make sure '{pretrained_model_name_or_path}' is not a path to a local directory with something else, in that case)\n\n"
|
||||||
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing relevant tokenizer files\n\n"
|
f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing relevant tokenizer files\n\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user