Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More error message fixup, plus some linebreaks! #26296

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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\n"
"machine. Please set the option `trust_remote_code=True` to permit loading of this model."
Rocketknight1 marked this conversation as resolved.
Show resolved Hide resolved
)


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\n"
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"
Rocketknight1 marked this conversation as resolved.
Show resolved Hide resolved
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\n"
f"load the model. You can inspect the repository content at https://hf.co/{model_name}.\n"
Rocketknight1 marked this conversation as resolved.
Show resolved Hide resolved
f"Please pass the argument `trust_remote_code=True` to allow custom code to be run."
)
elif has_remote_code:
Expand Down