jamie33 commited on
Commit
3ab0d5d
·
verified ·
1 Parent(s): dc89594

Upload folder using huggingface_hub (part 8)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/lora_llm_full_vit/merge_lora.sh +12 -0
  2. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/lora_llm_full_vit/sft.sh +31 -0
  3. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/ocr.sh +25 -0
  4. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/omni/infer.sh +10 -0
  5. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/omni/sft.sh +39 -0
  6. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/rlhf/dpo/full.sh +30 -0
  7. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/rlhf/dpo/lora.sh +33 -0
  8. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/rlhf/kto.sh +32 -0
  9. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/video.sh +31 -0
  10. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/vit_gradient_checkpointing.sh +35 -0
  11. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/optimizer/muon.sh +31 -0
  12. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/packing/llm.sh +31 -0
  13. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/packing/qwen2_5_omni.sh +40 -0
  14. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/packing/qwen2_5_vl.sh +35 -0
  15. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/packing/streaming.sh +34 -0
  16. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/padding_free/dpo.sh +29 -0
  17. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/padding_free/dpo_vlm.sh +31 -0
  18. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/padding_free/sft.sh +29 -0
  19. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/plugins/channel_loss.sh +32 -0
  20. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/plugins/loss_scale.sh +22 -0
  21. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/plugins/tuner_phi4_mm.sh +20 -0
  22. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/predict_with_generate/train.sh +28 -0
  23. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/pretrain/train.sh +31 -0
  24. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/qlora/awq.sh +28 -0
  25. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/qlora/bnb.sh +34 -0
  26. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/qlora/gptq.sh +25 -0
  27. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/qlora/hqq.sh +31 -0
  28. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rft/math.json +0 -0
  29. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rft/rft.py +224 -0
  30. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/README.md +3 -0
  31. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/cpo.sh +28 -0
  32. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/dpo/full.sh +26 -0
  33. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/dpo/lora.sh +27 -0
  34. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/kto.sh +27 -0
  35. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/orpo.sh +28 -0
  36. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/ppo/full.sh +33 -0
  37. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/ppo/lora.sh +36 -0
  38. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/rm.sh +28 -0
  39. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/simpo.sh +26 -0
  40. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/bert/deploy.sh +11 -0
  41. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/bert/infer.sh +7 -0
  42. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/bert/sft.sh +28 -0
  43. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/multi_label/sft.sh +28 -0
  44. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_5/deploy.sh +8 -0
  45. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_5/infer.sh +5 -0
  46. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_5/sft.sh +28 -0
  47. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_vl/infer.sh +5 -0
  48. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_vl/sft.sh +28 -0
  49. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/regression/deploy.sh +8 -0
  50. video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/regression/infer.sh +5 -0
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/lora_llm_full_vit/merge_lora.sh ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift export \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --merge_lora true
5
+
6
+ # CUDA_VISIBLE_DEVICES=0 \
7
+ # swift infer \
8
+ # --model output/vx-xxx/checkpoint-xxx-merged \
9
+ # --stream true \
10
+ # --load_data_args true \
11
+ # --temperature 0 \
12
+ # --max_new_tokens 2048
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/lora_llm_full_vit/sft.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 22GiB
2
+ # vit/merger lr 1e-5; llm lora lr 1e-4
3
+ NPROC_PER_NODE=4 \
4
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
5
+ MAX_PIXELS=1003520 \
6
+ swift sft \
7
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
8
+ --dataset 'AI-ModelScope/coco#20000' \
9
+ --train_type custom \
10
+ --external_plugins 'examples/train/multimodal/lora_llm_full_vit/custom_plugin.py' \
11
+ --torch_dtype bfloat16 \
12
+ --num_train_epochs 1 \
13
+ --per_device_train_batch_size 1 \
14
+ --per_device_eval_batch_size 1 \
15
+ --learning_rate 1e-4 \
16
+ --vit_lr 1e-5 \
17
+ --aligner_lr 1e-5 \
18
+ --lora_rank 16 \
19
+ --lora_alpha 32 \
20
+ --gradient_accumulation_steps 4 \
21
+ --eval_steps 100 \
22
+ --save_steps 100 \
23
+ --save_total_limit 2 \
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 4 \
30
+ --deepspeed zero2 \
31
+ --save_only_model true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/ocr.sh ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type lora \
8
+ --torch_dtype bfloat16 \
9
+ --num_train_epochs 1 \
10
+ --per_device_train_batch_size 1 \
11
+ --per_device_eval_batch_size 1 \
12
+ --learning_rate 1e-4 \
13
+ --lora_rank 8 \
14
+ --lora_alpha 32 \
15
+ --target_modules all-linear \
16
+ --freeze_vit true \
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
+ --warmup_ratio 0.05 \
25
+ --dataloader_num_workers 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
+ pip install transformers -U
4
+
5
+ nproc_per_node=4
6
+
7
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
8
+ ENABLE_AUDIO_OUTPUT=1 \
9
+ NPROC_PER_NODE=$nproc_per_node \
10
+ VIDEO_MAX_PIXELS=50176 \
11
+ FPS_MAX_FRAMES=12 \
12
+ MAX_PIXELS=1003520 \
13
+ ENABLE_AUDIO_OUTPUT=0 \
14
+ swift sft \
15
+ --model Qwen/Qwen2.5-Omni-7B \
16
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#2000' \
17
+ 'AI-ModelScope/LaTeX_OCR:human_handwrite#2000' \
18
+ 'speech_asr/speech_asr_aishell1_trainsets:validation#2000' \
19
+ 'swift/VideoChatGPT:all#2000' \
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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/rlhf/dpo/full.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --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 $(expr 16 / $nproc_per_node) \
20
+ --eval_steps 100 \
21
+ --save_steps 100 \
22
+ --save_total_limit 2 \
23
+ --deepspeed zero3 \
24
+ --logging_steps 5 \
25
+ --max_length 4096 \
26
+ --output_dir output \
27
+ --warmup_ratio 0.05 \
28
+ --dataloader_num_workers 4 \
29
+ --dataset_num_proc 4 \
30
+ --save_only_model true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/rlhf/dpo/lora.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type lora \
14
+ --torch_dtype bfloat16 \
15
+ --num_train_epochs 1 \
16
+ --per_device_train_batch_size 1 \
17
+ --per_device_eval_batch_size 1 \
18
+ --learning_rate 1e-4 \
19
+ --lora_rank 8 \
20
+ --lora_alpha 32 \
21
+ --target_modules all-linear \
22
+ --freeze_vit true \
23
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
24
+ --eval_steps 100 \
25
+ --save_steps 100 \
26
+ --save_total_limit 2 \
27
+ --deepspeed zero2 \
28
+ --logging_steps 5 \
29
+ --max_length 4096 \
30
+ --output_dir output \
31
+ --warmup_ratio 0.05 \
32
+ --dataloader_num_workers 4 \
33
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/rlhf/kto.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type lora \
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-4 \
18
+ --lora_rank 8 \
19
+ --lora_alpha 32 \
20
+ --target_modules all-linear \
21
+ --freeze_vit true \
22
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
23
+ --eval_steps 100 \
24
+ --save_steps 100 \
25
+ --save_total_limit 2 \
26
+ --deepspeed zero2 \
27
+ --logging_steps 5 \
28
+ --max_length 4096 \
29
+ --output_dir output \
30
+ --warmup_ratio 0.05 \
31
+ --dataloader_num_workers 4 \
32
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/video.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4*80GB
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=4
4
+
5
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
6
+ NPROC_PER_NODE=$nproc_per_node \
7
+ VIDEO_MAX_PIXELS=50176 \
8
+ FPS_MAX_FRAMES=12 \
9
+ swift sft \
10
+ --model Qwen/QVQ-72B-Preview \
11
+ --dataset swift/VideoChatGPT:all \
12
+ --train_type lora \
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-4 \
18
+ --lora_rank 8 \
19
+ --lora_alpha 32 \
20
+ --target_modules all-linear \
21
+ --freeze_vit true \
22
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
23
+ --eval_steps 50 \
24
+ --save_steps 50 \
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 zero3
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/multimodal/vit_gradient_checkpointing.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type full \
13
+ --torch_dtype bfloat16 \
14
+ --num_train_epochs 1 \
15
+ --per_device_train_batch_size 4 \
16
+ --per_device_eval_batch_size 4 \
17
+ --learning_rate 1e-5 \
18
+ --freeze_vit false \
19
+ --freeze_aligner false \
20
+ --gradient_accumulation_steps 1 \
21
+ --gradient_checkpointing true \
22
+ --vit_gradient_checkpointing true \
23
+ --eval_steps 100 \
24
+ --save_steps 100 \
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 zero3 \
32
+ --use_liger_kernel true \
33
+ --attn_impl flash_attn \
34
+ --padding_free true \
35
+ --save_only_model true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/packing/llm.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --torch_dtype bfloat16 \
11
+ --num_train_epochs 3 \
12
+ --attn_impl flash_attn \
13
+ --per_device_train_batch_size 1 \
14
+ --per_device_eval_batch_size 1 \
15
+ --learning_rate 1e-4 \
16
+ --lora_rank 8 \
17
+ --lora_alpha 32 \
18
+ --target_modules all-linear \
19
+ --gradient_accumulation_steps 4 \
20
+ --eval_steps 50 \
21
+ --save_steps 50 \
22
+ --save_total_limit 2 \
23
+ --logging_steps 5 \
24
+ --max_length 2048 \
25
+ --output_dir output \
26
+ --system 'You are a helpful assistant.' \
27
+ --warmup_ratio 0.05 \
28
+ --dataloader_num_workers 4 \
29
+ --dataset_num_proc 4 \
30
+ --model_author swift \
31
+ --model_name swift-robot
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
+ pip install transformers -U
6
+
7
+ NPROC_PER_NODE=4 \
8
+ ENABLE_AUDIO_OUTPUT=1 \
9
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
10
+ VIDEO_MAX_PIXELS=50176 \
11
+ FPS_MAX_FRAMES=12 \
12
+ MAX_PIXELS=1003520 \
13
+ swift sft \
14
+ --model Qwen/Qwen2.5-Omni-7B \
15
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#10000' \
16
+ 'AI-ModelScope/LaTeX_OCR#2000' \
17
+ 'speech_asr/speech_asr_aishell1_trainsets:validation#2000' \
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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/packing/qwen2_5_vl.sh ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
8
+ NPROC_PER_NODE=4 \
9
+ MAX_PIXELS=1003520 \
10
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
11
+ swift sft \
12
+ --model Qwen/Qwen2.5-VL-7B-Instruct \
13
+ --train_type lora \
14
+ --dataset 'AI-ModelScope/LaTeX_OCR#20000' \
15
+ --torch_dtype bfloat16 \
16
+ --attn_impl flash_attn \
17
+ --packing true \
18
+ --num_train_epochs 3 \
19
+ --per_device_train_batch_size 1 \
20
+ --per_device_eval_batch_size 1 \
21
+ --learning_rate 1e-4 \
22
+ --lora_rank 8 \
23
+ --lora_alpha 32 \
24
+ --target_modules all-linear \
25
+ --gradient_accumulation_steps 1 \
26
+ --eval_steps 100 \
27
+ --save_steps 100 \
28
+ --save_total_limit 2 \
29
+ --logging_steps 5 \
30
+ --max_length 8192 \
31
+ --output_dir output \
32
+ --warmup_ratio 0.05 \
33
+ --dataloader_num_workers 4 \
34
+ --dataset_num_proc 8 \
35
+ --deepspeed zero2
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/padding_free/dpo.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # with padding_free: 4 * 47GiB, 1.90s/it
2
+ # without padding_free: 4 * 57GiB 3.32s/it
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 hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
10
+ --torch_dtype bfloat16 \
11
+ --num_train_epochs 1 \
12
+ --per_device_train_batch_size 4 \
13
+ --per_device_eval_batch_size 4 \
14
+ --learning_rate 1e-5 \
15
+ --gradient_accumulation_steps 1 \
16
+ --eval_steps 100 \
17
+ --save_steps 100 \
18
+ --save_total_limit 2 \
19
+ --logging_steps 5 \
20
+ --max_length 8192 \
21
+ --output_dir output \
22
+ --warmup_ratio 0.05 \
23
+ --save_only_model true \
24
+ --dataloader_num_workers 4 \
25
+ --dataset_num_proc 4 \
26
+ --deepspeed zero3 \
27
+ --attn_impl flash_attn \
28
+ --save_only_model true \
29
+ --padding_free true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/padding_free/dpo_vlm.sh ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type full \
12
+ --torch_dtype bfloat16 \
13
+ --num_train_epochs 1 \
14
+ --per_device_train_batch_size 4 \
15
+ --per_device_eval_batch_size 4 \
16
+ --learning_rate 1e-5 \
17
+ --freeze_vit true \
18
+ --gradient_accumulation_steps 1 \
19
+ --eval_steps 100 \
20
+ --save_steps 100 \
21
+ --save_total_limit 2 \
22
+ --deepspeed zero3 \
23
+ --logging_steps 5 \
24
+ --max_length 4096 \
25
+ --output_dir output \
26
+ --warmup_ratio 0.05 \
27
+ --dataloader_num_workers 4 \
28
+ --dataset_num_proc 4 \
29
+ --attn_impl flash_attn \
30
+ --save_only_model true \
31
+ --padding_free true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/padding_free/sft.sh ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --torch_dtype bfloat16 \
12
+ --per_device_train_batch_size 8 \
13
+ --per_device_eval_batch_size 8 \
14
+ --learning_rate 1e-5 \
15
+ --gradient_accumulation_steps 1 \
16
+ --eval_steps 200 \
17
+ --save_steps 200 \
18
+ --logging_steps 5 \
19
+ --max_length 8192 \
20
+ --warmup_ratio 0.05 \
21
+ --dataloader_num_workers 8 \
22
+ --dataset_num_proc 8 \
23
+ --save_total_limit 2 \
24
+ --save_only_model true \
25
+ --output_dir output/Qwen2.5-7B \
26
+ --deepspeed zero3 \
27
+ --use_liger_kernel true \
28
+ --attn_impl flash_attn \
29
+ --padding_free true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/plugins/channel_loss.sh ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # use loss_type channel_loss
2
+ # channels specifies the channels included in the dataset
3
+ # data should have 'channel' field
4
+ # eg.
5
+ # {"channel": "chat",
6
+ # "messages": [
7
+ # {"role": "system", "content": "You are a helpful assistant"},
8
+ # {"role": "user", "content": "What color do you like?"},
9
+ # {"role": "assistant", "content": "I like blue."}
10
+ # ]}
11
+ CUDA_VISIBLE_DEVICES=0 \
12
+ swift sft \
13
+ --model Qwen/Qwen2.5-0.5B-Instruct \
14
+ --dataset '/path/to/channel_dataset' \
15
+ --train_type full \
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-5 \
21
+ --gradient_accumulation_steps 8 \
22
+ --eval_steps 100 \
23
+ --save_steps 100 \
24
+ --save_total_limit 2 \
25
+ --logging_steps 1 \
26
+ --max_length 512 \
27
+ --output_dir output \
28
+ --system 'You are a helpful assistant.' \
29
+ --warmup_ratio 0.05 \
30
+ --dataloader_num_workers 4 \
31
+ --loss_type channel_loss \
32
+ --channels 'chat' 'math' 'code'
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/plugins/tuner_phi4_mm.sh ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type dummy \
7
+ --torch_dtype bfloat16 \
8
+ --num_train_epochs 1 \
9
+ --per_device_train_batch_size 1 \
10
+ --per_device_eval_batch_size 1 \
11
+ --learning_rate 1e-4 \
12
+ --gradient_accumulation_steps 16 \
13
+ --eval_steps 200 \
14
+ --save_steps 200 \
15
+ --save_total_limit 2 \
16
+ --logging_steps 5 \
17
+ --max_length 2048 \
18
+ --output_dir output \
19
+ --warmup_ratio 0.05 \
20
+ --dataloader_num_workers 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/predict_with_generate/train.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type lora \
8
+ --torch_dtype bfloat16 \
9
+ --num_train_epochs 1 \
10
+ --per_device_train_batch_size 1 \
11
+ --per_device_eval_batch_size 2 \
12
+ --learning_rate 1e-4 \
13
+ --lora_rank 8 \
14
+ --lora_alpha 32 \
15
+ --target_modules all-linear \
16
+ --freeze_vit true \
17
+ --gradient_accumulation_steps 16 \
18
+ --eval_steps 100 \
19
+ --save_steps 100 \
20
+ --save_total_limit 2 \
21
+ --logging_steps 5 \
22
+ --max_length 2048 \
23
+ --output_dir output \
24
+ --warmup_ratio 0.05 \
25
+ --dataloader_num_workers 4 \
26
+ --predict_with_generate true \
27
+ --metric_for_best_model rouge-l \
28
+ --greater_is_better true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/qlora/awq.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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/qlora/bnb.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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/qlora/gptq.sh ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ --train_type lora \
8
+ --torch_dtype bfloat16 \
9
+ --num_train_epochs 1 \
10
+ --per_device_train_batch_size 1 \
11
+ --per_device_eval_batch_size 1 \
12
+ --learning_rate 1e-4 \
13
+ --lora_rank 8 \
14
+ --lora_alpha 32 \
15
+ --target_modules all-linear \
16
+ --freeze_vit true \
17
+ --gradient_accumulation_steps 16 \
18
+ --eval_steps 100 \
19
+ --save_steps 100 \
20
+ --save_total_limit 2 \
21
+ --logging_steps 5 \
22
+ --max_length 2048 \
23
+ --output_dir output \
24
+ --warmup_ratio 0.05 \
25
+ --dataloader_num_workers 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/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
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rft/math.json ADDED
The diff for this file is too large to render. See raw diff
 
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rft/rft.py ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import subprocess
4
+ import time
5
+ from typing import List
6
+
7
+ from swift.utils import get_device_count
8
+
9
+ # NOTE: this script supports at most 8 GPUS in a node, if using multi node, please use custom logic.
10
+
11
+ # Paste conda env
12
+ # conda_prefix = 'source /root/miniconda3/etc/profile.d/conda.sh && conda activate py311 && '
13
+ conda_prefix = ''
14
+
15
+
16
+ def do_sample(model: str, model_type: str, dataset: List[str], iter: int):
17
+ device_count = get_device_count()
18
+ handlers = []
19
+ datasets = []
20
+ # Sampling cache, to avoid lmdeploy & PRM run at the same time
21
+ # Why lmdeploy not vllm? we found that the responses generated by lmdeploy are more similar than ones of vllm.
22
+ for device in range(device_count):
23
+ sample_cmd = (f'{conda_prefix} USE_OPENCOMPASS_EVALUATOR=True CUDA_VISIBLE_DEVICES={device} swift sample '
24
+ f'--model {model} --model_type {model_type} '
25
+ f'--dataset {" ".join(dataset)} '
26
+ f'--data_range {device} {device_count} '
27
+ f'--max_length 2048 '
28
+ f'--system "You are a math model, you should **think step by step** carefully, '
29
+ f'and always consider the basic math principles to avoid making calculating mistakes.'
30
+ f'Give the final answer wrapped with \\boxed{{}}" '
31
+ f'--load_args false '
32
+ f'--sampler_engine vllm '
33
+ f'--max_new_tokens 768 '
34
+ f'--override_exist_file true '
35
+ f'--num_sampling_per_gpu_batch_size 1 '
36
+ f'--num_return_sequences 64 '
37
+ f'--cache_files sample_output/iter_{iter}_proc_{device}_cache.jsonl '
38
+ f'--output_file iter_{iter}_proc_{device}_cache.jsonl '
39
+ f'--top_p 1.0 '
40
+ f'--temperature 1.0 ')
41
+ print(f'Sampling caches of iter {iter}, part {device}.', flush=True)
42
+ env = os.environ.copy()
43
+ env['CUDA_VISIBLE_DEVICES'] = str(device)
44
+ handler = subprocess.Popen(
45
+ f'{sample_cmd}' + f' > logs/sample_iter_{iter}_proc_{device}_cache.log 2>&1',
46
+ env=os.environ.copy(),
47
+ shell=True,
48
+ executable='/bin/bash')
49
+ handlers.append(handler)
50
+
51
+ for proc, handler in enumerate(handlers):
52
+ handler.wait()
53
+ assert os.path.exists(os.path.join('sample_output', f'iter_{iter}_proc_{proc}_cache.jsonl'))
54
+
55
+ handlers = []
56
+ # Sample again, this time to filter with ORM & PRM
57
+ # Provide your PRM model or PRM name(add PRM in plugin/prm.py first)
58
+ # You can define your custom PRM logic in the plugin
59
+ # (like, split your steps, use the worst score/last score/avg score)
60
+ for device in range(device_count):
61
+ sample_cmd = (
62
+ f'{conda_prefix} USE_OPENCOMPASS_EVALUATOR=True CUDA_VISIBLE_DEVICES={device} swift sample '
63
+ f'--model {model} --model_type {model_type} ' # change to --resume_from_checkpoint to use the latest optimizer state # noqa
64
+ f'--dataset {" ".join(dataset)} '
65
+ f'--data_range {device} {device_count} '
66
+ f'--max_length 2048 '
67
+ f'--system "You are a math model, you should **think step by step** carefully, '
68
+ f'and always consider the basic math principles to avoid making calculating mistakes.'
69
+ f'Give the final answer wrapped with \\boxed{{}}" '
70
+ f'--load_args false '
71
+ f'--sampler_engine no '
72
+ f'--orm_model math ' # math defines in plugin/orm.py
73
+ f'--prm_model Qwen/Qwen2.5-Math-PRM-7B '
74
+ f'--prm_threshold {min(0.7 + 0.1*iter, 0.9)} '
75
+ f'--max_new_tokens 768 '
76
+ f'--override_exist_file true ' # no not override the existing sample files
77
+ f'--num_sampling_per_gpu_batch_size 1 '
78
+ f'--num_return_sequences 64 '
79
+ f'--output_file iter_{iter}_proc_{device}_sampling.jsonl '
80
+ f'--cache_files sample_output/iter_{iter}_proc_{device}_cache.jsonl ')
81
+ print(f'Sampling iter {iter}, part {device}.', flush=True)
82
+ env = os.environ.copy()
83
+ env['CUDA_VISIBLE_DEVICES'] = str(device)
84
+ handler = subprocess.Popen(
85
+ f'{sample_cmd}' + f' > logs/sample_iter_{iter}_proc_{device}.log 2>&1',
86
+ env=os.environ.copy(),
87
+ shell=True,
88
+ executable='/bin/bash')
89
+ handlers.append(handler)
90
+
91
+ for proc, handler in enumerate(handlers):
92
+ handler.wait()
93
+ assert os.path.exists(os.path.join('sample_output', f'iter_{iter}_proc_{proc}_sampling.jsonl')), (
94
+ f'{os.path.join("sample_output", f"iter_{iter}_proc_{proc}_sampling.jsonl")} not exists, '
95
+ 'please check the sample logs to get the detail error.')
96
+ datasets.append(os.path.join('sample_output', f'iter_{iter}_proc_{proc}_sampling.jsonl'))
97
+ print(f'Sampling done, files:{datasets}', flush=True)
98
+ return datasets
99
+
100
+
101
+ def do_train(model: str, model_type: str, datasets: List[str], iter, cmd='sft'):
102
+ gpu_prefix = ''
103
+ ds_config = ''
104
+ if get_device_count() > 1:
105
+ gpu_prefix = f'NPROC_PER_NODE={get_device_count()} '
106
+ ds_config = '--deepspeed zero3 '
107
+ extra_args = ''
108
+ if cmd == 'rlhf':
109
+ extra_args = '--rlhf_type dpo --beta 0.3 ' # use another reinforce learning method supported by swift
110
+ ga = 128 // get_device_count() // 2
111
+ train_cmd = (f'{conda_prefix} {gpu_prefix} swift {cmd} '
112
+ f'--model {model} --model_type {model_type} '
113
+ f'--dataset {" ".join(datasets)} '
114
+ f'--max_length 2048 '
115
+ f'--num_train_epochs 1 '
116
+ f'--load_args false '
117
+ f'--train_type full '
118
+ f'{extra_args} '
119
+ f'--eval_strategy no '
120
+ f'--split_dataset_ratio 0 '
121
+ f'--per_device_train_batch_size 2 '
122
+ f'--gradient_accumulation_steps {ga} '
123
+ f'--save_steps 1 '
124
+ f'--save_strategy epoch '
125
+ f'{ds_config} '
126
+ f'--learning_rate 4e-6 ')
127
+
128
+ print(f'Training iter {iter}.', flush=True)
129
+ handler = subprocess.Popen(
130
+ f'{train_cmd}' + f' > logs/train_iter_{iter}.log 2>&1',
131
+ shell=True,
132
+ env=os.environ.copy(),
133
+ executable='/bin/bash')
134
+ handler.wait()
135
+ ckpt = None
136
+ with open(f'logs/train_iter_{iter}.log', 'r') as f:
137
+ for line in f.readlines():
138
+ if 'last_model_checkpoint: ' in line:
139
+ ckpt = line.split('last_model_checkpoint: ')[1]
140
+ break
141
+ assert ckpt is not None
142
+ print(f'Training done, ckpt: {ckpt.strip()}.', flush=True)
143
+ return ckpt.strip()
144
+
145
+
146
+ def do_eval(model, model_type: str, iter):
147
+ eval_cmd = (
148
+ f'{conda_prefix} swift eval '
149
+ '--eval_dataset competition_math ' # eval another dataset
150
+ '--infer_backend vllm --eval_limit 500 '
151
+ f'--model {model} --model_type {model_type} '
152
+ '--system "You are a math model, you should **think step by step** carefully, '
153
+ 'and always consider the basic math principles to avoid making calculating mistakes. '
154
+ 'Give the final answer wrapped with \\boxed{}"')
155
+ print('Evaluating.', flush=True)
156
+ # Replace the original dataset to the math.json, this is for test, comment this if not need
157
+ replace_math_dataset()
158
+
159
+ if iter is None:
160
+ iter = 'origin'
161
+ env = os.environ.copy()
162
+ env['CUDA_VISIBLE_DEVICES'] = '0'
163
+ handler = subprocess.Popen(
164
+ f'{eval_cmd}' + f' > logs/eval_iter_{iter}.log 2>&1', shell=True, env=env, executable='/bin/bash')
165
+ handler.wait()
166
+
167
+ acc = None
168
+ # | math | 393424 | accuracy | gen | 39.00 |
169
+ with open(f'logs/eval_iter_{iter}.log', 'r') as f:
170
+ for line in f.readlines():
171
+ if 'Level 5' in line and 'AveragePass@1' in line:
172
+ parts = [p for p in line.split('|') if p.strip()]
173
+ acc = float(parts[-2])
174
+ break
175
+
176
+ print(f'Iter {iter} eval done with acc: {acc}.', flush=True)
177
+ return acc
178
+
179
+
180
+ def replace_math_dataset():
181
+ # Note: This may run failed because this is special for math test,
182
+ # and one must run swift eval --eval_dataset math first to make sure opencompass has created
183
+ # the folder.
184
+ # You can use original math dataset either. just comment this call.
185
+ user_dir = os.path.expanduser('~')
186
+ if os.path.exists(os.path.join(user_dir, '.cache', 'opencompass', 'data', 'math', 'math.json')):
187
+ os.remove(os.path.join(user_dir, '.cache', 'opencompass', 'data', 'math', 'math.json'))
188
+ shutil.copy(
189
+ os.path.join('examples', 'train', 'rft', 'math.json'),
190
+ os.path.join(user_dir, '.cache', 'opencompass', 'data', 'math', 'math.json'))
191
+
192
+
193
+ def main():
194
+ os.makedirs('logs', exist_ok=True)
195
+ max_acc = 0.
196
+ first_model = 'Qwen/Qwen2.5-Math-7B-Instruct'
197
+ model_type = 'qwen2_5_math'
198
+
199
+ if False:
200
+ # eval the original model
201
+ do_eval(first_model, None)
202
+
203
+ model = first_model
204
+ for i in range(5):
205
+ ts = time.time()
206
+ datasets = do_sample(model, model_type, ['tastelikefeet/competition_math'], i)
207
+ # add custom data filter here, for example: length or diversity control
208
+ print(f'do sample cost: {(time.time()-ts) / 60:.1f} minutes.', flush=True)
209
+ ts = time.time()
210
+ # if want to train the original dataset with datasets, add the original dataset here
211
+ # if want to train the original model everytime, change to first_model
212
+ ckpt = do_train(model, model_type, datasets, i)
213
+ print(f'do train cost: {(time.time() - ts) / 60:.1f} minutes.', flush=True)
214
+ ts = time.time()
215
+ acc = do_eval(ckpt, model_type, i)
216
+ print(f'do eval cost: {(time.time() - ts) / 60:.1f} minutes.', flush=True)
217
+ if acc > max_acc:
218
+ max_acc = acc
219
+ model = ckpt
220
+ print(f'acc: {acc}, upgrade model to : {model}', flush=True)
221
+
222
+
223
+ if __name__ == '__main__':
224
+ main()
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # TIPS
2
+
3
+ Multi-modal models' RLHF are also supported! Check the multimodal folder for details.
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/cpo.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nproc_per_node=2
2
+
3
+ CUDA_VISIBLE_DEVICES=0,1 \
4
+ NPROC_PER_NODE=$nproc_per_node \
5
+ swift rlhf \
6
+ --rlhf_type cpo \
7
+ --model Qwen/Qwen2.5-7B-Instruct \
8
+ --train_type lora \
9
+ --dataset hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
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
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
19
+ --eval_steps 100 \
20
+ --save_steps 100 \
21
+ --save_total_limit 2 \
22
+ --logging_steps 5 \
23
+ --max_length 2048 \
24
+ --output_dir output \
25
+ --warmup_ratio 0.05 \
26
+ --dataloader_num_workers 4 \
27
+ --deepspeed zero2 \
28
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/dpo/full.sh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 50GiB
2
+ NPROC_PER_NODE=4 \
3
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
4
+ swift rlhf \
5
+ --rlhf_type dpo \
6
+ --model Qwen/Qwen2.5-7B-Instruct \
7
+ --train_type full \
8
+ --dataset hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
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-5 \
14
+ --gradient_accumulation_steps 4 \
15
+ --eval_steps 100 \
16
+ --save_steps 100 \
17
+ --save_total_limit 2 \
18
+ --logging_steps 5 \
19
+ --max_length 8192 \
20
+ --output_dir output \
21
+ --warmup_ratio 0.05 \
22
+ --save_only_model true \
23
+ --dataloader_num_workers 4 \
24
+ --dataset_num_proc 4 \
25
+ --deepspeed zero3 \
26
+ --attn_impl flash_attn
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/dpo/lora.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 24GiB
2
+ # It is recommended to use padding_free. For more details, please refer to:
3
+ # https://github.com/modelscope/ms-swift/blob/main/examples/train/padding_free/dpo.sh
4
+ CUDA_VISIBLE_DEVICES=0 \
5
+ swift rlhf \
6
+ --rlhf_type dpo \
7
+ --model Qwen/Qwen2.5-7B-Instruct \
8
+ --train_type lora \
9
+ --dataset hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
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
+ --gradient_accumulation_steps 16 \
19
+ --eval_steps 100 \
20
+ --save_steps 100 \
21
+ --save_total_limit 2 \
22
+ --logging_steps 5 \
23
+ --max_length 2048 \
24
+ --output_dir output \
25
+ --warmup_ratio 0.05 \
26
+ --dataloader_num_workers 4 \
27
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/kto.sh ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nproc_per_node=2
2
+
3
+ CUDA_VISIBLE_DEVICES=0,1 \
4
+ NPROC_PER_NODE=$nproc_per_node \
5
+ swift rlhf \
6
+ --rlhf_type kto \
7
+ --model Qwen/Qwen2.5-7B-Instruct \
8
+ --train_type lora \
9
+ --dataset 'AI-ModelScope/ultrafeedback-binarized-preferences-cleaned-kto#10000' \
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 $(expr 16 / $nproc_per_node) \
18
+ --eval_steps 100 \
19
+ --save_steps 100 \
20
+ --save_total_limit 2 \
21
+ --logging_steps 5 \
22
+ --max_length 2048 \
23
+ --output_dir output \
24
+ --warmup_ratio 0.05 \
25
+ --dataloader_num_workers 4 \
26
+ --deepspeed zero2 \
27
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/orpo.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nproc_per_node=2
2
+
3
+ CUDA_VISIBLE_DEVICES=0,1 \
4
+ NPROC_PER_NODE=$nproc_per_node \
5
+ swift rlhf \
6
+ --rlhf_type orpo \
7
+ --model Qwen/Qwen2.5-7B-Instruct \
8
+ --train_type lora \
9
+ --dataset hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
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
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
19
+ --eval_steps 100 \
20
+ --save_steps 100 \
21
+ --save_total_limit 2 \
22
+ --logging_steps 5 \
23
+ --max_length 2048 \
24
+ --output_dir output \
25
+ --warmup_ratio 0.05 \
26
+ --dataloader_num_workers 4 \
27
+ --deepspeed zero2 \
28
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/ppo/full.sh ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 8 * 65 GiB
2
+ # Currently, it only supports the case where the model and reward_model use the same template/tokenizer.
3
+ # Currently, multimodal model PPO is not supported.
4
+ nproc_per_node=8
5
+
6
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
7
+ CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
8
+ NPROC_PER_NODE=$nproc_per_node \
9
+ swift rlhf \
10
+ --rlhf_type ppo \
11
+ --model LLM-Research/Meta-Llama-3.1-8B-Instruct \
12
+ --reward_model 'AI-ModelScope/Skywork-Reward-Llama-3.1-8B-v0.2' \
13
+ --train_type full \
14
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#20000' 'AI-ModelScope/alpaca-gpt4-data-en#20000' \
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-6 \
20
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
21
+ --eval_steps 100 \
22
+ --save_steps 100 \
23
+ --save_total_limit 2 \
24
+ --logging_steps 5 \
25
+ --max_length 2048 \
26
+ --output_dir output \
27
+ --warmup_ratio 0.05 \
28
+ --dataloader_num_workers 4 \
29
+ --deepspeed zero3 \
30
+ --response_length 512 \
31
+ --temperature 0.7 \
32
+ --dataset_num_proc 4 \
33
+ --save_only_model true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/ppo/lora.sh ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 4 * 50GiB
2
+ # Currently, it only supports the case where the model and reward_model use the same template/tokenizer.
3
+ # Currently, multimodal model PPO is not supported.
4
+ nproc_per_node=4
5
+
6
+ PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
7
+ CUDA_VISIBLE_DEVICES=0,1,2,3 \
8
+ NPROC_PER_NODE=$nproc_per_node \
9
+ swift rlhf \
10
+ --rlhf_type ppo \
11
+ --model LLM-Research/Meta-Llama-3.1-8B-Instruct \
12
+ --reward_model 'AI-ModelScope/Skywork-Reward-Llama-3.1-8B-v0.2' \
13
+ --train_type lora \
14
+ --dataset 'AI-ModelScope/alpaca-gpt4-data-zh#20000' 'AI-ModelScope/alpaca-gpt4-data-en#20000' \
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
+ --lora_rank 8 \
21
+ --lora_alpha 32 \
22
+ --target_modules all-linear \
23
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
24
+ --eval_steps 100 \
25
+ --save_steps 100 \
26
+ --save_total_limit 2 \
27
+ --logging_steps 5 \
28
+ --max_length 2048 \
29
+ --output_dir output \
30
+ --warmup_ratio 0.05 \
31
+ --dataloader_num_workers 4 \
32
+ --deepspeed zero2 \
33
+ --response_length 512 \
34
+ --temperature 0.7 \
35
+ --dataset_num_proc 4 \
36
+ --save_only_model true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/rm.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ nproc_per_node=2
2
+
3
+ CUDA_VISIBLE_DEVICES=0,1 \
4
+ NPROC_PER_NODE=$nproc_per_node \
5
+ swift rlhf \
6
+ --rlhf_type rm \
7
+ --model Qwen/Qwen2.5-7B-Instruct \
8
+ --train_type lora \
9
+ --dataset hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
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
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
19
+ --eval_steps 100 \
20
+ --save_steps 100 \
21
+ --save_total_limit 2 \
22
+ --logging_steps 5 \
23
+ --max_length 2048 \
24
+ --output_dir output \
25
+ --warmup_ratio 0.05 \
26
+ --dataloader_num_workers 4 \
27
+ --deepspeed zero2 \
28
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/rlhf/simpo.sh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 2*50GB
2
+ nproc_per_node=2
3
+
4
+ CUDA_VISIBLE_DEVICES=0,1 \
5
+ NPROC_PER_NODE=$nproc_per_node \
6
+ swift rlhf \
7
+ --rlhf_type simpo \
8
+ --model Qwen/Qwen2.5-3B-Instruct \
9
+ --train_type full \
10
+ --dataset hjh0119/shareAI-Llama3-DPO-zh-en-emoji \
11
+ --torch_dtype bfloat16 \
12
+ --num_train_epochs 1 \
13
+ --per_device_train_batch_size 1 \
14
+ --per_device_eval_batch_size 1 \
15
+ --learning_rate 1e-5 \
16
+ --gradient_accumulation_steps $(expr 16 / $nproc_per_node) \
17
+ --eval_steps 100 \
18
+ --save_steps 100 \
19
+ --save_total_limit 2 \
20
+ --logging_steps 5 \
21
+ --max_length 2048 \
22
+ --output_dir output \
23
+ --warmup_ratio 0.05 \
24
+ --dataloader_num_workers 4 \
25
+ --deepspeed zero2 \
26
+ --dataset_num_proc 4
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/bert/deploy.sh ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift deploy \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --served_model_name bert-base-chinese \
5
+ --truncation_strategy right \
6
+ --max_length 512
7
+
8
+ # curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
9
+ # "model": "bert-base-chinese",
10
+ # "messages": [{"role": "user", "content": "包装差,容易被调包。"}]
11
+ # }'
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/bert/infer.sh ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift infer \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --load_data_args true \
5
+ --max_batch_size 16 \
6
+ --truncation_strategy right \
7
+ --max_length 512
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/bert/sft.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # If `num_labels` is provided, it will be considered a classification task,
2
+ # and AutoModelForSequenceClassification will be used to load the model.
3
+ # The BERT model does not require templates, so it can usually be used without registration.
4
+ CUDA_VISIBLE_DEVICES=0 \
5
+ swift sft \
6
+ --model AI-ModelScope/bert-base-chinese \
7
+ --train_type lora \
8
+ --dataset 'DAMO_NLP/jd:cls#2000' \
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 512 \
23
+ --truncation_strategy right \
24
+ --output_dir output \
25
+ --warmup_ratio 0.05 \
26
+ --dataloader_num_workers 4 \
27
+ --num_labels 2 \
28
+ --task_type seq_cls
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/multi_label/sft.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Custom dataset format reference: https://swift.readthedocs.io/en/latest/Customization/Custom-dataset.html
2
+ CUDA_VISIBLE_DEVICES=0 \
3
+ swift sft \
4
+ --model Qwen/Qwen2.5-0.5B \
5
+ --train_type lora \
6
+ --dataset '<your-dataset>' \
7
+ --torch_dtype bfloat16 \
8
+ --num_train_epochs 1 \
9
+ --per_device_train_batch_size 16 \
10
+ --per_device_eval_batch_size 16 \
11
+ --learning_rate 1e-4 \
12
+ --lora_rank 8 \
13
+ --lora_alpha 32 \
14
+ --target_modules all-linear \
15
+ --gradient_accumulation_steps 1 \
16
+ --eval_steps 100 \
17
+ --save_steps 100 \
18
+ --save_total_limit 2 \
19
+ --logging_steps 5 \
20
+ --max_length 2048 \
21
+ --output_dir output \
22
+ --warmup_ratio 0.05 \
23
+ --dataloader_num_workers 4 \
24
+ --dataset_num_proc 4 \
25
+ --num_labels '<num-labels>' \
26
+ --task_type seq_cls \
27
+ --use_chat_template false \
28
+ --problem_type multi_label_classification
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_5/deploy.sh ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift deploy \
3
+ --adapters output/vx-xxx/checkpoint-xxx
4
+
5
+ # curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
6
+ # "model": "Qwen2.5-0.5B",
7
+ # "messages": [{"role": "user", "content": "包装差,容易被调包。"}]
8
+ # }'
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_5/infer.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift infer \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --load_data_args true \
5
+ --max_batch_size 16
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_5/sft.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # If `num_labels` is provided, it will be considered a classification task,
2
+ # and AutoModelForSequenceClassification will be used to load the model.
3
+ # You can also specify `--model Qwen/Qwen2.5-0.5B-Instruct --use_chat_template true`.
4
+ CUDA_VISIBLE_DEVICES=0 \
5
+ swift sft \
6
+ --model Qwen/Qwen2.5-0.5B \
7
+ --train_type lora \
8
+ --dataset 'DAMO_NLP/jd:cls#2000' \
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
+ --warmup_ratio 0.05 \
25
+ --dataloader_num_workers 4 \
26
+ --num_labels 2 \
27
+ --task_type seq_cls \
28
+ --use_chat_template false
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_vl/infer.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ MAX_PIXELS=1003520 \
3
+ swift infer \
4
+ --adapters output/vx-xxx/checkpoint-xxx \
5
+ --load_data_args true
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/qwen2_vl/sft.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # If `num_labels` is provided, it will be considered a classification task.
2
+ # You can also specify `--model Qwen/Qwen2.5-VL-2B-Instruct --use_chat_template true`.
3
+ CUDA_VISIBLE_DEVICES=0 \
4
+ MAX_PIXELS=1003520 \
5
+ swift sft \
6
+ --model Qwen/Qwen2-VL-2B \
7
+ --train_type lora \
8
+ --dataset 'tany0699/garbage265#20000' \
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
+ --warmup_ratio 0.05 \
25
+ --dataloader_num_workers 4 \
26
+ --num_labels 265 \
27
+ --task_type seq_cls \
28
+ --use_chat_template false
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/regression/deploy.sh ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift deploy \
3
+ --adapters output/vx-xxx/checkpoint-xxx
4
+
5
+ # curl http://localhost:8000/v1/chat/completions -H "Content-Type: application/json" -d '{
6
+ # "model": "Qwen2.5-0.5B",
7
+ # "messages": [{"role": "user", "content": "Task: Based on the given two sentences, provide a similarity score between 0.0 and 1.0.\nSentence 1: The animal is eating.\nSentence 2: A woman is dancing.\nSimilarity score: "}]
8
+ # }'
video_gen_14d/third_party/VBench/VBench-2.0/vbench2/third_party/Instance_detector/examples/train/seq_cls/regression/infer.sh ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ CUDA_VISIBLE_DEVICES=0 \
2
+ swift infer \
3
+ --adapters output/vx-xxx/checkpoint-xxx \
4
+ --load_data_args true \
5
+ --max_batch_size 16