Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
lip01 43dc1452d5 | 4 months ago | |
---|---|---|
docs | 5 months ago | |
flash_attention | 5 months ago | |
search | 6 months ago | |
src | 5 months ago | |
tokenizer | 6 months ago | |
tools | 4 months ago | |
README.md | 5 months ago | |
ma-pre-start.sh | 5 months ago | |
predict_7B.py | 5 months ago | |
predict_200B.py | 5 months ago | |
train_7B.py | 5 months ago | |
train_200B.py | 5 months ago |
PengCheng-Mind 鹏城·脑海大模型是基于Transformer架构的自回归式语言模型。模型是基于中国算力网的国产软硬件平台进行开发和训练的。采用MindSpore框架实现在大规模集群上长期稳定的多维分布式并行训练。鹏城·脑海模型主要聚焦中文核心能力,兼顾英文和部分多语言能力。 当前模型仍在持续训练迭代中。
随着中国算力网的不断发展壮大,我们希望通过模型训练全流程开源开放的方式,将鹏城·脑海200B 模型培育为算力网上一个种子应用,吸引产学研界更多人参与到通用大语言模型基座的研究和应用中,一起助力国产智能软硬件生态的发展。
PengCheng-Mind 7B | 结构参数 |
---|---|
seq_length | 2048 |
vocab_size | 50048 |
embedding_size | 4096 |
num_layers | 32 |
num_heads | 32 |
支持 python >= 3.7.5, mindspore >= 2.0.0 版本.
推荐使用mindspore的官方 docker 镜像。
硬件平台 | 操作系统 | 框架 | 7B推理设备数量 | 7B微调设备数量 |
---|---|---|---|---|
Ascend 910 | EulerOS-aarch64 | MindSpore | 1卡 | ≥16卡 |
启动命令(修改脚本中 obs_ckpt_url为脑海7B预训练模型文件路径):
python predict_7B.py \
--run_type predict \
--mode 7B \
--vocab_size 50048 \
--seq_length 2048 \
--distribute true \
--use_pynative_op 1 \
--op_level_model_parallel_num 1 \
--device_num 1 \
--stage_num 1 \
--top_p 1.0 \
--top_k_num 3 \
--max_generate_length 100 \
--pre_trained true
参考数据部分
启动命令(修改脚本中 obs_ckpt_url为脑海7B预训练模型文件路径):
python train_7B.py \
--data_url YOUR_OUTPUT_PATH \
--mode 7B \
--vocab_size 50048 \
--seq_length 2048 \
--stage_num 2 \
--op_level_model_parallel 8 \
--micro_size 16 \
--optimizer_shard 1 \
--param_init_type fp16 \
--save_checkpoint True \
--save_checkpoint_steps 100 \
--recompute True \
--sequence_parallel True \
--save_checkpoint_bucket_dir YOUR_SFT_OBS_PATH \
--save_strategy_bucket_dir YOUR_SFT_strategySaving_OBS_PATH \
--pre_trained True
finetune 完后的模型是分片的,如果要进行推理,则先需要对模型进行合并。
合并脚本参考:
python tools/merge_ckpt_forpp.py --obs_save_path YOUR_OBS_SAVE_PATH
(1).微调时产生的策略文件:$strategy_name_prefix
(2).merge成单个ckpt的策略文件:$src_obs_strategy_inference
(3).微调产生的多个模型分片位置:$ckpt_obs_path
参考脚本:/tools/pre_process_data.py
在 YOUR_DATASET_PATH 目录下存放多个 xxx.json
文件,如果训练数据较多,最好每个 json
文件大小统一,且分开多个 json
存放,
大小可以 1M 一个文件。如果有繁体文字,需要转成简体,可以使用zhconv
。
每个 json
文本格式为(需要换行符号分割不同样本):
{"text": "sample1"}
{"text": "sample2"}
{"text": "sample2"}
python pre_process_data.py --input_glob "YOUR_DATASET_PATH/*.json" --output_file "YOUR_OUTPUT_PATH/mindrecord" --SEQ_LEN 4097
将会在YOUR_OUTPUT_PATH目录下生成mindrecord* 文件。
转换流程:
一、merged-NPU模型文件,转NPY中间文件
python tools/check_merged_ckpt_7B.py
(1).merge后单个NPU-ckpt文件路径:$ckpt_full_name
(2).转换出NPY文件路径:$ckpt_obs_path
二、NPY中间文件,通过torch库,执行以下转换脚本,转换生成GPU模型
python tools/convert_ms_to_megatron.py
(1).中间NPY文件路径:$ms_npy_base_path/merged_ckpt.npy
(2).输出GPU模型:$pt_save_path/model_optim_rng.pt
在模型下载页面有提供转好的pytorch模型,推理代码请看这里
数据集/算力来源声明
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》