Feature Extraction
sentence-transformers
PyTorch
Safetensors
Transformers
multilingual
llama_bidirec
text
text-embeddings
retrieval
semantic-search
custom_code
text-embeddings-inference
Instructions to use nvidia/llama-nemotron-embed-1b-v2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use nvidia/llama-nemotron-embed-1b-v2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("nvidia/llama-nemotron-embed-1b-v2", trust_remote_code=True) sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Transformers
How to use nvidia/llama-nemotron-embed-1b-v2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="nvidia/llama-nemotron-embed-1b-v2", trust_remote_code=True)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/llama-nemotron-embed-1b-v2", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update vLLM usage docs: remove config_vllm.json overwrite, relax version pin, and clarify minimal required flags
#18
by oliverholworthy - opened
- README.md +37 -18
- config_vllm.json +0 -38
README.md
CHANGED
|
@@ -167,37 +167,57 @@ print(scores.tolist())
|
|
| 167 |
|
| 168 |
#### vLLM Usage
|
| 169 |
|
| 170 |
-
1. Ensure you are using `vllm=
|
| 171 |
-
2.
|
| 172 |
-
|
| 173 |
-
|
| 174 |
```
|
| 175 |
vllm serve \
|
| 176 |
-
|
| 177 |
-
--trust-remote-code
|
| 178 |
-
--runner pooling \
|
| 179 |
-
--model-impl vllm \
|
| 180 |
-
--pooler-config '{\"pooling_type\": \"MEAN\"}' \
|
| 181 |
-
--data-parallel-size <num_gpus_to_use> \
|
| 182 |
-
--dtype float32 \
|
| 183 |
-
--port 8000
|
| 184 |
```
|
| 185 |
|
| 186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
|
| 188 |
```
|
| 189 |
from openai import OpenAI
|
| 190 |
-
client = OpenAI(
|
| 191 |
-
|
| 192 |
-
|
|
|
|
| 193 |
|
| 194 |
response = client.embeddings.create(
|
| 195 |
input=['query: summit define'],
|
| 196 |
-
model=
|
| 197 |
)
|
| 198 |
response.data[0].embedding
|
| 199 |
```
|
| 200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
### **Software Integration**
|
| 202 |
|
| 203 |
**Runtime Engine:** Llama Nemotron embedding NIM
|
|
@@ -355,4 +375,3 @@ Visit the [NeMo Retriever docs page](https://docs.nvidia.com/nemo/retriever/inde
|
|
| 355 |
| Describe the physical safety impact (if present). | Not Applicable |
|
| 356 |
| Use Case Restrictions: | Use of this model is governed by the [NVIDIA Open Model License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/). Additional Information: [Llama 3.2 Community Model License Agreement](https://www.llama.com/llama3_2/license/). |
|
| 357 |
| 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. |
|
| 358 |
-
|
|
|
|
| 167 |
|
| 168 |
#### vLLM Usage
|
| 169 |
|
| 170 |
+
1. Ensure you are using `vllm>=0.14.0`.
|
| 171 |
+
2. Start the vLLM server with the following command:
|
| 172 |
+
|
| 173 |
+
Minimal command (required):
|
| 174 |
```
|
| 175 |
vllm serve \
|
| 176 |
+
nvidia/llama-nemotron-embed-1b-v2 \
|
| 177 |
+
--trust-remote-code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
```
|
| 179 |
|
| 180 |
+
If you already have a local copy of the model, you can also pass the local
|
| 181 |
+
path instead of the HF repo ID.
|
| 182 |
+
|
| 183 |
+
Optional flags:
|
| 184 |
+
|
| 185 |
+
- `--dtype <float32|bfloat16|float16>` to force precision (the default is `auto`, which resolves from model config; this model defaults to BF16).
|
| 186 |
+
- `--data-parallel-size <num_gpus_to_use>` for multi-GPU serving.
|
| 187 |
+
- `--port 8000` to set the server port.
|
| 188 |
+
|
| 189 |
+
Online serving example (OpenAI SDK):
|
| 190 |
|
| 191 |
```
|
| 192 |
from openai import OpenAI
|
| 193 |
+
client = OpenAI(
|
| 194 |
+
base_url="http://localhost:8000/v1",
|
| 195 |
+
api_key="EMPTY", # required by OpenAI SDK; ignored by default in local vLLM
|
| 196 |
+
)
|
| 197 |
|
| 198 |
response = client.embeddings.create(
|
| 199 |
input=['query: summit define'],
|
| 200 |
+
model="nvidia/llama-nemotron-embed-1b-v2",
|
| 201 |
)
|
| 202 |
response.data[0].embedding
|
| 203 |
```
|
| 204 |
|
| 205 |
+
Offline inference example (Python API, no server required):
|
| 206 |
+
|
| 207 |
+
```
|
| 208 |
+
from vllm import LLM
|
| 209 |
+
|
| 210 |
+
llm = LLM(
|
| 211 |
+
model="nvidia/llama-nemotron-embed-1b-v2",
|
| 212 |
+
runner="pooling",
|
| 213 |
+
trust_remote_code=True,
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
outputs = llm.embed(["query: summit define", "passage: a summit is a meeting"])
|
| 217 |
+
for output in outputs:
|
| 218 |
+
print(len(output.outputs.embedding)) # 2048
|
| 219 |
+
```
|
| 220 |
+
|
| 221 |
### **Software Integration**
|
| 222 |
|
| 223 |
**Runtime Engine:** Llama Nemotron embedding NIM
|
|
|
|
| 375 |
| Describe the physical safety impact (if present). | Not Applicable |
|
| 376 |
| Use Case Restrictions: | Use of this model is governed by the [NVIDIA Open Model License Agreement](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/). Additional Information: [Llama 3.2 Community Model License Agreement](https://www.llama.com/llama3_2/license/). |
|
| 377 |
| 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. |
|
|
|
config_vllm.json
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"_name_or_path": "nvidia/llama-3.2-nv-embedqa-1b-v2",
|
| 3 |
-
"architectures": [
|
| 4 |
-
"LlamaModel"
|
| 5 |
-
],
|
| 6 |
-
"attention_bias": false,
|
| 7 |
-
"attention_dropout": 0.0,
|
| 8 |
-
"bos_token_id": 128000,
|
| 9 |
-
"eos_token_id": 128001,
|
| 10 |
-
"head_dim": 64,
|
| 11 |
-
"hidden_act": "silu",
|
| 12 |
-
"hidden_size": 2048,
|
| 13 |
-
"initializer_range": 0.02,
|
| 14 |
-
"intermediate_size": 8192,
|
| 15 |
-
"max_position_embeddings": 131072,
|
| 16 |
-
"is_causal": false,
|
| 17 |
-
"mlp_bias": false,
|
| 18 |
-
"model_type": "llama",
|
| 19 |
-
"num_attention_heads": 32,
|
| 20 |
-
"num_hidden_layers": 16,
|
| 21 |
-
"num_key_value_heads": 8,
|
| 22 |
-
"pooling": "avg",
|
| 23 |
-
"pretraining_tp": 1,
|
| 24 |
-
"rms_norm_eps": 1e-05,
|
| 25 |
-
"rope_scaling": {
|
| 26 |
-
"factor": 32.0,
|
| 27 |
-
"high_freq_factor": 4.0,
|
| 28 |
-
"low_freq_factor": 1.0,
|
| 29 |
-
"original_max_position_embeddings": 8192,
|
| 30 |
-
"rope_type": "llama3"
|
| 31 |
-
},
|
| 32 |
-
"rope_theta": 500000.0,
|
| 33 |
-
"tie_word_embeddings": true,
|
| 34 |
-
"torch_dtype": "bfloat16",
|
| 35 |
-
"transformers_version": "4.44.2",
|
| 36 |
-
"use_cache": true,
|
| 37 |
-
"vocab_size": 128256
|
| 38 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|