InternVL 部署微调实践闯关任务
了解LMDeploy部署多模态大模型的核心代码,并运行提供的gradio代码,在UI界面体验与InternVL2的对话。
运行结果
总结
可以看到模型虽然能够根据图片回答问题,但是回答存在很多错误
了解XTuner,并利用给定数据集微调InternVL2-2B后,再次启动UI界面,体验模型美食鉴赏能力的变化。
环境配置
首先配置XTuner环境,并配置微调参数,微调数据集使用FoodieQA数据集,这里我们直接使用share目录下处理好的数据集
开始微调:xtuner train internvl_v2_internlm2_2b_lora_finetune_food --deepspeed deepspeed_zero2
微调完毕:
微调后,把模型checkpoint的格式转化为便于测试的格式:python xtuner/configs/internvl/v1_5/convert_to_official.py xtuner/configs/internvl/v2/internvl_v2_internlm2_2b_lora_finetune_food.py ./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/iter_640.pth ./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/lr35_ep10/
./work_dirs/internvl_v2_internlm2_2b_lora_finetune_food/lr35_ep10/
为转换后的模型checkpoint保存的路径。
修改MODEL_PATH为刚刚转换后保存的模型路径,再次启动应用:
cd /root/InternVL2-Tutorial
conda activate lmdeploy
python demo.py
运行结果
总结
可以看到微调后的模型能够正确回答出我们提出的问题