返回列表
[64GB]PyTorch1.11-Cann6.3rc3.1-Python3.9-Euler2.8.3
PyTorch
LLM
下载量:97
上传者:duanxinyu
点赞
0
有改进之处
0
收藏
收藏
版本信息
Python版本:3.9
CANN版本:6.3rc3.1
操作系统版本:Euler2.8
使用说明
当前镜像在BMS和ModelArts的notebook上均可使用。 # 大语言模型 ## Chatglm-6B ### 1.需要获取torch代码: ~~~ cp -rf /home/ma-user/ModelZoo-PyTorch ./ ~~~ ### 2.获取ADGEN数据集或者自有数据集: 若获取ADGEN数据集 ~~~ wget https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/AdvertiseGen.tar.gz tar -zxvf AdvertiseGen.tar.gz mv ./AdvertiseGen ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/ptuning ~~~ ### 3. 准备模型权重 ~~~ wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/tokenizer_config.json wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/tokenization_chatglm.py wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/test_modeling_chatglm.py wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/quantization.py wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model.bin.index.json wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00008-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00007-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00006-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00005-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00004-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00003-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00002-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/pytorch_model-00001-of-00008.bin wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/config.json wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/configuration_chatglm.py wget -P ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/model https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/glm/model/ice_text.model ~~~ ### 4. 覆盖文件 需要在运行前用./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/fix下的training_args.py替换路径下transformers/training_args.py ~~~ cp ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/fix/training_args.py /home/ma-user/anaconda3/envs/PyTorch-1.11/lib/python3.9/site-packages/transformers ~~~ ### 5. 训练微调 ~~~ cd ./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/ptuning bash preprocess.sh bash ds_train_finetune.sh # 全参微调 bash train.sh # 单卡微调需要先设置 export TRAIN_STATE=1 ~~~ ## Baichuan2-7B ### 1.需要获取torch代码: ~~~ pip install rich einops sympy regex decorator scipy setuptools-scm prompt-toolkit attrs accelerate sentencepiece transformers==4.28.1 cp -rf /home/ma-user/ModelZoo-PyTorch ./ ~~~ ### 2.获取waimai_10k数据集或者自有数据集: 若获取waimai_10k数据集 ~~~ cd ./ModelZoo-PyTorch/PyTorch/built-in/foundation/Baichuan2/7B wget https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/waimai_10k.csv python make_data.py # 运行前需要修改make_data.py中30行,将csv文件路径填入。 ~~~ ### 3. 准备模型权重 ~~~ wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/tokenizer_config.json wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/tokenizer.model wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/tokenization_baichuan.py wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/special_tokens_map.json wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/quantizer.py wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/pytorch_model.bin.index.json wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/pytorch_model-00002-of-00002.bin wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/pytorch_model-00001-of-00002.bin wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/generation_utils.py wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/configuration_baichuan.py wget -P ./Baichuan2-7B https://xx-proj.obs.cn-central-221.ovaijisuan.com/pytorch/Baichuan2_6B/config.json ~~~ ### 4. 覆盖文件 需要在运行前用./ModelZoo-PyTorch/PyTorch/built-in/foundation/ChatGLM-6B/fix下的training_args.py替换路径下transformers/training_args.py ~~~ cp ./transformers_modify/training_args.py /home/ma-user/anaconda3/envs/PyTorch-1.11/lib/python3.9/site-packages/transformers/ # 请输入 y 覆盖文件 cp ./transformers_modify/trainer.py /home/ma-user/anaconda3/envs/PyTorch-1.11/lib/python3.9/site-packages/transformers/ # 请输入 y 覆盖文件 cp ./transformers_modify/versions.py /home/ma-user/anaconda3/envs/PyTorch-1.11/lib/python3.9/site-packages/utils/ ~~~ ### 5. 训练微调 ~~~ bash ds_train_finetune.sh # 全参微调(需要八卡资源) ~~~ ### 6. 模型推理 运行前需要修改test.py文件原39行到44行。以及原69行内容;分别如下所示: ~~~ ###### 原39行到44行修改如下所示 ###### self.model = transformers.AutoModelForCausalLM.from_pretrained( self.model_path, torch_dtype=torch.float16, trust_remote_code=True, ).cuda() ##### 原69行修改如下所示 ####### base_classifier = BaichuanClassifier('Baichuan2-7B') ~~~ 修改完成后即可运行推理脚本 ~~~ bash ./run_test.sh ~~~
镜像地址
在其他AICC使用本镜像时,
1) 在本地arm宿主机通过docker pull 拉取上面镜像到本地(即执行docker pull remote_image_address)
2) 用docker tag 将局点信息和组织名替换成对应版本(即执行 docker tag local_image_address remote_image_address),
3) 用docker push 将修改后的镜像名称推送到局点的swr服务中(即执行docker push remote_image_address)
评论
若您有任何疑虑,您可以在这里反馈您的建议。
发布