Skip to main content
本指南将帮助您开始使用 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 a ChatHuggingFace model in two different ways, either from a HuggingFaceEndpoint or from a HuggingFacePipeline.

HuggingFaceEndpoint

Now let’s take advantage of Inference Providers to run the model on specific third-party providers

HuggingFacePipeline

Instatiating with quantization

To run a quantized version of your model, you can specify a bitsandbytes quantization config as follows:
and pass it to the HuggingFacePipeline as a part of its model_kwargs:

调用


API 参考

有关所有 ChatHuggingFace 功能和配置的详细文档,请前往 API reference