Open Jintao-Huang opened 2 days ago
qwen2-vl支持多图多伦对话训练吗?
can I train 72b with 2A6000? (248GB)
qwen2-vl支持多图多伦对话训练吗?
支持的
can I train 72b with 2_A6000? (2_48GB)
maybe qlora
# GPU Memory: 2 * 28GB
SIZE_FACTOR=8 MAX_PIXELS=602112 \
CUDA_VISIBLE_DEVICES=0,1 \
swift sft \
--model_type qwen2-vl-72b-instruct-gptq-int4 \
--model_id_or_path qwen/Qwen2-VL-72B-Instruct-GPTQ-Int4 \
--sft_type lora \
--dataset latex-ocr-print#20000
lora & device_map
# GPU Memory: 2 * 75GB
SIZE_FACTOR=8 MAX_PIXELS=602112 \
CUDA_VISIBLE_DEVICES=0,1 \
swift sft \
--model_type qwen2-vl-72b-instruct \
--model_id_or_path qwen/Qwen2-VL-72B-Instruct \
--sft_type lora \
--dataset latex-ocr-print#20000
More docs:
qwen2-vl: https://github.com/modelscope/ms-swift/blob/main/docs/source/Multi-Modal/qwen2-vl%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md
qwen1.5: https://github.com/modelscope/ms-swift/blob/main/docs/source/LLM/Qwen1.5%E5%85%A8%E6%B5%81%E7%A8%8B%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md
我们使用ms-swift对qwen2.5和qwen2-vl进行自我认知微调和图像OCR微调,并对微调后的模型进行推理。
在开始微调之前,请确保您的环境已正确安装
通常,大模型微调通常使用自定义数据集进行微调。在这里,我们将展示可直接运行的demo。
qwen2.5-72b-instruct
我们对Qwen2.5-72B-Instruct进行自我认知微调。
自我认知数据集:https://www.modelscope.cn/datasets/swift/self-cognition
通用混合数据集:
微调脚本:
自定义数据集文档可以查看:https://github.com/modelscope/ms-swift/blob/main/docs/source/Instruction/%E8%87%AA%E5%AE%9A%E4%B9%89%E4%B8%8E%E6%8B%93%E5%B1%95.md
微调显存消耗:
微调过程的loss可视化:
微调后推理脚本如下,这里的ckpt_dir需要修改为训练生成的last checkpoint文件夹。我们可以使用vLLM对merge后的checkpoint进行推理加速:
微调后模型对验证集进行推理的示例:
qwen2-vl-72b-instruct
我们对Qwen2-VL-72B-Instruct进行OCR微调。Grouding任务和视频微调的例子可以查看ms-swift文档:https://github.com/modelscope/ms-swift/blob/main/docs/source/Multi-Modal/qwen2-vl%E6%9C%80%E4%BD%B3%E5%AE%9E%E8%B7%B5.md
微调数据集:https://modelscope.cn/datasets/AI-ModelScope/LaTeX_OCR 微调脚本:
如果要使用自定义数据集,只需按以下方式进行指定:
自定义数据集格式:
微调显存消耗:
微调过程的loss可视化:(由于时间原因,这里只微调了250个steps)
微调后推理脚本如下,这里的ckpt_dir需要修改为训练生成的last checkpoint文件夹。我们可以使用vLLM对merge后的checkpoint进行推理加速:
微调后模型对验证集进行推理的示例: