Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

FastembedTextEmbedder

Embed strings using Fastembed embedding models. Use this component in query pipelines to transform user queries into vectors for embedding-based retrieval.

Key Features

  • Uses CPU-optimized embedding models from the Fastembed library.
  • Fast and lightweight — designed for production use without GPU requirements.
  • Supports a wide range of models from BAAI, Xenova, and others.
  • The embedding model must match the one used by FastembedDocumentEmbedder in the indexing pipeline.
Embedding Models in Query Pipelines and Indexes

The embedding model you use to embed documents in your indexing pipeline must be the same as the embedding model you use to embed the query in your query pipeline.

This means the embedders for your indexing and query pipelines must match. For example, if you use CohereDocumentEmbedder to embed your documents, you should use CohereTextEmbedder with the same model to embed your queries.

Configuration

  1. Drag the FastembedTextEmbedder component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Set the model to the Fastembed model you want to use (for example, BAAI/bge-small-en-v1.5). For a list of supported models, see the Fastembed documentation.
  4. Go to the Advanced tab to configure prefix, suffix, cache_dir, and threads.

Connections

FastembedTextEmbedder receives the user query as a text string, typically from the Input component. It outputs a float vector through its embedding output, which you connect to an embedding retriever.

Source Code

To check this component's source code, open fastembed_text_embedder.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  FastembedTextEmbedder:
type: haystack_integrations.components.embedders.fastembed.FastembedTextEmbedder
init_parameters:
model: BAAI/bge-small-en-v1.5
prefix: ""
suffix: ""
progress_bar: true

Using the Component in a Pipeline

# haystack-pipeline
components:
FastembedTextEmbedder:
type: haystack_integrations.components.embedders.fastembed.FastembedTextEmbedder
init_parameters:
model: BAAI/bge-small-en-v1.5

QdrantEmbeddingRetriever:
type: haystack_integrations.components.retrievers.qdrant.retriever.QdrantEmbeddingRetriever
init_parameters:
top_k: 10
document_store:
type: haystack_integrations.document_stores.qdrant.document_store.QdrantDocumentStore
init_parameters:
url: http://localhost:6333
index: documents

connections:
- sender: FastembedTextEmbedder.embedding
receiver: QdrantEmbeddingRetriever.query_embedding

max_runs_per_component: 100

metadata: {}

inputs:
query:
- FastembedTextEmbedder.text

Parameters

Inputs

ParameterTypeDescription
textstrThe text to embed.

Outputs

ParameterTypeDescription
embeddingList[float]The embedding of the text.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
modelstrBAAI/bge-small-en-v1.5The name of the Fastembed model to use. For a full list, see the Fastembed documentation.
cache_dirOptional[str]NoneThe directory to cache downloaded models. Defaults to the system cache directory.
threadsOptional[int]NoneThe number of threads for model inference. If not set, uses the available CPU count.
prefixstr""A string to add at the beginning of the text before embedding.
suffixstr""A string to add at the end of the text before embedding.
progress_barboolTrueWhether to show a progress bar during model loading.
parallelOptional[int]NoneThe number of parallel processes for batch processing.
local_files_onlyboolFalseWhether to use only locally cached models, without downloading from the internet.

Run Method Parameters

These are the parameters you can configure for the component's run() method. This means you can pass these parameters at query time through the API, in Playground, or when running a job. For details, see Modify Pipeline Parameters at Query Time.

ParameterTypeDefaultDescription
textstrThe text to embed.