Skip to main content

JinaTextEmbedder

A component for embedding strings using Jina AI models.

Basic Information

  • Type: haystack_integrations.components.embedders.jina.text_embedder.JinaTextEmbedder

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.

Overview

Work in Progress

Bear with us while we're working on adding pipeline examples and most common components connections.

A component for embedding strings using Jina AI models.

Usage example:

from haystack_integrations.components.embedders.jina import JinaTextEmbedder

# Make sure that the environment variable JINA_API_KEY is set

text_embedder = JinaTextEmbedder(task="retrieval.query")

text_to_embed = "I love pizza!"

print(text_embedder.run(text_to_embed))

# {'embedding': [0.017020374536514282, -0.023255806416273117, ...],
# 'meta': {'model': 'jina-embeddings-v3',
# 'usage': {'prompt_tokens': 4, 'total_tokens': 4}}}

Usage Example

components:
JinaTextEmbedder:
type: jina.src.haystack_integrations.components.embedders.jina.text_embedder.JinaTextEmbedder
init_parameters:

Parameters

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.