Skip to content

Commit

Permalink
Merge pull request #6253 from hiyouga/hiyouga/qwen2vl_mm_proj
Browse files Browse the repository at this point in the history
[model] support qwen2vl train proj only
  • Loading branch information
hiyouga authored Dec 5, 2024
2 parents 561a8e5 + 99c6266 commit bcb4fb3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/train_full/qwen2vl_full_sft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ stage: sft
do_train: true
finetuning_type: full
freeze_vision_tower: true # choices: [true, false]
train_mm_proj_only: false # choices: [true, false]
deepspeed: examples/deepspeed/ds_z3_config.json # choices: [ds_z0_config.json, ds_z2_config.json, ds_z3_config.json]

### dataset
Expand Down
7 changes: 3 additions & 4 deletions src/llamafactory/model/model_utils/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,10 @@ def get_forbidden_modules(config: "PretrainedConfig", finetuning_args: "Finetuni
forbidden_modules.add("language_model")

elif model_type == "qwen2_vl":
if finetuning_args.freeze_vision_tower:
forbidden_modules.add("visual")

if finetuning_args.train_mm_proj_only:
raise ValueError("Qwen2-VL models do not support `train_mm_proj_only`.")
forbidden_modules.update({"visual.patch_embed", "visual.blocks", "model", "lm_head"})
elif finetuning_args.freeze_vision_tower:
forbidden_modules.add("visual")

return forbidden_modules

Expand Down

0 comments on commit bcb4fb3

Please sign in to comment.