DocumentationAPI Reference📓 Tutorials🧑‍🍳 Cookbook🤝 Integrations💜 Discord🎨 Studio (Waitlist)
Documentation

Embedders

Embedders in Haystack transform texts or Documents into vector representations using pre-trained models. You can then use the embeddings in your pipeline for tasks like question answering, information retrieval, and more.

The embeddings produced by Haystack embedders are fixed-length vectors. They capture contextual information and semantic relationships within the text. The primary goal of embeddings is to transform text into a format the language model can understand and process in a more nuanced and contextually aware way.

Text and Document Embedders

There are two types of Embedders: text and document.

Text Embedders work with text strings and are most often used at the beginning of query pipelines to convert query text into vectors and send it to a Retriever.

Document Embedders embed Document objects and are most often used in indexing pipelines, after Converters, and before a DocumentWriter.

You must use the same embedding model for text and documents. This means that if you use CohereDocumentEmbedder in your indexing pipeline, you must then use CohereTextEmbedder with the same model in your query pipeline.

These are the Embedders available in Haystack:

EmbedderDescription
AmazonBedrockTextEmbedderComputes embeddings for text (such as a query) using models through Amazon Bedrock API.
AmazonBedrockDocumentEmbedderComputes embeddings for documents using models through Amazon Bedrock API.
AzureOpenAITextEmbedderComputes embeddings for text (such as a query) using OpenAI models deployed through Azure.
AzureOpenAIDocumentEmbedderComputes embeddings for documents using OpenAI models deployed through Azure.
CohereTextEmbedderEmbeds a simple string (such as a query) with a Cohere model. Requires an API key from Cohere
CohereDocumentEmbedderEmbeds a list of documents with a Cohere model. Requires an API key from Cohere.
FastembedTextEmbedderComputes the embeddings of a string using embedding models supported by Fastembed.
FastembedDocumentEmbedderComputes the embeddings of a list of documents using the models supported by Fastembed.
FastembedSparseTextEmbedderEmbeds a simple string (such as a query) into a sparse vector using the models supported by Fastembed.
FastembedSparseDocumentEmbedderEnriches a list of documents with their sparse embeddings using the models supported by Fastembed.
HuggingFaceAPIDocumentEmbedderComputes document embeddings using various Hugging Face APIs.
HuggingFaceAPITextEmbedderEmbeds strings using various Hugging Face APIs.
HuggingFaceTEIDocumentEmbedderComputes embeddings for documents using the TEI library.
HuggingFaceTEITextEmbedderCmputes embeddings for text using the TEI library.
JinaTextEmbedderEmbeds a simple string (such as a query) with a Jina AI Embeddings model. Requires an API key from Jina AI.
JinaDocumentEmbedderEmbeds a list of documents with a Jina AI Embeddings model. Requires an API key from Jina AI.
MistralTextEmbedderTransforms a string into a vector using the Mistral API and models.
MistralDocumentEmbedderComputes the embeddings of a list of documents using the Mistral API and models.
NvidiaTextEmbedderEmbeds a simple string (such as a query) into a vector.
NvidiaDocumentEmbedderEnriches the metadata of documents with an embedding of their content.
OllamaTextEmbedderComputes the embeddings of a string using embedding models compatible with the Ollama Library.
OllamaDocumentEmbedderComputes the embeddings of a list of documents using embedding models compatible with the Ollama Library.
OpenAIDocumentEmbedderEmbeds a list of documents with an OpenAI embedding model. Requires an API key from an active OpenAI account.
OpenAITextEmbedderEmbeds a simple string (such as a query) with an OpenAI embedding model. Requires an API key from an active OpenAI account.
OptimumTextEmbedderEmbeds text using models loaded with the Hugging Face Optimum library.
OptimumDocumentEmbedderComputes documents’ embeddings using models loaded with the Hugging Face Optimum library.
SentenceTransformersTextEmbedderEmbeds a simple string (such as a query) using a Sentence Transformer model.
SentenceTransformersDocumentEmbedderEmbeds a list of documents with a Sentence Transformer model.

Related Links

See the parameters details in our API reference: