Skip to main content

Embeddings models in Langflow

Embeddings models convert text into numerical vectors. These embeddings capture the semantic meaning of the input text, and allow LLMs to understand context.

Refer to your specific component's documentation for more information on parameters.

Use an embeddings model component in a flow

In this example of a document ingestion pipeline, the OpenAI embeddings model is connected to a vector database. The component converts the text chunks into vectors and stores them in the vector database. The vectorized data can be used to inform AI workloads like chatbots, similarity searches, and agents.

This embeddings component uses an OpenAI API key for authentication. Refer to your specific embeddings component's documentation for more information on authentication.

URL component in a data ingestion pipeline

AI/ML

This component generates embeddings using the AI/ML API.

Parameters

Inputs

NameTypeDescription
model_nameStringThe name of the AI/ML embedding model to use.
aiml_api_keySecretStringThe API key required for authenticating with the AI/ML service.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance of AIMLEmbeddingsImpl for generating embeddings.

Amazon Bedrock Embeddings

This component is used to load embedding models from Amazon Bedrock.

Parameters

Inputs

NameTypeDescription
credentials_profile_nameStringThe name of the AWS credentials profile in ~/.aws/credentials or ~/.aws/config, which has access keys or role information.
model_idStringThe ID of the model to call, such as amazon.titan-embed-text-v1. This is equivalent to the modelId property in the list-foundation-models API.
endpoint_urlStringThe URL to set a specific service endpoint other than the default AWS endpoint.
region_nameStringThe AWS region to use, such as us-west-2. Falls back to the AWS_DEFAULT_REGION environment variable or region specified in ~/.aws/config if not provided.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance for generating embeddings using Amazon Bedrock.

Astra DB vectorize

important

This component is deprecated as of Langflow version 1.1.2. Instead, use the Astra DB vector store component.

Connect this component to the Embeddings port of the Astra DB vector store component to generate embeddings.

This component requires that your Astra DB database has a collection that uses a vectorize embedding provider integration. For more information and instructions, see Embedding Generation.

Parameters

Inputs

NameDisplay NameInfo
providerEmbedding ProviderThe embedding provider to use.
model_nameModel NameThe embedding model to use.
authenticationAuthenticationThe name of the API key in Astra that stores your vectorize embedding provider credentials. (Not required if using an Astra-hosted embedding provider.)
provider_api_keyProvider API KeyAs an alternative to authentication, directly provide your embedding provider credentials.
model_parametersModel ParametersAdditional model parameters.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance for generating embeddings using Astra vectorize.

Azure OpenAI Embeddings

This component generates embeddings using Azure OpenAI models.

Parameters

Inputs

NameTypeDescription
ModelStringThe name of the model to use. Default: text-embedding-3-small.
Azure EndpointStringYour Azure endpoint, including the resource, such as https://example-resource.azure.openai.com/.
Deployment NameStringThe name of the deployment.
API VersionStringThe API version to use, with options including various dates.
API KeyStringThe API key required to access the Azure OpenAI service.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance for generating embeddings using Azure OpenAI.

Cloudflare Workers AI Embeddings

This component generates embeddings using Cloudflare Workers AI models.

Parameters

Inputs

NameDisplay NameInfo
account_idCloudflare account IDFind your Cloudflare account ID.
api_tokenCloudflare API tokenCreate an API token.
model_nameModel NameList of supported models.
strip_new_linesStrip New LinesWhether to strip new lines from the input text.
batch_sizeBatch SizeThe number of texts to embed in each batch.
api_base_urlCloudflare API base URLThe base URL for the Cloudflare API.
headersHeadersAdditional request headers.

Outputs

NameDisplay NameInfo
embeddingsEmbeddingsAn instance for generating embeddings using Cloudflare Workers.

Cohere Embeddings

This component is used to load embedding models from Cohere.

Parameters

Inputs

NameTypeDescription
cohere_api_keyStringThe API key required to authenticate with the Cohere service.
modelStringThe language model used for embedding text documents and performing queries. Default: embed-english-v2.0.
truncateBooleanWhether to truncate the input text to fit within the model's constraints. Default: False.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance for generating embeddings using Cohere.

Embedding similarity

This component computes selected forms of similarity between two embedding vectors.

Parameters

Inputs

NameDisplay NameInfo
embedding_vectorsEmbedding VectorsA list containing exactly two data objects with embedding vectors to compare.
similarity_metricSimilarity MetricSelect the similarity metric to use. Options: "Cosine Similarity", "Euclidean Distance", "Manhattan Distance".

Outputs

NameDisplay NameInfo
similarity_dataSimilarity DataA data object containing the computed similarity score and additional information.

Google generative AI embeddings

This component connects to Google's generative AI embedding service using the GoogleGenerativeAIEmbeddings class from the langchain-google-genai package.

Parameters

Inputs

NameDisplay NameInfo
api_keyAPI KeyThe secret API key for accessing Google's generative AI service. Required.
model_nameModel NameThe name of the embedding model to use. Default: "models/text-embedding-004".

Outputs

NameDisplay NameInfo
embeddingsEmbeddingsThe built GoogleGenerativeAIEmbeddings object.

Hugging Face Embeddings

note

This component is deprecated as of Langflow version 1.0.18. Instead, use the Hugging Face Embeddings Inference component.

This component loads embedding models from HuggingFace.

Use this component to generate embeddings using locally downloaded Hugging Face models. Ensure you have sufficient computational resources to run the models.

Parameters

Inputs

NameDisplay NameInfo
Cache FolderCache FolderThe folder path to cache HuggingFace models.
Encode KwargsEncoding ArgumentsAdditional arguments for the encoding process.
Model KwargsModel ArgumentsAdditional arguments for the model.
Model NameModel NameThe name of the HuggingFace model to use.
Multi ProcessMulti-ProcessWhether to use multiple processes.

Outputs

NameDisplay NameInfo
embeddingsEmbeddingsThe generated embeddings.

Hugging Face embeddings inference

This component generates embeddings using Hugging Face Inference API models and requires a Hugging Face API token to authenticate. Local inference models do not require an API key.

Use this component to create embeddings with Hugging Face's hosted models, or to connect to your own locally hosted models.

Parameters

Inputs

NameDisplay NameInfo
API KeyAPI KeyThe API key for accessing the Hugging Face Inference API.
API URLAPI URLThe URL of the Hugging Face Inference API.
Model NameModel NameThe name of the model to use for embeddings.

Outputs

NameDisplay NameInfo
embeddingsEmbeddingsThe generated embeddings.

Connect the Hugging Face component to a local embeddings model

To run an embeddings inference locally, see the HuggingFace documentation.

To connect the local Hugging Face model to the Hugging Face embeddings inference component and use it in a flow, follow these steps:

  1. Create a Vector store RAG flow. There are two embeddings models in this flow that you can replace with Hugging Face embeddings inference components.
  2. Replace both OpenAI embeddings model components with Hugging Face model components.
  3. Connect both Hugging Face components to the Embeddings ports of the Astra DB vector store components.
  4. In the Hugging Face components, set the Inference Endpoint field to the URL of your local inference model. The API Key field is not required for local inference.
  5. Run the flow. The local inference models generate embeddings for the input text.

IBM watsonx embeddings

This component generates text using IBM watsonx.ai foundation models.

To use IBM watsonx.ai embeddings components, replace an embeddings component with the IBM watsonx.ai component in a flow.

An example document processing flow looks like the following:

IBM watsonx embeddings model loading a chroma-db with split text

This flow loads a PDF file from local storage and splits the text into chunks.

The IBM watsonx embeddings component converts the text chunks into embeddings, which are then stored in a Chroma DB vector store.

The values for API endpoint, Project ID, API key, and Model Name are found in your IBM watsonx.ai deployment. For more information, see the Langchain documentation.

Default models

The component supports several default models with the following vector dimensions:

  • sentence-transformers/all-minilm-l12-v2: 384-dimensional embeddings
  • ibm/slate-125m-english-rtrvr-v2: 768-dimensional embeddings
  • ibm/slate-30m-english-rtrvr-v2: 768-dimensional embeddings
  • intfloat/multilingual-e5-large: 1024-dimensional embeddings

The component automatically fetches and updates the list of available models from your watsonx.ai instance when you provide your API endpoint and credentials.

Parameters

Inputs

NameDisplay NameInfo
urlwatsonx API EndpointThe base URL of the API.
project_idwatsonx project idThe project ID for your watsonx.ai instance.
api_keyAPI KeyThe API Key to use for the model.
model_nameModel NameThe name of the embedding model to use.
truncate_input_tokensTruncate Input TokensThe maximum number of tokens to process. Default: 200.
input_textInclude the original text in the outputDetermines if the original text is included in the output. Default: True.

Outputs

NameDisplay NameInfo
embeddingsEmbeddingsAn instance for generating embeddings using watsonx.ai.

LM Studio Embeddings

This component generates embeddings using LM Studio models.

Parameters

Inputs

NameDisplay NameInfo
modelModelThe LM Studio model to use for generating embeddings.
base_urlLM Studio Base URLThe base URL for the LM Studio API.
api_keyLM Studio API KeyThe API key for authentication with LM Studio.
temperatureModel TemperatureThe temperature setting for the model.

Outputs

NameDisplay NameInfo
embeddingsEmbeddingsThe generated embeddings.

MistralAI

This component generates embeddings using MistralAI models.

Parameters

Inputs

NameTypeDescription
modelStringThe MistralAI model to use. Default: "mistral-embed".
mistral_api_keySecretStringThe API key for authenticating with MistralAI.
max_concurrent_requestsIntegerThe maximum number of concurrent API requests. Default: 64.
max_retriesIntegerThe maximum number of retry attempts for failed requests. Default: 5.
timeoutIntegerThe request timeout in seconds. Default: 120.
endpointStringThe custom API endpoint URL. Default: https://api.mistral.ai/v1/).

Outputs

NameTypeDescription
embeddingsEmbeddingsA MistralAIEmbeddings instance for generating embeddings.

NVIDIA

This component generates embeddings using NVIDIA models.

Parameters

Inputs

NameTypeDescription
modelStringThe NVIDIA model to use for embeddings, such as nvidia/nv-embed-v1.
base_urlStringThe base URL for the NVIDIA API. Default: https://integrate.api.nvidia.com/v1.
nvidia_api_keySecretStringThe API key for authenticating with NVIDIA's service.
temperatureFloatThe model temperature for embedding generation. Default: 0.1.

Outputs

NameTypeDescription
embeddingsEmbeddingsA NVIDIAEmbeddings instance for generating embeddings.

Ollama embeddings

This component generates embeddings using Ollama models.

For a list of Ollama embeddings models, see the Ollama documentation.

To use this component in a flow, connect Langflow to your locally running Ollama server and select an embeddings model.

  1. In the Ollama component, in the Ollama Base URL field, enter the address for your locally running Ollama server. This value is set as the OLLAMA_HOST environment variable in Ollama. The default base URL is http://127.0.0.1:11434.
  2. To refresh the server's list of models, click .
  3. In the Ollama Model field, select an embeddings model. This example uses all-minilm:latest.
  4. Connect the Ollama embeddings component to a flow. For example, this flow connects a local Ollama server running a all-minilm:latest embeddings model to a Chroma DB vector store to generate embeddings for split text.

Ollama embeddings connected to Chroma DB

For more information, see the Ollama documentation.

Parameters

Inputs

NameTypeDescription
Ollama ModelStringThe name of the Ollama model to use. Default: llama2.
Ollama Base URLStringThe base URL of the Ollama API. Default: http://localhost:11434.
Model TemperatureFloatThe temperature parameter for the model. Adjusts the randomness in the generated embeddings.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance for generating embeddings using Ollama.

OpenAI Embeddings

This component is used to load embedding models from OpenAI.

Parameters

Inputs

NameTypeDescription
OpenAI API KeyStringThe API key to use for accessing the OpenAI API.
Default HeadersDictThe default headers for the HTTP requests.
Default QueryNestedDictThe default query parameters for the HTTP requests.
Allowed SpecialListThe special tokens allowed for processing. Default: [].
Disallowed SpecialListThe special tokens disallowed for processing. Default: ["all"].
Chunk SizeIntegerThe chunk size for processing. Default: 1000.
ClientAnyThe HTTP client for making requests.
DeploymentStringThe deployment name for the model. Default: text-embedding-3-small.
Embedding Context LengthIntegerThe length of embedding context. Default: 8191.
Max RetriesIntegerThe maximum number of retries for failed requests. Default: 6.
ModelStringThe name of the model to use. Default: text-embedding-3-small.
Model KwargsNestedDictAdditional keyword arguments for the model.
OpenAI API BaseStringThe base URL of the OpenAI API.
OpenAI API TypeStringThe type of the OpenAI API.
OpenAI API VersionStringThe version of the OpenAI API.
OpenAI OrganizationStringThe organization associated with the API key.
OpenAI ProxyStringThe proxy server for the requests.
Request TimeoutFloatThe timeout for the HTTP requests.
Show Progress BarBooleanWhether to show a progress bar for processing. Default: False.
Skip EmptyBooleanWhether to skip empty inputs. Default: False.
TikToken EnableBooleanWhether to enable TikToken. Default: True.
TikToken Model NameStringThe name of the TikToken model.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance for generating embeddings using OpenAI.

Text embedder

This component generates embeddings for a given message using a specified embedding model.

Parameters

Inputs

NameDisplay NameInfo
embedding_modelEmbedding ModelThe embedding model to use for generating embeddings.
messageMessageThe message for which to generate embeddings.

Outputs

NameDisplay NameInfo
embeddingsEmbedding DataA data object containing the original text and its embedding vector.

VertexAI Embeddings

This component is a wrapper around Google Vertex AI Embeddings API.

Parameters

Inputs

NameTypeDescription
credentialsCredentialsThe default custom credentials to use.
locationStringThe default location to use when making API calls. Default: us-central1.
max_output_tokensIntegerThe token limit determines the maximum amount of text output from one prompt. Default: 128.
model_nameStringThe name of the Vertex AI large language model. Default: text-bison.
projectStringThe default GCP project to use when making Vertex API calls.
request_parallelismIntegerThe amount of parallelism allowed for requests issued to VertexAI models. Default: 5.
temperatureFloatTunes the degree of randomness in text generations. Should be a non-negative value. Default: 0.
top_kIntegerHow the model selects tokens for output. The next token is selected from the top k tokens. Default: 40.
top_pFloatTokens are selected from the most probable to least until the sum of their probabilities exceeds the top p value. Default: 0.95.
tuned_model_nameStringThe name of a tuned model. If provided, model_name is ignored.
verboseBooleanThis parameter controls the level of detail in the output. When set to True, it prints internal states of the chain to help debug. Default: False.

Outputs

NameTypeDescription
embeddingsEmbeddingsAn instance for generating embeddings using VertexAI.
Search