ZWJ666 commited on
Commit
0dd9a1c
·
verified ·
1 Parent(s): 7f4fd08

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +6 -0
  2. checkpoints/rl-model/added_tokens.json +24 -0
  3. checkpoints/rl-model/chat_template.json +3 -0
  4. checkpoints/rl-model/config.json +50 -0
  5. checkpoints/rl-model/debug_log.txt +3 -0
  6. checkpoints/rl-model/generation_config.json +14 -0
  7. checkpoints/rl-model/merges.txt +0 -0
  8. checkpoints/rl-model/metrics.png +3 -0
  9. checkpoints/rl-model/model-00001-of-00004.safetensors +3 -0
  10. checkpoints/rl-model/model-00002-of-00004.safetensors +3 -0
  11. checkpoints/rl-model/model-00003-of-00004.safetensors +3 -0
  12. checkpoints/rl-model/model-00004-of-00004.safetensors +3 -0
  13. checkpoints/rl-model/model.safetensors.index.json +736 -0
  14. checkpoints/rl-model/preprocessor_config.json +29 -0
  15. checkpoints/rl-model/special_tokens_map.json +31 -0
  16. checkpoints/rl-model/tokenizer.json +3 -0
  17. checkpoints/rl-model/tokenizer_config.json +213 -0
  18. checkpoints/rl-model/training_args.bin +3 -0
  19. checkpoints/rl-model/training_log.txt +0 -0
  20. checkpoints/rl-model/vocab.json +0 -0
  21. checkpoints/sft-model/added_tokens.json +24 -0
  22. checkpoints/sft-model/chat_template.json +3 -0
  23. checkpoints/sft-model/config.json +50 -0
  24. checkpoints/sft-model/generation_config.json +12 -0
  25. checkpoints/sft-model/merges.txt +0 -0
  26. checkpoints/sft-model/model-00001-of-00004.safetensors +3 -0
  27. checkpoints/sft-model/model-00002-of-00004.safetensors +3 -0
  28. checkpoints/sft-model/model-00003-of-00004.safetensors +3 -0
  29. checkpoints/sft-model/model-00004-of-00004.safetensors +3 -0
  30. checkpoints/sft-model/model.safetensors.index.json +736 -0
  31. checkpoints/sft-model/preprocessor_config.json +29 -0
  32. checkpoints/sft-model/special_tokens_map.json +31 -0
  33. checkpoints/sft-model/tokenizer.json +3 -0
  34. checkpoints/sft-model/tokenizer_config.json +209 -0
  35. checkpoints/sft-model/training_args.bin +3 -0
  36. checkpoints/sft-model/training_log.txt +0 -0
  37. checkpoints/sft-model/vocab.json +0 -0
  38. cot_generate/add_timestamp_to_video.py +157 -0
  39. cot_generate/batch_add_timestamp.py +118 -0
  40. cot_generate/clean_and_convert.py +181 -0
  41. cot_generate/clean_cot_data.py +296 -0
  42. cot_generate/generate_video_cot.py +567 -0
  43. cot_generate/generate_video_cot_with_hint.py +581 -0
  44. cot_generate/rl_data/08_clean_rl_data.py +163 -0
  45. cot_generate/rl_data/09_convert_to_training_format.py +184 -0
  46. cot_generate/rl_data/build_delta_frame_mapping.py +294 -0
  47. cot_generate/rl_data/run_oracle_inference.py +379 -0
  48. cot_generate/rl_data/select_single_pattern.py +73 -0
  49. cot_generate/run_generate.sh +58 -0
  50. cot_generate/sft_data/filter_cot.py +400 -0
.gitattributes CHANGED
@@ -33,3 +33,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ checkpoints/rl-model/debug_log.txt filter=lfs diff=lfs merge=lfs -text
37
+ checkpoints/rl-model/metrics.png filter=lfs diff=lfs merge=lfs -text
38
+ checkpoints/rl-model/tokenizer.json filter=lfs diff=lfs merge=lfs -text
39
+ checkpoints/sft-model/tokenizer.json filter=lfs diff=lfs merge=lfs -text
40
+ dataset/sft/cot_filtered_sft.json filter=lfs diff=lfs merge=lfs -text
41
+ eval/benchmarks/eval_ssv2_validation.json filter=lfs diff=lfs merge=lfs -text
checkpoints/rl-model/added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
checkpoints/rl-model/chat_template.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}"
3
+ }
checkpoints/rl-model/config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/zwj/Qwen2.5-VL-7B-sft-model",
3
+ "architectures": [
4
+ "Qwen2_5_VLForConditionalGeneration"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151645,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 3584,
11
+ "image_token_id": 151655,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 18944,
14
+ "max_position_embeddings": 128000,
15
+ "max_window_layers": 28,
16
+ "model_type": "qwen2_5_vl",
17
+ "num_attention_heads": 28,
18
+ "num_hidden_layers": 28,
19
+ "num_key_value_heads": 4,
20
+ "rms_norm_eps": 1e-06,
21
+ "rope_scaling": {
22
+ "mrope_section": [
23
+ 16,
24
+ 24,
25
+ 24
26
+ ],
27
+ "rope_type": "default",
28
+ "type": "default"
29
+ },
30
+ "rope_theta": 1000000.0,
31
+ "sliding_window": 32768,
32
+ "tie_word_embeddings": false,
33
+ "torch_dtype": "bfloat16",
34
+ "transformers_version": "4.49.0.dev0",
35
+ "use_cache": false,
36
+ "use_sliding_window": false,
37
+ "video_token_id": 151656,
38
+ "vision_config": {
39
+ "hidden_size": 1280,
40
+ "in_chans": 3,
41
+ "model_type": "qwen2_5_vl",
42
+ "spatial_patch_size": 14,
43
+ "tokens_per_second": 2,
44
+ "torch_dtype": "float32"
45
+ },
46
+ "vision_end_token_id": 151653,
47
+ "vision_start_token_id": 151652,
48
+ "vision_token_id": 151654,
49
+ "vocab_size": 152064
50
+ }
checkpoints/rl-model/debug_log.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a412f0f57e5b007d96a6a35607fdd6adb5c71b191251c8eff8c9cc91ad7ed1f
3
+ size 142220165
checkpoints/rl-model/generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "attn_implementation": "flash_attention_2",
3
+ "bos_token_id": 151643,
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 151645,
7
+ 151643
8
+ ],
9
+ "pad_token_id": 151643,
10
+ "repetition_penalty": 1.05,
11
+ "temperature": 1e-06,
12
+ "transformers_version": "4.49.0.dev0",
13
+ "use_cache": false
14
+ }
checkpoints/rl-model/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoints/rl-model/metrics.png ADDED

Git LFS Details

  • SHA256: d5d54b1452c08b6c9ecfa232ca676bff91f23a2c0f7fd9b5f1be9efaefecc374
  • Pointer size: 131 Bytes
  • Size of remote file: 339 kB
checkpoints/rl-model/model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ba00fdb5573cbbbf0436e0b574c50686f9d96553ffff38bc11fdc21d5c5c82c
3
+ size 4968243304
checkpoints/rl-model/model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f670ea93e36b0264abc861ed530ad96be420101e2866367c7cc69119dd852fe1
3
+ size 4991495816
checkpoints/rl-model/model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a12eda7ecf268ef56796306df3c46e31fd837d297b84b3599ff807c6a036b48
3
+ size 4932751040
checkpoints/rl-model/model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:389cf59b4f102a77772f1a24bd3ef4303e2c96a370c56498a3c9ff8253d21d0d
3
+ size 1691924384
checkpoints/rl-model/model.safetensors.index.json ADDED
@@ -0,0 +1,736 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 16584333312
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00004-of-00004.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00004.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
13
+ "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
14
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
15
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
16
+ "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
17
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
18
+ "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
19
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
20
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
21
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
22
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
23
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
24
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
25
+ "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
26
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
27
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
28
+ "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
29
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
30
+ "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
31
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
32
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
33
+ "model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
34
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
35
+ "model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
36
+ "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
37
+ "model.layers.10.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
38
+ "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
39
+ "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
40
+ "model.layers.10.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
41
+ "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
42
+ "model.layers.10.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
43
+ "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
44
+ "model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
45
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
46
+ "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
47
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
48
+ "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
49
+ "model.layers.11.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
50
+ "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
51
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
52
+ "model.layers.11.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
53
+ "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
54
+ "model.layers.11.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
55
+ "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
56
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
57
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
58
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
59
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
60
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
61
+ "model.layers.12.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
62
+ "model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
63
+ "model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
64
+ "model.layers.12.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
65
+ "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
66
+ "model.layers.12.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
67
+ "model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
68
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
69
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
70
+ "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
71
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
72
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
73
+ "model.layers.13.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
74
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
75
+ "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
76
+ "model.layers.13.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
77
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
78
+ "model.layers.13.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
79
+ "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
80
+ "model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
81
+ "model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
82
+ "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
83
+ "model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
84
+ "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
85
+ "model.layers.14.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
86
+ "model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
87
+ "model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
88
+ "model.layers.14.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
89
+ "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
90
+ "model.layers.14.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
91
+ "model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
92
+ "model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
93
+ "model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
94
+ "model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
95
+ "model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
96
+ "model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
97
+ "model.layers.15.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
98
+ "model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
99
+ "model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
100
+ "model.layers.15.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
101
+ "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
102
+ "model.layers.15.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
103
+ "model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
104
+ "model.layers.16.input_layernorm.weight": "model-00003-of-00004.safetensors",
105
+ "model.layers.16.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
106
+ "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
107
+ "model.layers.16.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
108
+ "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
109
+ "model.layers.16.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
110
+ "model.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
111
+ "model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
112
+ "model.layers.16.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
113
+ "model.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
114
+ "model.layers.16.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
115
+ "model.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
116
+ "model.layers.17.input_layernorm.weight": "model-00003-of-00004.safetensors",
117
+ "model.layers.17.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
118
+ "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
119
+ "model.layers.17.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
120
+ "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
121
+ "model.layers.17.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
122
+ "model.layers.17.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
123
+ "model.layers.17.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
124
+ "model.layers.17.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
125
+ "model.layers.17.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
126
+ "model.layers.17.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
127
+ "model.layers.17.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
128
+ "model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors",
129
+ "model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
130
+ "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
131
+ "model.layers.18.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
132
+ "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
133
+ "model.layers.18.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
134
+ "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
135
+ "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
136
+ "model.layers.18.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
137
+ "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
138
+ "model.layers.18.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
139
+ "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
140
+ "model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors",
141
+ "model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
142
+ "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
143
+ "model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
144
+ "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
145
+ "model.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
146
+ "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
147
+ "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
148
+ "model.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
149
+ "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
150
+ "model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
151
+ "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
152
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
153
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
154
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
155
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
156
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
157
+ "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
158
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
159
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
160
+ "model.layers.2.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
161
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
162
+ "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
163
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
164
+ "model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
165
+ "model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
166
+ "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
167
+ "model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
168
+ "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
169
+ "model.layers.20.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
170
+ "model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
171
+ "model.layers.20.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
172
+ "model.layers.20.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
173
+ "model.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
174
+ "model.layers.20.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
175
+ "model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
176
+ "model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
177
+ "model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
178
+ "model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
179
+ "model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
180
+ "model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
181
+ "model.layers.21.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
182
+ "model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
183
+ "model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
184
+ "model.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
185
+ "model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
186
+ "model.layers.21.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
187
+ "model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
188
+ "model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
189
+ "model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
190
+ "model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
191
+ "model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
192
+ "model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
193
+ "model.layers.22.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
194
+ "model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
195
+ "model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
196
+ "model.layers.22.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
197
+ "model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
198
+ "model.layers.22.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
199
+ "model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
200
+ "model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
201
+ "model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
202
+ "model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
203
+ "model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
204
+ "model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
205
+ "model.layers.23.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
206
+ "model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
207
+ "model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
208
+ "model.layers.23.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
209
+ "model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
210
+ "model.layers.23.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
211
+ "model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
212
+ "model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
213
+ "model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
214
+ "model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
215
+ "model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
216
+ "model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
217
+ "model.layers.24.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
218
+ "model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
219
+ "model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
220
+ "model.layers.24.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
221
+ "model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
222
+ "model.layers.24.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
223
+ "model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
224
+ "model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
225
+ "model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
226
+ "model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
227
+ "model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
228
+ "model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
229
+ "model.layers.25.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
230
+ "model.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
231
+ "model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
232
+ "model.layers.25.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
233
+ "model.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
234
+ "model.layers.25.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
235
+ "model.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
236
+ "model.layers.26.input_layernorm.weight": "model-00004-of-00004.safetensors",
237
+ "model.layers.26.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
238
+ "model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
239
+ "model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
240
+ "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
241
+ "model.layers.26.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
242
+ "model.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
243
+ "model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
244
+ "model.layers.26.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
245
+ "model.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
246
+ "model.layers.26.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
247
+ "model.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
248
+ "model.layers.27.input_layernorm.weight": "model-00004-of-00004.safetensors",
249
+ "model.layers.27.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
250
+ "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
251
+ "model.layers.27.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
252
+ "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
253
+ "model.layers.27.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
254
+ "model.layers.27.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
255
+ "model.layers.27.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
256
+ "model.layers.27.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
257
+ "model.layers.27.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
258
+ "model.layers.27.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
259
+ "model.layers.27.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
260
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
261
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
262
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
263
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
264
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
265
+ "model.layers.3.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
266
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
267
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
268
+ "model.layers.3.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
269
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
270
+ "model.layers.3.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
271
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
272
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
273
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
274
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
275
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
276
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
277
+ "model.layers.4.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
278
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
279
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
280
+ "model.layers.4.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
281
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
282
+ "model.layers.4.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
283
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
284
+ "model.layers.5.input_layernorm.weight": "model-00002-of-00004.safetensors",
285
+ "model.layers.5.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
286
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
287
+ "model.layers.5.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
288
+ "model.layers.5.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
289
+ "model.layers.5.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
290
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
291
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
292
+ "model.layers.5.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
293
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
294
+ "model.layers.5.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
295
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
296
+ "model.layers.6.input_layernorm.weight": "model-00002-of-00004.safetensors",
297
+ "model.layers.6.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
298
+ "model.layers.6.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
299
+ "model.layers.6.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
300
+ "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
301
+ "model.layers.6.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
302
+ "model.layers.6.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
303
+ "model.layers.6.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
304
+ "model.layers.6.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
305
+ "model.layers.6.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
306
+ "model.layers.6.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
307
+ "model.layers.6.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
308
+ "model.layers.7.input_layernorm.weight": "model-00002-of-00004.safetensors",
309
+ "model.layers.7.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
310
+ "model.layers.7.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
311
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
312
+ "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
313
+ "model.layers.7.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
314
+ "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
315
+ "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
316
+ "model.layers.7.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
317
+ "model.layers.7.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
318
+ "model.layers.7.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
319
+ "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
320
+ "model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors",
321
+ "model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
322
+ "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
323
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
324
+ "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
325
+ "model.layers.8.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
326
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
327
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
328
+ "model.layers.8.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
329
+ "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
330
+ "model.layers.8.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
331
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
332
+ "model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
333
+ "model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
334
+ "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
335
+ "model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
336
+ "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
337
+ "model.layers.9.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
338
+ "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
339
+ "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
340
+ "model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
341
+ "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
342
+ "model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
343
+ "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
344
+ "model.norm.weight": "model-00004-of-00004.safetensors",
345
+ "visual.blocks.0.attn.proj.bias": "model-00001-of-00004.safetensors",
346
+ "visual.blocks.0.attn.proj.weight": "model-00001-of-00004.safetensors",
347
+ "visual.blocks.0.attn.qkv.bias": "model-00001-of-00004.safetensors",
348
+ "visual.blocks.0.attn.qkv.weight": "model-00001-of-00004.safetensors",
349
+ "visual.blocks.0.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
350
+ "visual.blocks.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
351
+ "visual.blocks.0.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
352
+ "visual.blocks.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
353
+ "visual.blocks.0.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
354
+ "visual.blocks.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
355
+ "visual.blocks.0.norm1.weight": "model-00001-of-00004.safetensors",
356
+ "visual.blocks.0.norm2.weight": "model-00001-of-00004.safetensors",
357
+ "visual.blocks.1.attn.proj.bias": "model-00001-of-00004.safetensors",
358
+ "visual.blocks.1.attn.proj.weight": "model-00001-of-00004.safetensors",
359
+ "visual.blocks.1.attn.qkv.bias": "model-00001-of-00004.safetensors",
360
+ "visual.blocks.1.attn.qkv.weight": "model-00001-of-00004.safetensors",
361
+ "visual.blocks.1.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
362
+ "visual.blocks.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
363
+ "visual.blocks.1.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
364
+ "visual.blocks.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
365
+ "visual.blocks.1.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
366
+ "visual.blocks.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
367
+ "visual.blocks.1.norm1.weight": "model-00001-of-00004.safetensors",
368
+ "visual.blocks.1.norm2.weight": "model-00001-of-00004.safetensors",
369
+ "visual.blocks.10.attn.proj.bias": "model-00001-of-00004.safetensors",
370
+ "visual.blocks.10.attn.proj.weight": "model-00001-of-00004.safetensors",
371
+ "visual.blocks.10.attn.qkv.bias": "model-00001-of-00004.safetensors",
372
+ "visual.blocks.10.attn.qkv.weight": "model-00001-of-00004.safetensors",
373
+ "visual.blocks.10.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
374
+ "visual.blocks.10.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
375
+ "visual.blocks.10.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
376
+ "visual.blocks.10.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
377
+ "visual.blocks.10.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
378
+ "visual.blocks.10.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
379
+ "visual.blocks.10.norm1.weight": "model-00001-of-00004.safetensors",
380
+ "visual.blocks.10.norm2.weight": "model-00001-of-00004.safetensors",
381
+ "visual.blocks.11.attn.proj.bias": "model-00001-of-00004.safetensors",
382
+ "visual.blocks.11.attn.proj.weight": "model-00001-of-00004.safetensors",
383
+ "visual.blocks.11.attn.qkv.bias": "model-00001-of-00004.safetensors",
384
+ "visual.blocks.11.attn.qkv.weight": "model-00001-of-00004.safetensors",
385
+ "visual.blocks.11.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
386
+ "visual.blocks.11.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
387
+ "visual.blocks.11.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
388
+ "visual.blocks.11.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
389
+ "visual.blocks.11.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
390
+ "visual.blocks.11.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
391
+ "visual.blocks.11.norm1.weight": "model-00001-of-00004.safetensors",
392
+ "visual.blocks.11.norm2.weight": "model-00001-of-00004.safetensors",
393
+ "visual.blocks.12.attn.proj.bias": "model-00001-of-00004.safetensors",
394
+ "visual.blocks.12.attn.proj.weight": "model-00001-of-00004.safetensors",
395
+ "visual.blocks.12.attn.qkv.bias": "model-00001-of-00004.safetensors",
396
+ "visual.blocks.12.attn.qkv.weight": "model-00001-of-00004.safetensors",
397
+ "visual.blocks.12.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
398
+ "visual.blocks.12.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
399
+ "visual.blocks.12.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
400
+ "visual.blocks.12.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
401
+ "visual.blocks.12.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
402
+ "visual.blocks.12.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
403
+ "visual.blocks.12.norm1.weight": "model-00001-of-00004.safetensors",
404
+ "visual.blocks.12.norm2.weight": "model-00001-of-00004.safetensors",
405
+ "visual.blocks.13.attn.proj.bias": "model-00001-of-00004.safetensors",
406
+ "visual.blocks.13.attn.proj.weight": "model-00001-of-00004.safetensors",
407
+ "visual.blocks.13.attn.qkv.bias": "model-00001-of-00004.safetensors",
408
+ "visual.blocks.13.attn.qkv.weight": "model-00001-of-00004.safetensors",
409
+ "visual.blocks.13.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
410
+ "visual.blocks.13.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
411
+ "visual.blocks.13.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
412
+ "visual.blocks.13.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
413
+ "visual.blocks.13.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
414
+ "visual.blocks.13.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
415
+ "visual.blocks.13.norm1.weight": "model-00001-of-00004.safetensors",
416
+ "visual.blocks.13.norm2.weight": "model-00001-of-00004.safetensors",
417
+ "visual.blocks.14.attn.proj.bias": "model-00001-of-00004.safetensors",
418
+ "visual.blocks.14.attn.proj.weight": "model-00001-of-00004.safetensors",
419
+ "visual.blocks.14.attn.qkv.bias": "model-00001-of-00004.safetensors",
420
+ "visual.blocks.14.attn.qkv.weight": "model-00001-of-00004.safetensors",
421
+ "visual.blocks.14.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
422
+ "visual.blocks.14.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
423
+ "visual.blocks.14.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
424
+ "visual.blocks.14.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
425
+ "visual.blocks.14.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
426
+ "visual.blocks.14.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
427
+ "visual.blocks.14.norm1.weight": "model-00001-of-00004.safetensors",
428
+ "visual.blocks.14.norm2.weight": "model-00001-of-00004.safetensors",
429
+ "visual.blocks.15.attn.proj.bias": "model-00001-of-00004.safetensors",
430
+ "visual.blocks.15.attn.proj.weight": "model-00001-of-00004.safetensors",
431
+ "visual.blocks.15.attn.qkv.bias": "model-00001-of-00004.safetensors",
432
+ "visual.blocks.15.attn.qkv.weight": "model-00001-of-00004.safetensors",
433
+ "visual.blocks.15.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
434
+ "visual.blocks.15.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
435
+ "visual.blocks.15.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
436
+ "visual.blocks.15.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
437
+ "visual.blocks.15.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
438
+ "visual.blocks.15.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
439
+ "visual.blocks.15.norm1.weight": "model-00001-of-00004.safetensors",
440
+ "visual.blocks.15.norm2.weight": "model-00001-of-00004.safetensors",
441
+ "visual.blocks.16.attn.proj.bias": "model-00001-of-00004.safetensors",
442
+ "visual.blocks.16.attn.proj.weight": "model-00001-of-00004.safetensors",
443
+ "visual.blocks.16.attn.qkv.bias": "model-00001-of-00004.safetensors",
444
+ "visual.blocks.16.attn.qkv.weight": "model-00001-of-00004.safetensors",
445
+ "visual.blocks.16.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
446
+ "visual.blocks.16.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
447
+ "visual.blocks.16.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
448
+ "visual.blocks.16.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
449
+ "visual.blocks.16.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
450
+ "visual.blocks.16.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
451
+ "visual.blocks.16.norm1.weight": "model-00001-of-00004.safetensors",
452
+ "visual.blocks.16.norm2.weight": "model-00001-of-00004.safetensors",
453
+ "visual.blocks.17.attn.proj.bias": "model-00001-of-00004.safetensors",
454
+ "visual.blocks.17.attn.proj.weight": "model-00001-of-00004.safetensors",
455
+ "visual.blocks.17.attn.qkv.bias": "model-00001-of-00004.safetensors",
456
+ "visual.blocks.17.attn.qkv.weight": "model-00001-of-00004.safetensors",
457
+ "visual.blocks.17.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
458
+ "visual.blocks.17.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
459
+ "visual.blocks.17.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
460
+ "visual.blocks.17.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
461
+ "visual.blocks.17.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
462
+ "visual.blocks.17.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
463
+ "visual.blocks.17.norm1.weight": "model-00001-of-00004.safetensors",
464
+ "visual.blocks.17.norm2.weight": "model-00001-of-00004.safetensors",
465
+ "visual.blocks.18.attn.proj.bias": "model-00001-of-00004.safetensors",
466
+ "visual.blocks.18.attn.proj.weight": "model-00001-of-00004.safetensors",
467
+ "visual.blocks.18.attn.qkv.bias": "model-00001-of-00004.safetensors",
468
+ "visual.blocks.18.attn.qkv.weight": "model-00001-of-00004.safetensors",
469
+ "visual.blocks.18.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
470
+ "visual.blocks.18.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
471
+ "visual.blocks.18.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
472
+ "visual.blocks.18.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
473
+ "visual.blocks.18.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
474
+ "visual.blocks.18.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
475
+ "visual.blocks.18.norm1.weight": "model-00001-of-00004.safetensors",
476
+ "visual.blocks.18.norm2.weight": "model-00001-of-00004.safetensors",
477
+ "visual.blocks.19.attn.proj.bias": "model-00001-of-00004.safetensors",
478
+ "visual.blocks.19.attn.proj.weight": "model-00001-of-00004.safetensors",
479
+ "visual.blocks.19.attn.qkv.bias": "model-00001-of-00004.safetensors",
480
+ "visual.blocks.19.attn.qkv.weight": "model-00001-of-00004.safetensors",
481
+ "visual.blocks.19.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
482
+ "visual.blocks.19.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
483
+ "visual.blocks.19.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
484
+ "visual.blocks.19.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
485
+ "visual.blocks.19.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
486
+ "visual.blocks.19.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
487
+ "visual.blocks.19.norm1.weight": "model-00001-of-00004.safetensors",
488
+ "visual.blocks.19.norm2.weight": "model-00001-of-00004.safetensors",
489
+ "visual.blocks.2.attn.proj.bias": "model-00001-of-00004.safetensors",
490
+ "visual.blocks.2.attn.proj.weight": "model-00001-of-00004.safetensors",
491
+ "visual.blocks.2.attn.qkv.bias": "model-00001-of-00004.safetensors",
492
+ "visual.blocks.2.attn.qkv.weight": "model-00001-of-00004.safetensors",
493
+ "visual.blocks.2.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
494
+ "visual.blocks.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
495
+ "visual.blocks.2.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
496
+ "visual.blocks.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
497
+ "visual.blocks.2.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
498
+ "visual.blocks.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
499
+ "visual.blocks.2.norm1.weight": "model-00001-of-00004.safetensors",
500
+ "visual.blocks.2.norm2.weight": "model-00001-of-00004.safetensors",
501
+ "visual.blocks.20.attn.proj.bias": "model-00001-of-00004.safetensors",
502
+ "visual.blocks.20.attn.proj.weight": "model-00001-of-00004.safetensors",
503
+ "visual.blocks.20.attn.qkv.bias": "model-00001-of-00004.safetensors",
504
+ "visual.blocks.20.attn.qkv.weight": "model-00001-of-00004.safetensors",
505
+ "visual.blocks.20.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
506
+ "visual.blocks.20.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
507
+ "visual.blocks.20.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
508
+ "visual.blocks.20.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
509
+ "visual.blocks.20.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
510
+ "visual.blocks.20.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
511
+ "visual.blocks.20.norm1.weight": "model-00001-of-00004.safetensors",
512
+ "visual.blocks.20.norm2.weight": "model-00001-of-00004.safetensors",
513
+ "visual.blocks.21.attn.proj.bias": "model-00001-of-00004.safetensors",
514
+ "visual.blocks.21.attn.proj.weight": "model-00001-of-00004.safetensors",
515
+ "visual.blocks.21.attn.qkv.bias": "model-00001-of-00004.safetensors",
516
+ "visual.blocks.21.attn.qkv.weight": "model-00001-of-00004.safetensors",
517
+ "visual.blocks.21.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
518
+ "visual.blocks.21.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
519
+ "visual.blocks.21.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
520
+ "visual.blocks.21.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
521
+ "visual.blocks.21.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
522
+ "visual.blocks.21.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
523
+ "visual.blocks.21.norm1.weight": "model-00001-of-00004.safetensors",
524
+ "visual.blocks.21.norm2.weight": "model-00001-of-00004.safetensors",
525
+ "visual.blocks.22.attn.proj.bias": "model-00001-of-00004.safetensors",
526
+ "visual.blocks.22.attn.proj.weight": "model-00001-of-00004.safetensors",
527
+ "visual.blocks.22.attn.qkv.bias": "model-00001-of-00004.safetensors",
528
+ "visual.blocks.22.attn.qkv.weight": "model-00001-of-00004.safetensors",
529
+ "visual.blocks.22.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
530
+ "visual.blocks.22.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
531
+ "visual.blocks.22.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
532
+ "visual.blocks.22.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
533
+ "visual.blocks.22.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
534
+ "visual.blocks.22.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
535
+ "visual.blocks.22.norm1.weight": "model-00001-of-00004.safetensors",
536
+ "visual.blocks.22.norm2.weight": "model-00001-of-00004.safetensors",
537
+ "visual.blocks.23.attn.proj.bias": "model-00001-of-00004.safetensors",
538
+ "visual.blocks.23.attn.proj.weight": "model-00001-of-00004.safetensors",
539
+ "visual.blocks.23.attn.qkv.bias": "model-00001-of-00004.safetensors",
540
+ "visual.blocks.23.attn.qkv.weight": "model-00001-of-00004.safetensors",
541
+ "visual.blocks.23.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
542
+ "visual.blocks.23.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
543
+ "visual.blocks.23.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
544
+ "visual.blocks.23.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
545
+ "visual.blocks.23.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
546
+ "visual.blocks.23.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
547
+ "visual.blocks.23.norm1.weight": "model-00001-of-00004.safetensors",
548
+ "visual.blocks.23.norm2.weight": "model-00001-of-00004.safetensors",
549
+ "visual.blocks.24.attn.proj.bias": "model-00001-of-00004.safetensors",
550
+ "visual.blocks.24.attn.proj.weight": "model-00001-of-00004.safetensors",
551
+ "visual.blocks.24.attn.qkv.bias": "model-00001-of-00004.safetensors",
552
+ "visual.blocks.24.attn.qkv.weight": "model-00001-of-00004.safetensors",
553
+ "visual.blocks.24.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
554
+ "visual.blocks.24.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
555
+ "visual.blocks.24.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
556
+ "visual.blocks.24.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
557
+ "visual.blocks.24.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
558
+ "visual.blocks.24.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
559
+ "visual.blocks.24.norm1.weight": "model-00001-of-00004.safetensors",
560
+ "visual.blocks.24.norm2.weight": "model-00001-of-00004.safetensors",
561
+ "visual.blocks.25.attn.proj.bias": "model-00001-of-00004.safetensors",
562
+ "visual.blocks.25.attn.proj.weight": "model-00001-of-00004.safetensors",
563
+ "visual.blocks.25.attn.qkv.bias": "model-00001-of-00004.safetensors",
564
+ "visual.blocks.25.attn.qkv.weight": "model-00001-of-00004.safetensors",
565
+ "visual.blocks.25.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
566
+ "visual.blocks.25.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
567
+ "visual.blocks.25.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
568
+ "visual.blocks.25.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
569
+ "visual.blocks.25.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
570
+ "visual.blocks.25.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
571
+ "visual.blocks.25.norm1.weight": "model-00001-of-00004.safetensors",
572
+ "visual.blocks.25.norm2.weight": "model-00001-of-00004.safetensors",
573
+ "visual.blocks.26.attn.proj.bias": "model-00001-of-00004.safetensors",
574
+ "visual.blocks.26.attn.proj.weight": "model-00001-of-00004.safetensors",
575
+ "visual.blocks.26.attn.qkv.bias": "model-00001-of-00004.safetensors",
576
+ "visual.blocks.26.attn.qkv.weight": "model-00001-of-00004.safetensors",
577
+ "visual.blocks.26.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
578
+ "visual.blocks.26.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
579
+ "visual.blocks.26.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
580
+ "visual.blocks.26.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
581
+ "visual.blocks.26.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
582
+ "visual.blocks.26.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
583
+ "visual.blocks.26.norm1.weight": "model-00001-of-00004.safetensors",
584
+ "visual.blocks.26.norm2.weight": "model-00001-of-00004.safetensors",
585
+ "visual.blocks.27.attn.proj.bias": "model-00001-of-00004.safetensors",
586
+ "visual.blocks.27.attn.proj.weight": "model-00001-of-00004.safetensors",
587
+ "visual.blocks.27.attn.qkv.bias": "model-00001-of-00004.safetensors",
588
+ "visual.blocks.27.attn.qkv.weight": "model-00001-of-00004.safetensors",
589
+ "visual.blocks.27.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
590
+ "visual.blocks.27.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
591
+ "visual.blocks.27.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
592
+ "visual.blocks.27.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
593
+ "visual.blocks.27.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
594
+ "visual.blocks.27.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
595
+ "visual.blocks.27.norm1.weight": "model-00001-of-00004.safetensors",
596
+ "visual.blocks.27.norm2.weight": "model-00001-of-00004.safetensors",
597
+ "visual.blocks.28.attn.proj.bias": "model-00001-of-00004.safetensors",
598
+ "visual.blocks.28.attn.proj.weight": "model-00001-of-00004.safetensors",
599
+ "visual.blocks.28.attn.qkv.bias": "model-00001-of-00004.safetensors",
600
+ "visual.blocks.28.attn.qkv.weight": "model-00001-of-00004.safetensors",
601
+ "visual.blocks.28.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
602
+ "visual.blocks.28.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
603
+ "visual.blocks.28.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
604
+ "visual.blocks.28.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
605
+ "visual.blocks.28.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
606
+ "visual.blocks.28.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
607
+ "visual.blocks.28.norm1.weight": "model-00001-of-00004.safetensors",
608
+ "visual.blocks.28.norm2.weight": "model-00001-of-00004.safetensors",
609
+ "visual.blocks.29.attn.proj.bias": "model-00001-of-00004.safetensors",
610
+ "visual.blocks.29.attn.proj.weight": "model-00001-of-00004.safetensors",
611
+ "visual.blocks.29.attn.qkv.bias": "model-00001-of-00004.safetensors",
612
+ "visual.blocks.29.attn.qkv.weight": "model-00001-of-00004.safetensors",
613
+ "visual.blocks.29.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
614
+ "visual.blocks.29.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
615
+ "visual.blocks.29.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
616
+ "visual.blocks.29.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
617
+ "visual.blocks.29.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
618
+ "visual.blocks.29.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
619
+ "visual.blocks.29.norm1.weight": "model-00001-of-00004.safetensors",
620
+ "visual.blocks.29.norm2.weight": "model-00001-of-00004.safetensors",
621
+ "visual.blocks.3.attn.proj.bias": "model-00001-of-00004.safetensors",
622
+ "visual.blocks.3.attn.proj.weight": "model-00001-of-00004.safetensors",
623
+ "visual.blocks.3.attn.qkv.bias": "model-00001-of-00004.safetensors",
624
+ "visual.blocks.3.attn.qkv.weight": "model-00001-of-00004.safetensors",
625
+ "visual.blocks.3.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
626
+ "visual.blocks.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
627
+ "visual.blocks.3.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
628
+ "visual.blocks.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
629
+ "visual.blocks.3.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
630
+ "visual.blocks.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
631
+ "visual.blocks.3.norm1.weight": "model-00001-of-00004.safetensors",
632
+ "visual.blocks.3.norm2.weight": "model-00001-of-00004.safetensors",
633
+ "visual.blocks.30.attn.proj.bias": "model-00001-of-00004.safetensors",
634
+ "visual.blocks.30.attn.proj.weight": "model-00001-of-00004.safetensors",
635
+ "visual.blocks.30.attn.qkv.bias": "model-00001-of-00004.safetensors",
636
+ "visual.blocks.30.attn.qkv.weight": "model-00001-of-00004.safetensors",
637
+ "visual.blocks.30.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
638
+ "visual.blocks.30.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
639
+ "visual.blocks.30.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
640
+ "visual.blocks.30.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
641
+ "visual.blocks.30.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
642
+ "visual.blocks.30.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
643
+ "visual.blocks.30.norm1.weight": "model-00001-of-00004.safetensors",
644
+ "visual.blocks.30.norm2.weight": "model-00001-of-00004.safetensors",
645
+ "visual.blocks.31.attn.proj.bias": "model-00001-of-00004.safetensors",
646
+ "visual.blocks.31.attn.proj.weight": "model-00001-of-00004.safetensors",
647
+ "visual.blocks.31.attn.qkv.bias": "model-00001-of-00004.safetensors",
648
+ "visual.blocks.31.attn.qkv.weight": "model-00001-of-00004.safetensors",
649
+ "visual.blocks.31.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
650
+ "visual.blocks.31.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
651
+ "visual.blocks.31.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
652
+ "visual.blocks.31.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
653
+ "visual.blocks.31.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
654
+ "visual.blocks.31.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
655
+ "visual.blocks.31.norm1.weight": "model-00001-of-00004.safetensors",
656
+ "visual.blocks.31.norm2.weight": "model-00001-of-00004.safetensors",
657
+ "visual.blocks.4.attn.proj.bias": "model-00001-of-00004.safetensors",
658
+ "visual.blocks.4.attn.proj.weight": "model-00001-of-00004.safetensors",
659
+ "visual.blocks.4.attn.qkv.bias": "model-00001-of-00004.safetensors",
660
+ "visual.blocks.4.attn.qkv.weight": "model-00001-of-00004.safetensors",
661
+ "visual.blocks.4.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
662
+ "visual.blocks.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
663
+ "visual.blocks.4.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
664
+ "visual.blocks.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
665
+ "visual.blocks.4.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
666
+ "visual.blocks.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
667
+ "visual.blocks.4.norm1.weight": "model-00001-of-00004.safetensors",
668
+ "visual.blocks.4.norm2.weight": "model-00001-of-00004.safetensors",
669
+ "visual.blocks.5.attn.proj.bias": "model-00001-of-00004.safetensors",
670
+ "visual.blocks.5.attn.proj.weight": "model-00001-of-00004.safetensors",
671
+ "visual.blocks.5.attn.qkv.bias": "model-00001-of-00004.safetensors",
672
+ "visual.blocks.5.attn.qkv.weight": "model-00001-of-00004.safetensors",
673
+ "visual.blocks.5.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
674
+ "visual.blocks.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
675
+ "visual.blocks.5.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
676
+ "visual.blocks.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
677
+ "visual.blocks.5.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
678
+ "visual.blocks.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
679
+ "visual.blocks.5.norm1.weight": "model-00001-of-00004.safetensors",
680
+ "visual.blocks.5.norm2.weight": "model-00001-of-00004.safetensors",
681
+ "visual.blocks.6.attn.proj.bias": "model-00001-of-00004.safetensors",
682
+ "visual.blocks.6.attn.proj.weight": "model-00001-of-00004.safetensors",
683
+ "visual.blocks.6.attn.qkv.bias": "model-00001-of-00004.safetensors",
684
+ "visual.blocks.6.attn.qkv.weight": "model-00001-of-00004.safetensors",
685
+ "visual.blocks.6.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
686
+ "visual.blocks.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
687
+ "visual.blocks.6.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
688
+ "visual.blocks.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
689
+ "visual.blocks.6.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
690
+ "visual.blocks.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
691
+ "visual.blocks.6.norm1.weight": "model-00001-of-00004.safetensors",
692
+ "visual.blocks.6.norm2.weight": "model-00001-of-00004.safetensors",
693
+ "visual.blocks.7.attn.proj.bias": "model-00001-of-00004.safetensors",
694
+ "visual.blocks.7.attn.proj.weight": "model-00001-of-00004.safetensors",
695
+ "visual.blocks.7.attn.qkv.bias": "model-00001-of-00004.safetensors",
696
+ "visual.blocks.7.attn.qkv.weight": "model-00001-of-00004.safetensors",
697
+ "visual.blocks.7.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
698
+ "visual.blocks.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
699
+ "visual.blocks.7.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
700
+ "visual.blocks.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
701
+ "visual.blocks.7.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
702
+ "visual.blocks.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
703
+ "visual.blocks.7.norm1.weight": "model-00001-of-00004.safetensors",
704
+ "visual.blocks.7.norm2.weight": "model-00001-of-00004.safetensors",
705
+ "visual.blocks.8.attn.proj.bias": "model-00001-of-00004.safetensors",
706
+ "visual.blocks.8.attn.proj.weight": "model-00001-of-00004.safetensors",
707
+ "visual.blocks.8.attn.qkv.bias": "model-00001-of-00004.safetensors",
708
+ "visual.blocks.8.attn.qkv.weight": "model-00001-of-00004.safetensors",
709
+ "visual.blocks.8.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
710
+ "visual.blocks.8.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
711
+ "visual.blocks.8.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
712
+ "visual.blocks.8.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
713
+ "visual.blocks.8.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
714
+ "visual.blocks.8.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
715
+ "visual.blocks.8.norm1.weight": "model-00001-of-00004.safetensors",
716
+ "visual.blocks.8.norm2.weight": "model-00001-of-00004.safetensors",
717
+ "visual.blocks.9.attn.proj.bias": "model-00001-of-00004.safetensors",
718
+ "visual.blocks.9.attn.proj.weight": "model-00001-of-00004.safetensors",
719
+ "visual.blocks.9.attn.qkv.bias": "model-00001-of-00004.safetensors",
720
+ "visual.blocks.9.attn.qkv.weight": "model-00001-of-00004.safetensors",
721
+ "visual.blocks.9.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
722
+ "visual.blocks.9.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
723
+ "visual.blocks.9.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
724
+ "visual.blocks.9.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
725
+ "visual.blocks.9.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
726
+ "visual.blocks.9.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
727
+ "visual.blocks.9.norm1.weight": "model-00001-of-00004.safetensors",
728
+ "visual.blocks.9.norm2.weight": "model-00001-of-00004.safetensors",
729
+ "visual.merger.ln_q.weight": "model-00001-of-00004.safetensors",
730
+ "visual.merger.mlp.0.bias": "model-00001-of-00004.safetensors",
731
+ "visual.merger.mlp.0.weight": "model-00001-of-00004.safetensors",
732
+ "visual.merger.mlp.2.bias": "model-00001-of-00004.safetensors",
733
+ "visual.merger.mlp.2.weight": "model-00001-of-00004.safetensors",
734
+ "visual.patch_embed.proj.weight": "model-00001-of-00004.safetensors"
735
+ }
736
+ }
checkpoints/rl-model/preprocessor_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": true,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.48145466,
8
+ 0.4578275,
9
+ 0.40821073
10
+ ],
11
+ "image_processor_type": "Qwen2_5_VLImageProcessor",
12
+ "image_std": [
13
+ 0.26862954,
14
+ 0.26130258,
15
+ 0.27577711
16
+ ],
17
+ "max_pixels": 501760,
18
+ "merge_size": 2,
19
+ "min_pixels": 3136,
20
+ "patch_size": 14,
21
+ "processor_class": "Qwen2_5_VLProcessor",
22
+ "resample": 3,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "size": {
25
+ "longest_edge": 12845056,
26
+ "shortest_edge": 3136
27
+ },
28
+ "temporal_patch_size": 2
29
+ }
checkpoints/rl-model/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
checkpoints/rl-model/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5eee858c5123a4279c3e1f7b81247343f356ac767940b2692a928ad929543214
3
+ size 11422063
checkpoints/rl-model/tokenizer_config.json ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}",
199
+ "clean_up_tokenization_spaces": false,
200
+ "eos_token": "<|im_end|>",
201
+ "errors": "replace",
202
+ "extra_special_tokens": {},
203
+ "max_length": null,
204
+ "model_max_length": 131072,
205
+ "pad_to_multiple_of": null,
206
+ "pad_token": "<|endoftext|>",
207
+ "pad_token_type_id": 0,
208
+ "padding_side": "right",
209
+ "processor_class": "Qwen2_5_VLProcessor",
210
+ "split_special_tokens": false,
211
+ "tokenizer_class": "Qwen2Tokenizer",
212
+ "unk_token": null
213
+ }
checkpoints/rl-model/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c2ff2cb693b88eb056e5c876821692cb9f6ac31755dda99e9d4e956c657665d5
3
+ size 8440
checkpoints/rl-model/training_log.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoints/rl-model/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
checkpoints/sft-model/added_tokens.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "</tool_call>": 151658,
3
+ "<tool_call>": 151657,
4
+ "<|box_end|>": 151649,
5
+ "<|box_start|>": 151648,
6
+ "<|endoftext|>": 151643,
7
+ "<|file_sep|>": 151664,
8
+ "<|fim_middle|>": 151660,
9
+ "<|fim_pad|>": 151662,
10
+ "<|fim_prefix|>": 151659,
11
+ "<|fim_suffix|>": 151661,
12
+ "<|im_end|>": 151645,
13
+ "<|im_start|>": 151644,
14
+ "<|image_pad|>": 151655,
15
+ "<|object_ref_end|>": 151647,
16
+ "<|object_ref_start|>": 151646,
17
+ "<|quad_end|>": 151651,
18
+ "<|quad_start|>": 151650,
19
+ "<|repo_name|>": 151663,
20
+ "<|video_pad|>": 151656,
21
+ "<|vision_end|>": 151653,
22
+ "<|vision_pad|>": 151654,
23
+ "<|vision_start|>": 151652
24
+ }
checkpoints/sft-model/chat_template.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}"
3
+ }
checkpoints/sft-model/config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/root/zwj/Model/Qwen2.5-VL-7B-Instruct",
3
+ "architectures": [
4
+ "Qwen2_5_VLForConditionalGeneration"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151645,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 3584,
11
+ "image_token_id": 151655,
12
+ "initializer_range": 0.02,
13
+ "intermediate_size": 18944,
14
+ "max_position_embeddings": 128000,
15
+ "max_window_layers": 28,
16
+ "model_type": "qwen2_5_vl",
17
+ "num_attention_heads": 28,
18
+ "num_hidden_layers": 28,
19
+ "num_key_value_heads": 4,
20
+ "rms_norm_eps": 1e-06,
21
+ "rope_scaling": {
22
+ "mrope_section": [
23
+ 16,
24
+ 24,
25
+ 24
26
+ ],
27
+ "rope_type": "default",
28
+ "type": "default"
29
+ },
30
+ "rope_theta": 1000000.0,
31
+ "sliding_window": 32768,
32
+ "tie_word_embeddings": false,
33
+ "torch_dtype": "bfloat16",
34
+ "transformers_version": "4.49.0.dev0",
35
+ "use_cache": true,
36
+ "use_sliding_window": false,
37
+ "video_token_id": 151656,
38
+ "vision_config": {
39
+ "hidden_size": 1280,
40
+ "in_chans": 3,
41
+ "model_type": "qwen2_5_vl",
42
+ "spatial_patch_size": 14,
43
+ "tokens_per_second": 2,
44
+ "torch_dtype": "float32"
45
+ },
46
+ "vision_end_token_id": 151653,
47
+ "vision_start_token_id": 151652,
48
+ "vision_token_id": 151654,
49
+ "vocab_size": 152064
50
+ }
checkpoints/sft-model/generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "pad_token_id": 151643,
9
+ "repetition_penalty": 1.05,
10
+ "temperature": 1e-06,
11
+ "transformers_version": "4.49.0.dev0"
12
+ }
checkpoints/sft-model/merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoints/sft-model/model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f46d9a59293a1f4d2ec11a0b73b6f0ba0dd7bc4f4a528fc3278a502339af9c2b
3
+ size 4968243304
checkpoints/sft-model/model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a267bd8d35011f3fc273b2a7df667da0cdcb1d2c2eac6f3c4397b7a86284a630
3
+ size 4991495816
checkpoints/sft-model/model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a63d0282c73caea663ffd78fa9a2f2233acc7deb6b5b4af5824de0c06e290c07
3
+ size 4932751040
checkpoints/sft-model/model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a4b7d3370247e316d297ca31432922641905ef15e448ffa2de08fd78d972b29f
3
+ size 1691924384
checkpoints/sft-model/model.safetensors.index.json ADDED
@@ -0,0 +1,736 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_size": 16584333312
4
+ },
5
+ "weight_map": {
6
+ "lm_head.weight": "model-00004-of-00004.safetensors",
7
+ "model.embed_tokens.weight": "model-00001-of-00004.safetensors",
8
+ "model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
9
+ "model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
10
+ "model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
11
+ "model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
12
+ "model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
13
+ "model.layers.0.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
14
+ "model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
15
+ "model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
16
+ "model.layers.0.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
17
+ "model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
18
+ "model.layers.0.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
19
+ "model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
20
+ "model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
21
+ "model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
22
+ "model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
23
+ "model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
24
+ "model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
25
+ "model.layers.1.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
26
+ "model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
27
+ "model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
28
+ "model.layers.1.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
29
+ "model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
30
+ "model.layers.1.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
31
+ "model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
32
+ "model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
33
+ "model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
34
+ "model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
35
+ "model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
36
+ "model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
37
+ "model.layers.10.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
38
+ "model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
39
+ "model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
40
+ "model.layers.10.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
41
+ "model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
42
+ "model.layers.10.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
43
+ "model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
44
+ "model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
45
+ "model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
46
+ "model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
47
+ "model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
48
+ "model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
49
+ "model.layers.11.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
50
+ "model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
51
+ "model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
52
+ "model.layers.11.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
53
+ "model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
54
+ "model.layers.11.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
55
+ "model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
56
+ "model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
57
+ "model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
58
+ "model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
59
+ "model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
60
+ "model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
61
+ "model.layers.12.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
62
+ "model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
63
+ "model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
64
+ "model.layers.12.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
65
+ "model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
66
+ "model.layers.12.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
67
+ "model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
68
+ "model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
69
+ "model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
70
+ "model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
71
+ "model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
72
+ "model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
73
+ "model.layers.13.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
74
+ "model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
75
+ "model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
76
+ "model.layers.13.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
77
+ "model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
78
+ "model.layers.13.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
79
+ "model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
80
+ "model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
81
+ "model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
82
+ "model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
83
+ "model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
84
+ "model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
85
+ "model.layers.14.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
86
+ "model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
87
+ "model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
88
+ "model.layers.14.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
89
+ "model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
90
+ "model.layers.14.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
91
+ "model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
92
+ "model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
93
+ "model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
94
+ "model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
95
+ "model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
96
+ "model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
97
+ "model.layers.15.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
98
+ "model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
99
+ "model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
100
+ "model.layers.15.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
101
+ "model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
102
+ "model.layers.15.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
103
+ "model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
104
+ "model.layers.16.input_layernorm.weight": "model-00003-of-00004.safetensors",
105
+ "model.layers.16.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
106
+ "model.layers.16.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
107
+ "model.layers.16.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
108
+ "model.layers.16.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
109
+ "model.layers.16.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
110
+ "model.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
111
+ "model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
112
+ "model.layers.16.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
113
+ "model.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
114
+ "model.layers.16.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
115
+ "model.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
116
+ "model.layers.17.input_layernorm.weight": "model-00003-of-00004.safetensors",
117
+ "model.layers.17.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
118
+ "model.layers.17.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
119
+ "model.layers.17.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
120
+ "model.layers.17.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
121
+ "model.layers.17.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
122
+ "model.layers.17.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
123
+ "model.layers.17.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
124
+ "model.layers.17.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
125
+ "model.layers.17.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
126
+ "model.layers.17.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
127
+ "model.layers.17.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
128
+ "model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors",
129
+ "model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
130
+ "model.layers.18.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
131
+ "model.layers.18.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
132
+ "model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
133
+ "model.layers.18.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
134
+ "model.layers.18.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
135
+ "model.layers.18.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
136
+ "model.layers.18.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
137
+ "model.layers.18.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
138
+ "model.layers.18.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
139
+ "model.layers.18.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
140
+ "model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors",
141
+ "model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
142
+ "model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
143
+ "model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
144
+ "model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
145
+ "model.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
146
+ "model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
147
+ "model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
148
+ "model.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
149
+ "model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
150
+ "model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
151
+ "model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
152
+ "model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
153
+ "model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
154
+ "model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
155
+ "model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
156
+ "model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
157
+ "model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
158
+ "model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
159
+ "model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
160
+ "model.layers.2.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
161
+ "model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
162
+ "model.layers.2.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
163
+ "model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
164
+ "model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
165
+ "model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
166
+ "model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
167
+ "model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
168
+ "model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
169
+ "model.layers.20.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
170
+ "model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
171
+ "model.layers.20.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
172
+ "model.layers.20.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
173
+ "model.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
174
+ "model.layers.20.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
175
+ "model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
176
+ "model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
177
+ "model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
178
+ "model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
179
+ "model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
180
+ "model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
181
+ "model.layers.21.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
182
+ "model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
183
+ "model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
184
+ "model.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
185
+ "model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
186
+ "model.layers.21.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
187
+ "model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
188
+ "model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
189
+ "model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
190
+ "model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
191
+ "model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
192
+ "model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
193
+ "model.layers.22.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
194
+ "model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
195
+ "model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
196
+ "model.layers.22.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
197
+ "model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
198
+ "model.layers.22.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
199
+ "model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
200
+ "model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
201
+ "model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
202
+ "model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
203
+ "model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
204
+ "model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
205
+ "model.layers.23.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
206
+ "model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
207
+ "model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
208
+ "model.layers.23.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
209
+ "model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
210
+ "model.layers.23.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
211
+ "model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
212
+ "model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
213
+ "model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
214
+ "model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
215
+ "model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
216
+ "model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
217
+ "model.layers.24.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
218
+ "model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
219
+ "model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
220
+ "model.layers.24.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
221
+ "model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
222
+ "model.layers.24.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
223
+ "model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
224
+ "model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
225
+ "model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
226
+ "model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
227
+ "model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
228
+ "model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
229
+ "model.layers.25.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
230
+ "model.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
231
+ "model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
232
+ "model.layers.25.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
233
+ "model.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
234
+ "model.layers.25.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
235
+ "model.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
236
+ "model.layers.26.input_layernorm.weight": "model-00004-of-00004.safetensors",
237
+ "model.layers.26.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
238
+ "model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
239
+ "model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
240
+ "model.layers.26.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
241
+ "model.layers.26.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
242
+ "model.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
243
+ "model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
244
+ "model.layers.26.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
245
+ "model.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
246
+ "model.layers.26.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
247
+ "model.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
248
+ "model.layers.27.input_layernorm.weight": "model-00004-of-00004.safetensors",
249
+ "model.layers.27.mlp.down_proj.weight": "model-00004-of-00004.safetensors",
250
+ "model.layers.27.mlp.gate_proj.weight": "model-00004-of-00004.safetensors",
251
+ "model.layers.27.mlp.up_proj.weight": "model-00004-of-00004.safetensors",
252
+ "model.layers.27.post_attention_layernorm.weight": "model-00004-of-00004.safetensors",
253
+ "model.layers.27.self_attn.k_proj.bias": "model-00004-of-00004.safetensors",
254
+ "model.layers.27.self_attn.k_proj.weight": "model-00004-of-00004.safetensors",
255
+ "model.layers.27.self_attn.o_proj.weight": "model-00004-of-00004.safetensors",
256
+ "model.layers.27.self_attn.q_proj.bias": "model-00004-of-00004.safetensors",
257
+ "model.layers.27.self_attn.q_proj.weight": "model-00004-of-00004.safetensors",
258
+ "model.layers.27.self_attn.v_proj.bias": "model-00004-of-00004.safetensors",
259
+ "model.layers.27.self_attn.v_proj.weight": "model-00004-of-00004.safetensors",
260
+ "model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
261
+ "model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
262
+ "model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
263
+ "model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
264
+ "model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
265
+ "model.layers.3.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
266
+ "model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
267
+ "model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
268
+ "model.layers.3.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
269
+ "model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
270
+ "model.layers.3.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
271
+ "model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
272
+ "model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
273
+ "model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
274
+ "model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
275
+ "model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
276
+ "model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
277
+ "model.layers.4.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
278
+ "model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
279
+ "model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
280
+ "model.layers.4.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
281
+ "model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
282
+ "model.layers.4.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
283
+ "model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
284
+ "model.layers.5.input_layernorm.weight": "model-00002-of-00004.safetensors",
285
+ "model.layers.5.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
286
+ "model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
287
+ "model.layers.5.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
288
+ "model.layers.5.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
289
+ "model.layers.5.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
290
+ "model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
291
+ "model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
292
+ "model.layers.5.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
293
+ "model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
294
+ "model.layers.5.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
295
+ "model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
296
+ "model.layers.6.input_layernorm.weight": "model-00002-of-00004.safetensors",
297
+ "model.layers.6.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
298
+ "model.layers.6.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
299
+ "model.layers.6.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
300
+ "model.layers.6.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
301
+ "model.layers.6.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
302
+ "model.layers.6.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
303
+ "model.layers.6.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
304
+ "model.layers.6.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
305
+ "model.layers.6.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
306
+ "model.layers.6.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
307
+ "model.layers.6.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
308
+ "model.layers.7.input_layernorm.weight": "model-00002-of-00004.safetensors",
309
+ "model.layers.7.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
310
+ "model.layers.7.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
311
+ "model.layers.7.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
312
+ "model.layers.7.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
313
+ "model.layers.7.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
314
+ "model.layers.7.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
315
+ "model.layers.7.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
316
+ "model.layers.7.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
317
+ "model.layers.7.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
318
+ "model.layers.7.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
319
+ "model.layers.7.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
320
+ "model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors",
321
+ "model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
322
+ "model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
323
+ "model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
324
+ "model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
325
+ "model.layers.8.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
326
+ "model.layers.8.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
327
+ "model.layers.8.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
328
+ "model.layers.8.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
329
+ "model.layers.8.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
330
+ "model.layers.8.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
331
+ "model.layers.8.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
332
+ "model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
333
+ "model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
334
+ "model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
335
+ "model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
336
+ "model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
337
+ "model.layers.9.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
338
+ "model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
339
+ "model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
340
+ "model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
341
+ "model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
342
+ "model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
343
+ "model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
344
+ "model.norm.weight": "model-00004-of-00004.safetensors",
345
+ "visual.blocks.0.attn.proj.bias": "model-00001-of-00004.safetensors",
346
+ "visual.blocks.0.attn.proj.weight": "model-00001-of-00004.safetensors",
347
+ "visual.blocks.0.attn.qkv.bias": "model-00001-of-00004.safetensors",
348
+ "visual.blocks.0.attn.qkv.weight": "model-00001-of-00004.safetensors",
349
+ "visual.blocks.0.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
350
+ "visual.blocks.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
351
+ "visual.blocks.0.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
352
+ "visual.blocks.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
353
+ "visual.blocks.0.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
354
+ "visual.blocks.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
355
+ "visual.blocks.0.norm1.weight": "model-00001-of-00004.safetensors",
356
+ "visual.blocks.0.norm2.weight": "model-00001-of-00004.safetensors",
357
+ "visual.blocks.1.attn.proj.bias": "model-00001-of-00004.safetensors",
358
+ "visual.blocks.1.attn.proj.weight": "model-00001-of-00004.safetensors",
359
+ "visual.blocks.1.attn.qkv.bias": "model-00001-of-00004.safetensors",
360
+ "visual.blocks.1.attn.qkv.weight": "model-00001-of-00004.safetensors",
361
+ "visual.blocks.1.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
362
+ "visual.blocks.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
363
+ "visual.blocks.1.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
364
+ "visual.blocks.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
365
+ "visual.blocks.1.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
366
+ "visual.blocks.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
367
+ "visual.blocks.1.norm1.weight": "model-00001-of-00004.safetensors",
368
+ "visual.blocks.1.norm2.weight": "model-00001-of-00004.safetensors",
369
+ "visual.blocks.10.attn.proj.bias": "model-00001-of-00004.safetensors",
370
+ "visual.blocks.10.attn.proj.weight": "model-00001-of-00004.safetensors",
371
+ "visual.blocks.10.attn.qkv.bias": "model-00001-of-00004.safetensors",
372
+ "visual.blocks.10.attn.qkv.weight": "model-00001-of-00004.safetensors",
373
+ "visual.blocks.10.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
374
+ "visual.blocks.10.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
375
+ "visual.blocks.10.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
376
+ "visual.blocks.10.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
377
+ "visual.blocks.10.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
378
+ "visual.blocks.10.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
379
+ "visual.blocks.10.norm1.weight": "model-00001-of-00004.safetensors",
380
+ "visual.blocks.10.norm2.weight": "model-00001-of-00004.safetensors",
381
+ "visual.blocks.11.attn.proj.bias": "model-00001-of-00004.safetensors",
382
+ "visual.blocks.11.attn.proj.weight": "model-00001-of-00004.safetensors",
383
+ "visual.blocks.11.attn.qkv.bias": "model-00001-of-00004.safetensors",
384
+ "visual.blocks.11.attn.qkv.weight": "model-00001-of-00004.safetensors",
385
+ "visual.blocks.11.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
386
+ "visual.blocks.11.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
387
+ "visual.blocks.11.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
388
+ "visual.blocks.11.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
389
+ "visual.blocks.11.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
390
+ "visual.blocks.11.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
391
+ "visual.blocks.11.norm1.weight": "model-00001-of-00004.safetensors",
392
+ "visual.blocks.11.norm2.weight": "model-00001-of-00004.safetensors",
393
+ "visual.blocks.12.attn.proj.bias": "model-00001-of-00004.safetensors",
394
+ "visual.blocks.12.attn.proj.weight": "model-00001-of-00004.safetensors",
395
+ "visual.blocks.12.attn.qkv.bias": "model-00001-of-00004.safetensors",
396
+ "visual.blocks.12.attn.qkv.weight": "model-00001-of-00004.safetensors",
397
+ "visual.blocks.12.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
398
+ "visual.blocks.12.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
399
+ "visual.blocks.12.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
400
+ "visual.blocks.12.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
401
+ "visual.blocks.12.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
402
+ "visual.blocks.12.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
403
+ "visual.blocks.12.norm1.weight": "model-00001-of-00004.safetensors",
404
+ "visual.blocks.12.norm2.weight": "model-00001-of-00004.safetensors",
405
+ "visual.blocks.13.attn.proj.bias": "model-00001-of-00004.safetensors",
406
+ "visual.blocks.13.attn.proj.weight": "model-00001-of-00004.safetensors",
407
+ "visual.blocks.13.attn.qkv.bias": "model-00001-of-00004.safetensors",
408
+ "visual.blocks.13.attn.qkv.weight": "model-00001-of-00004.safetensors",
409
+ "visual.blocks.13.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
410
+ "visual.blocks.13.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
411
+ "visual.blocks.13.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
412
+ "visual.blocks.13.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
413
+ "visual.blocks.13.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
414
+ "visual.blocks.13.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
415
+ "visual.blocks.13.norm1.weight": "model-00001-of-00004.safetensors",
416
+ "visual.blocks.13.norm2.weight": "model-00001-of-00004.safetensors",
417
+ "visual.blocks.14.attn.proj.bias": "model-00001-of-00004.safetensors",
418
+ "visual.blocks.14.attn.proj.weight": "model-00001-of-00004.safetensors",
419
+ "visual.blocks.14.attn.qkv.bias": "model-00001-of-00004.safetensors",
420
+ "visual.blocks.14.attn.qkv.weight": "model-00001-of-00004.safetensors",
421
+ "visual.blocks.14.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
422
+ "visual.blocks.14.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
423
+ "visual.blocks.14.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
424
+ "visual.blocks.14.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
425
+ "visual.blocks.14.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
426
+ "visual.blocks.14.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
427
+ "visual.blocks.14.norm1.weight": "model-00001-of-00004.safetensors",
428
+ "visual.blocks.14.norm2.weight": "model-00001-of-00004.safetensors",
429
+ "visual.blocks.15.attn.proj.bias": "model-00001-of-00004.safetensors",
430
+ "visual.blocks.15.attn.proj.weight": "model-00001-of-00004.safetensors",
431
+ "visual.blocks.15.attn.qkv.bias": "model-00001-of-00004.safetensors",
432
+ "visual.blocks.15.attn.qkv.weight": "model-00001-of-00004.safetensors",
433
+ "visual.blocks.15.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
434
+ "visual.blocks.15.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
435
+ "visual.blocks.15.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
436
+ "visual.blocks.15.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
437
+ "visual.blocks.15.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
438
+ "visual.blocks.15.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
439
+ "visual.blocks.15.norm1.weight": "model-00001-of-00004.safetensors",
440
+ "visual.blocks.15.norm2.weight": "model-00001-of-00004.safetensors",
441
+ "visual.blocks.16.attn.proj.bias": "model-00001-of-00004.safetensors",
442
+ "visual.blocks.16.attn.proj.weight": "model-00001-of-00004.safetensors",
443
+ "visual.blocks.16.attn.qkv.bias": "model-00001-of-00004.safetensors",
444
+ "visual.blocks.16.attn.qkv.weight": "model-00001-of-00004.safetensors",
445
+ "visual.blocks.16.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
446
+ "visual.blocks.16.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
447
+ "visual.blocks.16.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
448
+ "visual.blocks.16.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
449
+ "visual.blocks.16.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
450
+ "visual.blocks.16.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
451
+ "visual.blocks.16.norm1.weight": "model-00001-of-00004.safetensors",
452
+ "visual.blocks.16.norm2.weight": "model-00001-of-00004.safetensors",
453
+ "visual.blocks.17.attn.proj.bias": "model-00001-of-00004.safetensors",
454
+ "visual.blocks.17.attn.proj.weight": "model-00001-of-00004.safetensors",
455
+ "visual.blocks.17.attn.qkv.bias": "model-00001-of-00004.safetensors",
456
+ "visual.blocks.17.attn.qkv.weight": "model-00001-of-00004.safetensors",
457
+ "visual.blocks.17.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
458
+ "visual.blocks.17.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
459
+ "visual.blocks.17.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
460
+ "visual.blocks.17.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
461
+ "visual.blocks.17.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
462
+ "visual.blocks.17.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
463
+ "visual.blocks.17.norm1.weight": "model-00001-of-00004.safetensors",
464
+ "visual.blocks.17.norm2.weight": "model-00001-of-00004.safetensors",
465
+ "visual.blocks.18.attn.proj.bias": "model-00001-of-00004.safetensors",
466
+ "visual.blocks.18.attn.proj.weight": "model-00001-of-00004.safetensors",
467
+ "visual.blocks.18.attn.qkv.bias": "model-00001-of-00004.safetensors",
468
+ "visual.blocks.18.attn.qkv.weight": "model-00001-of-00004.safetensors",
469
+ "visual.blocks.18.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
470
+ "visual.blocks.18.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
471
+ "visual.blocks.18.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
472
+ "visual.blocks.18.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
473
+ "visual.blocks.18.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
474
+ "visual.blocks.18.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
475
+ "visual.blocks.18.norm1.weight": "model-00001-of-00004.safetensors",
476
+ "visual.blocks.18.norm2.weight": "model-00001-of-00004.safetensors",
477
+ "visual.blocks.19.attn.proj.bias": "model-00001-of-00004.safetensors",
478
+ "visual.blocks.19.attn.proj.weight": "model-00001-of-00004.safetensors",
479
+ "visual.blocks.19.attn.qkv.bias": "model-00001-of-00004.safetensors",
480
+ "visual.blocks.19.attn.qkv.weight": "model-00001-of-00004.safetensors",
481
+ "visual.blocks.19.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
482
+ "visual.blocks.19.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
483
+ "visual.blocks.19.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
484
+ "visual.blocks.19.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
485
+ "visual.blocks.19.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
486
+ "visual.blocks.19.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
487
+ "visual.blocks.19.norm1.weight": "model-00001-of-00004.safetensors",
488
+ "visual.blocks.19.norm2.weight": "model-00001-of-00004.safetensors",
489
+ "visual.blocks.2.attn.proj.bias": "model-00001-of-00004.safetensors",
490
+ "visual.blocks.2.attn.proj.weight": "model-00001-of-00004.safetensors",
491
+ "visual.blocks.2.attn.qkv.bias": "model-00001-of-00004.safetensors",
492
+ "visual.blocks.2.attn.qkv.weight": "model-00001-of-00004.safetensors",
493
+ "visual.blocks.2.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
494
+ "visual.blocks.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
495
+ "visual.blocks.2.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
496
+ "visual.blocks.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
497
+ "visual.blocks.2.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
498
+ "visual.blocks.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
499
+ "visual.blocks.2.norm1.weight": "model-00001-of-00004.safetensors",
500
+ "visual.blocks.2.norm2.weight": "model-00001-of-00004.safetensors",
501
+ "visual.blocks.20.attn.proj.bias": "model-00001-of-00004.safetensors",
502
+ "visual.blocks.20.attn.proj.weight": "model-00001-of-00004.safetensors",
503
+ "visual.blocks.20.attn.qkv.bias": "model-00001-of-00004.safetensors",
504
+ "visual.blocks.20.attn.qkv.weight": "model-00001-of-00004.safetensors",
505
+ "visual.blocks.20.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
506
+ "visual.blocks.20.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
507
+ "visual.blocks.20.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
508
+ "visual.blocks.20.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
509
+ "visual.blocks.20.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
510
+ "visual.blocks.20.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
511
+ "visual.blocks.20.norm1.weight": "model-00001-of-00004.safetensors",
512
+ "visual.blocks.20.norm2.weight": "model-00001-of-00004.safetensors",
513
+ "visual.blocks.21.attn.proj.bias": "model-00001-of-00004.safetensors",
514
+ "visual.blocks.21.attn.proj.weight": "model-00001-of-00004.safetensors",
515
+ "visual.blocks.21.attn.qkv.bias": "model-00001-of-00004.safetensors",
516
+ "visual.blocks.21.attn.qkv.weight": "model-00001-of-00004.safetensors",
517
+ "visual.blocks.21.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
518
+ "visual.blocks.21.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
519
+ "visual.blocks.21.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
520
+ "visual.blocks.21.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
521
+ "visual.blocks.21.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
522
+ "visual.blocks.21.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
523
+ "visual.blocks.21.norm1.weight": "model-00001-of-00004.safetensors",
524
+ "visual.blocks.21.norm2.weight": "model-00001-of-00004.safetensors",
525
+ "visual.blocks.22.attn.proj.bias": "model-00001-of-00004.safetensors",
526
+ "visual.blocks.22.attn.proj.weight": "model-00001-of-00004.safetensors",
527
+ "visual.blocks.22.attn.qkv.bias": "model-00001-of-00004.safetensors",
528
+ "visual.blocks.22.attn.qkv.weight": "model-00001-of-00004.safetensors",
529
+ "visual.blocks.22.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
530
+ "visual.blocks.22.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
531
+ "visual.blocks.22.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
532
+ "visual.blocks.22.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
533
+ "visual.blocks.22.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
534
+ "visual.blocks.22.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
535
+ "visual.blocks.22.norm1.weight": "model-00001-of-00004.safetensors",
536
+ "visual.blocks.22.norm2.weight": "model-00001-of-00004.safetensors",
537
+ "visual.blocks.23.attn.proj.bias": "model-00001-of-00004.safetensors",
538
+ "visual.blocks.23.attn.proj.weight": "model-00001-of-00004.safetensors",
539
+ "visual.blocks.23.attn.qkv.bias": "model-00001-of-00004.safetensors",
540
+ "visual.blocks.23.attn.qkv.weight": "model-00001-of-00004.safetensors",
541
+ "visual.blocks.23.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
542
+ "visual.blocks.23.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
543
+ "visual.blocks.23.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
544
+ "visual.blocks.23.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
545
+ "visual.blocks.23.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
546
+ "visual.blocks.23.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
547
+ "visual.blocks.23.norm1.weight": "model-00001-of-00004.safetensors",
548
+ "visual.blocks.23.norm2.weight": "model-00001-of-00004.safetensors",
549
+ "visual.blocks.24.attn.proj.bias": "model-00001-of-00004.safetensors",
550
+ "visual.blocks.24.attn.proj.weight": "model-00001-of-00004.safetensors",
551
+ "visual.blocks.24.attn.qkv.bias": "model-00001-of-00004.safetensors",
552
+ "visual.blocks.24.attn.qkv.weight": "model-00001-of-00004.safetensors",
553
+ "visual.blocks.24.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
554
+ "visual.blocks.24.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
555
+ "visual.blocks.24.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
556
+ "visual.blocks.24.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
557
+ "visual.blocks.24.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
558
+ "visual.blocks.24.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
559
+ "visual.blocks.24.norm1.weight": "model-00001-of-00004.safetensors",
560
+ "visual.blocks.24.norm2.weight": "model-00001-of-00004.safetensors",
561
+ "visual.blocks.25.attn.proj.bias": "model-00001-of-00004.safetensors",
562
+ "visual.blocks.25.attn.proj.weight": "model-00001-of-00004.safetensors",
563
+ "visual.blocks.25.attn.qkv.bias": "model-00001-of-00004.safetensors",
564
+ "visual.blocks.25.attn.qkv.weight": "model-00001-of-00004.safetensors",
565
+ "visual.blocks.25.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
566
+ "visual.blocks.25.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
567
+ "visual.blocks.25.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
568
+ "visual.blocks.25.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
569
+ "visual.blocks.25.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
570
+ "visual.blocks.25.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
571
+ "visual.blocks.25.norm1.weight": "model-00001-of-00004.safetensors",
572
+ "visual.blocks.25.norm2.weight": "model-00001-of-00004.safetensors",
573
+ "visual.blocks.26.attn.proj.bias": "model-00001-of-00004.safetensors",
574
+ "visual.blocks.26.attn.proj.weight": "model-00001-of-00004.safetensors",
575
+ "visual.blocks.26.attn.qkv.bias": "model-00001-of-00004.safetensors",
576
+ "visual.blocks.26.attn.qkv.weight": "model-00001-of-00004.safetensors",
577
+ "visual.blocks.26.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
578
+ "visual.blocks.26.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
579
+ "visual.blocks.26.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
580
+ "visual.blocks.26.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
581
+ "visual.blocks.26.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
582
+ "visual.blocks.26.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
583
+ "visual.blocks.26.norm1.weight": "model-00001-of-00004.safetensors",
584
+ "visual.blocks.26.norm2.weight": "model-00001-of-00004.safetensors",
585
+ "visual.blocks.27.attn.proj.bias": "model-00001-of-00004.safetensors",
586
+ "visual.blocks.27.attn.proj.weight": "model-00001-of-00004.safetensors",
587
+ "visual.blocks.27.attn.qkv.bias": "model-00001-of-00004.safetensors",
588
+ "visual.blocks.27.attn.qkv.weight": "model-00001-of-00004.safetensors",
589
+ "visual.blocks.27.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
590
+ "visual.blocks.27.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
591
+ "visual.blocks.27.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
592
+ "visual.blocks.27.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
593
+ "visual.blocks.27.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
594
+ "visual.blocks.27.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
595
+ "visual.blocks.27.norm1.weight": "model-00001-of-00004.safetensors",
596
+ "visual.blocks.27.norm2.weight": "model-00001-of-00004.safetensors",
597
+ "visual.blocks.28.attn.proj.bias": "model-00001-of-00004.safetensors",
598
+ "visual.blocks.28.attn.proj.weight": "model-00001-of-00004.safetensors",
599
+ "visual.blocks.28.attn.qkv.bias": "model-00001-of-00004.safetensors",
600
+ "visual.blocks.28.attn.qkv.weight": "model-00001-of-00004.safetensors",
601
+ "visual.blocks.28.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
602
+ "visual.blocks.28.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
603
+ "visual.blocks.28.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
604
+ "visual.blocks.28.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
605
+ "visual.blocks.28.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
606
+ "visual.blocks.28.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
607
+ "visual.blocks.28.norm1.weight": "model-00001-of-00004.safetensors",
608
+ "visual.blocks.28.norm2.weight": "model-00001-of-00004.safetensors",
609
+ "visual.blocks.29.attn.proj.bias": "model-00001-of-00004.safetensors",
610
+ "visual.blocks.29.attn.proj.weight": "model-00001-of-00004.safetensors",
611
+ "visual.blocks.29.attn.qkv.bias": "model-00001-of-00004.safetensors",
612
+ "visual.blocks.29.attn.qkv.weight": "model-00001-of-00004.safetensors",
613
+ "visual.blocks.29.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
614
+ "visual.blocks.29.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
615
+ "visual.blocks.29.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
616
+ "visual.blocks.29.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
617
+ "visual.blocks.29.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
618
+ "visual.blocks.29.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
619
+ "visual.blocks.29.norm1.weight": "model-00001-of-00004.safetensors",
620
+ "visual.blocks.29.norm2.weight": "model-00001-of-00004.safetensors",
621
+ "visual.blocks.3.attn.proj.bias": "model-00001-of-00004.safetensors",
622
+ "visual.blocks.3.attn.proj.weight": "model-00001-of-00004.safetensors",
623
+ "visual.blocks.3.attn.qkv.bias": "model-00001-of-00004.safetensors",
624
+ "visual.blocks.3.attn.qkv.weight": "model-00001-of-00004.safetensors",
625
+ "visual.blocks.3.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
626
+ "visual.blocks.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
627
+ "visual.blocks.3.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
628
+ "visual.blocks.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
629
+ "visual.blocks.3.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
630
+ "visual.blocks.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
631
+ "visual.blocks.3.norm1.weight": "model-00001-of-00004.safetensors",
632
+ "visual.blocks.3.norm2.weight": "model-00001-of-00004.safetensors",
633
+ "visual.blocks.30.attn.proj.bias": "model-00001-of-00004.safetensors",
634
+ "visual.blocks.30.attn.proj.weight": "model-00001-of-00004.safetensors",
635
+ "visual.blocks.30.attn.qkv.bias": "model-00001-of-00004.safetensors",
636
+ "visual.blocks.30.attn.qkv.weight": "model-00001-of-00004.safetensors",
637
+ "visual.blocks.30.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
638
+ "visual.blocks.30.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
639
+ "visual.blocks.30.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
640
+ "visual.blocks.30.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
641
+ "visual.blocks.30.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
642
+ "visual.blocks.30.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
643
+ "visual.blocks.30.norm1.weight": "model-00001-of-00004.safetensors",
644
+ "visual.blocks.30.norm2.weight": "model-00001-of-00004.safetensors",
645
+ "visual.blocks.31.attn.proj.bias": "model-00001-of-00004.safetensors",
646
+ "visual.blocks.31.attn.proj.weight": "model-00001-of-00004.safetensors",
647
+ "visual.blocks.31.attn.qkv.bias": "model-00001-of-00004.safetensors",
648
+ "visual.blocks.31.attn.qkv.weight": "model-00001-of-00004.safetensors",
649
+ "visual.blocks.31.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
650
+ "visual.blocks.31.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
651
+ "visual.blocks.31.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
652
+ "visual.blocks.31.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
653
+ "visual.blocks.31.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
654
+ "visual.blocks.31.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
655
+ "visual.blocks.31.norm1.weight": "model-00001-of-00004.safetensors",
656
+ "visual.blocks.31.norm2.weight": "model-00001-of-00004.safetensors",
657
+ "visual.blocks.4.attn.proj.bias": "model-00001-of-00004.safetensors",
658
+ "visual.blocks.4.attn.proj.weight": "model-00001-of-00004.safetensors",
659
+ "visual.blocks.4.attn.qkv.bias": "model-00001-of-00004.safetensors",
660
+ "visual.blocks.4.attn.qkv.weight": "model-00001-of-00004.safetensors",
661
+ "visual.blocks.4.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
662
+ "visual.blocks.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
663
+ "visual.blocks.4.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
664
+ "visual.blocks.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
665
+ "visual.blocks.4.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
666
+ "visual.blocks.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
667
+ "visual.blocks.4.norm1.weight": "model-00001-of-00004.safetensors",
668
+ "visual.blocks.4.norm2.weight": "model-00001-of-00004.safetensors",
669
+ "visual.blocks.5.attn.proj.bias": "model-00001-of-00004.safetensors",
670
+ "visual.blocks.5.attn.proj.weight": "model-00001-of-00004.safetensors",
671
+ "visual.blocks.5.attn.qkv.bias": "model-00001-of-00004.safetensors",
672
+ "visual.blocks.5.attn.qkv.weight": "model-00001-of-00004.safetensors",
673
+ "visual.blocks.5.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
674
+ "visual.blocks.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
675
+ "visual.blocks.5.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
676
+ "visual.blocks.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
677
+ "visual.blocks.5.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
678
+ "visual.blocks.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
679
+ "visual.blocks.5.norm1.weight": "model-00001-of-00004.safetensors",
680
+ "visual.blocks.5.norm2.weight": "model-00001-of-00004.safetensors",
681
+ "visual.blocks.6.attn.proj.bias": "model-00001-of-00004.safetensors",
682
+ "visual.blocks.6.attn.proj.weight": "model-00001-of-00004.safetensors",
683
+ "visual.blocks.6.attn.qkv.bias": "model-00001-of-00004.safetensors",
684
+ "visual.blocks.6.attn.qkv.weight": "model-00001-of-00004.safetensors",
685
+ "visual.blocks.6.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
686
+ "visual.blocks.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
687
+ "visual.blocks.6.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
688
+ "visual.blocks.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
689
+ "visual.blocks.6.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
690
+ "visual.blocks.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
691
+ "visual.blocks.6.norm1.weight": "model-00001-of-00004.safetensors",
692
+ "visual.blocks.6.norm2.weight": "model-00001-of-00004.safetensors",
693
+ "visual.blocks.7.attn.proj.bias": "model-00001-of-00004.safetensors",
694
+ "visual.blocks.7.attn.proj.weight": "model-00001-of-00004.safetensors",
695
+ "visual.blocks.7.attn.qkv.bias": "model-00001-of-00004.safetensors",
696
+ "visual.blocks.7.attn.qkv.weight": "model-00001-of-00004.safetensors",
697
+ "visual.blocks.7.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
698
+ "visual.blocks.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
699
+ "visual.blocks.7.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
700
+ "visual.blocks.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
701
+ "visual.blocks.7.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
702
+ "visual.blocks.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
703
+ "visual.blocks.7.norm1.weight": "model-00001-of-00004.safetensors",
704
+ "visual.blocks.7.norm2.weight": "model-00001-of-00004.safetensors",
705
+ "visual.blocks.8.attn.proj.bias": "model-00001-of-00004.safetensors",
706
+ "visual.blocks.8.attn.proj.weight": "model-00001-of-00004.safetensors",
707
+ "visual.blocks.8.attn.qkv.bias": "model-00001-of-00004.safetensors",
708
+ "visual.blocks.8.attn.qkv.weight": "model-00001-of-00004.safetensors",
709
+ "visual.blocks.8.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
710
+ "visual.blocks.8.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
711
+ "visual.blocks.8.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
712
+ "visual.blocks.8.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
713
+ "visual.blocks.8.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
714
+ "visual.blocks.8.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
715
+ "visual.blocks.8.norm1.weight": "model-00001-of-00004.safetensors",
716
+ "visual.blocks.8.norm2.weight": "model-00001-of-00004.safetensors",
717
+ "visual.blocks.9.attn.proj.bias": "model-00001-of-00004.safetensors",
718
+ "visual.blocks.9.attn.proj.weight": "model-00001-of-00004.safetensors",
719
+ "visual.blocks.9.attn.qkv.bias": "model-00001-of-00004.safetensors",
720
+ "visual.blocks.9.attn.qkv.weight": "model-00001-of-00004.safetensors",
721
+ "visual.blocks.9.mlp.down_proj.bias": "model-00001-of-00004.safetensors",
722
+ "visual.blocks.9.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
723
+ "visual.blocks.9.mlp.gate_proj.bias": "model-00001-of-00004.safetensors",
724
+ "visual.blocks.9.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
725
+ "visual.blocks.9.mlp.up_proj.bias": "model-00001-of-00004.safetensors",
726
+ "visual.blocks.9.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
727
+ "visual.blocks.9.norm1.weight": "model-00001-of-00004.safetensors",
728
+ "visual.blocks.9.norm2.weight": "model-00001-of-00004.safetensors",
729
+ "visual.merger.ln_q.weight": "model-00001-of-00004.safetensors",
730
+ "visual.merger.mlp.0.bias": "model-00001-of-00004.safetensors",
731
+ "visual.merger.mlp.0.weight": "model-00001-of-00004.safetensors",
732
+ "visual.merger.mlp.2.bias": "model-00001-of-00004.safetensors",
733
+ "visual.merger.mlp.2.weight": "model-00001-of-00004.safetensors",
734
+ "visual.patch_embed.proj.weight": "model-00001-of-00004.safetensors"
735
+ }
736
+ }
checkpoints/sft-model/preprocessor_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": true,
3
+ "do_normalize": true,
4
+ "do_rescale": true,
5
+ "do_resize": true,
6
+ "image_mean": [
7
+ 0.48145466,
8
+ 0.4578275,
9
+ 0.40821073
10
+ ],
11
+ "image_processor_type": "Qwen2_5_VLImageProcessor",
12
+ "image_std": [
13
+ 0.26862954,
14
+ 0.26130258,
15
+ 0.27577711
16
+ ],
17
+ "max_pixels": 12845056,
18
+ "merge_size": 2,
19
+ "min_pixels": 3136,
20
+ "patch_size": 14,
21
+ "processor_class": "Qwen2_5_VLProcessor",
22
+ "resample": 3,
23
+ "rescale_factor": 0.00392156862745098,
24
+ "size": {
25
+ "longest_edge": 12845056,
26
+ "shortest_edge": 3136
27
+ },
28
+ "temporal_patch_size": 2
29
+ }
checkpoints/sft-model/special_tokens_map.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>",
5
+ "<|object_ref_start|>",
6
+ "<|object_ref_end|>",
7
+ "<|box_start|>",
8
+ "<|box_end|>",
9
+ "<|quad_start|>",
10
+ "<|quad_end|>",
11
+ "<|vision_start|>",
12
+ "<|vision_end|>",
13
+ "<|vision_pad|>",
14
+ "<|image_pad|>",
15
+ "<|video_pad|>"
16
+ ],
17
+ "eos_token": {
18
+ "content": "<|im_end|>",
19
+ "lstrip": false,
20
+ "normalized": false,
21
+ "rstrip": false,
22
+ "single_word": false
23
+ },
24
+ "pad_token": {
25
+ "content": "<|endoftext|>",
26
+ "lstrip": false,
27
+ "normalized": false,
28
+ "rstrip": false,
29
+ "single_word": false
30
+ }
31
+ }
checkpoints/sft-model/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba0c439f7be467bf47d12a7e6f9adc6116201056fc60c67f431c679b7c16afc8
3
+ size 11422064
checkpoints/sft-model/tokenizer_config.json ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "added_tokens_decoder": {
5
+ "151643": {
6
+ "content": "<|endoftext|>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false,
11
+ "special": true
12
+ },
13
+ "151644": {
14
+ "content": "<|im_start|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false,
19
+ "special": true
20
+ },
21
+ "151645": {
22
+ "content": "<|im_end|>",
23
+ "lstrip": false,
24
+ "normalized": false,
25
+ "rstrip": false,
26
+ "single_word": false,
27
+ "special": true
28
+ },
29
+ "151646": {
30
+ "content": "<|object_ref_start|>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false,
35
+ "special": true
36
+ },
37
+ "151647": {
38
+ "content": "<|object_ref_end|>",
39
+ "lstrip": false,
40
+ "normalized": false,
41
+ "rstrip": false,
42
+ "single_word": false,
43
+ "special": true
44
+ },
45
+ "151648": {
46
+ "content": "<|box_start|>",
47
+ "lstrip": false,
48
+ "normalized": false,
49
+ "rstrip": false,
50
+ "single_word": false,
51
+ "special": true
52
+ },
53
+ "151649": {
54
+ "content": "<|box_end|>",
55
+ "lstrip": false,
56
+ "normalized": false,
57
+ "rstrip": false,
58
+ "single_word": false,
59
+ "special": true
60
+ },
61
+ "151650": {
62
+ "content": "<|quad_start|>",
63
+ "lstrip": false,
64
+ "normalized": false,
65
+ "rstrip": false,
66
+ "single_word": false,
67
+ "special": true
68
+ },
69
+ "151651": {
70
+ "content": "<|quad_end|>",
71
+ "lstrip": false,
72
+ "normalized": false,
73
+ "rstrip": false,
74
+ "single_word": false,
75
+ "special": true
76
+ },
77
+ "151652": {
78
+ "content": "<|vision_start|>",
79
+ "lstrip": false,
80
+ "normalized": false,
81
+ "rstrip": false,
82
+ "single_word": false,
83
+ "special": true
84
+ },
85
+ "151653": {
86
+ "content": "<|vision_end|>",
87
+ "lstrip": false,
88
+ "normalized": false,
89
+ "rstrip": false,
90
+ "single_word": false,
91
+ "special": true
92
+ },
93
+ "151654": {
94
+ "content": "<|vision_pad|>",
95
+ "lstrip": false,
96
+ "normalized": false,
97
+ "rstrip": false,
98
+ "single_word": false,
99
+ "special": true
100
+ },
101
+ "151655": {
102
+ "content": "<|image_pad|>",
103
+ "lstrip": false,
104
+ "normalized": false,
105
+ "rstrip": false,
106
+ "single_word": false,
107
+ "special": true
108
+ },
109
+ "151656": {
110
+ "content": "<|video_pad|>",
111
+ "lstrip": false,
112
+ "normalized": false,
113
+ "rstrip": false,
114
+ "single_word": false,
115
+ "special": true
116
+ },
117
+ "151657": {
118
+ "content": "<tool_call>",
119
+ "lstrip": false,
120
+ "normalized": false,
121
+ "rstrip": false,
122
+ "single_word": false,
123
+ "special": false
124
+ },
125
+ "151658": {
126
+ "content": "</tool_call>",
127
+ "lstrip": false,
128
+ "normalized": false,
129
+ "rstrip": false,
130
+ "single_word": false,
131
+ "special": false
132
+ },
133
+ "151659": {
134
+ "content": "<|fim_prefix|>",
135
+ "lstrip": false,
136
+ "normalized": false,
137
+ "rstrip": false,
138
+ "single_word": false,
139
+ "special": false
140
+ },
141
+ "151660": {
142
+ "content": "<|fim_middle|>",
143
+ "lstrip": false,
144
+ "normalized": false,
145
+ "rstrip": false,
146
+ "single_word": false,
147
+ "special": false
148
+ },
149
+ "151661": {
150
+ "content": "<|fim_suffix|>",
151
+ "lstrip": false,
152
+ "normalized": false,
153
+ "rstrip": false,
154
+ "single_word": false,
155
+ "special": false
156
+ },
157
+ "151662": {
158
+ "content": "<|fim_pad|>",
159
+ "lstrip": false,
160
+ "normalized": false,
161
+ "rstrip": false,
162
+ "single_word": false,
163
+ "special": false
164
+ },
165
+ "151663": {
166
+ "content": "<|repo_name|>",
167
+ "lstrip": false,
168
+ "normalized": false,
169
+ "rstrip": false,
170
+ "single_word": false,
171
+ "special": false
172
+ },
173
+ "151664": {
174
+ "content": "<|file_sep|>",
175
+ "lstrip": false,
176
+ "normalized": false,
177
+ "rstrip": false,
178
+ "single_word": false,
179
+ "special": false
180
+ }
181
+ },
182
+ "additional_special_tokens": [
183
+ "<|im_start|>",
184
+ "<|im_end|>",
185
+ "<|object_ref_start|>",
186
+ "<|object_ref_end|>",
187
+ "<|box_start|>",
188
+ "<|box_end|>",
189
+ "<|quad_start|>",
190
+ "<|quad_end|>",
191
+ "<|vision_start|>",
192
+ "<|vision_end|>",
193
+ "<|vision_pad|>",
194
+ "<|image_pad|>",
195
+ "<|video_pad|>"
196
+ ],
197
+ "bos_token": null,
198
+ "chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}Picture {{ image_count.value }}: {% endif %}<|vision_start|><|image_pad|><|vision_end|>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}Video {{ video_count.value }}: {% endif %}<|vision_start|><|video_pad|><|vision_end|>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}",
199
+ "clean_up_tokenization_spaces": false,
200
+ "eos_token": "<|im_end|>",
201
+ "errors": "replace",
202
+ "extra_special_tokens": {},
203
+ "model_max_length": 131072,
204
+ "pad_token": "<|endoftext|>",
205
+ "processor_class": "Qwen2_5_VLProcessor",
206
+ "split_special_tokens": false,
207
+ "tokenizer_class": "Qwen2Tokenizer",
208
+ "unk_token": null
209
+ }
checkpoints/sft-model/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1028ce87a560fb384c42d9a60b025a8fefe81db78fb79f38c90fbe7dc204b838
3
+ size 7864
checkpoints/sft-model/training_log.txt ADDED
The diff for this file is too large to render. See raw diff
 
checkpoints/sft-model/vocab.json ADDED
The diff for this file is too large to render. See raw diff
 
cot_generate/add_timestamp_to_video.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 给视频的每一帧左上角打上该帧对应的时间戳。
3
+ 时间戳格式: HH:MM:SS
4
+
5
+ 用法:
6
+ python add_timestamp_to_video.py --input video.mp4 --output video_with_timestamp.mp4
7
+ python add_timestamp_to_video.py --input video.mp4 # 默认输出到同目录下 xxx_timestamped.mp4
8
+ python add_timestamp_to_video.py --input_dir /path/to/videos --output_dir /path/to/output # 批量处理
9
+ """
10
+
11
+ import argparse
12
+ import os
13
+ import subprocess
14
+ import tempfile
15
+ import cv2
16
+ import glob
17
+ from pathlib import Path
18
+
19
+
20
+ def format_timestamp(seconds: float) -> str:
21
+ """将秒数格式化为 HH:MM:SS"""
22
+ h = int(seconds // 3600)
23
+ m = int((seconds % 3600) // 60)
24
+ s = int(seconds % 60)
25
+ return f"{h:02d}:{m:02d}:{s:02d}"
26
+
27
+
28
+ def add_timestamp_to_video(input_path: str, output_path: str, font_scale: float = 1.0, thickness: int = 2):
29
+ """
30
+ 给视频每一帧的左上角添加时间戳。
31
+
32
+ Args:
33
+ input_path: 输入视频路径
34
+ output_path: 输出视频路径
35
+ font_scale: 字体大小缩放系数
36
+ thickness: 字体粗细
37
+ """
38
+ cap = cv2.VideoCapture(input_path)
39
+ if not cap.isOpened():
40
+ print(f"[ERROR] 无法打开视频: {input_path}")
41
+ return False
42
+
43
+ fps = cap.get(cv2.CAP_PROP_FPS)
44
+ width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
45
+ height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
46
+ total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
47
+
48
+ # 根据视频分辨率自适应字体大小
49
+ auto_font_scale = font_scale * min(width, height) / 480.0
50
+ auto_thickness = max(1, int(thickness * min(width, height) / 480.0))
51
+
52
+ os.makedirs(os.path.dirname(output_path) if os.path.dirname(output_path) else ".", exist_ok=True)
53
+
54
+ fourcc = cv2.VideoWriter_fourcc(*"mp4v")
55
+ writer = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
56
+
57
+ frame_idx = 0
58
+ while True:
59
+ ret, frame = cap.read()
60
+ if not ret:
61
+ break
62
+
63
+ current_time = frame_idx / fps
64
+ timestamp_text = format_timestamp(current_time)
65
+
66
+ # 计算文字尺寸
67
+ font = cv2.FONT_HERSHEY_SIMPLEX
68
+ (text_w, text_h), baseline = cv2.getTextSize(timestamp_text, font, auto_font_scale, auto_thickness)
69
+
70
+ # 左上角位置,留一些边距
71
+ margin = int(10 * min(width, height) / 480.0)
72
+ x, y = margin, margin + text_h
73
+
74
+ # 画半透明黑色背景框,提高可读性
75
+ pad = int(6 * min(width, height) / 480.0)
76
+ overlay = frame.copy()
77
+ cv2.rectangle(overlay,
78
+ (x - pad, y - text_h - pad),
79
+ (x + text_w + pad, y + baseline + pad),
80
+ (0, 0, 0), -1)
81
+ cv2.addWeighted(overlay, 0.6, frame, 0.4, 0, frame)
82
+
83
+ # 画白色时间戳文字
84
+ cv2.putText(frame, timestamp_text, (x, y),
85
+ font, auto_font_scale, (255, 255, 255), auto_thickness, cv2.LINE_AA)
86
+
87
+ writer.write(frame)
88
+ frame_idx += 1
89
+
90
+ if frame_idx % 100 == 0:
91
+ print(f" 处理进度: {frame_idx}/{total_frames} ({frame_idx * 100 // total_frames}%)")
92
+
93
+ cap.release()
94
+ writer.release()
95
+
96
+ # 用 ffmpeg 重新编码为 H.264,大幅减小文件体积
97
+ tmp_path = output_path + ".tmp.mp4"
98
+ os.rename(output_path, tmp_path)
99
+ try:
100
+ cmd = [
101
+ "ffmpeg", "-y", "-i", tmp_path,
102
+ "-c:v", "libx264", "-preset", "medium", "-crf", "23",
103
+ "-pix_fmt", "yuv420p", "-an",
104
+ output_path
105
+ ]
106
+ subprocess.run(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, check=True)
107
+ os.remove(tmp_path)
108
+ except (subprocess.CalledProcessError, FileNotFoundError) as e:
109
+ print(f"[WARN] ffmpeg 压缩失败({e}),使用未压缩版本")
110
+ if os.path.exists(tmp_path):
111
+ os.rename(tmp_path, output_path)
112
+
113
+ print(f"[DONE] {input_path} -> {output_path} (共 {frame_idx} 帧)")
114
+ return True
115
+
116
+
117
+ def main():
118
+ parser = argparse.ArgumentParser(description="给视频左上角打上帧时间戳")
119
+ parser.add_argument("--input", type=str, default=None, help="输入视频路径")
120
+ parser.add_argument("--output", type=str, default=None, help="输出视频路径 (默认在原文件名后加 _timestamped)")
121
+ parser.add_argument("--input_dir", type=str, default=None, help="批量处理: 输入视频文件夹")
122
+ parser.add_argument("--output_dir", type=str, default=None, help="批量处理: 输出视频文件夹")
123
+ parser.add_argument("--font_scale", type=float, default=1.0, help="字体大小缩放 (默认 1.0)")
124
+ parser.add_argument("--thickness", type=int, default=2, help="字体粗细 (默认 2)")
125
+ parser.add_argument("--ext", type=str, default="mp4", help="批量模式下匹配的视频扩展名 (默认 mp4)")
126
+ args = parser.parse_args()
127
+
128
+ if args.input:
129
+ # 单个视频处理
130
+ if args.output is None:
131
+ stem = Path(args.input).stem
132
+ suffix = Path(args.input).suffix
133
+ args.output = str(Path(args.input).parent / f"{stem}_timestamped{suffix}")
134
+ add_timestamp_to_video(args.input, args.output, args.font_scale, args.thickness)
135
+
136
+ elif args.input_dir:
137
+ # 批量处理
138
+ if args.output_dir is None:
139
+ args.output_dir = args.input_dir + "_timestamped"
140
+ os.makedirs(args.output_dir, exist_ok=True)
141
+
142
+ video_files = sorted(glob.glob(os.path.join(args.input_dir, f"*.{args.ext}")))
143
+ if not video_files:
144
+ print(f"[WARN] 在 {args.input_dir} 中未找到 *.{args.ext} 文件")
145
+ return
146
+
147
+ print(f"共找到 {len(video_files)} 个视频文件")
148
+ for i, vpath in enumerate(video_files, 1):
149
+ out_path = os.path.join(args.output_dir, os.path.basename(vpath))
150
+ print(f"\n[{i}/{len(video_files)}] 处理: {vpath}")
151
+ add_timestamp_to_video(vpath, out_path, args.font_scale, args.thickness)
152
+ else:
153
+ parser.print_help()
154
+
155
+
156
+ if __name__ == "__main__":
157
+ main()
cot_generate/batch_add_timestamp.py ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 批量给视频加时间戳水印 — 从 Video-R1 JSON 提取唯一视频路径,
3
+ 保持原始目录结构输出到新目录, 支持多进程并行和断点续跑。
4
+
5
+ 用法:
6
+ python batch_add_timestamp.py \
7
+ --input_json /path/to/Video-R1-260k.json \
8
+ --video_root /path/to/video_root \
9
+ --output_root /path/to/output_root \
10
+ --workers 8
11
+ """
12
+
13
+ import argparse
14
+ import json
15
+ import os
16
+ from pathlib import Path
17
+ from multiprocessing import Pool
18
+ from functools import partial
19
+
20
+ from add_timestamp_to_video import add_timestamp_to_video
21
+
22
+
23
+ def extract_unique_videos(json_path: str) -> list:
24
+ """从 Video-R1 JSON 中提取所有唯一的视频相对路径"""
25
+ with open(json_path, encoding="utf-8") as f:
26
+ data = json.load(f)
27
+ videos = set()
28
+ for item in data:
29
+ rel = item.get("path", "").lstrip("./")
30
+ if rel:
31
+ videos.add(rel)
32
+ return sorted(videos)
33
+
34
+
35
+ def process_one(rel_path: str, video_root: str, output_root: str) -> dict:
36
+ """处理单个视频: 加时间戳水印"""
37
+ src = os.path.join(video_root, rel_path)
38
+ dst = os.path.join(output_root, rel_path)
39
+
40
+ if not os.path.exists(src):
41
+ return {"path": rel_path, "status": "missing", "msg": f"Source not found: {src}"}
42
+
43
+ if os.path.exists(dst):
44
+ return {"path": rel_path, "status": "skipped", "msg": "Already exists"}
45
+
46
+ try:
47
+ ok = add_timestamp_to_video(src, dst)
48
+ if ok:
49
+ return {"path": rel_path, "status": "done"}
50
+ else:
51
+ return {"path": rel_path, "status": "error", "msg": "add_timestamp returned False"}
52
+ except Exception as e:
53
+ return {"path": rel_path, "status": "error", "msg": str(e)}
54
+
55
+
56
+ def main():
57
+ parser = argparse.ArgumentParser(description="批量加时间戳水印 (保持目录结构)")
58
+ parser.add_argument("--input_json", required=True,
59
+ help="Video-R1 格式的 JSON 文件路径")
60
+ parser.add_argument("--video_root", required=True,
61
+ help="原始视频的根目录")
62
+ parser.add_argument("--output_root", required=True,
63
+ help="输出水印视频的根目录 (保持原始子目录结构)")
64
+ parser.add_argument("--workers", type=int, default=4,
65
+ help="并行处理进程数 (默认 4)")
66
+ args = parser.parse_args()
67
+
68
+ videos = extract_unique_videos(args.input_json)
69
+ print(f"[INFO] Found {len(videos)} unique videos in {args.input_json}")
70
+
71
+ # 统计已完成的
72
+ already_done = sum(1 for v in videos if os.path.exists(os.path.join(args.output_root, v)))
73
+ if already_done > 0:
74
+ print(f"[INFO] {already_done} already timestamped, {len(videos) - already_done} remaining")
75
+
76
+ os.makedirs(args.output_root, exist_ok=True)
77
+
78
+ worker_fn = partial(process_one,
79
+ video_root=args.video_root,
80
+ output_root=args.output_root)
81
+
82
+ done = 0
83
+ errors = 0
84
+ skipped = 0
85
+
86
+ if args.workers <= 1:
87
+ for i, v in enumerate(videos, 1):
88
+ result = worker_fn(v)
89
+ if result["status"] == "done":
90
+ done += 1
91
+ elif result["status"] == "skipped":
92
+ skipped += 1
93
+ else:
94
+ errors += 1
95
+ print(f" [ERROR] {result['path']}: {result.get('msg', '')}")
96
+ if i % 50 == 0:
97
+ print(f" Progress: {i}/{len(videos)} (done={done}, skipped={skipped}, errors={errors})")
98
+ else:
99
+ with Pool(processes=args.workers) as pool:
100
+ for i, result in enumerate(pool.imap_unordered(worker_fn, videos), 1):
101
+ if result["status"] == "done":
102
+ done += 1
103
+ elif result["status"] == "skipped":
104
+ skipped += 1
105
+ else:
106
+ errors += 1
107
+ print(f" [ERROR] {result['path']}: {result.get('msg', '')}")
108
+ if i % 50 == 0:
109
+ print(f" Progress: {i}/{len(videos)} (done={done}, skipped={skipped}, errors={errors})")
110
+
111
+ total = done + skipped
112
+ print(f"\n[DONE] Processed: {done} new, {skipped} skipped, {errors} errors")
113
+ print(f"[DONE] Total timestamped: {total}/{len(videos)}")
114
+ print(f"[DONE] Output: {args.output_root}")
115
+
116
+
117
+ if __name__ == "__main__":
118
+ main()
cot_generate/clean_and_convert.py ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 清洗 CoT 数据 + 转换为 Video-R1 SFT 格式
3
+
4
+ 输入: video_qa_final.jsonl (原始格式: video, question, answer, problem_id, response)
5
+ 输出: video_qa_sft.json (Video-R1 格式: problem_id, problem, data_type, problem_type,
6
+ options, process, solution, path, data_source)
7
+ """
8
+
9
+ import re
10
+ import json
11
+ import argparse
12
+ from pathlib import Path
13
+ from clean_cot_data import clean_response, validate_item
14
+
15
+
16
+ # 根据视频路径推断 data_source
17
+ DATA_SOURCE_MAP = {
18
+ "activitynet": "ActivityNet",
19
+ "Charades": "Charades",
20
+ "youcook2": "YouCook2",
21
+ "clevrer": "CLEVRER",
22
+ "CLEVRER": "CLEVRER",
23
+ "chiral_actions": "Chiral_Actions",
24
+ "speed_actions": "Speed_Actions",
25
+ "youtube_video_2024": "LLaVA-Video-178K/youtube_video_2024",
26
+ "NextQA": "NeXT-QA",
27
+ "NExTVideo": "NeXT-QA",
28
+ "STAR": "STAR",
29
+ "PerceptionTest": "PerceptionTest",
30
+ "ego4d": "Ego4D",
31
+ }
32
+
33
+
34
+ def infer_data_source(video_path: str) -> str:
35
+ """根据视频路径推断 data_source"""
36
+ for key, source in DATA_SOURCE_MAP.items():
37
+ if f"/{key}/" in video_path or video_path.endswith(f"/{key}"):
38
+ return source
39
+ # 数字目录 → NeXT-QA
40
+ parts = video_path.split("/")
41
+ for i, p in enumerate(parts):
42
+ if p == "NExTVideo" or p == "NextQA":
43
+ return "NeXT-QA"
44
+ # fallback: 用路径中的关键目录
45
+ if "LLaVA-Video-178K" in video_path:
46
+ return "LLaVA-Video-178K"
47
+ if "NeXT-QA" in video_path:
48
+ return "NeXT-QA"
49
+ return ""
50
+
51
+
52
+ def convert_path(video_path: str) -> str:
53
+ """将绝对路径转为相对路径 (相对于 dataset_First_Version)"""
54
+ marker = "/dataset_First_Version/"
55
+ if marker in video_path:
56
+ return "./" + video_path.split(marker, 1)[1]
57
+ return video_path
58
+
59
+
60
+ def detect_problem_type(question: str, answer: str) -> tuple[str, list]:
61
+ """检测题目类型和选项"""
62
+ # 检查 answer 是否是选择题格式 (A/B/C/D 或 A. xxx)
63
+ if re.match(r'^[A-D]\.?\s', answer) or re.match(r'^[A-D]$', answer.strip()):
64
+ return "multiple choice", []
65
+ return "free-form", []
66
+
67
+
68
+ def main():
69
+ parser = argparse.ArgumentParser(description="清洗并转换为 Video-R1 SFT 格式")
70
+ parser.add_argument("--input", required=True, help="输入 JSONL 文件")
71
+ parser.add_argument("--output", required=True, help="输出 JSON 文件")
72
+ parser.add_argument("--filter-wrong", action="store_true",
73
+ help="过滤答案与GT不一致的条目")
74
+ args = parser.parse_args()
75
+
76
+ # 读取
77
+ items = []
78
+ with open(args.input, encoding="utf-8") as f:
79
+ for line in f:
80
+ if line.strip():
81
+ items.append(json.loads(line))
82
+ print(f"读取 {len(items)} 条数据")
83
+
84
+ # 清洗 + 转换
85
+ results = []
86
+ total_fixes = 0
87
+ total_warnings = 0
88
+ n_filtered = 0
89
+
90
+ for i, item in enumerate(items):
91
+ pid = item.get("problem_id", str(i))
92
+ video = item.get("video", "")
93
+ question = item.get("question", "")
94
+ answer = item.get("answer", "")
95
+ response = item.get("response", "")
96
+
97
+ if not response:
98
+ total_warnings += 1
99
+ print(f" [{pid}] ⚠ response为空,跳过")
100
+ continue
101
+
102
+ # 1. 清洗 response
103
+ cleaned_resp, fixes = clean_response(response, answer)
104
+ if fixes:
105
+ total_fixes += len(fixes)
106
+
107
+ # 2. 验证
108
+ item["response"] = cleaned_resp
109
+ warnings = validate_item(item)
110
+ if warnings:
111
+ total_warnings += len(warnings)
112
+
113
+ # 3. 过滤答案错误
114
+ if args.filter_wrong:
115
+ ans_m = re.search(r"<answer>(.*?)</answer>", cleaned_resp, re.DOTALL)
116
+ model_ans = ans_m.group(1).strip() if ans_m else ""
117
+ if answer and model_ans != answer:
118
+ n_filtered += 1
119
+ continue
120
+
121
+ # 4. 拆分 process 和 solution
122
+ # process = <think>...</think> 部分
123
+ # solution = <answer>...</answer> 部分
124
+ think_match = re.search(r"(<think>.*?</think>)", cleaned_resp, re.DOTALL)
125
+ process = think_match.group(1) if think_match else cleaned_resp
126
+
127
+ answer_match = re.search(r"(<answer>.*?</answer>)", cleaned_resp, re.DOTALL)
128
+ solution = answer_match.group(0) if answer_match else f"<answer>{answer}</answer>"
129
+
130
+ # 如果 think 之后、answer 之前还有内容(如 Reference frame),也放入 process
131
+ # 完整的 process = think 外壳 + 所有分析内容
132
+ # 从 cleaned_resp 中去掉 answer 和 key_frame,剩下的都是 process
133
+ process_text = cleaned_resp
134
+ process_text = re.sub(r"<answer>.*?</answer>", "", process_text, flags=re.DOTALL)
135
+ process_text = re.sub(r"<key_frame>.*?</key_frame>", "", process_text, flags=re.DOTALL)
136
+ process_text = process_text.strip()
137
+ if process_text:
138
+ process = process_text
139
+
140
+ # 5. 推断类型
141
+ problem_type, options = detect_problem_type(question, answer)
142
+
143
+ # 6. 构建 Video-R1 格式
144
+ result = {
145
+ "problem_id": pid,
146
+ "problem": question,
147
+ "data_type": "video",
148
+ "problem_type": problem_type,
149
+ "options": options,
150
+ "process": process,
151
+ "solution": solution,
152
+ "path": convert_path(video),
153
+ "data_source": infer_data_source(video),
154
+ }
155
+ results.append(result)
156
+
157
+ # 写出 JSON 数组
158
+ with open(args.output, "w", encoding="utf-8") as f:
159
+ json.dump(results, f, ensure_ascii=False, indent=2)
160
+
161
+ # 报告
162
+ print(f"\n{'='*50}")
163
+ print(f"清洗并转换完成:")
164
+ print(f" 输入条数: {len(items)}")
165
+ print(f" 输出条数: {len(results)}")
166
+ print(f" 修复数: {total_fixes}")
167
+ print(f" 警告数: {total_warnings}")
168
+ if args.filter_wrong:
169
+ print(f" 过滤错误: {n_filtered}")
170
+ print(f" 输出文件: {args.output}")
171
+
172
+ # data_source 分布
173
+ from collections import Counter
174
+ src_dist = Counter(r["data_source"] for r in results)
175
+ print(f"\ndata_source 分布:")
176
+ for k, v in src_dist.most_common():
177
+ print(f" {k}: {v}")
178
+
179
+
180
+ if __name__ == "__main__":
181
+ main()
cot_generate/clean_cot_data.py ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ CoT 数据清洗脚本
3
+
4
+ 功能:
5
+ 1. 自动识别 think 模式新数据 / 旧数据两种格式
6
+ - 新数据 (think 模式): <think>[草稿]</think> Ref-Delta <answer>
7
+ → 丢弃草稿,将 Ref-Delta 包入 <think>
8
+ - 旧数据: <think>[Ref-Delta]</think> <answer> (保持原逻辑)
9
+ 2. 处理重复 <think></think> 标签
10
+ 3. 验证必要字段完整性
11
+ 4. 输出清洗报告
12
+
13
+ 用法:
14
+ python clean_cot_data.py input.jsonl -o output.jsonl
15
+ python clean_cot_data.py input.jsonl # 覆盖原文件
16
+ """
17
+
18
+ import re
19
+ import sys
20
+ import json
21
+ import argparse
22
+ from pathlib import Path
23
+
24
+
25
+ def clean_response(response: str, gt_answer: str = "") -> tuple[str, list[str]]:
26
+ """清洗单条 response,返回 (清洗后文本, 修复记录列表)"""
27
+ fixes = []
28
+
29
+ # ---- 1. 保护 <answer> 和 <key_frame> 块 ----
30
+ answer_match = re.search(r"<answer>(.*?)</answer>", response, re.DOTALL)
31
+ answer_block = answer_match.group(0).strip() if answer_match else ""
32
+
33
+ kf_match = re.search(r"<key_frame>(.*?)</key_frame>", response, re.DOTALL)
34
+ kf_block = kf_match.group(0).strip() if kf_match else ""
35
+
36
+ # ---- 2. 识别格式:新(think模式) vs 旧 ----
37
+ # 新格式特征:Ref-Delta 在 </think> 之后(草稿在 <think> 内部)
38
+ # 旧格式特征:Ref-Delta 在 <think> 内部
39
+ think_match = re.search(r"<think>(.*?)</think>(.*)", response, re.DOTALL)
40
+ is_new_format = False
41
+ if think_match:
42
+ after_think = think_match.group(2)
43
+ if "Reference frame at" in after_think or "<time_range>" in after_think:
44
+ is_new_format = True
45
+
46
+ if is_new_format:
47
+ # 新格式:丢弃 <think> 内的草稿,取 </think> 之后的 Ref-Delta 作为内容
48
+ after_think = think_match.group(2)
49
+ content = re.sub(r"<answer>.*?</answer>", "", after_think, flags=re.DOTALL)
50
+ content = re.sub(r"<key_frame>.*?</key_frame>", "", content, flags=re.DOTALL)
51
+ content = content.strip()
52
+ fixes.append("think模式新格式: 去除内部草稿,保留Ref-Delta")
53
+ n_think_open = n_think_close = 1
54
+ else:
55
+ # 旧格式:去掉所有 <think></think> 标签,内容原样保留
56
+ body = response
57
+ body = re.sub(r"<answer>.*?</answer>", "", body, flags=re.DOTALL)
58
+ body = re.sub(r"<key_frame>.*?</key_frame>", "", body, flags=re.DOTALL)
59
+ n_think_open = len(re.findall(r"<think>", body))
60
+ n_think_close = len(re.findall(r"</think>", body))
61
+ content = re.sub(r"</?think>", "", body).strip()
62
+
63
+ # ---- 3. 清理 think 内容 ----
64
+ # 3a. 把 bullet list 转为散文 (去掉行首 - • * 符号)
65
+ if re.search(r"^\s*[-•*]\s", content, re.MULTILINE):
66
+ lines = content.split("\n")
67
+ cleaned_lines = []
68
+ for line in lines:
69
+ stripped = re.sub(r"^\s*[-•*]\s+", "", line)
70
+ if stripped != line:
71
+ fixes.append(f"去除bullet: {line.strip()[:60]}")
72
+ cleaned_lines.append(stripped)
73
+ content = "\n".join(cleaned_lines)
74
+
75
+ # 3b. 把 "At <time>..." 句式统一为 Reference frame 句式
76
+ def _fix_at_time(m):
77
+ full = m.group(0)
78
+ t = m.group(1)
79
+ rest = m.group(2).strip().rstrip(".")
80
+ fixes.append(f"At <time> → Reference frame: {full[:60]}")
81
+ return f"Reference frame at <time>{t}</time>: {rest}."
82
+ content = re.sub(
83
+ r"(?<!Reference frame )At <time>(.*?)</time>[,:]\s*(.*?)(?=\.\s|\n\n|$)",
84
+ _fix_at_time, content, flags=re.DOTALL,
85
+ )
86
+
87
+ # ---- 4. 记录修复 ----
88
+ if not is_new_format and (n_think_open > 1 or n_think_close > 1):
89
+ fixes.append(f"多余think标签: {n_think_open}个<think>, {n_think_close}个</think>")
90
+
91
+ if not is_new_format:
92
+ think_matches = re.findall(r"<think>(.*?)</think>", response, re.DOTALL)
93
+ all_empty = all(m.strip() == "" for m in think_matches) if think_matches else True
94
+ if all_empty and content:
95
+ fixes.append("think为空,内容在外部,已合并")
96
+
97
+ # ---- 5. 清理 answer ----
98
+ if gt_answer and answer_block:
99
+ ans_inner = re.search(r"<answer>(.*?)</answer>", answer_block, re.DOTALL)
100
+ if ans_inner:
101
+ ans_text = ans_inner.group(1).strip()
102
+ if ans_text != gt_answer and len(ans_text) > len(gt_answer):
103
+ fixes.append(f"answer冗余: \"{ans_text[:50]}\" → \"{gt_answer}\"")
104
+ answer_block = f"<answer>{gt_answer}</answer>"
105
+
106
+ # ---- 6. 重新组装 ----
107
+ parts = []
108
+ if content:
109
+ parts.append(f"<think>\n{content}\n</think>")
110
+ else:
111
+ parts.append("<think>\n</think>")
112
+
113
+ if answer_block:
114
+ parts.append(answer_block)
115
+ if kf_block:
116
+ parts.append(kf_block)
117
+
118
+ cleaned = "\n\n".join(parts)
119
+ return cleaned, fixes
120
+
121
+
122
+ def _extract_option_letter(s: str) -> str:
123
+ """从答案文本中提取选项字母 A-E,失败返回空串"""
124
+ m = re.match(r"^\(?([A-E])\)?[\.\s]?", s.strip())
125
+ return m.group(1) if m else ""
126
+
127
+
128
+ _PLACEHOLDERS = {
129
+ "concise answer", "the answer", "answer", "...", "……",
130
+ "yes", "no", "n/a", "none", "unknown",
131
+ }
132
+
133
+
134
+ def answers_match(model_ans: str, gt: str) -> bool:
135
+ """答案匹配,分两套策略:
136
+ - 选择题(双方均可提取 A-E 字母):严格比较字母
137
+ - 自由文本:只过滤占位符/空答/极短答案,其余保留
138
+ (因为 GT 已作为引导传给模型,有实质内容即视为正确)
139
+ """
140
+ if not model_ans or not gt:
141
+ return False
142
+ if model_ans == gt:
143
+ return True
144
+
145
+ # ---- 选择题:提取字母比较 ----
146
+ ml = _extract_option_letter(model_ans)
147
+ gl = _extract_option_letter(gt)
148
+ if ml and gl:
149
+ return ml == gl
150
+
151
+ # ---- 自由文本:过滤明显失败 ----
152
+ mn = model_ans.strip().lower()
153
+ # 占位符
154
+ if mn in _PLACEHOLDERS:
155
+ return False
156
+ # 极短(不足 5 字符)
157
+ if len(mn) < 5:
158
+ return False
159
+ # 纯省略号 / 重复符号
160
+ if re.match(r"^[.\s…]+$", mn):
161
+ return False
162
+
163
+ # 有实质内容 → 保留(GT 已引导模型,不做严格文本比对)
164
+ return True
165
+
166
+
167
+ def validate_item(item: dict) -> list[str]:
168
+ """验证单条数据的必要字段"""
169
+ warnings = []
170
+ resp = item.get("response", "")
171
+
172
+ if not resp:
173
+ warnings.append("response为空")
174
+ return warnings
175
+
176
+ # 检查 think 内容
177
+ think_match = re.search(r"<think>(.*?)</think>", resp, re.DOTALL)
178
+ think_text = think_match.group(1).strip() if think_match else ""
179
+ if not think_text:
180
+ warnings.append("think内容为空")
181
+
182
+ # 检查 answer
183
+ if not re.search(r"<answer>", resp):
184
+ warnings.append("缺少answer")
185
+
186
+ # 检查 Reference frame
187
+ if not re.search(r"Reference frame at", resp):
188
+ warnings.append("无Reference frame")
189
+
190
+ # 检查 delta
191
+ if not re.search(r"<delta>", resp):
192
+ warnings.append("无delta")
193
+
194
+ # 检查 time 标签
195
+ n_time = len(re.findall(r"<time>", resp))
196
+ n_time_range = len(re.findall(r"<time_range>", resp))
197
+ if n_time + n_time_range == 0:
198
+ warnings.append("无时间标签")
199
+
200
+ # 检查 answer 是否与 GT 一致(宽松匹配)
201
+ gt = item.get("answer", "")
202
+ if gt:
203
+ ans_match = re.search(r"<answer>(.*?)</answer>", resp, re.DOTALL)
204
+ model_ans = ans_match.group(1).strip() if ans_match else ""
205
+ if model_ans and not answers_match(model_ans, gt):
206
+ warnings.append(f"答案错误: model={model_ans[:40]} gt={gt[:40]}")
207
+
208
+ return warnings
209
+
210
+
211
+ def main():
212
+ parser = argparse.ArgumentParser(description="清洗 CoT 数据")
213
+ parser.add_argument("input", help="输入 JSONL 文件路径")
214
+ parser.add_argument("-o", "--output", help="输出路径 (不指定则覆盖原文件)")
215
+ parser.add_argument("--filter-wrong", action="store_true",
216
+ help="过滤掉答案与GT不一致的条目")
217
+ args = parser.parse_args()
218
+
219
+ input_path = Path(args.input)
220
+ output_path = Path(args.output) if args.output else input_path
221
+
222
+ # 读取
223
+ items = []
224
+ with open(input_path, encoding="utf-8") as f:
225
+ for line in f:
226
+ if line.strip():
227
+ items.append(json.loads(line))
228
+
229
+ print(f"读取 {len(items)} 条数据\n")
230
+
231
+ # 清洗
232
+ total_fixes = 0
233
+ total_warnings = 0
234
+ cleaned_items = []
235
+
236
+ for i, item in enumerate(items):
237
+ pid = item.get("problem_id", i)
238
+ resp = item.get("response", "")
239
+
240
+ if not resp:
241
+ cleaned_items.append(item)
242
+ continue
243
+
244
+ # 清洗 response
245
+ gt_answer = item.get("answer", "")
246
+ cleaned_resp, fixes = clean_response(resp, gt_answer)
247
+ item["response"] = cleaned_resp
248
+
249
+ # 验证
250
+ warnings = validate_item(item)
251
+
252
+ if fixes or warnings:
253
+ print(f" [{pid}]", end="")
254
+ if fixes:
255
+ total_fixes += len(fixes)
256
+ print(f" 修复: {'; '.join(fixes)}", end="")
257
+ if warnings:
258
+ total_warnings += len(warnings)
259
+ print(f" ⚠ {'; '.join(warnings)}", end="")
260
+ print()
261
+
262
+ cleaned_items.append(item)
263
+
264
+ # 过滤答案错误的条目
265
+ n_filtered = 0
266
+ if args.filter_wrong:
267
+ filtered = []
268
+ for item in cleaned_items:
269
+ gt = item.get("answer", "")
270
+ resp = item.get("response", "")
271
+ ans_m = re.search(r"<answer>(.*?)</answer>", resp, re.DOTALL)
272
+ model_ans = ans_m.group(1).strip() if ans_m else ""
273
+ if not gt or answers_match(model_ans, gt):
274
+ filtered.append(item)
275
+ else:
276
+ n_filtered += 1
277
+ cleaned_items = filtered
278
+
279
+ # 写入
280
+ with open(output_path, "w", encoding="utf-8") as f:
281
+ for item in cleaned_items:
282
+ f.write(json.dumps(item, ensure_ascii=False) + "\n")
283
+
284
+ # 报告
285
+ print(f"\n{'='*50}")
286
+ print(f"清洗完成:")
287
+ print(f" 总条数: {len(cleaned_items)}")
288
+ print(f" 修复数: {total_fixes}")
289
+ print(f" 警告数: {total_warnings}")
290
+ if args.filter_wrong:
291
+ print(f" 过滤错误: {n_filtered}")
292
+ print(f" 输出到: {output_path}")
293
+
294
+
295
+ if __name__ == "__main__":
296
+ main()
cot_generate/generate_video_cot.py ADDED
@@ -0,0 +1,567 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 批量视频 CoT 数据生成脚本
3
+ 通过 OpenAI 兼容 API 调用 ms-swift 部署的 Qwen3.5-122B-A10B 模型,
4
+ 对视频生成带时间戳的 Chain-of-Thought 推理数据。
5
+
6
+ 使用方式:
7
+ 1. 先启动服务: bash start_server.sh
8
+ 2. 输入为视频目录 (无答案, 自由描述模式):
9
+ python generate_video_cot.py --input /path/to/videos --output output.jsonl
10
+ 3. 输入为 jsonl 文件 (支持 answer 字段引导推理):
11
+ python generate_video_cot.py --input data.jsonl --output output.jsonl
12
+ 4. 输入为 Video-R1 格式 json 文件:
13
+ python generate_video_cot.py --input Video-R1-260k.json --output output.jsonl --video_root /path/to/videos
14
+ 5. 支持断点续跑:
15
+ python generate_video_cot.py --input data.jsonl --output output.jsonl --resume
16
+
17
+ 输入 jsonl 格式 (每行一个 json):
18
+ {"video": "/path/to/video.mp4", "question": "What is the velocity?", "answer": "3 m/s"}
19
+ answer 字段可选; 有 answer 时模型会生成指向该答案的推理链
20
+
21
+ Video-R1 json 格式 (自动转换):
22
+ [{"path": "...", "problem": "...", "options": [...], "solution": "<answer>A</answer>"}, ...]
23
+ """
24
+
25
+ import base64
26
+ import json
27
+ import argparse
28
+ import math
29
+ import os
30
+ import re
31
+ import time
32
+ from pathlib import Path
33
+ from concurrent.futures import ThreadPoolExecutor, as_completed
34
+
35
+ import cv2
36
+
37
+ from openai import OpenAI
38
+ from tqdm import tqdm
39
+
40
+ # ============================================================
41
+ # CoT System Prompt — Reference-Frame + Delta (Ref-Δ) Paradigm
42
+ #
43
+ # 核心思想: 用 "参考系(锚点帧) + 动态变化量(Δ)" 的范式来对抗
44
+ # 静态先验捷径(Static Prior Shortcuts)。
45
+ # 模型必须先建立视觉锚点, 再显式追踪相对于锚点的变化(delta),
46
+ # 从而迫使推理基于真实视频演变, 而非背景+语言常识盲猜。
47
+ #
48
+ # 提取方式:
49
+ # 锚点帧: re.findall(r"Reference frame at <time>(.*?)</time>:\s*(.*?)(?=Reference frame at|$)", text, re.DOTALL)
50
+ # 变化量: re.findall(r"<time_range>(.*?)</time_range>.*?<delta>(.*?)</delta>", text, re.DOTALL)
51
+ # ============================================================
52
+
53
+ # ===================== v4 prompt (已弃用, 保留备份) =====================
54
+ # SYSTEM_PROMPT_GUIDED_V4 = """\
55
+ # Adopt the persona of an expert video analyst tasked with uncovering the true "Semantic Flow" of a video. \
56
+ # Your primary goal is to counteract common AI flaws: "single-frame bias" (jumping to conclusions from \
57
+ # one static image) and "background bias" (over-relying on the scene's setting rather than the actual action). \
58
+ # To do this, you must focus exclusively on the dynamic visual changes (deltas) across time, \
59
+ # strictly ignoring static background elements unless they interact with the main subject. \
60
+ # CRITICAL: The video frames have a precise timestamp watermarked in the top-left corner \
61
+ # in the format of HH:MM:SS. You MUST read these watermarked timestamps directly from \
62
+ # the video frames and use ONLY the exact timestamps you actually observe in the watermark. \
63
+ # Do NOT estimate, interpolate, round, or fabricate any timestamps — every timestamp you \
64
+ # cite in <time> or <time_range> tags must be one you can literally see on a video frame.
65
+ # {fps_constraint}
66
+ # Formatting Rules:
67
+ # 1. Thinking Block: Write your detailed thought process within <think> and </think> tags. \
68
+ # Present a continuous, logical analysis of the video's progression, moving smoothly from \
69
+ # the beginning to the end without abrupt shifts or artificial conversational fillers.
70
+ # 2. Cohesive Prose: Your thought process must be written in flowing paragraphs. \
71
+ # Avoid disjointed bullet points or fragmented lists to ensure a complete, unbroken narrative of the events.
72
+ # 3. Reference Frame (Anchor): When you first observe the scene, or when the scene changes \
73
+ # significantly (cut, new subject, environment shift), establish an anchor using this exact pattern: \
74
+ # "Reference frame at <time>HH:MM:SS</time>: [static description of subject positions, postures, \
75
+ # held objects, spatial relationships at this exact moment]." \
76
+ # The timestamp inside <time> MUST be copied exactly from the watermark visible on that frame — \
77
+ # do not guess or approximate. \
78
+ # The first reference frame should appear at the beginning of your analysis. \
79
+ # You may establish multiple reference frames throughout the video when the scene resets or shifts.
80
+ # 4. Dynamic Change (Delta): When describing how things change over time, use this pattern: \
81
+ # "From <time_range>HH:MM:SS - HH:MM:SS</time_range>, <delta>[description of what changed, \
82
+ # moved, or transformed relative to the most recent reference frame]</delta>." \
83
+ # Both the start and end timestamps in <time_range> MUST be exact watermarked timestamps \
84
+ # you can see on actual video frames — never interpolate between frames or invent timestamps. \
85
+ # Focus only on what changed — do not describe static background. \
86
+ # Each delta should clearly connect back to its preceding reference frame.
87
+ # 5. Anti-Bias Continuity: Build your reasoning seamlessly from one reference frame and its \
88
+ # deltas to the next. Do not describe stationary room decor. Prove your final conclusion by \
89
+ # connecting the sequence of temporal deltas into a complete logical chain.
90
+ # 6. Answer Block: After the </think> block, provide the final concise answer inside \
91
+ # <answer> and </answer> tags.
92
+ # 7. Key Frame/Range Block: After the answer, include a block using <key_frame> and </key_frame> \
93
+ # tags where you point out the specific timestamp(s) or time range(s) of the critical video frames \
94
+ # without which the question cannot be answered.
95
+ #
96
+ # Example output structure:
97
+ #
98
+ # <think>
99
+ # Reference frame at <time>00:00:00</time>: a person stands at a table holding a red cup \
100
+ # in their right hand, with a white bowl positioned to the left.
101
+ #
102
+ # The action begins immediately. From <time_range>00:00:00 - 00:00:02</time_range>, \
103
+ # <delta>the person lifts the red cup from the table and tilts it toward the bowl on the left</delta>. \
104
+ # The motion is deliberate, suggesting an intentional pouring action.
105
+ #
106
+ # Continuing the flow, from <time_range>00:00:02 - 00:00:04</time_range>, \
107
+ # <delta>the cup is now fully inverted and liquid streams steadily into the bowl</delta>. \
108
+ # This confirms the pouring interpretation.
109
+ #
110
+ # The scene then resets. Reference frame at <time>00:00:05</time>: the cup is back upright \
111
+ # on the table, and the bowl is now visibly full of liquid.
112
+ #
113
+ # From <time_range>00:00:05 - 00:00:07</time_range>, \
114
+ # <delta>the person pushes the bowl forward across the table toward the opposite edge</delta>.
115
+ #
116
+ # Connecting the delta chain: the person poured liquid from cup to bowl, then pushed the bowl away.
117
+ # </think>
118
+ #
119
+ # <answer>The person poured liquid from the cup into the bowl.</answer>
120
+ #
121
+ # <key_frame>00:00:02 - 00:00:04, 00:00:05</key_frame>
122
+ #
123
+ # Here is your question:
124
+ # {question}
125
+ #
126
+ # The final answer is provided below. Use it as a reference to guide your thinking process. \
127
+ # You MUST logically arrive at this correct conclusion by connecting the dynamic temporal \
128
+ # deltas in a continuous, well-reasoned flow.
129
+ # {answer}"""
130
+ # ===================== end v4 prompt =====================
131
+
132
+ # 有正确答案时使用 (answer-guided) — v5 精简版
133
+ SYSTEM_PROMPT_GUIDED = """\
134
+ You are an expert video analyst. Analyze the "Semantic Flow" of a video by \
135
+ tracking dynamic changes across time. Ignore static backgrounds unless they \
136
+ interact with the main subject.
137
+
138
+ CRITICAL: Video frames have timestamps watermarked in the top-left corner. \
139
+ Read timestamps directly from the watermark — never estimate or fabricate. \
140
+ Always round DOWN to whole seconds and write timestamps as HH:MM:SS only \
141
+ (e.g. if watermark shows 00:00:04.8, write 00:00:04).
142
+ {fps_constraint}
143
+ Output format:
144
+ 1. Reference Frame: "Reference frame at <time>HH:MM:SS</time>: [brief description]."
145
+ 2. Delta: "From <time_range>HH:MM:SS - HH:MM:SS</time_range>, <delta>[what changed]</delta>."
146
+ 3. Reasoning Summary: "<reasoning_summary>[connect deltas to answer]</reasoning_summary>"
147
+ 4. Answer: "<answer>concise answer</answer>"
148
+
149
+ Example:
150
+ Reference frame at <time>00:00:00</time>: a person holds a red cup, white bowl to the left.
151
+ From <time_range>00:00:00 - 00:00:03</time_range>, <delta>the person tilts the cup and pours liquid into the bowl</delta>.
152
+ From <time_range>00:00:03 - 00:00:05</time_range>, <delta>the person pushes the filled bowl forward</delta>.
153
+ <reasoning_summary>The person poured liquid from cup to bowl, then pushed it away.</reasoning_summary>
154
+ <answer>The person poured liquid into the bowl.</answer>
155
+
156
+ Cover the entire video timeline. Each delta must describe a different change — \
157
+ never repeat previous observations. If an action repeats, summarize it in one \
158
+ delta instead of describing each repetition. Keep your analysis concise.
159
+
160
+ Question: {question}
161
+
162
+ The correct answer is given below. You MUST logically arrive at this conclusion \
163
+ by connecting the temporal deltas.
164
+ {answer}"""
165
+
166
+ # 无正确答案时使用 (free reasoning) — v5 精简版
167
+ SYSTEM_PROMPT_FREE = """\
168
+ You are an expert video analyst. Analyze the "Semantic Flow" of a video by \
169
+ tracking dynamic changes across time. Ignore static backgrounds unless they \
170
+ interact with the main subject.
171
+
172
+ CRITICAL: Video frames have timestamps watermarked in the top-left corner. \
173
+ Read timestamps directly from the watermark — never estimate or fabricate. \
174
+ Always round DOWN to whole seconds and write timestamps as HH:MM:SS only \
175
+ (e.g. if watermark shows 00:00:04.8, write 00:00:04).
176
+ {fps_constraint}
177
+ Output format:
178
+ 1. Reference Frame: "Reference frame at <time>HH:MM:SS</time>: [brief description]."
179
+ 2. Delta: "From <time_range>HH:MM:SS - HH:MM:SS</time_range>, <delta>[what changed]</delta>."
180
+ 3. Reasoning Summary: "<reasoning_summary>[connect deltas to answer]</reasoning_summary>"
181
+ 4. Answer: "<answer>concise answer</answer>"
182
+
183
+ Example:
184
+ Reference frame at <time>00:00:00</time>: a person holds a red cup, white bowl to the left.
185
+ From <time_range>00:00:00 - 00:00:03</time_range>, <delta>the person tilts the cup and pours liquid into the bowl</delta>.
186
+ From <time_range>00:00:03 - 00:00:05</time_range>, <delta>the person pushes the filled bowl forward</delta>.
187
+ <reasoning_summary>The person poured liquid from cup to bowl, then pushed it away.</reasoning_summary>
188
+ <answer>The person poured liquid into the bowl.</answer>
189
+
190
+ Cover the entire video timeline. Each delta must describe a different change — \
191
+ never repeat previous observations. If an action repeats, summarize it in one \
192
+ delta instead of describing each repetition. Keep your analysis concise.
193
+
194
+ Question: {question}"""
195
+
196
+ DEFAULT_QUESTION = "Describe and analyze what is happening in this video step by step."
197
+
198
+ VIDEO_EXTENSIONS = {".mp4", ".avi", ".mkv", ".mov", ".webm", ".flv"}
199
+
200
+ MIME_MAP = {
201
+ ".mp4": "video/mp4", ".avi": "video/avi", ".mkv": "video/x-matroska",
202
+ ".mov": "video/quicktime", ".webm": "video/webm", ".flv": "video/x-flv",
203
+ }
204
+
205
+
206
+ def _smart_nframes(total_frames: int, video_fps: float, max_frames: int,
207
+ sample_fps: float = 2.0) -> int:
208
+ """复现 qwen_vl_utils.vision_process.smart_nframes 的完整逻辑
209
+
210
+ ms-swift (Qwen2.5-VL / Qwen3.5) 的实际抽帧流程:
211
+ 1. 按目标采样率(默认2FPS)算出理想帧数: total_frames / video_fps * sample_fps
212
+ 2. clamp 到 [min_frames=4, max_frames] 区间
213
+ 3. 向下取到 FRAME_FACTOR=2 的倍数 (帧数必须是偶数)
214
+
215
+ 参数:
216
+ total_frames: 视频原始总帧数
217
+ video_fps: 视频原始帧率
218
+ max_frames: 最大采样帧数 (对应 FPS_MAX_FRAMES 环境变量, 默认32)
219
+ sample_fps: 目标采样帧率 (qwen_vl_utils 默认 2.0)
220
+ """
221
+ FRAME_FACTOR = 2
222
+ min_frames = math.ceil(4 / FRAME_FACTOR) * FRAME_FACTOR # = 4
223
+ max_frames = math.floor(min(max_frames, total_frames) / FRAME_FACTOR) * FRAME_FACTOR
224
+
225
+ nframes = total_frames / video_fps * sample_fps
226
+ nframes = min(min(max(nframes, min_frames), max_frames), total_frames)
227
+ nframes = math.floor(nframes / FRAME_FACTOR) * FRAME_FACTOR
228
+
229
+ # 安全边界
230
+ nframes = max(nframes, FRAME_FACTOR)
231
+ nframes = min(nframes, total_frames)
232
+
233
+ return int(nframes)
234
+
235
+
236
+ def _get_video_actual_fps(video_path: str, max_frames: int = 32) -> float:
237
+ """根据视频实际时长, 用 smart_nframes 计算 ms-swift 的真实采样率"""
238
+ cap = cv2.VideoCapture(video_path)
239
+ total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
240
+ native_fps = cap.get(cv2.CAP_PROP_FPS)
241
+ cap.release()
242
+
243
+ if native_fps <= 0 or total_frames <= 0:
244
+ return 2.0 # fallback
245
+
246
+ duration = total_frames / native_fps
247
+ sampled = _smart_nframes(total_frames, native_fps, max_frames)
248
+ return sampled / duration if duration > 0 else 2.0
249
+
250
+
251
+ def _build_fps_constraint(fps: float) -> str:
252
+ """根据实际抽帧率生成时间戳约束段落 (宽松措辞, 以水印为准)"""
253
+ interval = 1.0 / fps
254
+ return (
255
+ f"\nIMPORTANT: The video frames you see have been sampled at approximately "
256
+ f"{fps:.1f} FPS (roughly one frame every {interval:.1f}s). "
257
+ f"The timestamps watermarked on each frame reflect the actual frame times. "
258
+ f"Always use the exact watermark timestamps you observe — "
259
+ f"do not invent, interpolate, or round timestamps to values "
260
+ f"that do not appear in the watermark.\n"
261
+ )
262
+
263
+
264
+ def build_messages(video_path: str, question: str, answer: str = None, max_frames: int = 32) -> list:
265
+ """构建包含视频的多模态消息 (base64 编码本地文件)
266
+
267
+ answer: 若提供, 使用 answer-guided prompt 引导模型推理到正确答案;
268
+ 否则使用 free reasoning prompt 自由推理。
269
+ question 和 answer 嵌入 system prompt, user 消息仅含视频。
270
+ max_frames: 对应 FPS_MAX_FRAMES, 用于动态计算实际采样率。
271
+ """
272
+ path = Path(video_path).resolve()
273
+ mime = MIME_MAP.get(path.suffix.lower(), "video/mp4")
274
+ with open(path, "rb") as f:
275
+ b64 = base64.b64encode(f.read()).decode("utf-8")
276
+ video_url = f"data:{mime};base64,{b64}"
277
+
278
+ actual_fps = _get_video_actual_fps(video_path, max_frames)
279
+ fps_constraint = _build_fps_constraint(actual_fps)
280
+
281
+ if answer is not None:
282
+ system = SYSTEM_PROMPT_GUIDED.format(question=question, answer=answer, fps_constraint=fps_constraint)
283
+ else:
284
+ system = SYSTEM_PROMPT_FREE.format(question=question, fps_constraint=fps_constraint)
285
+
286
+ return [
287
+ {"role": "system", "content": system},
288
+ {
289
+ "role": "user",
290
+ "content": [
291
+ {"type": "video_url", "video_url": {"url": video_url}},
292
+ {"type": "text", "text": "Please analyze the video and answer the question."},
293
+ ],
294
+ },
295
+ ]
296
+
297
+
298
+ def generate_single(
299
+ client: OpenAI,
300
+ model: str,
301
+ video_path: str,
302
+ question: str,
303
+ max_tokens: int,
304
+ temperature: float,
305
+ answer: str = None,
306
+ max_frames: int = 32,
307
+ ) -> str:
308
+ """对单个视频生成 CoT"""
309
+ messages = build_messages(video_path, question, answer, max_frames=max_frames)
310
+ response = client.chat.completions.create(
311
+ model=model,
312
+ messages=messages,
313
+ max_tokens=max_tokens,
314
+ temperature=temperature,
315
+ )
316
+ return response.choices[0].message.content
317
+
318
+
319
+ # ============================================================
320
+ # Video-R1 格式转换
321
+ # ============================================================
322
+ def _extract_answer(solution: str) -> str:
323
+ """从 '<answer>A</answer>' 中提取答案文本"""
324
+ m = re.search(r"<answer>(.*?)</answer>", solution, re.DOTALL)
325
+ return m.group(1).strip() if m else solution.strip()
326
+
327
+
328
+ def load_video_r1(json_path: str, video_root: str, default_question: str) -> list:
329
+ """加载 Video-R1 格式 json, 转换为统一 item 格式"""
330
+ root = Path(video_root) if video_root else Path(".")
331
+ with open(json_path, encoding="utf-8") as f:
332
+ data = json.load(f)
333
+ items = []
334
+ for entry in data:
335
+ # 视频路径: video_root / entry["path"] (去掉开头的 ./)
336
+ rel = entry.get("path", "").lstrip("./")
337
+ video = str(root / rel)
338
+
339
+ # 问题: problem + options
340
+ problem = entry.get("problem", default_question)
341
+ options = entry.get("options", [])
342
+ if options:
343
+ question = problem.rstrip() + "\n" + "\n".join(options)
344
+ else:
345
+ question = problem
346
+
347
+ # 答案
348
+ solution = entry.get("solution", "")
349
+ answer = _extract_answer(solution) if solution else None
350
+
351
+ item = {"video": video, "question": question}
352
+ if answer:
353
+ item["answer"] = answer
354
+ # 保留原始字段供输出追溯
355
+ if "problem_id" in entry:
356
+ item["problem_id"] = entry["problem_id"]
357
+ items.append(item)
358
+ return items
359
+
360
+
361
+ # ============================================================
362
+ # 通用输入加载
363
+ # ============================================================
364
+ def load_inputs(input_path: str, default_question: str, video_root: str = None) -> list:
365
+ """
366
+ 支持格式:
367
+ 1. 视频文件目录
368
+ 2. 单个视频文件
369
+ 3. jsonl 文件: 每行 {"video", "question"[, "answer"]}
370
+ 4. Video-R1 json 文件: [{"path", "problem", "options", "solution"}, ...]
371
+ """
372
+ path = Path(input_path)
373
+ items = []
374
+
375
+ if path.is_dir():
376
+ for f in sorted(path.rglob("*")):
377
+ if f.suffix.lower() in VIDEO_EXTENSIONS:
378
+ items.append({"video": str(f), "question": default_question})
379
+
380
+ elif path.is_file() and path.suffix.lower() in VIDEO_EXTENSIONS:
381
+ items.append({"video": str(path), "question": default_question})
382
+
383
+ elif path.suffix == ".jsonl":
384
+ with open(path, encoding="utf-8") as f:
385
+ for line in f:
386
+ line = line.strip()
387
+ if not line:
388
+ continue
389
+ item = json.loads(line)
390
+ item.setdefault("question", default_question)
391
+ items.append(item)
392
+
393
+ elif path.suffix == ".json":
394
+ with open(path, encoding="utf-8") as f:
395
+ data = json.load(f)
396
+ if not isinstance(data, list):
397
+ raise ValueError(f"JSON file should contain a list, got {type(data)}")
398
+ # 自动检测是否为 Video-R1 格式 (含 "path" 和 "problem" 字段)
399
+ if data and "path" in data[0] and "problem" in data[0]:
400
+ items = load_video_r1(input_path, video_root or ".", default_question)
401
+ else:
402
+ for item in data:
403
+ item.setdefault("question", default_question)
404
+ items.append(item)
405
+ else:
406
+ raise ValueError(f"Unsupported input format: {path.suffix}")
407
+
408
+ return items
409
+
410
+
411
+ def load_processed(output_path: str) -> set:
412
+ """加载已处理的条目 key (用于断点续跑)
413
+ key = video + question,支持同一视频多个不同问题"""
414
+ processed = set()
415
+ if Path(output_path).exists():
416
+ with open(output_path, encoding="utf-8") as f:
417
+ for line in f:
418
+ line = line.strip()
419
+ if not line:
420
+ continue
421
+ entry = json.loads(line)
422
+ video = entry.get("video", "")
423
+ question = entry.get("question", "")
424
+ processed.add((video, question))
425
+ return processed
426
+
427
+
428
+ # ============================================================
429
+ # 处理流程
430
+ # ============================================================
431
+ def _make_result(item: dict) -> dict:
432
+ result = {"video": item["video"], "question": item["question"]}
433
+ if "answer" in item:
434
+ result["answer"] = item["answer"]
435
+ if "problem_id" in item:
436
+ result["problem_id"] = item["problem_id"]
437
+ if "data_source" in item:
438
+ result["data_source"] = item["data_source"]
439
+ return result
440
+
441
+
442
+ def process_sequential(client, model, items, output_path, max_tokens, temperature, mode, max_frames):
443
+ with open(output_path, mode, encoding="utf-8") as fout:
444
+ for item in tqdm(items, desc="Generating CoT"):
445
+ result = _make_result(item)
446
+ try:
447
+ result["response"] = generate_single(
448
+ client, model,
449
+ item["video"], item["question"],
450
+ max_tokens, temperature,
451
+ answer=item.get("answer"),
452
+ max_frames=max_frames,
453
+ )
454
+ except Exception as e:
455
+ print(f"\n[ERROR] {item['video']}: {e}")
456
+ result["error"] = str(e)
457
+ fout.write(json.dumps(result, ensure_ascii=False) + "\n")
458
+ fout.flush()
459
+
460
+
461
+ def process_parallel(client, model, items, output_path, max_tokens, temperature, mode, workers, max_frames):
462
+ with open(output_path, mode, encoding="utf-8") as fout:
463
+ with ThreadPoolExecutor(max_workers=workers) as executor:
464
+ futures = {
465
+ executor.submit(
466
+ generate_single,
467
+ client, model,
468
+ item["video"], item["question"],
469
+ max_tokens, temperature,
470
+ item.get("answer"),
471
+ max_frames,
472
+ ): item
473
+ for item in items
474
+ }
475
+ for future in tqdm(as_completed(futures), total=len(futures), desc="Generating CoT"):
476
+ item = futures[future]
477
+ result = _make_result(item)
478
+ try:
479
+ result["response"] = future.result()
480
+ except Exception as e:
481
+ print(f"\n[ERROR] {item['video']}: {e}")
482
+ result["error"] = str(e)
483
+ fout.write(json.dumps(result, ensure_ascii=False) + "\n")
484
+ fout.flush()
485
+
486
+
487
+ def main():
488
+ parser = argparse.ArgumentParser(
489
+ description="批量视频 CoT 数据生成 (Qwen3.5 + ms-swift)",
490
+ formatter_class=argparse.RawDescriptionHelpFormatter,
491
+ )
492
+ parser.add_argument("--input", required=True,
493
+ help="输入: 视频目录 / jsonl 文件 / json 文件 (含 Video-R1 格式)")
494
+ parser.add_argument("--output", required=True,
495
+ help="输出 jsonl 文件路径")
496
+ parser.add_argument("--video_root", default=None,
497
+ help="Video-R1 json 格式时, 视频文件的根目录")
498
+ parser.add_argument("--api_base", default="http://localhost:8000/v1",
499
+ help="ms-swift deploy 的 API 地址 (default: http://localhost:8000/v1)")
500
+ parser.add_argument("--model", default="Qwen3.5-122B-A10B",
501
+ help="模型名称, 需与 swift deploy 一致")
502
+ parser.add_argument("--question", default=DEFAULT_QUESTION,
503
+ help="默认问题 (当输入数据无 question 字段时使用)")
504
+ parser.add_argument("--max_tokens", type=int, default=4096,
505
+ help="最大生成 token 数 (default: 4096)")
506
+ parser.add_argument("--temperature", type=float, default=0.7,
507
+ help="生成温度 (default: 0.7)")
508
+ parser.add_argument("--workers", type=int, default=1,
509
+ help="并行请求数 (default: 1, vLLM 会自动做 batch)")
510
+ parser.add_argument("--max_frames", type=int, default=None,
511
+ help="最大采样帧数, 需与 FPS_MAX_FRAMES 环境变量一致 (默认读取环境变量, 否则 32)")
512
+ parser.add_argument("--resume", action="store_true",
513
+ help="断点续跑: 跳过已处理的视频")
514
+ args = parser.parse_args()
515
+
516
+ # max_frames: 优先用 CLI 参数, 其次读环境变量 FPS_MAX_FRAMES, 最后默认 32
517
+ max_frames = args.max_frames or int(os.environ.get("FPS_MAX_FRAMES", 32))
518
+
519
+ items = load_inputs(args.input, args.question, args.video_root)
520
+ print(f"[INFO] Loaded {len(items)} items")
521
+ has_answer = sum(1 for i in items if "answer" in i)
522
+ print(f"[INFO] Items with ground-truth answer: {has_answer}/{len(items)}")
523
+ print(f"[INFO] Max sampled frames per video: {max_frames} (actual FPS varies by video duration)")
524
+
525
+ mode = "w"
526
+ if args.resume:
527
+ processed = load_processed(args.output)
528
+ before = len(items)
529
+ items = [item for item in items if (item["video"], item["question"]) not in processed]
530
+ print(f"[INFO] Resume mode: skipped {before - len(items)}, remaining {len(items)}")
531
+ mode = "a"
532
+
533
+ if not items:
534
+ print("[INFO] Nothing to process. Done!")
535
+ return
536
+
537
+ Path(args.output).parent.mkdir(parents=True, exist_ok=True)
538
+
539
+ client = OpenAI(api_key="EMPTY", base_url=args.api_base)
540
+ print(f"[INFO] Connecting to {args.api_base} ...")
541
+ try:
542
+ models = client.models.list()
543
+ print(f"[INFO] Server ready. Available models: {[m.id for m in models.data]}")
544
+ except Exception as e:
545
+ print(f"[ERROR] Cannot connect to server: {e}")
546
+ print("[HINT] Please run 'bash start_server.sh' first.")
547
+ return
548
+
549
+ t0 = time.time()
550
+ if args.workers <= 1:
551
+ process_sequential(client, args.model, items, args.output,
552
+ args.max_tokens, args.temperature, mode, max_frames)
553
+ else:
554
+ process_parallel(client, args.model, items, args.output,
555
+ args.max_tokens, args.temperature, mode, args.workers, max_frames)
556
+
557
+ elapsed = time.time() - t0
558
+ print(f"\n[DONE] Results saved to {args.output}")
559
+ print(f"[DONE] Processed {len(items)} videos in {elapsed:.1f}s "
560
+ f"({elapsed / len(items):.1f}s per video)")
561
+
562
+
563
+ if __name__ == "__main__":
564
+ main()
565
+
566
+
567
+ # tmux send-keys -t cot_gen C-c 2>/dev/null; sleep 1; tmux send-keys -t cot_gen "cd /root/zwj/CoT_generate && python generate_video_cot.py --input /root/zwj/CoT_generate/output/need_rerun_v2.jsonl --output /root/zwj/CoT_generate/output/need_rerun_v2_cot.jsonl --max_frames 768 --workers 4 --resume" Enter
cot_generate/generate_video_cot_with_hint.py ADDED
@@ -0,0 +1,581 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 批量视频 CoT 数据生成脚本
3
+ 通过 OpenAI 兼容 API 调用 ms-swift 部署的 Qwen3.5-122B-A10B 模型,
4
+ 对视频生成带时间戳的 Chain-of-Thought 推理数据。
5
+
6
+ 使用方式:
7
+ 1. 先启动服务: bash start_server.sh
8
+ 2. 输入为视频目录 (无答案, 自由描述模式):
9
+ python generate_video_cot.py --input /path/to/videos --output output.jsonl
10
+ 3. 输入为 jsonl 文件 (支持 answer 字段引导推理):
11
+ python generate_video_cot.py --input data.jsonl --output output.jsonl
12
+ 4. 输入为 Video-R1 格式 json 文件:
13
+ python generate_video_cot.py --input Video-R1-260k.json --output output.jsonl --video_root /path/to/videos
14
+ 5. 支持断点续跑:
15
+ python generate_video_cot.py --input data.jsonl --output output.jsonl --resume
16
+
17
+ 输入 jsonl 格式 (每行一个 json):
18
+ {"video": "/path/to/video.mp4", "question": "What is the velocity?", "answer": "3 m/s"}
19
+ answer 字段可选; 有 answer 时模型会生成指向该答案的推理链
20
+
21
+ Video-R1 json 格式 (自动转换):
22
+ [{"path": "...", "problem": "...", "options": [...], "solution": "<answer>A</answer>"}, ...]
23
+ """
24
+
25
+ import base64
26
+ import json
27
+ import argparse
28
+ import math
29
+ import os
30
+ import re
31
+ import time
32
+ from pathlib import Path
33
+ from concurrent.futures import ThreadPoolExecutor, as_completed
34
+
35
+ import cv2
36
+
37
+ from openai import OpenAI
38
+ from tqdm import tqdm
39
+
40
+ # ============================================================
41
+ # CoT System Prompt — Reference-Frame + Delta (Ref-Δ) Paradigm
42
+ #
43
+ # 核心思想: 用 "参考系(锚点帧) + 动态变化量(Δ)" 的范式来对抗
44
+ # 静态先验捷径(Static Prior Shortcuts)。
45
+ # 模型必须先建立视觉锚点, 再显式追踪相对于锚点的变化(delta),
46
+ # 从而迫使推理基于真实视频演变, 而非背景+语言常识盲猜。
47
+ #
48
+ # 提取方式:
49
+ # 锚点帧: re.findall(r"Reference frame at <time>(.*?)</time>:\s*(.*?)(?=Reference frame at|$)", text, re.DOTALL)
50
+ # 变化量: re.findall(r"<time_range>(.*?)</time_range>.*?<delta>(.*?)</delta>", text, re.DOTALL)
51
+ # ============================================================
52
+
53
+ # ===================== v4 prompt (已弃用, 保留备份) =====================
54
+ # SYSTEM_PROMPT_GUIDED_V4 = """\
55
+ # Adopt the persona of an expert video analyst tasked with uncovering the true "Semantic Flow" of a video. \
56
+ # Your primary goal is to counteract common AI flaws: "single-frame bias" (jumping to conclusions from \
57
+ # one static image) and "background bias" (over-relying on the scene's setting rather than the actual action). \
58
+ # To do this, you must focus exclusively on the dynamic visual changes (deltas) across time, \
59
+ # strictly ignoring static background elements unless they interact with the main subject. \
60
+ # CRITICAL: The video frames have a precise timestamp watermarked in the top-left corner \
61
+ # in the format of HH:MM:SS. You MUST read these watermarked timestamps directly from \
62
+ # the video frames and use ONLY the exact timestamps you actually observe in the watermark. \
63
+ # Do NOT estimate, interpolate, round, or fabricate any timestamps — every timestamp you \
64
+ # cite in <time> or <time_range> tags must be one you can literally see on a video frame.
65
+ # {fps_constraint}
66
+ # Formatting Rules:
67
+ # 1. Thinking Block: Write your detailed thought process within <think> and </think> tags. \
68
+ # Present a continuous, logical analysis of the video's progression, moving smoothly from \
69
+ # the beginning to the end without abrupt shifts or artificial conversational fillers.
70
+ # 2. Cohesive Prose: Your thought process must be written in flowing paragraphs. \
71
+ # Avoid disjointed bullet points or fragmented lists to ensure a complete, unbroken narrative of the events.
72
+ # 3. Reference Frame (Anchor): When you first observe the scene, or when the scene changes \
73
+ # significantly (cut, new subject, environment shift), establish an anchor using this exact pattern: \
74
+ # "Reference frame at <time>HH:MM:SS</time>: [static description of subject positions, postures, \
75
+ # held objects, spatial relationships at this exact moment]." \
76
+ # The timestamp inside <time> MUST be copied exactly from the watermark visible on that frame — \
77
+ # do not guess or approximate. \
78
+ # The first reference frame should appear at the beginning of your analysis. \
79
+ # You may establish multiple reference frames throughout the video when the scene resets or shifts.
80
+ # 4. Dynamic Change (Delta): When describing how things change over time, use this pattern: \
81
+ # "From <time_range>HH:MM:SS - HH:MM:SS</time_range>, <delta>[description of what changed, \
82
+ # moved, or transformed relative to the most recent reference frame]</delta>." \
83
+ # Both the start and end timestamps in <time_range> MUST be exact watermarked timestamps \
84
+ # you can see on actual video frames — never interpolate between frames or invent timestamps. \
85
+ # Focus only on what changed — do not describe static background. \
86
+ # Each delta should clearly connect back to its preceding reference frame.
87
+ # 5. Anti-Bias Continuity: Build your reasoning seamlessly from one reference frame and its \
88
+ # deltas to the next. Do not describe stationary room decor. Prove your final conclusion by \
89
+ # connecting the sequence of temporal deltas into a complete logical chain.
90
+ # 6. Answer Block: After the </think> block, provide the final concise answer inside \
91
+ # <answer> and </answer> tags.
92
+ # 7. Key Frame/Range Block: After the answer, include a block using <key_frame> and </key_frame> \
93
+ # tags where you point out the specific timestamp(s) or time range(s) of the critical video frames \
94
+ # without which the question cannot be answered.
95
+ #
96
+ # Example output structure:
97
+ #
98
+ # <think>
99
+ # Reference frame at <time>00:00:00</time>: a person stands at a table holding a red cup \
100
+ # in their right hand, with a white bowl positioned to the left.
101
+ #
102
+ # The action begins immediately. From <time_range>00:00:00 - 00:00:02</time_range>, \
103
+ # <delta>the person lifts the red cup from the table and tilts it toward the bowl on the left</delta>. \
104
+ # The motion is deliberate, suggesting an intentional pouring action.
105
+ #
106
+ # Continuing the flow, from <time_range>00:00:02 - 00:00:04</time_range>, \
107
+ # <delta>the cup is now fully inverted and liquid streams steadily into the bowl</delta>. \
108
+ # This confirms the pouring interpretation.
109
+ #
110
+ # The scene then resets. Reference frame at <time>00:00:05</time>: the cup is back upright \
111
+ # on the table, and the bowl is now visibly full of liquid.
112
+ #
113
+ # From <time_range>00:00:05 - 00:00:07</time_range>, \
114
+ # <delta>the person pushes the bowl forward across the table toward the opposite edge</delta>.
115
+ #
116
+ # Connecting the delta chain: the person poured liquid from cup to bowl, then pushed the bowl away.
117
+ # </think>
118
+ #
119
+ # <answer>The person poured liquid from the cup into the bowl.</answer>
120
+ #
121
+ # <key_frame>00:00:02 - 00:00:04, 00:00:05</key_frame>
122
+ #
123
+ # Here is your question:
124
+ # {question}
125
+ #
126
+ # The final answer is provided below. Use it as a reference to guide your thinking process. \
127
+ # You MUST logically arrive at this correct conclusion by connecting the dynamic temporal \
128
+ # deltas in a continuous, well-reasoned flow.
129
+ # {answer}"""
130
+ # ===================== end v4 prompt =====================
131
+
132
+ # 有正确答案时使用 (answer-guided) — v5 精简版
133
+ SYSTEM_PROMPT_GUIDED = """\
134
+ You are an expert video analyst. Analyze the "Semantic Flow" of a video by \
135
+ tracking dynamic changes across time. Ignore static backgrounds unless they \
136
+ interact with the main subject.
137
+
138
+ CRITICAL: Video frames have HH:MM:SS timestamps watermarked in the top-left \
139
+ corner. Use ONLY exact timestamps you observe — never estimate or fabricate.
140
+ {fps_constraint}
141
+ Output format:
142
+ 1. Reference Frame: "Reference frame at <time>HH:MM:SS</time>: [brief description]."
143
+ 2. Delta: "From <time_range>HH:MM:SS - HH:MM:SS</time_range>, <delta>[what changed]</delta>."
144
+ 3. Reasoning Summary: "<reasoning_summary>[connect deltas to answer]</reasoning_summary>"
145
+ 4. Answer: "<answer>concise answer</answer>"
146
+
147
+ Example:
148
+ Reference frame at <time>00:00:00</time>: a person holds a red cup, white bowl to the left.
149
+ From <time_range>00:00:00 - 00:00:03</time_range>, <delta>the person tilts the cup and pours liquid into the bowl</delta>.
150
+ From <time_range>00:00:03 - 00:00:05</time_range>, <delta>the person pushes the filled bowl forward</delta>.
151
+ <reasoning_summary>The person poured liquid from cup to bowl, then pushed it away.</reasoning_summary>
152
+ <answer>The person poured liquid into the bowl.</answer>
153
+
154
+ Cover the entire video timeline. Each delta must describe a different change — \
155
+ never repeat previous observations. If an action repeats, summarize it in one \
156
+ delta instead of describing each repetition. Keep your analysis concise.
157
+
158
+ {hint}Question: {question}
159
+
160
+ The correct answer is given below. You MUST logically arrive at this conclusion \
161
+ by connecting the temporal deltas.
162
+ {answer}"""
163
+
164
+ # 无正确答案时使用 (free reasoning) — v5 精简版
165
+ SYSTEM_PROMPT_FREE = """\
166
+ You are an expert video analyst. Analyze the "Semantic Flow" of a video by \
167
+ tracking dynamic changes across time. Ignore static backgrounds unless they \
168
+ interact with the main subject.
169
+
170
+ CRITICAL: Video frames have HH:MM:SS timestamps watermarked in the top-left \
171
+ corner. Use ONLY exact timestamps you observe — never estimate or fabricate.
172
+ {fps_constraint}
173
+ Output format:
174
+ 1. Reference Frame: "Reference frame at <time>HH:MM:SS</time>: [brief description]."
175
+ 2. Delta: "From <time_range>HH:MM:SS - HH:MM:SS</time_range>, <delta>[what changed]</delta>."
176
+ 3. Reasoning Summary: "<reasoning_summary>[connect deltas to answer]</reasoning_summary>"
177
+ 4. Answer: "<answer>concise answer</answer>"
178
+
179
+ Example:
180
+ Reference frame at <time>00:00:00</time>: a person holds a red cup, white bowl to the left.
181
+ From <time_range>00:00:00 - 00:00:03</time_range>, <delta>the person tilts the cup and pours liquid into the bowl</delta>.
182
+ From <time_range>00:00:03 - 00:00:05</time_range>, <delta>the person pushes the filled bowl forward</delta>.
183
+ <reasoning_summary>The person poured liquid from cup to bowl, then pushed it away.</reasoning_summary>
184
+ <answer>The person poured liquid into the bowl.</answer>
185
+
186
+ Cover the entire video timeline. Each delta must describe a different change — \
187
+ never repeat previous observations. If an action repeats, summarize it in one \
188
+ delta instead of describing each repetition. Keep your analysis concise.
189
+
190
+ {hint}Question: {question}"""
191
+
192
+ # ============================================================
193
+ # Dimension-specific hints (inserted before Question:)
194
+ # ============================================================
195
+ HINT_SPEED = "NOTE: This is a speed-related question. Your analysis should reflect how fast or slow the action is happening in the video.\n"
196
+ HINT_DIRECTION = "NOTE: This is a direction-related question. Your analysis should reflect which direction the subject is moving in the video.\n"
197
+ HINT_TEMPORAL = "NOTE: This question asks about temporal order. Your analysis should reflect whether the sequence of events flows naturally forward or appears reversed.\n"
198
+
199
+ DEFAULT_QUESTION = "Describe and analyze what is happening in this video step by step."
200
+
201
+ VIDEO_EXTENSIONS = {".mp4", ".avi", ".mkv", ".mov", ".webm", ".flv"}
202
+
203
+ MIME_MAP = {
204
+ ".mp4": "video/mp4", ".avi": "video/avi", ".mkv": "video/x-matroska",
205
+ ".mov": "video/quicktime", ".webm": "video/webm", ".flv": "video/x-flv",
206
+ }
207
+
208
+
209
+ def _smart_nframes(total_frames: int, video_fps: float, max_frames: int,
210
+ sample_fps: float = 2.0) -> int:
211
+ """复现 qwen_vl_utils.vision_process.smart_nframes 的完整逻辑
212
+
213
+ ms-swift (Qwen2.5-VL / Qwen3.5) 的实际抽帧流程:
214
+ 1. 按目标采样率(默认2FPS)算出理想帧数: total_frames / video_fps * sample_fps
215
+ 2. clamp 到 [min_frames=4, max_frames] 区间
216
+ 3. 向下取到 FRAME_FACTOR=2 的倍数 (帧数必须是偶数)
217
+
218
+ 参数:
219
+ total_frames: 视频原始总帧数
220
+ video_fps: 视频原始帧率
221
+ max_frames: 最大采样帧数 (对应 FPS_MAX_FRAMES 环境变量, 默认32)
222
+ sample_fps: 目标采样帧率 (qwen_vl_utils 默认 2.0)
223
+ """
224
+ FRAME_FACTOR = 2
225
+ min_frames = math.ceil(4 / FRAME_FACTOR) * FRAME_FACTOR # = 4
226
+ max_frames = math.floor(min(max_frames, total_frames) / FRAME_FACTOR) * FRAME_FACTOR
227
+
228
+ nframes = total_frames / video_fps * sample_fps
229
+ nframes = min(min(max(nframes, min_frames), max_frames), total_frames)
230
+ nframes = math.floor(nframes / FRAME_FACTOR) * FRAME_FACTOR
231
+
232
+ # 安全边界
233
+ nframes = max(nframes, FRAME_FACTOR)
234
+ nframes = min(nframes, total_frames)
235
+
236
+ return int(nframes)
237
+
238
+
239
+ def _get_video_actual_fps(video_path: str, max_frames: int = 32) -> float:
240
+ """根据视频实际时长, 用 smart_nframes 计算 ms-swift 的真实采样率"""
241
+ cap = cv2.VideoCapture(video_path)
242
+ total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
243
+ native_fps = cap.get(cv2.CAP_PROP_FPS)
244
+ cap.release()
245
+
246
+ if native_fps <= 0 or total_frames <= 0:
247
+ return 2.0 # fallback
248
+
249
+ duration = total_frames / native_fps
250
+ sampled = _smart_nframes(total_frames, native_fps, max_frames)
251
+ return sampled / duration if duration > 0 else 2.0
252
+
253
+
254
+ def _build_fps_constraint(fps: float) -> str:
255
+ """根据实际抽帧率生成时间戳约束段落 (宽松措辞, 以水印为准)"""
256
+ interval = 1.0 / fps
257
+ return (
258
+ f"\nIMPORTANT: The video frames you see have been sampled at approximately "
259
+ f"{fps:.1f} FPS (roughly one frame every {interval:.1f}s). "
260
+ f"The timestamps watermarked on each frame reflect the actual frame times. "
261
+ f"Always use the exact watermark timestamps you observe — "
262
+ f"do not invent, interpolate, or round timestamps to values "
263
+ f"that do not appear in the watermark.\n"
264
+ )
265
+
266
+
267
+ def build_messages(video_path: str, question: str, answer: str = None, max_frames: int = 32, hint: str = "") -> list:
268
+ """构建包含视频的多模态消息 (base64 编码本地文件)
269
+
270
+ answer: 若提供, 使用 answer-guided prompt 引导模型推理到正确答案;
271
+ 否则使用 free reasoning prompt 自由推理。
272
+ question 和 answer 嵌入 system prompt, user 消息仅含视频。
273
+ max_frames: 对应 FPS_MAX_FRAMES, 用于动态计算实际采样率。
274
+ hint: 维度专项提示,插入到 Question: 前面,空字符串表示不加提示。
275
+ """
276
+ path = Path(video_path).resolve()
277
+ mime = MIME_MAP.get(path.suffix.lower(), "video/mp4")
278
+ with open(path, "rb") as f:
279
+ b64 = base64.b64encode(f.read()).decode("utf-8")
280
+ video_url = f"data:{mime};base64,{b64}"
281
+
282
+ actual_fps = _get_video_actual_fps(video_path, max_frames)
283
+ fps_constraint = _build_fps_constraint(actual_fps)
284
+ hint_str = hint + "\n" if hint else ""
285
+
286
+ if answer is not None:
287
+ system = SYSTEM_PROMPT_GUIDED.format(question=question, answer=answer, fps_constraint=fps_constraint, hint=hint_str)
288
+ else:
289
+ system = SYSTEM_PROMPT_FREE.format(question=question, fps_constraint=fps_constraint, hint=hint_str)
290
+
291
+ return [
292
+ {"role": "system", "content": system},
293
+ {
294
+ "role": "user",
295
+ "content": [
296
+ {"type": "video_url", "video_url": {"url": video_url}},
297
+ {"type": "text", "text": "Please analyze the video and answer the question."},
298
+ ],
299
+ },
300
+ ]
301
+
302
+
303
+ def generate_single(
304
+ client: OpenAI,
305
+ model: str,
306
+ video_path: str,
307
+ question: str,
308
+ max_tokens: int,
309
+ temperature: float,
310
+ answer: str = None,
311
+ max_frames: int = 32,
312
+ hint: str = "",
313
+ ) -> str:
314
+ """对单个视频生成 CoT"""
315
+ messages = build_messages(video_path, question, answer, max_frames=max_frames, hint=hint)
316
+ response = client.chat.completions.create(
317
+ model=model,
318
+ messages=messages,
319
+ max_tokens=max_tokens,
320
+ temperature=temperature,
321
+ )
322
+ return response.choices[0].message.content
323
+
324
+
325
+ # ============================================================
326
+ # Video-R1 格式转换
327
+ # ============================================================
328
+ def _extract_answer(solution: str) -> str:
329
+ """从 '<answer>A</answer>' 中提取答案文本"""
330
+ m = re.search(r"<answer>(.*?)</answer>", solution, re.DOTALL)
331
+ return m.group(1).strip() if m else solution.strip()
332
+
333
+
334
+ def load_video_r1(json_path: str, video_root: str, default_question: str) -> list:
335
+ """加载 Video-R1 格式 json, 转换为统一 item 格式"""
336
+ root = Path(video_root) if video_root else Path(".")
337
+ with open(json_path, encoding="utf-8") as f:
338
+ data = json.load(f)
339
+ items = []
340
+ for entry in data:
341
+ # 视频路径: video_root / entry["path"] (去掉开头的 ./)
342
+ rel = entry.get("path", "").lstrip("./")
343
+ video = str(root / rel)
344
+
345
+ # 问题: problem + options
346
+ problem = entry.get("problem", default_question)
347
+ options = entry.get("options", [])
348
+ if options:
349
+ question = problem.rstrip() + "\n" + "\n".join(options)
350
+ else:
351
+ question = problem
352
+
353
+ # 答案
354
+ solution = entry.get("solution", "")
355
+ answer = _extract_answer(solution) if solution else None
356
+
357
+ item = {"video": video, "question": question}
358
+ if answer:
359
+ item["answer"] = answer
360
+ # 保留原始字段供输出追溯
361
+ if "problem_id" in entry:
362
+ item["problem_id"] = entry["problem_id"]
363
+ items.append(item)
364
+ return items
365
+
366
+
367
+ # ============================================================
368
+ # 通用输入加载
369
+ # ============================================================
370
+ def load_inputs(input_path: str, default_question: str, video_root: str = None) -> list:
371
+ """
372
+ 支持格式:
373
+ 1. 视频文件目录
374
+ 2. 单个视频文件
375
+ 3. jsonl 文件: 每行 {"video", "question"[, "answer"]}
376
+ 4. Video-R1 json 文件: [{"path", "problem", "options", "solution"}, ...]
377
+ """
378
+ path = Path(input_path)
379
+ items = []
380
+
381
+ if path.is_dir():
382
+ for f in sorted(path.rglob("*")):
383
+ if f.suffix.lower() in VIDEO_EXTENSIONS:
384
+ items.append({"video": str(f), "question": default_question})
385
+
386
+ elif path.is_file() and path.suffix.lower() in VIDEO_EXTENSIONS:
387
+ items.append({"video": str(path), "question": default_question})
388
+
389
+ elif path.suffix == ".jsonl":
390
+ with open(path, encoding="utf-8") as f:
391
+ for line in f:
392
+ line = line.strip()
393
+ if not line:
394
+ continue
395
+ item = json.loads(line)
396
+ item.setdefault("question", default_question)
397
+ items.append(item)
398
+
399
+ elif path.suffix == ".json":
400
+ with open(path, encoding="utf-8") as f:
401
+ data = json.load(f)
402
+ if not isinstance(data, list):
403
+ raise ValueError(f"JSON file should contain a list, got {type(data)}")
404
+ # 自动检测是否为 Video-R1 格式 (含 "path" 和 "problem" 字段)
405
+ if data and "path" in data[0] and "problem" in data[0]:
406
+ items = load_video_r1(input_path, video_root or ".", default_question)
407
+ else:
408
+ for item in data:
409
+ item.setdefault("question", default_question)
410
+ items.append(item)
411
+ else:
412
+ raise ValueError(f"Unsupported input format: {path.suffix}")
413
+
414
+ return items
415
+
416
+
417
+ def load_processed(output_path: str) -> set:
418
+ """加载已处理的视频路径 (用于断点续跑)"""
419
+ processed = set()
420
+ if Path(output_path).exists():
421
+ with open(output_path, encoding="utf-8") as f:
422
+ for line in f:
423
+ line = line.strip()
424
+ if not line:
425
+ continue
426
+ entry = json.loads(line)
427
+ processed.add(entry.get("video", ""))
428
+ return processed
429
+
430
+
431
+ # ============================================================
432
+ # 处理流程
433
+ # ============================================================
434
+ def _make_result(item: dict) -> dict:
435
+ result = {"video": item["video"], "question": item["question"]}
436
+ if "answer" in item:
437
+ result["answer"] = item["answer"]
438
+ if "problem_id" in item:
439
+ result["problem_id"] = item["problem_id"]
440
+ return result
441
+
442
+
443
+ def process_sequential(client, model, items, output_path, max_tokens, temperature, mode, max_frames, hint):
444
+ with open(output_path, mode, encoding="utf-8") as fout:
445
+ for item in tqdm(items, desc="Generating CoT"):
446
+ result = _make_result(item)
447
+ try:
448
+ result["response"] = generate_single(
449
+ client, model,
450
+ item["video"], item["question"],
451
+ max_tokens, temperature,
452
+ answer=item.get("answer"),
453
+ max_frames=max_frames,
454
+ hint=hint,
455
+ )
456
+ except Exception as e:
457
+ print(f"\n[ERROR] {item['video']}: {e}")
458
+ result["error"] = str(e)
459
+ fout.write(json.dumps(result, ensure_ascii=False) + "\n")
460
+ fout.flush()
461
+
462
+
463
+ def process_parallel(client, model, items, output_path, max_tokens, temperature, mode, workers, max_frames, hint):
464
+ with open(output_path, mode, encoding="utf-8") as fout:
465
+ with ThreadPoolExecutor(max_workers=workers) as executor:
466
+ futures = {
467
+ executor.submit(
468
+ generate_single,
469
+ client, model,
470
+ item["video"], item["question"],
471
+ max_tokens, temperature,
472
+ item.get("answer"),
473
+ max_frames,
474
+ hint,
475
+ ): item
476
+ for item in items
477
+ }
478
+ for future in tqdm(as_completed(futures), total=len(futures), desc="Generating CoT"):
479
+ item = futures[future]
480
+ result = _make_result(item)
481
+ try:
482
+ result["response"] = future.result()
483
+ except Exception as e:
484
+ print(f"\n[ERROR] {item['video']}: {e}")
485
+ result["error"] = str(e)
486
+ fout.write(json.dumps(result, ensure_ascii=False) + "\n")
487
+ fout.flush()
488
+
489
+
490
+ def main():
491
+ parser = argparse.ArgumentParser(
492
+ description="批量视频 CoT 数据生成 (Qwen3.5 + ms-swift)",
493
+ formatter_class=argparse.RawDescriptionHelpFormatter,
494
+ )
495
+ parser.add_argument("--input", required=True,
496
+ help="输入: 视频目录 / jsonl 文件 / json 文件 (含 Video-R1 格式)")
497
+ parser.add_argument("--output", required=True,
498
+ help="输出 jsonl 文件路径")
499
+ parser.add_argument("--video_root", default=None,
500
+ help="Video-R1 json 格式时, 视频文件的根目录")
501
+ parser.add_argument("--api_base", default="http://localhost:8000/v1",
502
+ help="ms-swift deploy 的 API 地址 (default: http://localhost:8000/v1)")
503
+ parser.add_argument("--model", default="Qwen3.5-122B-A10B",
504
+ help="模型名称, 需与 swift deploy 一致")
505
+ parser.add_argument("--question", default=DEFAULT_QUESTION,
506
+ help="默认问题 (当输入数据无 question 字段时使用)")
507
+ parser.add_argument("--max_tokens", type=int, default=4096,
508
+ help="最大生成 token 数 (default: 4096)")
509
+ parser.add_argument("--temperature", type=float, default=0.7,
510
+ help="生成温度 (default: 0.7)")
511
+ parser.add_argument("--workers", type=int, default=1,
512
+ help="并行请求数 (default: 1, vLLM 会自动做 batch)")
513
+ parser.add_argument("--max_frames", type=int, default=None,
514
+ help="最大采样帧数, 需与 FPS_MAX_FRAMES 环境变量一致 (默认读取环境变量, 否则 32)")
515
+ parser.add_argument("--hint", default="",
516
+ help="维度专项提示,插入到 Question: 前,可直接传字符串或使用预设值: "
517
+ "speed / direction / temporal")
518
+ parser.add_argument("--resume", action="store_true",
519
+ help="断点续跑: 跳过已处理的视频")
520
+ args = parser.parse_args()
521
+
522
+ # hint 支持预设别名
523
+ _hint_map = {
524
+ "speed": HINT_SPEED,
525
+ "direction": HINT_DIRECTION,
526
+ "temporal": HINT_TEMPORAL,
527
+ }
528
+ hint = _hint_map.get(args.hint, args.hint)
529
+
530
+ # max_frames: 优先用 CLI 参数, 其次读环境变量 FPS_MAX_FRAMES, 最后默认 32
531
+ max_frames = args.max_frames or int(os.environ.get("FPS_MAX_FRAMES", 32))
532
+
533
+ items = load_inputs(args.input, args.question, args.video_root)
534
+ print(f"[INFO] Loaded {len(items)} items")
535
+ has_answer = sum(1 for i in items if "answer" in i)
536
+ print(f"[INFO] Items with ground-truth answer: {has_answer}/{len(items)}")
537
+ print(f"[INFO] Max sampled frames per video: {max_frames} (actual FPS varies by video duration)")
538
+
539
+ mode = "w"
540
+ if args.resume:
541
+ processed = load_processed(args.output)
542
+ before = len(items)
543
+ items = [item for item in items if item["video"] not in processed]
544
+ print(f"[INFO] Resume mode: skipped {before - len(items)}, remaining {len(items)}")
545
+ mode = "a"
546
+
547
+ if not items:
548
+ print("[INFO] Nothing to process. Done!")
549
+ return
550
+
551
+ Path(args.output).parent.mkdir(parents=True, exist_ok=True)
552
+
553
+ client = OpenAI(api_key="EMPTY", base_url=args.api_base)
554
+ print(f"[INFO] Connecting to {args.api_base} ...")
555
+ try:
556
+ models = client.models.list()
557
+ print(f"[INFO] Server ready. Available models: {[m.id for m in models.data]}")
558
+ except Exception as e:
559
+ print(f"[ERROR] Cannot connect to server: {e}")
560
+ print("[HINT] Please run 'bash start_server.sh' first.")
561
+ return
562
+
563
+ t0 = time.time()
564
+ if args.workers <= 1:
565
+ process_sequential(client, args.model, items, args.output,
566
+ args.max_tokens, args.temperature, mode, max_frames, hint)
567
+ else:
568
+ process_parallel(client, args.model, items, args.output,
569
+ args.max_tokens, args.temperature, mode, args.workers, max_frames, hint)
570
+
571
+ elapsed = time.time() - t0
572
+ print(f"\n[DONE] Results saved to {args.output}")
573
+ print(f"[DONE] Processed {len(items)} videos in {elapsed:.1f}s "
574
+ f"({elapsed / len(items):.1f}s per video)")
575
+
576
+
577
+ if __name__ == "__main__":
578
+ main()
579
+
580
+
581
+ # tmux send-keys -t cot_gen C-c 2>/dev/null; sleep 1; tmux send-keys -t cot_gen "cd /root/zwj/CoT_generate && python generate_video_cot.py --input /root/zwj/CoT_generate/output/need_rerun_v2.jsonl --output /root/zwj/CoT_generate/output/need_rerun_v2_cot.jsonl --max_frames 768 --workers 4 --resume" Enter
cot_generate/rl_data/08_clean_rl_data.py ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 数据清洗脚本:从 07_oracle_results_nothink + 05_delta_frame_mapping 生成 RL 训练数据
3
+
4
+ 过滤策略:
5
+ 1. 非多选题(answer 不符合 A/A.xxx 格式)→ 丢弃
6
+ 2. oracle_results 为空(推理失败)→ 丢弃
7
+ 3. 单 pattern 条目(1个delta)→ 直接保留
8
+ 4. 多 pattern 条目(2+个delta)→ 过滤掉含异常 oracle_answer 的 pattern
9
+ 异常定义:oracle_answer 不是单个字母 A-E
10
+ """
11
+
12
+ import json
13
+ from pathlib import Path
14
+
15
+ DATA_DIR = Path(__file__).resolve().parent
16
+
17
+ ORACLE_FILE = DATA_DIR / "07_oracle_results_nothink.json"
18
+ DELTA_FILE = DATA_DIR / "05_delta_frame_mapping.json"
19
+ OUTPUT_FILE = DATA_DIR / "08_rl_training_data.json"
20
+
21
+ VALID_ANSWERS = set("ABCDE")
22
+
23
+
24
+ def is_multiple_choice(answer: str) -> bool:
25
+ """判断是否为标准多选题格式:A / A. xxx / A xxx"""
26
+ ans = answer.strip()
27
+ return (len(ans) == 1 and ans in VALID_ANSWERS) or \
28
+ (len(ans) >= 2 and ans[0] in VALID_ANSWERS and ans[1] in ". ")
29
+
30
+
31
+ def is_valid_oracle_answer(answer: str) -> bool:
32
+ """oracle_answer 是否为合法的单字母选项"""
33
+ return answer.strip() in VALID_ANSWERS
34
+
35
+
36
+ def main():
37
+ # 加载 delta frame mapping
38
+ with open(DELTA_FILE) as f:
39
+ delta_data = json.load(f)
40
+ delta_map = {m["problem_id"]: m for m in delta_data["mappings"]}
41
+ print(f"[Delta] 加载 {len(delta_map)} 条")
42
+
43
+ # 加载 oracle results,同时构建 oracle 查找表
44
+ with open(ORACLE_FILE) as f:
45
+ oracle_data = json.load(f)
46
+ oracle_results = oracle_data["results"]
47
+ print(f"[Oracle] 加载 {len(oracle_results)} 条")
48
+
49
+ # 构建查找表:(problem_id, mask_delta_id) -> oracle entry
50
+ oracle_map = {}
51
+ for r in oracle_results:
52
+ pid = r["problem_id"]
53
+ for o in r.get("oracle_results", []):
54
+ oracle_map[(pid, o["mask_delta_id"])] = o
55
+
56
+ stats = {
57
+ "total_problems": len(oracle_results),
58
+ "skipped_not_mc": 0,
59
+ "skipped_empty_oracle": 0,
60
+ "skipped_no_delta": 0,
61
+ "output_problems": 0,
62
+ "single_pattern_kept": 0,
63
+ "multi_pattern_kept": 0,
64
+ "multi_pattern_abnormal_removed": 0,
65
+ "total_mask_patterns": 0,
66
+ "oracle_correct_count": 0,
67
+ }
68
+
69
+ training_data = []
70
+
71
+ for problem in oracle_results:
72
+ pid = problem["problem_id"]
73
+
74
+ # 过滤1:非多选题
75
+ if not is_multiple_choice(problem["gt_answer"]):
76
+ stats["skipped_not_mc"] += 1
77
+ continue
78
+
79
+ # 过滤2:oracle_results 为空
80
+ if not problem["oracle_results"]:
81
+ stats["skipped_empty_oracle"] += 1
82
+ continue
83
+
84
+ # 过滤3:没有 delta mapping
85
+ delta_item = delta_map.get(pid)
86
+ if delta_item is None:
87
+ stats["skipped_no_delta"] += 1
88
+ continue
89
+
90
+ delta_mask_patterns = delta_item.get("mask_patterns", [])
91
+ n_patterns = len(delta_mask_patterns)
92
+
93
+ # 构建 mask_patterns
94
+ mask_patterns = []
95
+ for p in delta_mask_patterns:
96
+ mid = p["mask_delta_id"]
97
+ oracle_entry = oracle_map.get((pid, mid))
98
+ oracle_correct = oracle_entry["oracle_correct"] if oracle_entry else None
99
+
100
+ # 多 pattern 时,过滤掉异常 oracle_answer 的 pattern
101
+ if n_patterns > 1 and oracle_entry is not None:
102
+ if not is_valid_oracle_answer(oracle_entry["oracle_answer"]):
103
+ stats["multi_pattern_abnormal_removed"] += 1
104
+ continue
105
+
106
+ pattern = {
107
+ "mask_delta_id": mid,
108
+ "zero_frame_indices": p["zero_frame_indices"],
109
+ "remaining_frames": p["remaining_frames"],
110
+ "mask_ratio": p["mask_ratio"],
111
+ "oracle_correct": oracle_correct,
112
+ }
113
+ mask_patterns.append(pattern)
114
+ stats["total_mask_patterns"] += 1
115
+ if oracle_correct:
116
+ stats["oracle_correct_count"] += 1
117
+
118
+ # 过滤掉清洗后 mask_patterns 为空的条目
119
+ if not mask_patterns:
120
+ continue
121
+
122
+ entry = {
123
+ "problem_id": pid,
124
+ "video": problem["video_path"],
125
+ "question": problem["question"],
126
+ "answer": problem["gt_answer"],
127
+ "n_sampled_frames": problem["n_sampled_frames"],
128
+ "mask_patterns": mask_patterns,
129
+ }
130
+ training_data.append(entry)
131
+ stats["output_problems"] += 1
132
+
133
+ if n_patterns == 1:
134
+ stats["single_pattern_kept"] += 1
135
+ else:
136
+ stats["multi_pattern_kept"] += 1
137
+
138
+ # 写出
139
+ n_total_p = stats["total_mask_patterns"]
140
+ output = {
141
+ "metadata": {
142
+ "total_entries": len(training_data),
143
+ "total_mask_patterns": n_total_p,
144
+ "oracle_correct_count": stats["oracle_correct_count"],
145
+ "oracle_correct_rate": round(stats["oracle_correct_count"] / n_total_p, 3) if n_total_p else 0,
146
+ "oracle_source": ORACLE_FILE.name,
147
+ "delta_source": DELTA_FILE.name,
148
+ },
149
+ "data": training_data,
150
+ }
151
+
152
+ with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
153
+ json.dump(output, f, ensure_ascii=False, indent=2)
154
+
155
+ print(f"\n{'='*50}")
156
+ print(f"清洗完成,输出到 {OUTPUT_FILE.name}")
157
+ print(f"{'='*50}")
158
+ for k, v in stats.items():
159
+ print(f" {k}: {v}")
160
+
161
+
162
+ if __name__ == "__main__":
163
+ main()
cot_generate/rl_data/09_convert_to_training_format.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 格式转换:将 08_rl_training_data.json 转换为 DM-GRPO 训练所需格式
3
+
4
+ 目标格式(对齐 rl_delta_mask_training_data_clean.json):
5
+ {
6
+ "problem_id": 10,
7
+ "problem": "What are the first two ingredients shown in the video?",
8
+ "data_type": "video",
9
+ "problem_type": "multiple choice",
10
+ "options": ["A. Potato and garlic", "B. Potato and onion", ...],
11
+ "solution": "<answer>B</answer>",
12
+ "path": "./LLaVA-Video-178K/.../video.mp4", # 相对路径
13
+ "data_source": "",
14
+ "video_duration": 32.7,
15
+ "n_sampled_frames": 16,
16
+ "mask_patterns": [...]
17
+ }
18
+ """
19
+
20
+ import json
21
+ import re
22
+ from pathlib import Path
23
+
24
+ DATA_DIR = Path(__file__).resolve().parent
25
+ INPUT_FILE = DATA_DIR / "08_rl_training_data.json"
26
+ DELTA_FILE = DATA_DIR / "05_delta_frame_mapping.json"
27
+ RAW_FILE = DATA_DIR / "01_raw_input.jsonl" # 完整 question 来源
28
+ OUTPUT_FILE = DATA_DIR / "09_rl_training_data_formatted.json"
29
+
30
+ # video 绝对路径的根前缀,转成相对路径时去掉
31
+ VIDEO_ROOT = "/root/zwj/final_dataset/videos_timestamped"
32
+
33
+
34
+ def parse_question_and_options(question_text: str):
35
+ """
36
+ 把含选项的 question 拆分成 problem(纯题干)和 options 列表
37
+
38
+ 输入示例:
39
+ "What are the first two ingredients?\nA. Potato and garlic\nB. Potato and onion\nC. ..."
40
+ 输出:
41
+ problem = "What are the first two ingredients?"
42
+ options = ["A. Potato and garlic", "B. Potato and onion", ...]
43
+ """
44
+ lines = question_text.strip().split("\n")
45
+ option_pattern = re.compile(r"^[A-E][.、\s]")
46
+
47
+ problem_lines = []
48
+ options = []
49
+ in_options = False
50
+
51
+ for line in lines:
52
+ line = line.strip()
53
+ if not line:
54
+ continue
55
+ if option_pattern.match(line):
56
+ in_options = True
57
+ options.append(line)
58
+ elif not in_options:
59
+ problem_lines.append(line)
60
+
61
+ problem = " ".join(problem_lines).strip()
62
+ return problem, options
63
+
64
+
65
+ def extract_answer_letter(answer: str) -> str:
66
+ """
67
+ 从 gt_answer 中提取单字母选项
68
+
69
+ 输入:'B. Potato and onion' 或 'B' 或 'B) xxx'
70
+ 输出:'B'
71
+ """
72
+ ans = answer.strip()
73
+ if len(ans) == 1 and ans in "ABCDE":
74
+ return ans
75
+ if len(ans) >= 1 and ans[0] in "ABCDE":
76
+ return ans[0]
77
+ return ans
78
+
79
+
80
+ def make_path_relative(video_abs_path: str) -> str:
81
+ """绝对路径转相对路径,去掉 VIDEO_ROOT 前缀"""
82
+ if video_abs_path.startswith(VIDEO_ROOT):
83
+ rel = video_abs_path[len(VIDEO_ROOT):]
84
+ # 保留 ./ 开头格式
85
+ return "." + rel
86
+ return video_abs_path
87
+
88
+
89
+ def main():
90
+ # 加载清洗后数据
91
+ with open(INPUT_FILE) as f:
92
+ d = json.load(f)
93
+ input_data = d["data"]
94
+ print(f"[Input] 加载 {len(input_data)} 条")
95
+
96
+ # 加载原始数据,获取完整 question 和 data_source
97
+ raw_map = {}
98
+ with open(RAW_FILE) as f:
99
+ for line in f:
100
+ item = json.loads(line)
101
+ raw_map[item["problem_id"]] = item
102
+ print(f"[Raw] 加载 {len(raw_map)} 条原始数据")
103
+
104
+ # 加载 delta mapping 获取 video_duration
105
+ with open(DELTA_FILE) as f:
106
+ delta_raw = json.load(f)
107
+ duration_map = {
108
+ m["problem_id"]: m["video_info"]["duration"]
109
+ for m in delta_raw["mappings"]
110
+ }
111
+ print(f"[Delta] 加载 {len(duration_map)} 条 duration 信息")
112
+
113
+ stats = {
114
+ "total": len(input_data),
115
+ "missing_duration": 0,
116
+ "question_from_raw": 0, # 用原始数据补全 question 的条数
117
+ "options_empty": 0,
118
+ "output": 0,
119
+ }
120
+
121
+ output_data = []
122
+
123
+ for item in input_data:
124
+ pid = item["problem_id"]
125
+
126
+ # 优先用原始数据的完整 question(防止截断)
127
+ raw_item = raw_map.get(pid)
128
+ question_text = raw_item["question"] if raw_item else item["question"]
129
+ if raw_item and question_text != item["question"]:
130
+ stats["question_from_raw"] += 1
131
+
132
+ # 拆分 problem 和 options
133
+ problem, options = parse_question_and_options(question_text)
134
+ if not options:
135
+ stats["options_empty"] += 1
136
+
137
+ # 提取答案字母
138
+ answer_letter = extract_answer_letter(item["answer"])
139
+ solution = f"<answer>{answer_letter}</answer>"
140
+
141
+ # 转换 video 路径
142
+ path = make_path_relative(item["video"])
143
+
144
+ # 获取 video_duration
145
+ duration = duration_map.get(pid)
146
+ if duration is None:
147
+ stats["missing_duration"] += 1
148
+ duration = 0.0
149
+
150
+ # data_source
151
+ data_source = raw_item["data_source"] if raw_item else ""
152
+
153
+ entry = {
154
+ "problem_id": pid,
155
+ "problem": problem,
156
+ "data_type": "video",
157
+ "problem_type": "multiple choice",
158
+ "options": options,
159
+ "solution": solution,
160
+ "path": path,
161
+ "data_source": data_source,
162
+ "video_duration": duration,
163
+ "n_sampled_frames": item["n_sampled_frames"],
164
+ "mask_patterns": item["mask_patterns"],
165
+ }
166
+ output_data.append(entry)
167
+ stats["output"] += 1
168
+
169
+ with open(OUTPUT_FILE, "w", encoding="utf-8") as f:
170
+ json.dump(output_data, f, ensure_ascii=False, indent=2)
171
+
172
+ print(f"\n{'='*50}")
173
+ print(f"转换完成,输出到 {OUTPUT_FILE.name}")
174
+ print(f"{'='*50}")
175
+ for k, v in stats.items():
176
+ print(f" {k}: {v}")
177
+
178
+ # 打印一条示例对比
179
+ print("\n=== 输出示例 ===")
180
+ print(json.dumps(output_data[0], ensure_ascii=False, indent=2))
181
+
182
+
183
+ if __name__ == "__main__":
184
+ main()
cot_generate/rl_data/build_delta_frame_mapping.py ADDED
@@ -0,0 +1,294 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Build delta-to-frame-index mapping for Adaptive Delta Mask.
3
+
4
+ For each sample:
5
+ 1. Parse CoT response to extract delta time ranges
6
+ 2. Load video metadata (total_frames, fps) via OpenCV
7
+ 3. Replicate Qwen2VL frame sampling logic (smart_nframes + linspace)
8
+ 4. Map each delta's time_range to sampled frame indices
9
+ 5. Generate mask patterns (which frames to zero out per delta)
10
+
11
+ Usage:
12
+ python build_delta_frame_mapping.py \
13
+ --input Example/sampled_50.jsonl \
14
+ --output Example/delta_frame_mapping.json
15
+ """
16
+
17
+ import argparse
18
+ import json
19
+ import math
20
+ import os
21
+ import re
22
+ import sys
23
+ import random
24
+
25
+ import cv2
26
+
27
+ # ---------------------------------------------------------------------------
28
+ # Replicate Qwen2VL frame sampling logic from Video-R1
29
+ # ---------------------------------------------------------------------------
30
+ FRAME_FACTOR = 2
31
+ DEFAULT_FPS = 2.0
32
+ FPS_MIN_FRAMES = 4
33
+ FPS_MAX_FRAMES_DEFAULT = 16
34
+
35
+
36
+ def smart_nframes(total_frames: int, video_fps: float,
37
+ sample_fps: float = DEFAULT_FPS,
38
+ max_frames: int = FPS_MAX_FRAMES_DEFAULT) -> int:
39
+ """Replicate qwen_vl_utils.vision_process.smart_nframes."""
40
+ min_frames = math.ceil(FPS_MIN_FRAMES / FRAME_FACTOR) * FRAME_FACTOR
41
+ max_f = math.floor(min(max_frames, total_frames) / FRAME_FACTOR) * FRAME_FACTOR
42
+ nframes = total_frames / video_fps * sample_fps
43
+ nframes = min(min(max(nframes, min_frames), max_f), total_frames)
44
+ nframes = math.floor(nframes / FRAME_FACTOR) * FRAME_FACTOR
45
+ nframes = max(nframes, FRAME_FACTOR)
46
+ nframes = min(nframes, total_frames)
47
+ return int(nframes)
48
+
49
+
50
+ def get_sampled_frame_info(video_path: str, max_frames: int = FPS_MAX_FRAMES_DEFAULT):
51
+ """Get video metadata and compute sampled frame indices + timestamps."""
52
+ cap = cv2.VideoCapture(video_path)
53
+ if not cap.isOpened():
54
+ return None
55
+
56
+ total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
57
+ video_fps = cap.get(cv2.CAP_PROP_FPS)
58
+ cap.release()
59
+
60
+ if total_frames <= 0 or video_fps <= 0:
61
+ return None
62
+
63
+ duration = total_frames / video_fps
64
+ nframes = smart_nframes(total_frames, video_fps, max_frames=max_frames)
65
+
66
+ # Replicate torch.linspace(0, total_frames-1, nframes)
67
+ if nframes == 1:
68
+ indices = [0]
69
+ else:
70
+ step = (total_frames - 1) / (nframes - 1)
71
+ indices = [round(i * step) for i in range(nframes)]
72
+
73
+ # Each sampled frame's timestamp in seconds
74
+ timestamps = [idx / video_fps for idx in indices]
75
+
76
+ return {
77
+ "total_frames": total_frames,
78
+ "video_fps": video_fps,
79
+ "duration": duration,
80
+ "n_sampled": nframes,
81
+ "sampled_indices": indices,
82
+ "sampled_timestamps": timestamps,
83
+ }
84
+
85
+
86
+ # ---------------------------------------------------------------------------
87
+ # Parse CoT response to extract deltas
88
+ # ---------------------------------------------------------------------------
89
+ def parse_timestamp(ts_str: str) -> float:
90
+ """Parse HH:MM:SS or HH:MM:SS.s to seconds."""
91
+ # Strip nested tags like <time>...</time>
92
+ ts_str = re.sub(r'<[^>]+>', '', ts_str).strip()
93
+ parts = ts_str.split(":")
94
+ if len(parts) == 3:
95
+ h, m, s = parts
96
+ return int(h) * 3600 + int(m) * 60 + float(s)
97
+ elif len(parts) == 2:
98
+ m, s = parts
99
+ return int(m) * 60 + float(s)
100
+ else:
101
+ return float(ts_str)
102
+
103
+
104
+ def parse_deltas_from_cot(response: str):
105
+ """Extract delta time ranges from CoT response.
106
+
107
+ Looks for patterns like:
108
+ From <time_range>00:00:00 - 00:00:07</time_range>, <delta>...</delta>
109
+ """
110
+ time_ranges = re.findall(r'<time_range>(.*?)</time_range>', response)
111
+ deltas_text = re.findall(r'<delta>(.*?)</delta>', response, re.DOTALL)
112
+
113
+ deltas = []
114
+ for i, tr in enumerate(time_ranges):
115
+ try:
116
+ # Try regex first: match two timestamp-like groups separated by ' - '
117
+ m = re.match(r'\s*([\d:\.]+)\s*-\s*([\d:\.]+)\s*', re.sub(r'<[^>]+>', '', tr))
118
+ if not m:
119
+ continue
120
+ start = parse_timestamp(m.group(1))
121
+ end = parse_timestamp(m.group(2))
122
+ delta_text = deltas_text[i] if i < len(deltas_text) else ""
123
+ deltas.append({
124
+ "delta_id": i,
125
+ "time_range_str": tr.strip(),
126
+ "start_sec": start,
127
+ "end_sec": end,
128
+ "description": delta_text.strip(),
129
+ })
130
+ except (ValueError, AttributeError):
131
+ continue
132
+
133
+ return deltas
134
+
135
+
136
+ # ---------------------------------------------------------------------------
137
+ # Map deltas to sampled frame indices
138
+ # ---------------------------------------------------------------------------
139
+ def map_delta_to_frames(delta, sampled_timestamps):
140
+ """Find which sampled frame indices fall within the delta's time range.
141
+
142
+ Since CoT timestamps are integer seconds, we use floor-based matching:
143
+ a frame at timestamp t belongs to delta [start, end] if
144
+ int(t) is within [start_sec, end_sec].
145
+ """
146
+ start = int(delta["start_sec"])
147
+ end = int(delta["end_sec"])
148
+ frame_indices = []
149
+ for i, ts in enumerate(sampled_timestamps):
150
+ if start <= int(ts) <= end:
151
+ frame_indices.append(i)
152
+ return frame_indices
153
+
154
+
155
+ # ---------------------------------------------------------------------------
156
+ # Main
157
+ # ---------------------------------------------------------------------------
158
+ def process_entry(entry, video_root=None, max_frames=FPS_MAX_FRAMES_DEFAULT):
159
+ """Process a single data entry."""
160
+ video_path = entry["video"]
161
+ if video_root and not os.path.isabs(video_path):
162
+ video_path = os.path.join(video_root, video_path)
163
+
164
+ if not os.path.exists(video_path):
165
+ return {"problem_id": entry["problem_id"], "error": f"Video not found: {video_path}"}
166
+
167
+ # Get frame sampling info
168
+ frame_info = get_sampled_frame_info(video_path, max_frames=max_frames)
169
+ if frame_info is None:
170
+ return {"problem_id": entry["problem_id"], "error": "Failed to read video"}
171
+
172
+ # Parse deltas from CoT
173
+ deltas = parse_deltas_from_cot(entry["response"])
174
+ if not deltas:
175
+ return {"problem_id": entry["problem_id"], "error": "No deltas found in CoT"}
176
+
177
+ # Map each delta to frame indices
178
+ for d in deltas:
179
+ d["frame_indices"] = map_delta_to_frames(d, frame_info["sampled_timestamps"])
180
+
181
+ # Generate mask patterns: one pattern per delta (zero out that delta's frames)
182
+ mask_patterns = []
183
+ all_candidates = [] # 兜底用:保存所有候选 pattern
184
+ min_remaining = 4 # 至少保留 4 帧有效内容,避免信息过少产生噪声
185
+ for d in deltas:
186
+ if d["frame_indices"]: # only if the delta maps to at least one frame
187
+ remaining = frame_info["n_sampled"] - len(d["frame_indices"])
188
+ pattern = {
189
+ "mask_delta_id": d["delta_id"],
190
+ "mask_delta_time": d["time_range_str"],
191
+ "zero_frame_indices": d["frame_indices"],
192
+ "remaining_frames": remaining,
193
+ "mask_ratio": round(len(d["frame_indices"]) / frame_info["n_sampled"], 3),
194
+ }
195
+ all_candidates.append(pattern)
196
+ if remaining >= min_remaining:
197
+ mask_patterns.append(pattern)
198
+
199
+ # 兜底:如果过滤后没有 pattern,保留剩余帧数最多的那个
200
+ if not mask_patterns and all_candidates:
201
+ best = max(all_candidates, key=lambda p: p["remaining_frames"])
202
+ mask_patterns.append(best)
203
+
204
+ result = {
205
+ "problem_id": entry["problem_id"],
206
+ "video_path": video_path,
207
+ "question": entry["question"],
208
+ "answer": entry.get("answer", ""),
209
+ "video_info": {
210
+ "total_frames": frame_info["total_frames"],
211
+ "video_fps": round(frame_info["video_fps"], 2),
212
+ "duration": round(frame_info["duration"], 2),
213
+ "n_sampled_frames": frame_info["n_sampled"],
214
+ },
215
+ "sampled_timestamps": [round(t, 2) for t in frame_info["sampled_timestamps"]],
216
+ "deltas": deltas,
217
+ "mask_patterns": mask_patterns,
218
+ }
219
+
220
+ return result
221
+
222
+
223
+ def main():
224
+ parser = argparse.ArgumentParser(description="Build delta-to-frame mapping")
225
+ parser.add_argument("--input", required=True, help="Input JSONL file with CoT data")
226
+ parser.add_argument("--output", required=True, help="Output JSON file")
227
+ parser.add_argument("--video-root", default=None, help="Root dir for relative video paths")
228
+ parser.add_argument("--max-frames", type=int, default=FPS_MAX_FRAMES_DEFAULT,
229
+ help=f"Max sampled frames, must match RL training setting (default: {FPS_MAX_FRAMES_DEFAULT})")
230
+ args = parser.parse_args()
231
+
232
+ entries = []
233
+ with open(args.input) as f:
234
+ for line in f:
235
+ line = line.strip()
236
+ if line:
237
+ entries.append(json.loads(line))
238
+
239
+ print(f"Processing {len(entries)} entries (max_frames={args.max_frames})...")
240
+
241
+ results = []
242
+ errors = []
243
+ for i, entry in enumerate(entries):
244
+ result = process_entry(entry, args.video_root, max_frames=args.max_frames)
245
+ if "error" in result:
246
+ errors.append(result)
247
+ print(f" [{i+1}/{len(entries)}] ERROR {result['problem_id']}: {result['error']}")
248
+ else:
249
+ results.append(result)
250
+ n_deltas = len(result["deltas"])
251
+ n_patterns = len(result["mask_patterns"])
252
+ print(f" [{i+1}/{len(entries)}] OK {result['problem_id']}: "
253
+ f"{result['video_info']['n_sampled_frames']} frames, "
254
+ f"{n_deltas} deltas, {n_patterns} mask patterns")
255
+
256
+ # Summary stats
257
+ print(f"\n{'='*60}")
258
+ print(f"Total: {len(entries)} | Success: {len(results)} | Errors: {len(errors)}")
259
+ if results:
260
+ avg_deltas = sum(len(r["deltas"]) for r in results) / len(results)
261
+ avg_patterns = sum(len(r["mask_patterns"]) for r in results) / len(results)
262
+ avg_frames = sum(r["video_info"]["n_sampled_frames"] for r in results) / len(results)
263
+ mask_ratios = [p["mask_ratio"] for r in results for p in r["mask_patterns"]]
264
+ avg_mask_ratio = sum(mask_ratios) / len(mask_ratios) if mask_ratios else 0
265
+ print(f"Avg sampled frames: {avg_frames:.1f}")
266
+ print(f"Avg deltas per video: {avg_deltas:.1f}")
267
+ print(f"Avg mask patterns: {avg_patterns:.1f}")
268
+ print(f"Avg mask ratio: {avg_mask_ratio:.3f} ({avg_mask_ratio*100:.1f}%)")
269
+
270
+ # Save
271
+ output_data = {
272
+ "metadata": {
273
+ "total_entries": len(entries),
274
+ "successful": len(results),
275
+ "errors": len(errors),
276
+ "frame_sampling": {
277
+ "method": "smart_nframes (Qwen2VL)",
278
+ "max_frames": args.max_frames,
279
+ "sample_fps": DEFAULT_FPS,
280
+ },
281
+ "mask_strategy": "delta-level zero-out",
282
+ },
283
+ "mappings": results,
284
+ "errors": errors,
285
+ }
286
+
287
+ os.makedirs(os.path.dirname(args.output) or ".", exist_ok=True)
288
+ with open(args.output, "w") as f:
289
+ json.dump(output_data, f, indent=2, ensure_ascii=False)
290
+ print(f"\nSaved to {args.output}")
291
+
292
+
293
+ if __name__ == "__main__":
294
+ main()
cot_generate/rl_data/run_oracle_inference.py ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Oracle 推理脚本 — 对 masked 视频逐帧发送图片给强模型,获取 oracle 答案。
3
+
4
+ 核心逻辑:
5
+ 1. 读取 delta_frame_mapping.json(含每条数据的所有 mask pattern)
6
+ 2. 对每个 mask pattern:
7
+ - 用跟 trainer 完全一致的 smart_nframes 抽帧
8
+ - 将 delta 对应帧置零(黑帧)
9
+ - 逐帧编码为 base64 JPEG 图片
10
+ - 发给强模型 API(多图输入),获取回答
11
+ - 提取答案并与 GT 比对,记录 oracle_correct
12
+ 3. 输出带 oracle 结果的 JSON
13
+
14
+ 使用方式:
15
+ 1. 先启动 Qwen3.5 推理服务: bash start_server.sh
16
+ 2. 运行:
17
+ python run_oracle_inference.py \
18
+ --mapping Example/delta_frame_mapping.json \
19
+ --output Example/oracle_results.json \
20
+ --max-frames 16
21
+
22
+ 依赖: cv2, numpy, openai, torch
23
+ """
24
+
25
+ import argparse
26
+ import base64
27
+ import json
28
+ import math
29
+ import os
30
+ import re
31
+ import time
32
+ import threading
33
+ from concurrent.futures import ThreadPoolExecutor, as_completed
34
+ from io import BytesIO
35
+
36
+ import cv2
37
+ import numpy as np
38
+ from openai import OpenAI
39
+ from tqdm import tqdm
40
+
41
+
42
+ # ---------------------------------------------------------------------------
43
+ # Frame sampling — 与 trainer (Qwen2VL) 完全一致
44
+ # ---------------------------------------------------------------------------
45
+ FRAME_FACTOR = 2
46
+ DEFAULT_FPS = 2.0
47
+ FPS_MIN_FRAMES = 4
48
+ FPS_MAX_FRAMES_DEFAULT = 16
49
+
50
+
51
+ def smart_nframes(total_frames: int, video_fps: float,
52
+ sample_fps: float = DEFAULT_FPS,
53
+ max_frames: int = FPS_MAX_FRAMES_DEFAULT) -> int:
54
+ """Replicate qwen_vl_utils.vision_process.smart_nframes."""
55
+ min_f = math.ceil(FPS_MIN_FRAMES / FRAME_FACTOR) * FRAME_FACTOR
56
+ max_f = math.floor(min(max_frames, total_frames) / FRAME_FACTOR) * FRAME_FACTOR
57
+ n = total_frames / video_fps * sample_fps
58
+ n = min(min(max(n, min_f), max_f), total_frames)
59
+ n = math.floor(n / FRAME_FACTOR) * FRAME_FACTOR
60
+ n = max(n, FRAME_FACTOR)
61
+ n = min(n, total_frames)
62
+ return int(n)
63
+
64
+
65
+ def sample_frames(video_path: str, max_frames: int = FPS_MAX_FRAMES_DEFAULT):
66
+ """
67
+ 用跟 trainer 一致的逻辑采样帧,返回 (frames_bgr_list, sampled_timestamps).
68
+ frames_bgr_list: list of numpy arrays (H, W, 3) in BGR
69
+ sampled_timestamps: list of float (seconds)
70
+ """
71
+ cap = cv2.VideoCapture(video_path)
72
+ total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
73
+ video_fps = cap.get(cv2.CAP_PROP_FPS)
74
+
75
+ if total_frames <= 0 or video_fps <= 0:
76
+ cap.release()
77
+ raise ValueError(f"Cannot read video: {video_path}")
78
+
79
+ nframes = smart_nframes(total_frames, video_fps, max_frames=max_frames)
80
+
81
+ # linspace 采样 — 跟 torch.linspace(0, total_frames-1, nframes).round().long() 一致
82
+ indices = np.linspace(0, total_frames - 1, nframes).round().astype(int).tolist()
83
+ timestamps = [idx / video_fps for idx in indices]
84
+
85
+ frames = []
86
+ for idx in indices:
87
+ cap.set(cv2.CAP_PROP_POS_FRAMES, idx)
88
+ ret, frame = cap.read()
89
+ if ret:
90
+ frames.append(frame)
91
+ else:
92
+ # fallback: 黑帧
93
+ h = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) or 480
94
+ w = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) or 640
95
+ frames.append(np.zeros((h, w, 3), dtype=np.uint8))
96
+ cap.release()
97
+
98
+ return frames, timestamps
99
+
100
+
101
+ def apply_mask(frames, zero_frame_indices):
102
+ """将指定索引的帧置零(黑帧),返回新的 frames 列表。"""
103
+ masked = []
104
+ for i, f in enumerate(frames):
105
+ if i in set(zero_frame_indices):
106
+ masked.append(np.zeros_like(f))
107
+ else:
108
+ masked.append(f.copy())
109
+ return masked
110
+
111
+
112
+ def frames_to_base64_content(frames, quality=85):
113
+ """将帧列表编码为 OpenAI API 多图格式的 content list。"""
114
+ content = []
115
+ for frame in frames:
116
+ _, buf = cv2.imencode(".jpg", frame, [cv2.IMWRITE_JPEG_QUALITY, quality])
117
+ b64 = base64.b64encode(buf.tobytes()).decode("utf-8")
118
+ content.append({
119
+ "type": "image_url",
120
+ "image_url": {"url": f"data:image/jpeg;base64,{b64}"}
121
+ })
122
+ return content
123
+
124
+
125
+ # ---------------------------------------------------------------------------
126
+ # Oracle prompt — 简洁直接,只要求回答问题
127
+ # ---------------------------------------------------------------------------
128
+ ORACLE_SYSTEM_PROMPT = """\
129
+ You are a video understanding expert. You will be given a sequence of video frames \
130
+ (images in temporal order) and a question. Analyze the frames carefully and answer \
131
+ the question. First think about the reasoning process in <think> </think> tags, \
132
+ then provide your final answer in <answer> </answer> tags, i.e., \
133
+ <think> reasoning process here </think><answer> answer here </answer>
134
+
135
+ Here is your question:
136
+ {question}"""
137
+
138
+
139
+ def extract_answer(text: str) -> str:
140
+ """从模型输出中提取 <answer>...</answer> 内容。"""
141
+ m = re.search(r"<answer>(.*?)</answer>", text, re.DOTALL)
142
+ if m:
143
+ return m.group(1).strip()
144
+ # fallback: 取最后一行非空文本
145
+ lines = [l.strip() for l in text.strip().split("\n") if l.strip()]
146
+ return lines[-1] if lines else text.strip()
147
+
148
+
149
+ def normalize_answer(ans: str) -> str:
150
+ """标准化答案用于比较 — 取首字母/首词。"""
151
+ ans = ans.strip().rstrip(".")
152
+ # 处理 "A. xxx" 或 "A" 格式
153
+ m = re.match(r"^([A-D])\b", ans)
154
+ if m:
155
+ return m.group(1).upper()
156
+ return ans.lower()
157
+
158
+
159
+ def check_correct(oracle_answer: str, gt_answer: str) -> bool:
160
+ """比较 oracle 答案与 GT 答案是否一致。"""
161
+ o = normalize_answer(oracle_answer)
162
+ g = normalize_answer(gt_answer)
163
+ # 直接匹配
164
+ if o == g:
165
+ return True
166
+ # GT 可能是 "A" 而 oracle 是 "A. xxx"
167
+ if len(g) == 1 and g.upper() in "ABCD":
168
+ return o == g.upper()
169
+ # oracle 可能是 "A" 而 GT 是 "A. xxx"
170
+ if len(o) == 1 and o.upper() in "ABCD":
171
+ return o.upper() == normalize_answer(gt_answer)
172
+ # 包含关系
173
+ return g in o or o in g
174
+
175
+
176
+ # ---------------------------------------------------------------------------
177
+ # API 调用
178
+ # ---------------------------------------------------------------------------
179
+ def call_oracle(client, model, frames_content, question, max_tokens=1024, temperature=0.0):
180
+ """调用强模型对 masked 帧序列进行推理。"""
181
+ system = ORACLE_SYSTEM_PROMPT.format(question=question)
182
+ user_content = frames_content + [
183
+ {"type": "text", "text": "These are video frames in temporal order. Please analyze them and answer the question."}
184
+ ]
185
+ response = client.chat.completions.create(
186
+ model=model,
187
+ messages=[
188
+ {"role": "system", "content": system},
189
+ {"role": "user", "content": user_content},
190
+ ],
191
+ max_tokens=max_tokens,
192
+ temperature=temperature,
193
+ )
194
+ return response.choices[0].message.content
195
+
196
+
197
+ # ---------------------------------------------------------------------------
198
+ # Main
199
+ # ---------------------------------------------------------------------------
200
+ def process_mapping(mapping_entry, client, model, max_frames, max_tokens, temperature, retry=2):
201
+ """处理一条 mapping entry 的所有 mask patterns。"""
202
+ video_path = mapping_entry["video_path"]
203
+ question = mapping_entry["question"]
204
+ gt_answer = mapping_entry.get("answer", "")
205
+
206
+ # 采帧(只采一次,所有 mask pattern 复用)
207
+ try:
208
+ frames, timestamps = sample_frames(video_path, max_frames=max_frames)
209
+ except Exception as e:
210
+ return {"problem_id": mapping_entry["problem_id"], "error": f"sample_frames: {e}"}
211
+
212
+ results = []
213
+ for pattern in mapping_entry.get("mask_patterns", []):
214
+ mask_indices = pattern["zero_frame_indices"]
215
+
216
+ # 置零
217
+ masked_frames = apply_mask(frames, mask_indices)
218
+ frames_content = frames_to_base64_content(masked_frames)
219
+
220
+ # 调用 API(带重试)
221
+ oracle_raw = None
222
+ for attempt in range(retry + 1):
223
+ try:
224
+ oracle_raw = call_oracle(client, model, frames_content, question,
225
+ max_tokens=max_tokens, temperature=temperature)
226
+ break
227
+ except Exception as e:
228
+ if attempt < retry:
229
+ time.sleep(2 ** attempt)
230
+ else:
231
+ oracle_raw = f"[ERROR] {e}"
232
+
233
+ oracle_ans = extract_answer(oracle_raw) if not oracle_raw.startswith("[ERROR]") else ""
234
+ correct = check_correct(oracle_ans, gt_answer) if oracle_ans else False
235
+
236
+ results.append({
237
+ "mask_delta_id": pattern["mask_delta_id"],
238
+ "mask_delta_time": pattern["mask_delta_time"],
239
+ "zero_frame_indices": mask_indices,
240
+ "mask_ratio": pattern["mask_ratio"],
241
+ "oracle_raw_response": oracle_raw,
242
+ "oracle_answer": oracle_ans,
243
+ "gt_answer": gt_answer,
244
+ "oracle_correct": correct,
245
+ })
246
+
247
+ return {
248
+ "problem_id": mapping_entry["problem_id"],
249
+ "video_path": video_path,
250
+ "question": question[:100] + "..." if len(question) > 100 else question,
251
+ "gt_answer": gt_answer,
252
+ "n_sampled_frames": len(frames),
253
+ "oracle_results": results,
254
+ }
255
+
256
+
257
+ def main():
258
+ parser = argparse.ArgumentParser(
259
+ description="Oracle 推理: 对 masked 视频逐帧发图片给强模型",
260
+ )
261
+ parser.add_argument("--mapping", required=True,
262
+ help="delta_frame_mapping.json 文件路径")
263
+ parser.add_argument("--output", required=True,
264
+ help="输出 JSON 文件路径")
265
+ parser.add_argument("--max-frames", type=int, default=FPS_MAX_FRAMES_DEFAULT,
266
+ help=f"最大采样帧数,需与 RL 训练一致 (default: {FPS_MAX_FRAMES_DEFAULT})")
267
+ parser.add_argument("--api-base", default="http://localhost:8000/v1",
268
+ help="强模型 API 地��� (default: http://localhost:8000/v1)")
269
+ parser.add_argument("--model", default="Qwen3.5-122B-A10B",
270
+ help="强模型名称 (default: Qwen3.5-122B-A10B)")
271
+ parser.add_argument("--max-tokens", type=int, default=1024,
272
+ help="最大生成 token 数 (default: 1024)")
273
+ parser.add_argument("--temperature", type=float, default=0.0,
274
+ help="生成温度 (default: 0.0)")
275
+ parser.add_argument("--resume", action="store_true",
276
+ help="断点续跑:跳过已有结果的 problem_id")
277
+ parser.add_argument("--workers", type=int, default=8,
278
+ help="并发线程数 (default: 8)")
279
+ args = parser.parse_args()
280
+
281
+ # 加载 mapping
282
+ with open(args.mapping) as f:
283
+ data = json.load(f)
284
+ mappings = data["mappings"]
285
+ print(f"Loaded {len(mappings)} entries from {args.mapping}")
286
+ print(f"Settings: max_frames={args.max_frames}, model={args.model}, workers={args.workers}")
287
+
288
+ # 断点续跑:加载已完成的 problem_id
289
+ done_ids = set()
290
+ existing_results = []
291
+ if args.resume and os.path.exists(args.output):
292
+ with open(args.output) as f:
293
+ prev = json.load(f)
294
+ existing_results = prev.get("results", [])
295
+ done_ids = {r["problem_id"] for r in existing_results if "error" not in r}
296
+ print(f"Resume: skipping {len(done_ids)} already completed entries")
297
+
298
+ remaining = [m for m in mappings if m["problem_id"] not in done_ids]
299
+ print(f"To process: {len(remaining)} entries")
300
+
301
+ if not remaining:
302
+ print("Nothing to do.")
303
+ return
304
+
305
+ # 初始化 API client
306
+ client = OpenAI(base_url=args.api_base, api_key="not-needed")
307
+
308
+ # 并发处理
309
+ results = list(existing_results)
310
+ errors = []
311
+ lock = threading.Lock()
312
+ save_counter = [0] # mutable counter for save interval
313
+
314
+ def _process_one(entry):
315
+ return process_mapping(entry, client, args.model,
316
+ max_frames=args.max_frames,
317
+ max_tokens=args.max_tokens,
318
+ temperature=args.temperature)
319
+
320
+ pbar = tqdm(total=len(remaining), desc="Oracle inference")
321
+
322
+ with ThreadPoolExecutor(max_workers=args.workers) as executor:
323
+ futures = {executor.submit(_process_one, entry): entry for entry in remaining}
324
+
325
+ for future in as_completed(futures):
326
+ result = future.result()
327
+ with lock:
328
+ if "error" in result:
329
+ errors.append(result)
330
+ pbar.write(f" ERROR {result['problem_id']}: {result['error']}")
331
+ else:
332
+ n_correct = sum(1 for r in result["oracle_results"] if r["oracle_correct"])
333
+ n_total = len(result["oracle_results"])
334
+ pbar.write(f" OK {result['problem_id']}: "
335
+ f"{n_correct}/{n_total} oracle correct")
336
+ results.append(result)
337
+ save_counter[0] += 1
338
+ pbar.update(1)
339
+
340
+ # 每 10 条自动保存
341
+ if save_counter[0] % 10 == 0:
342
+ _save(args.output, results, errors, args)
343
+
344
+ pbar.close()
345
+ _save(args.output, results, errors, args)
346
+
347
+ # 统计
348
+ all_oracle = []
349
+ for r in results:
350
+ if "oracle_results" in r:
351
+ all_oracle.extend(r["oracle_results"])
352
+
353
+ n_oracle_correct = sum(1 for o in all_oracle if o.get("oracle_correct"))
354
+ print(f"\n{'='*60}")
355
+ print(f"Total entries: {len(results)} | Errors: {len(errors)}")
356
+ print(f"Total mask patterns: {len(all_oracle)}")
357
+ print(f"Oracle correct: {n_oracle_correct}/{len(all_oracle)} "
358
+ f"({n_oracle_correct/len(all_oracle)*100:.1f}%)" if all_oracle else "")
359
+ print(f"Saved to {args.output}")
360
+
361
+
362
+ def _save(output_path, results, errors, args):
363
+ """保存中间/最终结果。"""
364
+ output = {
365
+ "metadata": {
366
+ "total_entries": len(results),
367
+ "errors": len(errors),
368
+ "max_frames": args.max_frames,
369
+ "model": args.model,
370
+ "temperature": args.temperature,
371
+ },
372
+ "results": results,
373
+ }
374
+ with open(output_path, "w", encoding="utf-8") as f:
375
+ json.dump(output, f, ensure_ascii=False, indent=2)
376
+
377
+
378
+ if __name__ == "__main__":
379
+ main()
cot_generate/rl_data/select_single_pattern.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ 从 full_delta_frame_mapping.json 中为每个视频随机选取一个 mask pattern,
3
+ 输出精简版 mapping,用于加速 oracle 推理。
4
+
5
+ 随机性保证:
6
+ - 使用 os.urandom 生成种子(系统级熵源)
7
+ - 每条 entry 独立随机选取
8
+ - 打印种子方便复现
9
+
10
+ 使用方式:
11
+ python select_single_pattern.py \
12
+ --input full_delta_frame_mapping.json \
13
+ --output single_delta_frame_mapping.json
14
+ """
15
+
16
+ import argparse
17
+ import json
18
+ import os
19
+ import random
20
+
21
+
22
+ def main():
23
+ parser = argparse.ArgumentParser(
24
+ description="为每个视频随机选取一个 mask pattern"
25
+ )
26
+ parser.add_argument("--input", required=True, help="完整 mapping JSON")
27
+ parser.add_argument("--output", required=True, help="输出精简 mapping JSON")
28
+ parser.add_argument("--seed", type=int, default=None,
29
+ help="随机种子(不指定则用 os.urandom 自动生成)")
30
+ args = parser.parse_args()
31
+
32
+ # 随机种子:优先用户指定,否则用系统熵源
33
+ if args.seed is not None:
34
+ seed = args.seed
35
+ else:
36
+ seed = int.from_bytes(os.urandom(8), "big")
37
+ random.seed(seed)
38
+ print(f"Random seed: {seed} (可用 --seed {seed} 复现)")
39
+
40
+ with open(args.input) as f:
41
+ data = json.load(f)
42
+
43
+ mappings = data["mappings"]
44
+ print(f"输入: {len(mappings)} entries")
45
+
46
+ total_before = 0
47
+ total_after = 0
48
+ no_pattern = 0
49
+
50
+ for entry in mappings:
51
+ patterns = entry.get("mask_patterns", [])
52
+ total_before += len(patterns)
53
+ if patterns:
54
+ selected = random.choice(patterns)
55
+ entry["mask_patterns"] = [selected]
56
+ total_after += 1
57
+ else:
58
+ no_pattern += 1
59
+
60
+ data["metadata"]["selection"] = "single_random_pattern"
61
+ data["metadata"]["random_seed"] = seed
62
+
63
+ with open(args.output, "w", encoding="utf-8") as f:
64
+ json.dump(data, f, ensure_ascii=False, indent=2)
65
+
66
+ print(f"输出: {len(mappings)} entries")
67
+ print(f"Patterns: {total_before} → {total_after} ({total_before - total_after} 减少)")
68
+ print(f"无 pattern 的 entry: {no_pattern}")
69
+ print(f"Saved to {args.output}")
70
+
71
+
72
+ if __name__ == "__main__":
73
+ main()
cot_generate/run_generate.sh ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # ============================================================
3
+ # 视频 CoT 数据生成 - 完整流程示例
4
+ #
5
+ # 流程:
6
+ # Step 1. 给视频加时间戳水印 (add_timestamp_to_video.py)
7
+ # Step 2. 启动 Qwen3.5 推理服务 (start_server.sh)
8
+ # Step 3. 批量生成 CoT 数据 (generate_video_cot.py)
9
+ # ============================================================
10
+
11
+ set -e
12
+ cd "$(dirname "$0")"
13
+
14
+ # ==============================
15
+ # Step 1: 给视频加时间戳 (可选, 如果视频已有时间戳可跳过)
16
+ # ==============================
17
+ # python add_timestamp_to_video.py \
18
+ # --input_dir /path/to/raw_videos \
19
+ # --output_dir /path/to/timestamped_videos \
20
+ # --ext mp4
21
+
22
+ # ==============================
23
+ # Step 2: 启动推理服务 (在另一个终端运行, 等待服务就绪)
24
+ # ==============================
25
+ # bash start_server.sh
26
+ # 等待看到类似 "Uvicorn running on http://0.0.0.0:8000" 的日志
27
+
28
+ # ==============================
29
+ # Step 3: 批量生成 CoT
30
+ # ==============================
31
+
32
+ # --- 示例 A: 输入为视频目录, 使用默认问题 ---
33
+ # python generate_video_cot.py \
34
+ # --input /path/to/timestamped_videos \
35
+ # --output ./output/cot_results.jsonl
36
+
37
+ # --- 示例 B: 输入为 jsonl, 每个视频有不同的问题 ---
38
+ # python generate_video_cot.py \
39
+ # --input ./my_data.jsonl \
40
+ # --output ./output/cot_results.jsonl
41
+
42
+ # --- 示例 C: 自定义问题 + 断点续跑 ---
43
+ # python generate_video_cot.py \
44
+ # --input /path/to/timestamped_videos \
45
+ # --output ./output/cot_results.jsonl \
46
+ # --question "What is the velocity of the object in this video? Analyze its motion frame by frame." \
47
+ # --max_tokens 4096 \
48
+ # --temperature 0.7 \
49
+ # --resume
50
+
51
+ # --- 示例 D: 实际运行示例 ---
52
+ python generate_video_cot.py \
53
+ --input /path/to/your/videos \
54
+ --output ./output/cot_results.jsonl \
55
+ --question "Describe and analyze what is happening in this video step by step." \
56
+ --max_tokens 4096 \
57
+ --temperature 0.7 \
58
+ --resume
cot_generate/sft_data/filter_cot.py ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ CoT Data Filtering Script
4
+ =========================
5
+ cot_all.jsonl -> SFT-ready JSON for sft_video_v5e.py
6
+
7
+ Filter rules:
8
+ Structural:
9
+ 1. has 'error' key
10
+ 2. response empty or too short (< MIN_RESPONSE_LEN)
11
+ 3. <think> opened but never closed (truncated)
12
+ 4. <think> content too short (< MIN_THINK_LEN)
13
+ 5. no <time> / <time_range> tag
14
+ 6. no <reasoning_summary> tag
15
+ 7. </think> tail truncated or empty
16
+ 8. video file missing on disk
17
+ 9. no <answer> tag, or answer content empty
18
+ 10. no <delta> tag
19
+ 11. no "Reference frame at"
20
+ Quality:
21
+ 12. meta language ("as an AI", "I cannot process", ...)
22
+ 13. answer leakage ("answer key", "ground truth", ...)
23
+ 14. MC: pred letter unparsable (e.g. placeholder "concise answer")
24
+ 15. MC: pred letter != GT letter
25
+
26
+ Problem type (dual condition based on GT answer):
27
+ question has option lines AND GT answer resolves to A-E letter -> multiple-choice
28
+ otherwise -> free-form (even if question has options but GT is free text)
29
+
30
+ Output fields: problem_id, problem, data_type, problem_type, options,
31
+ process, solution, path, data_source
32
+ """
33
+
34
+ import json
35
+ import os
36
+ import re
37
+ import argparse
38
+
39
+ MIN_THINK_LEN = 200
40
+ MIN_RESPONSE_LEN = 100
41
+
42
+ # 原始无时间戳视频的文件名索引(文件名 → 路径列表)
43
+ _VIDEO_INDEX_PATH = os.path.join(os.path.dirname(__file__), "orig_video_index.json")
44
+ if os.path.exists(_VIDEO_INDEX_PATH):
45
+ with open(_VIDEO_INDEX_PATH) as _f:
46
+ _VIDEO_INDEX = json.load(_f)
47
+ else:
48
+ _VIDEO_INDEX = {}
49
+
50
+ META_KEYWORDS = [
51
+ "as an AI", "as a language model", "I apologize for",
52
+ "I'm unable to", "I cannot process", "I give up",
53
+ "for the sake of the task", "the prompt has a typo",
54
+ ]
55
+
56
+ ANSWER_LEAK_PATTERNS = [
57
+ r'answer key says', r'answer key', r'the provided answer',
58
+ r'correct answer (?:is )?(?:given|provided|stated)',
59
+ r'answer is given as', r'ground truth', r'reference answer',
60
+ r'per the provided answer', r'as per the provided',
61
+ r'need to box [A-E].*?per the',
62
+ ]
63
+
64
+
65
+ # ---------------------------------------------------------------------------
66
+ # Helpers
67
+ # ---------------------------------------------------------------------------
68
+
69
+ def extract_think(response):
70
+ if "<think>" not in response or "</think>" not in response:
71
+ return None
72
+ return response.split("<think>", 1)[1].split("</think>", 1)[0]
73
+
74
+
75
+ def extract_after_think(response):
76
+ if "</think>" in response:
77
+ return response.split("</think>", 1)[1].strip()
78
+ return response.strip()
79
+
80
+
81
+ def extract_letter(text):
82
+ """Extract option letter A-E from answer text. Returns None on failure.
83
+ Supports: A / A. / A. text / (A) / (A) text
84
+ """
85
+ if not text:
86
+ return None
87
+ t = text.strip()
88
+ if re.match(r'^[A-E]$', t):
89
+ return t.upper()
90
+ m = re.match(r'^[(\u0028\uff08]?\s*([A-E])\s*[)\u0029\uff09.]', t)
91
+ if m:
92
+ return m.group(1).upper()
93
+ return None
94
+
95
+
96
+ # 选项后面追加的指令模板,需要从 question 和 options 中剔除
97
+ _TRAILING_INSTRUCTIONS = re.compile(
98
+ r'\n?(?:Please respond.*|Note:.*|Answer by.*|Provide your answer.*)$',
99
+ re.IGNORECASE | re.DOTALL
100
+ )
101
+
102
+
103
+ def strip_trailing_instructions(text):
104
+ """去掉 question 末尾的指令文字(如 'Please respond systematically...')"""
105
+ return _TRAILING_INSTRUCTIONS.sub('', text).strip()
106
+
107
+
108
+ def extract_options_from_question(question):
109
+ """Return [(letter, text), ...] for option lines in question.
110
+ Supports: A. text A) text (A) text
111
+ 先去掉尾部指令再提取,避免最后一个选项文字混入指令。
112
+ """
113
+ q = strip_trailing_instructions(question)
114
+ pat = re.compile(
115
+ r'(?:^|\n)[(\u0028\uff08]?([A-E])[)\u0029\uff09.]\s*(.+?)(?=\n[(\u0028\uff08]?[A-E][)\u0029\uff09.]|\Z)',
116
+ re.DOTALL
117
+ )
118
+ return [(l, t.strip()) for l, t in pat.findall(q)]
119
+
120
+
121
+ def classify_entry(question, gt_answer):
122
+ """Return (problem_type, options_list).
123
+ multiple choice only when BOTH: question has option lines AND GT has A-E letter.
124
+ Uses 'multiple choice' (space) to match sft_video_v5e.py TYPE_TEMPLATE keys.
125
+ """
126
+ opts = extract_options_from_question(question)
127
+ gt_letter = extract_letter(gt_answer)
128
+ if opts and gt_letter:
129
+ return "multiple choice", [f"{l}. {t.strip()}" for l, t in opts]
130
+ return "free-form", []
131
+
132
+
133
+ def check_mc_answer(pred, gt_letter, question):
134
+ """Return (ok: bool, reason: str).
135
+ 1. Try direct letter extraction.
136
+ 2. Fallback: full option text match (model answered the text not the letter).
137
+ 3. Still None -> unparsable.
138
+ """
139
+ pred_letter = extract_letter(pred)
140
+ if pred_letter is None:
141
+ opts = extract_options_from_question(question)
142
+ pred_clean = pred.lower().strip().rstrip(".")
143
+ for letter, opt_text in opts:
144
+ opt_clean = opt_text.strip().lower().rstrip(".")
145
+ if pred_clean == opt_clean or pred_clean in opt_clean or opt_clean in pred_clean:
146
+ pred_letter = letter.upper()
147
+ break
148
+ if pred_letter is None:
149
+ return False, "mc_unparsable"
150
+ if pred_letter != gt_letter:
151
+ return False, "mc_wrong_answer"
152
+ return True, "ok"
153
+
154
+
155
+ def extract_structured_body(response):
156
+ """提取 </think> 之后、<answer> 之前的结构化内容
157
+ (Reference frame / delta / reasoning_summary 部分),
158
+ 作为新的 <think> 块内容。
159
+ """
160
+ after = extract_after_think(response)
161
+ # 去掉末尾的 <answer>...</answer>
162
+ after = re.sub(r'<answer>.*?</answer>\s*$', '', after, flags=re.DOTALL).strip()
163
+ return after
164
+
165
+
166
+ def build_output_entry(obj, video_data_root):
167
+ video_raw = obj["video"]
168
+ answer = obj.get("answer", "")
169
+ question = obj.get("question", "")
170
+ response = obj.get("response", "")
171
+ problem_id = obj.get("problem_id", "")
172
+
173
+ structured = extract_structured_body(response)
174
+ process = f"<think>\n{structured}\n</think>"
175
+
176
+ # MC solution: 训练脚本期望只有字母(TYPE_TEMPLATE 里要求 "single option letter")
177
+ # free-form solution: 保留完整 GT 文本
178
+ gt_letter = extract_letter(answer)
179
+ has_opts = bool(extract_options_from_question(question))
180
+ if gt_letter and has_opts:
181
+ solution = f"<answer>{gt_letter}</answer>"
182
+ else:
183
+ solution = f"<answer>{answer.strip()}</answer>"
184
+
185
+ # path:优先使用原始无时间戳视频,回退顺序:
186
+ # 1. /final_dataset/<rel>(去掉 videos_timestamped 层)
187
+ # 2. /root/zwj/<rel>(同上,另一种前缀)
188
+ # 3. data_preparation/<subdir>/<fname>
189
+ # 4. compose_data/<subdir>/<fname>
190
+ # 5. 实在找不到则保留 timestamped 路径(如 *_reverse_*.mp4)
191
+ path = video_raw
192
+ ts_marker = "/final_dataset/videos_timestamped/"
193
+ if ts_marker in video_raw:
194
+ rel = video_raw.split(ts_marker, 1)[1] # e.g. dataset_First_Version/...
195
+ cand1 = os.path.join("/root/zwj/final_dataset", rel)
196
+ cand2 = os.path.join("/root/zwj", rel)
197
+ if os.path.exists(cand1):
198
+ path = cand1
199
+ elif os.path.exists(cand2):
200
+ path = cand2
201
+ else:
202
+ # 按文件名在索引中查找,优先级:data_preparation > compose_data > Video-R1
203
+ fname = os.path.basename(video_raw)
204
+ matches = _VIDEO_INDEX.get(fname, [])
205
+ chosen = None
206
+ for priority in ["data_preparation", "compose_data", "Video-R1"]:
207
+ for m in matches:
208
+ if priority in m:
209
+ chosen = m
210
+ break
211
+ if chosen:
212
+ break
213
+ if chosen:
214
+ path = chosen
215
+ # else: 保留原始 timestamped 路径
216
+
217
+ problem_type, options = classify_entry(question, answer)
218
+
219
+ # problem:先去掉尾部指令,再去掉选项块,只保留题目主体
220
+ q_clean = strip_trailing_instructions(question)
221
+ problem = re.sub(
222
+ r"\n?(?:Options?[:\s]*\n)?(?:[(\uff08]?[A-E][)\uff09.].+(?:\n|$))+",
223
+ "", q_clean, flags=re.IGNORECASE
224
+ ).strip()
225
+
226
+ return {
227
+ "problem_id": problem_id,
228
+ "problem": problem,
229
+ "data_type": "video",
230
+ "problem_type": problem_type,
231
+ "options": options,
232
+ "process": process,
233
+ "solution": solution,
234
+ "path": path,
235
+ "data_source": "cot_all_filtered",
236
+ }
237
+
238
+
239
+ # ---------------------------------------------------------------------------
240
+ # Main
241
+ # ---------------------------------------------------------------------------
242
+
243
+ def filter_and_convert(input_path, output_path, video_data_root):
244
+ reject_reasons = {
245
+ "error_key": 0,
246
+ "empty_response": 0,
247
+ "truncated_no_close_think": 0,
248
+ "short_think": 0,
249
+ "no_time_tag": 0,
250
+ "no_reasoning_summary": 0,
251
+ "truncated_after_think": 0,
252
+ "video_missing": 0,
253
+ "no_answer_tag": 0,
254
+ "no_delta": 0,
255
+ "no_reference_frame": 0,
256
+ "meta_language": 0,
257
+ "answer_leak": 0,
258
+ "mc_unparsable": 0,
259
+ "mc_wrong_answer": 0,
260
+ }
261
+
262
+ total = 0
263
+ passed = []
264
+ rejected = [] # 保存被过滤的原始条目,附带过滤原因
265
+
266
+ with open(input_path, "r", encoding="utf-8") as f:
267
+ for line in f:
268
+ line = line.strip()
269
+ if not line:
270
+ continue
271
+ try:
272
+ obj = json.loads(line)
273
+ except json.JSONDecodeError:
274
+ continue
275
+
276
+ total += 1
277
+ resp = obj.get("response", "")
278
+ question = obj.get("question", "")
279
+ gt = obj.get("answer", "").strip()
280
+
281
+ # --- Structural filters ---
282
+
283
+ if "error" in obj:
284
+ reject_reasons["error_key"] += 1
285
+ rejected.append({**obj, "_reject_reason": "error_key"})
286
+ continue
287
+
288
+ if not resp or len(resp) < MIN_RESPONSE_LEN:
289
+ reject_reasons["empty_response"] += 1
290
+ rejected.append({**obj, "_reject_reason": "empty_response"})
291
+ continue
292
+
293
+ if "<think>" in resp and "</think>" not in resp:
294
+ reject_reasons["truncated_no_close_think"] += 1
295
+ rejected.append({**obj, "_reject_reason": "truncated_no_close_think"})
296
+ continue
297
+
298
+ think_body = extract_think(resp)
299
+ if think_body is None or len(think_body.strip()) < MIN_THINK_LEN:
300
+ reject_reasons["short_think"] += 1
301
+ rejected.append({**obj, "_reject_reason": "short_think"})
302
+ continue
303
+
304
+ if "<time>" not in resp and "<time_range>" not in resp:
305
+ reject_reasons["no_time_tag"] += 1
306
+ rejected.append({**obj, "_reject_reason": "no_time_tag"})
307
+ continue
308
+
309
+ if "<reasoning_summary>" not in resp:
310
+ reject_reasons["no_reasoning_summary"] += 1
311
+ rejected.append({**obj, "_reject_reason": "no_reasoning_summary"})
312
+ continue
313
+
314
+ after = extract_after_think(resp)
315
+ has_ans_tag = "<answer>" in after or "</answer>" in after
316
+ if len(after) < 10 or (after[-1] not in ".!?>" and not has_ans_tag):
317
+ reject_reasons["truncated_after_think"] += 1
318
+ rejected.append({**obj, "_reject_reason": "truncated_after_think"})
319
+ continue
320
+
321
+ video = obj.get("video", "")
322
+ if video and not os.path.exists(video):
323
+ reject_reasons["video_missing"] += 1
324
+ rejected.append({**obj, "_reject_reason": "video_missing"})
325
+ continue
326
+
327
+ ans_m = re.search(r'<answer>(.*?)</answer>', resp, re.DOTALL)
328
+ pred = ans_m.group(1).strip() if ans_m else None
329
+ if not pred:
330
+ reject_reasons["no_answer_tag"] += 1
331
+ rejected.append({**obj, "_reject_reason": "no_answer_tag"})
332
+ continue
333
+
334
+ if "<delta>" not in resp:
335
+ reject_reasons["no_delta"] += 1
336
+ rejected.append({**obj, "_reject_reason": "no_delta"})
337
+ continue
338
+
339
+ if "Reference frame at" not in resp:
340
+ reject_reasons["no_reference_frame"] += 1
341
+ rejected.append({**obj, "_reject_reason": "no_reference_frame"})
342
+ continue
343
+
344
+ # --- Quality filters ---
345
+
346
+ lower_resp = resp.lower()
347
+ if any(kw.lower() in lower_resp for kw in META_KEYWORDS):
348
+ reject_reasons["meta_language"] += 1
349
+ rejected.append({**obj, "_reject_reason": "meta_language"})
350
+ continue
351
+
352
+ if any(re.search(p, resp, re.IGNORECASE) for p in ANSWER_LEAK_PATTERNS):
353
+ reject_reasons["answer_leak"] += 1
354
+ rejected.append({**obj, "_reject_reason": "answer_leak"})
355
+ continue
356
+
357
+ # MC answer correctness
358
+ gt_letter = extract_letter(gt)
359
+ has_opts = bool(extract_options_from_question(question))
360
+ if gt_letter and has_opts:
361
+ ok, reason = check_mc_answer(pred, gt_letter, question)
362
+ if not ok:
363
+ reject_reasons[reason] += 1
364
+ rejected.append({**obj, "_reject_reason": reason})
365
+ continue
366
+
367
+ passed.append(build_output_entry(obj, video_data_root))
368
+
369
+ with open(output_path, "w", encoding="utf-8") as f:
370
+ json.dump(passed, f, ensure_ascii=False, indent=2)
371
+
372
+ # 保存 rejected 条目(原始字段 + _reject_reason)
373
+ rejected_path = output_path.replace(".json", "_rejected.json")
374
+ with open(rejected_path, "w", encoding="utf-8") as f:
375
+ json.dump(rejected, f, ensure_ascii=False, indent=2)
376
+
377
+ rejected_cnt = sum(reject_reasons.values())
378
+ print("=" * 62)
379
+ print(f" Input total : {total:>7,}")
380
+ print(f" Passed : {len(passed):>7,} ({100*len(passed)/total:.1f}%)")
381
+ print(f" Rejected : {rejected_cnt:>7,} ({100*rejected_cnt/total:.1f}%)")
382
+ print("-" * 62)
383
+ for reason, cnt in reject_reasons.items():
384
+ if cnt > 0:
385
+ print(f" {reason:<35}: {cnt:>5,} ({100*cnt/total:.1f}%)")
386
+ print("=" * 62)
387
+ print(f" Output: {output_path}")
388
+ print(f" Rejected saved: {rejected_path}")
389
+
390
+
391
+ if __name__ == "__main__":
392
+ parser = argparse.ArgumentParser()
393
+ parser.add_argument("--input", default=None, help="Path to cot_all.jsonl")
394
+ parser.add_argument("--output", default=None, help="Path to output filtered json")
395
+ parser.add_argument("--video_data_root", default=os.environ.get("VIDEO_DATA_ROOT", "/root/zwj"))
396
+ parser.add_argument("--min_think_len", type=int, default=MIN_THINK_LEN)
397
+ args = parser.parse_args()
398
+
399
+ MIN_THINK_LEN = args.min_think_len
400
+ filter_and_convert(args.input, args.output, args.video_data_root)