From 512ddb842231048326aaf78c54c6e3f1a64ad2b7 Mon Sep 17 00:00:00 2001 From: Justin Zhao Date: Thu, 28 Sep 2023 20:47:43 +0000 Subject: [PATCH 1/2] Use Huggingface's error messaage for AutoConfig loading failures. --- ludwig/schema/llms/base_model.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ludwig/schema/llms/base_model.py b/ludwig/schema/llms/base_model.py index 7aff31718a0..2bd2fda37a4 100644 --- a/ludwig/schema/llms/base_model.py +++ b/ludwig/schema/llms/base_model.py @@ -57,12 +57,8 @@ def validate(model_name: str): try: AutoConfig.from_pretrained(model_name) return model_name - except OSError: - raise ConfigValidationError( - f"Specified base model `{model_name}` is not a valid pretrained CausalLM listed on huggingface " - "or a valid local directory containing the weights for a pretrained CausalLM from huggingface." - "Please see: https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads" - ) + except OSError as e: + raise ConfigValidationError(e) raise ValidationError( f"`base_model` should be a string, instead given: {model_name}. This can be a preset or any pretrained " "CausalLM on huggingface. See: https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads" From ebf892b1f5a1ea8841ba5ef1349b3bb2a4308fa1 Mon Sep 17 00:00:00 2001 From: Justin Zhao Date: Thu, 28 Sep 2023 20:55:51 +0000 Subject: [PATCH 2/2] Improve error message. --- ludwig/schema/llms/base_model.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ludwig/schema/llms/base_model.py b/ludwig/schema/llms/base_model.py index 2bd2fda37a4..1eca08e13ef 100644 --- a/ludwig/schema/llms/base_model.py +++ b/ludwig/schema/llms/base_model.py @@ -57,8 +57,14 @@ def validate(model_name: str): try: AutoConfig.from_pretrained(model_name) return model_name - except OSError as e: - raise ConfigValidationError(e) + except OSError: + raise ConfigValidationError( + f"Specified base model `{model_name}` could not be loaded. If this is a private repository, make " + f"sure to set HUGGING_FACE_HUB_TOKEN in your environment. Check that {model_name} is a valid " + "pretrained CausalLM listed on huggingface or a valid local directory containing the weights for a " + "pretrained CausalLM from huggingface. See: " + "https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads for a full list." + ) raise ValidationError( f"`base_model` should be a string, instead given: {model_name}. This can be a preset or any pretrained " "CausalLM on huggingface. See: https://huggingface.co/models?pipeline_tag=text-generation&sort=downloads"