Step 1: Embed a product corpus
NeMo Retriever embeddings
NVIDIA's llama-nemotron-embed-1b-v2 is a 2048-dim text embedding model optimized for retrieval. The NIM API follows the OpenAI /v1/embeddings spec, but adds an input_type parameter you should always set:
input_type: "passage"when indexing documentsinput_type: "query"when embedding a user query
This asymmetry matters — using the wrong one degrades recall by ~10–20%.
Your task
Add to main.py:
- Build
CORPUS: at least 5 short product descriptions (1–2 sentences each). Mix categories: furniture, electronics, kitchenware. - Call the embedding endpoint with
input_type="passage"and store the result as a numpy arraypassage_embeddingsof shape(N, 2048). - Print the shape.
main.py, the file you edit16 lines
from openai import OpenAI
import numpy as np
client = OpenAI(base_url="http://nim-proxy.labs.svc:8080/v1", api_key="nvapi-inject")
EMBED_MODEL = "nvidia/llama-nemotron-embed-vl-1b-v2"
# TODO: define CORPUS with >=5 product descriptions
CORPUS = [
# "Product N: description ...",
]
# TODO: embed with input_type="passage" and store as numpy array
passage_embeddings = ______
print('corpus size:', len(CORPUS))
print('embedding shape:', passage_embeddings.shape)