langchain_huggingface
chat models. For detailed documentation of all ChatHuggingFace
features and configurations head to the API reference. For a list of models supported by Hugging Face check out this page.
Overview
Integration details
Integration details
Class | Package | Local | Serializable | JS support | Downloads | Version |
---|---|---|---|---|---|---|
ChatHuggingFace | langchain-huggingface | ✅ | beta | ❌ |
Model features
Tool calling | Structured output | JSON mode | Image input | Audio input | Video input | Token-level streaming | Native async | Token usage | Logprobs |
---|---|---|---|---|---|---|---|---|---|
✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ |
Setup
To access Hugging Face models you’ll need to create a Hugging Face account, get an API key, and install thelangchain-huggingface
integration package.
Credentials
Generate a Hugging Face Access Token and store it as an environment variable:HUGGINGFACEHUB_API_TOKEN
.
Installation
Class | Package | Local | Serializable | JS support | Downloads | Version |
---|---|---|---|---|---|---|
ChatHuggingFace | langchain-huggingface | ✅ | ❌ | ❌ |
Model features
Tool calling | Structured output | JSON mode | Image input | Audio input | Video input | Token-level streaming | Native async | Token usage | Logprobs |
---|---|---|---|---|---|---|---|---|---|
✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Setup
To accesslangchain_huggingface
models you’ll need to create a Hugging Face
account, get an API key, and install the langchain-huggingface
integration package.
Credentials
You’ll need to have a Hugging Face Access Token saved as an environment variable:HUGGINGFACEHUB_API_TOKEN
.
Instantiation
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
:
Invocation
API reference
For detailed documentation of allChatHuggingFace
features and configurations head to the API reference: python.langchain.com/api_reference/huggingface/chat_models/langchain_huggingface.chat_models.huggingface.ChatHuggingFace.html