| |
|
Megatron-GPT 5B是基于Transformer的语言模型。GPT是指一类类似于GPT-2和3的仅解码器的Transformer模型,而5B表示总的可训练参数数量(50亿)[1, 2]。
这个模型是用 NeMo Megatron 进行训练的。
您需要安装NVIDIA Apex和NeMo。
git clone https://github.com/ericharper/apex.git cd apex git checkout nm_v1.11.0 pip install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" --global-option="--fast_layer_norm" --global-option="--distributed_adam" --global-option="--deprecated_fused_adam" ./
pip install nemo_toolkit['nlp']==1.11.0
或者,您可以使用预先安装了所有依赖项的NeMo Megatron训练Docker容器。
注意:下面的示例在两个GPU上启动了一个具有2个张量并行性(TP)和1个流水线并行性(PP)的模型变体。
git clone https://github.com/NVIDIA/NeMo.git cd NeMo/examples/nlp/language_modeling git checkout v1.11.0 python megatron_gpt_eval.py gpt_model_file=nemo_gpt5B_fp16_tp2.nemo server=True tensor_model_parallel_size=2 trainer.devices=2
import json
import requests
port_num = 5555
headers = {"Content-Type": "application/json"}
def request_data(data):
resp = requests.put('http://localhost:{}/generate'.format(port_num),
data=json.dumps(data),
headers=headers)
sentences = resp.json()['sentences']
return sentences
data = {
"sentences": ["Tell me an interesting fact about space travel."]*1,
"tokens_to_generate": 50,
"temperature": 1.0,
"add_BOS": True,
"top_k": 0,
"top_p": 0.9,
"greedy": False,
"all_probs": False,
"repetition_penalty": 1.2,
"min_tokens_to_generate": 2,
}
sentences = request_data(data)
print(sentences)
该模型是在 "The Piles" dataset prepared by Eleuther.AI 上进行训练的。[4]
零-shot性能。使用 LM Evaluation Test Suite from AI21 进行评估
| ARC-Challenge | ARC-Easy | RACE-middle | RACE-high | Winogrande | RTE | BoolQA | HellaSwag | PiQA |
|---|---|---|---|---|---|---|---|---|
| 0.3976 | 0.5566 | 0.5007 | 0.4171 | 0.6133 | 0.5812 | 0.6356 | 0.6298 | 0.7492 |
该模型是在从互联网抓取的数据上进行训练的。这些数据包含有害语言和社会偏见。因此,当使用有害提示进行提示时,模型可能会放大这些偏见并返回有害的回复。
[1] Improving Language Understanding by Generative Pre-Training
[2] Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelism
[4] The Pile: An 800GB Dataset of Diverse Text for Language Modeling
使用该模型的许可证受到 CC-BY-4.0 的保护。通过下载公共和发布版本的模型,您接受 CC-BY-4.0 许可证的条款和条件。
.hf-sanitized.hf-sanitized-zOD0gHjQNvYE8wIMkUkl4 img {display: inline;}