Back to Langflow

Embedding Model

docs/versioned_docs/version-1.8.0/Components/components-embedding-models.mdx

1.10.0.dev205.6 KB
Original Source

import Icon from "@site/src/components/icon"; import PartialGlobalModelProviders from '@site/docs/_partial-global-model-providers.mdx';

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 in place of the Embedding Model core component.

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.

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

  2. <PartialGlobalModelProviders />

    :::tip My preferred provider or model isn't listed If your preferred embedding model provider or model isn't available in Langflow's global <Icon name="BrainCog" aria-hidden="true" /> Models, you can use any additional embedding models in place of the core component.

    Browse <Icon name="Blocks" aria-hidden="true" /> Bundles or <Icon name="Search" aria-hidden="true" /> Search for your preferred provider to find additional embedding models, such as the Hugging Face Embeddings Inference component. :::

  3. Add the Embedding Model core component to your flow, and then select your configured embedding model from the Embedding Model dropdown.

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

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

  6. Connect the components:

    • Connect the Read 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.
  7. 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.
  8. Click Playground, and then enter a search query to retrieve text chunks that are most semantically similar to your query.

Embedding Model parameters

The following parameters are for the Embedding Model core component. Other embedding model components can have additional or different parameters.

import PartialParams from '@site/docs/_partial-hidden-params.mdx';

<PartialParams />
NameDisplay NameTypeDescription
providerModel ProviderListInput parameter. Select the embedding model provider. Models are configured globally in the Models pane.
modelModel NameListInput parameter. Select the embedding model to use. Options depend on the selected provider and are configured globally in the Models pane.
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 models

If your provider or model isn't available in Langflow's global <Icon name="BrainCog" aria-hidden="true" /> Models, you can replace the Embedding Model core component with any other component that generates embeddings.

To find additional embedding model components, browse <Icon name="Blocks" aria-hidden="true" /> Bundles or <Icon name="Search" aria-hidden="true" /> Search for your preferred provider.

Pair models with vector stores

import PartialVectorRagBlurb from '@site/docs/_partial-vector-rag-blurb.mdx';

<PartialVectorRagBlurb /> <details> <summary>Example: Vector search flow</summary>

import PartialVectorRagFlow from '@site/docs/_partial-vector-rag-flow.mdx';

<PartialVectorRagFlow /> </details>