Skip to main content

Embedding Model

Embedding Model components in Langflow generate text embeddings using a specified Large Language Model (LLM).

Langflow includes an Embedding Model core component that has built-in support for some LLMs. Alternatively, you can use any additional Embedding Model component in place of the core Embedding Model component.

The built-in LLMs are appropriate for most text-based embedding model use cases in Langflow.

Use Embedding Model components in a flow

Use Embedding Model components anywhere you need to generate embeddings in a flow.

This example shows how to use an Embedding Model component in a flow to create a semantic search system. This flow loads a text file, splits the text into chunks, generates embeddings for each chunk, and then loads the chunks and embeddings into a vector store. The Input and Output components allow a user to query the vector store through a chat interface.

A semantic search flow that uses Embedding Model, File, Split Text, Chroma DB, Chat Input, and Chat Output components

tip

This example uses the Embedding Model core component.

To use another model, you can replace the Embedding Model core component with any additional Embedding Model component in these steps. However, your component might have different parameters than the Embedding Model core component.

  1. Create a flow, add a File component, and then select a file containing text data, such as a PDF, that you can use to test the flow.

  2. Add an Embedding Model component, and then provide a valid OpenAI API key.

    By default, the Embedding Model component uses an OpenAI model. If you want to use a different model, edit the Model Name, and API Key fields accordingly. Or, see Additional Embedding Model components for other components that you can use in place of the Embedding Model core component.

    You can enter component API keys directly or use Langflow global variables to reference your API keys.

  3. Add a Split Text component to your flow. This component splits text input into smaller chunks to be processed into embeddings.

  4. Add a Vector Store component, such as the Chroma DB component, to your flow, and then configure the component to connect to your vector store database. This component stores the generated embeddings so they can be used for similarity search.

  5. Connect the components:

    • Connect the File component's Loaded Files output to the Split Text component's Data or DataFrame input.
    • Connect the Split Text component's Chunks output to the Vector Store component's Ingest Data input.
    • Connect the Embedding Model component's Embeddings output to the Vector Store component's Embedding input.
  6. To query the vector store, add Chat Input and Output components:

    • Connect the Chat Input component to the Vector Store component's Search Query input.
    • Connect the Vector Store component's Search Results output to the Chat Output component.
  7. Click Playground, and then enter a search query to retrieve text chunks that are most semantically similar to your query.

Embedding Model

Some Embedding Model component input parameters are hidden by default in the visual editor. You can toggle parameters through the Controls in the component's header menu.

NameDisplay NameTypeDescription
providerModel ProviderListInput parameter. Select the embedding model provider.
modelModel NameListInput parameter. Select the embedding model to use.
api_keyOpenAI API KeySecret[String]Input parameter. The API key required for authenticating with the provider.
api_baseAPI Base URLStringInput parameter. Base URL for the API. Leave empty for default.
dimensionsDimensionsIntegerInput parameter. The number of dimensions for the output embeddings.
chunk_sizeChunk SizeIntegerInput parameter. The size of text chunks to process. Default: 1000.
request_timeoutRequest TimeoutFloatInput parameter. Timeout for API requests.
max_retriesMax RetriesIntegerInput parameter. Maximum number of retry attempts. Default: 3.
show_progress_barShow Progress BarBooleanInput parameter. Whether to display a progress bar during embedding generation.
model_kwargsModel KwargsDictionaryInput parameter. Additional keyword arguments to pass to the model.
embeddingsEmbeddingsEmbeddingsOutput parameter. An instance for generating embeddings using the selected provider.

Additional Embedding Model components

If your provider or model isn't supported by the Embedding Model core component, additional single-provider Embedding Model components are available in the Bundles section of the Components menu.

Legacy embedding components

The following components are legacy components. You can still use them in your flows, but they are no longer maintained and they can be removed in future releases.

Embedding Similarity

The Embedding Similarity component is replaced by built-in similarity search functionality in Vector Store components.

This component calculates similarity scores for two embedding vectors.

It accepts the following parameters:

NameDisplay NameInfo
embedding_vectorsEmbedding VectorsInput parameter. A list containing exactly two data objects with embedding vectors to compare.
similarity_metricSimilarity MetricInput parameter. Select the similarity metric to use. Options: "Cosine Similarity", "Euclidean Distance", "Manhattan Distance".
similarity_dataSimilarity DataOutput parameter. A data object containing the computed similarity score and additional information.
Text Embedder

The Text Embedder component is replaced by the Embedding Model component.

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

It accepts the following parameters:

NameDisplay NameInfo
embedding_modelEmbedding ModelInput parameter. The embedding model to use for generating embeddings.
messageMessageInput parameter. The message for which to generate embeddings.
embeddingsEmbedding DataOutput parameter. A data object containing the original text and its embedding vector.
Search