docs/versioned_docs/version-1.9.0/Components/components-embedding-models.mdx
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 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.
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.
:::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. :::
Add the Embedding Model core component to your flow, and then select your configured embedding model from the Embedding Model dropdown.
Add a Split Text component to your flow. This component splits text input into smaller chunks to be processed into embeddings.
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.
Connect the components:
To query the vector store, add Chat Input and Output components:
Click Playground, and then enter a search query to retrieve text chunks that are most semantically similar to your query.
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 />| Name | Display Name | Type | Description |
|---|---|---|---|
| provider | Model Provider | List | Input parameter. Select the embedding model provider. Models are configured globally in the Models pane. |
| model | Model Name | List | Input parameter. Select the embedding model to use. Options depend on the selected provider and are configured globally in the Models pane. |
| api_base | API Base URL | String | Input parameter. Base URL for the API. Leave empty for default. |
| dimensions | Dimensions | Integer | Input parameter. The number of dimensions for the output embeddings. |
| chunk_size | Chunk Size | Integer | Input parameter. The size of text chunks to process. Default: 1000. |
| request_timeout | Request Timeout | Float | Input parameter. Timeout for API requests. |
| max_retries | Max Retries | Integer | Input parameter. Maximum number of retry attempts. Default: 3. |
| show_progress_bar | Show Progress Bar | Boolean | Input parameter. Whether to display a progress bar during embedding generation. |
| model_kwargs | Model Kwargs | Dictionary | Input parameter. Additional keyword arguments to pass to the model. |
| embeddings | Embeddings | Embeddings | Output parameter. An instance for generating embeddings using the selected provider. |
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.
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>