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

JinaTextEmbedder

Embeds a query string using Jina AI models and returns a vector for use in semantic search.

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.

Key Features

  • Embeds query strings using Jina AI embedding models.
  • Returns the query as a vector for use with embedding retrievers.
  • Supports multiple task types optimized for different use cases, including retrieval.query.
  • Configurable prefix and suffix text for instruction-following models.
  • Adjustable embedding dimensions with minimal performance impact using MRL.
  • Supports late chunking for contextual embeddings (jina-embeddings-v3 only).

Configuration

Authentication

Create a secret with your Jina API key. Use JINA_API_KEY as the secret key. For instructions, see Create Secrets. Get your API key from Jina AI.

  1. Drag the JinaTextEmbedder 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 name of the Jina embedding model to use, such as jina-embeddings-v3. For available models, see the Jina documentation.
  4. Go to the Advanced tab to configure the API key, prefix and suffix text, task type, embedding dimensions, and late chunking.

Connections

JinaTextEmbedder accepts a text string as input and outputs an embedding (list of floats) and a meta dictionary with model name and usage statistics.

Connect the Input component to its text input. Connect its embedding output to an embedding retriever, such as InMemoryEmbeddingRetriever, to find semantically similar documents.

For embedding documents in indexes, use JinaDocumentEmbedder instead.

Usage Example

This example shows a query pipeline that embeds a user query using Jina and retrieves relevant documents.

components:
JinaTextEmbedder:
type: haystack_integrations.components.embedders.jina.text_embedder.JinaTextEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- JINA_API_KEY
strict: false
model: jina-embeddings-v3
task: retrieval.query
InMemoryEmbeddingRetriever:
type: haystack.components.retrievers.in_memory.embedding_retriever.InMemoryEmbeddingRetriever
init_parameters:
document_store:
type: haystack.document_stores.in_memory.document_store.InMemoryDocumentStore
init_parameters:
bm25_tokenization_regex: (?u)\b\w\w+\b
bm25_algorithm: BM25L
bm25_parameters:
embedding_similarity_function: dot_product
index: 'default'
async_executor:
top_k: 5

connections:
- sender: JinaTextEmbedder.embedding
receiver: InMemoryEmbeddingRetriever.query_embedding

max_runs_per_component: 100

metadata: {}

inputs:
query:
- JinaTextEmbedder.text
- InMemoryEmbeddingRetriever.query

outputs:
documents: InMemoryEmbeddingRetriever.documents

Parameters

Inputs

ParameterTypeDefaultDescription
textstrThe string to embed.

Outputs

ParameterTypeDefaultDescription
embeddingList[float]A dictionary with following keys: - embedding: The embedding of the input string. - meta: A dictionary with metadata including the model name and usage statistics.
metaDict[str, Any]A dictionary with following keys: - embedding: The embedding of the input string. - meta: A dictionary with metadata including the model name and usage statistics.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
api_keySecretSecret.from_env_var('JINA_API_KEY')The Jina API key. It can be explicitly provided or automatically read from the environment variable JINA_API_KEY (recommended).
modelstrjina-embeddings-v3The name of the Jina model to use. Check the list of available models on Jina documentation.
prefixstrA string to add to the beginning of each text.
suffixstrA string to add to the end of each text.
taskOptional[str]NoneThe downstream task for which the embeddings will be used. The model will return the optimized embeddings for that task. Check the list of available tasks on Jina documentation.
dimensionsOptional[int]NoneNumber of desired dimension. Smaller dimensions are easier to store and retrieve, with minimal performance impact thanks to MRL.
late_chunkingOptional[bool]NoneA boolean to enable or disable late chunking. Apply the late chunking technique to leverage the model's long-context capabilities for generating contextual chunk embeddings. The support of task and late_chunking parameters is only available for jina-embeddings-v3.

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 string to embed.