NeMo
okuchaiev commited on
Commit
8d2ac2d
1 Parent(s): a09b26f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -51
README.md CHANGED
@@ -6,25 +6,26 @@ license_link: >-
6
  ---
7
  ## Nemotron-4-340B-Instruct
8
 
9
- [![Model architectuve](https://img.shields.io/badge/Model%20Arch-Transformer%20Decoder-green)](#model-architecture)[![Model size](https://img.shields.io/badge/Params-340B-green)](#model-architecture)[![Language](https://img.shields.io/badge/Language-Multilingual-green)](#datasets)
10
 
11
  ### Model Overview
12
 
13
- Nemotron-4-340B-Instruct is a large language model (LLM) that can be used as part of a synthetic data generation pipeline to create training data that helps researchers and developers build their own LLMs; and is a fine-tuned version of the Nemotron-4-340B-Base model, optimized for English single and multi-turn chat use-cases. The base model was pre-trained on a corpus of 9 trillion tokens consisting of a diverse assortment of English based texts,50+ natural languages, and 40+ coding languages.
 
 
14
 
15
- Subsequently the Nemotron-4-340B-Instruct model went through additional alignment steps including:
16
  - Supervised Fine-tuning (SFT)
17
  - Direct Preference Optimization (DPO)
18
- - Additional in-house alignment technique: Reward-aware Preference Optimization (RPO)
19
 
20
- Throughout the alignment process, we relied on only approximately 20K human-annotated data while our data generation pipeline synthesized over 98% of the data used for supervised fine-tuning and preference fine-tuning (DPO & RPO). We provide comprehensive details about our synthetic data generation pipeline in the technical report.
21
 
22
  This results in a model that is aligned for human chat preferences, improvements in mathematical reasoning, coding and instruction-following, and is capable of generating high quality synthetic data for a variety of use cases.
23
 
24
  Under the NVIDIA Open Model License, NVIDIA confirms:
25
- - Models are commercially usable.
26
- - You are free to create and distribute Derivative Models.
27
- - NVIDIA does not claim ownership to any outputs generated using the Models or Derivative Models.
28
 
29
  ### License:
30
 
@@ -36,44 +37,75 @@ Nemotron-4-340B-Instruct is a chat model intended for use for the English langua
36
 
37
  Nemotron-4-340B-Instruct is designed for Synthetic Data Generation to enable developers and enterprises for building and customizing their own large language models and LLM applications.
38
 
39
- The instruct model itself can be further customized using the [NeMo Framework](https://docs.nvidia.com/nemo-framework/index.html) suite of customization tools including Parameter-Efficient Fine-Tuning (P-tuning, Adapters, LoRA), and SFT/Steer-LM/RLHF using [NeMo-Aligner](https://github.com/NVIDIA/NeMo-Aligner).
40
 
41
  **Model Developer:** NVIDIA
42
 
43
- **Model Input:** Text
44
- **Input Format:** String
45
- **Input Parameters:** One-Dimensional (1D)
46
-
47
- **Model Output:** Text
48
- **Output Format:** String
49
- **Output Parameters:** 1D
50
 
51
- **Model Dates:** Nemotron-4-340B-Instruct was trained between December 2023 and May 2024
52
-
53
- **Data Freshness:** The pretraining data has a cutoff of June 2023
54
 
55
  ### Required Hardware
56
 
57
  BF16 Inference:
58
- - 8x H200 (1x H200 Node)
59
- - 16x H100 (2x H100 Nodes)
60
- - 16x A100 (2x A100 Nodes)
61
 
62
- FP8 Inference:
63
- - 8x H100 (1x H100 Node)
64
 
65
  ### Model Architecture:
66
 
67
- Nemotron-4-340B-Base, is standard decoder-only Transformer, trained with a sequence length of 4096 tokens, uses Grouped-Query Attention (GQA), and Rotary Position Embeddings (RoPE).
68
 
69
  **Architecture Type:** Transformer Decoder (auto-regressive language model)
70
 
71
  **Network Architecture:**
72
  Nemotron-4
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  ### Usage
75
 
76
- 1. We will spin up an inference server and then call the inference server in a python script. Let’s first define the python script ``call_server.py``
 
 
 
 
 
 
77
 
78
  ```python
79
  import json
@@ -117,13 +149,13 @@ print(prompt)
117
  response = get_generation(prompt, greedy=True, add_BOS=False, token_to_gen=1024, min_tokens=1, temp=1.0, top_p=1.0, top_k=0, repetition=1.0, batch=False)
118
  response = response[len(prompt):]
119
  if response.endswith("<extra_id_1>"):
120
- response = response[:-len("<extra_id_1>")]
121
  print(response)
122
  ```
123
 
124
- 2. Given this python script, we will create a bash script, which spins up the inference server within the NeMo container (```docker pull nvcr.io/nvidia/nemo:24.01.framework```) and calls the python script ``call_server.py``. The bash script ``nemo_inference.sh`` is as follows,
125
 
126
- ```bash
127
  NEMO_FILE=$1
128
  WEB_PORT=1424
129
 
@@ -141,6 +173,7 @@ depends_on () {
141
  }
142
 
143
 
 
144
  /usr/bin/python3 /opt/NeMo/examples/nlp/language_modeling/megatron_gpt_eval.py \
145
  gpt_model_file=$NEMO_FILE \
146
  pipeline_model_parallel_split_rank=0 \
@@ -170,13 +203,13 @@ depends_on () {
170
  ```
171
 
172
 
173
- 3. We can launch the ``nemo_inferece.sh`` with a slurm script defined like below, which starts a 2-node job for the model inference.
174
 
175
- ```bash
176
  #!/bin/bash
177
  #SBATCH -A SLURM-ACCOUNT
178
  #SBATCH -p SLURM-PARITION
179
- #SBATCH -N 2
180
  #SBATCH -J generation
181
  #SBATCH --ntasks-per-node=8
182
  #SBATCH --gpus-per-node=8
@@ -186,7 +219,6 @@ RESULTS=<PATH_TO_YOUR_SCRIPTS_FOLDER>
186
  OUTFILE="${RESULTS}/slurm-%j-%n.out"
187
  ERRFILE="${RESULTS}/error-%j-%n.out"
188
  MODEL=<PATH_TO>/Nemotron-4-340B-Instruct
189
- CONTAINER="nvcr.io/nvidia/nemo:24.01.framework"
190
 
191
  MOUNTS="--container-mounts=<PATH_TO_YOUR_SCRIPTS_FOLDER>:/scripts,MODEL:/model"
192
  read -r -d '' cmd <<EOF
@@ -200,13 +232,10 @@ srun -o $OUTFILE -e $ERRFILE --container-image="$CONTAINER" $MOUNTS bash -c "${c
200
 
201
  #### MT-Bench (GPT-4-Turbo)
202
 
203
- Evaluated using MT-Bench judging by GPT-4-Turbo as described in the [HelpSteer2 Dataset Paper](https://arxiv.org/abs/2406.08673).
204
 
205
- Please note that these numbers aren't comparable with original MT-bench as we corrected [some references](https://github.com/lm-sys/FastChat/pull/3158)
206
-
207
-
208
- | total | writing | roleplay | extraction | stem | humanities | reasoning | math | coding | turn 1 | turn 2 |
209
- | ----- | ------- | -------- | ---------- | ---- | ---------- | --------- | ---- | ------ | ------ | ------ |
210
  | 8.22 | 8.70 | 8.70 | 9.20 | 8.75 | 8.95 | 6.40 | 8.40 | 6.70 | 8.61 | 7.84 |
211
 
212
  #### IFEval
@@ -214,7 +243,7 @@ Please note that these numbers aren't comparable with original MT-bench as we co
214
  Evaluated using the Instruction Following Eval (IFEval) introduced in [Instruction-Following Evaluation for Large Language Models](https://arxiv.org/pdf/2311.07911).
215
 
216
  | Prompt-Strict Acc | Instruction-Strict Acc |
217
- | ----------------------- | ---------------------------- |
218
  | 79.9 | 86.1 |
219
 
220
  #### MMLU
@@ -222,7 +251,7 @@ Evaluated using the Instruction Following Eval (IFEval) introduced in [Instructi
222
  Evaluated using the Multi-task Language Understanding benchmarks as introduced in [Measuring Massive Multitask Language Understanding](https://arxiv.org/pdf/2009.03300)
223
 
224
  |MMLU 0-shot |
225
- | ----------------- |
226
  | 78.7 |
227
 
228
  #### GSM8K
@@ -230,7 +259,7 @@ Evaluated using the Multi-task Language Understanding benchmarks as introduced i
230
  Evaluated using the Grade School Math 8K (GSM8K) benchmark as introduced in [Training Verifiers to Solve Math Word Problems](https://arxiv.org/pdf/2110.14168v2).
231
 
232
  | GSM8K 0-shot |
233
- | ----------------- |
234
  | 92.3 |
235
 
236
  #### HumanEval
@@ -239,7 +268,7 @@ Evaluated using the HumanEval benchmark as introduced in [Evaluating Large Langu
239
 
240
 
241
  | HumanEval 0-shot |
242
- | ----- |
243
  | 73.2 |
244
 
245
  #### MBPP
@@ -247,7 +276,7 @@ Evaluated using the HumanEval benchmark as introduced in [Evaluating Large Langu
247
  Evaluated using the MBPP Dataset as introduced in the [Program Synthesis with Large Language Models](https://arxiv.org/abs/2108.07732) paper.
248
 
249
  | MBPP 0-shot|
250
- | ----------------- |
251
  | 75.4 |
252
 
253
 
@@ -256,7 +285,7 @@ Evaluated using the MBPP Dataset as introduced in the [Program Synthesis with La
256
  Evaluated using the [Arena-Hard Pipeline](https://lmsys.org/blog/2024-04-19-arena-hard/) from the LMSys Org.
257
 
258
  | Arena Hard |
259
- | ----------------- |
260
  | 54.2 |
261
 
262
  #### AlpacaEval 2.0 LC
@@ -264,7 +293,7 @@ Evaluated using the [Arena-Hard Pipeline](https://lmsys.org/blog/2024-04-19-aren
264
  Evaluated using the AlpacaEval 2.0 LC (Length Controlled) as introduced in the paper: [Length-Controlled AlpacaEval: A Simple Way to Debias Automatic Evaluators](https://arxiv.org/abs/2404.04475)
265
 
266
  | AlpacaEval 2.0 LC|
267
- | ----------------- |
268
  | 41.5 |
269
 
270
 
@@ -273,18 +302,22 @@ Evaluated using the AlpacaEval 2.0 LC (Length Controlled) as introduced in the p
273
  Evaluated using the CantTalkAboutThis Dataset as introduced in the [CantTalkAboutThis: Aligning Language Models to Stay on Topic in Dialogues](https://arxiv.org/abs/2404.03820) paper.
274
 
275
  | Distractor F1 | On-topic F1 |
276
- | ----------------------- | ---------------------------- |
277
  | 81.7 | 97.7 |
278
 
279
 
280
  ### Adversarial Testing and Red Teaming Efforts
281
 
282
  The Nemotron-4 340B-Instruct model underwent extensive safety evaluation including adversarial testing via three distinct methods:
283
- - [Garak](https://docs.garak.ai/garak), is an automated LLM vulnerability scanner that probes for common weaknesses, including prompt injection and data leakage.
284
- - [AEGIS](https://arxiv.org/pdf/2404.05993), is a content safety evaluation dataset and LLM based content safety classifier model, that adheres to a broad taxonomy of 13 categories of critical risks in human-LLM interactions.
285
- - Human Content Red Teaming leveraging human interaction and evaluation of the models' responses.
 
 
 
 
286
 
287
 
288
  ### Ethical Considerations
289
 
290
- 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. For more detailed information on ethical considerations for this model, please see the Model Card++ Explainability, Bias, Safety & Security, and Privacy Subcards [Insert Link to Model Card++ here]. Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
 
6
  ---
7
  ## Nemotron-4-340B-Instruct
8
 
9
+ [![Model architecture](https://img.shields.io/badge/Model%20Arch-Transformer%20Decoder-green)](#model-architecture)[![Model size](https://img.shields.io/badge/Params-340B-green)](#model-architecture)[![Language](https://img.shields.io/badge/Language-Multilingual-green)](#datasets)
10
 
11
  ### Model Overview
12
 
13
+ Nemotron-4-340B-Instruct is a large language model (LLM) that can be used as part of a synthetic data generation pipeline to create training data that helps researchers and developers build their own LLMs. It is a fine-tuned version of the Nemotron-4-340B-Base model, optimized for English-based single and multi-turn chat use-cases. It supports a context length of 4,096 tokens.
14
+
15
+ The base model was pre-trained on a corpus of 9 trillion tokens consisting of a diverse assortment of English based texts, 50+ natural languages, and 40+ coding languages. Subsequently the Nemotron-4-340B-Instruct model went through additional alignment steps including:
16
 
 
17
  - Supervised Fine-tuning (SFT)
18
  - Direct Preference Optimization (DPO)
19
+ - Reward-aware Preference Optimization (RPO) ([Additional in-house alignment technique](https://research.nvidia.com/publication/2024-06_nemotron-4-340b))
20
 
21
+ Throughout the alignment process, we relied on only approximately 20K human-annotated data while our data generation pipeline synthesized over 98% of the data used for supervised fine-tuning and preference fine-tuning (DPO & RPO). We provide comprehensive details about our synthetic data generation pipeline in the [technical report](https://research.nvidia.com/publication/2024-06_nemotron-4-340b).
22
 
23
  This results in a model that is aligned for human chat preferences, improvements in mathematical reasoning, coding and instruction-following, and is capable of generating high quality synthetic data for a variety of use cases.
24
 
25
  Under the NVIDIA Open Model License, NVIDIA confirms:
26
+ Models are commercially usable.
27
+ You are free to create and distribute Derivative Models.
28
+ NVIDIA does not claim ownership to any outputs generated using the Models or Derivative Models.
29
 
30
  ### License:
31
 
 
37
 
38
  Nemotron-4-340B-Instruct is designed for Synthetic Data Generation to enable developers and enterprises for building and customizing their own large language models and LLM applications.
39
 
40
+ The instruct model itself can be further customized using the [NeMo Framework](https://docs.nvidia.com/nemo-framework/index.html) suite of customization tools including Parameter-Efficient Fine-Tuning (P-tuning, Adapters, LoRA, and more), and Model Alignment (SFT, SteerLM, RLHF, and more) using [NeMo-Aligner](https://github.com/NVIDIA/NeMo-Aligner).
41
 
42
  **Model Developer:** NVIDIA
43
 
44
+ **Model Dates:** Nemotron-4-340B-Instruct was trained between December 2023 and May 2024.
 
 
 
 
 
 
45
 
46
+ **Data Freshness:** The pretraining data has a cutoff of June 2023.
 
 
47
 
48
  ### Required Hardware
49
 
50
  BF16 Inference:
51
+ - 8x H200 (1x H200 node)
52
+ - 16x H100 (2x H100 nodes)
53
+ - 16x A100 80GB (2x A100 80GB nodes)
54
 
 
 
55
 
56
  ### Model Architecture:
57
 
58
+ Nemotron-4-340B-Instruct is standard decoder-only Transformer, trained with a sequence length of 4096 tokens, uses Grouped-Query Attention (GQA), and Rotary Position Embeddings (RoPE).
59
 
60
  **Architecture Type:** Transformer Decoder (auto-regressive language model)
61
 
62
  **Network Architecture:**
63
  Nemotron-4
64
 
65
+ ### Prompt Format
66
+
67
+ Note: For Nemotron-4-340B-Instruct we recommend keeping the system prompt empty.
68
+
69
+ #### Single Turn
70
+
71
+ ```text
72
+ <extra_id_0>System
73
+
74
+ <extra_id_1>User
75
+ {prompt}
76
+ <extra_id_1>Assistant
77
+ ```
78
+
79
+ #### Multi-Turn or Few-shot
80
+
81
+ ```text
82
+ <extra_id_0>System
83
+
84
+ <extra_id_1>User
85
+ {prompt 1}
86
+ <extra_id_1>Assistant
87
+ {response 1}
88
+ <extra_id_1>User
89
+ {prompt 2}
90
+ <extra_id_1>Assistant
91
+ {response 2}
92
+ ...
93
+ <extra_id_1>User
94
+ {prompt N}
95
+ <extra_id_1>Assistant
96
+ ```
97
+
98
+ An example of a formattable prompt template is available in the following section.
99
+
100
  ### Usage
101
 
102
+ Deployment and inference with Nemotron-4-340B-Instruct can be done in three steps using NeMo Framework:
103
+
104
+ Create a Python script to interact with the deployed model.
105
+ Create a Bash script to start the inference server
106
+ Schedule a Slurm job to distribute the model across 4 nodes and associate them with the inference server.
107
+
108
+ 1. Define the Python script ``call_server.py``
109
 
110
  ```python
111
  import json
 
149
  response = get_generation(prompt, greedy=True, add_BOS=False, token_to_gen=1024, min_tokens=1, temp=1.0, top_p=1.0, top_k=0, repetition=1.0, batch=False)
150
  response = response[len(prompt):]
151
  if response.endswith("<extra_id_1>"):
152
+ response = response[:-len("<extra_id_1>")]
153
  print(response)
154
  ```
155
 
156
+ 2. Given this Python script, create a Bash script which spins up the inference server within the [NeMo container](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/nemo) (docker pull nvcr.io/nvidia/nemo:24.01.framework) and calls the Python script ``call_server.py``. The Bash script ``nemo_inference.sh`` is as follows,
157
 
158
+ ```
159
  NEMO_FILE=$1
160
  WEB_PORT=1424
161
 
 
173
  }
174
 
175
 
176
+
177
  /usr/bin/python3 /opt/NeMo/examples/nlp/language_modeling/megatron_gpt_eval.py \
178
  gpt_model_file=$NEMO_FILE \
179
  pipeline_model_parallel_split_rank=0 \
 
203
  ```
204
 
205
 
206
+ 3, Launch ``nemo_inference.sh`` with a Slurm script defined like below, which starts a 4-node job for model inference.
207
 
208
+ ```
209
  #!/bin/bash
210
  #SBATCH -A SLURM-ACCOUNT
211
  #SBATCH -p SLURM-PARITION
212
+ #SBATCH -N 2 # number of nodes
213
  #SBATCH -J generation
214
  #SBATCH --ntasks-per-node=8
215
  #SBATCH --gpus-per-node=8
 
219
  OUTFILE="${RESULTS}/slurm-%j-%n.out"
220
  ERRFILE="${RESULTS}/error-%j-%n.out"
221
  MODEL=<PATH_TO>/Nemotron-4-340B-Instruct
 
222
 
223
  MOUNTS="--container-mounts=<PATH_TO_YOUR_SCRIPTS_FOLDER>:/scripts,MODEL:/model"
224
  read -r -d '' cmd <<EOF
 
232
 
233
  #### MT-Bench (GPT-4-Turbo)
234
 
235
+ Evaluated using MT-Bench judging by GPT-4-0125-Preview as described in Appendix H in the [HelpSteer2 Dataset Paper](https://arxiv.org/abs/2406.08673)
236
 
237
+ | total | writing | roleplay | extraction | stem | humanities | reasoning | math | coding | turn 1 | turn 2 |
238
+ | :----- | :------- | :-------- | :---------- | :---- | :---------- | :--------- | :---- | ------ | :------ | :------ |
 
 
 
239
  | 8.22 | 8.70 | 8.70 | 9.20 | 8.75 | 8.95 | 6.40 | 8.40 | 6.70 | 8.61 | 7.84 |
240
 
241
  #### IFEval
 
243
  Evaluated using the Instruction Following Eval (IFEval) introduced in [Instruction-Following Evaluation for Large Language Models](https://arxiv.org/pdf/2311.07911).
244
 
245
  | Prompt-Strict Acc | Instruction-Strict Acc |
246
+ | :----------------------- | :---------------------------- |
247
  | 79.9 | 86.1 |
248
 
249
  #### MMLU
 
251
  Evaluated using the Multi-task Language Understanding benchmarks as introduced in [Measuring Massive Multitask Language Understanding](https://arxiv.org/pdf/2009.03300)
252
 
253
  |MMLU 0-shot |
254
+ | :----------------- |
255
  | 78.7 |
256
 
257
  #### GSM8K
 
259
  Evaluated using the Grade School Math 8K (GSM8K) benchmark as introduced in [Training Verifiers to Solve Math Word Problems](https://arxiv.org/pdf/2110.14168v2).
260
 
261
  | GSM8K 0-shot |
262
+ | :----------------- |
263
  | 92.3 |
264
 
265
  #### HumanEval
 
268
 
269
 
270
  | HumanEval 0-shot |
271
+ | :----- |
272
  | 73.2 |
273
 
274
  #### MBPP
 
276
  Evaluated using the MBPP Dataset as introduced in the [Program Synthesis with Large Language Models](https://arxiv.org/abs/2108.07732) paper.
277
 
278
  | MBPP 0-shot|
279
+ | :----------------- |
280
  | 75.4 |
281
 
282
 
 
285
  Evaluated using the [Arena-Hard Pipeline](https://lmsys.org/blog/2024-04-19-arena-hard/) from the LMSys Org.
286
 
287
  | Arena Hard |
288
+ | :----------------- |
289
  | 54.2 |
290
 
291
  #### AlpacaEval 2.0 LC
 
293
  Evaluated using the AlpacaEval 2.0 LC (Length Controlled) as introduced in the paper: [Length-Controlled AlpacaEval: A Simple Way to Debias Automatic Evaluators](https://arxiv.org/abs/2404.04475)
294
 
295
  | AlpacaEval 2.0 LC|
296
+ | :----------------- |
297
  | 41.5 |
298
 
299
 
 
302
  Evaluated using the CantTalkAboutThis Dataset as introduced in the [CantTalkAboutThis: Aligning Language Models to Stay on Topic in Dialogues](https://arxiv.org/abs/2404.03820) paper.
303
 
304
  | Distractor F1 | On-topic F1 |
305
+ | :----------------------- | :---------------------------- |
306
  | 81.7 | 97.7 |
307
 
308
 
309
  ### Adversarial Testing and Red Teaming Efforts
310
 
311
  The Nemotron-4 340B-Instruct model underwent extensive safety evaluation including adversarial testing via three distinct methods:
312
+ [Garak](https://docs.garak.ai/garak), is an automated LLM vulnerability scanner that probes for common weaknesses, including prompt injection and data leakage.
313
+ [AEGIS](https://arxiv.org/pdf/2404.05993), is a content safety evaluation dataset and LLM based content safety classifier model, that adheres to a broad taxonomy of 13 categories of critical risks in human-LLM interactions.
314
+ Human Content Red Teaming leveraging human interaction and evaluation of the models' responses.
315
+
316
+ ### Limitations
317
+
318
+ The model was trained on data that contains toxic language, unsafe content, and societal biases originally crawled from the internet. Therefore, the model may amplify those biases and return toxic responses especially when prompted with toxic prompts. The model may generate answers that may be inaccurate, omit key information, or include irrelevant or redundant text producing socially unacceptable or undesirable text, even if the prompt itself does not include anything explicitly offensive.
319
 
320
 
321
  ### Ethical Considerations
322
 
323
+ 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. For more detailed information on ethical considerations for this model, please see the Model Card++ Explainability, Bias, Safety & Security, and Privacy Subcards [here](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/nemo/models/nemotron-4-340b-instruct). Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).