InternVL2-40B 微调实战
环境准备
基于 Python 环境的 SWIFT 框架进行全量微调。
训练命令
CUDA_VISIBLE_DEVICES=0,1,2,6 swift sft \
--model_type internvl2-40b \
--dataset coco-en-2-mini \
--max_length 4096 \
--sft_type full \
--model_id_or_path <model_path>
核心参数配置
- dtype: bf16
- batch_size: 1 (per_device_train_batch_size)
- gradient_accumulation_steps: 16
- learning_rate: 1e-05
- optim: adamw_torch
- lr_scheduler_type: cosine
- template_type: internvl2
- target_modules: language_model|mlp1
模型与数据信息
- 参数量: 约 40068M,全部可训练 (100% Trainable)
- 数据集: ModelScope (coco_2014_caption)
- 训练集: 40099 条
- 验证集: 405 条
- 系统提示词: 书生多模态大模型标准介绍
注意事项
- FlashAttention 未安装,默认使用 eager 实现。
- 加载自定义数据集时需设置
trust_remote_code=True。 - 视觉编码器与语言模型均启用梯度更新。

