Skip to main content

NVIDIA NIM embeddings + Moorcheh

This integration uses the NVIDIA NIM OpenAI-compatible Embeddings API with nvidia/llama-nemotron-embed-vl-1b-v2 and Moorcheh vector namespaces to store and search vectors with ITS ranking. The model outputs 2048-dimensional vectors (model reference). For this model you must set input_type: use passage when embedding content you index, and query when embedding search strings—mixing them hurts retrieval quality.

Architecture

Embedding generation

POST https://integrate.api.nvidia.com/v1/embeddings with model, input, and input_type

Vector storage

Store vectors in Moorcheh vector namespaces

Semantic retrieval

Embed the query with input_type: query and run vector search

Authentication

Authorization: Bearer your NVIDIA API key (NVIDIA API Catalog)

Prerequisites

Or explicitly:

.env file

Do not commit API keys. If a key is exposed, rotate it in the NVIDIA dashboard and update your local .env.

input_type (passage vs query)

The NIM inference reference states that using the wrong mode can significantly reduce retrieval accuracy.

Vector dimensions

nvidia/llama-nemotron-embed-vl-1b-v2 outputs 2048 dimensions per text. Set Moorcheh vector_dimension to 2048 for the namespace.

End-to-end example

The following example loads keys from .env, embeds passages and a query through the NVIDIA embeddings endpoint, uploads vectors to Moorcheh, and runs similarity search.

Runnable demo script

See integrations/nvidia/nvidia_moorcheh_demo.py. Run from the repo root (or set PYTHONPATH as needed):

Important notes

nvidia/llama-nemotron-embed-vl-1b-v2 is 2048 dimensions. Create the Moorcheh namespace with vector_dimension=2048.
Use passage for stored chunks and query for search queries, per the NIM API schema.
Include text on each uploaded vector so search results can return the original chunk.
You can also use an OpenAI-compatible client with base_url=https://integrate.api.nvidia.com/v1 and the same model and input_type fields; the example above uses requests for clarity.

Troubleshooting

  • 401 / auth errors: Verify NVIDIA_API_KEY and Authorization: Bearer format.
  • Dimension mismatch: Namespace must be 2048 for this model’s default output.
  • Low relevance: Check input_type (passage at index, query at search), chunking, threshold, and top_k.