Views
No views yet
MODEL_ID with that path. For vLLM online serving from a local checkpoint, use the local checkpoint example.MODEL_ID = "nvidia/Nemotron-3-Embed-1B-BF16"query: prefix for queries and the passage: prefix for documents. Embeddings are L2-normalized, so dot product and cosine similarity are equivalent. The output tables use q[i] for queries and d[i] for documents. Scores are rounded to four decimals. Exact values can vary by runtime and package version.5.2.0 and above. The examples also require a CUDA-enabled PyTorch installation that matches your driver and CUDA environment.pip install --upgrade torch--index-url argument. Use that CUDA-specific index URL when the default PyPI wheel does not match your CUDA environment.pip install --upgrade "transformers>=5.2.0" "sentence-transformers>=5.4.1"nvcr.io/nvidia/pytorch:26.06-py3 with the container-provided Torch and CUDA stack. Inside NVIDIA PyTorch containers, do not upgrade Torch. Install only the missing packages:pip install --upgrade "transformers>=5.2.0" "sentence-transformers>=5.4.1"nvcr.io/nvidia/pytorch:26.06-py3 container includes flash-attn, so the snippets use FlashAttention-2 by default. If your environment does not have FlashAttention-2, set attn_implementation or ATTN_IMPLEMENTATION to sdpa.1import torch
2from sentence_transformers import SentenceTransformer
3
4MODEL_ID = "nvidia/Nemotron-3-Embed-1B-BF16"
5
6model = SentenceTransformer(
7 MODEL_ID,
8 device="cuda",
9 model_kwargs={
10 "dtype": torch.bfloat16,
11 "attn_implementation": "flash_attention_2",
12 },
13)
14model.max_seq_length = 32768
15
16QUERIES = [
17 "Write a Python function that counts the frequency of each element in a list of lists.",
18 "Write a function that orders a dictionary with tuple keys by the product of each key's tuple values.",
19 "What symptoms and common triggers help distinguish eczema from other inflammatory skin conditions?",
20 "How can someone reduce exposure to pollen during allergy season?",
21]
22
23DOCUMENTS = [
24 "def frequency_lists(list1):\n flattened = [item for sublist in list1 for item in sublist]\n counts = {}\n for item in flattened:\n if item in counts:\n counts[item] += 1\n else:\n counts[item] = 1\n return counts",
25 "def sort_dict_item(test_dict):\n return {key: test_dict[key] for key in sorted(test_dict.keys(), key=lambda ele: ele[0] * ele[1])}",
26 "Eczema commonly causes itchy, dry, inflamed patches of skin. The affected areas may look red, scaly, cracked, or darker than the surrounding skin depending on skin tone. Symptoms can flare after exposure to irritants, allergens, stress, or changes in weather.",
27 "People with pollen allergy can reduce exposure by staying indoors on dry, windy days, avoiding early-morning outdoor activity, and going outside after rain when pollen levels are lower. They should check pollen forecasts, close windows and doors when counts are high, and consider starting allergy medication before symptoms begin if high pollen is expected. After being outside, showering, changing clothes, avoiding outdoor laundry drying, and wearing a face mask for yard work can help limit pollen contact.",
28]
29query_embeddings = model.encode_query(QUERIES, batch_size=8, convert_to_tensor=True)
30document_embeddings = model.encode_document(DOCUMENTS, batch_size=8, convert_to_tensor=True)
31
32scores = model.similarity(query_embeddings, document_embeddings)
33print("Similarity scores:")
34print(f"{'':>4}" + "".join(f"d[{i}]".rjust(10) for i in range(scores.shape[1])))
35for query_index, row in enumerate(scores):
36 print(f"q[{query_index}]" + "".join(f"{score.item():>10.4f}" for score in row))1Similarity scores:
2 d[0] d[1] d[2] d[3]
3q[0] 0.8125 0.0255 0.0005 -0.0312
4q[1] 0.0447 0.6484 -0.0520 0.0386
5q[2] -0.0095 -0.0410 0.6484 0.1006
6q[3] -0.0216 0.0214 0.1211 0.77341import torch
2import torch.nn.functional as F
3from transformers import AutoModel, AutoTokenizer
4
5MODEL_ID = "nvidia/Nemotron-3-Embed-1B-BF16"
6MAX_LENGTH = 32768
7BATCH_SIZE = 8
8DTYPE = torch.bfloat16
9ATTN_IMPLEMENTATION = "flash_attention_2"
10
11QUERIES = [
12 "Write a Python function that counts the frequency of each element in a list of lists.",
13 "Write a function that orders a dictionary with tuple keys by the product of each key's tuple values.",
14 "What symptoms and common triggers help distinguish eczema from other inflammatory skin conditions?",
15 "How can someone reduce exposure to pollen during allergy season?",
16]
17
18DOCUMENTS = [
19 "def frequency_lists(list1):\n flattened = [item for sublist in list1 for item in sublist]\n counts = {}\n for item in flattened:\n if item in counts:\n counts[item] += 1\n else:\n counts[item] = 1\n return counts",
20 "def sort_dict_item(test_dict):\n return {key: test_dict[key] for key in sorted(test_dict.keys(), key=lambda ele: ele[0] * ele[1])}",
21 "Eczema commonly causes itchy, dry, inflamed patches of skin. The affected areas may look red, scaly, cracked, or darker than the surrounding skin depending on skin tone. Symptoms can flare after exposure to irritants, allergens, stress, or changes in weather.",
22 "People with pollen allergy can reduce exposure by staying indoors on dry, windy days, avoiding early-morning outdoor activity, and going outside after rain when pollen levels are lower. They should check pollen forecasts, close windows and doors when counts are high, and consider starting allergy medication before symptoms begin if high pollen is expected. After being outside, showering, changing clothes, avoiding outdoor laundry drying, and wearing a face mask for yard work can help limit pollen contact.",
23]
24
25def average_pool(last_hidden_state: torch.Tensor, attention_mask: torch.Tensor) -> torch.Tensor:
26 last_hidden = last_hidden_state.masked_fill(~attention_mask[..., None].bool(), 0.0)
27 return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
28
29if not torch.cuda.is_available():
30 raise RuntimeError("CUDA is required for practical BF16 inference.")
31
32device = torch.device("cuda")
33
34tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, padding_side="left")
35if tokenizer.pad_token is None:
36 tokenizer.pad_token = tokenizer.eos_token
37
38model = AutoModel.from_pretrained(
39 MODEL_ID,
40 dtype=DTYPE,
41 attn_implementation=ATTN_IMPLEMENTATION,
42).to(device)
43model.eval()
44
45def encode_texts(texts: list[str]) -> torch.Tensor:
46 embedding_batches = []
47
48 for start in range(0, len(texts), BATCH_SIZE):
49 encoded = tokenizer(
50 texts[start : start + BATCH_SIZE],
51 max_length=MAX_LENGTH,
52 truncation=True,
53 padding=True,
54 return_tensors="pt",
55 )
56 encoded = {name: tensor.to(device) for name, tensor in encoded.items()}
57
58 with torch.inference_mode():
59 output = model(**encoded)
60 pooled = average_pool(output.last_hidden_state, encoded["attention_mask"])
61 embeddings = F.normalize(pooled, p=2, dim=-1)
62
63 embedding_batches.append(embeddings.detach().cpu().to(torch.float32))
64
65 return torch.cat(embedding_batches, dim=0)
66
67embeddings = encode_texts(
68 ["query: " + query for query in QUERIES]
69 + ["passage: " + doc for doc in DOCUMENTS]
70)
71query_embeddings = embeddings[: len(QUERIES)]
72document_embeddings = embeddings[len(QUERIES) :]
73
74scores = query_embeddings @ document_embeddings.T
75print("Similarity scores:")
76print(f"{'':>4}" + "".join(f"d[{i}]".rjust(10) for i in range(scores.shape[1])))
77for query_index, row in enumerate(scores):
78 print(f"q[{query_index}]" + "".join(f"{score.item():>10.4f}" for score in row))1Similarity scores:
2 d[0] d[1] d[2] d[3]
3q[0] 0.8069 0.0252 0.0001 -0.0312
4q[1] 0.0446 0.6466 -0.0514 0.0385
5q[2] -0.0098 -0.0410 0.6450 0.0998
6q[3] -0.0215 0.0212 0.1197 0.7679vllm==0.25.0 for /v2/embed serving. NVIDIA also validated vllm serve "$MODEL_ID" with vllm/vllm-openai:v0.20.0 through v0.24.0 for this checkpoint.pip install --upgrade "vllm==0.25.0" openai requests numpyLLM.embed accepts formatted strings, so add the query: and passage: prefixes manually.1import numpy as np
2from vllm import LLM
3
4MODEL_ID = "nvidia/Nemotron-3-Embed-1B-BF16"
5
6QUERIES = [
7 "Write a Python function that counts the frequency of each element in a list of lists.",
8 "Write a function that orders a dictionary with tuple keys by the product of each key's tuple values.",
9 "What symptoms and common triggers help distinguish eczema from other inflammatory skin conditions?",
10 "How can someone reduce exposure to pollen during allergy season?",
11]
12
13DOCUMENTS = [
14 "def frequency_lists(list1):\n flattened = [item for sublist in list1 for item in sublist]\n counts = {}\n for item in flattened:\n if item in counts:\n counts[item] += 1\n else:\n counts[item] = 1\n return counts",
15 "def sort_dict_item(test_dict):\n return {key: test_dict[key] for key in sorted(test_dict.keys(), key=lambda ele: ele[0] * ele[1])}",
16 "Eczema commonly causes itchy, dry, inflamed patches of skin. The affected areas may look red, scaly, cracked, or darker than the surrounding skin depending on skin tone. Symptoms can flare after exposure to irritants, allergens, stress, or changes in weather.",
17 "People with pollen allergy can reduce exposure by staying indoors on dry, windy days, avoiding early-morning outdoor activity, and going outside after rain when pollen levels are lower. They should check pollen forecasts, close windows and doors when counts are high, and consider starting allergy medication before symptoms begin if high pollen is expected. After being outside, showering, changing clothes, avoiding outdoor laundry drying, and wearing a face mask for yard work can help limit pollen contact.",
18]
19
20def main():
21 llm = LLM(model=MODEL_ID)
22 texts = ["query: " + query for query in QUERIES] + [
23 "passage: " + doc for doc in DOCUMENTS
24 ]
25 outputs = llm.embed(texts, use_tqdm=False)
26 embeddings = np.array(
27 [output.outputs.embedding for output in outputs],
28 dtype=np.float32,
29 )
30
31 query_embeddings = embeddings[: len(QUERIES)]
32 document_embeddings = embeddings[len(QUERIES) :]
33
34 scores = query_embeddings @ document_embeddings.T
35 print("Similarity scores:")
36 print(f"{'':>4}" + "".join(f"d[{i}]".rjust(10) for i in range(scores.shape[1])))
37 for query_index, row in enumerate(scores):
38 print(f"q[{query_index}]" + "".join(f"{score:>10.4f}" for score in row))
39
40
41if __name__ == "__main__":
42 main()1Similarity scores:
2 d[0] d[1] d[2] d[3]
3q[0] 0.8110 0.0255 0.0003 -0.0312
4q[1] 0.0448 0.6469 -0.0517 0.0386
5q[2] -0.0100 -0.0400 0.6469 0.1003
6q[3] -0.0224 0.0217 0.1199 0.76921MODEL_ID=nvidia/Nemotron-3-Embed-1B-BF16
2
3vllm serve "$MODEL_ID"8000. Add host and port when you need an explicit bind address or a non-default port:vllm serve "$MODEL_ID" --host 0.0.0.0 --port 8000nvidia/Nemotron-3-Embed-1B-BF16. If you serve a local checkpoint path, vLLM still reads the model config and weights from that path; --served-model-name only sets the model name accepted by API requests.1MODEL_PATH=/path/to/local/Nemotron-3-Embed-1B-BF16
2vllm serve "$MODEL_PATH" --host 0.0.0.0 --port 8000 --served-model-name nvidia/Nemotron-3-Embed-1B-BF16--served-model-name, client requests continue to use MODEL = "nvidia/Nemotron-3-Embed-1B-BF16". If you omit it, use the served name reported by /v1/models in client requests./v2/embed for retrieval. Send raw query and document strings. input_type applies the saved query and document prompts:1import numpy as np
2import requests
3
4MODEL = "nvidia/Nemotron-3-Embed-1B-BF16"
5URL = "http://localhost:8000/v2/embed"
6
7QUERIES = [
8 "Write a Python function that counts the frequency of each element in a list of lists.",
9 "Write a function that orders a dictionary with tuple keys by the product of each key's tuple values.",
10 "What symptoms and common triggers help distinguish eczema from other inflammatory skin conditions?",
11 "How can someone reduce exposure to pollen during allergy season?",
12]
13
14DOCUMENTS = [
15 "def frequency_lists(list1):\n flattened = [item for sublist in list1 for item in sublist]\n counts = {}\n for item in flattened:\n if item in counts:\n counts[item] += 1\n else:\n counts[item] = 1\n return counts",
16 "def sort_dict_item(test_dict):\n return {key: test_dict[key] for key in sorted(test_dict.keys(), key=lambda ele: ele[0] * ele[1])}",
17 "Eczema commonly causes itchy, dry, inflamed patches of skin. The affected areas may look red, scaly, cracked, or darker than the surrounding skin depending on skin tone. Symptoms can flare after exposure to irritants, allergens, stress, or changes in weather.",
18 "People with pollen allergy can reduce exposure by staying indoors on dry, windy days, avoiding early-morning outdoor activity, and going outside after rain when pollen levels are lower. They should check pollen forecasts, close windows and doors when counts are high, and consider starting allergy medication before symptoms begin if high pollen is expected. After being outside, showering, changing clothes, avoiding outdoor laundry drying, and wearing a face mask for yard work can help limit pollen contact.",
19]
20
21def embed(input_type: str, texts: list[str]) -> np.ndarray:
22 response = requests.post(
23 URL,
24 json={
25 "model": MODEL,
26 "input_type": input_type,
27 "texts": texts,
28 "embedding_types": ["float"],
29 "truncate": "END",
30 },
31 timeout=120,
32 )
33 response.raise_for_status()
34 return np.array(response.json()["embeddings"]["float"], dtype=np.float32)
35
36query_embeddings = embed("query", QUERIES)
37document_embeddings = embed("document", DOCUMENTS)
38
39scores = query_embeddings @ document_embeddings.T
40print("Similarity scores:")
41print(f"{'':>4}" + "".join(f"d[{i}]".rjust(10) for i in range(scores.shape[1])))
42for query_index, row in enumerate(scores):
43 print(f"q[{query_index}]" + "".join(f"{score:>10.4f}" for score in row))1Similarity scores:
2 d[0] d[1] d[2] d[3]
3q[0] 0.8109 0.0252 0.0001 -0.0314
4q[1] 0.0448 0.6470 -0.0516 0.0387
5q[2] -0.0103 -0.0400 0.6470 0.1000
6q[3] -0.0223 0.0217 0.1199 0.7693/v1/embeddings endpoint. For those requests, pass strings in input and manually prefix them with query: or passage: .[transformers] Unrecognized keys in `rope_parameters` for 'rope_type'='yarn': {'apply_yarn_scaling'}apply_yarn_scaling is retained as a temporary vLLM compatibility field that preserves the checkpoint's intended long-context RoPE behavior. Do not remove it from config.json. The upstream compatibility work is tracked in vLLM issue #48621.| LLMs used to generate synthetic datasets |
|---|
| Qwen/Qwen3-Next-80B-A3B-Instruct Qwen/Qwen3-235B-A22B Qwen/Qwen3.5-397B-A17B Qwen/Qwen3.6-27B Qwen/Qwen3.6-35B-A3B |
| google/gemma-4-31B-it |
| openai/gpt-oss-120b openai/gpt-oss-20b |
| nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16 nvidia/NVIDIA-Nemotron-3-Ultra-550B-A55B-NVFP4 |
| Seed Datasets | |
|---|---|
| Dataset | Reference |
| FinePdfs | https://huggingface.co/datasets/HuggingFaceFW/finepdfs |
| CentralActs | https://zenodo.org/records/5088102 |
| BRIGHT | https://huggingface.co/datasets/xlangai/BRIGHT |
| MultiHiertt | https://github.com/psunlpgroup/MultiHiertt |
| Text Retrieval benchmarks (chunk retrieval) - Avg. NDCG@10 | |||
|---|---|---|---|
| Model Name | RTEB | ViDoRe-V3 text | MMTEB (Retrieval) |
| llama-nemotron-embed-vl-1b-v2 | 61.98 | 52.54 | 59.71 |
| Nemotron-3-Embed-1B-BF16 | 72.38 | 57.74 | 71.04 |
| Field | Response |
|---|---|
| Participation considerations from adversely impacted groups protected classes in model design and testing: | None |
| Measures taken to mitigate against unwanted bias: | None |
| Bias Metric (If Measured): | None |
| Field | Response |
|---|---|
| Intended Task/Domain: | Passage and query embedding for question and answer retrieval |
| Model Type: | Transformer encoder |
| Intended Users: | Generative AI creators working with conversational AI models - users who want to build a multilingual question and answer application over a large text corpus, leveraging the latest dense retrieval technologies. |
| Output: | Array of float numbers (Dense Vector Representation for the input text) |
| Describe how the model works: | Model transforms the tokenized input text into a dense vector representation. |
| Name the adversely impacted groups this has been tested to deliver comparable outcomes regardless of: | Not Applicable |
| Technical Limitations & Mitigation: | The model’s max sequence length is 32768. Therefore, longer text inputs should be truncated. |
| Verified to have met prescribed NVIDIA quality standards: | Yes |
| Performance Metrics: | Accuracy, Throughput, and Latency |
| Potential Known Risks: | This model does not always guarantee to retrieve the correct passage(s) for a given query. |
| Licensing: | This model and its associated configuration files are licensed under the OpenMDW License Agreement, version 1.1 (OpenMDW-1.1). Additional Information: Built with Ministral-3-3B-Instruct-2512 which is released under Apache 2.0. |
| Field | Response |
|---|---|
| Generatable or reverse engineerable personal data? | None |
| Was consent obtained for any personal data used? | Not Applicable |
| Personal data used to create this model? | None Known |
| How often is the dataset reviewed? | Before Every Release |
| Is there provenance for all datasets used in training? | Yes |
| Does data labeling (annotation, metadata) comply with privacy laws? | Yes |
| Was data from user interactions with the AI model (e.g. user input and prompts) used to train the model? | Yes |
| Is data compliant with data subject requests for data correction or removal, if such a request was made? | No, not possible with externally-sourced data. |
| Applicable Privacy Policy | https://www.nvidia.com/en-us/about-nvidia/privacy-policy/ |
| Field | Response |
|---|---|
| Model Application(s): | Text Embedding for Retrieval |
| Describe the physical safety impact (if present). | Not Applicable |
| Use Case Restrictions: | This model and its associated configuration files are licensed under the OpenMDW License Agreement, version 1.1 (OpenMDW-1.1). Additional Information: Built with Ministral-3-3B-Instruct-2512 which is released under Apache 2.0. |
| Model and dataset restrictions: | The Principle of least privilege (PoLP) is applied limiting access for dataset generation and model development. Restrictions enforce dataset access during training, and dataset license constraints adhered to. |