Text Generation
Transformers
Safetensors
PyTorch
English
llama
nvidia
llama-3
conversational
text-generation-inference
suhara commited on
Commit
5cfbec5
·
verified ·
1 Parent(s): c96caf6

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +329 -0
README.md ADDED
@@ -0,0 +1,329 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: other
4
+ license_name: nvidia-open-model-license
5
+ license_link: >-
6
+ https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/
7
+
8
+ pipeline_tag: text-generation
9
+ language:
10
+ - en
11
+ tags:
12
+ - nvidia
13
+ - llama-3
14
+ - pytorch
15
+ ---
16
+
17
+ # Llama-3.1-Nemotron-Nano-4B-v1.1
18
+
19
+
20
+ ## Model Overview
21
+
22
+ Llama-3.1-Nemotron-Nano-4B-v1.1 is a large language model (LLM) which is a derivative of [nvidia/Llama-3.1-Minitron-4B-Width-Base](https://huggingface.co/nvidia/Llama-3.1-Minitron-4B-Width-Base), which is created from Llama 3.1 8B using [our LLM compression technique](https://arxiv.org/abs/2408.11796) and offers improvements in model accuracy and efficiency. It is a reasoning model that is post trained for reasoning, human chat preferences, and tasks, such as RAG and tool calling.
23
+
24
+ Llama-3.1-Nemotron-Nano-4B-v1.1 is a model which offers a great tradeoff between model accuracy and efficiency. The model fits on a single RTX GPU and can be used locally. The model supports a context length of 128K.
25
+
26
+ This model underwent a multi-phase post-training process to enhance both its reasoning and non-reasoning capabilities. This includes a supervised fine-tuning stage for Math, Code, Reasoning, and Tool Calling as well as multiple reinforcement learning (RL) stages using Reward-aware Preference Optimization (RPO) algorithms for both chat and instruction-following. The final model checkpoint is obtained after merging the final SFT and RPO checkpoints
27
+
28
+ This model is part of the Llama Nemotron Collection. You can find the other model(s) in this family here:
29
+ - [Llama-3.3-Nemotron-Ultra-253B-v1](https://huggingface.co/nvidia/Llama-3_1-Nemotron-Ultra-253B-v1)
30
+ - [Llama-3.3-Nemotron-Super-49B-v1](https://huggingface.co/nvidia/Llama-3.3-Nemotron-Super-49B-v1)
31
+ - [Llama-3.1-Nemotron-Nano-8B-v1](https://huggingface.co/nvidia/Llama-3.1-Nemotron-Nano-8B-v1)
32
+
33
+ This model is ready for commercial use.
34
+
35
+ ## License/Terms of Use
36
+
37
+ GOVERNING TERMS: Your use of this model is governed by the [NVIDIA Open Model License](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/). Additional Information: [Llama 3.1 Community License Agreement](https://www.llama.com/llama3_1/license/). Built with Llama.
38
+
39
+ **Model Developer:** NVIDIA
40
+
41
+ **Model Dates:** Trained between August 2024 and April 2025
42
+
43
+ **Data Freshness:** The pretraining data has a cutoff of 2023 per Meta Llama 3.1 8B
44
+
45
+
46
+ ## Use Case:
47
+
48
+ Developers designing AI Agent systems, chatbots, RAG systems, and other AI-powered applications. Also suitable for typical instruction-following tasks. Balance of model accuracy and compute efficiency (the model fits on a single RTX GPU and can be used locally).
49
+
50
+ ## Release Date: <br>
51
+ x/xx/2025 <br>
52
+
53
+ ## References
54
+
55
+ - [\[2502.00203\] Reward-aware Preference Optimization: A Unified Mathematical Framework for Model Alignment](https://arxiv.org/abs/2502.00203)
56
+
57
+
58
+ ## Model Architecture
59
+
60
+ **Architecture Type:** Dense decoder-only Transformer model
61
+
62
+ **Network Architecture:** Llama 3.1 Minitron Width 4B Base
63
+
64
+ ## Intended use
65
+
66
+ Llama-3.1-Nemotron-Nano-4B-v1.1 is a general purpose reasoning and chat model intended to be used in English and coding languages. Other non-English languages (German, French, Italian, Portuguese, Hindi, Spanish, and Thai) are also supported.
67
+
68
+ # Input:
69
+ - **Input Type:** Text
70
+ - **Input Format:** String
71
+ - **Input Parameters:** One-Dimensional (1D)
72
+ - **Other Properties Related to Input:** Context length up to 131,072 tokens
73
+
74
+ ## Output:
75
+ - **Output Type:** Text
76
+ - **Output Format:** String
77
+ - **Output Parameters:** One-Dimensional (1D)
78
+ - **Other Properties Related to Output:** Context length up to 131,072 tokens
79
+
80
+ ## Model Version:
81
+ 1.0 (x/xx/2025)
82
+
83
+ ## Software Integration
84
+ - **Runtime Engine:** NeMo 24.12 <br>
85
+ - **Recommended Hardware Microarchitecture Compatibility:**
86
+ - NVIDIA Hopper
87
+ - NVIDIA Ampere
88
+
89
+ ## Quick Start and Usage Recommendations:
90
+
91
+ 1. Reasoning mode (ON/OFF) is controlled via the system prompt, which must be set as shown in the example below. All instructions should be contained within the user prompt
92
+ 2. We recommend setting temperature to `0.6`, and Top P to `0.95` for Reasoning ON mode
93
+ 3. We recommend using greedy decoding for Reasoning OFF mode
94
+ 4. We have provided a list of prompts to use for evaluation for each benchmark where a specific template is required
95
+
96
+ See the snippet below for usage with Hugging Face Transformers library. Reasoning mode (ON/OFF) is controlled via system prompt. Please see the example below.
97
+ Our code requires the transformers package version to be `4.44.2` or higher.
98
+
99
+
100
+ ### Example of “Reasoning On:”
101
+
102
+ ```python
103
+ import torch
104
+ import transformers
105
+
106
+ model_id = "nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1"
107
+ model_kwargs = {"torch_dtype": torch.bfloat16, "device_map": "auto"}
108
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
109
+ tokenizer.pad_token_id = tokenizer.eos_token_id
110
+
111
+ pipeline = transformers.pipeline(
112
+ "text-generation",
113
+ model=model_id,
114
+ tokenizer=tokenizer,
115
+ max_new_tokens=32768,
116
+ temperature=0.6,
117
+ top_p=0.95,
118
+ **model_kwargs
119
+ )
120
+
121
+ # Thinking can be "on" or "off"
122
+ thinking = "on"
123
+
124
+ print(pipeline([{"role": "system", "content": f"detailed thinking {thinking}"}, {"role": "user", "content": "Solve x*(sin(x)+2)=0"}]))
125
+ ```
126
+
127
+
128
+ ### Example of “Reasoning Off:”
129
+
130
+ ```python
131
+ import torch
132
+ import transformers
133
+
134
+ model_id = "nvidia/Llama-3.1-Nemotron-Nano-4B-v1"
135
+ model_kwargs = {"torch_dtype": torch.bfloat16, "device_map": "auto"}
136
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
137
+ tokenizer.pad_token_id = tokenizer.eos_token_id
138
+
139
+ pipeline = transformers.pipeline(
140
+ "text-generation",
141
+ model=model_id,
142
+ tokenizer=tokenizer,
143
+ max_new_tokens=32768,
144
+ do_sample=False,
145
+ **model_kwargs
146
+ )
147
+
148
+ # Thinking can be "on" or "off"
149
+ thinking = "off"
150
+
151
+ print(pipeline([{"role": "system", "content": f"detailed thinking {thinking}"}, {"role": "user", "content": "Solve x*(sin(x)+2)=0"}]))
152
+ ```
153
+
154
+ For some prompts, even though thinking is disabled, the model emergently prefers to think before responding. But if desired, the users can prevent it by pre-filling the assistant response.
155
+
156
+ ```python
157
+ import torch
158
+ import transformers
159
+
160
+ model_id = "nvidia/Llama-3.1-Nemotron-Nano-4B-v1.1"
161
+ model_kwargs = {"torch_dtype": torch.bfloat16, "device_map": "auto"}
162
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
163
+ tokenizer.pad_token_id = tokenizer.eos_token_id
164
+
165
+ # Thinking can be "on" or "off"
166
+ thinking = "off"
167
+
168
+ pipeline = transformers.pipeline(
169
+ "text-generation",
170
+ model=model_id,
171
+ tokenizer=tokenizer,
172
+ max_new_tokens=32768,
173
+ do_sample=False,
174
+ **model_kwargs
175
+ )
176
+
177
+ print(pipeline([{"role": "system", "content": f"detailed thinking {thinking}"}, {"role": "user", "content": "Solve x*(sin(x)+2)=0"}, {"role":"assistant", "content":"<think>\n</think>"}]))
178
+ ```
179
+
180
+ ## Inference:
181
+ **Engine:** Transformers
182
+ **Test Hardware:**
183
+
184
+ - BF16:
185
+ - 1x RTX 50 Series GPUs
186
+ - 1x RTX 40 Series GPUs
187
+ - 1x RTX 30 Series GPUs
188
+ - 1x H100-80GB GPU
189
+ - 1x A100-80GB GPU
190
+
191
+
192
+ **Preferred/Supported] Operating System(s):** Linux <br>
193
+
194
+ ## Training Datasets
195
+
196
+ A large variety of training data was used for the post-training pipeline, including manually annotated data and synthetic data.
197
+
198
+ The data for the multi-stage post-training phases for improvements in Code, Math, and Reasoning is a compilation of SFT and RL data that supports improvements of math, code, general reasoning, and instruction following capabilities of the original Llama instruct model.
199
+
200
+ Prompts have been sourced from either public and open corpus or synthetically generated. Responses were synthetically generated by a variety of models, with some prompts containing responses for both Reasoning On and Off modes, to train the model to distinguish between two modes.
201
+
202
+ **Data Collection for Training Datasets:** <br>
203
+ * Hybrid: Automated, Human, Synthetic <br>
204
+
205
+ **Data Labeling for Training Datasets:** <br>
206
+ * N/A <br>
207
+
208
+ ## Evaluation Datasets
209
+
210
+ We used the datasets listed below to evaluate Llama-3.1-Nemotron-Nano-8B-v1.
211
+
212
+ **Data Collection for Evaluation Datasets:** Hybrid: Human/Synthetic
213
+
214
+ **Data Labeling for Evaluation Datasets:** Hybrid: Human/Synthetic/Automatic
215
+
216
+ ## Evaluation Results
217
+
218
+ These results contain both “Reasoning On”, and “Reasoning Off”. We recommend using temperature=`0.6`, top_p=`0.95` for “Reasoning On” mode, and greedy decoding for “Reasoning Off” mode. All evaluations are done with 32k sequence length. We run the benchmarks up to 16 times and average the scores to be more accurate.
219
+
220
+ > NOTE: Where applicable, a Prompt Template will be provided. While completing benchmarks, please ensure that you are parsing for the correct output format as per the provided prompt in order to reproduce the benchmarks seen below.
221
+
222
+ ### MT-Bench
223
+
224
+ | Reasoning Mode | Score |
225
+ |--------------|------------|
226
+ | Reasoning Off | 7.6 |
227
+ | Reasoning On | 8.1 |
228
+
229
+
230
+ ### MATH500
231
+
232
+ | Reasoning Mode | pass@1 |
233
+ |--------------|------------|
234
+ | Reasoning Off | 72.0% |
235
+ | Reasoning On | 95.1% |
236
+
237
+ User Prompt Template:
238
+
239
+ ```
240
+ "Below is a math question. I want you to reason through the steps and then give a final answer. Your final answer should be in \boxed{}.\nQuestion: {question}"
241
+ ```
242
+
243
+
244
+ ### AIME25
245
+
246
+ | Reasoning Mode | pass@1 |
247
+ |--------------|------------|
248
+ | Reasoning Off | 13.3% |
249
+ | Reasoning On | 46.7% |
250
+
251
+ User Prompt Template:
252
+
253
+ ```
254
+ "Below is a math question. I want you to reason through the steps and then give a final answer. Your final answer should be in \boxed{}.\nQuestion: {question}"
255
+ ```
256
+
257
+
258
+ ### GPQA-D
259
+
260
+ | Reasoning Mode | pass@1 |
261
+ |--------------|------------|
262
+ | Reasoning Off | 31.8% |
263
+ | Reasoning On | 55.8% |
264
+
265
+ User Prompt Template:
266
+
267
+
268
+ ```
269
+ "What is the correct answer to this question: {question}\nChoices:\nA. {option_A}\nB. {option_B}\nC. {option_C}\nD. {option_D}\nLet's think step by step, and put the final answer (should be a single letter A, B, C, or D) into a \boxed{}"
270
+ ```
271
+
272
+
273
+ ### IFEval
274
+
275
+ | Reasoning Mode | Strict:Prompt | Strict:Instruction |
276
+ |--------------|------------|------------|
277
+ | Reasoning Off | 73.6% | 80.8% |
278
+ | Reasoning On | 75.4% | 82.6% |
279
+
280
+ ### BFCL v2 Live
281
+
282
+ | Reasoning Mode | Score |
283
+ |--------------|------------|
284
+ | Reasoning Off | 57.1% |
285
+ | Reasoning On | 64.2% |
286
+
287
+ User Prompt Template:
288
+
289
+
290
+ ```
291
+ <AVAILABLE_TOOLS>{functions}</AVAILABLE_TOOLS>
292
+
293
+ {user_prompt}
294
+ ```
295
+
296
+
297
+ ### MBPP 0-shot
298
+
299
+ | Reasoning Mode | pass@1 |
300
+ |--------------|------------|
301
+ | Reasoning Off | 66.4% |
302
+ | Reasoning On | 86.0% |
303
+
304
+ User Prompt Template:
305
+
306
+
307
+ ````
308
+ You are an exceptionally intelligent coding assistant that consistently delivers accurate and reliable responses to user instructions.
309
+
310
+ @@ Instruction
311
+ Here is the given problem and test examples:
312
+ {prompt}
313
+ Please use the python programming language to solve this problem.
314
+ Please make sure that your code includes the functions from the test samples and that the input and output formats of these functions match the test samples.
315
+ Please return all completed codes in one code block.
316
+ This code block should be in the following format:
317
+ ```python
318
+ # Your codes here
319
+ ```
320
+ ````
321
+
322
+
323
+ ## Ethical Considerations:
324
+
325
+ NVIDIA believes Trustworthy AI is a shared responsibility and we have established policies and practices to enable development for a wide array of AI applications. When downloaded or used in accordance with our terms of service, developers should work with their internal model team to ensure this model meets requirements for the relevant industry and use case and addresses unforeseen product misuse.
326
+
327
+ For more detailed information on ethical considerations for this model, please see the Model Card++ [Explainability](explainability.md), [Bias](bias.md), [Safety & Security](safety.md), and [Privacy](privacy.md) Subcards.
328
+
329
+ Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).