BBBBCHAN TRAE CLI commited on
Commit
2a482a9
·
verified ·
1 Parent(s): 4c895f3

Sync StreamDelta directory

Browse files

Co-authored-by: TRAE CLI <noreply@bytedance.com>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. docs/resources/asyncengine.png +3 -0
  2. docs/resources/deepeyes.png +3 -0
  3. docs/resources/dpo_data.png +3 -0
  4. docs/resources/grpo.png +3 -0
  5. docs/resources/grpo_clevr_count.png +3 -0
  6. docs/resources/grpo_code.png +3 -0
  7. docs/resources/grpo_countdown.png +3 -0
  8. docs/resources/grpo_countdown_1.png +3 -0
  9. docs/resources/grpo_geoqa.png +3 -0
  10. docs/resources/grpo_multi_turn.png +3 -0
  11. docs/resources/grpo_openr1_multimodal.png +3 -0
  12. docs/resources/gym_env.png +3 -0
  13. docs/resources/kto_data.png +3 -0
  14. docs/resources/multiturn_pipeline.png +3 -0
  15. docs/resources/web-ui-en.jpg +3 -0
  16. docs/resources/web-ui.jpg +3 -0
  17. examples/train/multimodal/ocr.sh +27 -0
  18. examples/train/multimodal/omni/infer.sh +10 -0
  19. examples/train/multimodal/omni/sft.sh +39 -0
  20. examples/train/multimodal/rlhf/dpo/full.sh +32 -0
  21. examples/train/multimodal/rlhf/dpo/lora.sh +35 -0
  22. examples/train/multimodal/rlhf/gkd/fast.sh +49 -0
  23. examples/train/multimodal/rlhf/gkd/full.sh +34 -0
  24. examples/train/multimodal/rlhf/kto.sh +34 -0
  25. examples/train/multimodal/video.sh +33 -0
  26. examples/train/multimodal/vit_gradient_checkpointing.sh +37 -0
  27. examples/train/new_special_tokens/infer.sh +6 -0
  28. examples/train/new_special_tokens/merge_lora.sh +13 -0
  29. examples/train/new_special_tokens/tokens.txt +100 -0
  30. examples/train/new_special_tokens/train.sh +31 -0
  31. examples/train/optimizer/muon.sh +31 -0
  32. examples/train/packing/dpo.sh +30 -0
  33. examples/train/packing/dpo_vlm.sh +32 -0
  34. examples/train/packing/liger_kernel.sh +31 -0
  35. examples/train/packing/llm.sh +32 -0
  36. examples/train/packing/qwen2_5_omni.sh +40 -0
  37. examples/train/packing/qwen2_5_vl.sh +36 -0
  38. examples/train/packing/streaming.sh +34 -0
  39. examples/train/padding_free/dpo_vlm.sh +33 -0
  40. examples/train/padding_free/sft.sh +31 -0
  41. examples/train/plugins/loss_scale.sh +22 -0
  42. examples/train/plugins/tuner_phi4_mm.sh +22 -0
  43. examples/train/predict_with_generate/train.sh +30 -0
  44. examples/train/pretrain/train.sh +31 -0
  45. examples/train/qlora/awq/merge_lora.sh +5 -0
  46. examples/train/qlora/awq/train.sh +28 -0
  47. examples/train/qlora/bnb/merge_lora.sh +4 -0
  48. examples/train/qlora/bnb/train.sh +34 -0
  49. examples/train/qlora/gptq.sh +27 -0
  50. examples/train/qlora/hqq.sh +31 -0
docs/resources/asyncengine.png ADDED

Git LFS Details

  • SHA256: e45caf4012a44fd1065d11971fb9fcf7730a18e7ee97fc2455d35fc33229e07b
  • Pointer size: 131 Bytes
  • Size of remote file: 956 kB
docs/resources/deepeyes.png ADDED

Git LFS Details

  • SHA256: c36883b9e3ec0c5c104959e2d51558b5ff25678cf7c9916391631aa9692023da
  • Pointer size: 131 Bytes
  • Size of remote file: 874 kB
docs/resources/dpo_data.png ADDED

Git LFS Details

  • SHA256: 8d87ca58f3ac43a79836ba40f5d9cb788b8fabc26d717fb4e8eb1f1400f6598d
  • Pointer size: 131 Bytes
  • Size of remote file: 355 kB
docs/resources/grpo.png ADDED

Git LFS Details

  • SHA256: 1205d144192ae04901251d52b23424451bb2dece97399bbcdd3ce31671579305
  • Pointer size: 130 Bytes
  • Size of remote file: 30.6 kB
docs/resources/grpo_clevr_count.png ADDED

Git LFS Details

  • SHA256: 7192dc4f04801dbdff30bed098a16a7e21212a773ba7b6dc1424b261feca366f
  • Pointer size: 131 Bytes
  • Size of remote file: 671 kB
docs/resources/grpo_code.png ADDED

Git LFS Details

  • SHA256: 5f396d9ce5ce9de323d7a6ffa8d53f783d938a242088b191f46a293268193b64
  • Pointer size: 131 Bytes
  • Size of remote file: 294 kB
docs/resources/grpo_countdown.png ADDED

Git LFS Details

  • SHA256: 1b55fe6864e0c92549940d6989d92b3ab22be38a035cff3694525252737fc91e
  • Pointer size: 132 Bytes
  • Size of remote file: 2.23 MB
docs/resources/grpo_countdown_1.png ADDED

Git LFS Details

  • SHA256: b78dc3ce1cd541e76f2c557dea3aff06b278bb3b5413946a92c584cf42c1369f
  • Pointer size: 131 Bytes
  • Size of remote file: 785 kB
docs/resources/grpo_geoqa.png ADDED

Git LFS Details

  • SHA256: 71246376b16f2ff288542dca2ff31532b16ef99f5e862797463d548e447e1f8d
  • Pointer size: 132 Bytes
  • Size of remote file: 2.24 MB
docs/resources/grpo_multi_turn.png ADDED

Git LFS Details

  • SHA256: 25804a46bf35f8925348064edd8e3fcee501fa95a6cebf45ef1ae0d1cdd6dc02
  • Pointer size: 132 Bytes
  • Size of remote file: 1.52 MB
docs/resources/grpo_openr1_multimodal.png ADDED

Git LFS Details

  • SHA256: 050f56792468a4c9797a90314e322c16dd916bde3be24a7ce7c7b96381e70d9e
  • Pointer size: 132 Bytes
  • Size of remote file: 2.3 MB
docs/resources/gym_env.png ADDED

Git LFS Details

  • SHA256: 3e5b9827992d1b432fd3b9ff749efe7da01032afce574f5c22c0467c6888450a
  • Pointer size: 131 Bytes
  • Size of remote file: 203 kB
docs/resources/kto_data.png ADDED

Git LFS Details

  • SHA256: becb20db8a8b890718f3f9e1752dc6669a018ed19a344f155fbe5123521aff49
  • Pointer size: 131 Bytes
  • Size of remote file: 164 kB
docs/resources/multiturn_pipeline.png ADDED

Git LFS Details

  • SHA256: f8c1565822f749f6531bc28b3e854f0066fcf0ae44038a3364ca7d222312bc55
  • Pointer size: 131 Bytes
  • Size of remote file: 203 kB
docs/resources/web-ui-en.jpg ADDED

Git LFS Details

  • SHA256: 6ad958b680650b4f900f1a99560e825975f1a5807702c6fbbaef8e4f0e2a5efe
  • Pointer size: 131 Bytes
  • Size of remote file: 175 kB
docs/resources/web-ui.jpg ADDED

Git LFS Details

  • SHA256: 5e83bb4b4ecda9386286b99c6e83551f1dd1fdcdaf7be2efa3117208e3806000
  • Pointer size: 131 Bytes
  • Size of remote file: 182 kB
examples/train/multimodal/ocr.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 20GB
2
+ CUDA_VISIBLE_DEVICES=0 \
3
+ MAX_PIXELS=1003520 \
4
+ swift sft \
5
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
6
+ --dataset 'AI-ModelScope/LaTeX_OCR:human_handwrite#20000' \
7
+ --load_from_cache_file true \
8
+ --split_dataset_ratio 0.01 \
9
+ --train_type lora \
10
+ --torch_dtype bfloat16 \
11
+ --num_train_epochs 1 \
12
+ --per_device_train_batch_size 1 \
13
+ --per_device_eval_batch_size 1 \
14
+ --learning_rate 1e-4 \
15
+ --lora_rank 8 \
16
+ --lora_alpha 32 \
17
+ --target_modules all-linear \
18
+ --freeze_vit true \
19
+ --gradient_accumulation_steps 16 \
20
+ --eval_steps 50 \
21
+ --save_steps 50 \
22
+ --save_total_limit 2 \
23
+ --logging_steps 5 \
24
+ --max_length 4096 \
25
+ --output_dir output \
26
+ --warmup_ratio 0.05 \
27
+ --dataloader_num_workers 4
examples/train/multimodal/omni/infer.sh ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ VIDEO_MAX_PIXELS=50176 \
3
+ FPS_MAX_FRAMES=12 \
4
+ MAX_PIXELS=1003520 \
5
+ ENABLE_AUDIO_OUTPUT=0 \
6
+ swift infer \
7
+ --adapters output/vx-xxx/checkpoint-xxx \
8
+ --stream true \
9
+ --load_data_args true \
10
+ --max_new_tokens 2048
examples/train/multimodal/omni/sft.sh ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4*35GB
2
+ # A demo for four modalities that can be run directly
3
+ nproc_per_node=4
4
+
5
+ # If using zero3, please set `ENABLE_AUDIO_OUTPUT=0`.
6
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
7
+ ENABLE_AUDIO_OUTPUT=1 \
8
+ NPROC_PER_NODE=$nproc_per_node \
9
+ VIDEO_MAX_PIXELS=50176 \
10
+ FPS_MAX_FRAMES=12 \
11
+ MAX_PIXELS=1003520 \
12
+ swift sft \
13
+ --model Qwen/Qwen2.5-Omni-7B \
14
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#2000' \
15
+ 'AI-ModelScope/LaTeX_OCR:human_handwrite#2000' \
16
+ 'speech_asr/speech_asr_aishell1_trainsets:validation#2000' \
17
+ 'swift/VideoChatGPT:all#2000' \
18
+ --load_from_cache_file true \
19
+ --split_dataset_ratio 0.01 \
20
+ --train_type lora \
21
+ --torch_dtype bfloat16 \
22
+ --num_train_epochs 1 \
23
+ --per_device_train_batch_size 1 \
24
+ --per_device_eval_batch_size 1 \
25
+ --learning_rate 1e-4 \
26
+ --lora_rank 8 \
27
+ --lora_alpha 32 \
28
+ --target_modules all-linear \
29
+ --freeze_vit true \
30
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
31
+ --eval_steps 50 \
32
+ --save_steps 50 \
33
+ --save_total_limit 2 \
34
+ --logging_steps 5 \
35
+ --max_length 2048 \
36
+ --output_dir output \
37
+ --warmup_ratio 0.05 \
38
+ --dataloader_num_workers 4 \
39
+ --deepspeed zero2
examples/train/multimodal/rlhf/dpo/full.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 50GiB
2
+ nproc_per_node=4
3
+
4
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
5
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
6
+ NPROC_PER_NODE=$nproc_per_node \
7
+ MAX_PIXELS=1003520 \
8
+ swift rlhf \
9
+ --rlhf_type dpo \
10
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
11
+ --dataset 'swift/RLAIF-V-Dataset#20000' \
12
+ --load_from_cache_file true \
13
+ --split_dataset_ratio 0.01 \
14
+ --train_type full \
15
+ --torch_dtype bfloat16 \
16
+ --num_train_epochs 1 \
17
+ --per_device_train_batch_size 1 \
18
+ --per_device_eval_batch_size 1 \
19
+ --learning_rate 1e-5 \
20
+ --freeze_vit true \
21
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
22
+ --eval_steps 100 \
23
+ --save_steps 100 \
24
+ --save_total_limit 2 \
25
+ --deepspeed zero3 \
26
+ --logging_steps 5 \
27
+ --max_length 4096 \
28
+ --output_dir output \
29
+ --warmup_ratio 0.05 \
30
+ --dataloader_num_workers 4 \
31
+ --dataset_num_proc 4 \
32
+ --save_only_model true
examples/train/multimodal/rlhf/dpo/lora.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 50GiB
2
+ # You can refer to `https://github.com/QwenLM/Qwen2.5-VL` for the meaning of the `MAX_PIXELS` parameter.
3
+ # --rlhf_type cpo/orpo/simpo/rm are also supported
4
+ nproc_per_node=2
5
+
6
+ CUDA_VISIBLE_DEVICES=0,1 \
7
+ NPROC_PER_NODE=$nproc_per_node \
8
+ MAX_PIXELS=1003520 \
9
+ swift rlhf \
10
+ --rlhf_type dpo \
11
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
12
+ --dataset 'swift/RLAIF-V-Dataset#20000' \
13
+ --load_from_cache_file true \
14
+ --split_dataset_ratio 0.01 \
15
+ --train_type lora \
16
+ --torch_dtype bfloat16 \
17
+ --num_train_epochs 1 \
18
+ --per_device_train_batch_size 1 \
19
+ --per_device_eval_batch_size 1 \
20
+ --learning_rate 1e-4 \
21
+ --lora_rank 8 \
22
+ --lora_alpha 32 \
23
+ --target_modules all-linear \
24
+ --freeze_vit true \
25
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
26
+ --eval_steps 100 \
27
+ --save_steps 100 \
28
+ --save_total_limit 2 \
29
+ --deepspeed zero2 \
30
+ --logging_steps 5 \
31
+ --max_length 4096 \
32
+ --output_dir output \
33
+ --warmup_ratio 0.05 \
34
+ --dataloader_num_workers 4 \
35
+ --dataset_num_proc 4
examples/train/multimodal/rlhf/gkd/fast.sh ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ export teacher_model='OpenGVLab/InternVL3-8B'
3
+
4
+ NPROC_PER_NODE=4 \
5
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
6
+ swift infer \
7
+ --model $teacher_model \
8
+ --infer_backend vllm \
9
+ --val_dataset 'modelscope/coco_2014_caption:validation#5000' \
10
+ --vllm_gpu_memory_utilization 0.9 \
11
+ --vllm_max_model_len 8192 \
12
+ --max_new_tokens 2048 \
13
+ --write_batch_size 1000 \
14
+ --result_path new_coco_dataset.jsonl
15
+
16
+
17
+ # 4 * 42GiB, 3.05s/it
18
+ NPROC_PER_NODE=4 \
19
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
20
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
21
+ swift rlhf \
22
+ --rlhf_type gkd \
23
+ --model OpenGVLab/InternVL3-2B-Pretrained \
24
+ --teacher_model $teacher_model \
25
+ --train_type full \
26
+ --dataset 'new_coco_dataset.jsonl' \
27
+ --load_from_cache_file true \
28
+ --split_dataset_ratio 0.01 \
29
+ --torch_dtype bfloat16 \
30
+ --num_train_epochs 1 \
31
+ --per_device_train_batch_size 4 \
32
+ --per_device_eval_batch_size 4 \
33
+ --learning_rate 1e-5 \
34
+ --freeze_vit true \
35
+ --gradient_accumulation_steps 1 \
36
+ --eval_steps 100 \
37
+ --save_steps 100 \
38
+ --save_total_limit 2 \
39
+ --logging_steps 5 \
40
+ --max_length 4096 \
41
+ --output_dir output \
42
+ --warmup_ratio 0.05 \
43
+ --save_only_model true \
44
+ --dataloader_num_workers 4 \
45
+ --dataset_num_proc 4 \
46
+ --deepspeed zero2 \
47
+ --padding_free true \
48
+ --attn_impl flash_attn \
49
+ --lmbda 0
examples/train/multimodal/rlhf/gkd/full.sh ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 45GiB, 10.29s/it
2
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
3
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
4
+ MASTER_PORT=29501 \
5
+ NPROC_PER_NODE=4 \
6
+ swift rlhf \
7
+ --rlhf_type gkd \
8
+ --model OpenGVLab/InternVL3-2B-Pretrained \
9
+ --teacher_model OpenGVLab/InternVL3-8B \
10
+ --dataset 'modelscope/coco_2014_caption:validation#2000' \
11
+ --load_from_cache_file true \
12
+ --split_dataset_ratio 0.01 \
13
+ --train_type full \
14
+ --seq_kd true \
15
+ --torch_dtype bfloat16 \
16
+ --num_train_epochs 1 \
17
+ --per_device_train_batch_size 4 \
18
+ --per_device_eval_batch_size 4 \
19
+ --learning_rate 1e-5 \
20
+ --freeze_vit true \
21
+ --gradient_accumulation_steps 1 \
22
+ --eval_steps 50 \
23
+ --save_steps 50 \
24
+ --save_total_limit 2 \
25
+ --deepspeed zero2 \
26
+ --attn_impl flash_attn \
27
+ --logging_steps 5 \
28
+ --max_length 4096 \
29
+ --max_completion_length 512 \
30
+ --output_dir output \
31
+ --warmup_ratio 0.05 \
32
+ --dataloader_num_workers 4 \
33
+ --dataset_num_proc 4 \
34
+ --save_only_model true
examples/train/multimodal/rlhf/kto.sh ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Due to the absence of a multi-modal open-source dataset for kto,
2
+ # we will use a pure text kto dataset as an example here.
3
+ nproc_per_node=2
4
+
5
+ CUDA_VISIBLE_DEVICES=0,1 \
6
+ NPROC_PER_NODE=$nproc_per_node \
7
+ MAX_PIXELS=1003520 \
8
+ swift rlhf \
9
+ --rlhf_type kto \
10
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
11
+ --dataset 'AI-ModelScope/ultrafeedback-binarized-preferences-cleaned-kto#10000' \
12
+ --load_from_cache_file true \
13
+ --split_dataset_ratio 0.01 \
14
+ --train_type lora \
15
+ --torch_dtype bfloat16 \
16
+ --num_train_epochs 1 \
17
+ --per_device_train_batch_size 1 \
18
+ --per_device_eval_batch_size 1 \
19
+ --learning_rate 1e-4 \
20
+ --lora_rank 8 \
21
+ --lora_alpha 32 \
22
+ --target_modules all-linear \
23
+ --freeze_vit true \
24
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
25
+ --eval_steps 100 \
26
+ --save_steps 100 \
27
+ --save_total_limit 2 \
28
+ --deepspeed zero2 \
29
+ --logging_steps 5 \
30
+ --max_length 4096 \
31
+ --output_dir output \
32
+ --warmup_ratio 0.05 \
33
+ --dataloader_num_workers 4 \
34
+ --dataset_num_proc 4
examples/train/multimodal/video.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 2*24GB
2
+ # You can refer to `https://github.com/QwenLM/Qwen2.5-VL` for the meaning of the `VIDEO_MAX_PIXELS` parameter.
3
+ nproc_per_node=2
4
+
5
+ CUDA_VISIBLE_DEVICES=0,1 \
6
+ NPROC_PER_NODE=$nproc_per_node \
7
+ VIDEO_MAX_PIXELS=50176 \
8
+ FPS_MAX_FRAMES=12 \
9
+ swift sft \
10
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
11
+ --dataset swift/VideoChatGPT:all \
12
+ --load_from_cache_file true \
13
+ --split_dataset_ratio 0.01 \
14
+ --train_type lora \
15
+ --torch_dtype bfloat16 \
16
+ --num_train_epochs 1 \
17
+ --per_device_train_batch_size 1 \
18
+ --per_device_eval_batch_size 1 \
19
+ --learning_rate 1e-4 \
20
+ --lora_rank 8 \
21
+ --lora_alpha 32 \
22
+ --target_modules all-linear \
23
+ --freeze_vit true \
24
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
25
+ --eval_steps 50 \
26
+ --save_steps 50 \
27
+ --save_total_limit 2 \
28
+ --logging_steps 5 \
29
+ --max_length 2048 \
30
+ --output_dir output \
31
+ --warmup_ratio 0.05 \
32
+ --dataloader_num_workers 4 \
33
+ --deepspeed zero2
examples/train/multimodal/vit_gradient_checkpointing.sh ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # gc true, vgc true: 48GiB, 2.45s/it
2
+ # gc true, vgc false: 62GiB 2.32s/it
3
+ # gc false, vgc true: 56GiB 2.16s/it
4
+ # gc false, vgc false: 77GiB 1.95s/it
5
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
6
+ NPROC_PER_NODE=4 \
7
+ VIDEO_MAX_PIXELS=50176 \
8
+ FPS_MAX_FRAMES=12 \
9
+ swift sft \
10
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
11
+ --dataset swift/VideoChatGPT:all \
12
+ --load_from_cache_file true \
13
+ --split_dataset_ratio 0.01 \
14
+ --train_type full \
15
+ --torch_dtype bfloat16 \
16
+ --num_train_epochs 1 \
17
+ --per_device_train_batch_size 4 \
18
+ --per_device_eval_batch_size 4 \
19
+ --learning_rate 1e-5 \
20
+ --freeze_vit false \
21
+ --freeze_aligner false \
22
+ --gradient_accumulation_steps 1 \
23
+ --gradient_checkpointing true \
24
+ --vit_gradient_checkpointing true \
25
+ --eval_steps 100 \
26
+ --save_steps 100 \
27
+ --save_total_limit 2 \
28
+ --logging_steps 5 \
29
+ --max_length 2048 \
30
+ --output_dir output \
31
+ --warmup_ratio 0.05 \
32
+ --dataloader_num_workers 4 \
33
+ --deepspeed zero3 \
34
+ --use_liger_kernel true \
35
+ --attn_impl flash_attn \
36
+ --padding_free true \
37
+ --save_only_model true
examples/train/new_special_tokens/infer.sh ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift infer \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --max_batch_size 16 \
5
+ --load_data_args true \
6
+ --temperature 0
examples/train/new_special_tokens/merge_lora.sh ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift export \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --merge_lora true
5
+
6
+
7
+ # infer
8
+ CUDA_VISIBLE_DEVICES=0 \
9
+ swift infer \
10
+ --adapters output/vx-xxx/checkpoint-xxx-merged \
11
+ --max_batch_size 16 \
12
+ --load_data_args true \
13
+ --temperature 0
examples/train/new_special_tokens/tokens.txt ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <|0|>
2
+ <|1|>
3
+ <|2|>
4
+ <|3|>
5
+ <|4|>
6
+ <|5|>
7
+ <|6|>
8
+ <|7|>
9
+ <|8|>
10
+ <|9|>
11
+ <|10|>
12
+ <|11|>
13
+ <|12|>
14
+ <|13|>
15
+ <|14|>
16
+ <|15|>
17
+ <|16|>
18
+ <|17|>
19
+ <|18|>
20
+ <|19|>
21
+ <|20|>
22
+ <|21|>
23
+ <|22|>
24
+ <|23|>
25
+ <|24|>
26
+ <|25|>
27
+ <|26|>
28
+ <|27|>
29
+ <|28|>
30
+ <|29|>
31
+ <|30|>
32
+ <|31|>
33
+ <|32|>
34
+ <|33|>
35
+ <|34|>
36
+ <|35|>
37
+ <|36|>
38
+ <|37|>
39
+ <|38|>
40
+ <|39|>
41
+ <|40|>
42
+ <|41|>
43
+ <|42|>
44
+ <|43|>
45
+ <|44|>
46
+ <|45|>
47
+ <|46|>
48
+ <|47|>
49
+ <|48|>
50
+ <|49|>
51
+ <|50|>
52
+ <|51|>
53
+ <|52|>
54
+ <|53|>
55
+ <|54|>
56
+ <|55|>
57
+ <|56|>
58
+ <|57|>
59
+ <|58|>
60
+ <|59|>
61
+ <|60|>
62
+ <|61|>
63
+ <|62|>
64
+ <|63|>
65
+ <|64|>
66
+ <|65|>
67
+ <|66|>
68
+ <|67|>
69
+ <|68|>
70
+ <|69|>
71
+ <|70|>
72
+ <|71|>
73
+ <|72|>
74
+ <|73|>
75
+ <|74|>
76
+ <|75|>
77
+ <|76|>
78
+ <|77|>
79
+ <|78|>
80
+ <|79|>
81
+ <|80|>
82
+ <|81|>
83
+ <|82|>
84
+ <|83|>
85
+ <|84|>
86
+ <|85|>
87
+ <|86|>
88
+ <|87|>
89
+ <|88|>
90
+ <|89|>
91
+ <|90|>
92
+ <|91|>
93
+ <|92|>
94
+ <|93|>
95
+ <|94|>
96
+ <|95|>
97
+ <|96|>
98
+ <|97|>
99
+ <|98|>
100
+ <|99|>
examples/train/new_special_tokens/train.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 26GB
2
+ # This example is just a demo showing how to add new_special_tokens.
3
+ NPROC_PER_NODE=4 \
4
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
5
+ swift sft \
6
+ --model Qwen/Qwen2.5-7B-Instruct \
7
+ --train_type lora \
8
+ --dataset 'swift/new_special_tokens' \
9
+ --split_dataset_ratio 0.01 \
10
+ --new_special_tokens 'examples/train/new_special_tokens/tokens.txt' \
11
+ --torch_dtype bfloat16 \
12
+ --num_train_epochs 5 \
13
+ --per_device_train_batch_size 16 \
14
+ --per_device_eval_batch_size 16 \
15
+ --padding_free true \
16
+ --attn_impl flash_attn \
17
+ --learning_rate 1e-4 \
18
+ --lora_rank 16 \
19
+ --lora_alpha 32 \
20
+ --target_modules all-linear \
21
+ --modules_to_save embed_tokens lm_head \
22
+ --gradient_accumulation_steps 1 \
23
+ --eval_steps 500 \
24
+ --save_steps 500 \
25
+ --save_total_limit 2 \
26
+ --logging_steps 5 \
27
+ --max_length 2048 \
28
+ --output_dir output \
29
+ --warmup_ratio 0.05 \
30
+ --dataloader_num_workers 4 \
31
+ --deepspeed zero2
examples/train/optimizer/muon.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 17GB
2
+ # ref: https://github.com/MoonshotAI/Moonlight/blob/master/examples/toy_train.py
3
+ # `moonshotai/Moonlight-16B-A3B-Instruct` does not support training; here we use `Qwen/Qwen2.5-7B-Instruct` as an example.
4
+ CUDA_VISIBLE_DEVICES=0 \
5
+ swift sft \
6
+ --model Qwen/Qwen2.5-7B-Instruct \
7
+ --train_type lora \
8
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
9
+ 'AI-ModelScope/alpaca-gpt4-data-en#500' \
10
+ 'swift/self-cognition#500' \
11
+ --optimizer muon \
12
+ --torch_dtype bfloat16 \
13
+ --num_train_epochs 1 \
14
+ --per_device_train_batch_size 1 \
15
+ --per_device_eval_batch_size 1 \
16
+ --learning_rate 1e-4 \
17
+ --lora_rank 8 \
18
+ --lora_alpha 32 \
19
+ --target_modules all-linear \
20
+ --gradient_accumulation_steps 16 \
21
+ --eval_steps 50 \
22
+ --save_steps 50 \
23
+ --save_total_limit 2 \
24
+ --logging_steps 5 \
25
+ --max_length 2048 \
26
+ --output_dir output \
27
+ --system 'You are a helpful assistant.' \
28
+ --warmup_ratio 0.05 \
29
+ --dataloader_num_workers 4 \
30
+ --model_author swift \
31
+ --model_name swift-robot
examples/train/packing/dpo.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 50GiB; 2h
2
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
3
+ NPROC_PER_NODE=4 \
4
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
5
+ swift rlhf \
6
+ --rlhf_type dpo \
7
+ --model Qwen/Qwen2.5-7B-Instruct \
8
+ --train_type full \
9
+ --dataset AI-ModelScope/orpo-dpo-mix-40k \
10
+ --load_from_cache_file true \
11
+ --split_dataset_ratio 0.01 \
12
+ --torch_dtype bfloat16 \
13
+ --num_train_epochs 1 \
14
+ --per_device_train_batch_size 1 \
15
+ --per_device_eval_batch_size 1 \
16
+ --learning_rate 1e-5 \
17
+ --gradient_accumulation_steps 1 \
18
+ --eval_steps 200 \
19
+ --save_steps 200 \
20
+ --save_total_limit 2 \
21
+ --logging_steps 5 \
22
+ --max_length 8192 \
23
+ --output_dir output \
24
+ --warmup_ratio 0.05 \
25
+ --save_only_model true \
26
+ --dataloader_num_workers 4 \
27
+ --dataset_num_proc 4 \
28
+ --deepspeed zero3 \
29
+ --attn_impl flash_attn \
30
+ --packing true
examples/train/packing/dpo_vlm.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 50GiB; 6h
2
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
3
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
4
+ NPROC_PER_NODE=4 \
5
+ MAX_PIXELS=1003520 \
6
+ swift rlhf \
7
+ --rlhf_type dpo \
8
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
9
+ --dataset 'swift/RLAIF-V-Dataset' \
10
+ --load_from_cache_file true \
11
+ --split_dataset_ratio 0.01 \
12
+ --train_type full \
13
+ --torch_dtype bfloat16 \
14
+ --num_train_epochs 1 \
15
+ --per_device_train_batch_size 1 \
16
+ --per_device_eval_batch_size 1 \
17
+ --learning_rate 1e-5 \
18
+ --freeze_vit true \
19
+ --gradient_accumulation_steps 1 \
20
+ --eval_steps 200 \
21
+ --save_steps 200 \
22
+ --save_total_limit 2 \
23
+ --deepspeed zero3 \
24
+ --logging_steps 5 \
25
+ --max_length 8192 \
26
+ --output_dir output \
27
+ --warmup_ratio 0.05 \
28
+ --dataloader_num_workers 4 \
29
+ --dataset_num_proc 64 \
30
+ --attn_impl flash_attn \
31
+ --save_only_model true \
32
+ --packing true
examples/train/packing/liger_kernel.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Env: 4 * A100
2
+ # https://github.com/modelscope/ms-swift/blob/main/examples/megatron/long_text.sh
3
+ # Max Length: 16K
4
+ # GPU Memory: 4 * 42GB, Training Speed 10s/it
5
+ NPROC_PER_NODE=4 \
6
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
7
+ swift sft \
8
+ --model Qwen/Qwen2.5-7B \
9
+ --train_type full \
10
+ --dataset 'AI-ModelScope/LongAlpaca-12k' \
11
+ --load_from_cache_file true \
12
+ --split_dataset_ratio 0.01 \
13
+ --torch_dtype bfloat16 \
14
+ --per_device_train_batch_size 1 \
15
+ --per_device_eval_batch_size 1 \
16
+ --learning_rate 1e-5 \
17
+ --gradient_accumulation_steps 2 \
18
+ --packing true \
19
+ --eval_steps 200 \
20
+ --save_steps 200 \
21
+ --logging_steps 5 \
22
+ --max_length 16384 \
23
+ --warmup_ratio 0.05 \
24
+ --dataloader_num_workers 8 \
25
+ --dataset_num_proc 8 \
26
+ --save_total_limit 2 \
27
+ --save_only_model true \
28
+ --output_dir output/Qwen2.5-7B \
29
+ --deepspeed zero3 \
30
+ --use_liger_kernel true \
31
+ --attn_impl flash_attn
examples/train/packing/llm.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 22GB
2
+ CUDA_VISIBLE_DEVICES=0 \
3
+ swift sft \
4
+ --model Qwen/Qwen2.5-7B-Instruct \
5
+ --train_type lora \
6
+ --packing true \
7
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
8
+ 'AI-ModelScope/alpaca-gpt4-data-en#500' \
9
+ 'swift/self-cognition#500' \
10
+ --split_dataset_ratio 0.01 \
11
+ --torch_dtype bfloat16 \
12
+ --num_train_epochs 3 \
13
+ --attn_impl flash_attn \
14
+ --per_device_train_batch_size 1 \
15
+ --per_device_eval_batch_size 1 \
16
+ --learning_rate 1e-4 \
17
+ --lora_rank 8 \
18
+ --lora_alpha 32 \
19
+ --target_modules all-linear \
20
+ --gradient_accumulation_steps 4 \
21
+ --eval_steps 50 \
22
+ --save_steps 50 \
23
+ --save_total_limit 2 \
24
+ --logging_steps 5 \
25
+ --max_length 2048 \
26
+ --output_dir output \
27
+ --system 'You are a helpful assistant.' \
28
+ --warmup_ratio 0.05 \
29
+ --dataloader_num_workers 4 \
30
+ --dataset_num_proc 4 \
31
+ --model_author swift \
32
+ --model_name swift-robot
examples/train/packing/qwen2_5_omni.sh ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 32GB
2
+ # Multimodal packing currently only supports qwen2_vl, qwen2_5_vl, qwen2_5_omni, internvl2_5/3
3
+ # A demo for four modalities that can be run directly
4
+ # For local datasets, it is recommended to use streaming: `--streaming true` (save memory)
5
+ NPROC_PER_NODE=4 \
6
+ ENABLE_AUDIO_OUTPUT=1 \
7
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
8
+ VIDEO_MAX_PIXELS=50176 \
9
+ FPS_MAX_FRAMES=12 \
10
+ MAX_PIXELS=1003520 \
11
+ swift sft \
12
+ --model Qwen/Qwen2.5-Omni-7B \
13
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#10000' \
14
+ 'AI-ModelScope/LaTeX_OCR#2000' \
15
+ 'speech_asr/speech_asr_aishell1_trainsets:validation#2000' \
16
+ --load_from_cache_file true \
17
+ --split_dataset_ratio 0.01 \
18
+ --train_type lora \
19
+ --torch_dtype bfloat16 \
20
+ --attn_impl flash_attn \
21
+ --packing true \
22
+ --num_train_epochs 3 \
23
+ --per_device_train_batch_size 1 \
24
+ --per_device_eval_batch_size 1 \
25
+ --learning_rate 1e-4 \
26
+ --lora_rank 8 \
27
+ --lora_alpha 32 \
28
+ --target_modules all-linear \
29
+ --freeze_vit true \
30
+ --gradient_accumulation_steps 1 \
31
+ --eval_steps 50 \
32
+ --save_steps 50 \
33
+ --save_total_limit 2 \
34
+ --logging_steps 5 \
35
+ --max_length 4096 \
36
+ --output_dir output \
37
+ --warmup_ratio 0.05 \
38
+ --dataloader_num_workers 4 \
39
+ --dataset_num_proc 8 \
40
+ --deepspeed zero2
examples/train/packing/qwen2_5_vl.sh ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 36GB
2
+ # Multimodal packing currently only supports qwen2_vl, qwen2_5_vl, qwen2_5_omni, internvl2_5/3
3
+ # Efficiency: With packing: 10 minutes; Without packing: >=1 hour
4
+ # For local datasets, it is recommended to use streaming: `--streaming true` (save memory)
5
+ # You can also use padding_free to avoid the space/time cost caused by multi-modal packing:
6
+ # https://github.com/modelscope/ms-swift/blob/main/examples/train/padding_free/sft.sh
7
+ NPROC_PER_NODE=4 \
8
+ MAX_PIXELS=1003520 \
9
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
10
+ swift sft \
11
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
12
+ --train_type lora \
13
+ --dataset 'AI-ModelScope/LaTeX_OCR#20000' \
14
+ --load_from_cache_file true \
15
+ --split_dataset_ratio 0.01 \
16
+ --torch_dtype bfloat16 \
17
+ --attn_impl flash_attn \
18
+ --packing true \
19
+ --num_train_epochs 3 \
20
+ --per_device_train_batch_size 1 \
21
+ --per_device_eval_batch_size 1 \
22
+ --learning_rate 1e-4 \
23
+ --lora_rank 8 \
24
+ --lora_alpha 32 \
25
+ --target_modules all-linear \
26
+ --gradient_accumulation_steps 1 \
27
+ --eval_steps 100 \
28
+ --save_steps 100 \
29
+ --save_total_limit 2 \
30
+ --logging_steps 5 \
31
+ --max_length 8192 \
32
+ --output_dir output \
33
+ --warmup_ratio 0.05 \
34
+ --dataloader_num_workers 4 \
35
+ --dataset_num_proc 8 \
36
+ --deepspeed zero2
examples/train/packing/streaming.sh ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 36GB
2
+ # A demo using the Hugging Face dataset
3
+ # The first model weights will be saved around step 70.
4
+ NPROC_PER_NODE=4 \
5
+ MAX_PIXELS=1003520 \
6
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
7
+ HF_ENDPOINT=https://hf-mirror.com \
8
+ swift sft \
9
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
10
+ --train_type lora \
11
+ --dataset 'HF::linxy/LaTeX_OCR:full#20000' \
12
+ --torch_dtype bfloat16 \
13
+ --attn_impl flash_attn \
14
+ --streaming true \
15
+ --shuffle_buffer_size 1000 \
16
+ --packing true \
17
+ --save_strategy epoch \
18
+ --max_steps 1000 \
19
+ --max_epochs 5 \
20
+ --per_device_train_batch_size 1 \
21
+ --per_device_eval_batch_size 1 \
22
+ --learning_rate 1e-4 \
23
+ --lora_rank 8 \
24
+ --lora_alpha 32 \
25
+ --target_modules all-linear \
26
+ --gradient_accumulation_steps 1 \
27
+ --save_total_limit 2 \
28
+ --logging_steps 5 \
29
+ --max_length 8192 \
30
+ --output_dir output \
31
+ --warmup_ratio 0.05 \
32
+ --dataloader_num_workers 1 \
33
+ --dataset_num_proc 8 \
34
+ --deepspeed zero2
examples/train/padding_free/dpo_vlm.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # with padding_free: 4 * 53GiB, 3.55s/it
2
+ # without padding_free: 4 * 62GiB 4.41s/it
3
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
4
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
5
+ NPROC_PER_NODE=4 \
6
+ MAX_PIXELS=1003520 \
7
+ swift rlhf \
8
+ --rlhf_type dpo \
9
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
10
+ --dataset 'swift/RLAIF-V-Dataset#20000' \
11
+ --load_from_cache_file true \
12
+ --split_dataset_ratio 0.01 \
13
+ --train_type full \
14
+ --torch_dtype bfloat16 \
15
+ --num_train_epochs 1 \
16
+ --per_device_train_batch_size 4 \
17
+ --per_device_eval_batch_size 4 \
18
+ --learning_rate 1e-5 \
19
+ --freeze_vit true \
20
+ --gradient_accumulation_steps 1 \
21
+ --eval_steps 100 \
22
+ --save_steps 100 \
23
+ --save_total_limit 2 \
24
+ --deepspeed zero3 \
25
+ --logging_steps 5 \
26
+ --max_length 4096 \
27
+ --output_dir output \
28
+ --warmup_ratio 0.05 \
29
+ --dataloader_num_workers 4 \
30
+ --dataset_num_proc 4 \
31
+ --attn_impl flash_attn \
32
+ --save_only_model true \
33
+ --padding_free true
examples/train/padding_free/sft.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Supported multimodal models reference:
2
+ # https://github.com/modelscope/ms-swift/blob/main/examples/train/packing/qwen2_5_vl.sh
3
+ # without padding_free: 4 * 60GiB, 26h
4
+ # padding_free: 4 * 44GiB, 13h
5
+ NPROC_PER_NODE=4 \
6
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
7
+ swift sft \
8
+ --model Qwen/Qwen2.5-7B \
9
+ --train_type full \
10
+ --dataset 'liucong/Chinese-DeepSeek-R1-Distill-data-110k-SFT' \
11
+ --load_from_cache_file true \
12
+ --split_dataset_ratio 0.01 \
13
+ --torch_dtype bfloat16 \
14
+ --per_device_train_batch_size 8 \
15
+ --per_device_eval_batch_size 8 \
16
+ --learning_rate 1e-5 \
17
+ --gradient_accumulation_steps 1 \
18
+ --eval_steps 200 \
19
+ --save_steps 200 \
20
+ --logging_steps 5 \
21
+ --max_length 8192 \
22
+ --warmup_ratio 0.05 \
23
+ --dataloader_num_workers 8 \
24
+ --dataset_num_proc 8 \
25
+ --save_total_limit 2 \
26
+ --save_only_model true \
27
+ --output_dir output/Qwen2.5-7B \
28
+ --deepspeed zero3 \
29
+ --use_liger_kernel true \
30
+ --attn_impl flash_attn \
31
+ --padding_free true
examples/train/plugins/loss_scale.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # loss_scale all to train all tokens
2
+ # use loss_type loss_scale
3
+ # This is just an example
4
+ CUDA_VISIBLE_DEVICES=0 \
5
+ swift sft \
6
+ --model Qwen/Qwen2.5-7B-Instruct \
7
+ --train_type lora \
8
+ --dataset 'swift/self-cognition#1000' \
9
+ --num_train_epochs 1 \
10
+ --per_device_train_batch_size 1 \
11
+ --learning_rate 1e-4 \
12
+ --lora_rank 8 \
13
+ --lora_alpha 32 \
14
+ --gradient_accumulation_steps 16 \
15
+ --eval_steps 100 \
16
+ --save_steps 100 \
17
+ --save_total_limit 2 \
18
+ --logging_steps 5 \
19
+ --model_author swift \
20
+ --model_name swift-robot \
21
+ --loss_scale all \
22
+ --loss_type loss_scale
examples/train/plugins/tuner_phi4_mm.sh ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # `--train_type dummy`
2
+ CUDA_VISIBLE_DEVICES=0 \
3
+ swift sft \
4
+ --model LLM-Research/Phi-4-multimodal-instruct \
5
+ --dataset 'AI-ModelScope/LaTeX_OCR:human_handwrite#20000' \
6
+ --load_from_cache_file true \
7
+ --split_dataset_ratio 0.01 \
8
+ --train_type dummy \
9
+ --torch_dtype bfloat16 \
10
+ --num_train_epochs 1 \
11
+ --per_device_train_batch_size 1 \
12
+ --per_device_eval_batch_size 1 \
13
+ --learning_rate 1e-4 \
14
+ --gradient_accumulation_steps 16 \
15
+ --eval_steps 200 \
16
+ --save_steps 200 \
17
+ --save_total_limit 2 \
18
+ --logging_steps 5 \
19
+ --max_length 2048 \
20
+ --output_dir output \
21
+ --warmup_ratio 0.05 \
22
+ --dataloader_num_workers 4
examples/train/predict_with_generate/train.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 20GiB
2
+ CUDA_VISIBLE_DEVICES=0 \
3
+ MAX_PIXELS=1003520 \
4
+ swift sft \
5
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
6
+ --dataset 'AI-ModelScope/LaTeX_OCR:human_handwrite#20000' \
7
+ --load_from_cache_file true \
8
+ --split_dataset_ratio 0.01 \
9
+ --train_type lora \
10
+ --torch_dtype bfloat16 \
11
+ --num_train_epochs 1 \
12
+ --per_device_train_batch_size 1 \
13
+ --per_device_eval_batch_size 2 \
14
+ --learning_rate 1e-4 \
15
+ --lora_rank 8 \
16
+ --lora_alpha 32 \
17
+ --target_modules all-linear \
18
+ --freeze_vit true \
19
+ --gradient_accumulation_steps 16 \
20
+ --eval_steps 100 \
21
+ --save_steps 100 \
22
+ --save_total_limit 2 \
23
+ --logging_steps 5 \
24
+ --max_length 2048 \
25
+ --output_dir output \
26
+ --warmup_ratio 0.05 \
27
+ --dataloader_num_workers 4 \
28
+ --predict_with_generate true \
29
+ --metric_for_best_model rouge-l \
30
+ --greater_is_better true
examples/train/pretrain/train.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # If not using flash_attn, or transformers<4.44,
2
+ # or encountering an abnormally large loss (i.e., the model does not support packing),
3
+ # please remove `--packing true`.
4
+ nproc_per_node=4
5
+
6
+ NPROC_PER_NODE=$nproc_per_node \
7
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
8
+ swift pt \
9
+ --model Qwen/Qwen2.5-7B \
10
+ --train_type full \
11
+ --dataset swift/chinese-c4 \
12
+ --torch_dtype bfloat16 \
13
+ --streaming true \
14
+ --per_device_train_batch_size 1 \
15
+ --per_device_eval_batch_size 1 \
16
+ --learning_rate 1e-5 \
17
+ --gradient_accumulation_steps $(expr 64 / $nproc_per_node) \
18
+ --packing true \
19
+ --eval_steps 500 \
20
+ --save_steps 500 \
21
+ --save_total_limit 2 \
22
+ --logging_steps 5 \
23
+ --deepspeed zero3 \
24
+ --max_length 8192 \
25
+ --max_steps 10000 \
26
+ --warmup_ratio 0.05 \
27
+ --dataloader_num_workers 4 \
28
+ --dataset_num_proc 8 \
29
+ --save_only_model true \
30
+ --output_dir output/Qwen2.5-7B \
31
+ --attn_impl flash_attn
examples/train/qlora/awq/merge_lora.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # This will store the full, unquantized weights.
2
+ swift export \
3
+ --model Qwen/Qwen2.5-7B-Instruct \
4
+ --adapters output/vx-xxx/checkpoint-xxx \
5
+ --merge_lora true
examples/train/qlora/awq/train.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 10GB
2
+ CUDA_VISIBLE_DEVICES=0 \
3
+ swift sft \
4
+ --model Qwen/Qwen2.5-7B-Instruct-AWQ \
5
+ --train_type lora \
6
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
7
+ 'AI-ModelScope/alpaca-gpt4-data-en#500' \
8
+ 'swift/self-cognition#500' \
9
+ --torch_dtype bfloat16 \
10
+ --num_train_epochs 1 \
11
+ --per_device_train_batch_size 1 \
12
+ --per_device_eval_batch_size 1 \
13
+ --learning_rate 1e-4 \
14
+ --lora_rank 8 \
15
+ --lora_alpha 32 \
16
+ --target_modules all-linear \
17
+ --gradient_accumulation_steps 16 \
18
+ --eval_steps 50 \
19
+ --save_steps 50 \
20
+ --save_total_limit 2 \
21
+ --logging_steps 5 \
22
+ --max_length 2048 \
23
+ --output_dir output \
24
+ --system 'You are a helpful assistant.' \
25
+ --warmup_ratio 0.05 \
26
+ --dataloader_num_workers 4 \
27
+ --model_author swift \
28
+ --model_name swift-robot
examples/train/qlora/bnb/merge_lora.sh ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # This will store the full, unquantized weights.
2
+ swift export \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --merge_lora true
examples/train/qlora/bnb/train.sh ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 10GB
2
+ # pip install bitsandbytes
3
+ CUDA_VISIBLE_DEVICES=0 \
4
+ swift sft \
5
+ --model Qwen/Qwen2.5-7B-Instruct \
6
+ --train_type lora \
7
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
8
+ 'AI-ModelScope/alpaca-gpt4-data-en#500' \
9
+ 'swift/self-cognition#500' \
10
+ --torch_dtype bfloat16 \
11
+ --bnb_4bit_compute_dtype bfloat16 \
12
+ --bnb_4bit_quant_type nf4 \
13
+ --bnb_4bit_use_double_quant true \
14
+ --quant_method bnb \
15
+ --quant_bits 4 \
16
+ --num_train_epochs 1 \
17
+ --per_device_train_batch_size 1 \
18
+ --per_device_eval_batch_size 1 \
19
+ --learning_rate 1e-4 \
20
+ --lora_rank 8 \
21
+ --lora_alpha 32 \
22
+ --target_modules all-linear \
23
+ --gradient_accumulation_steps 16 \
24
+ --eval_steps 50 \
25
+ --save_steps 50 \
26
+ --save_total_limit 2 \
27
+ --logging_steps 5 \
28
+ --max_length 2048 \
29
+ --output_dir output \
30
+ --system 'You are a helpful assistant.' \
31
+ --warmup_ratio 0.05 \
32
+ --dataloader_num_workers 4 \
33
+ --model_author swift \
34
+ --model_name swift-robot
examples/train/qlora/gptq.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 2 * 30GiB
2
+ CUDA_VISIBLE_DEVICES=0,1 \
3
+ MAX_PIXELS=1003520 \
4
+ swift sft \
5
+ --model Qwen/Qwen2.5-VL-72B-Instruct-GPTQ-Int4 \
6
+ --dataset 'modelscope/coco_2014_caption:validation#20000' \
7
+ --load_from_cache_file true \
8
+ --split_dataset_ratio 0.01 \
9
+ --train_type lora \
10
+ --torch_dtype bfloat16 \
11
+ --num_train_epochs 1 \
12
+ --per_device_train_batch_size 1 \
13
+ --per_device_eval_batch_size 1 \
14
+ --learning_rate 1e-4 \
15
+ --lora_rank 8 \
16
+ --lora_alpha 32 \
17
+ --target_modules all-linear \
18
+ --freeze_vit true \
19
+ --gradient_accumulation_steps 16 \
20
+ --eval_steps 100 \
21
+ --save_steps 100 \
22
+ --save_total_limit 2 \
23
+ --logging_steps 5 \
24
+ --max_length 2048 \
25
+ --output_dir output \
26
+ --warmup_ratio 0.05 \
27
+ --dataloader_num_workers 4
examples/train/qlora/hqq.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 10GB
2
+ # pip install hqq
3
+ CUDA_VISIBLE_DEVICES=0 \
4
+ swift sft \
5
+ --model Qwen/Qwen2.5-7B-Instruct \
6
+ --train_type lora \
7
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#500' \
8
+ 'AI-ModelScope/alpaca-gpt4-data-en#500' \
9
+ 'swift/self-cognition#500' \
10
+ --torch_dtype bfloat16 \
11
+ --quant_method hqq \
12
+ --quant_bits 4 \
13
+ --num_train_epochs 1 \
14
+ --per_device_train_batch_size 1 \
15
+ --per_device_eval_batch_size 1 \
16
+ --learning_rate 1e-4 \
17
+ --lora_rank 8 \
18
+ --lora_alpha 32 \
19
+ --target_modules all-linear \
20
+ --gradient_accumulation_steps 16 \
21
+ --eval_steps 50 \
22
+ --save_steps 50 \
23
+ --save_total_limit 2 \
24
+ --logging_steps 5 \
25
+ --max_length 2048 \
26
+ --output_dir output \
27
+ --system 'You are a helpful assistant.' \
28
+ --warmup_ratio 0.05 \
29
+ --dataloader_num_workers 4 \
30
+ --model_author swift \
31
+ --model_name swift-robot