Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
BAAI-WuDao 43e7396215 | 2 years ago | |
---|---|---|
.. | ||
chinese_sentencepiece | 2 years ago | |
data_utils | 2 years ago | |
docker | 2 years ago | |
fp16 | 2 years ago | |
model | 2 years ago | |
mpu | 2 years ago | |
openwebtext | 2 years ago | |
scripts | 2 years ago | |
README.md | 2 years ago | |
arguments.py | 2 years ago | |
change_mp.py | 2 years ago | |
configure_data.py | 2 years ago | |
detokenizer.py | 2 years ago | |
evaluate_perplexity.py | 2 years ago | |
generate_samples.py | 2 years ago | |
generation_utils.py | 2 years ago | |
gpt2_data_loader.py | 2 years ago | |
learning_rates.py | 2 years ago | |
pretrain_bert.py | 2 years ago | |
pretrain_gpt2.py | 2 years ago | |
requirements.txt | 2 years ago | |
utils.py | 2 years ago |
Under construction
本项目提供了智源研究院"文汇"
预训练模型Chinese-Transformer-XL的预训练和文本生成代码。[应用主页] [模型下载]
本模型使用了智源研究院发布的中文预训练语料WuDaoCorpus
。具体地,我们使用了WuDaoCorpus中来自百度百科+搜狗百科(133G)、知乎(131G)、百度知道(38G)的语料,一共303GB数据。
本模型使用了GPT-3
的训练目标,同时使用能够更好地处理长序列建模的Transformer-XL 替代了GPT中的Transformer。模型的结构与GPT-3
2.7B(32层,隐表示维度2560,每层32个注意力头)基本相同,因为Transformer-XL的结构改动,模型参数增加到了29亿。
为了验证模型的生成能力,我们在中文的开放域长文问答上进行了评测。我们从知乎
上随机选择了100个不同领域的、不在训练语料中的问题。对每个问题,由人类测试员对一个高赞同数回答、3个模型生成的回答和3个CPM
生成的回答在流畅度、信息量、相关度、总体四个维度进行打分。测评结果如下:
模型 | 流畅度(1-5) | 信息量(1-5) | 相关度(1-5) | 总体(1-10) |
---|---|---|---|---|
CPM | 2.66 | 2.47 | 2.36 | 4.32 |
文汇 | 3.44 | 3.25 | 3.21 | 5.97 |
人类答案 | 3.80 | 3.61 | 3.67 | 6.85 |
可以看到相比起CPM,"文汇"更接近人类所写的高赞答案。
根据requirements.txt
安装pytorch等基础依赖
pip install -r requirements.txt
如果要finetune模型参数,还需要安装DeepSpeed
DS_BUILD_OPS=1 pip install deepspeed
首先下载模型的checkpoint ,目录结构如下
.
└─ txl-2.9B
└─ mp_rank_00_model_states.pt
然后运行交互式生成脚本
bash scripts/generate_text.sh ./txl-2.9B
模型的finetune基于使用DeepSpeed。首先在scripts/ds_finetune_gpt_2.9B.sh
中修改NUM_WORKERS
和NUM_GPUS_PER_WORKER
为使用的节点数目和每个节点的GPU数量。如果使用多机训练的话,还要修改HOST_FILE_PATH
为hostfile的路径(DeepSpeed使用OpenMPI风格的hostfile
)。
然后运行finetune脚本
bash scripts/ds_finetune_gpt_2.9B.sh ./txl-2.9B ./data.json
其中./txl-2.9B
为checkpoint目录。./data.json
为finetune数据,格式为jsonl文件
,每条数据的格式为{"prompt": .., "text": ...}
。其中prompt为生成的context,text为生成的内容。
如果你在finetune的遇到了OOM错误(一般是因为GPU数量或者显存不足导致的),可以尝试在scripts/ds_config_2.9B_finetune.json的zero_optimization
部分添加"cpu_offload": true
,来开启ZeRO-Offload 以减少显存消耗。
如果你的显存大小比较有限,可以尝试使用模型并行来减少显存消耗。我们提供的模型checkpoint是在单卡上运行的。首先使用change_mp.py来对hceckpoint进行切分
python change_mp.py ./txl-2.9B 2
其中2表示2路模型并行。在推理和finetune的时候,将脚本中的MP_SIZE改为2,然后使用./txl-2.9B_MP2作为运行脚本时的checkpoint路径。
“悟道”项目开源模型
Python Text C++ Shell Cuda other
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》