More error message fixup, plus some linebreaks! (#26296)

* More error message fixup, plus some linebreaks!

* Update src/transformers/dynamic_module_utils.py

Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>

* Update src/transformers/dynamic_module_utils.py

Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>

* Update src/transformers/dynamic_module_utils.py

Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>

---------

Co-authored-by: Arthur <48595927+ArthurZucker@users.noreply.github.com>
This commit is contained in:
Matt
2023-09-21 17:36:05 +01:00
committed by GitHub
parent 9a30753485
commit 000e52aec8

View File

@@ -575,9 +575,8 @@ def custom_object_save(obj: Any, folder: Union[str, os.PathLike], config: Option
def _raise_timeout_error(signum, frame): def _raise_timeout_error(signum, frame):
raise ValueError( raise ValueError(
"Loading this model requires you to execute the configuration file in that repo on your local machine. We " "Loading this model requires you to execute custom code contained in the model repository on your local"
"asked if it was okay but did not get an answer. Make sure you have read the code there to avoid malicious " "machine. Please set the option `trust_remote_code=True` to permit loading of this model."
"use, then set the option `trust_remote_code=True` to remove this error."
) )
@@ -594,9 +593,9 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has
signal.alarm(TIME_OUT_REMOTE_CODE) signal.alarm(TIME_OUT_REMOTE_CODE)
while trust_remote_code is None: while trust_remote_code is None:
answer = input( answer = input(
f"The repository for {model_name} contains custom code which must be executed to correctly " 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"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" 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] " f"Do you wish to run the custom code? [y/N] "
) )
if answer.lower() in ["yes", "y", "1"]: if answer.lower() in ["yes", "y", "1"]:
@@ -607,8 +606,8 @@ def resolve_trust_remote_code(trust_remote_code, model_name, has_local_code, has
except Exception: except Exception:
# OS which does not support signal.SIGALRM # OS which does not support signal.SIGALRM
raise ValueError( raise ValueError(
f"The repository for {model_name} contains custom code which must be executed to correctly " 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"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." f"Please pass the argument `trust_remote_code=True` to allow custom code to be run."
) )
elif has_remote_code: elif has_remote_code: