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

OllamaTextEmbedder

Embed strings, such as user queries, using Ollama models.

Key Features

  • Uses Ollama to run embedding models locally without external API dependencies.
  • Designed for query pipelines — embeds user queries for semantic search.
  • Returns both the embedding vector and request metadata.
  • Configurable timeout and generation options.
  • Requires a running Ollama instance with the embedding model pulled.

Configuration

  1. Drag the OllamaTextEmbedder component onto the canvas from the Component Library.
  2. Click the component to open the configuration panel.
  3. On the General tab:
    1. Enter the model name. The model must already be pulled in the running Ollama instance. The default is nomic-embed-text.
  4. Go to the Advanced tab to configure the Ollama URL and timeout.

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.

Compatible Models

Unless specified otherwise, the default embedding model is nomic-embed-text. See other pre-built models in Ollama's library. To load your own custom model, follow the instructions from Ollama.

Connections

OllamaTextEmbedder receives a text string (the user query) as input. It outputs an embedding (list of floats) and meta (request metadata). Connect its embedding output to an OpenSearchEmbeddingRetriever or other embedding retriever. Use the same model as the one used to embed documents in the document store. To embed documents in an index, use OllamaDocumentEmbedder instead.

Usage Example

This is an example of a query pipeline with OllamaTextEmbedder that receives a query to embed and then sends the embedded query to OpenSearchEmbeddingRetriever to find matching documents.

components:
OllamaTextEmbedder:
type: haystack_integrations.components.embedders.ollama.text_embedder.OllamaTextEmbedder
init_parameters:
model: nomic-embed-text
url: http://localhost:11434
generation_kwargs:
timeout: 120
OpenSearchEmbeddingRetriever:
type: haystack_integrations.components.retrievers.opensearch.embedding_retriever.OpenSearchEmbeddingRetriever
init_parameters:
filters:
top_k: 10
filter_policy: replace
custom_query:
raise_on_failure: true
efficient_filtering: true
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: ollama-embeddings-index
max_chunk_bytes: 104857600
embedding_dim: 768
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:
similarity: cosine

connections:
- sender: OllamaTextEmbedder.embedding
receiver: OpenSearchEmbeddingRetriever.query_embedding

max_runs_per_component: 100

metadata: {}

inputs:
query:
- OllamaTextEmbedder.text

outputs:
documents: OpenSearchEmbeddingRetriever.documents

Parameters

Inputs

ParameterTypeDefaultDescription
textstrText to be converted to an embedding.
generation_kwargsOptional[Dict[str, Any]]NoneOptional arguments to pass to the Ollama generation endpoint, such as temperature, top_p, etc. See the Ollama docs.

Outputs

ParameterTypeDefaultDescription
embeddingList[float]The embedding of the text.
metaDict[str, Any]Metadata about the request, including the model name.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
modelstrnomic-embed-textThe name of the model to use. The model should be available in the running Ollama instance.
urlstrhttp://localhost:11434The URL of a running Ollama instance.
generation_kwargsOptional[Dict[str, Any]]NoneOptional arguments to pass to the Ollama generation endpoint, such as temperature, top_p, and others. See the available arguments in Ollama docs.
timeoutint120The number of seconds before throwing a timeout error from the Ollama API.

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
textstrText to be converted to an embedding.
generation_kwargsOptional[Dict[str, Any]]NoneOptional arguments to pass to the Ollama generation endpoint, such as temperature, top_p, etc. See the Ollama docs.