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

NvidiaDocumentEmbedder

Embeds documents using NVIDIA models and stores results in each document's embedding field 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 documents using NVIDIA embedding models, including self-hosted NVIDIA NIM models and NVIDIA API Catalog models.
  • Stores computed embeddings in each document's embedding field.
  • Configurable batch size (up to 50) for efficient processing of large document collections.
  • Optionally embeds metadata fields alongside document text.
  • Configurable truncation mode for inputs that exceed the maximum token length.

Configuration

Authentication

Connect Haystack Platform to NVIDIA on the Integrations page. For detailed instructions, see Use NVIDIA Models.

  1. Drag the NvidiaDocumentEmbedder 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 NVIDIA embedding model to use, such as nvidia/nv-embedqa-e5-v5.
  4. Go to the Advanced tab to configure the API key, API URL, batch size, metadata fields to embed, embedding separator, and truncation mode.

Connections

NvidiaDocumentEmbedder receives a list of documents as input and outputs those documents with embeddings stored in their embedding field, along with a meta dictionary with usage statistics.

Connect DocumentSplitter or another preprocessor to its documents input. Connect its documents output to DocumentWriter to store the embedded documents.

Use the same embedding model in NvidiaTextEmbedder in your query pipeline to ensure consistent results.

Usage Example

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

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

Outputs

ParameterTypeDefaultDescription
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.