langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.53k stars 14.82k forks source link

HuggingFaceHub api can not pass trust_remote_code argument #15141

Closed RWDai closed 5 months ago

RWDai commented 9 months ago

System Info

wsl conda 23.7.4 python 3.8.11

Who can help?

No response

Information

Related Components

Reproduction

repo_id = "Qwen/Qwen-1_8B-Chat"
llm = HuggingFaceHub(
    repo_id=repo_id, model_kwargs={"max_length": 128, "temperature": 0.5}
)
llm_chain = LLMChain(prompt=prompt, llm=llm)
print(llm_chain.run(question))

output:

ValueError: Error raised by inference API: The repository for Qwen/Qwen-1_8B-Chat contains custom code which must be executed to correctly load the model. You can inspect the repository content at https://hf.co/Qwen/Qwen-1_8B-Chat.
Please pass the argument `trust_remote_code=True` to allow custom code to be run.

similar issue #6080

RWDai commented 9 months ago

officical doc https://python.langchain.com/docs/integrations/llms/huggingface_hub most of examples mybe can not run.