NeMo
nvidia
Chris-Alexiuk commited on
Commit
b4dbbfe
1 Parent(s): 70ca52b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +217 -217
README.md CHANGED
@@ -1,217 +1,217 @@
1
- ---
2
- license: other
3
- license_name: nvidia-open-model-license
4
- license_link: >-
5
- https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf
6
- ---
7
-
8
- ## Nemotron-4-340B-Base
9
-
10
- [![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)
11
-
12
-
13
-
14
- ### Model Overview:
15
-
16
- 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.
17
-
18
- Under the NVIDIA Open Model License, NVIDIA confirms:
19
- Models are commercially usable.
20
- You are free to create and distribute Derivative Models.
21
- NVIDIA does not claim ownership to any outputs generated using the Models or Derivative Models
22
-
23
-
24
- ### License:
25
-
26
- [NVIDIA Open Model License](https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf)
27
-
28
- ### Intended use
29
-
30
- 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).
31
-
32
- **Model Developer:** NVIDIA
33
-
34
- **Model Dates:** Nemotron-4-340B-Base was trained between December 2023 and May 2024.
35
-
36
- ### Required Hardware
37
-
38
- BF16 Inference:
39
- - 8x H200 (1x H200 node)
40
- - 16x H100 (2x H100 nodes)
41
- - 16x A100 80GB (2x A100 80GB nodes)
42
-
43
- ### Model Architecture:
44
-
45
- 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).
46
-
47
- **Architecture Type:** Transformer Decoder (auto-regressive language model)
48
-
49
- **Network Architecture:**
50
- Nemotron-4
51
-
52
- ### Usage
53
-
54
- Deployment and inference with Nemotron-4-340B-Base can be done in three steps using NeMo Framework:
55
-
56
- 1. Create a Python script to interact with the deployed model.
57
- 2. Create a Bash script to start the inference server.
58
- 3. Schedule a Slurm job to distribute the model across 4 nodes and associate them with the inference server.
59
-
60
-
61
- 1. Define the Python script ``call_server.py``
62
-
63
- ```python
64
- import requests
65
- import json
66
-
67
- headers = {"Content-Type": "application/json"}
68
-
69
- def text_generation(data, ip='localhost', port=None):
70
- resp = requests.put(f'http://{ip}:{port}/generate', data=json.dumps(data), headers=headers)
71
- return resp.json()
72
-
73
-
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
-
91
- PROMPT_TEMPLATE = "{prompt}"
92
-
93
- question = "Write a poem on NVIDIA in the style of Shakespeare"
94
- prompt = PROMPT_TEMPLATE.format(prompt=question)
95
- print(prompt)
96
-
97
- 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)
98
- response = response[len(prompt):]
99
- print(response)
100
- ```
101
-
102
-
103
- 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:
104
-
105
-
106
- ```bash
107
- NEMO_FILE=$1
108
- WEB_PORT=1424
109
-
110
- depends_on () {
111
- HOST=$1
112
- PORT=$2
113
- STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
114
- while [ $STATUS -ne 0 ]
115
- do
116
- echo "waiting for server ($HOST:$PORT) to be up"
117
- sleep 10
118
- STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
119
- done
120
- echo "server ($HOST:$PORT) is up running"
121
- }
122
-
123
-
124
- /usr/bin/python3 /opt/NeMo/examples/nlp/language_modeling/megatron_gpt_eval.py \
125
- gpt_model_file=$NEMO_FILE \
126
- pipeline_model_parallel_split_rank=0 \
127
- server=True tensor_model_parallel_size=8 \
128
- trainer.precision=bf16 pipeline_model_parallel_size=2 \
129
- trainer.devices=8 \
130
- trainer.num_nodes=2 \
131
- web_server=False \
132
- port=${WEB_PORT} &
133
- SERVER_PID=$!
134
-
135
- readonly local_rank="${LOCAL_RANK:=${SLURM_LOCALID:=${OMPI_COMM_WORLD_LOCAL_RANK:-}}}"
136
- if [ $SLURM_NODEID -eq 0 ] && [ $local_rank -eq 0 ]; then
137
- depends_on "0.0.0.0" ${WEB_PORT}
138
-
139
- echo "start get json"
140
- sleep 5
141
-
142
- echo "SLURM_NODEID: $SLURM_NODEID"
143
- echo "local_rank: $local_rank"
144
- /usr/bin/python3 /scripts/call_server.py
145
- echo "clean up dameons: $$"
146
- kill -9 $SERVER_PID
147
- pkill python
148
- fi
149
- wait
150
- ```
151
-
152
-
153
- 3. Launch ``nemo_inference.sh`` with a Slurm script defined like below, which starts a 2-node job for model inference.
154
-
155
- ```bash
156
- #!/bin/bash
157
- #SBATCH -A SLURM-ACCOUNT
158
- #SBATCH -p SLURM-PARITION
159
- #SBATCH -N 2
160
- #SBATCH -J generation
161
- #SBATCH --ntasks-per-node=8
162
- #SBATCH --gpus-per-node=8
163
- set -x
164
-
165
- RESULTS=<PATH_TO_YOUR_SCRIPTS_FOLDER>
166
- OUTFILE="${RESULTS}/slurm-%j-%n.out"
167
- ERRFILE="${RESULTS}/error-%j-%n.out"
168
- MODEL=<PATH_TO>/Nemotron-4-340B-Base
169
- CONTAINER="nvcr.io/nvidia/nemo:24.01.framework"
170
- MOUNTS="--container-mounts=<PATH_TO_YOUR_SCRIPTS_FOLDER>:/scripts,MODEL:/model"
171
-
172
- read -r -d '' cmd <<EOF
173
- bash /scripts/nemo_inference.sh /model
174
- EOF
175
-
176
- srun -o $OUTFILE -e $ERRFILE --container-image="$CONTAINER" $MOUNTS bash -c "${cmd}"
177
- ```
178
-
179
-
180
- ### Dataset & Training
181
-
182
- 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.
183
-
184
- **Data Freshness:** The pretraining data has a cutoff of June 2023.
185
-
186
- ### Evaluation Results
187
-
188
- #### Overview
189
-
190
- *5-shot performance.* Language Understanding evaluated using [Massive Multitask Language Understanding](https://arxiv.org/abs/2009.03300):
191
- | Average |
192
- | :------------- |
193
- | 81.1 |
194
-
195
- *Zero-shot performance.* Evaluated using select datasets from the [LM Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) with additions:
196
- | HellaSwag | Winogrande | BBH| ARC-Challenge |
197
- | :------------- | :------------- | :------------- | :------------- |
198
- | 90.53 | 89.50 | 85.44 | 94.28 |
199
-
200
- *Chain of Thought (CoT)*. Multilingual capabilities evaluated using [Multilingual Grade School Math](https://arxiv.org/abs/2210.03057):
201
-
202
- | ES Exact Match (%) | JA Exact Match (%) | TH Exact Match (%) |
203
- | :------------- | :------------- | :------------- |
204
- | 68.8 | 69.6 | 68.4 |
205
-
206
- *Code generation performance*. Evaluated using [HumanEval](https://github.com/openai/human-eval):
207
- | p@1, 0-Shot |
208
- | :------------- |
209
- | 57.3 |
210
-
211
- ### Limitations
212
-
213
- 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.
214
-
215
- ### Ethical Considerations
216
-
217
- 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: >-
5
+ https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf
6
+ ---
7
+
8
+ ## Nemotron-4-340B-Base
9
+
10
+ [![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)
11
+
12
+
13
+
14
+ ### Model Overview:
15
+
16
+ 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.
17
+
18
+ Under the NVIDIA Open Model License, NVIDIA confirms:
19
+ - Models are commercially usable.
20
+ - You are free to create and distribute Derivative Models.
21
+ - NVIDIA does not claim ownership to any outputs generated using the Models or Derivative Models
22
+
23
+
24
+ ### License:
25
+
26
+ [NVIDIA Open Model License](https://developer.download.nvidia.com/licenses/nvidia-open-model-license-agreement-june-2024.pdf)
27
+
28
+ ### Intended use
29
+
30
+ 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).
31
+
32
+ **Model Developer:** NVIDIA
33
+
34
+ **Model Dates:** Nemotron-4-340B-Base was trained between December 2023 and May 2024.
35
+
36
+ ### Required Hardware
37
+
38
+ BF16 Inference:
39
+ - 8x H200 (1x H200 node)
40
+ - 16x H100 (2x H100 nodes)
41
+ - 16x A100 80GB (2x A100 80GB nodes)
42
+
43
+ ### Model Architecture:
44
+
45
+ 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).
46
+
47
+ **Architecture Type:** Transformer Decoder (auto-regressive language model)
48
+
49
+ **Network Architecture:**
50
+ Nemotron-4
51
+
52
+ ### Usage
53
+
54
+ Deployment and inference with Nemotron-4-340B-Base can be done in three steps using NeMo Framework:
55
+
56
+ 1. Create a Python script to interact with the deployed model.
57
+ 2. Create a Bash script to start the inference server.
58
+ 3. Schedule a Slurm job to distribute the model across 4 nodes and associate them with the inference server.
59
+
60
+
61
+ 1. Define the Python script ``call_server.py``
62
+
63
+ ```python
64
+ import requests
65
+ import json
66
+
67
+ headers = {"Content-Type": "application/json"}
68
+
69
+ def text_generation(data, ip='localhost', port=None):
70
+ resp = requests.put(f'http://{ip}:{port}/generate', data=json.dumps(data), headers=headers)
71
+ return resp.json()
72
+
73
+
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
+
91
+ PROMPT_TEMPLATE = "{prompt}"
92
+
93
+ question = "Write a poem on NVIDIA in the style of Shakespeare"
94
+ prompt = PROMPT_TEMPLATE.format(prompt=question)
95
+ print(prompt)
96
+
97
+ 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)
98
+ response = response[len(prompt):]
99
+ print(response)
100
+ ```
101
+
102
+
103
+ 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:
104
+
105
+
106
+ ```bash
107
+ NEMO_FILE=$1
108
+ WEB_PORT=1424
109
+
110
+ depends_on () {
111
+ HOST=$1
112
+ PORT=$2
113
+ STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
114
+ while [ $STATUS -ne 0 ]
115
+ do
116
+ echo "waiting for server ($HOST:$PORT) to be up"
117
+ sleep 10
118
+ STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
119
+ done
120
+ echo "server ($HOST:$PORT) is up running"
121
+ }
122
+
123
+
124
+ /usr/bin/python3 /opt/NeMo/examples/nlp/language_modeling/megatron_gpt_eval.py \
125
+ gpt_model_file=$NEMO_FILE \
126
+ pipeline_model_parallel_split_rank=0 \
127
+ server=True tensor_model_parallel_size=8 \
128
+ trainer.precision=bf16 pipeline_model_parallel_size=2 \
129
+ trainer.devices=8 \
130
+ trainer.num_nodes=2 \
131
+ web_server=False \
132
+ port=${WEB_PORT} &
133
+ SERVER_PID=$!
134
+
135
+ readonly local_rank="${LOCAL_RANK:=${SLURM_LOCALID:=${OMPI_COMM_WORLD_LOCAL_RANK:-}}}"
136
+ if [ $SLURM_NODEID -eq 0 ] && [ $local_rank -eq 0 ]; then
137
+ depends_on "0.0.0.0" ${WEB_PORT}
138
+
139
+ echo "start get json"
140
+ sleep 5
141
+
142
+ echo "SLURM_NODEID: $SLURM_NODEID"
143
+ echo "local_rank: $local_rank"
144
+ /usr/bin/python3 /scripts/call_server.py
145
+ echo "clean up dameons: $$"
146
+ kill -9 $SERVER_PID
147
+ pkill python
148
+ fi
149
+ wait
150
+ ```
151
+
152
+
153
+ 3. Launch ``nemo_inference.sh`` with a Slurm script defined like below, which starts a 2-node job for model inference.
154
+
155
+ ```bash
156
+ #!/bin/bash
157
+ #SBATCH -A SLURM-ACCOUNT
158
+ #SBATCH -p SLURM-PARITION
159
+ #SBATCH -N 2
160
+ #SBATCH -J generation
161
+ #SBATCH --ntasks-per-node=8
162
+ #SBATCH --gpus-per-node=8
163
+ set -x
164
+
165
+ RESULTS=<PATH_TO_YOUR_SCRIPTS_FOLDER>
166
+ OUTFILE="${RESULTS}/slurm-%j-%n.out"
167
+ ERRFILE="${RESULTS}/error-%j-%n.out"
168
+ MODEL=<PATH_TO>/Nemotron-4-340B-Base
169
+ CONTAINER="nvcr.io/nvidia/nemo:24.01.framework"
170
+ MOUNTS="--container-mounts=<PATH_TO_YOUR_SCRIPTS_FOLDER>:/scripts,MODEL:/model"
171
+
172
+ read -r -d '' cmd <<EOF
173
+ bash /scripts/nemo_inference.sh /model
174
+ EOF
175
+
176
+ srun -o $OUTFILE -e $ERRFILE --container-image="$CONTAINER" $MOUNTS bash -c "${cmd}"
177
+ ```
178
+
179
+
180
+ ### Dataset & Training
181
+
182
+ 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.
183
+
184
+ **Data Freshness:** The pretraining data has a cutoff of June 2023.
185
+
186
+ ### Evaluation Results
187
+
188
+ #### Overview
189
+
190
+ *5-shot performance.* Language Understanding evaluated using [Massive Multitask Language Understanding](https://arxiv.org/abs/2009.03300):
191
+ | Average |
192
+ | :------------- |
193
+ | 81.1 |
194
+
195
+ *Zero-shot performance.* Evaluated using select datasets from the [LM Evaluation Harness](https://github.com/EleutherAI/lm-evaluation-harness) with additions:
196
+ | HellaSwag | Winogrande | BBH| ARC-Challenge |
197
+ | :------------- | :------------- | :------------- | :------------- |
198
+ | 90.53 | 89.50 | 85.44 | 94.28 |
199
+
200
+ *Chain of Thought (CoT)*. Multilingual capabilities evaluated using [Multilingual Grade School Math](https://arxiv.org/abs/2210.03057):
201
+
202
+ | ES Exact Match (%) | JA Exact Match (%) | TH Exact Match (%) |
203
+ | :------------- | :------------- | :------------- |
204
+ | 68.8 | 69.6 | 68.4 |
205
+
206
+ *Code generation performance*. Evaluated using [HumanEval](https://github.com/openai/human-eval):
207
+ | p@1, 0-Shot |
208
+ | :------------- |
209
+ | 57.3 |
210
+
211
+ ### Limitations
212
+
213
+ 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.
214
+
215
+ ### Ethical Considerations
216
+
217
+ 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/).