ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

多模态模型微调,怎么实现vit 和aligner 模型是全量微调,但同时 llm 使用lora 微调

Open zmqwer opened this issue 8 months ago • 4 comments

Checklist / 检查清单

  • [x] I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。

Question Description / 问题描述

想请教,怎么让vit 和 aligner,llm 各自使用不同的微调方式

zmqwer avatar Mar 05 '26 06:03 zmqwer

https://github.com/modelscope/ms-swift/tree/main/examples/train/multimodal/lora_llm_full_vit

Jintao-Huang avatar Mar 05 '26 06:03 Jintao-Huang

参考这个脚本里的参数设置,在ms-swift 3.x 版本里,设置参数train_type为lora_llm, 报错不支持lora_llm 参数 https://github.com/modelscope/ms-swift/blob/main/examples/train/multimodal/lora_llm_full_vit/sft.sh

zmqwer avatar Mar 05 '26 12:03 zmqwer

参考这个脚本里的参数设置,在ms-swift 3.x 版本里,设置参数train_type为lora_llm, 报错不支持lora_llm 参数 https://github.com/modelscope/ms-swift/blob/main/examples/train/multimodal/lora_llm_full_vit/sft.sh

你好,问题解决了吗?

freeneuro avatar Mar 17 '26 03:03 freeneuro

当前支持 lora_llm tuner 的版本可以这样跑,LLM 用 LoRA,ViT/aligner 全量训练。替换模型和数据路径:

NPROC_PER_NODE=4 swift sft \
  --model Qwen/Qwen2.5-VL-7B-Instruct \
  --dataset /path/to/train.jsonl \
  --tuner_type lora_llm \
  --torch_dtype bfloat16 \
  --learning_rate 1e-4 \
  --vit_lr 1e-5 \
  --aligner_lr 1e-5 \
  --lora_rank 16 \
  --lora_alpha 32 \
  --per_device_train_batch_size 1 \
  --gradient_accumulation_steps 4 \
  --num_train_epochs 1 \
  --max_length 8192 \
  --deepspeed zero2 \
  --output_dir output/lora-llm-full-vit

示例脚本 是对应官方脚本。3.x 报不认识 lora_llm 的话,先确认小版本;当时不支持这个 tuner 的版本需要升级,或自己配置语言侧 LoRA 和视觉侧 modules_to_save。当前 tuner 会额外保存视觉权重,推理时也要加载它。

yyh-sjtu avatar Nov 01 '26 15:11 yyh-sjtu