From f29fe7458953dbf00addaf793d95ea1965bc8441 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 20 Sep 2023 15:18:49 +0100 Subject: [PATCH] Rewrite for custom code warning messages (#26291) Quick britpicking for some warning messages! --- src/transformers/dynamic_module_utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/transformers/dynamic_module_utils.py b/src/transformers/dynamic_module_utils.py index 611702baeb..627adf4fc8 100644 --- a/src/transformers/dynamic_module_utils.py +++ b/src/transformers/dynamic_module_utils.py @@ -594,9 +594,10 @@ 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"Loading {model_name} requires to execute some code in that repo, you can inspect the content of " - f"the repository at https://hf.co/{model_name}. You can dismiss this prompt by passing " - "`trust_remote_code=True`.\nDo you accept? [y/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}. " + f"You can avoid this prompt in future by passing the argument `trust_remote_code=True`.\n" + f"Do you wish to run the custom code? [y/N] " ) if answer.lower() in ["yes", "y", "1"]: trust_remote_code = True @@ -606,9 +607,9 @@ 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( - "Loading this model requires you to execute execute some code in that repo on your local machine. " - f"Make sure you have read the code at https://hf.co/{model_name} to avoid malicious use, then set " - "the option `trust_remote_code=True` to remove this error." + 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"Please pass the argument `trust_remote_code=True` to allow custom code to be run." ) elif has_remote_code: # For the CI which puts the timeout at 0