Embeddings
HuggingFace Inference Embeddings
The HuggingFace Inference Embeddings node is a component used to generate embeddings for given text using the HuggingFace Inference API. This node is part of the Embeddings category and leverages HuggingFace’s powerful language models to create vector representations of text.
Node Details
- Name: HuggingFaceInferenceEmbeddings
- Type: HuggingFaceInferenceEmbeddings
- Version: 1.0
- Category: Embeddings
Parameters
Credential
- Label: Connect Credential
- Name: credential
- Type: credential
- Credential Names: huggingFaceApi
Inputs
-
Model
- Label: Model
- Name: modelName
- Type: string
- Description: The name of the HuggingFace model to use for embeddings. Leave blank if using a custom inference endpoint.
- Placeholder: sentence-transformers/distilbert-base-nli-mean-tokens
- Optional: Yes
-
Endpoint
- Label: Endpoint
- Name: endpoint
- Type: string
- Description: The URL of your custom inference endpoint, if using one.
- Placeholder: https://xyz.eu-west-1.aws.endpoints.huggingface.cloud/sentence-transformers/all-MiniLM-L6-v2
- Optional: Yes
Initialization
The node initializes by creating an instance of HuggingFaceInferenceEmbeddings
with the following steps:
- Retrieves the HuggingFace API key from the provided credentials.
- Sets up the configuration object with the API key.
- If a model name is provided, it’s added to the configuration.
- If a custom endpoint is provided, it’s added to the configuration.
- Creates and returns a new
HuggingFaceInferenceEmbeddings
instance with the configured parameters.
Usage
This node is typically used in workflows where text needs to be converted into numerical vector representations. Common use cases include:
- Text similarity comparisons
- Document clustering
- Input preparation for machine learning models
- Semantic search implementations
By leveraging HuggingFace’s pre-trained models or custom-deployed endpoints, users can easily generate high-quality embeddings for a wide range of natural language processing tasks.
Was this page helpful?
Previous
LocalAI EmbeddingsThe LocalAI Embeddings node is a component designed to use local embedding models, such as those powered by llama.cpp, within a larger language processing system. It leverages the OpenAIEmbeddings class from the @langchain/openai package but configures it to work with a local AI setup.
Next