huggingface
config_error
ai_generated
true
ValueError: Loading this model requires trust_remote_code=True. See https://huggingface.co/docs/hub/security
ID: huggingface/trust-remote-code-required
93%Fix Rate
90%Confidence
1Evidence
2023-06-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| transformers>=4.30.0 | active | — | — | — |
Root Cause
The model repository contains custom Python code (e.g., modeling file) that must be executed locally; trust_remote_code flag is not set for security reasons.
generic中文
模型仓库包含必须本地执行的自定义Python代码(例如建模文件);出于安全原因未设置trust_remote_code标志。
Official Documentation
https://huggingface.co/docs/hub/security#trust-remote-codeWorkarounds
-
95% success Set trust_remote_code=True in from_pretrained after reviewing the custom code.
Set trust_remote_code=True in from_pretrained after reviewing the custom code.
-
90% success Download and inspect the custom code files, then load with trust_remote_code=True.
Download and inspect the custom code files, then load with trust_remote_code=True.
-
85% success Use the transformers CLI to download the model and then load with trust_remote_code.
Use the transformers CLI to download the model and then load with trust_remote_code.
中文步骤
Set trust_remote_code=True in from_pretrained after reviewing the custom code.
Download and inspect the custom code files, then load with trust_remote_code=True.
Use the transformers CLI to download the model and then load with trust_remote_code.
Dead Ends
Common approaches that don't work:
-
98% fail
This parameter does not address the remote code execution requirement.
-
85% fail
Custom code is still required even from local files; trust_remote_code must be set.