From af471ce5e8ca7c19183e70bb998561170addc276 Mon Sep 17 00:00:00 2001 From: Patrick von Platen Date: Mon, 16 Mar 2020 09:48:30 +0100 Subject: [PATCH] Improved Error message when loading config/model with .from_pretrained() (#3247) * better error message * better error message * update to model identifier instead of url * update to model identifier instead of ur --- src/transformers/configuration_utils.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/transformers/configuration_utils.py b/src/transformers/configuration_utils.py index 34fec9034e..69dcab6d41 100644 --- a/src/transformers/configuration_utils.py +++ b/src/transformers/configuration_utils.py @@ -250,10 +250,17 @@ class PretrainedConfig(object): ) else: msg = ( - "Model name '{}' was not found in model name list. " - "We assumed '{}' was a path, a model identifier, or url to a configuration file named {} or " - "a directory containing such a file but couldn't find any such file at this path or url.".format( - pretrained_model_name_or_path, config_file, CONFIG_NAME, + "Can't load '{}'. Make sure that:\n\n" + "- '{}' is either a correct model identifier of a community model from 'https://huggingface.co/models' which has a '{}' file\n\n" + "- or '{}' is a model name in {}\n\n" + "- or '{}' is the correct path to a directory containing a '{}' file".format( + pretrained_model_name_or_path, + pretrained_model_name_or_path, + CONFIG_NAME, + pretrained_model_name_or_path, + list(pretrained_config_archive_map.keys()), + pretrained_model_name_or_path, + CONFIG_NAME, ) ) raise EnvironmentError(msg)