XTuner 认知微调
1. 训练步骤
- 安装conda 环境
- 安装 XTuner 框架,这里通过源码安装
- 准备模型
ln -s /root/share/new_models/Shanghai_AI_Laboratory/internlm2-chat-1_8b Shanghai_AI_Laboratory/internlm2-chat-1_8b
[
{"conversation": [{"input": "请介绍一下你自己", "output": "我是海绵没有宝宝的小助手,内在是上海AI实验室书生·浦语的1.8B大模型哦"}]},
{"conversation": [{"input": "你在实战营做什么", "output": "我在这里帮助海绵没有宝宝完成XTuner微调个人小助手的任务"}]},
]
- 准备微调配置脚本,并调整相应的配置(数据目录,模型目录)
xtuner copy-cfg internlm2_chat_1_8b_qlora_alpaca_e3 .
xtuner train ./internlm2_chat_1_8b_qlora_alpaca_e3_copy.py
pth_file=`ls -t ./work_dirs/internlm2_chat_1_8b_qlora_alpaca_e3_copy/*.pth | head -n 1` && MKL_SERVICE_FORCE_INTEL=1 MKL_THREADING_LAYER=GNU xtuner convert pth_to_hf ./internlm2_chat_1_8b_qlora_alpaca_e3_copy.py ${pth_file} ./hf
MKL_SERVICE_FORCE_INTEL=1 MKL_THREADING_LAYER=GNU xtuner convert merge /root/InternLM/XTuner/Shanghai_AI_Laboratory/internlm2-chat-1_8b ./hf ./merged --max-shard-size 2GB
pip install streamlit==1.36.0
streamlit run xtuner_streamlit_demo.py
2. 训练后