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

NvidiaTextEmbedder

Embed strings, such as user queries, using NVIDIA models.

Key Features

  • Embeds strings (typically user queries) using NVIDIA models for semantic search.
  • Works with self-hosted models deployed with NVIDIA NIM or models hosted on the NVIDIA API Catalog.
  • For models that differentiate between query and document inputs, this component embeds the input as a query.
  • Use in query pipelines to transform a query into a vector.
  • For embedding documents in indexes, use NvidiaDocumentEmbedder.

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 NvidiaTextEmbedder 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. Use the same model as in NvidiaDocumentEmbedder in your indexing pipeline.
  4. Go to the Advanced tab to configure prefix, suffix, truncate, timeout, and api_url.

Connections

NvidiaTextEmbedder accepts a string through its text input. It outputs the embedding as a list of floats through its embedding output, plus usage metadata through its meta output.

Connect the Input component's query output to NvidiaTextEmbedder's text input. Then connect NvidiaTextEmbedder's embedding output to an embedding retriever's query_embedding input.

Source Code

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

Usage Examples

Basic Configuration

  NvidiaTextEmbedder:
type: haystack_integrations.components.embedders.nvidia.text_embedder.NvidiaTextEmbedder
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: ''

This is an example of a query pipeline with NvidiaTextEmbedder that receives a query, embeds it, and sends it to OpenSearchEmbeddingRetriever to find matching documents.

components:
NvidiaTextEmbedder:
type: haystack_integrations.components.embedders.nvidia.text_embedder.NvidiaTextEmbedder
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: ''
truncate:
timeout:
OpenSearchEmbeddingRetriever:
type: haystack_integrations.components.retrievers.opensearch.embedding_retriever.OpenSearchEmbeddingRetriever
init_parameters:
filters:
top_k: 10
filter_policy: replace
custom_query:
raise_on_failure: true
efficient_filtering: true
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

connections:
- sender: NvidiaTextEmbedder.embedding
receiver: OpenSearchEmbeddingRetriever.query_embedding

max_runs_per_component: 100

metadata: {}

inputs:
query:
- NvidiaTextEmbedder.text

outputs:
documents: OpenSearchEmbeddingRetriever.documents

Parameters

Inputs

ParameterTypeDescription
textstrThe text to embed.

Outputs

ParameterTypeDescription
embeddingList[float]The embedding of the text.
metaDict[str, Any]Metadata about the request, 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.
truncateOptional[Union[EmbeddingTruncateMode, str]]NoneSpecifies how inputs longer that 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
textstrThe text to embed.