Skip to content

Commit 23bde49

Browse files
authored
[Bugfix] Raise error for processor remote code (#1184)
## Purpose ## * Raise error when processor cannot load due to required remote code option Signed-off-by: Kyle Sayers <[email protected]>
1 parent f19fdd0 commit 23bde49

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/llmcompressor/entrypoints/utils.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,16 @@ def initialize_processor_from_path(
230230
use_auth_token=True if model_args.use_auth_token else None,
231231
trust_remote_code=model_args.trust_remote_code_model,
232232
)
233-
except Exception:
233+
234+
except ValueError as exception:
235+
if "trust_remote_code=True" in exception.value:
236+
raise ValueError(
237+
f"The repository for {processor_src} contains custom code which must "
238+
"be executed to correctly load the tokenizer/processor. You can "
239+
f"inspect the repository content at https://hf.co/{processor_src}.\n"
240+
"Please pass the argument `trust_remote_code_model=True`."
241+
)
242+
234243
logger.debug("Could not load fast processor, loading slow processor instead")
235244
processor = AutoProcessor.from_pretrained(
236245
processor_src,

0 commit comments

Comments
 (0)