Skip to content

Commit

Permalink
More error message fixup, plus some linebreaks! (huggingface#26296)
Browse files Browse the repository at this point in the history
* More error message fixup, plus some linebreaks!

* Update src/transformers/dynamic_module_utils.py

Co-authored-by: Arthur <[email protected]>

* Update src/transformers/dynamic_module_utils.py

Co-authored-by: Arthur <[email protected]>

* Update src/transformers/dynamic_module_utils.py

Co-authored-by: Arthur <[email protected]>

---------

Co-authored-by: Arthur <[email protected]>
  • Loading branch information
2 people authored and EduardoPach committed Nov 18, 2023
1 parent d4dc25b commit a5265f0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/transformers/dynamic_module_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,8 @@ def _set_auto_map_in_config(_config):

def _raise_timeout_error(signum, frame):
raise ValueError(
"Loading this model requires you to execute the configuration file in that repo on your local machine. We "
"asked if it was okay but did not get an answer. Make sure you have read the code there to avoid malicious "
"use, then set the option `trust_remote_code=True` to remove this error."
"Loading this model requires you to execute custom code contained in the model repository on your local"
"machine. Please set the option `trust_remote_code=True` to permit loading of this model."
)


Expand All @@ -594,9 +593,9 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has
signal.alarm(TIME_OUT_REMOTE_CODE)
while trust_remote_code is None:
answer = input(
f"The repository for {model_name} contains custom code which must be executed to correctly "
f"load the model. You can inspect the repository content at https://hf.co/{model_name}. "
f"You can avoid this prompt in future by passing the argument `trust_remote_code=True`.\n"
f"The repository for {model_name} contains custom code which must be executed to correctly"
f"load the model. You can inspect the repository content at https://hf.co/{model_name}.\n"
f"You can avoid this prompt in future by passing the argument `trust_remote_code=True`.\n\n"
f"Do you wish to run the custom code? [y/N] "
)
if answer.lower() in ["yes", "y", "1"]:
Expand All @@ -607,8 +606,8 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has
except Exception:
# OS which does not support signal.SIGALRM
raise ValueError(
f"The repository for {model_name} contains custom code which must be executed to correctly "
f"load the model. You can inspect the repository content at https://hf.co/{model_name}. "
f"The repository for {model_name} contains custom code which must be executed to correctly"
f"load the model. You can inspect the repository content at https://hf.co/{model_name}.\n"
f"Please pass the argument `trust_remote_code=True` to allow custom code to be run."
)
elif has_remote_code:
Expand Down

0 comments on commit a5265f0

Please sign in to comment.