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
FastembedDocumentEmbedderin the indexing pipeline.
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
- Drag the
FastembedTextEmbeddercomponent onto the canvas from the Component Library. - Click on the component to open the configuration panel.
- On the General tab:
- Set the
modelto 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.
- Set the
- Go to the Advanced tab to configure
prefix,suffix,cache_dir, andthreads.
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
| Parameter | Type | Description |
|---|---|---|
text | str | The text to embed. |
Outputs
| Parameter | Type | Description |
|---|---|---|
embedding | List[float] | The embedding of the text. |
Init Parameters
These are the parameters you can configure in Pipeline Builder:
| Parameter | Type | Default | Description |
|---|---|---|---|
model | str | BAAI/bge-small-en-v1.5 | The name of the Fastembed model to use. For a full list, see the Fastembed documentation. |
cache_dir | Optional[str] | None | The directory to cache downloaded models. Defaults to the system cache directory. |
threads | Optional[int] | None | The number of threads for model inference. If not set, uses the available CPU count. |
prefix | str | "" | A string to add at the beginning of the text before embedding. |
suffix | str | "" | A string to add at the end of the text before embedding. |
progress_bar | bool | True | Whether to show a progress bar during model loading. |
parallel | Optional[int] | None | The number of parallel processes for batch processing. |
local_files_only | bool | False | Whether 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
text | str | The text to embed. |
Related Information
Was this page helpful?