Add files using large-upload tool
Browse files
README.md
CHANGED
@@ -4,3 +4,218 @@ 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 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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; 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 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. For best performance on a given task, users are encouraged to customize the completion model using the NeMo Framework 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).
|
31 |
+
|
32 |
+
**Model Developer:** NVIDIA
|
33 |
+
|
34 |
+
**Model Input:** Text
|
35 |
+
**Input Format:** String
|
36 |
+
**Input Parameters:** One-Dimensional (1D)
|
37 |
+
|
38 |
+
**Model Output:** Text
|
39 |
+
**Output Format:** String
|
40 |
+
**Output Parameters:** 1D
|
41 |
+
|
42 |
+
**Model Dates:** Nemotron-4-340B-Base was trained between December 2023 and May 2024
|
43 |
+
|
44 |
+
### Required Hardware
|
45 |
+
|
46 |
+
BF16 Inference:
|
47 |
+
- 8x H200 (1x H200 Node)
|
48 |
+
- 16x H100 (2x H100 Nodes)
|
49 |
+
- 16x A100 (2x A100 Nodes)
|
50 |
+
|
51 |
+
### Model Architecture:
|
52 |
+
|
53 |
+
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 RoPE positional embeddings.
|
54 |
+
|
55 |
+
**Architecture Type:** Transformer Decoder (auto-regressive language model)
|
56 |
+
|
57 |
+
**Network Architecture:**
|
58 |
+
Nemotron-4
|
59 |
+
|
60 |
+
### Usage
|
61 |
+
|
62 |
+
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``
|
63 |
+
|
64 |
+
```python
|
65 |
+
import requests
|
66 |
+
import json
|
67 |
+
|
68 |
+
headers = {"Content-Type": "application/json"}
|
69 |
+
|
70 |
+
def text_generation(data, ip='localhost', port=None):
|
71 |
+
resp = requests.put(f'http://{ip}:{port}/generate', data=json.dumps(data), headers=headers)
|
72 |
+
return resp.json()
|
73 |
+
|
74 |
+
|
75 |
+
def get_generation(prompt, greedy, add_BOS, token_to_gen, min_tokens, temp, top_p, top_k, repetition, batch=False):
|
76 |
+
data = {
|
77 |
+
"sentences": [prompt] if not batch else prompt,
|
78 |
+
"tokens_to_generate": int(token_to_gen),
|
79 |
+
"temperature": temp,
|
80 |
+
"add_BOS": add_BOS,
|
81 |
+
"top_k": top_k,
|
82 |
+
"top_p": top_p,
|
83 |
+
"greedy": greedy,
|
84 |
+
"all_probs": False,
|
85 |
+
"repetition_penalty": repetition,
|
86 |
+
"min_tokens_to_generate": int(min_tokens),
|
87 |
+
"end_strings": ["<|endoftext|>", "<extra_id_1>", "\x11", "<extra_id_1>User"],
|
88 |
+
}
|
89 |
+
sentences = text_generation(data, port=1424)['sentences']
|
90 |
+
return sentences[0] if not batch else sentences
|
91 |
+
|
92 |
+
PROMPT_TEMPLATE = "{prompt}"
|
93 |
+
|
94 |
+
question = "Write a poem on NVIDIA in the style of Shakespeare"
|
95 |
+
prompt = PROMPT_TEMPLATE.format(prompt=question)
|
96 |
+
print(prompt)
|
97 |
+
|
98 |
+
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)
|
99 |
+
response = response[len(prompt):]
|
100 |
+
print(response)
|
101 |
+
```
|
102 |
+
|
103 |
+
|
104 |
+
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,
|
105 |
+
|
106 |
+
|
107 |
+
```bash
|
108 |
+
NEMO_FILE=$1
|
109 |
+
WEB_PORT=1424
|
110 |
+
|
111 |
+
depends_on () {
|
112 |
+
HOST=$1
|
113 |
+
PORT=$2
|
114 |
+
STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
|
115 |
+
while [ $STATUS -ne 0 ]
|
116 |
+
do
|
117 |
+
echo "waiting for server ($HOST:$PORT) to be up"
|
118 |
+
sleep 10
|
119 |
+
STATUS=$(curl -X PUT http://$HOST:$PORT >/dev/null 2>/dev/null; echo $?)
|
120 |
+
done
|
121 |
+
echo "server ($HOST:$PORT) is up running"
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
+
/usr/bin/python3 /opt/NeMo/examples/nlp/language_modeling/megatron_gpt_eval.py \
|
126 |
+
gpt_model_file=$NEMO_FILE \
|
127 |
+
pipeline_model_parallel_split_rank=0 \
|
128 |
+
server=True tensor_model_parallel_size=8 \
|
129 |
+
trainer.precision=bf16 pipeline_model_parallel_size=2 \
|
130 |
+
trainer.devices=8 \
|
131 |
+
trainer.num_nodes=2 \
|
132 |
+
web_server=False \
|
133 |
+
port=${WEB_PORT} &
|
134 |
+
SERVER_PID=$!
|
135 |
+
|
136 |
+
readonly local_rank="${LOCAL_RANK:=${SLURM_LOCALID:=${OMPI_COMM_WORLD_LOCAL_RANK:-}}}"
|
137 |
+
if [ $SLURM_NODEID -eq 0 ] && [ $local_rank -eq 0 ]; then
|
138 |
+
depends_on "0.0.0.0" ${WEB_PORT}
|
139 |
+
|
140 |
+
echo "start get json"
|
141 |
+
sleep 5
|
142 |
+
|
143 |
+
echo "SLURM_NODEID: $SLURM_NODEID"
|
144 |
+
echo "local_rank: $local_rank"
|
145 |
+
/usr/bin/python3 /scripts/call_server.py
|
146 |
+
echo "clean up dameons: $$"
|
147 |
+
kill -9 $SERVER_PID
|
148 |
+
pkill python
|
149 |
+
fi
|
150 |
+
wait
|
151 |
+
```
|
152 |
+
|
153 |
+
|
154 |
+
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.
|
155 |
+
|
156 |
+
```bash
|
157 |
+
#!/bin/bash
|
158 |
+
#SBATCH -A SLURM-ACCOUNT
|
159 |
+
#SBATCH -p SLURM-PARITION
|
160 |
+
#SBATCH -N 2 # number of nodes
|
161 |
+
#SBATCH -J generation
|
162 |
+
#SBATCH --ntasks-per-node=8
|
163 |
+
#SBATCH --gpus-per-node=8
|
164 |
+
set -x
|
165 |
+
|
166 |
+
RESULTS=<PATH_TO_YOUR_SCRIPTS_FOLDER>
|
167 |
+
OUTFILE="${RESULTS}/slurm-%j-%n.out"
|
168 |
+
ERRFILE="${RESULTS}/error-%j-%n.out"
|
169 |
+
MODEL=<PATH_TO>/Nemotron-4-340B-Base
|
170 |
+
|
171 |
+
MOUNTS="--container-mounts=<PATH_TO_YOUR_SCRIPTS_FOLDER>:/scripts,MODEL:/model"
|
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 |
+
|
181 |
+
|
182 |
+
|
183 |
+
### Dataset & Training
|
184 |
+
|
185 |
+
The training corpus for Nemotron-4-340B-Base consists of English and multilingual text, as well as code. Our English 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, alignment style data to improve model performance.
|
186 |
+
|
187 |
+
**Data Freshness:** The pretraining data has a cutoff of June 2023
|
188 |
+
|
189 |
+
### Evaluation Results
|
190 |
+
|
191 |
+
#### Overview
|
192 |
+
|
193 |
+
|
194 |
+
|
195 |
+
*5-shot performance.* Language Understanding evaluated using [Massive Multitask Language Understanding](https://arxiv.org/abs/2009.03300):
|
196 |
+
| Average |
|
197 |
+
| ------------- |
|
198 |
+
| 81.1 |
|
199 |
+
|
200 |
+
*Zero-shot performance.* Evaluated using select datasets from the [LM Evaluation Harness](https://github.com/EleutherAI/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](https://arxiv.org/abs/2210.03057):
|
206 |
+
| ES Exact Match (%) | JA Exact Match (%) | TH Exact Match (%) |
|
207 |
+
| ------------- | ------------- | ------------- |
|
208 |
+
| 68.8 | 69.6 | 68.4 |
|
209 |
+
|
210 |
+
*Code generation performance*. Evaluated using [HumanEval](https://github.com/openai/human-eval):
|
211 |
+
| p@1, 0-Shot |
|
212 |
+
| ------------- |
|
213 |
+
| 57.3 |
|
214 |
+
|
215 |
+
### Limitations
|
216 |
+
|
217 |
+
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.
|
218 |
+
|
219 |
+
### Ethical Considerations
|
220 |
+
|
221 |
+
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/).
|