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

FastembedDocumentEmbedder

Compute embeddings for a list of documents using Fastembed embedding models. Use this component in indexing pipelines to prepare documents 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.
  • Stores the computed embedding in each document's embedding field.
  • Supports adding metadata fields to the text before embedding.
  • Configurable batch size for efficient processing.
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 FastembedDocumentEmbedder 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 batch_size, meta_fields_to_embed, embedding_separator, prefix, and suffix.

Connections

FastembedDocumentEmbedder receives a list of documents, typically from a document splitter or converter. It outputs the same documents with embeddings added to their embedding field, ready to be sent to a DocumentWriter.

Source Code

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

Usage Examples

Basic Configuration

  FastembedDocumentEmbedder:
type: haystack_integrations.components.embedders.fastembed.FastembedDocumentEmbedder
init_parameters:
model: BAAI/bge-small-en-v1.5
batch_size: 256

Using the Component in a Pipeline

# haystack-pipeline
components:
FastembedDocumentEmbedder:
type: haystack_integrations.components.embedders.fastembed.FastembedDocumentEmbedder
init_parameters:
model: BAAI/bge-small-en-v1.5
batch_size: 256
meta_fields_to_embed:
embedding_separator: "\n"

document_writer:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
document_store:
type: haystack_integrations.document_stores.qdrant.document_store.QdrantDocumentStore
init_parameters:
url: http://localhost:6333
index: documents

connections:
- sender: FastembedDocumentEmbedder.documents
receiver: document_writer.documents

max_runs_per_component: 100

metadata: {}

Parameters

Inputs

ParameterTypeDescription
documentsList[Document]A list of documents to embed.

Outputs

ParameterTypeDescription
documentsList[Document]The documents with their embedding field populated.

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.
threadsOptional[int]NoneThe number of threads for model inference.
prefixstr""A string to add at the beginning of each document's text before embedding.
suffixstr""A string to add at the end of each document's text before embedding.
batch_sizeint256The number of documents to process in each batch.
progress_barboolTrueWhether to show a progress bar during embedding.
parallelOptional[int]NoneThe number of parallel processes for batch processing.
local_files_onlyboolFalseWhether to use only locally cached models.
meta_fields_to_embedOptional[List[str]]NoneA list of document metadata field names to include in the text before embedding.
embedding_separatorstr"\n"The separator used to join the document text and metadata fields.

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
documentsList[Document]A list of documents to embed.