|  | 
 | 
 
Megatron-GPT 1.3B 是一种基于 Transformer 的语言模型。GPT 是指一类类似于 GPT-2 和 GPT-3 的仅包含解码器的 Transformer 模型,而 1.3B 是指总的可训练参数数量为 13 亿 [1, 2]。它具有 Tensor 并行性 (TP) 为 1,Pipeline 并行性 (PP) 为 1,可以适配单个 NVIDIA GPU。
该模型是通过 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 容器。
注意。该模型的 Tensor 并行性 (TP) 为 1,Pipeline 并行性 (PP) 为 1,可以适配单个 NVIDIA GPU。
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_gpt1.3B_fp16.nemo server=True tensor_model_parallel_size=1 trainer.devices=1
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]
零样本性能。使用 LM Evaluation Test Suite from AI21 进行评估
| ARC-Challenge | ARC-Easy | RACE-middle | RACE-high | Winogrande | RTE | BoolQA | HellaSwag | PiQA | 
|---|---|---|---|---|---|---|---|---|
| 0.3012 | 0.4596 | 0.459 | 0.3797 | 0.5343 | 0.5451 | 0.5979 | 0.4443 | 0.6834 | 
该模型是在从互联网抓取的数据上进行训练的。这些数据包含有害语言和社会偏见。因此,当使用有害提示进行提示时,模型可能放大这些偏见并返回有害回答。
[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-Te97goFnymZf3nukOOEZR img {display: inline;}