XTuner 微调个人小助手认知
基础任务 使用 XTuner 微调 InternLM2-Chat-7B 实现自己的小助手认知
创建python虚拟环境并安装xtuner
xtuner list-cfg
构造微调数据
更改jsonl文件,把其中的“机智流”替换为自己的名字
python change_script.py ./assistant_Tuner.jsonl ./assistant_Tuner_change.jsonl
微调模型
xtuner train ./config/internlm2_5_chat_7b_qlora_alpaca_e3_copy.py \
--deepspeed deepspeed_zero2 \
--work-dir ./work_dirs/assistTuner
获得.bin后缀的lora adapter:
MKL_SERVICE_FORCE_INTEL=1 MKL_THREADING_LAYER=GNU xtuner convert pth_to_hf ./internlm2_5_chat_7b_qlora_alpaca_e3_copy.py ./iter_289.pth ./hf
合并adapter得到完整模型权重:
MKL_SERVICE_FORCE_INTEL=1 MKL_THREADING_LAYER=GNU xtuner convert merge /root/finetune/models/internlm2_5-7b-chat ./hf ./merged --max-shard-size 4GB
启动 Web-UI
streamlit run app.py
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://xxx:8501
External URL: http://yyy:8501
打开浏览器,访问映射后的地址
然后输入以下问题,可以看到模型是按照微调数据集中的数据来做回答的:
任务完成!