JinaDocumentEmbedder
A component for computing Document embeddings using Jina AI models.
Basic Information
- Type:
haystack_integrations.components.embedders.jina.document_embedder.JinaDocumentEmbedder
Inputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | A list of Documents to embed. |
Outputs
| Parameter | Type | Default | Description |
|---|---|---|---|
| documents | List[Document] | A dictionary with following keys: - documents: List of Documents, each with an embedding field containing the computed embedding. - meta: A dictionary with metadata including the model name and usage statistics. | |
| meta | Dict[str, Any] | A dictionary with following keys: - documents: List of Documents, each with an embedding field containing the computed embedding. - 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 computing Document embeddings using Jina AI models.
The embedding of each Document is stored in the embedding field of the Document.
Usage example:
from haystack import Document
from haystack_integrations.components.embedders.jina import JinaDocumentEmbedder
# Make sure that the environment variable JINA_API_KEY is set
document_embedder = JinaDocumentEmbedder(task="retrieval.query")
doc = Document(content="I love pizza!")
result = document_embedder.run([doc])
print(result['documents'][0].embedding)
# [0.017020374536514282, -0.023255806416273117, ...]
Usage Example
components:
JinaDocumentEmbedder:
type: jina.src.haystack_integrations.components.embedders.jina.document_embedder.JinaDocumentEmbedder
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. |
| 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. | |
| batch_size | int | 32 | Number of Documents to encode at once. |
| progress_bar | bool | True | Whether to show a progress bar or not. Can be helpful to disable in production deployments to keep the logs clean. |
| meta_fields_to_embed | Optional[List[str]] | None | List of meta fields that should be embedded along with the Document text. |
| embedding_separator | str | \n | Separator used to concatenate the meta fields to the Document 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 |
|---|---|---|---|
| documents | List[Document] | A list of Documents to embed. |
Was this page helpful?