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

NvidiaDocumentEmbedder

Calculate document embeddings using NVIDIA models. Document embedders are used to embed documents in your indexes.

Key Features

  • Embeds documents using NVIDIA models and stores the computed embedding in each document's embedding field.
  • Works with self-hosted models deployed with NVIDIA NIM or models hosted on the NVIDIA API Catalog.
  • Use in indexing pipelines to embed documents before storing them in a document store.
  • Use the same model as in NvidiaTextEmbedder in your query pipeline.
  • Configurable batch size, truncation, and progress bar.

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.

Configuration

  1. Drag the NvidiaDocumentEmbedder component onto the canvas from the Component Library.
  2. Click on the component to open the configuration panel.
  3. On the General tab:
    1. Connect Haystack Platform to your NVIDIA account on the Integrations page. For instructions, see Use NVIDIA Models.
    2. Select the embedding model.
  4. Go to the Advanced tab to configure prefix, suffix, batch_size, progress_bar, meta_fields_to_embed, embedding_separator, truncate, timeout, and api_url.

Connections

NvidiaDocumentEmbedder receives a list of documents through its documents input. It outputs the same documents with embeddings added through its documents output, plus usage metadata through its meta output.

Connect a converter (such as TextFileToDocument) or DocumentSplitter output to NvidiaDocumentEmbedder's documents input. Then connect its documents output to DocumentWriter.

Source Code

To check this component's source code, open document_embedder.py in the Haystack Core Integrations repository.

Usage Examples

Basic Configuration

  NvidiaDocumentEmbedder:
type: haystack_integrations.components.embedders.nvidia.document_embedder.NvidiaDocumentEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- NVIDIA_API_KEY
strict: true
model: nvidia/nv-embedqa-e5-v5
api_url: https://integrate.api.nvidia.com/v1
prefix: ''
suffix: ''
batch_size: 32
progress_bar: true
embedding_separator: "\n"

In this index, NvidiaDocumentEmbedder receives documents from DocumentSplitter, embeds them, and sends them to DocumentWriter. The index uses the nvidia/nv-embedqa-e5-v5 model, so NvidiaTextEmbedder in the query pipeline must use the same model.

components:
TextFileToDocument:
type: haystack.components.converters.txt.TextFileToDocument
init_parameters:
encoding: utf-8
store_full_path: false
DocumentSplitter:
type: haystack.components.preprocessors.document_splitter.DocumentSplitter
init_parameters:
split_by: word
split_length: 200
split_overlap: 0
split_threshold: 0
splitting_function:
NvidiaDocumentEmbedder:
type: haystack_integrations.components.embedders.nvidia.document_embedder.NvidiaDocumentEmbedder
init_parameters:
api_key:
type: env_var
env_vars:
- NVIDIA_API_KEY
strict: true
model: nvidia/nv-embedqa-e5-v5
api_url: https://integrate.api.nvidia.com/v1
prefix: ''
suffix: ''
batch_size: 32
progress_bar: true
meta_fields_to_embed:
embedding_separator: "\n"
truncate:
timeout:
DocumentWriter:
type: haystack.components.writers.document_writer.DocumentWriter
init_parameters:
document_store:
type: haystack_integrations.document_stores.opensearch.document_store.OpenSearchDocumentStore
init_parameters:
hosts:
index: nvidia-embeddings-index
max_chunk_bytes: 104857600
embedding_dim: 1024
return_embedding: false
method:
mappings:
settings:
create_index: true
http_auth:
use_ssl:
verify_certs:
timeout:
similarity: cosine
policy: NONE

connections:
- sender: TextFileToDocument.documents
receiver: DocumentSplitter.documents
- sender: DocumentSplitter.documents
receiver: NvidiaDocumentEmbedder.documents
- sender: NvidiaDocumentEmbedder.documents
receiver: DocumentWriter.documents

max_runs_per_component: 100

metadata: {}

inputs:
files:
- TextFileToDocument.sources

Parameters

Inputs

ParameterTypeDescription
documentsList[Document]A list of Documents to embed.

Outputs

ParameterTypeDescription
documentsList[Document]Documents with their embeddings added to the embedding field.
metaDict[str, Any]Metadata related to the embedding process, including usage statistics.

Init Parameters

These are the parameters you can configure in Pipeline Builder:

ParameterTypeDefaultDescription
modelOptional[str]NoneEmbedding model to use. If no specific model along with locally hosted API URL is provided, the system defaults to the available model found using /models API.
api_keyOptional[Secret]Secret.from_env_var('NVIDIA_API_KEY')API key for the NVIDIA NIM.
api_urlstros.getenv('NVIDIA_API_URL', DEFAULT_API_URL)Custom API URL for the NVIDIA NIM. Format for API URL is http://host:port
prefixstrA string to add to the beginning of each text.
suffixstrA string to add to the end of each text.
batch_sizeint32Number of Documents to encode at once. Cannot be greater than 50.
progress_barboolTrueWhether to show a progress bar or not.
meta_fields_to_embedOptional[List[str]]NoneList of meta fields that should be embedded along with the Document text.
embedding_separatorstr\nSeparator used to concatenate the meta fields to the Document text.
truncateOptional[Union[EmbeddingTruncateMode, str]]NoneSpecifies how inputs longer than the maximum token length should be truncated. If None the behavior is model-dependent, see the official documentation for more information.
timeoutOptional[float]NoneTimeout for request calls, if not set it is inferred from the NVIDIA_TIMEOUT environment variable or set to 60 by default.

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
documentsList[Document]A list of Documents to embed.