langchain_huggingface 聊天模型. 有关所有 ChatHuggingFace 功能和配置的详细文档,请前往 API reference. For a list of models supported by Hugging Face 查看 this page.
概述
集成详情
模型功能
设置
要访问 Hugging Face 模型,您需要创建一个 Hugging Face 账户,获取 API 密钥,并安装langchain-huggingface 集成包。
凭证
Generate a Hugging Face Access Token and store it as an 环境变量:HUGGINGFACEHUB_API_TOKEN.
安装
模型功能
设置
要访问langchain_huggingface 模型,您需要创建一个 Hugging Face 账户,获取 API 密钥,并安装 langchain-huggingface 集成包。
凭证
You’ll need to have a Hugging Face Access Token saved as an 环境变量:HUGGINGFACEHUB_API_TOKEN.
实例化
You can instantiate aChatHuggingFace model in two different ways, either from a HuggingFaceEndpoint or from a HuggingFacePipeline.
HuggingFaceEndpoint
HuggingFacePipeline
Instatiating with quantization
To run a quantized version of your model, you can specify abitsandbytes quantization config as follows:
HuggingFacePipeline as a part of its model_kwargs:
调用
API 参考
有关所有ChatHuggingFace 功能和配置的详细文档,请前往 API reference
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

