NeMo
nvidia
jiaqiz commited on
Commit
1d68e9e
1 Parent(s): 9f32193

Add files using large-upload tool

Browse files
Files changed (1) hide show
  1. README.md +205 -222
README.md CHANGED
@@ -1,222 +1,205 @@
1
- ---
2
- license: other
3
- license_name: nvidia-open-model-license
4
- license_link: https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf
5
- library_name: nemo
6
- inference: false
7
- fine-tuning: false
8
- tags:
9
- - nvidia
10
- ---
11
-
12
- ## Nemotron-4-340B-Base
13
-
14
- [![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)
15
-
16
-
17
-
18
- ### Model Overview:
19
-
20
- Nemotron-4-340B-Base 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. This model has 340 billion parameters, and supports a context length of 4,096 tokens. It is pre-trained for a total of 9 trillion tokens, consisting of a diverse assortment of English-based texts, 50+ natural languages and 40+ coding languages. After an initial pre-training phase of 8 trillion tokens, continuous pre-training of 1 trillion tokens was performed on top of the pre-trained model in order to improve model quality. During continuous pre-training, we altered the data composition by using a different distribution than the one seen at the beginning of training.
21
-
22
- Under the NVIDIA Open Model License, NVIDIA confirms:
23
- - Models are commercially usable.
24
- - You are free to create and distribute Derivative Models.
25
- - NVIDIA does not claim ownership to any outputs generated using the Models or Derivative Models
26
-
27
-
28
- ### License:
29
-
30
- [NVIDIA Open Model License](https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf)
31
-
32
- ### Intended use
33
-
34
- Nemotron-4-340B-Base is a completion model intended for use in over 50+ natural and 40+ coding languages. It is compatible with [NVIDIA NeMo Framework](https://docs.nvidia.com/nemo-framework/index.html). For best performance on a given task, users are encouraged to customize the model using the NeMo Framework 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). Refer to the [documentation](https://docs.nvidia.com/nemo-framework/user-guide/latest/llms/nemotron/index.html) for examples.
35
-
36
- **Model Developer:** NVIDIA
37
-
38
- **Model Dates:** Nemotron-4-340B-Base was trained between December 2023 and May 2024.
39
-
40
- ### Required Hardware
41
-
42
- BF16 Inference:
43
- - 8x H200 (1x H200 node)
44
- - 16x H100 (2x H100 nodes)
45
- - 16x A100 80GB (2x A100 80GB nodes)
46
-
47
- ### Model Architecture:
48
-
49
- Nemotron-4-340B-Base is trained with a global batch-size of 2304, a sequence length of 4096 tokens, uses Grouped-Query Attention (GQA), and Rotary Position Embeddings (RoPE).
50
-
51
- **Architecture Type:** Transformer Decoder (auto-regressive language model)
52
-
53
- **Network Architecture:**
54
- Nemotron-4
55
-
56
- ### Usage
57
-
58
- Deployment and inference with Nemotron-4-340B-Base can be done in three steps using NeMo Framework:
59
-
60
- 1. Create a Python script to interact with the deployed model.
61
- 2. Create a Bash script to start the inference server.
62
- 3. Schedule a Slurm job to distribute the model across 2 nodes and associate them with the inference server.
63
-
64
- The first task is for the Python Script.
65
-
66
- 1. Define the Python script ``call_server.py``
67
-
68
- ```python
69
- import requests
70
- import json
71
-
72
- headers = {"Content-Type": "application/json"}
73
-
74
- def text_generation(data, ip='localhost', port=None):
75
- resp = requests.put(f'http://{ip}:{port}/generate', data=json.dumps(data), headers=headers)
76
- return resp.json()
77
-
78
-
79
- def get_generation(prompt, greedy, add_BOS, token_to_gen, min_tokens, temp, top_p, top_k, repetition, batch=False):
80
- data = {
81
- "sentences": [prompt] if not batch else prompt,
82
- "tokens_to_generate": int(token_to_gen),
83
- "temperature": temp,
84
- "add_BOS": add_BOS,
85
- "top_k": top_k,
86
- "top_p": top_p,
87
- "greedy": greedy,
88
- "all_probs": False,
89
- "repetition_penalty": repetition,
90
- "min_tokens_to_generate": int(min_tokens),
91
- "end_strings": ["<|endoftext|>", "<extra_id_1>", "\x11", "<extra_id_1>User"],
92
- }
93
- sentences = text_generation(data, port=1424)['sentences']
94
- return sentences[0] if not batch else sentences
95
-
96
- PROMPT_TEMPLATE = "{prompt}"
97
-
98
- question = "Write a poem on NVIDIA in the style of Shakespeare"
99
- prompt = PROMPT_TEMPLATE.format(prompt=question)
100
- print(prompt)
101
-
102
- 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)
103
- response = response[len(prompt):]
104
- print(response)
105
- ```
106
-
107
-
108
- 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.05```) and calls the Python script ``call_server.py``. The Bash script ``nemo_inference.sh`` is as follows:
109
-
110
-
111
- ```bash
112
- NEMO_FILE=$1
113
- WEB_PORT=1424
114
-
115
- depends_on () {
116
- HOST=$1
117
- PORT=$2
118
- STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
119
- while [ $STATUS -ne 0 ]
120
- do
121
- echo "waiting for server ($HOST:$PORT) to be up"
122
- sleep 10
123
- STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
124
- done
125
- echo "server ($HOST:$PORT) is up running"
126
- }
127
-
128
-
129
- /usr/bin/python3 /opt/NeMo/examples/nlp/language_modeling/megatron_gpt_eval.py \
130
- gpt_model_file=$NEMO_FILE \
131
- pipeline_model_parallel_split_rank=0 \
132
- server=True tensor_model_parallel_size=8 \
133
- trainer.precision=bf16 pipeline_model_parallel_size=2 \
134
- trainer.devices=8 \
135
- trainer.num_nodes=2 \
136
- web_server=False \
137
- port=${WEB_PORT} &
138
- SERVER_PID=$!
139
-
140
- readonly local_rank="${LOCAL_RANK:=${SLURM_LOCALID:=${OMPI_COMM_WORLD_LOCAL_RANK:-}}}"
141
- if [ $SLURM_NODEID -eq 0 ] && [ $local_rank -eq 0 ]; then
142
- depends_on "0.0.0.0" ${WEB_PORT}
143
-
144
- echo "start get json"
145
- sleep 5
146
-
147
- echo "SLURM_NODEID: $SLURM_NODEID"
148
- echo "local_rank: $local_rank"
149
- /usr/bin/python3 /scripts/call_server.py
150
- echo "clean up dameons: $$"
151
- kill -9 $SERVER_PID
152
- pkill python
153
- fi
154
- wait
155
- ```
156
-
157
-
158
- 3. Launch ``nemo_inference.sh`` with a Slurm script defined like below, which starts a 2-node job for model inference.
159
-
160
- ```bash
161
- #!/bin/bash
162
- #SBATCH -A SLURM-ACCOUNT
163
- #SBATCH -p SLURM-PARITION
164
- #SBATCH -N 2
165
- #SBATCH -J generation
166
- #SBATCH --ntasks-per-node=8
167
- #SBATCH --gpus-per-node=8
168
- set -x
169
-
170
- RESULTS=<PATH_TO_YOUR_SCRIPTS_FOLDER>
171
- OUTFILE="${RESULTS}/slurm-%j-%n.out"
172
- ERRFILE="${RESULTS}/error-%j-%n.out"
173
- MODEL=<PATH_TO>/Nemotron-4-340B-Base
174
- CONTAINER="nvcr.io/nvidia/nemo:24.05"
175
- MOUNTS="--container-mounts=<PATH_TO_YOUR_SCRIPTS_FOLDER>:/scripts,MODEL:/model"
176
-
177
- read -r -d '' cmd <<EOF
178
- bash /scripts/nemo_inference.sh /model
179
- EOF
180
-
181
- srun -o $OUTFILE -e $ERRFILE --container-image="$CONTAINER" $MOUNTS bash -c "${cmd}"
182
- ```
183
-
184
-
185
- ### Dataset & Training
186
-
187
- The training corpus for Nemotron-4-340B-Base consists of English and multilingual text, as well as code. Our sources cover a variety of document types such as: webpages, dialogue, articles, and other written materials. The corpus spans domains including legal, math, science, finance, and more. In our continued training set, we introduce a small portion of question-answering, and alignment style data to improve model performance.
188
-
189
- **Data Freshness:** The pretraining data has a cutoff of June 2023.
190
-
191
- ### Evaluation Results
192
-
193
- #### Overview
194
-
195
- *5-shot performance.* Language Understanding evaluated using Massive Multitask Language Understanding:
196
- | Average |
197
- | :------------- |
198
- | 81.1 |
199
-
200
- *Zero-shot performance.* Evaluated using select datasets from the LM Evaluation Harness with additions:
201
- | HellaSwag | Winogrande | BBH| ARC-Challenge |
202
- | :------------- | :------------- | :------------- | :------------- |
203
- | 90.53 | 89.50 | 85.44 | 94.28 |
204
-
205
- *Chain of Thought (CoT)*. Multilingual capabilities evaluated using Multilingual Grade School Math:
206
-
207
- | ES Exact Match (%) | JA Exact Match (%) | TH Exact Match (%) |
208
- | :------------- | :------------- | :------------- |
209
- | 68.8 | 69.6 | 68.4 |
210
-
211
- *Code generation performance*. Evaluated using HumanEval:
212
- | p@1, 0-Shot |
213
- | :------------- |
214
- | 57.3 |
215
-
216
- ### Limitations
217
-
218
- 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.
219
-
220
- ### Ethical Considerations
221
-
222
- 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-base). Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).
 
1
+ ---
2
+ license: other
3
+ license_name: nvidia-open-model-license
4
+ license_link: https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf
5
+ library_name: nemo
6
+ inference: false
7
+ fine-tuning: false
8
+ tags:
9
+ - nvidia
10
+ ---
11
+ ## Nemotron-4-340B-Base
12
+
13
+ [![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)
14
+
15
+
16
+
17
+ ### Model Overview:
18
+
19
+ Nemotron-4-340B-Base 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. This model has 340 billion parameters, and supports a context length of 4,096 tokens. It is pre-trained for a total of 9 trillion tokens, consisting of a diverse assortment of English-based texts, 50+ natural languages and 40+ coding languages. After an initial pre-training phase of 8 trillion tokens, continuous pre-training of 1 trillion tokens was performed on top of the pre-trained model in order to improve model quality. During continuous pre-training, we altered the data composition by using a different distribution than the one seen at the beginning of training.
20
+
21
+ Under the NVIDIA Open Model License, NVIDIA confirms:
22
+ - Models are commercially usable.
23
+ - You are free to create and distribute Derivative Models.
24
+ - NVIDIA does not claim ownership to any outputs generated using the Models or Derivative Models
25
+
26
+
27
+ ### License:
28
+
29
+ [NVIDIA Open Model License](https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf)
30
+
31
+ ### Intended use
32
+
33
+ Nemotron-4-340B-Base is a completion model intended for use in over 50+ natural and 40+ coding languages. It is compatible with [NVIDIA NeMo Framework](https://docs.nvidia.com/nemo-framework/index.html). For best performance on a given task, users are encouraged to customize the model using the NeMo Framework 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). Refer to the [documentation](https://docs.nvidia.com/nemo-framework/user-guide/latest/llms/nemotron/index.html) for examples.
34
+
35
+ **Model Developer:** NVIDIA
36
+
37
+ **Model Dates:** Nemotron-4-340B-Base was trained between December 2023 and May 2024.
38
+
39
+ ### Required Hardware
40
+
41
+ BF16 Inference:
42
+ - 8x H200 (1x H200 node)
43
+ - 16x H100 (2x H100 nodes)
44
+ - 16x A100 80GB (2x A100 80GB nodes)
45
+
46
+ ### Model Architecture:
47
+
48
+ Nemotron-4-340B-Base is trained with a global batch-size of 2304, a sequence length of 4096 tokens, uses Grouped-Query Attention (GQA), and Rotary Position Embeddings (RoPE).
49
+
50
+ **Architecture Type:** Transformer Decoder (auto-regressive language model)
51
+
52
+ **Network Architecture:**
53
+ Nemotron-4
54
+
55
+ ### Usage
56
+
57
+ Deployment and inference with Nemotron-4-340B-Base can be done in three steps using NeMo Framework:
58
+
59
+ 1. Create a Python script to interact with the deployed model.
60
+ 2. Create a Bash script to start the inference server.
61
+ 3. Schedule a Slurm job to distribute the model across 2 nodes and associate them with the inference server.
62
+
63
+ The first task is for the Python Script.
64
+
65
+ 1. Define the Python script ``call_server.py``
66
+
67
+ ```python
68
+ import requests
69
+ import json
70
+ headers = {"Content-Type": "application/json"}
71
+ def text_generation(data, ip='localhost', port=None):
72
+ resp = requests.put(f'http://{ip}:{port}/generate', data=json.dumps(data), headers=headers)
73
+ return resp.json()
74
+ def get_generation(prompt, greedy, add_BOS, token_to_gen, min_tokens, temp, top_p, top_k, repetition, batch=False):
75
+ data = {
76
+ "sentences": [prompt] if not batch else prompt,
77
+ "tokens_to_generate": int(token_to_gen),
78
+ "temperature": temp,
79
+ "add_BOS": add_BOS,
80
+ "top_k": top_k,
81
+ "top_p": top_p,
82
+ "greedy": greedy,
83
+ "all_probs": False,
84
+ "repetition_penalty": repetition,
85
+ "min_tokens_to_generate": int(min_tokens),
86
+ "end_strings": ["<|endoftext|>", "<extra_id_1>", "\x11", "<extra_id_1>User"],
87
+ }
88
+ sentences = text_generation(data, port=1424)['sentences']
89
+ return sentences[0] if not batch else sentences
90
+ PROMPT_TEMPLATE = "{prompt}"
91
+ question = "Write a poem on NVIDIA in the style of Shakespeare"
92
+ prompt = PROMPT_TEMPLATE.format(prompt=question)
93
+ print(prompt)
94
+ 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)
95
+ response = response[len(prompt):]
96
+ print(response)
97
+ ```
98
+
99
+
100
+ 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.05```) and calls the Python script ``call_server.py``. The Bash script ``nemo_inference.sh`` is as follows:
101
+
102
+
103
+ ```bash
104
+ NEMO_FILE=$1
105
+ WEB_PORT=1424
106
+ depends_on () {
107
+ HOST=$1
108
+ PORT=$2
109
+ STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
110
+ while [ $STATUS -ne 0 ]
111
+ do
112
+ echo "waiting for server ($HOST:$PORT) to be up"
113
+ sleep 10
114
+ STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
115
+ done
116
+ echo "server ($HOST:$PORT) is up running"
117
+ }
118
+ /usr/bin/python3 /opt/NeMo/examples/nlp/language_modeling/megatron_gpt_eval.py \
119
+ gpt_model_file=$NEMO_FILE \
120
+ pipeline_model_parallel_split_rank=0 \
121
+ server=True tensor_model_parallel_size=8 \
122
+ trainer.precision=bf16 pipeline_model_parallel_size=2 \
123
+ trainer.devices=8 \
124
+ trainer.num_nodes=2 \
125
+ web_server=False \
126
+ port=${WEB_PORT} &
127
+ SERVER_PID=$!
128
+ readonly local_rank="${LOCAL_RANK:=${SLURM_LOCALID:=${OMPI_COMM_WORLD_LOCAL_RANK:-}}}"
129
+ if [ $SLURM_NODEID -eq 0 ] && [ $local_rank -eq 0 ]; then
130
+ depends_on "0.0.0.0" ${WEB_PORT}
131
+ echo "start get json"
132
+ sleep 5
133
+ echo "SLURM_NODEID: $SLURM_NODEID"
134
+ echo "local_rank: $local_rank"
135
+ /usr/bin/python3 /scripts/call_server.py
136
+ echo "clean up dameons: $$"
137
+ kill -9 $SERVER_PID
138
+ pkill python
139
+ fi
140
+ wait
141
+ ```
142
+
143
+
144
+ 3. Launch ``nemo_inference.sh`` with a Slurm script defined like below, which starts a 2-node job for model inference.
145
+
146
+ ```bash
147
+ #!/bin/bash
148
+ #SBATCH -A SLURM-ACCOUNT
149
+ #SBATCH -p SLURM-PARITION
150
+ #SBATCH -N 2
151
+ #SBATCH -J generation
152
+ #SBATCH --ntasks-per-node=8
153
+ #SBATCH --gpus-per-node=8
154
+ set -x
155
+ RESULTS=<PATH_TO_YOUR_SCRIPTS_FOLDER>
156
+ OUTFILE="${RESULTS}/slurm-%j-%n.out"
157
+ ERRFILE="${RESULTS}/error-%j-%n.out"
158
+ MODEL=<PATH_TO>/Nemotron-4-340B-Base
159
+ CONTAINER="nvcr.io/nvidia/nemo:24.05"
160
+ MOUNTS="--container-mounts=<PATH_TO_YOUR_SCRIPTS_FOLDER>:/scripts,MODEL:/model"
161
+ read -r -d '' cmd <<EOF
162
+ bash /scripts/nemo_inference.sh /model
163
+ EOF
164
+ srun -o $OUTFILE -e $ERRFILE --container-image="$CONTAINER" $MOUNTS bash -c "${cmd}"
165
+ ```
166
+
167
+
168
+ ### Dataset & Training
169
+
170
+ The training corpus for Nemotron-4-340B-Base consists of English and multilingual text, as well as code. Our sources cover a variety of document types such as: webpages, dialogue, articles, and other written materials. The corpus spans domains including legal, math, science, finance, and more. In our continued training set, we introduce a small portion of question-answering, and alignment style data to improve model performance.
171
+
172
+ **Data Freshness:** The pretraining data has a cutoff of June 2023.
173
+
174
+ ### Evaluation Results
175
+
176
+ #### Overview
177
+
178
+ *5-shot performance.* Language Understanding evaluated using Massive Multitask Language Understanding:
179
+ | Average |
180
+ | :------------- |
181
+ | 81.1 |
182
+
183
+ *Zero-shot performance.* Evaluated using select datasets from the LM Evaluation Harness with additions:
184
+ | HellaSwag | Winogrande | BBH| ARC-Challenge |
185
+ | :------------- | :------------- | :------------- | :------------- |
186
+ | 90.53 | 89.50 | 85.44 | 94.28 |
187
+
188
+ *Chain of Thought (CoT)*. Multilingual capabilities evaluated using Multilingual Grade School Math:
189
+
190
+ | ES Exact Match (%) | JA Exact Match (%) | TH Exact Match (%) |
191
+ | :------------- | :------------- | :------------- |
192
+ | 68.8 | 69.6 | 68.4 |
193
+
194
+ *Code generation performance*. Evaluated using HumanEval:
195
+ | p@1, 0-Shot |
196
+ | :------------- |
197
+ | 57.3 |
198
+
199
+ ### Limitations
200
+
201
+ 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.
202
+
203
+ ### Ethical Considerations
204
+
205
+ 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-base). Please report security vulnerabilities or NVIDIA AI Concerns [here](https://www.nvidia.com/en-us/support/submit-security-vulnerability/).