JinaTextEmbedder
A component for embedding strings using Jina AI models.
Basic Information
- Type:
haystack_integrations.components.embedders.jina.text_embedder.JinaTextEmbedder
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| text | str | The string to embed. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| embedding | List[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. | |
| meta | Dict[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:
| Parameter | Type | Default | Description |
|---|---|---|---|
| api_key | Secret | Secret.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). |
| model | str | jina-embeddings-v3 | The name of the Jina model to use. Check the list of available models on Jina documentation. |
| prefix | str | A string to add to the beginning of each text. | |
| suffix | str | A string to add to the end of each text. | |
| task | Optional[str] | None | The 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. |
| dimensions | Optional[int] | None | Number of desired dimension. Smaller dimensions are easier to store and retrieve, with minimal performance impact thanks to MRL. |
| late_chunking | Optional[bool] | None | A 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.
| Parameter | Type | Default | Description |
|---|---|---|---|
| text | str | The string to embed. |
Was this page helpful?