laolao77 commited on
Commit
fdf01c1
·
verified ·
1 Parent(s): 20c994b

Upload Valen-4B merged model and unmerged LoRA bundle

Browse files

Final shared-state Qwen3.5-4B + two-layer Mixer after 1225k two-stage SFT (step 325). Includes standalone merged weights, original LoRA/Mixer/visual-merger weights, processor, tokenizer, custom loading code and export validation reports.

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +2 -0
  2. COMPLETE.json +6 -0
  3. LICENSE +202 -0
  4. MODEL_USAGE.md +49 -0
  5. README.md +103 -0
  6. batching.py +62 -0
  7. chat_template.jinja +154 -0
  8. compiler.py +239 -0
  9. config.json +138 -0
  10. configuration_valen.py +16 -0
  11. data_types.py +12 -0
  12. export_manifest.json +82 -0
  13. fresh_process_validation.json +112 -0
  14. heads.py +143 -0
  15. model-00001-of-00003.safetensors +3 -0
  16. model-00002-of-00003.safetensors +3 -0
  17. model-00003-of-00003.safetensors +3 -0
  18. model.safetensors.index.json +764 -0
  19. modeling_valen.py +84 -0
  20. processor_config.json +60 -0
  21. responses.py +29 -0
  22. runtime_model.py +101 -0
  23. schema.py +71 -0
  24. tokenizer.json +3 -0
  25. tokenizer_config.json +32 -0
  26. unmerged/COMPLETE.json +4 -0
  27. unmerged/LICENSE +202 -0
  28. unmerged/README.md +50 -0
  29. unmerged/batching.py +62 -0
  30. unmerged/chat_template.jinja +154 -0
  31. unmerged/compiler.py +239 -0
  32. unmerged/config.json +163 -0
  33. unmerged/configuration_valen.py +16 -0
  34. unmerged/data_types.py +12 -0
  35. unmerged/export_manifest.json +68 -0
  36. unmerged/fresh_process_validation.json +113 -0
  37. unmerged/heads.py +143 -0
  38. unmerged/lora/README.md +206 -0
  39. unmerged/lora/adapter_config.json +54 -0
  40. unmerged/lora/adapter_model.safetensors +3 -0
  41. unmerged/mixer.safetensors +3 -0
  42. unmerged/modeling_valen.py +84 -0
  43. unmerged/modeling_valen_lora.py +92 -0
  44. unmerged/processor_config.json +60 -0
  45. unmerged/responses.py +29 -0
  46. unmerged/runtime_model.py +101 -0
  47. unmerged/schema.py +71 -0
  48. unmerged/tokenizer.json +3 -0
  49. unmerged/tokenizer_config.json +32 -0
  50. unmerged/validation.json +136 -0
.gitattributes CHANGED
@@ -33,3 +33,5 @@ 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
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ unmerged/tokenizer.json filter=lfs diff=lfs merge=lfs -text
COMPLETE.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "model": "Valen-4B",
3
+ "validated": true,
4
+ "files": 21,
5
+ "source_checkpoint_sha256": "b4193b4e907f44b913fd54a8d6b998e7050a1528306269a000f1e5e8bd8dffc7"
6
+ }
LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Alibaba Cloud
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
MODEL_USAGE.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Valen-4B
2
+
3
+ 完整合并的 Qwen3.5 + 两层 Mixer,提供 Choice、Noul、Score 决策和 share_state 多题推理。
4
+ Complete Qwen3.5 backbone with merged LoRA, trained visual merger, and the FP32 Mixer head.
5
+
6
+ 训练版本:1195k + JevBench 30k,两阶段 SFT,最终 step 325。
7
+ 全体基座参数、训练参数、分词器及输入编译代码均在本目录。
8
+
9
+ ## 加载 / Load
10
+
11
+ 验证环境:Python 3.10、PyTorch 2.6.0、Transformers 5.4.0、torchvision 0.21.0、Pillow、av 16.1.0。
12
+ 使用 Flash Attention 2 时,另需与 PyTorch/CUDA 匹配的 flash-attn。
13
+
14
+ ```python
15
+ import torch
16
+ from transformers import AutoModel
17
+
18
+ model = AutoModel.from_pretrained(
19
+ "./Valen-4B",
20
+ trust_remote_code=True,
21
+ dtype=torch.bfloat16,
22
+ attn_implementation="sdpa", # 或 flash_attention_2 / or flash_attention_2
23
+ ).to("cuda").eval()
24
+ # 和导出一致性验证保持相同的 FP32 精度。 / Match export verification precision.
25
+ torch.set_float32_matmul_precision("highest")
26
+ torch.backends.cudnn.allow_tf32 = False
27
+
28
+ response = model.predict({
29
+ "state": "There is one cat in the room.",
30
+ "questions": {
31
+ "animal": {"type": "choice", "instructions": "Which animal is present?",
32
+ "criteria": {"cat": "A cat", "dog": "A dog"}},
33
+ "is_cat": {"type": "noul", "instructions": "There is a cat in the room."},
34
+ "count": {"type": "score", "instructions": "How many cats are present?",
35
+ "criteria": ["No cats", "Exactly one cat", "Two or more cats"]},
36
+ },
37
+ })
38
+ print(response["answers"])
39
+ ```
40
+
41
+ 图像/视频使用 Valen 的 messages、image_url、video_url 输入格式,媒体路径由 `media_root` 解析。
42
+ 默认 `execution="shared_state"`;`model.predict(..., execution="question")` 可使用独立问题路径。
43
+ 视频沿用训练配置,采样 16 帧。所有 Mixer 参数保持 FP32,基座权重为 BF16。
44
+
45
+ `validation.json` 记录合并前后概率差异、重新加载一致性、文本/图像/视频及三类题型检查。
46
+ `export_manifest.json` 记录来源 checkpoint、基座版本及文件 SHA-256。
47
+ LoRA 以 FP32 累加后保存为 BF16;融合矩阵的舍入顺序与独立 LoRA 分支不同。
48
+ 验证样本中最大概率绝对差:0.01969546;预测标签变化:0 / 20。
49
+ 该检查只验证导出样本,不能代替完整 benchmark;之前 checkpoint 的成绩属于未融合版本。
README.md CHANGED
@@ -1,3 +1,106 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ base_model: Qwen/Qwen3.5-4B
4
+ library_name: transformers
5
+ tags:
6
+ - valen
7
+ - decision-making
8
+ - shared-state
9
+ - qwen3.5
10
+ - custom-code
11
  ---
12
+
13
+ # Valen-4B
14
+
15
+ Valen-4B combines Qwen3.5-4B with a two-layer MLP-Mixer decision head. It predicts probability distributions for Choice, Noul (yes/no), and Score questions. A shared state can contain text, images, or video and serve multiple questions.
16
+
17
+ Valen-4B 基于 Qwen3.5-4B 和两层 MLP-Mixer 决策头,支持图文、文本、视频,以及共享 state 的多题推理。
18
+
19
+ ## Training / 训练
20
+
21
+ - Two-stage SFT: decision-head warmup followed by joint LoRA, Mixer, and visual-merger fine-tuning.
22
+ - Training data: the previous 1,195,000 records plus JevBench train_v2 30,000 records, totaling 1,225,000 records. This count refers to records; shared-state records may contain multiple questions.
23
+ - Warmup: 122,500 records, 67 optimizer steps. Joint SFT: one epoch over all 1,225,000 records, 325 optimizer steps, on 32 H200 GPUs.
24
+ - Final checkpoint: joint SFT step 325. This release uses SFT training.
25
+ - Backbone: BF16. Mixer: FP32. Videos use 16 sampled frames.
26
+
27
+ ## Files / 权重格式
28
+
29
+ - Root directory: complete backbone with merged LoRA, trained visual merger, FP32 Mixer, tokenizer, processor, and standalone loading code.
30
+ - `unmerged/`: separate PEFT LoRA, Mixer, and trained visual-merger weights, with its own configuration and loading code. Requires the pinned original Qwen3.5-4B base.
31
+ - `MODEL_USAGE.md`: inference examples and environment details.
32
+ - `validation.json`, `fresh_process_validation.json`: export checks covering text, images, video, Choice/Noul/Score, question/shared_state, and isolated Python loading.
33
+ - `export_manifest.json`: source revision and file checksums.
34
+
35
+ ## Load merged weights / 加载完整合并权重
36
+
37
+ The verified environment uses Python 3.10, PyTorch 2.6.0, Transformers 5.4.0, torchvision 0.21.0, Pillow, and av 16.1.0. Flash Attention 2 requires a compatible flash-attn installation. Private repositories require an account with access.
38
+
39
+ ```python
40
+ import torch
41
+ from transformers import AutoModel
42
+
43
+ model = AutoModel.from_pretrained(
44
+ "Valen-Team/Valen-4B",
45
+ trust_remote_code=True,
46
+ dtype=torch.bfloat16,
47
+ attn_implementation="sdpa", # or "flash_attention_2"
48
+ ).to("cuda").eval()
49
+ torch.set_float32_matmul_precision("highest")
50
+ torch.backends.cudnn.allow_tf32 = False
51
+
52
+ response = model.predict({
53
+ "state": "There is one cat in the room.",
54
+ "questions": {
55
+ "animal": {"type": "choice", "instructions": "Which animal is present?",
56
+ "criteria": {"cat": "A cat", "dog": "A dog"}},
57
+ "is_cat": {"type": "noul", "instructions": "There is a cat in the room."},
58
+ },
59
+ }, execution="shared_state")
60
+ print(response["answers"])
61
+ ```
62
+
63
+ For a local copy, replace the repository ID with `"./Valen-4B"`.
64
+ `execution="question"` scores questions separately. Images and video use the Valen `messages`, `image_url`, and `video_url` schema; relative media paths are resolved against `media_root`.
65
+
66
+ ## Load unmerged LoRA / 加载未合并权重
67
+
68
+ Download the repository first; the adapter loader expects a local directory. PEFT 0.18.1 and safetensors are also required.
69
+
70
+ ```python
71
+ import torch
72
+ from huggingface_hub import snapshot_download
73
+ from transformers import AutoModel
74
+
75
+ folder = snapshot_download("Valen-Team/Valen-4B")
76
+ model = AutoModel.from_pretrained(
77
+ folder + "/unmerged",
78
+ trust_remote_code=True,
79
+ local_files_only=False, # download the pinned Qwen base if needed
80
+ dtype=torch.bfloat16,
81
+ attn_implementation="sdpa",
82
+ ).to("cuda").eval()
83
+ torch.set_float32_matmul_precision("highest")
84
+ torch.backends.cudnn.allow_tf32 = False
85
+ ```
86
+
87
+ For an existing local base, pass `base_model_path="./Qwen3.5-4B"` and `local_files_only=True`. The loader verifies its original weight hashes and restores LoRA, Mixer, and visual-merger weights together. `is_trainable=True` enables training those parameters.
88
+
89
+ ## Reference benchmark results / 参考评测
90
+
91
+ Measured on the original final **unmerged** SFT checkpoint, using shared-state inference for multimodal sets and single-question inference for JevBench:
92
+
93
+ | Benchmark | QA | Accuracy | Choice | Noul | Score |
94
+ | --- | --- | --- | --- | --- | --- |
95
+ | eval_v1 | 2,000 | 83.06% | 85.42% | 83.25% | 54.00% |
96
+ | General | 10,000 | 88.68% | 90.68% | 85.76% | 75.60% |
97
+ | Video | 7,143 | 87.36% | 90.80% | 93.14% | 72.43% |
98
+ | JevBench | 231 | 83.12% | 84.89% | 81.08% | 77.78% |
99
+
100
+ JevBench difficulty scores: Easy 100.00% (48/48), Standard 93.06% (67/72), Hard 69.37% (77/111). The overall score is weighted by task count: 192/231.
101
+
102
+ The export smoke cases showed a maximum absolute probability difference of 0.01969546 between merged and unmerged inference, with no label changes in those cases. This does not establish full-benchmark equivalence.
103
+
104
+ For eval_v1, accuracy uses 1,700 hard-label questions. Its remaining 300 soft-label Score questions contribute probability metrics and are excluded from hard-label accuracy.
105
+
106
+ Merged BF16 matrices and separate LoRA branches can produce numerical differences. Export validation records those differences; the merged release has not been independently rerun on the complete benchmarks. The unmerged bundle preserves the original trained tensors and passed reloading checks.
batching.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Pad language rows and concatenate visual patches. / 文本补齐,视觉 patch 拼接。"""
2
+ import torch
3
+ from torch.nn.utils.rnn import pad_sequence
4
+
5
+
6
+ SEQUENCE_KEYS = {"input_ids", "attention_mask", "mm_token_type_ids"}
7
+ VISUAL_KEYS = {"pixel_values", "pixel_values_videos", "image_grid_thw", "video_grid_thw"}
8
+
9
+
10
+ def collate_branches(branches, pad_token_id=0):
11
+ if not branches:
12
+ raise ValueError("Cannot collate an empty branch batch")
13
+ inputs = [branch.inputs for branch in branches]
14
+ unknown = set().union(*(row.keys() for row in inputs)) - SEQUENCE_KEYS - VISUAL_KEYS
15
+ if unknown:
16
+ raise ValueError(f"Unsupported batched Qwen inputs: {sorted(unknown)}")
17
+ if any(row["input_ids"].ndim != 2 or row["input_ids"].shape[0] != 1 for row in inputs):
18
+ raise ValueError("Each compiled branch must contain one language row")
19
+ result = {}
20
+ for key in SEQUENCE_KEYS:
21
+ if key != "input_ids" and not any(key in row for row in inputs):
22
+ continue
23
+ rows = []
24
+ for row in inputs:
25
+ value = row.get(key)
26
+ if value is None:
27
+ value = (torch.ones_like(row["input_ids"]) if key == "attention_mask"
28
+ else torch.zeros_like(row["input_ids"]))
29
+ if value.shape != row["input_ids"].shape:
30
+ raise ValueError(f"{key} must match the branch input_ids shape")
31
+ rows.append(value[0])
32
+ # Right padding keeps all compiler readout positions and spans unchanged.
33
+ # 右侧补齐,候选位置和角色区间无需偏移。
34
+ result[key] = pad_sequence(rows, batch_first=True,
35
+ padding_value=pad_token_id if key == "input_ids" else 0)
36
+ if "attention_mask" not in result:
37
+ result["attention_mask"] = pad_sequence([torch.ones_like(r["input_ids"][0]) for r in inputs],
38
+ batch_first=True, padding_value=0)
39
+ for key in VISUAL_KEYS:
40
+ values = [row[key] for row in inputs if key in row]
41
+ if values:
42
+ result[key] = torch.cat(values, dim=0)
43
+ return result
44
+
45
+
46
+ def branch_batches(questions, max_tokens):
47
+ """Limit padded tokens per backbone forward, keeping Score branch order."""
48
+ if type(max_tokens) is not int or max_tokens <= 0:
49
+ raise ValueError("microbatch_max_tokens must be a positive integer")
50
+ batch, longest = [], 0
51
+ for question_index, question in enumerate(questions):
52
+ if not question.branches:
53
+ raise ValueError("A Qwen question requires at least one branch")
54
+ for branch in question.branches:
55
+ length = branch.inputs["input_ids"].shape[1]
56
+ if batch and max(longest, length) * (len(batch) + 1) > max_tokens:
57
+ yield batch
58
+ batch, longest = [], 0
59
+ batch.append((question_index, branch))
60
+ longest = max(longest, length)
61
+ if batch:
62
+ yield batch
chat_template.jinja ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if tools and tools is iterable and tools is not mapping %}
46
+ {{- '<|im_start|>system\n' }}
47
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
48
+ {%- for tool in tools %}
49
+ {{- "\n" }}
50
+ {{- tool | tojson }}
51
+ {%- endfor %}
52
+ {{- "\n</tools>" }}
53
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
54
+ {%- if messages[0].role == 'system' %}
55
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
56
+ {%- if content %}
57
+ {{- '\n\n' + content }}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
64
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
+ {%- endif %}
66
+ {%- endif %}
67
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
+ {%- for message in messages[::-1] %}
69
+ {%- set index = (messages|length - 1) - loop.index0 %}
70
+ {%- if ns.multi_step_tool and message.role == "user" %}
71
+ {%- set content = render_content(message.content, false)|trim %}
72
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
73
+ {%- set ns.multi_step_tool = false %}
74
+ {%- set ns.last_query_index = index %}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if ns.multi_step_tool %}
79
+ {{- raise_exception('No user query found in messages.') }}
80
+ {%- endif %}
81
+ {%- for message in messages %}
82
+ {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
84
+ {%- if not loop.first %}
85
+ {{- raise_exception('System message must be at the beginning.') }}
86
+ {%- endif %}
87
+ {%- elif message.role == "user" %}
88
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
89
+ {%- elif message.role == "assistant" %}
90
+ {%- set reasoning_content = '' %}
91
+ {%- if message.reasoning_content is string %}
92
+ {%- set reasoning_content = message.reasoning_content %}
93
+ {%- else %}
94
+ {%- if '</think>' in content %}
95
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
96
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
97
+ {%- endif %}
98
+ {%- endif %}
99
+ {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if loop.index0 > ns.last_query_index %}
101
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
+ {%- else %}
103
+ {{- '<|im_start|>' + message.role + '\n' + content }}
104
+ {%- endif %}
105
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
106
+ {%- for tool_call in message.tool_calls %}
107
+ {%- if tool_call.function is defined %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {%- if loop.first %}
111
+ {%- if content|trim %}
112
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
113
+ {%- else %}
114
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
115
+ {%- endif %}
116
+ {%- else %}
117
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
+ {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
126
+ {%- endif %}
127
+ {{- '</function>\n</tool_call>' }}
128
+ {%- endfor %}
129
+ {%- endif %}
130
+ {{- '<|im_end|>\n' }}
131
+ {%- elif message.role == "tool" %}
132
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
133
+ {{- '<|im_start|>user' }}
134
+ {%- endif %}
135
+ {{- '\n<tool_response>\n' }}
136
+ {{- content }}
137
+ {{- '\n</tool_response>' }}
138
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
139
+ {{- '<|im_end|>\n' }}
140
+ {%- elif loop.last %}
141
+ {{- '<|im_end|>\n' }}
142
+ {%- endif %}
143
+ {%- else %}
144
+ {{- raise_exception('Unexpected message role.') }}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if add_generation_prompt %}
148
+ {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is false %}
150
+ {{- '<think>\n\n</think>\n\n' }}
151
+ {%- else %}
152
+ {{- '<think>\n' }}
153
+ {%- endif %}
154
+ {%- endif %}
compiler.py ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Compile Qwen question branches or a shared sequence with per-question readouts."""
2
+ from copy import deepcopy
3
+ from dataclasses import dataclass
4
+ from pathlib import Path
5
+ import hashlib
6
+ import torch
7
+ from .schema import candidates, target_distribution
8
+ from .data_types import QuestionSpec
9
+
10
+
11
+ @dataclass
12
+ class Branch:
13
+ inputs: dict
14
+ candidate_positions: list
15
+ decision_position: int
16
+ context_span: tuple | None = None
17
+ instruction_span: tuple | None = None
18
+ candidate_spans: list | None = None
19
+
20
+
21
+ @dataclass(init=False)
22
+ class Question(QuestionSpec):
23
+ branches: list
24
+
25
+ def __init__(self, qid, kind, keys, descriptions, branches, target, is_text):
26
+ # Keep the positional constructor used by existing compiler clients.
27
+ super().__init__(qid, kind, keys, descriptions, target, is_text)
28
+ self.branches = branches
29
+
30
+
31
+ @dataclass
32
+ class CompiledState:
33
+ questions: list
34
+ logical_tokens: int
35
+ compute_tokens: int
36
+ media: list
37
+ inputs: dict | None = None
38
+
39
+
40
+ class Compiler:
41
+ def __init__(self, processor, media_root=".", max_length=8192, media_kwargs=None, verified_media_hashes=None,
42
+ execution="question"):
43
+ if execution not in {"question", "shared_state"}:
44
+ raise ValueError(f"Unknown qwen_execution: {execution}")
45
+ self.execution = execution
46
+ self.processor = processor
47
+ self.tokenizer = processor.tokenizer
48
+ self.media_root = Path(media_root)
49
+ self.max_length = max_length
50
+ self.media_kwargs = media_kwargs or {}
51
+ # Optional, pre-audited immutable assets for latency measurements.
52
+ # Normal training/inference continues to hash each input at use time.
53
+ self.verified_media_hashes = verified_media_hashes or {}
54
+
55
+ def _messages(self, state):
56
+ messages = [{"role": "user", "content": state}] if isinstance(state, str) else deepcopy(state["messages"])
57
+ media = []
58
+ for message in messages:
59
+ if message["role"] not in {"user", "assistant", "system"}:
60
+ raise ValueError("Unsupported state role")
61
+ if isinstance(message["content"], str):
62
+ message["content"] = [{"type": "text", "text": message["content"]}]
63
+ for item in message["content"]:
64
+ kind = item["type"]
65
+ if kind == "text":
66
+ # Prevent user text from injecting Qwen control tokens.
67
+ if any(t in item["text"] for t in self.tokenizer.all_special_tokens):
68
+ raise ValueError("Reserved tokenizer control token in state")
69
+ continue
70
+ if kind not in {"image_url", "video_url"}:
71
+ raise ValueError(f"Unsupported content type: {kind}")
72
+ url = item[kind]["url"]
73
+ if "://" in url:
74
+ raise ValueError("Materialize remote media locally with a hash before training")
75
+ path = Path(url)
76
+ path = path if path.is_absolute() else self.media_root / path
77
+ path = path.resolve(strict=True)
78
+ digest = self.verified_media_hashes.get(str(path))
79
+ if digest is None:
80
+ digest = hashlib.sha256(path.read_bytes()).hexdigest()
81
+ media.append({"path": str(path), "sha256": digest, "type": kind})
82
+ item.clear()
83
+ item.update(type=kind.removesuffix("_url"), path=str(path))
84
+ return messages, media
85
+
86
+ def compile(self, record, rng=None, labeled_only=False):
87
+ selected = []
88
+ for qid, question in record["request"]["questions"].items():
89
+ pairs = candidates(question)
90
+ target = record.get("targets", {}).get(qid)
91
+ if labeled_only and self.execution == "question" and target_distribution(target, [k for k, _ in pairs]) is None:
92
+ continue
93
+ if rng is not None and question["type"] == "choice":
94
+ rng.shuffle(pairs)
95
+ selected.append((qid, question, pairs, target))
96
+ # 标签只决定监督范围,共享序列仍保留所有题。 / Labels select losses, never prompt content.
97
+ if not selected or (labeled_only and not any(
98
+ target_distribution(target, [k for k, _ in pairs]) is not None
99
+ for _, _, pairs, target in selected)):
100
+ return CompiledState([], 0, 0, [])
101
+ messages, media = self._messages(record["request"]["state"])
102
+ expected_assets = {str((self.media_root / a["path"]).resolve()): a["sha256"] for a in record.get("assets", [])}
103
+ for entry in media:
104
+ if entry["path"] in expected_assets and expected_assets[entry["path"]] != entry["sha256"]:
105
+ raise ValueError(f"Media hash mismatch: {entry['path']}")
106
+ base = dict(self.processor.apply_chat_template(
107
+ messages, tokenize=True, add_generation_prompt=False, return_dict=True,
108
+ return_tensors="pt", processor_kwargs=dict(self.media_kwargs, return_metadata=True)))
109
+ # Metadata is audit information, never a backbone keyword argument.
110
+ metadata = base.pop("video_metadata", None)
111
+ if metadata is not None:
112
+ for entry, meta in zip([m for m in media if m["type"] == "video_url"], metadata):
113
+ entry["sampling"] = dict(meta) if isinstance(meta, dict) else vars(meta)
114
+ sampling = entry["sampling"]
115
+ indices = sampling.get("frames_indices")
116
+ if indices is not None and sampling.get("fps"):
117
+ sampling["frames_indices"] = [int(i) for i in indices]
118
+ sampling["timestamps_seconds"] = [int(i) / sampling["fps"] for i in indices]
119
+ sampling["visible_range_seconds"] = [min(sampling["timestamps_seconds"]), max(sampling["timestamps_seconds"])]
120
+ for name in ("image_grid_thw", "video_grid_thw"):
121
+ if name in base:
122
+ grid = base[name]
123
+ media.append({name: grid.tolist(), "visual_tokens": int(grid.prod(-1).sum()) // 4})
124
+ base_length = base["input_ids"].shape[1]
125
+ if self.execution == "shared_state":
126
+ return self._compile_shared(selected, base, media, labeled_only)
127
+ logical_tokens, compute_tokens = base_length, 0
128
+ compiled = []
129
+ for qid, question, pairs, target in selected:
130
+ keys = [k for k, _ in pairs]
131
+ branches = []
132
+ groups = [[pair] for pair in pairs] if question["type"] == "score" else [pairs]
133
+ for group in groups:
134
+ suffix = []
135
+ def append(text, char_span=None):
136
+ start = base_length + len(suffix)
137
+ if char_span is None:
138
+ suffix.extend(self.tokenizer.encode(text, add_special_tokens=False))
139
+ return None
140
+ # 保持原有分词,只额外记录区间。 / Preserve token IDs; record role spans.
141
+ encoded = self.tokenizer(text, add_special_tokens=False, return_offsets_mapping=True)
142
+ suffix.extend(encoded["input_ids"])
143
+ indices = [i for i, (a, b) in enumerate(encoded["offset_mapping"])
144
+ if a < char_span[1] and b > char_span[0]]
145
+ if not indices:
146
+ raise ValueError("Empty token span for decision role")
147
+ return (start + indices[0], start + indices[-1] + 1)
148
+ # Canonical segment tokenization makes endpoints exact; no string searching.
149
+ suffix.extend(self.tokenizer.encode("<|im_start|>user\n", add_special_tokens=False))
150
+ for value in [question["instructions"]] + [v for pair in group for v in pair]:
151
+ if any(t in value for t in self.tokenizer.all_special_tokens):
152
+ raise ValueError("Reserved tokenizer control token in question/criteria")
153
+ prefix = "Task: " + question["type"] + "\nQuestion: "
154
+ instruction_span = append(prefix + question["instructions"] + "\nCandidates:\n",
155
+ (len(prefix), len(prefix) + len(question["instructions"])))
156
+ positions, candidate_spans = [], []
157
+ for key, description in group:
158
+ # Score never sees its level ID, nor any other level description.
159
+ prefix = key + ": " if question["type"] != "score" else ""
160
+ candidate_spans.append(append(prefix + description, (len(prefix), len(prefix) + len(description))))
161
+ positions.append(base_length + len(suffix) - 1)
162
+ append("\n")
163
+ append("Decision:")
164
+ length = base_length + len(suffix)
165
+ if length > self.max_length:
166
+ raise ValueError(f"{qid}: {length} tokens exceed max_length={self.max_length}; no truncation")
167
+ inputs = dict(base)
168
+ inputs["input_ids"] = torch.cat([base["input_ids"], torch.tensor([suffix], dtype=torch.long)], dim=1)
169
+ inputs["attention_mask"] = torch.ones_like(inputs["input_ids"])
170
+ if "mm_token_type_ids" in base:
171
+ inputs["mm_token_type_ids"] = torch.cat([base["mm_token_type_ids"], torch.zeros((1, len(suffix)), dtype=torch.long)], dim=1)
172
+ branches.append(Branch(inputs, positions, length - 1, (0, base_length),
173
+ instruction_span, candidate_spans))
174
+ compute_tokens += length
175
+ logical_tokens += len(suffix)
176
+ compiled.append(Question(qid, question["type"], keys, [v for _, v in pairs], branches,
177
+ target_distribution(target, keys), not media))
178
+ return CompiledState(compiled, logical_tokens, compute_tokens, media)
179
+
180
+ def _compile_shared(self, selected, base, media, labeled_only=False):
181
+ """All schemas precede all readouts; labels and external IDs never enter inputs.
182
+
183
+ This is ordinary causal attention, not isolated question/Score branches.
184
+ No answer tokens or LM output layer are required by the decision heads.
185
+ """
186
+ base_length = base["input_ids"].shape[1]
187
+ suffix, compiled = [], []
188
+
189
+ def append(text, span=None):
190
+ start = base_length + len(suffix)
191
+ if span is None:
192
+ suffix.extend(self.tokenizer.encode(text, add_special_tokens=False))
193
+ return None
194
+ encoded = self.tokenizer(text, add_special_tokens=False, return_offsets_mapping=True)
195
+ suffix.extend(encoded["input_ids"])
196
+ indices = [i for i, (a, b) in enumerate(encoded["offset_mapping"]) if a < span[1] and b > span[0]]
197
+ if not indices:
198
+ raise ValueError("Empty token span for decision role")
199
+ return start + indices[0], start + indices[-1] + 1
200
+
201
+ append("<|im_start|>user\n")
202
+ for index, (qid, question, pairs, target) in enumerate(selected):
203
+ for value in [question["instructions"]] + [v for pair in pairs for v in pair]:
204
+ if any(t in value for t in self.tokenizer.all_special_tokens):
205
+ raise ValueError("Reserved tokenizer control token in question/criteria")
206
+ prefix = f"Question {index + 1}\nTask: {question['type']}\nQuestion: "
207
+ instruction = append(prefix + question["instructions"] + "\nCandidates:\n",
208
+ (len(prefix), len(prefix) + len(question["instructions"])))
209
+ positions, spans = [], []
210
+ for key, description in pairs:
211
+ prefix = key + ": " if question["type"] != "score" else ""
212
+ spans.append(append(prefix + description, (len(prefix), len(prefix) + len(description))))
213
+ positions.append(base_length + len(suffix) - 1)
214
+ append("\n")
215
+ # Inputs and the decision position are filled after all schemas are appended.
216
+ branch = Branch({}, positions, -1, (0, base_length), instruction, spans)
217
+ keys = [key for key, _ in pairs]
218
+ compiled.append(Question(qid, question["type"], keys, [v for _, v in pairs], [branch],
219
+ target_distribution(target, keys), not media))
220
+ append("<|im_end|>\n<|im_start|>assistant\n")
221
+ for index, question in enumerate(compiled):
222
+ append(f"Question {index + 1} Decision:")
223
+ question.branches[0].decision_position = base_length + len(suffix) - 1
224
+ append("\n")
225
+ length = base_length + len(suffix)
226
+ if length > self.max_length:
227
+ raise ValueError(f"Shared state: {length} tokens exceed max_length={self.max_length}; no truncation")
228
+ inputs = dict(base)
229
+ inputs["input_ids"] = torch.cat([base["input_ids"], base["input_ids"].new_tensor([suffix])], dim=1)
230
+ inputs["attention_mask"] = torch.cat([base["attention_mask"],
231
+ base["attention_mask"].new_ones((1, len(suffix)))], dim=1)
232
+ if "mm_token_type_ids" in base:
233
+ inputs["mm_token_type_ids"] = torch.cat([base["mm_token_type_ids"],
234
+ base["mm_token_type_ids"].new_zeros((1, len(suffix)))], dim=1)
235
+ for question in compiled:
236
+ question.branches[0].inputs = inputs
237
+ if labeled_only:
238
+ compiled = [question for question in compiled if question.target is not None]
239
+ return CompiledState(compiled, length, length, media, inputs)
config.json ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ValenQwenForDecisionMaking"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_valen.ValenQwenConfig",
7
+ "AutoModel": "modeling_valen.ValenQwenForDecisionMaking"
8
+ },
9
+ "dtype": "bfloat16",
10
+ "image_token_id": 248056,
11
+ "model_type": "valen_qwen",
12
+ "qwen_execution": "shared_state",
13
+ "text_config": {
14
+ "attention_bias": false,
15
+ "attention_dropout": 0.0,
16
+ "attn_output_gate": true,
17
+ "bos_token_id": null,
18
+ "dtype": "bfloat16",
19
+ "eos_token_id": 248044,
20
+ "full_attention_interval": 4,
21
+ "head_dim": 256,
22
+ "hidden_act": "silu",
23
+ "hidden_size": 2560,
24
+ "initializer_range": 0.02,
25
+ "intermediate_size": 9216,
26
+ "layer_types": [
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "full_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "full_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "full_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "full_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "linear_attention",
46
+ "full_attention",
47
+ "linear_attention",
48
+ "linear_attention",
49
+ "linear_attention",
50
+ "full_attention",
51
+ "linear_attention",
52
+ "linear_attention",
53
+ "linear_attention",
54
+ "full_attention",
55
+ "linear_attention",
56
+ "linear_attention",
57
+ "linear_attention",
58
+ "full_attention"
59
+ ],
60
+ "linear_conv_kernel_dim": 4,
61
+ "linear_key_head_dim": 128,
62
+ "linear_num_key_heads": 16,
63
+ "linear_num_value_heads": 32,
64
+ "linear_value_head_dim": 128,
65
+ "mamba_ssm_dtype": "float32",
66
+ "max_position_embeddings": 262144,
67
+ "mlp_only_layers": [],
68
+ "model_type": "qwen3_5_text",
69
+ "mtp_num_hidden_layers": 1,
70
+ "mtp_use_dedicated_embeddings": false,
71
+ "num_attention_heads": 16,
72
+ "num_hidden_layers": 32,
73
+ "num_key_value_heads": 4,
74
+ "pad_token_id": null,
75
+ "partial_rotary_factor": 0.25,
76
+ "rms_norm_eps": 1e-06,
77
+ "rope_parameters": {
78
+ "mrope_interleaved": true,
79
+ "mrope_section": [
80
+ 11,
81
+ 11,
82
+ 10
83
+ ],
84
+ "partial_rotary_factor": 0.25,
85
+ "rope_theta": 10000000,
86
+ "rope_type": "default"
87
+ },
88
+ "tie_word_embeddings": true,
89
+ "use_cache": true,
90
+ "vocab_size": 248320
91
+ },
92
+ "tie_word_embeddings": true,
93
+ "transformers_version": "5.4.0",
94
+ "valen_head": {
95
+ "head_channel_hidden_dim": 1024,
96
+ "head_layers": 2,
97
+ "head_token_hidden_dim": 16,
98
+ "head_type": "mixer",
99
+ "head_width": 256
100
+ },
101
+ "valen_max_length": 32768,
102
+ "valen_media_kwargs": {
103
+ "images_kwargs": {
104
+ "size": {
105
+ "longest_edge": 262144,
106
+ "shortest_edge": 65536
107
+ }
108
+ },
109
+ "videos_kwargs": {
110
+ "fps": null,
111
+ "num_frames": 16,
112
+ "size": {
113
+ "longest_edge": 2097152,
114
+ "shortest_edge": 131072
115
+ }
116
+ }
117
+ },
118
+ "video_token_id": 248057,
119
+ "vision_config": {
120
+ "deepstack_visual_indexes": [],
121
+ "depth": 24,
122
+ "dtype": "bfloat16",
123
+ "hidden_act": "gelu_pytorch_tanh",
124
+ "hidden_size": 1024,
125
+ "in_channels": 3,
126
+ "initializer_range": 0.02,
127
+ "intermediate_size": 4096,
128
+ "model_type": "qwen3_5",
129
+ "num_heads": 16,
130
+ "num_position_embeddings": 2304,
131
+ "out_hidden_size": 2560,
132
+ "patch_size": 16,
133
+ "spatial_merge_size": 2,
134
+ "temporal_patch_size": 2
135
+ },
136
+ "vision_end_token_id": 248054,
137
+ "vision_start_token_id": 248053
138
+ }
configuration_valen.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Standalone Qwen decision configuration. / 独立的 Qwen 决策模型配置。"""
2
+ from transformers import Qwen3_5Config
3
+
4
+
5
+ class ValenQwenConfig(Qwen3_5Config):
6
+ model_type = "valen_qwen"
7
+
8
+ def __init__(self, valen_head=None, qwen_execution="shared_state", valen_max_length=32768,
9
+ valen_media_kwargs=None, **kwargs):
10
+ if qwen_execution not in {"question", "shared_state"}:
11
+ raise ValueError("qwen_execution must be question or shared_state")
12
+ self.valen_head = valen_head or {"head_type": "mixer"}
13
+ self.qwen_execution = qwen_execution
14
+ self.valen_max_length = valen_max_length
15
+ self.valen_media_kwargs = valen_media_kwargs or {}
16
+ super().__init__(**kwargs)
data_types.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Model-independent decision metadata; encoded tensors stay with each compiler."""
2
+ from dataclasses import dataclass
3
+
4
+
5
+ @dataclass
6
+ class QuestionSpec:
7
+ qid: str
8
+ kind: str
9
+ keys: list
10
+ descriptions: list
11
+ target: list | None
12
+ is_text: bool
export_manifest.json ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "valen_qwen_merged_v1",
3
+ "created_utc": "2026-10-06T06:52:07.182367+00:00",
4
+ "model": "Valen-4B",
5
+ "architecture": "Qwen3.5 + two-layer Mixer",
6
+ "execution": "shared_state",
7
+ "source_checkpoint_sha256": "b4193b4e907f44b913fd54a8d6b998e7050a1528306269a000f1e5e8bd8dffc7",
8
+ "training_step": 325,
9
+ "training_records": 1225000,
10
+ "training_data_sha256": "648cb127fe4830f9faaa6d4595445cc2573ef0c152f8f74c9c776dc8a9223d7f",
11
+ "base": {
12
+ "repo": "Qwen/Qwen3.5-4B",
13
+ "revision": "851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a",
14
+ "weight_sha256": {
15
+ "model.safetensors-00001-of-00002.safetensors": "26a93f066e1916adb13453dae5a0c707c0fbc71299ed98779571a907b8e74c61",
16
+ "model.safetensors-00002-of-00002.safetensors": "cb544bd9bfae93dc59b0f22b292f5933573854a7f9b97835c67060d7d910e188"
17
+ },
18
+ "files_sha256": {
19
+ ".gitattributes": "34448b82c17d60fec9b65b1f093c115ddbaadc04beb1b0140b6bfed2e012a930",
20
+ "LICENSE": "bbedc3fda3305820b977265f01b8619d87570a6739de3a5582c3464840f1e57a",
21
+ "README.md": "1406be1b6b8fd8a6545870da516912804756593628a1d0fb0a7965211e82a7bb",
22
+ "chat_template.jinja": "a4aee8afcf2e0711942cf848899be66016f8d14a889ff9ede07bca099c28f715",
23
+ "config.json": "ddc63e1c717afa86c865bb5e01313d89d72bb53b97ad4a8a03ba8510c0621670",
24
+ "merges.txt": "a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d",
25
+ "model.safetensors-00001-of-00002.safetensors": "26a93f066e1916adb13453dae5a0c707c0fbc71299ed98779571a907b8e74c61",
26
+ "model.safetensors-00002-of-00002.safetensors": "cb544bd9bfae93dc59b0f22b292f5933573854a7f9b97835c67060d7d910e188",
27
+ "model.safetensors.index.json": "cf3f798ee02ba45f9622aa8892a47369ab667d0afbf154ee7c2212de42e6302d",
28
+ "preprocessor_config.json": "27225450ac9c6529872ee1924fcb0962ff5634834f817040f444118116f4e516",
29
+ "tokenizer.json": "5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42",
30
+ "tokenizer_config.json": "316230d6a809701f4db5ea8f8fc862bc3a6f3229c937c174e674ff3ca0a64ac8",
31
+ "video_preprocessor_config.json": "7768af27c1fafa9cc9011c1dc20067e03f8915e03b63504550e11d5066986d13",
32
+ "vocab.json": "ce99b4cb2983d118806ce0a8b777a35b093e2000a503ebde25853284c9dfa003"
33
+ },
34
+ "verified_from": "download_manifest.json; every LFS SHA256 matched"
35
+ },
36
+ "merge": "FP32 base+LoRA accumulation, stored BF16; trained visual merger and FP32 Mixer retained",
37
+ "merged_linear_layers": 248,
38
+ "runtime_source_sha256": {
39
+ "valen/modeling/qwen/heads.py": "63b5970a8bfa121eff94d50ffd35e1fa8387f3af5abccc5f5b75381fb084fc34",
40
+ "valen/modeling/qwen/batching.py": "ea45d4724bcafca559fc5a2a18092918b633746771c19da6554c29bc5f2cef64",
41
+ "valen/modeling/qwen/model.py": "37b97e52bd16ada6a841fd553454ec0b0e458f3966ca0bef8a1bfe15293c2271",
42
+ "valen/data/compilers/qwen.py": "cae0389c407a9e67e1b14776b56d87767046b4ad119e93d138e1ae2f20fcadb2",
43
+ "valen/data/schema.py": "253825862b60016e37fd1040492008ad7f303679c092313d8a6527cf509f3b6e",
44
+ "valen/data/types.py": "b06ce08081d8f7b2bf36abf302410a96086395e75a04f9e9b1c591db519b1641",
45
+ "valen/evaluation/inference.py": "ccb47efd9f029f19a70cc462e262143cbab021deb4b8f4d11d2ecec054cbe553"
46
+ },
47
+ "versions": {
48
+ "torch": "2.6.0",
49
+ "transformers": "5.4.0",
50
+ "peft": "0.18.1",
51
+ "safetensors": "0.6.2",
52
+ "flash-attn": "2.7.4.post1",
53
+ "torchvision": "0.21.0",
54
+ "Pillow": "11.3.0",
55
+ "av": "16.1.0"
56
+ },
57
+ "files_sha256": {
58
+ "LICENSE": "bbedc3fda3305820b977265f01b8619d87570a6739de3a5582c3464840f1e57a",
59
+ "MODEL_USAGE.md": "cc6beb959e63059e68d8e5badb4df45090a22f1b049b1762262deb1988a61590",
60
+ "batching.py": "ea45d4724bcafca559fc5a2a18092918b633746771c19da6554c29bc5f2cef64",
61
+ "chat_template.jinja": "a4aee8afcf2e0711942cf848899be66016f8d14a889ff9ede07bca099c28f715",
62
+ "compiler.py": "f35bab2e71b6beb1228daaa5b7baecdacf04eaf713aee14e8082b97090f910b4",
63
+ "config.json": "15dd1b0e94aa6ad330d3d8c50e4f9ea579edbb21fb2ba13c02b32c3e0ede6527",
64
+ "configuration_valen.py": "735b02402fb5b6c7a1652f6691ba66d066ef99e84500042faec396ff7a668fe5",
65
+ "data_types.py": "b06ce08081d8f7b2bf36abf302410a96086395e75a04f9e9b1c591db519b1641",
66
+ "heads.py": "63b5970a8bfa121eff94d50ffd35e1fa8387f3af5abccc5f5b75381fb084fc34",
67
+ "model-00001-of-00003.safetensors": "21fef5c5b93c2d9f1e54100f31709aaeb1651058784b9d38c47d9345fdba50d0",
68
+ "model-00002-of-00003.safetensors": "9ec6792a776db86b348b97ae3e9ff5feaa055dba2ea28035aac9f1d543623e9b",
69
+ "model-00003-of-00003.safetensors": "c7b96a0d85eb01475c0f775a51f88e4455aeae31143cc86c8457723d9019c13e",
70
+ "model.safetensors.index.json": "69f50ed2c7dcbbda30cc1b9ec3413ef84f2ac9aa569f357eec9f8ab63d1fdb95",
71
+ "modeling_valen.py": "07f87481334cb1e28e9daee036c27bab3654645abf3df7983346b316e7788848",
72
+ "processor_config.json": "d89ef49ce9cd37fbf510158e13c1ef063d9286411c1ec9049932dbe0487143b1",
73
+ "responses.py": "298016b0070f1000a38d033e1048e038ff5df6fc1dcbe830601105b181f1d228",
74
+ "runtime_model.py": "98bf0443ca196900b9f2b056129c84932041b8b53395d111f2fe6d3f2bc1e0a6",
75
+ "schema.py": "253825862b60016e37fd1040492008ad7f303679c092313d8a6527cf509f3b6e",
76
+ "tokenizer.json": "87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4",
77
+ "tokenizer_config.json": "e98f1901ac6f0adff67b1d540bfa0c36ac1a0cf59eb72ed78146ef89aafa1182",
78
+ "validation.json": "0ed2de1bc25b85c42d2329e42eb53bb6bad85e1ee3e2ec598a1dff643a3aa509",
79
+ "README.md": "fc0d6e3a980891edd2264d5a705da824cb1c0a31ebf52f44da54903c13d2b4c3",
80
+ "fresh_process_validation.json": "5945d5fc669cb573bb47db5fd41c3bb3ceb51b81b6951eea30681c7451505d43"
81
+ }
82
+ }
fresh_process_validation.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "passed": true,
3
+ "isolated_python": true,
4
+ "valen_imports_blocked": true,
5
+ "all_real_modalities_and_question_types_passed": true,
6
+ "sdpa_example_passed": true,
7
+ "cases": 20,
8
+ "max_probability_abs_error": 0.0,
9
+ "max_logit_abs_error": 0.0,
10
+ "details": [
11
+ {
12
+ "case": "shared_state/text_multi/choice",
13
+ "probability_max_abs": 0.0,
14
+ "logit_max_abs": 0.0
15
+ },
16
+ {
17
+ "case": "shared_state/text_multi/noul",
18
+ "probability_max_abs": 0.0,
19
+ "logit_max_abs": 0.0
20
+ },
21
+ {
22
+ "case": "shared_state/text_multi/score",
23
+ "probability_max_abs": 0.0,
24
+ "logit_max_abs": 0.0
25
+ },
26
+ {
27
+ "case": "shared_state/text_multi/score_many",
28
+ "probability_max_abs": 0.0,
29
+ "logit_max_abs": 0.0
30
+ },
31
+ {
32
+ "case": "shared_state/image_score/decision",
33
+ "probability_max_abs": 0.0,
34
+ "logit_max_abs": 0.0
35
+ },
36
+ {
37
+ "case": "shared_state/image_noul/decision",
38
+ "probability_max_abs": 0.0,
39
+ "logit_max_abs": 0.0
40
+ },
41
+ {
42
+ "case": "shared_state/image_choice/decision",
43
+ "probability_max_abs": 0.0,
44
+ "logit_max_abs": 0.0
45
+ },
46
+ {
47
+ "case": "shared_state/video_multi/q000",
48
+ "probability_max_abs": 0.0,
49
+ "logit_max_abs": 0.0
50
+ },
51
+ {
52
+ "case": "shared_state/video_multi/score_000",
53
+ "probability_max_abs": 0.0,
54
+ "logit_max_abs": 0.0
55
+ },
56
+ {
57
+ "case": "shared_state/video_multi/noul_000",
58
+ "probability_max_abs": 0.0,
59
+ "logit_max_abs": 0.0
60
+ },
61
+ {
62
+ "case": "question/text_multi/choice",
63
+ "probability_max_abs": 0.0,
64
+ "logit_max_abs": 0.0
65
+ },
66
+ {
67
+ "case": "question/text_multi/noul",
68
+ "probability_max_abs": 0.0,
69
+ "logit_max_abs": 0.0
70
+ },
71
+ {
72
+ "case": "question/text_multi/score",
73
+ "probability_max_abs": 0.0,
74
+ "logit_max_abs": 0.0
75
+ },
76
+ {
77
+ "case": "question/text_multi/score_many",
78
+ "probability_max_abs": 0.0,
79
+ "logit_max_abs": 0.0
80
+ },
81
+ {
82
+ "case": "question/image_score/decision",
83
+ "probability_max_abs": 0.0,
84
+ "logit_max_abs": 0.0
85
+ },
86
+ {
87
+ "case": "question/image_noul/decision",
88
+ "probability_max_abs": 0.0,
89
+ "logit_max_abs": 0.0
90
+ },
91
+ {
92
+ "case": "question/image_choice/decision",
93
+ "probability_max_abs": 0.0,
94
+ "logit_max_abs": 0.0
95
+ },
96
+ {
97
+ "case": "question/video_multi/q000",
98
+ "probability_max_abs": 0.0,
99
+ "logit_max_abs": 0.0
100
+ },
101
+ {
102
+ "case": "question/video_multi/score_000",
103
+ "probability_max_abs": 0.0,
104
+ "logit_max_abs": 0.0
105
+ },
106
+ {
107
+ "case": "question/video_multi/noul_000",
108
+ "probability_max_abs": 0.0,
109
+ "logit_max_abs": 0.0
110
+ }
111
+ ]
112
+ }
heads.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """可替换的候选评分头。 / Interchangeable, candidate-wise decision heads."""
2
+ import math
3
+
4
+ import torch
5
+ from torch import nn
6
+
7
+
8
+ def head_signature(config):
9
+ """用于构建与恢复校验。 / Canonical architecture settings for loading."""
10
+ kind = config.get("head_type", "bilinear")
11
+ defaults = {
12
+ "bilinear": {"projection_dim": 256},
13
+ "mlp": {"head_hidden_dim": 512, "head_bottleneck_dim": 128},
14
+ "role_mlp": {"head_width": 256, "head_hidden_dim": 1024},
15
+ "mixer": {"head_width": 256, "head_layers": 2,
16
+ "head_token_hidden_dim": 16, "head_channel_hidden_dim": 1024},
17
+ }
18
+ if kind not in defaults:
19
+ raise ValueError(f"Unknown Qwen head_type: {kind!r}")
20
+ values = {key: config.get(key, value) for key, value in defaults[kind].items()}
21
+ if any(type(value) is not int or value <= 0 for value in values.values()):
22
+ raise ValueError("Decision head dimensions must be positive integers")
23
+ return {"head_type": kind, **values}
24
+
25
+
26
+ class DecisionHead(nn.Module):
27
+ """原有参数名保持兼容。 / Preserve legacy bilinear parameter names."""
28
+ def __init__(self, hidden_size, projection_dim=256):
29
+ super().__init__()
30
+ self.decision = nn.Linear(hidden_size, projection_dim, bias=False)
31
+ self.candidate = nn.Linear(hidden_size, projection_dim, bias=False)
32
+ self.scale = math.sqrt(projection_dim)
33
+
34
+ def forward(self, hidden, positions, decision_position):
35
+ d = self.decision(hidden[0, decision_position].float())
36
+ c = self.candidate(hidden[0, positions].float())
37
+ return (c * d).sum(-1) / self.scale
38
+
39
+ def extract_features(self, hidden, branch):
40
+ return hidden[:, [*branch.candidate_positions, branch.decision_position], :]
41
+
42
+ def score_features(self, features):
43
+ return self(features, list(range(features.shape[1] - 1)), features.shape[1] - 1)
44
+
45
+
46
+ class MLPHead(nn.Module):
47
+ """每个候选共享一个 MLP。 / One shared MLP for arbitrary candidate counts."""
48
+ def __init__(self, hidden_size, hidden_dim=512, bottleneck_dim=128):
49
+ super().__init__()
50
+ self.decision_norm = nn.LayerNorm(hidden_size)
51
+ self.candidate_norm = nn.LayerNorm(hidden_size)
52
+ self.network = nn.Sequential(nn.Linear(2 * hidden_size, hidden_dim), nn.GELU(),
53
+ nn.Linear(hidden_dim, bottleneck_dim), nn.GELU(),
54
+ nn.Linear(bottleneck_dim, 1))
55
+
56
+ def extract_features(self, hidden, branch):
57
+ c = hidden[0, branch.candidate_positions]
58
+ d = hidden[0, branch.decision_position].expand_as(c)
59
+ return torch.stack((d, c), dim=1)
60
+
61
+ def score_features(self, features):
62
+ d, c = features.float().unbind(1)
63
+ return self.network(torch.cat((self.decision_norm(d), self.candidate_norm(c)), -1)).squeeze(-1)
64
+
65
+
66
+ def role_features(hidden, branch):
67
+ """先池化再投影,可缓存冻结特征。 / Pool before trainable projections."""
68
+ spans = (getattr(branch, "context_span", None), getattr(branch, "instruction_span", None))
69
+ candidates = getattr(branch, "candidate_spans", None)
70
+ if any(span is None for span in spans) or not candidates or len(candidates) != len(branch.candidate_positions):
71
+ raise ValueError("Role heads require compiler context, instruction and candidate spans")
72
+
73
+ def pool(span):
74
+ start, end = span
75
+ if not 0 <= start < end <= hidden.shape[1]:
76
+ raise ValueError(f"Invalid role span: {span}")
77
+ return hidden[0, start:end].float().mean(0)
78
+
79
+ context, instruction = (pool(span) for span in spans)
80
+ decision = hidden[0, branch.decision_position].float()
81
+ return torch.stack([torch.stack((context, instruction, pool(span), decision)) for span in candidates])
82
+
83
+
84
+ class RoleHead(nn.Module):
85
+ def __init__(self, hidden_size, width):
86
+ super().__init__()
87
+ self.input_norm = nn.LayerNorm(hidden_size)
88
+ self.projection = nn.Linear(hidden_size, width)
89
+ self.roles = nn.Parameter(torch.zeros(1, 4, width))
90
+
91
+ def extract_features(self, hidden, branch):
92
+ return role_features(hidden, branch)
93
+
94
+ def project(self, features):
95
+ return self.projection(self.input_norm(features.float())) + self.roles
96
+
97
+
98
+ class RoleMLPHead(RoleHead):
99
+ """与 Mixer 使用相同输入。 / Control for the Mixer's richer input features."""
100
+ def __init__(self, hidden_size, width=256, hidden_dim=1024):
101
+ super().__init__(hidden_size, width)
102
+ self.network = nn.Sequential(nn.Linear(4 * width, hidden_dim), nn.GELU(), nn.Linear(hidden_dim, 1))
103
+
104
+ def score_features(self, features):
105
+ return self.network(self.project(features).flatten(1)).squeeze(-1)
106
+
107
+
108
+ class MixerBlock(nn.Module):
109
+ def __init__(self, width, token_hidden, channel_hidden):
110
+ super().__init__()
111
+ self.token_norm = nn.LayerNorm(width)
112
+ self.token_mlp = nn.Sequential(nn.Linear(4, token_hidden), nn.GELU(), nn.Linear(token_hidden, 4))
113
+ self.channel_norm = nn.LayerNorm(width)
114
+ self.channel_mlp = nn.Sequential(nn.Linear(width, channel_hidden), nn.GELU(), nn.Linear(channel_hidden, width))
115
+
116
+ def forward(self, x):
117
+ # 混合角色,不混合不同候选。 / Mix fixed roles, never candidate rows.
118
+ x = x + self.token_mlp(self.token_norm(x).transpose(1, 2)).transpose(1, 2)
119
+ return x + self.channel_mlp(self.channel_norm(x))
120
+
121
+
122
+ class MixerHead(RoleHead):
123
+ def __init__(self, hidden_size, width=256, layers=2, token_hidden=16, channel_hidden=1024):
124
+ super().__init__(hidden_size, width)
125
+ self.blocks = nn.Sequential(*(MixerBlock(width, token_hidden, channel_hidden) for _ in range(layers)))
126
+ self.output = nn.Sequential(nn.LayerNorm(width), nn.Linear(width, 1))
127
+
128
+ def score_features(self, features):
129
+ # 第三行是候选角色。 / Read the updated candidate role.
130
+ return self.output(self.blocks(self.project(features))[:, 2]).squeeze(-1)
131
+
132
+
133
+ def build_head(hidden_size, config):
134
+ settings = head_signature(config)
135
+ kind = settings.pop("head_type")
136
+ if kind == "bilinear":
137
+ return DecisionHead(hidden_size, settings["projection_dim"])
138
+ if kind == "mlp":
139
+ return MLPHead(hidden_size, settings["head_hidden_dim"], settings["head_bottleneck_dim"])
140
+ if kind == "role_mlp":
141
+ return RoleMLPHead(hidden_size, settings["head_width"], settings["head_hidden_dim"])
142
+ return MixerHead(hidden_size, settings["head_width"], settings["head_layers"],
143
+ settings["head_token_hidden_dim"], settings["head_channel_hidden_dim"])
model-00001-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21fef5c5b93c2d9f1e54100f31709aaeb1651058784b9d38c47d9345fdba50d0
3
+ size 3991299376
model-00002-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ec6792a776db86b348b97ae3e9ff5feaa055dba2ea28035aac9f1d543623e9b
3
+ size 3979833864
model-00003-of-00003.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c7b96a0d85eb01475c0f775a51f88e4455aeae31143cc86c8457723d9019c13e
3
+ size 1114356012
model.safetensors.index.json ADDED
@@ -0,0 +1,764 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "metadata": {
3
+ "total_parameters": 4540981545,
4
+ "total_size": 9085395108
5
+ },
6
+ "weight_map": {
7
+ "backbone.language_model.embed_tokens.weight": "model-00001-of-00003.safetensors",
8
+ "backbone.language_model.layers.0.input_layernorm.weight": "model-00001-of-00003.safetensors",
9
+ "backbone.language_model.layers.0.linear_attn.A_log": "model-00001-of-00003.safetensors",
10
+ "backbone.language_model.layers.0.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
11
+ "backbone.language_model.layers.0.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
12
+ "backbone.language_model.layers.0.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
13
+ "backbone.language_model.layers.0.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
14
+ "backbone.language_model.layers.0.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
15
+ "backbone.language_model.layers.0.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
16
+ "backbone.language_model.layers.0.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
17
+ "backbone.language_model.layers.0.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
18
+ "backbone.language_model.layers.0.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
19
+ "backbone.language_model.layers.0.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
20
+ "backbone.language_model.layers.0.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
21
+ "backbone.language_model.layers.0.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
22
+ "backbone.language_model.layers.1.input_layernorm.weight": "model-00001-of-00003.safetensors",
23
+ "backbone.language_model.layers.1.linear_attn.A_log": "model-00001-of-00003.safetensors",
24
+ "backbone.language_model.layers.1.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
25
+ "backbone.language_model.layers.1.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
26
+ "backbone.language_model.layers.1.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
27
+ "backbone.language_model.layers.1.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
28
+ "backbone.language_model.layers.1.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
29
+ "backbone.language_model.layers.1.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
30
+ "backbone.language_model.layers.1.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
31
+ "backbone.language_model.layers.1.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
32
+ "backbone.language_model.layers.1.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
33
+ "backbone.language_model.layers.1.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
34
+ "backbone.language_model.layers.1.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
35
+ "backbone.language_model.layers.1.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
36
+ "backbone.language_model.layers.10.input_layernorm.weight": "model-00001-of-00003.safetensors",
37
+ "backbone.language_model.layers.10.linear_attn.A_log": "model-00001-of-00003.safetensors",
38
+ "backbone.language_model.layers.10.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
39
+ "backbone.language_model.layers.10.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
40
+ "backbone.language_model.layers.10.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
41
+ "backbone.language_model.layers.10.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
42
+ "backbone.language_model.layers.10.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
43
+ "backbone.language_model.layers.10.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
44
+ "backbone.language_model.layers.10.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
45
+ "backbone.language_model.layers.10.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
46
+ "backbone.language_model.layers.10.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
47
+ "backbone.language_model.layers.10.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
48
+ "backbone.language_model.layers.10.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
49
+ "backbone.language_model.layers.10.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
50
+ "backbone.language_model.layers.11.input_layernorm.weight": "model-00001-of-00003.safetensors",
51
+ "backbone.language_model.layers.11.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
52
+ "backbone.language_model.layers.11.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
53
+ "backbone.language_model.layers.11.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
54
+ "backbone.language_model.layers.11.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
55
+ "backbone.language_model.layers.11.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
56
+ "backbone.language_model.layers.11.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
57
+ "backbone.language_model.layers.11.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
58
+ "backbone.language_model.layers.11.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
59
+ "backbone.language_model.layers.11.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
60
+ "backbone.language_model.layers.11.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
61
+ "backbone.language_model.layers.12.input_layernorm.weight": "model-00001-of-00003.safetensors",
62
+ "backbone.language_model.layers.12.linear_attn.A_log": "model-00001-of-00003.safetensors",
63
+ "backbone.language_model.layers.12.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
64
+ "backbone.language_model.layers.12.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
65
+ "backbone.language_model.layers.12.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
66
+ "backbone.language_model.layers.12.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
67
+ "backbone.language_model.layers.12.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
68
+ "backbone.language_model.layers.12.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
69
+ "backbone.language_model.layers.12.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
70
+ "backbone.language_model.layers.12.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
71
+ "backbone.language_model.layers.12.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
72
+ "backbone.language_model.layers.12.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
73
+ "backbone.language_model.layers.12.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
74
+ "backbone.language_model.layers.12.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
75
+ "backbone.language_model.layers.13.input_layernorm.weight": "model-00002-of-00003.safetensors",
76
+ "backbone.language_model.layers.13.linear_attn.A_log": "model-00002-of-00003.safetensors",
77
+ "backbone.language_model.layers.13.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
78
+ "backbone.language_model.layers.13.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
79
+ "backbone.language_model.layers.13.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
80
+ "backbone.language_model.layers.13.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
81
+ "backbone.language_model.layers.13.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
82
+ "backbone.language_model.layers.13.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
83
+ "backbone.language_model.layers.13.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
84
+ "backbone.language_model.layers.13.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
85
+ "backbone.language_model.layers.13.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
86
+ "backbone.language_model.layers.13.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
87
+ "backbone.language_model.layers.13.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
88
+ "backbone.language_model.layers.13.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
89
+ "backbone.language_model.layers.14.input_layernorm.weight": "model-00002-of-00003.safetensors",
90
+ "backbone.language_model.layers.14.linear_attn.A_log": "model-00002-of-00003.safetensors",
91
+ "backbone.language_model.layers.14.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
92
+ "backbone.language_model.layers.14.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
93
+ "backbone.language_model.layers.14.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
94
+ "backbone.language_model.layers.14.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
95
+ "backbone.language_model.layers.14.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
96
+ "backbone.language_model.layers.14.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
97
+ "backbone.language_model.layers.14.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
98
+ "backbone.language_model.layers.14.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
99
+ "backbone.language_model.layers.14.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
100
+ "backbone.language_model.layers.14.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
101
+ "backbone.language_model.layers.14.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
102
+ "backbone.language_model.layers.14.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
103
+ "backbone.language_model.layers.15.input_layernorm.weight": "model-00002-of-00003.safetensors",
104
+ "backbone.language_model.layers.15.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
105
+ "backbone.language_model.layers.15.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
106
+ "backbone.language_model.layers.15.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
107
+ "backbone.language_model.layers.15.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
108
+ "backbone.language_model.layers.15.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
109
+ "backbone.language_model.layers.15.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
110
+ "backbone.language_model.layers.15.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
111
+ "backbone.language_model.layers.15.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
112
+ "backbone.language_model.layers.15.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
113
+ "backbone.language_model.layers.15.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
114
+ "backbone.language_model.layers.16.input_layernorm.weight": "model-00002-of-00003.safetensors",
115
+ "backbone.language_model.layers.16.linear_attn.A_log": "model-00002-of-00003.safetensors",
116
+ "backbone.language_model.layers.16.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
117
+ "backbone.language_model.layers.16.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
118
+ "backbone.language_model.layers.16.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
119
+ "backbone.language_model.layers.16.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
120
+ "backbone.language_model.layers.16.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
121
+ "backbone.language_model.layers.16.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
122
+ "backbone.language_model.layers.16.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
123
+ "backbone.language_model.layers.16.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
124
+ "backbone.language_model.layers.16.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
125
+ "backbone.language_model.layers.16.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
126
+ "backbone.language_model.layers.16.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
127
+ "backbone.language_model.layers.16.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
128
+ "backbone.language_model.layers.17.input_layernorm.weight": "model-00002-of-00003.safetensors",
129
+ "backbone.language_model.layers.17.linear_attn.A_log": "model-00002-of-00003.safetensors",
130
+ "backbone.language_model.layers.17.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
131
+ "backbone.language_model.layers.17.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
132
+ "backbone.language_model.layers.17.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
133
+ "backbone.language_model.layers.17.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
134
+ "backbone.language_model.layers.17.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
135
+ "backbone.language_model.layers.17.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
136
+ "backbone.language_model.layers.17.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
137
+ "backbone.language_model.layers.17.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
138
+ "backbone.language_model.layers.17.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
139
+ "backbone.language_model.layers.17.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
140
+ "backbone.language_model.layers.17.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
141
+ "backbone.language_model.layers.17.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
142
+ "backbone.language_model.layers.18.input_layernorm.weight": "model-00002-of-00003.safetensors",
143
+ "backbone.language_model.layers.18.linear_attn.A_log": "model-00002-of-00003.safetensors",
144
+ "backbone.language_model.layers.18.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
145
+ "backbone.language_model.layers.18.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
146
+ "backbone.language_model.layers.18.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
147
+ "backbone.language_model.layers.18.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
148
+ "backbone.language_model.layers.18.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
149
+ "backbone.language_model.layers.18.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
150
+ "backbone.language_model.layers.18.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
151
+ "backbone.language_model.layers.18.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
152
+ "backbone.language_model.layers.18.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
153
+ "backbone.language_model.layers.18.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
154
+ "backbone.language_model.layers.18.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
155
+ "backbone.language_model.layers.18.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
156
+ "backbone.language_model.layers.19.input_layernorm.weight": "model-00002-of-00003.safetensors",
157
+ "backbone.language_model.layers.19.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
158
+ "backbone.language_model.layers.19.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
159
+ "backbone.language_model.layers.19.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
160
+ "backbone.language_model.layers.19.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
161
+ "backbone.language_model.layers.19.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
162
+ "backbone.language_model.layers.19.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
163
+ "backbone.language_model.layers.19.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
164
+ "backbone.language_model.layers.19.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
165
+ "backbone.language_model.layers.19.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
166
+ "backbone.language_model.layers.19.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
167
+ "backbone.language_model.layers.2.input_layernorm.weight": "model-00001-of-00003.safetensors",
168
+ "backbone.language_model.layers.2.linear_attn.A_log": "model-00001-of-00003.safetensors",
169
+ "backbone.language_model.layers.2.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
170
+ "backbone.language_model.layers.2.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
171
+ "backbone.language_model.layers.2.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
172
+ "backbone.language_model.layers.2.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
173
+ "backbone.language_model.layers.2.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
174
+ "backbone.language_model.layers.2.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
175
+ "backbone.language_model.layers.2.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
176
+ "backbone.language_model.layers.2.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
177
+ "backbone.language_model.layers.2.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
178
+ "backbone.language_model.layers.2.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
179
+ "backbone.language_model.layers.2.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
180
+ "backbone.language_model.layers.2.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
181
+ "backbone.language_model.layers.20.input_layernorm.weight": "model-00002-of-00003.safetensors",
182
+ "backbone.language_model.layers.20.linear_attn.A_log": "model-00002-of-00003.safetensors",
183
+ "backbone.language_model.layers.20.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
184
+ "backbone.language_model.layers.20.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
185
+ "backbone.language_model.layers.20.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
186
+ "backbone.language_model.layers.20.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
187
+ "backbone.language_model.layers.20.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
188
+ "backbone.language_model.layers.20.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
189
+ "backbone.language_model.layers.20.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
190
+ "backbone.language_model.layers.20.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
191
+ "backbone.language_model.layers.20.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
192
+ "backbone.language_model.layers.20.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
193
+ "backbone.language_model.layers.20.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
194
+ "backbone.language_model.layers.20.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
195
+ "backbone.language_model.layers.21.input_layernorm.weight": "model-00002-of-00003.safetensors",
196
+ "backbone.language_model.layers.21.linear_attn.A_log": "model-00002-of-00003.safetensors",
197
+ "backbone.language_model.layers.21.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
198
+ "backbone.language_model.layers.21.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
199
+ "backbone.language_model.layers.21.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
200
+ "backbone.language_model.layers.21.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
201
+ "backbone.language_model.layers.21.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
202
+ "backbone.language_model.layers.21.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
203
+ "backbone.language_model.layers.21.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
204
+ "backbone.language_model.layers.21.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
205
+ "backbone.language_model.layers.21.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
206
+ "backbone.language_model.layers.21.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
207
+ "backbone.language_model.layers.21.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
208
+ "backbone.language_model.layers.21.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
209
+ "backbone.language_model.layers.22.input_layernorm.weight": "model-00002-of-00003.safetensors",
210
+ "backbone.language_model.layers.22.linear_attn.A_log": "model-00002-of-00003.safetensors",
211
+ "backbone.language_model.layers.22.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
212
+ "backbone.language_model.layers.22.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
213
+ "backbone.language_model.layers.22.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
214
+ "backbone.language_model.layers.22.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
215
+ "backbone.language_model.layers.22.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
216
+ "backbone.language_model.layers.22.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
217
+ "backbone.language_model.layers.22.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
218
+ "backbone.language_model.layers.22.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
219
+ "backbone.language_model.layers.22.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
220
+ "backbone.language_model.layers.22.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
221
+ "backbone.language_model.layers.22.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
222
+ "backbone.language_model.layers.22.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
223
+ "backbone.language_model.layers.23.input_layernorm.weight": "model-00002-of-00003.safetensors",
224
+ "backbone.language_model.layers.23.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
225
+ "backbone.language_model.layers.23.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
226
+ "backbone.language_model.layers.23.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
227
+ "backbone.language_model.layers.23.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
228
+ "backbone.language_model.layers.23.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
229
+ "backbone.language_model.layers.23.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
230
+ "backbone.language_model.layers.23.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
231
+ "backbone.language_model.layers.23.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
232
+ "backbone.language_model.layers.23.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
233
+ "backbone.language_model.layers.23.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
234
+ "backbone.language_model.layers.24.input_layernorm.weight": "model-00002-of-00003.safetensors",
235
+ "backbone.language_model.layers.24.linear_attn.A_log": "model-00002-of-00003.safetensors",
236
+ "backbone.language_model.layers.24.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
237
+ "backbone.language_model.layers.24.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
238
+ "backbone.language_model.layers.24.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
239
+ "backbone.language_model.layers.24.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
240
+ "backbone.language_model.layers.24.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
241
+ "backbone.language_model.layers.24.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
242
+ "backbone.language_model.layers.24.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
243
+ "backbone.language_model.layers.24.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
244
+ "backbone.language_model.layers.24.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
245
+ "backbone.language_model.layers.24.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
246
+ "backbone.language_model.layers.24.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
247
+ "backbone.language_model.layers.24.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
248
+ "backbone.language_model.layers.25.input_layernorm.weight": "model-00002-of-00003.safetensors",
249
+ "backbone.language_model.layers.25.linear_attn.A_log": "model-00002-of-00003.safetensors",
250
+ "backbone.language_model.layers.25.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
251
+ "backbone.language_model.layers.25.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
252
+ "backbone.language_model.layers.25.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
253
+ "backbone.language_model.layers.25.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
254
+ "backbone.language_model.layers.25.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
255
+ "backbone.language_model.layers.25.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
256
+ "backbone.language_model.layers.25.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
257
+ "backbone.language_model.layers.25.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
258
+ "backbone.language_model.layers.25.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
259
+ "backbone.language_model.layers.25.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
260
+ "backbone.language_model.layers.25.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
261
+ "backbone.language_model.layers.25.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
262
+ "backbone.language_model.layers.26.input_layernorm.weight": "model-00002-of-00003.safetensors",
263
+ "backbone.language_model.layers.26.linear_attn.A_log": "model-00002-of-00003.safetensors",
264
+ "backbone.language_model.layers.26.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
265
+ "backbone.language_model.layers.26.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
266
+ "backbone.language_model.layers.26.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
267
+ "backbone.language_model.layers.26.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
268
+ "backbone.language_model.layers.26.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
269
+ "backbone.language_model.layers.26.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
270
+ "backbone.language_model.layers.26.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
271
+ "backbone.language_model.layers.26.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
272
+ "backbone.language_model.layers.26.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
273
+ "backbone.language_model.layers.26.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
274
+ "backbone.language_model.layers.26.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
275
+ "backbone.language_model.layers.26.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
276
+ "backbone.language_model.layers.27.input_layernorm.weight": "model-00002-of-00003.safetensors",
277
+ "backbone.language_model.layers.27.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
278
+ "backbone.language_model.layers.27.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
279
+ "backbone.language_model.layers.27.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
280
+ "backbone.language_model.layers.27.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
281
+ "backbone.language_model.layers.27.self_attn.k_norm.weight": "model-00002-of-00003.safetensors",
282
+ "backbone.language_model.layers.27.self_attn.k_proj.weight": "model-00002-of-00003.safetensors",
283
+ "backbone.language_model.layers.27.self_attn.o_proj.weight": "model-00002-of-00003.safetensors",
284
+ "backbone.language_model.layers.27.self_attn.q_norm.weight": "model-00002-of-00003.safetensors",
285
+ "backbone.language_model.layers.27.self_attn.q_proj.weight": "model-00002-of-00003.safetensors",
286
+ "backbone.language_model.layers.27.self_attn.v_proj.weight": "model-00002-of-00003.safetensors",
287
+ "backbone.language_model.layers.28.input_layernorm.weight": "model-00002-of-00003.safetensors",
288
+ "backbone.language_model.layers.28.linear_attn.A_log": "model-00002-of-00003.safetensors",
289
+ "backbone.language_model.layers.28.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
290
+ "backbone.language_model.layers.28.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
291
+ "backbone.language_model.layers.28.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
292
+ "backbone.language_model.layers.28.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
293
+ "backbone.language_model.layers.28.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
294
+ "backbone.language_model.layers.28.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
295
+ "backbone.language_model.layers.28.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
296
+ "backbone.language_model.layers.28.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
297
+ "backbone.language_model.layers.28.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
298
+ "backbone.language_model.layers.28.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
299
+ "backbone.language_model.layers.28.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
300
+ "backbone.language_model.layers.28.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
301
+ "backbone.language_model.layers.29.input_layernorm.weight": "model-00002-of-00003.safetensors",
302
+ "backbone.language_model.layers.29.linear_attn.A_log": "model-00002-of-00003.safetensors",
303
+ "backbone.language_model.layers.29.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
304
+ "backbone.language_model.layers.29.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
305
+ "backbone.language_model.layers.29.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
306
+ "backbone.language_model.layers.29.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
307
+ "backbone.language_model.layers.29.linear_attn.in_proj_qkv.weight": "model-00002-of-00003.safetensors",
308
+ "backbone.language_model.layers.29.linear_attn.in_proj_z.weight": "model-00002-of-00003.safetensors",
309
+ "backbone.language_model.layers.29.linear_attn.norm.weight": "model-00002-of-00003.safetensors",
310
+ "backbone.language_model.layers.29.linear_attn.out_proj.weight": "model-00002-of-00003.safetensors",
311
+ "backbone.language_model.layers.29.mlp.down_proj.weight": "model-00002-of-00003.safetensors",
312
+ "backbone.language_model.layers.29.mlp.gate_proj.weight": "model-00002-of-00003.safetensors",
313
+ "backbone.language_model.layers.29.mlp.up_proj.weight": "model-00002-of-00003.safetensors",
314
+ "backbone.language_model.layers.29.post_attention_layernorm.weight": "model-00002-of-00003.safetensors",
315
+ "backbone.language_model.layers.3.input_layernorm.weight": "model-00001-of-00003.safetensors",
316
+ "backbone.language_model.layers.3.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
317
+ "backbone.language_model.layers.3.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
318
+ "backbone.language_model.layers.3.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
319
+ "backbone.language_model.layers.3.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
320
+ "backbone.language_model.layers.3.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
321
+ "backbone.language_model.layers.3.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
322
+ "backbone.language_model.layers.3.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
323
+ "backbone.language_model.layers.3.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
324
+ "backbone.language_model.layers.3.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
325
+ "backbone.language_model.layers.3.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
326
+ "backbone.language_model.layers.30.input_layernorm.weight": "model-00002-of-00003.safetensors",
327
+ "backbone.language_model.layers.30.linear_attn.A_log": "model-00002-of-00003.safetensors",
328
+ "backbone.language_model.layers.30.linear_attn.conv1d.weight": "model-00002-of-00003.safetensors",
329
+ "backbone.language_model.layers.30.linear_attn.dt_bias": "model-00002-of-00003.safetensors",
330
+ "backbone.language_model.layers.30.linear_attn.in_proj_a.weight": "model-00002-of-00003.safetensors",
331
+ "backbone.language_model.layers.30.linear_attn.in_proj_b.weight": "model-00002-of-00003.safetensors",
332
+ "backbone.language_model.layers.30.linear_attn.in_proj_qkv.weight": "model-00003-of-00003.safetensors",
333
+ "backbone.language_model.layers.30.linear_attn.in_proj_z.weight": "model-00003-of-00003.safetensors",
334
+ "backbone.language_model.layers.30.linear_attn.norm.weight": "model-00003-of-00003.safetensors",
335
+ "backbone.language_model.layers.30.linear_attn.out_proj.weight": "model-00003-of-00003.safetensors",
336
+ "backbone.language_model.layers.30.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
337
+ "backbone.language_model.layers.30.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
338
+ "backbone.language_model.layers.30.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
339
+ "backbone.language_model.layers.30.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
340
+ "backbone.language_model.layers.31.input_layernorm.weight": "model-00003-of-00003.safetensors",
341
+ "backbone.language_model.layers.31.mlp.down_proj.weight": "model-00003-of-00003.safetensors",
342
+ "backbone.language_model.layers.31.mlp.gate_proj.weight": "model-00003-of-00003.safetensors",
343
+ "backbone.language_model.layers.31.mlp.up_proj.weight": "model-00003-of-00003.safetensors",
344
+ "backbone.language_model.layers.31.post_attention_layernorm.weight": "model-00003-of-00003.safetensors",
345
+ "backbone.language_model.layers.31.self_attn.k_norm.weight": "model-00003-of-00003.safetensors",
346
+ "backbone.language_model.layers.31.self_attn.k_proj.weight": "model-00003-of-00003.safetensors",
347
+ "backbone.language_model.layers.31.self_attn.o_proj.weight": "model-00003-of-00003.safetensors",
348
+ "backbone.language_model.layers.31.self_attn.q_norm.weight": "model-00003-of-00003.safetensors",
349
+ "backbone.language_model.layers.31.self_attn.q_proj.weight": "model-00003-of-00003.safetensors",
350
+ "backbone.language_model.layers.31.self_attn.v_proj.weight": "model-00003-of-00003.safetensors",
351
+ "backbone.language_model.layers.4.input_layernorm.weight": "model-00001-of-00003.safetensors",
352
+ "backbone.language_model.layers.4.linear_attn.A_log": "model-00001-of-00003.safetensors",
353
+ "backbone.language_model.layers.4.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
354
+ "backbone.language_model.layers.4.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
355
+ "backbone.language_model.layers.4.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
356
+ "backbone.language_model.layers.4.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
357
+ "backbone.language_model.layers.4.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
358
+ "backbone.language_model.layers.4.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
359
+ "backbone.language_model.layers.4.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
360
+ "backbone.language_model.layers.4.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
361
+ "backbone.language_model.layers.4.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
362
+ "backbone.language_model.layers.4.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
363
+ "backbone.language_model.layers.4.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
364
+ "backbone.language_model.layers.4.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
365
+ "backbone.language_model.layers.5.input_layernorm.weight": "model-00001-of-00003.safetensors",
366
+ "backbone.language_model.layers.5.linear_attn.A_log": "model-00001-of-00003.safetensors",
367
+ "backbone.language_model.layers.5.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
368
+ "backbone.language_model.layers.5.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
369
+ "backbone.language_model.layers.5.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
370
+ "backbone.language_model.layers.5.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
371
+ "backbone.language_model.layers.5.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
372
+ "backbone.language_model.layers.5.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
373
+ "backbone.language_model.layers.5.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
374
+ "backbone.language_model.layers.5.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
375
+ "backbone.language_model.layers.5.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
376
+ "backbone.language_model.layers.5.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
377
+ "backbone.language_model.layers.5.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
378
+ "backbone.language_model.layers.5.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
379
+ "backbone.language_model.layers.6.input_layernorm.weight": "model-00001-of-00003.safetensors",
380
+ "backbone.language_model.layers.6.linear_attn.A_log": "model-00001-of-00003.safetensors",
381
+ "backbone.language_model.layers.6.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
382
+ "backbone.language_model.layers.6.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
383
+ "backbone.language_model.layers.6.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
384
+ "backbone.language_model.layers.6.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
385
+ "backbone.language_model.layers.6.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
386
+ "backbone.language_model.layers.6.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
387
+ "backbone.language_model.layers.6.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
388
+ "backbone.language_model.layers.6.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
389
+ "backbone.language_model.layers.6.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
390
+ "backbone.language_model.layers.6.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
391
+ "backbone.language_model.layers.6.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
392
+ "backbone.language_model.layers.6.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
393
+ "backbone.language_model.layers.7.input_layernorm.weight": "model-00001-of-00003.safetensors",
394
+ "backbone.language_model.layers.7.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
395
+ "backbone.language_model.layers.7.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
396
+ "backbone.language_model.layers.7.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
397
+ "backbone.language_model.layers.7.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
398
+ "backbone.language_model.layers.7.self_attn.k_norm.weight": "model-00001-of-00003.safetensors",
399
+ "backbone.language_model.layers.7.self_attn.k_proj.weight": "model-00001-of-00003.safetensors",
400
+ "backbone.language_model.layers.7.self_attn.o_proj.weight": "model-00001-of-00003.safetensors",
401
+ "backbone.language_model.layers.7.self_attn.q_norm.weight": "model-00001-of-00003.safetensors",
402
+ "backbone.language_model.layers.7.self_attn.q_proj.weight": "model-00001-of-00003.safetensors",
403
+ "backbone.language_model.layers.7.self_attn.v_proj.weight": "model-00001-of-00003.safetensors",
404
+ "backbone.language_model.layers.8.input_layernorm.weight": "model-00001-of-00003.safetensors",
405
+ "backbone.language_model.layers.8.linear_attn.A_log": "model-00001-of-00003.safetensors",
406
+ "backbone.language_model.layers.8.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
407
+ "backbone.language_model.layers.8.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
408
+ "backbone.language_model.layers.8.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
409
+ "backbone.language_model.layers.8.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
410
+ "backbone.language_model.layers.8.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
411
+ "backbone.language_model.layers.8.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
412
+ "backbone.language_model.layers.8.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
413
+ "backbone.language_model.layers.8.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
414
+ "backbone.language_model.layers.8.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
415
+ "backbone.language_model.layers.8.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
416
+ "backbone.language_model.layers.8.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
417
+ "backbone.language_model.layers.8.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
418
+ "backbone.language_model.layers.9.input_layernorm.weight": "model-00001-of-00003.safetensors",
419
+ "backbone.language_model.layers.9.linear_attn.A_log": "model-00001-of-00003.safetensors",
420
+ "backbone.language_model.layers.9.linear_attn.conv1d.weight": "model-00001-of-00003.safetensors",
421
+ "backbone.language_model.layers.9.linear_attn.dt_bias": "model-00001-of-00003.safetensors",
422
+ "backbone.language_model.layers.9.linear_attn.in_proj_a.weight": "model-00001-of-00003.safetensors",
423
+ "backbone.language_model.layers.9.linear_attn.in_proj_b.weight": "model-00001-of-00003.safetensors",
424
+ "backbone.language_model.layers.9.linear_attn.in_proj_qkv.weight": "model-00001-of-00003.safetensors",
425
+ "backbone.language_model.layers.9.linear_attn.in_proj_z.weight": "model-00001-of-00003.safetensors",
426
+ "backbone.language_model.layers.9.linear_attn.norm.weight": "model-00001-of-00003.safetensors",
427
+ "backbone.language_model.layers.9.linear_attn.out_proj.weight": "model-00001-of-00003.safetensors",
428
+ "backbone.language_model.layers.9.mlp.down_proj.weight": "model-00001-of-00003.safetensors",
429
+ "backbone.language_model.layers.9.mlp.gate_proj.weight": "model-00001-of-00003.safetensors",
430
+ "backbone.language_model.layers.9.mlp.up_proj.weight": "model-00001-of-00003.safetensors",
431
+ "backbone.language_model.layers.9.post_attention_layernorm.weight": "model-00001-of-00003.safetensors",
432
+ "backbone.language_model.norm.weight": "model-00003-of-00003.safetensors",
433
+ "backbone.visual.blocks.0.attn.proj.bias": "model-00003-of-00003.safetensors",
434
+ "backbone.visual.blocks.0.attn.proj.weight": "model-00003-of-00003.safetensors",
435
+ "backbone.visual.blocks.0.attn.qkv.bias": "model-00003-of-00003.safetensors",
436
+ "backbone.visual.blocks.0.attn.qkv.weight": "model-00003-of-00003.safetensors",
437
+ "backbone.visual.blocks.0.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
438
+ "backbone.visual.blocks.0.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
439
+ "backbone.visual.blocks.0.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
440
+ "backbone.visual.blocks.0.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
441
+ "backbone.visual.blocks.0.norm1.bias": "model-00003-of-00003.safetensors",
442
+ "backbone.visual.blocks.0.norm1.weight": "model-00003-of-00003.safetensors",
443
+ "backbone.visual.blocks.0.norm2.bias": "model-00003-of-00003.safetensors",
444
+ "backbone.visual.blocks.0.norm2.weight": "model-00003-of-00003.safetensors",
445
+ "backbone.visual.blocks.1.attn.proj.bias": "model-00003-of-00003.safetensors",
446
+ "backbone.visual.blocks.1.attn.proj.weight": "model-00003-of-00003.safetensors",
447
+ "backbone.visual.blocks.1.attn.qkv.bias": "model-00003-of-00003.safetensors",
448
+ "backbone.visual.blocks.1.attn.qkv.weight": "model-00003-of-00003.safetensors",
449
+ "backbone.visual.blocks.1.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
450
+ "backbone.visual.blocks.1.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
451
+ "backbone.visual.blocks.1.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
452
+ "backbone.visual.blocks.1.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
453
+ "backbone.visual.blocks.1.norm1.bias": "model-00003-of-00003.safetensors",
454
+ "backbone.visual.blocks.1.norm1.weight": "model-00003-of-00003.safetensors",
455
+ "backbone.visual.blocks.1.norm2.bias": "model-00003-of-00003.safetensors",
456
+ "backbone.visual.blocks.1.norm2.weight": "model-00003-of-00003.safetensors",
457
+ "backbone.visual.blocks.10.attn.proj.bias": "model-00003-of-00003.safetensors",
458
+ "backbone.visual.blocks.10.attn.proj.weight": "model-00003-of-00003.safetensors",
459
+ "backbone.visual.blocks.10.attn.qkv.bias": "model-00003-of-00003.safetensors",
460
+ "backbone.visual.blocks.10.attn.qkv.weight": "model-00003-of-00003.safetensors",
461
+ "backbone.visual.blocks.10.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
462
+ "backbone.visual.blocks.10.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
463
+ "backbone.visual.blocks.10.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
464
+ "backbone.visual.blocks.10.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
465
+ "backbone.visual.blocks.10.norm1.bias": "model-00003-of-00003.safetensors",
466
+ "backbone.visual.blocks.10.norm1.weight": "model-00003-of-00003.safetensors",
467
+ "backbone.visual.blocks.10.norm2.bias": "model-00003-of-00003.safetensors",
468
+ "backbone.visual.blocks.10.norm2.weight": "model-00003-of-00003.safetensors",
469
+ "backbone.visual.blocks.11.attn.proj.bias": "model-00003-of-00003.safetensors",
470
+ "backbone.visual.blocks.11.attn.proj.weight": "model-00003-of-00003.safetensors",
471
+ "backbone.visual.blocks.11.attn.qkv.bias": "model-00003-of-00003.safetensors",
472
+ "backbone.visual.blocks.11.attn.qkv.weight": "model-00003-of-00003.safetensors",
473
+ "backbone.visual.blocks.11.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
474
+ "backbone.visual.blocks.11.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
475
+ "backbone.visual.blocks.11.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
476
+ "backbone.visual.blocks.11.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
477
+ "backbone.visual.blocks.11.norm1.bias": "model-00003-of-00003.safetensors",
478
+ "backbone.visual.blocks.11.norm1.weight": "model-00003-of-00003.safetensors",
479
+ "backbone.visual.blocks.11.norm2.bias": "model-00003-of-00003.safetensors",
480
+ "backbone.visual.blocks.11.norm2.weight": "model-00003-of-00003.safetensors",
481
+ "backbone.visual.blocks.12.attn.proj.bias": "model-00003-of-00003.safetensors",
482
+ "backbone.visual.blocks.12.attn.proj.weight": "model-00003-of-00003.safetensors",
483
+ "backbone.visual.blocks.12.attn.qkv.bias": "model-00003-of-00003.safetensors",
484
+ "backbone.visual.blocks.12.attn.qkv.weight": "model-00003-of-00003.safetensors",
485
+ "backbone.visual.blocks.12.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
486
+ "backbone.visual.blocks.12.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
487
+ "backbone.visual.blocks.12.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
488
+ "backbone.visual.blocks.12.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
489
+ "backbone.visual.blocks.12.norm1.bias": "model-00003-of-00003.safetensors",
490
+ "backbone.visual.blocks.12.norm1.weight": "model-00003-of-00003.safetensors",
491
+ "backbone.visual.blocks.12.norm2.bias": "model-00003-of-00003.safetensors",
492
+ "backbone.visual.blocks.12.norm2.weight": "model-00003-of-00003.safetensors",
493
+ "backbone.visual.blocks.13.attn.proj.bias": "model-00003-of-00003.safetensors",
494
+ "backbone.visual.blocks.13.attn.proj.weight": "model-00003-of-00003.safetensors",
495
+ "backbone.visual.blocks.13.attn.qkv.bias": "model-00003-of-00003.safetensors",
496
+ "backbone.visual.blocks.13.attn.qkv.weight": "model-00003-of-00003.safetensors",
497
+ "backbone.visual.blocks.13.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
498
+ "backbone.visual.blocks.13.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
499
+ "backbone.visual.blocks.13.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
500
+ "backbone.visual.blocks.13.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
501
+ "backbone.visual.blocks.13.norm1.bias": "model-00003-of-00003.safetensors",
502
+ "backbone.visual.blocks.13.norm1.weight": "model-00003-of-00003.safetensors",
503
+ "backbone.visual.blocks.13.norm2.bias": "model-00003-of-00003.safetensors",
504
+ "backbone.visual.blocks.13.norm2.weight": "model-00003-of-00003.safetensors",
505
+ "backbone.visual.blocks.14.attn.proj.bias": "model-00003-of-00003.safetensors",
506
+ "backbone.visual.blocks.14.attn.proj.weight": "model-00003-of-00003.safetensors",
507
+ "backbone.visual.blocks.14.attn.qkv.bias": "model-00003-of-00003.safetensors",
508
+ "backbone.visual.blocks.14.attn.qkv.weight": "model-00003-of-00003.safetensors",
509
+ "backbone.visual.blocks.14.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
510
+ "backbone.visual.blocks.14.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
511
+ "backbone.visual.blocks.14.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
512
+ "backbone.visual.blocks.14.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
513
+ "backbone.visual.blocks.14.norm1.bias": "model-00003-of-00003.safetensors",
514
+ "backbone.visual.blocks.14.norm1.weight": "model-00003-of-00003.safetensors",
515
+ "backbone.visual.blocks.14.norm2.bias": "model-00003-of-00003.safetensors",
516
+ "backbone.visual.blocks.14.norm2.weight": "model-00003-of-00003.safetensors",
517
+ "backbone.visual.blocks.15.attn.proj.bias": "model-00003-of-00003.safetensors",
518
+ "backbone.visual.blocks.15.attn.proj.weight": "model-00003-of-00003.safetensors",
519
+ "backbone.visual.blocks.15.attn.qkv.bias": "model-00003-of-00003.safetensors",
520
+ "backbone.visual.blocks.15.attn.qkv.weight": "model-00003-of-00003.safetensors",
521
+ "backbone.visual.blocks.15.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
522
+ "backbone.visual.blocks.15.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
523
+ "backbone.visual.blocks.15.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
524
+ "backbone.visual.blocks.15.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
525
+ "backbone.visual.blocks.15.norm1.bias": "model-00003-of-00003.safetensors",
526
+ "backbone.visual.blocks.15.norm1.weight": "model-00003-of-00003.safetensors",
527
+ "backbone.visual.blocks.15.norm2.bias": "model-00003-of-00003.safetensors",
528
+ "backbone.visual.blocks.15.norm2.weight": "model-00003-of-00003.safetensors",
529
+ "backbone.visual.blocks.16.attn.proj.bias": "model-00003-of-00003.safetensors",
530
+ "backbone.visual.blocks.16.attn.proj.weight": "model-00003-of-00003.safetensors",
531
+ "backbone.visual.blocks.16.attn.qkv.bias": "model-00003-of-00003.safetensors",
532
+ "backbone.visual.blocks.16.attn.qkv.weight": "model-00003-of-00003.safetensors",
533
+ "backbone.visual.blocks.16.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
534
+ "backbone.visual.blocks.16.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
535
+ "backbone.visual.blocks.16.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
536
+ "backbone.visual.blocks.16.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
537
+ "backbone.visual.blocks.16.norm1.bias": "model-00003-of-00003.safetensors",
538
+ "backbone.visual.blocks.16.norm1.weight": "model-00003-of-00003.safetensors",
539
+ "backbone.visual.blocks.16.norm2.bias": "model-00003-of-00003.safetensors",
540
+ "backbone.visual.blocks.16.norm2.weight": "model-00003-of-00003.safetensors",
541
+ "backbone.visual.blocks.17.attn.proj.bias": "model-00003-of-00003.safetensors",
542
+ "backbone.visual.blocks.17.attn.proj.weight": "model-00003-of-00003.safetensors",
543
+ "backbone.visual.blocks.17.attn.qkv.bias": "model-00003-of-00003.safetensors",
544
+ "backbone.visual.blocks.17.attn.qkv.weight": "model-00003-of-00003.safetensors",
545
+ "backbone.visual.blocks.17.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
546
+ "backbone.visual.blocks.17.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
547
+ "backbone.visual.blocks.17.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
548
+ "backbone.visual.blocks.17.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
549
+ "backbone.visual.blocks.17.norm1.bias": "model-00003-of-00003.safetensors",
550
+ "backbone.visual.blocks.17.norm1.weight": "model-00003-of-00003.safetensors",
551
+ "backbone.visual.blocks.17.norm2.bias": "model-00003-of-00003.safetensors",
552
+ "backbone.visual.blocks.17.norm2.weight": "model-00003-of-00003.safetensors",
553
+ "backbone.visual.blocks.18.attn.proj.bias": "model-00003-of-00003.safetensors",
554
+ "backbone.visual.blocks.18.attn.proj.weight": "model-00003-of-00003.safetensors",
555
+ "backbone.visual.blocks.18.attn.qkv.bias": "model-00003-of-00003.safetensors",
556
+ "backbone.visual.blocks.18.attn.qkv.weight": "model-00003-of-00003.safetensors",
557
+ "backbone.visual.blocks.18.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
558
+ "backbone.visual.blocks.18.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
559
+ "backbone.visual.blocks.18.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
560
+ "backbone.visual.blocks.18.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
561
+ "backbone.visual.blocks.18.norm1.bias": "model-00003-of-00003.safetensors",
562
+ "backbone.visual.blocks.18.norm1.weight": "model-00003-of-00003.safetensors",
563
+ "backbone.visual.blocks.18.norm2.bias": "model-00003-of-00003.safetensors",
564
+ "backbone.visual.blocks.18.norm2.weight": "model-00003-of-00003.safetensors",
565
+ "backbone.visual.blocks.19.attn.proj.bias": "model-00003-of-00003.safetensors",
566
+ "backbone.visual.blocks.19.attn.proj.weight": "model-00003-of-00003.safetensors",
567
+ "backbone.visual.blocks.19.attn.qkv.bias": "model-00003-of-00003.safetensors",
568
+ "backbone.visual.blocks.19.attn.qkv.weight": "model-00003-of-00003.safetensors",
569
+ "backbone.visual.blocks.19.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
570
+ "backbone.visual.blocks.19.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
571
+ "backbone.visual.blocks.19.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
572
+ "backbone.visual.blocks.19.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
573
+ "backbone.visual.blocks.19.norm1.bias": "model-00003-of-00003.safetensors",
574
+ "backbone.visual.blocks.19.norm1.weight": "model-00003-of-00003.safetensors",
575
+ "backbone.visual.blocks.19.norm2.bias": "model-00003-of-00003.safetensors",
576
+ "backbone.visual.blocks.19.norm2.weight": "model-00003-of-00003.safetensors",
577
+ "backbone.visual.blocks.2.attn.proj.bias": "model-00003-of-00003.safetensors",
578
+ "backbone.visual.blocks.2.attn.proj.weight": "model-00003-of-00003.safetensors",
579
+ "backbone.visual.blocks.2.attn.qkv.bias": "model-00003-of-00003.safetensors",
580
+ "backbone.visual.blocks.2.attn.qkv.weight": "model-00003-of-00003.safetensors",
581
+ "backbone.visual.blocks.2.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
582
+ "backbone.visual.blocks.2.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
583
+ "backbone.visual.blocks.2.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
584
+ "backbone.visual.blocks.2.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
585
+ "backbone.visual.blocks.2.norm1.bias": "model-00003-of-00003.safetensors",
586
+ "backbone.visual.blocks.2.norm1.weight": "model-00003-of-00003.safetensors",
587
+ "backbone.visual.blocks.2.norm2.bias": "model-00003-of-00003.safetensors",
588
+ "backbone.visual.blocks.2.norm2.weight": "model-00003-of-00003.safetensors",
589
+ "backbone.visual.blocks.20.attn.proj.bias": "model-00003-of-00003.safetensors",
590
+ "backbone.visual.blocks.20.attn.proj.weight": "model-00003-of-00003.safetensors",
591
+ "backbone.visual.blocks.20.attn.qkv.bias": "model-00003-of-00003.safetensors",
592
+ "backbone.visual.blocks.20.attn.qkv.weight": "model-00003-of-00003.safetensors",
593
+ "backbone.visual.blocks.20.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
594
+ "backbone.visual.blocks.20.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
595
+ "backbone.visual.blocks.20.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
596
+ "backbone.visual.blocks.20.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
597
+ "backbone.visual.blocks.20.norm1.bias": "model-00003-of-00003.safetensors",
598
+ "backbone.visual.blocks.20.norm1.weight": "model-00003-of-00003.safetensors",
599
+ "backbone.visual.blocks.20.norm2.bias": "model-00003-of-00003.safetensors",
600
+ "backbone.visual.blocks.20.norm2.weight": "model-00003-of-00003.safetensors",
601
+ "backbone.visual.blocks.21.attn.proj.bias": "model-00003-of-00003.safetensors",
602
+ "backbone.visual.blocks.21.attn.proj.weight": "model-00003-of-00003.safetensors",
603
+ "backbone.visual.blocks.21.attn.qkv.bias": "model-00003-of-00003.safetensors",
604
+ "backbone.visual.blocks.21.attn.qkv.weight": "model-00003-of-00003.safetensors",
605
+ "backbone.visual.blocks.21.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
606
+ "backbone.visual.blocks.21.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
607
+ "backbone.visual.blocks.21.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
608
+ "backbone.visual.blocks.21.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
609
+ "backbone.visual.blocks.21.norm1.bias": "model-00003-of-00003.safetensors",
610
+ "backbone.visual.blocks.21.norm1.weight": "model-00003-of-00003.safetensors",
611
+ "backbone.visual.blocks.21.norm2.bias": "model-00003-of-00003.safetensors",
612
+ "backbone.visual.blocks.21.norm2.weight": "model-00003-of-00003.safetensors",
613
+ "backbone.visual.blocks.22.attn.proj.bias": "model-00003-of-00003.safetensors",
614
+ "backbone.visual.blocks.22.attn.proj.weight": "model-00003-of-00003.safetensors",
615
+ "backbone.visual.blocks.22.attn.qkv.bias": "model-00003-of-00003.safetensors",
616
+ "backbone.visual.blocks.22.attn.qkv.weight": "model-00003-of-00003.safetensors",
617
+ "backbone.visual.blocks.22.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
618
+ "backbone.visual.blocks.22.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
619
+ "backbone.visual.blocks.22.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
620
+ "backbone.visual.blocks.22.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
621
+ "backbone.visual.blocks.22.norm1.bias": "model-00003-of-00003.safetensors",
622
+ "backbone.visual.blocks.22.norm1.weight": "model-00003-of-00003.safetensors",
623
+ "backbone.visual.blocks.22.norm2.bias": "model-00003-of-00003.safetensors",
624
+ "backbone.visual.blocks.22.norm2.weight": "model-00003-of-00003.safetensors",
625
+ "backbone.visual.blocks.23.attn.proj.bias": "model-00003-of-00003.safetensors",
626
+ "backbone.visual.blocks.23.attn.proj.weight": "model-00003-of-00003.safetensors",
627
+ "backbone.visual.blocks.23.attn.qkv.bias": "model-00003-of-00003.safetensors",
628
+ "backbone.visual.blocks.23.attn.qkv.weight": "model-00003-of-00003.safetensors",
629
+ "backbone.visual.blocks.23.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
630
+ "backbone.visual.blocks.23.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
631
+ "backbone.visual.blocks.23.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
632
+ "backbone.visual.blocks.23.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
633
+ "backbone.visual.blocks.23.norm1.bias": "model-00003-of-00003.safetensors",
634
+ "backbone.visual.blocks.23.norm1.weight": "model-00003-of-00003.safetensors",
635
+ "backbone.visual.blocks.23.norm2.bias": "model-00003-of-00003.safetensors",
636
+ "backbone.visual.blocks.23.norm2.weight": "model-00003-of-00003.safetensors",
637
+ "backbone.visual.blocks.3.attn.proj.bias": "model-00003-of-00003.safetensors",
638
+ "backbone.visual.blocks.3.attn.proj.weight": "model-00003-of-00003.safetensors",
639
+ "backbone.visual.blocks.3.attn.qkv.bias": "model-00003-of-00003.safetensors",
640
+ "backbone.visual.blocks.3.attn.qkv.weight": "model-00003-of-00003.safetensors",
641
+ "backbone.visual.blocks.3.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
642
+ "backbone.visual.blocks.3.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
643
+ "backbone.visual.blocks.3.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
644
+ "backbone.visual.blocks.3.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
645
+ "backbone.visual.blocks.3.norm1.bias": "model-00003-of-00003.safetensors",
646
+ "backbone.visual.blocks.3.norm1.weight": "model-00003-of-00003.safetensors",
647
+ "backbone.visual.blocks.3.norm2.bias": "model-00003-of-00003.safetensors",
648
+ "backbone.visual.blocks.3.norm2.weight": "model-00003-of-00003.safetensors",
649
+ "backbone.visual.blocks.4.attn.proj.bias": "model-00003-of-00003.safetensors",
650
+ "backbone.visual.blocks.4.attn.proj.weight": "model-00003-of-00003.safetensors",
651
+ "backbone.visual.blocks.4.attn.qkv.bias": "model-00003-of-00003.safetensors",
652
+ "backbone.visual.blocks.4.attn.qkv.weight": "model-00003-of-00003.safetensors",
653
+ "backbone.visual.blocks.4.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
654
+ "backbone.visual.blocks.4.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
655
+ "backbone.visual.blocks.4.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
656
+ "backbone.visual.blocks.4.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
657
+ "backbone.visual.blocks.4.norm1.bias": "model-00003-of-00003.safetensors",
658
+ "backbone.visual.blocks.4.norm1.weight": "model-00003-of-00003.safetensors",
659
+ "backbone.visual.blocks.4.norm2.bias": "model-00003-of-00003.safetensors",
660
+ "backbone.visual.blocks.4.norm2.weight": "model-00003-of-00003.safetensors",
661
+ "backbone.visual.blocks.5.attn.proj.bias": "model-00003-of-00003.safetensors",
662
+ "backbone.visual.blocks.5.attn.proj.weight": "model-00003-of-00003.safetensors",
663
+ "backbone.visual.blocks.5.attn.qkv.bias": "model-00003-of-00003.safetensors",
664
+ "backbone.visual.blocks.5.attn.qkv.weight": "model-00003-of-00003.safetensors",
665
+ "backbone.visual.blocks.5.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
666
+ "backbone.visual.blocks.5.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
667
+ "backbone.visual.blocks.5.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
668
+ "backbone.visual.blocks.5.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
669
+ "backbone.visual.blocks.5.norm1.bias": "model-00003-of-00003.safetensors",
670
+ "backbone.visual.blocks.5.norm1.weight": "model-00003-of-00003.safetensors",
671
+ "backbone.visual.blocks.5.norm2.bias": "model-00003-of-00003.safetensors",
672
+ "backbone.visual.blocks.5.norm2.weight": "model-00003-of-00003.safetensors",
673
+ "backbone.visual.blocks.6.attn.proj.bias": "model-00003-of-00003.safetensors",
674
+ "backbone.visual.blocks.6.attn.proj.weight": "model-00003-of-00003.safetensors",
675
+ "backbone.visual.blocks.6.attn.qkv.bias": "model-00003-of-00003.safetensors",
676
+ "backbone.visual.blocks.6.attn.qkv.weight": "model-00003-of-00003.safetensors",
677
+ "backbone.visual.blocks.6.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
678
+ "backbone.visual.blocks.6.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
679
+ "backbone.visual.blocks.6.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
680
+ "backbone.visual.blocks.6.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
681
+ "backbone.visual.blocks.6.norm1.bias": "model-00003-of-00003.safetensors",
682
+ "backbone.visual.blocks.6.norm1.weight": "model-00003-of-00003.safetensors",
683
+ "backbone.visual.blocks.6.norm2.bias": "model-00003-of-00003.safetensors",
684
+ "backbone.visual.blocks.6.norm2.weight": "model-00003-of-00003.safetensors",
685
+ "backbone.visual.blocks.7.attn.proj.bias": "model-00003-of-00003.safetensors",
686
+ "backbone.visual.blocks.7.attn.proj.weight": "model-00003-of-00003.safetensors",
687
+ "backbone.visual.blocks.7.attn.qkv.bias": "model-00003-of-00003.safetensors",
688
+ "backbone.visual.blocks.7.attn.qkv.weight": "model-00003-of-00003.safetensors",
689
+ "backbone.visual.blocks.7.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
690
+ "backbone.visual.blocks.7.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
691
+ "backbone.visual.blocks.7.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
692
+ "backbone.visual.blocks.7.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
693
+ "backbone.visual.blocks.7.norm1.bias": "model-00003-of-00003.safetensors",
694
+ "backbone.visual.blocks.7.norm1.weight": "model-00003-of-00003.safetensors",
695
+ "backbone.visual.blocks.7.norm2.bias": "model-00003-of-00003.safetensors",
696
+ "backbone.visual.blocks.7.norm2.weight": "model-00003-of-00003.safetensors",
697
+ "backbone.visual.blocks.8.attn.proj.bias": "model-00003-of-00003.safetensors",
698
+ "backbone.visual.blocks.8.attn.proj.weight": "model-00003-of-00003.safetensors",
699
+ "backbone.visual.blocks.8.attn.qkv.bias": "model-00003-of-00003.safetensors",
700
+ "backbone.visual.blocks.8.attn.qkv.weight": "model-00003-of-00003.safetensors",
701
+ "backbone.visual.blocks.8.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
702
+ "backbone.visual.blocks.8.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
703
+ "backbone.visual.blocks.8.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
704
+ "backbone.visual.blocks.8.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
705
+ "backbone.visual.blocks.8.norm1.bias": "model-00003-of-00003.safetensors",
706
+ "backbone.visual.blocks.8.norm1.weight": "model-00003-of-00003.safetensors",
707
+ "backbone.visual.blocks.8.norm2.bias": "model-00003-of-00003.safetensors",
708
+ "backbone.visual.blocks.8.norm2.weight": "model-00003-of-00003.safetensors",
709
+ "backbone.visual.blocks.9.attn.proj.bias": "model-00003-of-00003.safetensors",
710
+ "backbone.visual.blocks.9.attn.proj.weight": "model-00003-of-00003.safetensors",
711
+ "backbone.visual.blocks.9.attn.qkv.bias": "model-00003-of-00003.safetensors",
712
+ "backbone.visual.blocks.9.attn.qkv.weight": "model-00003-of-00003.safetensors",
713
+ "backbone.visual.blocks.9.mlp.linear_fc1.bias": "model-00003-of-00003.safetensors",
714
+ "backbone.visual.blocks.9.mlp.linear_fc1.weight": "model-00003-of-00003.safetensors",
715
+ "backbone.visual.blocks.9.mlp.linear_fc2.bias": "model-00003-of-00003.safetensors",
716
+ "backbone.visual.blocks.9.mlp.linear_fc2.weight": "model-00003-of-00003.safetensors",
717
+ "backbone.visual.blocks.9.norm1.bias": "model-00003-of-00003.safetensors",
718
+ "backbone.visual.blocks.9.norm1.weight": "model-00003-of-00003.safetensors",
719
+ "backbone.visual.blocks.9.norm2.bias": "model-00003-of-00003.safetensors",
720
+ "backbone.visual.blocks.9.norm2.weight": "model-00003-of-00003.safetensors",
721
+ "backbone.visual.merger.linear_fc1.bias": "model-00003-of-00003.safetensors",
722
+ "backbone.visual.merger.linear_fc1.weight": "model-00003-of-00003.safetensors",
723
+ "backbone.visual.merger.linear_fc2.bias": "model-00003-of-00003.safetensors",
724
+ "backbone.visual.merger.linear_fc2.weight": "model-00003-of-00003.safetensors",
725
+ "backbone.visual.merger.norm.bias": "model-00003-of-00003.safetensors",
726
+ "backbone.visual.merger.norm.weight": "model-00003-of-00003.safetensors",
727
+ "backbone.visual.patch_embed.proj.bias": "model-00003-of-00003.safetensors",
728
+ "backbone.visual.patch_embed.proj.weight": "model-00003-of-00003.safetensors",
729
+ "backbone.visual.pos_embed.weight": "model-00003-of-00003.safetensors",
730
+ "head.blocks.0.channel_mlp.0.bias": "model-00003-of-00003.safetensors",
731
+ "head.blocks.0.channel_mlp.0.weight": "model-00003-of-00003.safetensors",
732
+ "head.blocks.0.channel_mlp.2.bias": "model-00003-of-00003.safetensors",
733
+ "head.blocks.0.channel_mlp.2.weight": "model-00003-of-00003.safetensors",
734
+ "head.blocks.0.channel_norm.bias": "model-00003-of-00003.safetensors",
735
+ "head.blocks.0.channel_norm.weight": "model-00003-of-00003.safetensors",
736
+ "head.blocks.0.token_mlp.0.bias": "model-00003-of-00003.safetensors",
737
+ "head.blocks.0.token_mlp.0.weight": "model-00003-of-00003.safetensors",
738
+ "head.blocks.0.token_mlp.2.bias": "model-00003-of-00003.safetensors",
739
+ "head.blocks.0.token_mlp.2.weight": "model-00003-of-00003.safetensors",
740
+ "head.blocks.0.token_norm.bias": "model-00003-of-00003.safetensors",
741
+ "head.blocks.0.token_norm.weight": "model-00003-of-00003.safetensors",
742
+ "head.blocks.1.channel_mlp.0.bias": "model-00003-of-00003.safetensors",
743
+ "head.blocks.1.channel_mlp.0.weight": "model-00003-of-00003.safetensors",
744
+ "head.blocks.1.channel_mlp.2.bias": "model-00003-of-00003.safetensors",
745
+ "head.blocks.1.channel_mlp.2.weight": "model-00003-of-00003.safetensors",
746
+ "head.blocks.1.channel_norm.bias": "model-00003-of-00003.safetensors",
747
+ "head.blocks.1.channel_norm.weight": "model-00003-of-00003.safetensors",
748
+ "head.blocks.1.token_mlp.0.bias": "model-00003-of-00003.safetensors",
749
+ "head.blocks.1.token_mlp.0.weight": "model-00003-of-00003.safetensors",
750
+ "head.blocks.1.token_mlp.2.bias": "model-00003-of-00003.safetensors",
751
+ "head.blocks.1.token_mlp.2.weight": "model-00003-of-00003.safetensors",
752
+ "head.blocks.1.token_norm.bias": "model-00003-of-00003.safetensors",
753
+ "head.blocks.1.token_norm.weight": "model-00003-of-00003.safetensors",
754
+ "head.input_norm.bias": "model-00003-of-00003.safetensors",
755
+ "head.input_norm.weight": "model-00003-of-00003.safetensors",
756
+ "head.output.0.bias": "model-00003-of-00003.safetensors",
757
+ "head.output.0.weight": "model-00003-of-00003.safetensors",
758
+ "head.output.1.bias": "model-00003-of-00003.safetensors",
759
+ "head.output.1.weight": "model-00003-of-00003.safetensors",
760
+ "head.projection.bias": "model-00003-of-00003.safetensors",
761
+ "head.projection.weight": "model-00003-of-00003.safetensors",
762
+ "head.roles": "model-00003-of-00003.safetensors"
763
+ }
764
+ }
modeling_valen.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Complete merged Qwen + decision head. / 已合并的完整 Qwen 和决策头。"""
2
+ import torch
3
+ from transformers import AutoProcessor
4
+ from transformers.models.qwen3_5.modeling_qwen3_5 import Qwen3_5Model, Qwen3_5PreTrainedModel
5
+
6
+ from .configuration_valen import ValenQwenConfig
7
+ from .heads import build_head
8
+ from .runtime_model import ValenQwen
9
+ from .compiler import Compiler
10
+ from .responses import answer
11
+ # List transitive files explicitly for Transformers' local dynamic loader.
12
+ # 本地动态加载需要显式列出间接依赖,否则搬移后可能缺少这些模块。
13
+ from .batching import collate_branches
14
+ from .schema import candidates
15
+ from .data_types import QuestionSpec
16
+
17
+
18
+ class ValenQwenForDecisionMaking(Qwen3_5PreTrainedModel):
19
+ config_class = ValenQwenConfig
20
+ base_model_prefix = "backbone"
21
+ model_name = "Valen"
22
+ architecture = "qwen"
23
+ # The trained Mixer stays FP32 with a BF16 backbone. / BF16 基座、FP32 决策头。
24
+ _keep_in_fp32_modules_strict = ["head"]
25
+
26
+ def __init__(self, config, backbone=None, head=None):
27
+ super().__init__(config)
28
+ if (backbone is None) != (head is None):
29
+ raise ValueError("Supply both a merged backbone and a trained head")
30
+ self.backbone = backbone if backbone is not None else Qwen3_5Model(config)
31
+ self.head = head if head is not None else build_head(config.text_config.hidden_size, config.valen_head)
32
+ self.head.float()
33
+ self._processor = None
34
+ # Supplied weights are already trained: do not reinitialize them.
35
+ # 传入的参数已训练完成,不能再次调用初始化覆盖它们。
36
+ if backbone is not None:
37
+ for module in self.modules():
38
+ module._is_hf_initialized = True
39
+ self.post_init()
40
+
41
+ def get_input_embeddings(self):
42
+ return self.backbone.get_input_embeddings()
43
+
44
+ def set_input_embeddings(self, value):
45
+ self.backbone.set_input_embeddings(value)
46
+
47
+ def forward(self, question=None, **inputs):
48
+ if question is None:
49
+ return self.backbone(**inputs)
50
+ if hasattr(question, "questions"):
51
+ return self.forward_state(question)
52
+ return ValenQwen.forward(self, question)
53
+
54
+ # Use the exact trained readouts and batching implementation.
55
+ # 保留训练时的特征读取和 batch 逻辑。
56
+ extract_features = ValenQwen.extract_features
57
+ extract_state_features = ValenQwen.extract_state_features
58
+ _state_features = ValenQwen._state_features
59
+ forward_state = ValenQwen.forward_state
60
+ forward_state_batch = ValenQwen.forward_state_batch
61
+ forward_batch = ValenQwen.forward_batch
62
+ score_features = ValenQwen.score_features
63
+
64
+ def make_compiler(self, media_root=".", execution=None, processor=None):
65
+ if processor is None:
66
+ if self._processor is None:
67
+ self._processor = AutoProcessor.from_pretrained(self.config._name_or_path, trust_remote_code=True)
68
+ processor = self._processor
69
+ return Compiler(processor, media_root, self.config.valen_max_length, self.config.valen_media_kwargs,
70
+ execution=execution or self.config.qwen_execution)
71
+
72
+ @torch.inference_mode()
73
+ def predict(self, request, *, media_root=".", execution=None, temperature=1.0, processor=None):
74
+ self.eval()
75
+ # Only request content reaches the compiler. / 只编译输入,不读取标签。
76
+ request = request["request"] if "request" in request else request
77
+ compiler = self.make_compiler(media_root, execution, processor)
78
+ state = compiler.compile({"request": request})
79
+ logits = self.forward_state(state) if state.inputs is not None else [self(q) for q in state.questions]
80
+ answers = {q.qid: answer(q, z, temperature[q.kind] if isinstance(temperature, dict) else temperature)
81
+ for q, z in zip(state.questions, logits)}
82
+ return {"model": self.model_name, "answers": answers,
83
+ "usage": {"input_tokens": state.logical_tokens, "output_tokens": 0},
84
+ "internal_usage": {"compute_tokens": state.compute_tokens}}
processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }
responses.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+ import torch
3
+
4
+ def answer(question, logits, temperature=1.0):
5
+ if not math.isfinite(temperature) or temperature <= 0:
6
+ raise ValueError("Calibration temperature must be finite and positive")
7
+ if logits.ndim != 1 or len(logits) != len(question.keys) or not torch.isfinite(logits).all():
8
+ raise ValueError("Expected one finite logit per candidate")
9
+ probs = (logits.float() / temperature).softmax(-1).detach().cpu().tolist()
10
+ total = sum(probs)
11
+ probs = [p / total for p in probs]
12
+ result = {"type": question.kind}
13
+ if question.kind == "noul":
14
+ result["noul"] = probs[question.keys.index("true")]
15
+ return result
16
+ result["probabilities"] = dict(zip(question.keys, probs))
17
+ mode = max(range(len(probs)), key=probs.__getitem__)
18
+ if question.kind == "choice":
19
+ result["choice"] = question.keys[mode]
20
+ result["confidence"] = 1.0 if len(probs) == 1 else max(0.0, (max(probs) - 1/len(probs)) / (1 - 1/len(probs)))
21
+ else:
22
+ result["score"] = sum(i * p for i, p in enumerate(probs))
23
+ result["legend"] = dict(zip(question.keys, question.descriptions))
24
+ # Independently implemented formula from pinned system-one adapter:
25
+ # fb52b1030b7fc1f4f1cf39910afa5da54f9835e3, confidence_metrics.py.
26
+ distance = sum(p * abs(i - mode) for i, p in enumerate(probs))
27
+ uniform_mad = sum(abs(i - (len(probs)-1)/2) for i in range(len(probs))) / len(probs)
28
+ result["confidence"] = max(0.0, 1.0 - distance / uniform_mad)
29
+ return result
runtime_model.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+ MODEL_NAME = "Valen"
4
+ from .heads import DecisionHead, build_head
5
+ from .batching import branch_batches, collate_branches
6
+
7
+
8
+ class ValenQwen(nn.Module):
9
+ """Qwen3.5 backbone with a shared candidate decision head."""
10
+
11
+ model_name = MODEL_NAME
12
+ architecture = "qwen"
13
+
14
+ def __init__(self, backbone, projection_dim=256, head_config=None):
15
+ super().__init__()
16
+ self.backbone = backbone
17
+ self.head = build_head(backbone.config.text_config.hidden_size,
18
+ dict({"projection_dim": projection_dim}, **(head_config or {})))
19
+
20
+ def forward(self, question):
21
+ device = next(self.backbone.parameters()).device
22
+ outputs = []
23
+ for branch in question.branches:
24
+ inputs = {k: v.to(device) if isinstance(v, torch.Tensor) else v for k, v in branch.inputs.items()}
25
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
26
+ outputs.append(self.head.score_features(self.head.extract_features(hidden, branch)))
27
+ return torch.cat(outputs)
28
+
29
+ def extract_features(self, question):
30
+ """缓存投影前的特征。 / Cache raw readouts before trainable head layers."""
31
+ device = next(self.backbone.parameters()).device
32
+ features = []
33
+ for branch in question.branches:
34
+ inputs = {k: v.to(device) if isinstance(v, torch.Tensor) else v for k, v in branch.inputs.items()}
35
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
36
+ features.append(self.head.extract_features(hidden, branch))
37
+ return features
38
+
39
+ def extract_state_features(self, state):
40
+ """一次编码 state,读取各题特征。 / One backbone graph for every question."""
41
+ if not state.questions:
42
+ return []
43
+ if state.inputs is None:
44
+ raise ValueError("Shared-state features require compiled shared inputs")
45
+ device = next(self.backbone.parameters()).device
46
+ inputs = {k: v.to(device) if isinstance(v, torch.Tensor) else v for k, v in state.inputs.items()}
47
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
48
+ return self._state_features(hidden, state)
49
+
50
+ def _state_features(self, hidden, state):
51
+ return [[self.head.extract_features(hidden, branch) for branch in q.branches]
52
+ for q in state.questions]
53
+
54
+ def forward_state(self, state):
55
+ return [self.score_features(features) for features in self.extract_state_features(state)]
56
+
57
+ def forward_state_batch(self, states, max_tokens=32768):
58
+ """不同 state 组成 batch,同一 state 的题目共用一行。 / One row per shared state."""
59
+ device = next(self.backbone.parameters()).device
60
+ pad_token_id = getattr(self.backbone.config.text_config, "pad_token_id", None) or 0
61
+ outputs = [[] for _ in states]
62
+ representatives = []
63
+ indices = []
64
+ for index, state in enumerate(states):
65
+ if not state.questions:
66
+ continue
67
+ if state.inputs is None or any(branch.inputs is not state.inputs
68
+ for q in state.questions for branch in q.branches):
69
+ raise ValueError("Shared-state batch requires one shared input per state")
70
+ representatives.append(state.questions[0])
71
+ indices.append(index)
72
+ for batch in branch_batches(representatives, max_tokens):
73
+ inputs = collate_branches([branch for _, branch in batch], pad_token_id)
74
+ inputs = {key: value.to(device) for key, value in inputs.items()}
75
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
76
+ for row, (index, _) in enumerate(batch):
77
+ original = indices[index]
78
+ features = self._state_features(hidden[row:row + 1], states[original])
79
+ outputs[original] = [self.score_features(f) for f in features]
80
+ return outputs
81
+
82
+ def forward_batch(self, questions, max_tokens=32768):
83
+ """Forward several QAs together; each keeps its own decision head inputs.
84
+
85
+ 多条 QA 并行;每条保留独立的候选、角色区间和 Score 分支。
86
+ """
87
+ device = next(self.backbone.parameters()).device
88
+ pad_token_id = getattr(self.backbone.config.text_config, "pad_token_id", None) or 0
89
+ outputs = [[] for _ in questions]
90
+ for batch in branch_batches(questions, max_tokens):
91
+ inputs = collate_branches([branch for _, branch in batch], pad_token_id)
92
+ inputs = {key: value.to(device) for key, value in inputs.items()}
93
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
94
+ for row, (question_index, branch) in enumerate(batch):
95
+ features = self.head.extract_features(hidden[row:row + 1], branch)
96
+ outputs[question_index].append(self.head.score_features(features))
97
+ return [torch.cat(branches) for branches in outputs]
98
+
99
+ def score_features(self, features, head=None):
100
+ head = self.head if head is None else head
101
+ return torch.cat([head.score_features(hidden) for hidden in features])
schema.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Strict JSONL contract. IDs and labels never enter the model prompt."""
2
+ import json
3
+ import math
4
+ from pathlib import Path
5
+
6
+
7
+ def candidates(question):
8
+ kind = question.get("type")
9
+ if not isinstance(question.get("instructions"), str) or not question["instructions"].strip():
10
+ raise ValueError("instructions must be nonempty text")
11
+ criteria = question.get("criteria")
12
+ if kind == "noul":
13
+ return [("true", "True / 是:满足问题中的条件。"), ("false", "False / 否:不满足问题中的条件。")]
14
+ if kind == "choice":
15
+ if not isinstance(criteria, dict) or not 1 <= len(criteria) <= 255:
16
+ raise ValueError("Choice needs 1–255 named criteria")
17
+ result = list(criteria.items())
18
+ elif kind == "score":
19
+ if not isinstance(criteria, list) or not 2 <= len(criteria) <= 255:
20
+ raise ValueError("Score criteria must be an ordered list of 2–255 descriptions")
21
+ result = [(str(i), text) for i, text in enumerate(criteria)]
22
+ else:
23
+ raise ValueError(f"Unsupported question type: {kind}")
24
+ if any(not isinstance(k, str) or not k or not isinstance(v, str) or not v.strip() for k, v in result):
25
+ raise ValueError("Candidate names and descriptions must be nonempty strings")
26
+ return result
27
+
28
+
29
+ def target_distribution(target, keys):
30
+ if target is None or target.get("probabilities") is None:
31
+ return None
32
+ probs = target["probabilities"]
33
+ if not isinstance(probs, dict) or set(probs) != set(keys):
34
+ raise ValueError(f"Probability keys must exactly match {keys}")
35
+ values = [probs[k] for k in keys]
36
+ if any(isinstance(v, bool) or not isinstance(v, (int, float)) or not math.isfinite(v) or v < 0 for v in values):
37
+ raise ValueError("Probabilities must be finite nonnegative numbers")
38
+ if not math.isclose(sum(values), 1.0, abs_tol=1e-6):
39
+ raise ValueError("Target probabilities must sum to 1")
40
+ return values
41
+
42
+
43
+ def validate_record(record, candidate_fn=candidates):
44
+ request = record["request"]
45
+ state = request["state"]
46
+ if not isinstance(state, (str, dict)):
47
+ raise ValueError("state must be text or a messages object")
48
+ if not isinstance(request["questions"], dict) or not request["questions"]:
49
+ raise ValueError("questions must be a nonempty mapping")
50
+ targets = record.get("targets", {})
51
+ if set(targets) - set(request["questions"]):
52
+ raise ValueError("Unknown target question IDs")
53
+ for qid, question in request["questions"].items():
54
+ target_distribution(targets.get(qid), [k for k, _ in candidate_fn(question)])
55
+ if not record.get("group_id"):
56
+ raise ValueError("group_id is required for leakage-free splits")
57
+ return record
58
+
59
+
60
+ def read_jsonl(path, candidate_fn=candidates):
61
+ records = []
62
+ with Path(path).open(encoding="utf-8") as stream:
63
+ for line_number, line in enumerate(stream, 1):
64
+ if line.strip():
65
+ try:
66
+ records.append(validate_record(json.loads(line), candidate_fn))
67
+ except (ValueError, KeyError, TypeError, AttributeError) as exc:
68
+ raise ValueError(f"{path}:{line_number}: {exc}") from exc
69
+ if not records:
70
+ raise ValueError("Empty dataset")
71
+ return records
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4
3
+ size 19989343
tokenizer_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": true,
13
+ "model_max_length": 262144,
14
+ "model_specific_special_tokens": {
15
+ "audio_bos_token": "<|audio_start|>",
16
+ "audio_eos_token": "<|audio_end|>",
17
+ "audio_token": "<|audio_pad|>",
18
+ "image_token": "<|image_pad|>",
19
+ "video_token": "<|video_pad|>",
20
+ "vision_bos_token": "<|vision_start|>",
21
+ "vision_eos_token": "<|vision_end|>"
22
+ },
23
+ "pad_token": "<|endoftext|>",
24
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
25
+ "processor_class": "Qwen3VLProcessor",
26
+ "split_special_tokens": false,
27
+ "tokenizer_class": "TokenizersBackend",
28
+ "unk_token": null,
29
+ "video_token": "<|video_pad|>",
30
+ "vision_bos_token": "<|vision_start|>",
31
+ "vision_eos_token": "<|vision_end|>"
32
+ }
unmerged/COMPLETE.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "validated": true,
3
+ "source_checkpoint_sha256": "b4193b4e907f44b913fd54a8d6b998e7050a1528306269a000f1e5e8bd8dffc7"
4
+ }
unmerged/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Alibaba Cloud
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
unmerged/README.md ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Valen-4B — unmerged LoRA
2
+
3
+ 原始 Qwen3.5 基座 + 未合并的 LoRA + FP32 Mixer + 训练后的视觉 merger。
4
+ Original base with separate LoRA, Mixer, and trained visual merger weights.
5
+ 来源:1195k + JevBench 30k,两阶段 SFT,最终 step 325。
6
+
7
+ ## 文件 / Files
8
+
9
+ - `lora/adapter_model.safetensors`、`lora/adapter_config.json`:标准 PEFT LoRA。
10
+ - `mixer.safetensors`:完整 FP32 Mixer 决策头。
11
+ - `visual_merger.safetensors`:联合微调时训练的视觉 merger,加载时一并恢复。
12
+ - `config.json`、processor、tokenizer 和 Python 文件:模型配置及独立加载代码。
13
+
14
+ ## 完整模型加载 / Load the complete decision model
15
+
16
+ 环境沿用父目录:PyTorch 2.6.0、Transformers 5.4.0,另需 PEFT 0.18.1 和 safetensors。
17
+ Flash Attention 2 可通过 `attn_implementation="flash_attention_2"` 启用。
18
+
19
+ ```python
20
+ import torch
21
+ from transformers import AutoModel
22
+
23
+ model = AutoModel.from_pretrained(
24
+ "./Valen-4B/unmerged",
25
+ base_model_path="./Qwen3.5-4B", # 原始官方基座 / original published base
26
+ trust_remote_code=True,
27
+ dtype=torch.bfloat16,
28
+ attn_implementation="sdpa",
29
+ ).to("cuda").eval()
30
+ torch.set_float32_matmul_precision("highest")
31
+ torch.backends.cudnn.allow_tf32 = False
32
+
33
+ result = model.predict({
34
+ "state": "There is one cat in the room.",
35
+ "questions": {
36
+ "animal": {"type": "choice", "instructions": "Which animal is present?",
37
+ "criteria": {"cat": "A cat", "dog": "A dog"}},
38
+ "is_cat": {"type": "noul", "instructions": "There is a cat in the room."},
39
+ },
40
+ })
41
+ print(result["answers"])
42
+ ```
43
+
44
+ `base_model_path` 指向原始官方 `Qwen/Qwen3.5-4B` 权重,本目录中的加载器会核对基座 SHA-256。
45
+ 省略该参数时使用配置记录的仓库及固定 revision;离线环境需提前缓存该版本。
46
+ 默认 share_state,也支持 `model.predict(..., execution="question")`;视频采样 16 帧。
47
+ 内部使用 `PeftModel.from_pretrained(backbone.language_model, .../lora)` 加载语言 LoRA,随后恢复 Mixer 和视觉 merger。
48
+ 适配器不会被融合。`is_trainable=True` 可启用 LoRA、Mixer 和视觉 merger 的梯度。
49
+
50
+ `validation.json` 记录恢复后与原 checkpoint 的一致性;文件来源和校验和见 `export_manifest.json`。
unmerged/batching.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Pad language rows and concatenate visual patches. / 文本补齐,视觉 patch 拼接。"""
2
+ import torch
3
+ from torch.nn.utils.rnn import pad_sequence
4
+
5
+
6
+ SEQUENCE_KEYS = {"input_ids", "attention_mask", "mm_token_type_ids"}
7
+ VISUAL_KEYS = {"pixel_values", "pixel_values_videos", "image_grid_thw", "video_grid_thw"}
8
+
9
+
10
+ def collate_branches(branches, pad_token_id=0):
11
+ if not branches:
12
+ raise ValueError("Cannot collate an empty branch batch")
13
+ inputs = [branch.inputs for branch in branches]
14
+ unknown = set().union(*(row.keys() for row in inputs)) - SEQUENCE_KEYS - VISUAL_KEYS
15
+ if unknown:
16
+ raise ValueError(f"Unsupported batched Qwen inputs: {sorted(unknown)}")
17
+ if any(row["input_ids"].ndim != 2 or row["input_ids"].shape[0] != 1 for row in inputs):
18
+ raise ValueError("Each compiled branch must contain one language row")
19
+ result = {}
20
+ for key in SEQUENCE_KEYS:
21
+ if key != "input_ids" and not any(key in row for row in inputs):
22
+ continue
23
+ rows = []
24
+ for row in inputs:
25
+ value = row.get(key)
26
+ if value is None:
27
+ value = (torch.ones_like(row["input_ids"]) if key == "attention_mask"
28
+ else torch.zeros_like(row["input_ids"]))
29
+ if value.shape != row["input_ids"].shape:
30
+ raise ValueError(f"{key} must match the branch input_ids shape")
31
+ rows.append(value[0])
32
+ # Right padding keeps all compiler readout positions and spans unchanged.
33
+ # 右侧补齐,候选位置和角色区间无需偏移。
34
+ result[key] = pad_sequence(rows, batch_first=True,
35
+ padding_value=pad_token_id if key == "input_ids" else 0)
36
+ if "attention_mask" not in result:
37
+ result["attention_mask"] = pad_sequence([torch.ones_like(r["input_ids"][0]) for r in inputs],
38
+ batch_first=True, padding_value=0)
39
+ for key in VISUAL_KEYS:
40
+ values = [row[key] for row in inputs if key in row]
41
+ if values:
42
+ result[key] = torch.cat(values, dim=0)
43
+ return result
44
+
45
+
46
+ def branch_batches(questions, max_tokens):
47
+ """Limit padded tokens per backbone forward, keeping Score branch order."""
48
+ if type(max_tokens) is not int or max_tokens <= 0:
49
+ raise ValueError("microbatch_max_tokens must be a positive integer")
50
+ batch, longest = [], 0
51
+ for question_index, question in enumerate(questions):
52
+ if not question.branches:
53
+ raise ValueError("A Qwen question requires at least one branch")
54
+ for branch in question.branches:
55
+ length = branch.inputs["input_ids"].shape[1]
56
+ if batch and max(longest, length) * (len(batch) + 1) > max_tokens:
57
+ yield batch
58
+ batch, longest = [], 0
59
+ batch.append((question_index, branch))
60
+ longest = max(longest, length)
61
+ if batch:
62
+ yield batch
unmerged/chat_template.jinja ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set image_count = namespace(value=0) %}
2
+ {%- set video_count = namespace(value=0) %}
3
+ {%- macro render_content(content, do_vision_count, is_system_content=false) %}
4
+ {%- if content is string %}
5
+ {{- content }}
6
+ {%- elif content is iterable and content is not mapping %}
7
+ {%- for item in content %}
8
+ {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}
9
+ {%- if is_system_content %}
10
+ {{- raise_exception('System message cannot contain images.') }}
11
+ {%- endif %}
12
+ {%- if do_vision_count %}
13
+ {%- set image_count.value = image_count.value + 1 %}
14
+ {%- endif %}
15
+ {%- if add_vision_id %}
16
+ {{- 'Picture ' ~ image_count.value ~ ': ' }}
17
+ {%- endif %}
18
+ {{- '<|vision_start|><|image_pad|><|vision_end|>' }}
19
+ {%- elif 'video' in item or item.type == 'video' %}
20
+ {%- if is_system_content %}
21
+ {{- raise_exception('System message cannot contain videos.') }}
22
+ {%- endif %}
23
+ {%- if do_vision_count %}
24
+ {%- set video_count.value = video_count.value + 1 %}
25
+ {%- endif %}
26
+ {%- if add_vision_id %}
27
+ {{- 'Video ' ~ video_count.value ~ ': ' }}
28
+ {%- endif %}
29
+ {{- '<|vision_start|><|video_pad|><|vision_end|>' }}
30
+ {%- elif 'text' in item %}
31
+ {{- item.text }}
32
+ {%- else %}
33
+ {{- raise_exception('Unexpected item type in content.') }}
34
+ {%- endif %}
35
+ {%- endfor %}
36
+ {%- elif content is none or content is undefined %}
37
+ {{- '' }}
38
+ {%- else %}
39
+ {{- raise_exception('Unexpected content type.') }}
40
+ {%- endif %}
41
+ {%- endmacro %}
42
+ {%- if not messages %}
43
+ {{- raise_exception('No messages provided.') }}
44
+ {%- endif %}
45
+ {%- if tools and tools is iterable and tools is not mapping %}
46
+ {{- '<|im_start|>system\n' }}
47
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
48
+ {%- for tool in tools %}
49
+ {{- "\n" }}
50
+ {{- tool | tojson }}
51
+ {%- endfor %}
52
+ {{- "\n</tools>" }}
53
+ {{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
54
+ {%- if messages[0].role == 'system' %}
55
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
56
+ {%- if content %}
57
+ {{- '\n\n' + content }}
58
+ {%- endif %}
59
+ {%- endif %}
60
+ {{- '<|im_end|>\n' }}
61
+ {%- else %}
62
+ {%- if messages[0].role == 'system' %}
63
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
64
+ {{- '<|im_start|>system\n' + content + '<|im_end|>\n' }}
65
+ {%- endif %}
66
+ {%- endif %}
67
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
68
+ {%- for message in messages[::-1] %}
69
+ {%- set index = (messages|length - 1) - loop.index0 %}
70
+ {%- if ns.multi_step_tool and message.role == "user" %}
71
+ {%- set content = render_content(message.content, false)|trim %}
72
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
73
+ {%- set ns.multi_step_tool = false %}
74
+ {%- set ns.last_query_index = index %}
75
+ {%- endif %}
76
+ {%- endif %}
77
+ {%- endfor %}
78
+ {%- if ns.multi_step_tool %}
79
+ {{- raise_exception('No user query found in messages.') }}
80
+ {%- endif %}
81
+ {%- for message in messages %}
82
+ {%- set content = render_content(message.content, true)|trim %}
83
+ {%- if message.role == "system" %}
84
+ {%- if not loop.first %}
85
+ {{- raise_exception('System message must be at the beginning.') }}
86
+ {%- endif %}
87
+ {%- elif message.role == "user" %}
88
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
89
+ {%- elif message.role == "assistant" %}
90
+ {%- set reasoning_content = '' %}
91
+ {%- if message.reasoning_content is string %}
92
+ {%- set reasoning_content = message.reasoning_content %}
93
+ {%- else %}
94
+ {%- if '</think>' in content %}
95
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
96
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
97
+ {%- endif %}
98
+ {%- endif %}
99
+ {%- set reasoning_content = reasoning_content|trim %}
100
+ {%- if loop.index0 > ns.last_query_index %}
101
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
102
+ {%- else %}
103
+ {{- '<|im_start|>' + message.role + '\n' + content }}
104
+ {%- endif %}
105
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
106
+ {%- for tool_call in message.tool_calls %}
107
+ {%- if tool_call.function is defined %}
108
+ {%- set tool_call = tool_call.function %}
109
+ {%- endif %}
110
+ {%- if loop.first %}
111
+ {%- if content|trim %}
112
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
113
+ {%- else %}
114
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
115
+ {%- endif %}
116
+ {%- else %}
117
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
118
+ {%- endif %}
119
+ {%- if tool_call.arguments is defined %}
120
+ {%- for args_name, args_value in tool_call.arguments|items %}
121
+ {{- '<parameter=' + args_name + '>\n' }}
122
+ {%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
123
+ {{- args_value }}
124
+ {{- '\n</parameter>\n' }}
125
+ {%- endfor %}
126
+ {%- endif %}
127
+ {{- '</function>\n</tool_call>' }}
128
+ {%- endfor %}
129
+ {%- endif %}
130
+ {{- '<|im_end|>\n' }}
131
+ {%- elif message.role == "tool" %}
132
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
133
+ {{- '<|im_start|>user' }}
134
+ {%- endif %}
135
+ {{- '\n<tool_response>\n' }}
136
+ {{- content }}
137
+ {{- '\n</tool_response>' }}
138
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
139
+ {{- '<|im_end|>\n' }}
140
+ {%- elif loop.last %}
141
+ {{- '<|im_end|>\n' }}
142
+ {%- endif %}
143
+ {%- else %}
144
+ {{- raise_exception('Unexpected message role.') }}
145
+ {%- endif %}
146
+ {%- endfor %}
147
+ {%- if add_generation_prompt %}
148
+ {{- '<|im_start|>assistant\n' }}
149
+ {%- if enable_thinking is defined and enable_thinking is false %}
150
+ {{- '<think>\n\n</think>\n\n' }}
151
+ {%- else %}
152
+ {{- '<think>\n' }}
153
+ {%- endif %}
154
+ {%- endif %}
unmerged/compiler.py ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Compile Qwen question branches or a shared sequence with per-question readouts."""
2
+ from copy import deepcopy
3
+ from dataclasses import dataclass
4
+ from pathlib import Path
5
+ import hashlib
6
+ import torch
7
+ from .schema import candidates, target_distribution
8
+ from .data_types import QuestionSpec
9
+
10
+
11
+ @dataclass
12
+ class Branch:
13
+ inputs: dict
14
+ candidate_positions: list
15
+ decision_position: int
16
+ context_span: tuple | None = None
17
+ instruction_span: tuple | None = None
18
+ candidate_spans: list | None = None
19
+
20
+
21
+ @dataclass(init=False)
22
+ class Question(QuestionSpec):
23
+ branches: list
24
+
25
+ def __init__(self, qid, kind, keys, descriptions, branches, target, is_text):
26
+ # Keep the positional constructor used by existing compiler clients.
27
+ super().__init__(qid, kind, keys, descriptions, target, is_text)
28
+ self.branches = branches
29
+
30
+
31
+ @dataclass
32
+ class CompiledState:
33
+ questions: list
34
+ logical_tokens: int
35
+ compute_tokens: int
36
+ media: list
37
+ inputs: dict | None = None
38
+
39
+
40
+ class Compiler:
41
+ def __init__(self, processor, media_root=".", max_length=8192, media_kwargs=None, verified_media_hashes=None,
42
+ execution="question"):
43
+ if execution not in {"question", "shared_state"}:
44
+ raise ValueError(f"Unknown qwen_execution: {execution}")
45
+ self.execution = execution
46
+ self.processor = processor
47
+ self.tokenizer = processor.tokenizer
48
+ self.media_root = Path(media_root)
49
+ self.max_length = max_length
50
+ self.media_kwargs = media_kwargs or {}
51
+ # Optional, pre-audited immutable assets for latency measurements.
52
+ # Normal training/inference continues to hash each input at use time.
53
+ self.verified_media_hashes = verified_media_hashes or {}
54
+
55
+ def _messages(self, state):
56
+ messages = [{"role": "user", "content": state}] if isinstance(state, str) else deepcopy(state["messages"])
57
+ media = []
58
+ for message in messages:
59
+ if message["role"] not in {"user", "assistant", "system"}:
60
+ raise ValueError("Unsupported state role")
61
+ if isinstance(message["content"], str):
62
+ message["content"] = [{"type": "text", "text": message["content"]}]
63
+ for item in message["content"]:
64
+ kind = item["type"]
65
+ if kind == "text":
66
+ # Prevent user text from injecting Qwen control tokens.
67
+ if any(t in item["text"] for t in self.tokenizer.all_special_tokens):
68
+ raise ValueError("Reserved tokenizer control token in state")
69
+ continue
70
+ if kind not in {"image_url", "video_url"}:
71
+ raise ValueError(f"Unsupported content type: {kind}")
72
+ url = item[kind]["url"]
73
+ if "://" in url:
74
+ raise ValueError("Materialize remote media locally with a hash before training")
75
+ path = Path(url)
76
+ path = path if path.is_absolute() else self.media_root / path
77
+ path = path.resolve(strict=True)
78
+ digest = self.verified_media_hashes.get(str(path))
79
+ if digest is None:
80
+ digest = hashlib.sha256(path.read_bytes()).hexdigest()
81
+ media.append({"path": str(path), "sha256": digest, "type": kind})
82
+ item.clear()
83
+ item.update(type=kind.removesuffix("_url"), path=str(path))
84
+ return messages, media
85
+
86
+ def compile(self, record, rng=None, labeled_only=False):
87
+ selected = []
88
+ for qid, question in record["request"]["questions"].items():
89
+ pairs = candidates(question)
90
+ target = record.get("targets", {}).get(qid)
91
+ if labeled_only and self.execution == "question" and target_distribution(target, [k for k, _ in pairs]) is None:
92
+ continue
93
+ if rng is not None and question["type"] == "choice":
94
+ rng.shuffle(pairs)
95
+ selected.append((qid, question, pairs, target))
96
+ # 标签只决定监督范围,共享序列仍保留所有题。 / Labels select losses, never prompt content.
97
+ if not selected or (labeled_only and not any(
98
+ target_distribution(target, [k for k, _ in pairs]) is not None
99
+ for _, _, pairs, target in selected)):
100
+ return CompiledState([], 0, 0, [])
101
+ messages, media = self._messages(record["request"]["state"])
102
+ expected_assets = {str((self.media_root / a["path"]).resolve()): a["sha256"] for a in record.get("assets", [])}
103
+ for entry in media:
104
+ if entry["path"] in expected_assets and expected_assets[entry["path"]] != entry["sha256"]:
105
+ raise ValueError(f"Media hash mismatch: {entry['path']}")
106
+ base = dict(self.processor.apply_chat_template(
107
+ messages, tokenize=True, add_generation_prompt=False, return_dict=True,
108
+ return_tensors="pt", processor_kwargs=dict(self.media_kwargs, return_metadata=True)))
109
+ # Metadata is audit information, never a backbone keyword argument.
110
+ metadata = base.pop("video_metadata", None)
111
+ if metadata is not None:
112
+ for entry, meta in zip([m for m in media if m["type"] == "video_url"], metadata):
113
+ entry["sampling"] = dict(meta) if isinstance(meta, dict) else vars(meta)
114
+ sampling = entry["sampling"]
115
+ indices = sampling.get("frames_indices")
116
+ if indices is not None and sampling.get("fps"):
117
+ sampling["frames_indices"] = [int(i) for i in indices]
118
+ sampling["timestamps_seconds"] = [int(i) / sampling["fps"] for i in indices]
119
+ sampling["visible_range_seconds"] = [min(sampling["timestamps_seconds"]), max(sampling["timestamps_seconds"])]
120
+ for name in ("image_grid_thw", "video_grid_thw"):
121
+ if name in base:
122
+ grid = base[name]
123
+ media.append({name: grid.tolist(), "visual_tokens": int(grid.prod(-1).sum()) // 4})
124
+ base_length = base["input_ids"].shape[1]
125
+ if self.execution == "shared_state":
126
+ return self._compile_shared(selected, base, media, labeled_only)
127
+ logical_tokens, compute_tokens = base_length, 0
128
+ compiled = []
129
+ for qid, question, pairs, target in selected:
130
+ keys = [k for k, _ in pairs]
131
+ branches = []
132
+ groups = [[pair] for pair in pairs] if question["type"] == "score" else [pairs]
133
+ for group in groups:
134
+ suffix = []
135
+ def append(text, char_span=None):
136
+ start = base_length + len(suffix)
137
+ if char_span is None:
138
+ suffix.extend(self.tokenizer.encode(text, add_special_tokens=False))
139
+ return None
140
+ # 保持原有分词,只额外记录区间。 / Preserve token IDs; record role spans.
141
+ encoded = self.tokenizer(text, add_special_tokens=False, return_offsets_mapping=True)
142
+ suffix.extend(encoded["input_ids"])
143
+ indices = [i for i, (a, b) in enumerate(encoded["offset_mapping"])
144
+ if a < char_span[1] and b > char_span[0]]
145
+ if not indices:
146
+ raise ValueError("Empty token span for decision role")
147
+ return (start + indices[0], start + indices[-1] + 1)
148
+ # Canonical segment tokenization makes endpoints exact; no string searching.
149
+ suffix.extend(self.tokenizer.encode("<|im_start|>user\n", add_special_tokens=False))
150
+ for value in [question["instructions"]] + [v for pair in group for v in pair]:
151
+ if any(t in value for t in self.tokenizer.all_special_tokens):
152
+ raise ValueError("Reserved tokenizer control token in question/criteria")
153
+ prefix = "Task: " + question["type"] + "\nQuestion: "
154
+ instruction_span = append(prefix + question["instructions"] + "\nCandidates:\n",
155
+ (len(prefix), len(prefix) + len(question["instructions"])))
156
+ positions, candidate_spans = [], []
157
+ for key, description in group:
158
+ # Score never sees its level ID, nor any other level description.
159
+ prefix = key + ": " if question["type"] != "score" else ""
160
+ candidate_spans.append(append(prefix + description, (len(prefix), len(prefix) + len(description))))
161
+ positions.append(base_length + len(suffix) - 1)
162
+ append("\n")
163
+ append("Decision:")
164
+ length = base_length + len(suffix)
165
+ if length > self.max_length:
166
+ raise ValueError(f"{qid}: {length} tokens exceed max_length={self.max_length}; no truncation")
167
+ inputs = dict(base)
168
+ inputs["input_ids"] = torch.cat([base["input_ids"], torch.tensor([suffix], dtype=torch.long)], dim=1)
169
+ inputs["attention_mask"] = torch.ones_like(inputs["input_ids"])
170
+ if "mm_token_type_ids" in base:
171
+ inputs["mm_token_type_ids"] = torch.cat([base["mm_token_type_ids"], torch.zeros((1, len(suffix)), dtype=torch.long)], dim=1)
172
+ branches.append(Branch(inputs, positions, length - 1, (0, base_length),
173
+ instruction_span, candidate_spans))
174
+ compute_tokens += length
175
+ logical_tokens += len(suffix)
176
+ compiled.append(Question(qid, question["type"], keys, [v for _, v in pairs], branches,
177
+ target_distribution(target, keys), not media))
178
+ return CompiledState(compiled, logical_tokens, compute_tokens, media)
179
+
180
+ def _compile_shared(self, selected, base, media, labeled_only=False):
181
+ """All schemas precede all readouts; labels and external IDs never enter inputs.
182
+
183
+ This is ordinary causal attention, not isolated question/Score branches.
184
+ No answer tokens or LM output layer are required by the decision heads.
185
+ """
186
+ base_length = base["input_ids"].shape[1]
187
+ suffix, compiled = [], []
188
+
189
+ def append(text, span=None):
190
+ start = base_length + len(suffix)
191
+ if span is None:
192
+ suffix.extend(self.tokenizer.encode(text, add_special_tokens=False))
193
+ return None
194
+ encoded = self.tokenizer(text, add_special_tokens=False, return_offsets_mapping=True)
195
+ suffix.extend(encoded["input_ids"])
196
+ indices = [i for i, (a, b) in enumerate(encoded["offset_mapping"]) if a < span[1] and b > span[0]]
197
+ if not indices:
198
+ raise ValueError("Empty token span for decision role")
199
+ return start + indices[0], start + indices[-1] + 1
200
+
201
+ append("<|im_start|>user\n")
202
+ for index, (qid, question, pairs, target) in enumerate(selected):
203
+ for value in [question["instructions"]] + [v for pair in pairs for v in pair]:
204
+ if any(t in value for t in self.tokenizer.all_special_tokens):
205
+ raise ValueError("Reserved tokenizer control token in question/criteria")
206
+ prefix = f"Question {index + 1}\nTask: {question['type']}\nQuestion: "
207
+ instruction = append(prefix + question["instructions"] + "\nCandidates:\n",
208
+ (len(prefix), len(prefix) + len(question["instructions"])))
209
+ positions, spans = [], []
210
+ for key, description in pairs:
211
+ prefix = key + ": " if question["type"] != "score" else ""
212
+ spans.append(append(prefix + description, (len(prefix), len(prefix) + len(description))))
213
+ positions.append(base_length + len(suffix) - 1)
214
+ append("\n")
215
+ # Inputs and the decision position are filled after all schemas are appended.
216
+ branch = Branch({}, positions, -1, (0, base_length), instruction, spans)
217
+ keys = [key for key, _ in pairs]
218
+ compiled.append(Question(qid, question["type"], keys, [v for _, v in pairs], [branch],
219
+ target_distribution(target, keys), not media))
220
+ append("<|im_end|>\n<|im_start|>assistant\n")
221
+ for index, question in enumerate(compiled):
222
+ append(f"Question {index + 1} Decision:")
223
+ question.branches[0].decision_position = base_length + len(suffix) - 1
224
+ append("\n")
225
+ length = base_length + len(suffix)
226
+ if length > self.max_length:
227
+ raise ValueError(f"Shared state: {length} tokens exceed max_length={self.max_length}; no truncation")
228
+ inputs = dict(base)
229
+ inputs["input_ids"] = torch.cat([base["input_ids"], base["input_ids"].new_tensor([suffix])], dim=1)
230
+ inputs["attention_mask"] = torch.cat([base["attention_mask"],
231
+ base["attention_mask"].new_ones((1, len(suffix)))], dim=1)
232
+ if "mm_token_type_ids" in base:
233
+ inputs["mm_token_type_ids"] = torch.cat([base["mm_token_type_ids"],
234
+ base["mm_token_type_ids"].new_zeros((1, len(suffix)))], dim=1)
235
+ for question in compiled:
236
+ question.branches[0].inputs = inputs
237
+ if labeled_only:
238
+ compiled = [question for question in compiled if question.target is not None]
239
+ return CompiledState(compiled, length, length, media, inputs)
unmerged/config.json ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "ValenQwenWithLoRA"
4
+ ],
5
+ "auto_map": {
6
+ "AutoConfig": "configuration_valen.ValenQwenConfig",
7
+ "AutoModel": "modeling_valen_lora.ValenQwenWithLoRA"
8
+ },
9
+ "dtype": "bfloat16",
10
+ "image_token_id": 248056,
11
+ "model_type": "valen_qwen",
12
+ "qwen_execution": "shared_state",
13
+ "text_config": {
14
+ "attention_bias": false,
15
+ "attention_dropout": 0.0,
16
+ "attn_output_gate": true,
17
+ "bos_token_id": null,
18
+ "dtype": "bfloat16",
19
+ "eos_token_id": 248044,
20
+ "full_attention_interval": 4,
21
+ "head_dim": 256,
22
+ "hidden_act": "silu",
23
+ "hidden_size": 2560,
24
+ "initializer_range": 0.02,
25
+ "intermediate_size": 9216,
26
+ "layer_types": [
27
+ "linear_attention",
28
+ "linear_attention",
29
+ "linear_attention",
30
+ "full_attention",
31
+ "linear_attention",
32
+ "linear_attention",
33
+ "linear_attention",
34
+ "full_attention",
35
+ "linear_attention",
36
+ "linear_attention",
37
+ "linear_attention",
38
+ "full_attention",
39
+ "linear_attention",
40
+ "linear_attention",
41
+ "linear_attention",
42
+ "full_attention",
43
+ "linear_attention",
44
+ "linear_attention",
45
+ "linear_attention",
46
+ "full_attention",
47
+ "linear_attention",
48
+ "linear_attention",
49
+ "linear_attention",
50
+ "full_attention",
51
+ "linear_attention",
52
+ "linear_attention",
53
+ "linear_attention",
54
+ "full_attention",
55
+ "linear_attention",
56
+ "linear_attention",
57
+ "linear_attention",
58
+ "full_attention"
59
+ ],
60
+ "linear_conv_kernel_dim": 4,
61
+ "linear_key_head_dim": 128,
62
+ "linear_num_key_heads": 16,
63
+ "linear_num_value_heads": 32,
64
+ "linear_value_head_dim": 128,
65
+ "mamba_ssm_dtype": "float32",
66
+ "max_position_embeddings": 262144,
67
+ "mlp_only_layers": [],
68
+ "model_type": "qwen3_5_text",
69
+ "mtp_num_hidden_layers": 1,
70
+ "mtp_use_dedicated_embeddings": false,
71
+ "num_attention_heads": 16,
72
+ "num_hidden_layers": 32,
73
+ "num_key_value_heads": 4,
74
+ "pad_token_id": null,
75
+ "partial_rotary_factor": 0.25,
76
+ "rms_norm_eps": 1e-06,
77
+ "rope_parameters": {
78
+ "mrope_interleaved": true,
79
+ "mrope_section": [
80
+ 11,
81
+ 11,
82
+ 10
83
+ ],
84
+ "partial_rotary_factor": 0.25,
85
+ "rope_theta": 10000000,
86
+ "rope_type": "default"
87
+ },
88
+ "tie_word_embeddings": true,
89
+ "use_cache": true,
90
+ "vocab_size": 248320
91
+ },
92
+ "tie_word_embeddings": true,
93
+ "transformers_version": "5.4.0",
94
+ "valen_head": {
95
+ "head_channel_hidden_dim": 1024,
96
+ "head_layers": 2,
97
+ "head_token_hidden_dim": 16,
98
+ "head_type": "mixer",
99
+ "head_width": 256
100
+ },
101
+ "valen_max_length": 32768,
102
+ "valen_media_kwargs": {
103
+ "images_kwargs": {
104
+ "size": {
105
+ "longest_edge": 262144,
106
+ "shortest_edge": 65536
107
+ }
108
+ },
109
+ "videos_kwargs": {
110
+ "fps": null,
111
+ "num_frames": 16,
112
+ "size": {
113
+ "longest_edge": 2097152,
114
+ "shortest_edge": 131072
115
+ }
116
+ }
117
+ },
118
+ "video_token_id": 248057,
119
+ "vision_config": {
120
+ "deepstack_visual_indexes": [],
121
+ "depth": 24,
122
+ "dtype": "bfloat16",
123
+ "hidden_act": "gelu_pytorch_tanh",
124
+ "hidden_size": 1024,
125
+ "in_channels": 3,
126
+ "initializer_range": 0.02,
127
+ "intermediate_size": 4096,
128
+ "model_type": "qwen3_5",
129
+ "num_heads": 16,
130
+ "num_position_embeddings": 2304,
131
+ "out_hidden_size": 2560,
132
+ "patch_size": 16,
133
+ "spatial_merge_size": 2,
134
+ "temporal_patch_size": 2
135
+ },
136
+ "vision_end_token_id": 248054,
137
+ "vision_start_token_id": 248053,
138
+ "valen_base": {
139
+ "repo": "Qwen/Qwen3.5-4B",
140
+ "revision": "851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a",
141
+ "weight_sha256": {
142
+ "model.safetensors-00001-of-00002.safetensors": "26a93f066e1916adb13453dae5a0c707c0fbc71299ed98779571a907b8e74c61",
143
+ "model.safetensors-00002-of-00002.safetensors": "cb544bd9bfae93dc59b0f22b292f5933573854a7f9b97835c67060d7d910e188"
144
+ },
145
+ "files_sha256": {
146
+ ".gitattributes": "34448b82c17d60fec9b65b1f093c115ddbaadc04beb1b0140b6bfed2e012a930",
147
+ "LICENSE": "bbedc3fda3305820b977265f01b8619d87570a6739de3a5582c3464840f1e57a",
148
+ "README.md": "1406be1b6b8fd8a6545870da516912804756593628a1d0fb0a7965211e82a7bb",
149
+ "chat_template.jinja": "a4aee8afcf2e0711942cf848899be66016f8d14a889ff9ede07bca099c28f715",
150
+ "config.json": "ddc63e1c717afa86c865bb5e01313d89d72bb53b97ad4a8a03ba8510c0621670",
151
+ "merges.txt": "a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d",
152
+ "model.safetensors-00001-of-00002.safetensors": "26a93f066e1916adb13453dae5a0c707c0fbc71299ed98779571a907b8e74c61",
153
+ "model.safetensors-00002-of-00002.safetensors": "cb544bd9bfae93dc59b0f22b292f5933573854a7f9b97835c67060d7d910e188",
154
+ "model.safetensors.index.json": "cf3f798ee02ba45f9622aa8892a47369ab667d0afbf154ee7c2212de42e6302d",
155
+ "preprocessor_config.json": "27225450ac9c6529872ee1924fcb0962ff5634834f817040f444118116f4e516",
156
+ "tokenizer.json": "5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42",
157
+ "tokenizer_config.json": "316230d6a809701f4db5ea8f8fc862bc3a6f3229c937c174e674ff3ca0a64ac8",
158
+ "video_preprocessor_config.json": "7768af27c1fafa9cc9011c1dc20067e03f8915e03b63504550e11d5066986d13",
159
+ "vocab.json": "ce99b4cb2983d118806ce0a8b777a35b093e2000a503ebde25853284c9dfa003"
160
+ },
161
+ "verified_from": "download_manifest.json; every LFS SHA256 matched"
162
+ }
163
+ }
unmerged/configuration_valen.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Standalone Qwen decision configuration. / 独立的 Qwen 决策模型配置。"""
2
+ from transformers import Qwen3_5Config
3
+
4
+
5
+ class ValenQwenConfig(Qwen3_5Config):
6
+ model_type = "valen_qwen"
7
+
8
+ def __init__(self, valen_head=None, qwen_execution="shared_state", valen_max_length=32768,
9
+ valen_media_kwargs=None, **kwargs):
10
+ if qwen_execution not in {"question", "shared_state"}:
11
+ raise ValueError("qwen_execution must be question or shared_state")
12
+ self.valen_head = valen_head or {"head_type": "mixer"}
13
+ self.qwen_execution = qwen_execution
14
+ self.valen_max_length = valen_max_length
15
+ self.valen_media_kwargs = valen_media_kwargs or {}
16
+ super().__init__(**kwargs)
unmerged/data_types.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Model-independent decision metadata; encoded tensors stay with each compiler."""
2
+ from dataclasses import dataclass
3
+
4
+
5
+ @dataclass
6
+ class QuestionSpec:
7
+ qid: str
8
+ kind: str
9
+ keys: list
10
+ descriptions: list
11
+ target: list | None
12
+ is_text: bool
unmerged/export_manifest.json ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "format": "valen_qwen_unmerged_v1",
3
+ "created_utc": "2026-10-06T06:53:45.813755+00:00",
4
+ "model": "Valen-4B",
5
+ "source_checkpoint_sha256": "b4193b4e907f44b913fd54a8d6b998e7050a1528306269a000f1e5e8bd8dffc7",
6
+ "training_step": 325,
7
+ "training_records": 1225000,
8
+ "training_data_sha256": "648cb127fe4830f9faaa6d4595445cc2573ef0c152f8f74c9c776dc8a9223d7f",
9
+ "base": {
10
+ "repo": "Qwen/Qwen3.5-4B",
11
+ "revision": "851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a",
12
+ "weight_sha256": {
13
+ "model.safetensors-00001-of-00002.safetensors": "26a93f066e1916adb13453dae5a0c707c0fbc71299ed98779571a907b8e74c61",
14
+ "model.safetensors-00002-of-00002.safetensors": "cb544bd9bfae93dc59b0f22b292f5933573854a7f9b97835c67060d7d910e188"
15
+ },
16
+ "files_sha256": {
17
+ ".gitattributes": "34448b82c17d60fec9b65b1f093c115ddbaadc04beb1b0140b6bfed2e012a930",
18
+ "LICENSE": "bbedc3fda3305820b977265f01b8619d87570a6739de3a5582c3464840f1e57a",
19
+ "README.md": "1406be1b6b8fd8a6545870da516912804756593628a1d0fb0a7965211e82a7bb",
20
+ "chat_template.jinja": "a4aee8afcf2e0711942cf848899be66016f8d14a889ff9ede07bca099c28f715",
21
+ "config.json": "ddc63e1c717afa86c865bb5e01313d89d72bb53b97ad4a8a03ba8510c0621670",
22
+ "merges.txt": "a9d356d7bdf1ef4949e3e748e95b8e10ad9d4e2e838eddc38a0a7b6b94d1db8d",
23
+ "model.safetensors-00001-of-00002.safetensors": "26a93f066e1916adb13453dae5a0c707c0fbc71299ed98779571a907b8e74c61",
24
+ "model.safetensors-00002-of-00002.safetensors": "cb544bd9bfae93dc59b0f22b292f5933573854a7f9b97835c67060d7d910e188",
25
+ "model.safetensors.index.json": "cf3f798ee02ba45f9622aa8892a47369ab667d0afbf154ee7c2212de42e6302d",
26
+ "preprocessor_config.json": "27225450ac9c6529872ee1924fcb0962ff5634834f817040f444118116f4e516",
27
+ "tokenizer.json": "5f9e4d4901a92b997e463c1f46055088b6cca5ca61a6522d1b9f64c4bb81cb42",
28
+ "tokenizer_config.json": "316230d6a809701f4db5ea8f8fc862bc3a6f3229c937c174e674ff3ca0a64ac8",
29
+ "video_preprocessor_config.json": "7768af27c1fafa9cc9011c1dc20067e03f8915e03b63504550e11d5066986d13",
30
+ "vocab.json": "ce99b4cb2983d118806ce0a8b777a35b093e2000a503ebde25853284c9dfa003"
31
+ },
32
+ "verified_from": "download_manifest.json; every LFS SHA256 matched"
33
+ },
34
+ "execution": "shared_state",
35
+ "trainable_tensor_count": 535,
36
+ "versions": {
37
+ "torch": "2.6.0",
38
+ "transformers": "5.4.0",
39
+ "peft": "0.18.1",
40
+ "safetensors": "0.6.2"
41
+ },
42
+ "files_sha256": {
43
+ "LICENSE": "bbedc3fda3305820b977265f01b8619d87570a6739de3a5582c3464840f1e57a",
44
+ "README.md": "19dade0ed4951da63d3f556939f52d16e81d6a77fea4372816754824c52a3983",
45
+ "batching.py": "ea45d4724bcafca559fc5a2a18092918b633746771c19da6554c29bc5f2cef64",
46
+ "chat_template.jinja": "a4aee8afcf2e0711942cf848899be66016f8d14a889ff9ede07bca099c28f715",
47
+ "compiler.py": "f35bab2e71b6beb1228daaa5b7baecdacf04eaf713aee14e8082b97090f910b4",
48
+ "config.json": "63d39d4399bf06747f5f06d6b68db7b17fa3e96e8bc219fb9823742a700a06c1",
49
+ "configuration_valen.py": "735b02402fb5b6c7a1652f6691ba66d066ef99e84500042faec396ff7a668fe5",
50
+ "data_types.py": "b06ce08081d8f7b2bf36abf302410a96086395e75a04f9e9b1c591db519b1641",
51
+ "heads.py": "63b5970a8bfa121eff94d50ffd35e1fa8387f3af5abccc5f5b75381fb084fc34",
52
+ "lora/README.md": "761f9a02d12a6434a0444d774b01bd6e13cd98c392c154f2442665b8e632819b",
53
+ "lora/adapter_config.json": "83e2bc08b862c2cec7326c9f1ef2f44580e422c5f4ba2eea1148c8cd12bc979a",
54
+ "lora/adapter_model.safetensors": "b162b622b6d92720a87c678931a88ff05fd5e4b93b356997153c124bfac87708",
55
+ "mixer.safetensors": "64d368877bac6f4d9e8662d07ed6f21d3e4e58bec4e7a5dc6b4ac555fb4028d9",
56
+ "modeling_valen.py": "07f87481334cb1e28e9daee036c27bab3654645abf3df7983346b316e7788848",
57
+ "modeling_valen_lora.py": "0102d4e71596dc7e1f6f3c95e6cf5fb514c50bff9f27c4870f16ad618874d4be",
58
+ "processor_config.json": "d89ef49ce9cd37fbf510158e13c1ef063d9286411c1ec9049932dbe0487143b1",
59
+ "responses.py": "298016b0070f1000a38d033e1048e038ff5df6fc1dcbe830601105b181f1d228",
60
+ "runtime_model.py": "98bf0443ca196900b9f2b056129c84932041b8b53395d111f2fe6d3f2bc1e0a6",
61
+ "schema.py": "253825862b60016e37fd1040492008ad7f303679c092313d8a6527cf509f3b6e",
62
+ "tokenizer.json": "87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4",
63
+ "tokenizer_config.json": "e98f1901ac6f0adff67b1d540bfa0c36ac1a0cf59eb72ed78146ef89aafa1182",
64
+ "validation.json": "6e66db946145cba9c89033b82036e048845ac0f4e81920dcc9a8992a7f88edd2",
65
+ "visual_merger.safetensors": "8379c8434e846ff5007de471cd6174092ac0d30699007fbea7780882106774c1",
66
+ "fresh_process_validation.json": "d5f7b9a17d0f1011d02177a0dc0af7530912c2a5f191f06ee98a3a94cbd39b0c"
67
+ }
68
+ }
unmerged/fresh_process_validation.json ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "passed": true,
3
+ "isolated_python": true,
4
+ "valen_imports_blocked": true,
5
+ "lora_remains_unmerged": true,
6
+ "all_real_modalities_and_question_types_passed": true,
7
+ "sdpa_example_passed": true,
8
+ "cases": 20,
9
+ "max_probability_abs_error": 0.0,
10
+ "max_logit_abs_error": 0.0,
11
+ "details": [
12
+ {
13
+ "case": "shared_state/text_multi/choice",
14
+ "probability_max_abs": 0.0,
15
+ "logit_max_abs": 0.0
16
+ },
17
+ {
18
+ "case": "shared_state/text_multi/noul",
19
+ "probability_max_abs": 0.0,
20
+ "logit_max_abs": 0.0
21
+ },
22
+ {
23
+ "case": "shared_state/text_multi/score",
24
+ "probability_max_abs": 0.0,
25
+ "logit_max_abs": 0.0
26
+ },
27
+ {
28
+ "case": "shared_state/text_multi/score_many",
29
+ "probability_max_abs": 0.0,
30
+ "logit_max_abs": 0.0
31
+ },
32
+ {
33
+ "case": "shared_state/image_score/decision",
34
+ "probability_max_abs": 0.0,
35
+ "logit_max_abs": 0.0
36
+ },
37
+ {
38
+ "case": "shared_state/image_noul/decision",
39
+ "probability_max_abs": 0.0,
40
+ "logit_max_abs": 0.0
41
+ },
42
+ {
43
+ "case": "shared_state/image_choice/decision",
44
+ "probability_max_abs": 0.0,
45
+ "logit_max_abs": 0.0
46
+ },
47
+ {
48
+ "case": "shared_state/video_multi/q000",
49
+ "probability_max_abs": 0.0,
50
+ "logit_max_abs": 0.0
51
+ },
52
+ {
53
+ "case": "shared_state/video_multi/score_000",
54
+ "probability_max_abs": 0.0,
55
+ "logit_max_abs": 0.0
56
+ },
57
+ {
58
+ "case": "shared_state/video_multi/noul_000",
59
+ "probability_max_abs": 0.0,
60
+ "logit_max_abs": 0.0
61
+ },
62
+ {
63
+ "case": "question/text_multi/choice",
64
+ "probability_max_abs": 0.0,
65
+ "logit_max_abs": 0.0
66
+ },
67
+ {
68
+ "case": "question/text_multi/noul",
69
+ "probability_max_abs": 0.0,
70
+ "logit_max_abs": 0.0
71
+ },
72
+ {
73
+ "case": "question/text_multi/score",
74
+ "probability_max_abs": 0.0,
75
+ "logit_max_abs": 0.0
76
+ },
77
+ {
78
+ "case": "question/text_multi/score_many",
79
+ "probability_max_abs": 0.0,
80
+ "logit_max_abs": 0.0
81
+ },
82
+ {
83
+ "case": "question/image_score/decision",
84
+ "probability_max_abs": 0.0,
85
+ "logit_max_abs": 0.0
86
+ },
87
+ {
88
+ "case": "question/image_noul/decision",
89
+ "probability_max_abs": 0.0,
90
+ "logit_max_abs": 0.0
91
+ },
92
+ {
93
+ "case": "question/image_choice/decision",
94
+ "probability_max_abs": 0.0,
95
+ "logit_max_abs": 0.0
96
+ },
97
+ {
98
+ "case": "question/video_multi/q000",
99
+ "probability_max_abs": 0.0,
100
+ "logit_max_abs": 0.0
101
+ },
102
+ {
103
+ "case": "question/video_multi/score_000",
104
+ "probability_max_abs": 0.0,
105
+ "logit_max_abs": 0.0
106
+ },
107
+ {
108
+ "case": "question/video_multi/noul_000",
109
+ "probability_max_abs": 0.0,
110
+ "logit_max_abs": 0.0
111
+ }
112
+ ]
113
+ }
unmerged/heads.py ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """可替换的候选评分头。 / Interchangeable, candidate-wise decision heads."""
2
+ import math
3
+
4
+ import torch
5
+ from torch import nn
6
+
7
+
8
+ def head_signature(config):
9
+ """用于构建与恢复校验。 / Canonical architecture settings for loading."""
10
+ kind = config.get("head_type", "bilinear")
11
+ defaults = {
12
+ "bilinear": {"projection_dim": 256},
13
+ "mlp": {"head_hidden_dim": 512, "head_bottleneck_dim": 128},
14
+ "role_mlp": {"head_width": 256, "head_hidden_dim": 1024},
15
+ "mixer": {"head_width": 256, "head_layers": 2,
16
+ "head_token_hidden_dim": 16, "head_channel_hidden_dim": 1024},
17
+ }
18
+ if kind not in defaults:
19
+ raise ValueError(f"Unknown Qwen head_type: {kind!r}")
20
+ values = {key: config.get(key, value) for key, value in defaults[kind].items()}
21
+ if any(type(value) is not int or value <= 0 for value in values.values()):
22
+ raise ValueError("Decision head dimensions must be positive integers")
23
+ return {"head_type": kind, **values}
24
+
25
+
26
+ class DecisionHead(nn.Module):
27
+ """原有参数名保持兼容。 / Preserve legacy bilinear parameter names."""
28
+ def __init__(self, hidden_size, projection_dim=256):
29
+ super().__init__()
30
+ self.decision = nn.Linear(hidden_size, projection_dim, bias=False)
31
+ self.candidate = nn.Linear(hidden_size, projection_dim, bias=False)
32
+ self.scale = math.sqrt(projection_dim)
33
+
34
+ def forward(self, hidden, positions, decision_position):
35
+ d = self.decision(hidden[0, decision_position].float())
36
+ c = self.candidate(hidden[0, positions].float())
37
+ return (c * d).sum(-1) / self.scale
38
+
39
+ def extract_features(self, hidden, branch):
40
+ return hidden[:, [*branch.candidate_positions, branch.decision_position], :]
41
+
42
+ def score_features(self, features):
43
+ return self(features, list(range(features.shape[1] - 1)), features.shape[1] - 1)
44
+
45
+
46
+ class MLPHead(nn.Module):
47
+ """每个候选共享一个 MLP。 / One shared MLP for arbitrary candidate counts."""
48
+ def __init__(self, hidden_size, hidden_dim=512, bottleneck_dim=128):
49
+ super().__init__()
50
+ self.decision_norm = nn.LayerNorm(hidden_size)
51
+ self.candidate_norm = nn.LayerNorm(hidden_size)
52
+ self.network = nn.Sequential(nn.Linear(2 * hidden_size, hidden_dim), nn.GELU(),
53
+ nn.Linear(hidden_dim, bottleneck_dim), nn.GELU(),
54
+ nn.Linear(bottleneck_dim, 1))
55
+
56
+ def extract_features(self, hidden, branch):
57
+ c = hidden[0, branch.candidate_positions]
58
+ d = hidden[0, branch.decision_position].expand_as(c)
59
+ return torch.stack((d, c), dim=1)
60
+
61
+ def score_features(self, features):
62
+ d, c = features.float().unbind(1)
63
+ return self.network(torch.cat((self.decision_norm(d), self.candidate_norm(c)), -1)).squeeze(-1)
64
+
65
+
66
+ def role_features(hidden, branch):
67
+ """先池化再投影,可缓存冻结特征。 / Pool before trainable projections."""
68
+ spans = (getattr(branch, "context_span", None), getattr(branch, "instruction_span", None))
69
+ candidates = getattr(branch, "candidate_spans", None)
70
+ if any(span is None for span in spans) or not candidates or len(candidates) != len(branch.candidate_positions):
71
+ raise ValueError("Role heads require compiler context, instruction and candidate spans")
72
+
73
+ def pool(span):
74
+ start, end = span
75
+ if not 0 <= start < end <= hidden.shape[1]:
76
+ raise ValueError(f"Invalid role span: {span}")
77
+ return hidden[0, start:end].float().mean(0)
78
+
79
+ context, instruction = (pool(span) for span in spans)
80
+ decision = hidden[0, branch.decision_position].float()
81
+ return torch.stack([torch.stack((context, instruction, pool(span), decision)) for span in candidates])
82
+
83
+
84
+ class RoleHead(nn.Module):
85
+ def __init__(self, hidden_size, width):
86
+ super().__init__()
87
+ self.input_norm = nn.LayerNorm(hidden_size)
88
+ self.projection = nn.Linear(hidden_size, width)
89
+ self.roles = nn.Parameter(torch.zeros(1, 4, width))
90
+
91
+ def extract_features(self, hidden, branch):
92
+ return role_features(hidden, branch)
93
+
94
+ def project(self, features):
95
+ return self.projection(self.input_norm(features.float())) + self.roles
96
+
97
+
98
+ class RoleMLPHead(RoleHead):
99
+ """与 Mixer 使用相同输入。 / Control for the Mixer's richer input features."""
100
+ def __init__(self, hidden_size, width=256, hidden_dim=1024):
101
+ super().__init__(hidden_size, width)
102
+ self.network = nn.Sequential(nn.Linear(4 * width, hidden_dim), nn.GELU(), nn.Linear(hidden_dim, 1))
103
+
104
+ def score_features(self, features):
105
+ return self.network(self.project(features).flatten(1)).squeeze(-1)
106
+
107
+
108
+ class MixerBlock(nn.Module):
109
+ def __init__(self, width, token_hidden, channel_hidden):
110
+ super().__init__()
111
+ self.token_norm = nn.LayerNorm(width)
112
+ self.token_mlp = nn.Sequential(nn.Linear(4, token_hidden), nn.GELU(), nn.Linear(token_hidden, 4))
113
+ self.channel_norm = nn.LayerNorm(width)
114
+ self.channel_mlp = nn.Sequential(nn.Linear(width, channel_hidden), nn.GELU(), nn.Linear(channel_hidden, width))
115
+
116
+ def forward(self, x):
117
+ # 混合角色,不混合不同候选。 / Mix fixed roles, never candidate rows.
118
+ x = x + self.token_mlp(self.token_norm(x).transpose(1, 2)).transpose(1, 2)
119
+ return x + self.channel_mlp(self.channel_norm(x))
120
+
121
+
122
+ class MixerHead(RoleHead):
123
+ def __init__(self, hidden_size, width=256, layers=2, token_hidden=16, channel_hidden=1024):
124
+ super().__init__(hidden_size, width)
125
+ self.blocks = nn.Sequential(*(MixerBlock(width, token_hidden, channel_hidden) for _ in range(layers)))
126
+ self.output = nn.Sequential(nn.LayerNorm(width), nn.Linear(width, 1))
127
+
128
+ def score_features(self, features):
129
+ # 第三行是候选角色。 / Read the updated candidate role.
130
+ return self.output(self.blocks(self.project(features))[:, 2]).squeeze(-1)
131
+
132
+
133
+ def build_head(hidden_size, config):
134
+ settings = head_signature(config)
135
+ kind = settings.pop("head_type")
136
+ if kind == "bilinear":
137
+ return DecisionHead(hidden_size, settings["projection_dim"])
138
+ if kind == "mlp":
139
+ return MLPHead(hidden_size, settings["head_hidden_dim"], settings["head_bottleneck_dim"])
140
+ if kind == "role_mlp":
141
+ return RoleMLPHead(hidden_size, settings["head_width"], settings["head_hidden_dim"])
142
+ return MixerHead(hidden_size, settings["head_width"], settings["head_layers"],
143
+ settings["head_token_hidden_dim"], settings["head_channel_hidden_dim"])
unmerged/lora/README.md ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: ''
3
+ library_name: peft
4
+ tags:
5
+ - 'base_model:adapter:'
6
+ - lora
7
+ - transformers
8
+ ---
9
+
10
+ # Model Card for Model ID
11
+
12
+ <!-- Provide a quick summary of what the model is/does. -->
13
+
14
+
15
+
16
+ ## Model Details
17
+
18
+ ### Model Description
19
+
20
+ <!-- Provide a longer summary of what this model is. -->
21
+
22
+
23
+
24
+ - **Developed by:** [More Information Needed]
25
+ - **Funded by [optional]:** [More Information Needed]
26
+ - **Shared by [optional]:** [More Information Needed]
27
+ - **Model type:** [More Information Needed]
28
+ - **Language(s) (NLP):** [More Information Needed]
29
+ - **License:** [More Information Needed]
30
+ - **Finetuned from model [optional]:** [More Information Needed]
31
+
32
+ ### Model Sources [optional]
33
+
34
+ <!-- Provide the basic links for the model. -->
35
+
36
+ - **Repository:** [More Information Needed]
37
+ - **Paper [optional]:** [More Information Needed]
38
+ - **Demo [optional]:** [More Information Needed]
39
+
40
+ ## Uses
41
+
42
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
43
+
44
+ ### Direct Use
45
+
46
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
47
+
48
+ [More Information Needed]
49
+
50
+ ### Downstream Use [optional]
51
+
52
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
53
+
54
+ [More Information Needed]
55
+
56
+ ### Out-of-Scope Use
57
+
58
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
59
+
60
+ [More Information Needed]
61
+
62
+ ## Bias, Risks, and Limitations
63
+
64
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
65
+
66
+ [More Information Needed]
67
+
68
+ ### Recommendations
69
+
70
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
71
+
72
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
73
+
74
+ ## How to Get Started with the Model
75
+
76
+ Use the code below to get started with the model.
77
+
78
+ [More Information Needed]
79
+
80
+ ## Training Details
81
+
82
+ ### Training Data
83
+
84
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
85
+
86
+ [More Information Needed]
87
+
88
+ ### Training Procedure
89
+
90
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
91
+
92
+ #### Preprocessing [optional]
93
+
94
+ [More Information Needed]
95
+
96
+
97
+ #### Training Hyperparameters
98
+
99
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
100
+
101
+ #### Speeds, Sizes, Times [optional]
102
+
103
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
104
+
105
+ [More Information Needed]
106
+
107
+ ## Evaluation
108
+
109
+ <!-- This section describes the evaluation protocols and provides the results. -->
110
+
111
+ ### Testing Data, Factors & Metrics
112
+
113
+ #### Testing Data
114
+
115
+ <!-- This should link to a Dataset Card if possible. -->
116
+
117
+ [More Information Needed]
118
+
119
+ #### Factors
120
+
121
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
122
+
123
+ [More Information Needed]
124
+
125
+ #### Metrics
126
+
127
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
128
+
129
+ [More Information Needed]
130
+
131
+ ### Results
132
+
133
+ [More Information Needed]
134
+
135
+ #### Summary
136
+
137
+
138
+
139
+ ## Model Examination [optional]
140
+
141
+ <!-- Relevant interpretability work for the model goes here -->
142
+
143
+ [More Information Needed]
144
+
145
+ ## Environmental Impact
146
+
147
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
148
+
149
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
150
+
151
+ - **Hardware Type:** [More Information Needed]
152
+ - **Hours used:** [More Information Needed]
153
+ - **Cloud Provider:** [More Information Needed]
154
+ - **Compute Region:** [More Information Needed]
155
+ - **Carbon Emitted:** [More Information Needed]
156
+
157
+ ## Technical Specifications [optional]
158
+
159
+ ### Model Architecture and Objective
160
+
161
+ [More Information Needed]
162
+
163
+ ### Compute Infrastructure
164
+
165
+ [More Information Needed]
166
+
167
+ #### Hardware
168
+
169
+ [More Information Needed]
170
+
171
+ #### Software
172
+
173
+ [More Information Needed]
174
+
175
+ ## Citation [optional]
176
+
177
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
178
+
179
+ **BibTeX:**
180
+
181
+ [More Information Needed]
182
+
183
+ **APA:**
184
+
185
+ [More Information Needed]
186
+
187
+ ## Glossary [optional]
188
+
189
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
190
+
191
+ [More Information Needed]
192
+
193
+ ## More Information [optional]
194
+
195
+ [More Information Needed]
196
+
197
+ ## Model Card Authors [optional]
198
+
199
+ [More Information Needed]
200
+
201
+ ## Model Card Contact
202
+
203
+ [More Information Needed]
204
+ ### Framework versions
205
+
206
+ - PEFT 0.18.1
unmerged/lora/adapter_config.json ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "Qwen3_5TextModel",
7
+ "parent_library": "transformers.models.qwen3_5.modeling_qwen3_5"
8
+ },
9
+ "base_model_name_or_path": "Qwen/Qwen3.5-4B",
10
+ "bias": "none",
11
+ "corda_config": null,
12
+ "ensure_weight_tying": false,
13
+ "eva_config": null,
14
+ "exclude_modules": null,
15
+ "fan_in_fan_out": false,
16
+ "inference_mode": true,
17
+ "init_lora_weights": true,
18
+ "layer_replication": null,
19
+ "layers_pattern": null,
20
+ "layers_to_transform": null,
21
+ "loftq_config": {},
22
+ "lora_alpha": 64,
23
+ "lora_bias": false,
24
+ "lora_dropout": 0.0,
25
+ "megatron_config": null,
26
+ "megatron_core": "megatron.core",
27
+ "modules_to_save": null,
28
+ "peft_type": "LORA",
29
+ "peft_version": "0.18.1",
30
+ "qalora_group_size": 16,
31
+ "r": 32,
32
+ "rank_pattern": {},
33
+ "revision": "851bf6e806efd8d0a36b00ddf55e13ccb7b8cd0a",
34
+ "target_modules": [
35
+ "in_proj_qkv",
36
+ "out_proj",
37
+ "in_proj_z",
38
+ "gate_proj",
39
+ "o_proj",
40
+ "up_proj",
41
+ "k_proj",
42
+ "in_proj_a",
43
+ "in_proj_b",
44
+ "v_proj",
45
+ "q_proj",
46
+ "down_proj"
47
+ ],
48
+ "target_parameters": null,
49
+ "task_type": null,
50
+ "trainable_token_indices": null,
51
+ "use_dora": false,
52
+ "use_qalora": false,
53
+ "use_rslora": false
54
+ }
unmerged/lora/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b162b622b6d92720a87c678931a88ff05fd5e4b93b356997153c124bfac87708
3
+ size 259784032
unmerged/mixer.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:64d368877bac6f4d9e8662d07ed6f21d3e4e58bec4e7a5dc6b4ac555fb4028d9
3
+ size 6867012
unmerged/modeling_valen.py ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Complete merged Qwen + decision head. / 已合并的完整 Qwen 和决策头。"""
2
+ import torch
3
+ from transformers import AutoProcessor
4
+ from transformers.models.qwen3_5.modeling_qwen3_5 import Qwen3_5Model, Qwen3_5PreTrainedModel
5
+
6
+ from .configuration_valen import ValenQwenConfig
7
+ from .heads import build_head
8
+ from .runtime_model import ValenQwen
9
+ from .compiler import Compiler
10
+ from .responses import answer
11
+ # List transitive files explicitly for Transformers' local dynamic loader.
12
+ # 本地动态加载需要显式列出间接依赖,否则搬移后可能缺少这些模块。
13
+ from .batching import collate_branches
14
+ from .schema import candidates
15
+ from .data_types import QuestionSpec
16
+
17
+
18
+ class ValenQwenForDecisionMaking(Qwen3_5PreTrainedModel):
19
+ config_class = ValenQwenConfig
20
+ base_model_prefix = "backbone"
21
+ model_name = "Valen"
22
+ architecture = "qwen"
23
+ # The trained Mixer stays FP32 with a BF16 backbone. / BF16 基座、FP32 决策头。
24
+ _keep_in_fp32_modules_strict = ["head"]
25
+
26
+ def __init__(self, config, backbone=None, head=None):
27
+ super().__init__(config)
28
+ if (backbone is None) != (head is None):
29
+ raise ValueError("Supply both a merged backbone and a trained head")
30
+ self.backbone = backbone if backbone is not None else Qwen3_5Model(config)
31
+ self.head = head if head is not None else build_head(config.text_config.hidden_size, config.valen_head)
32
+ self.head.float()
33
+ self._processor = None
34
+ # Supplied weights are already trained: do not reinitialize them.
35
+ # 传入的参数已训练完成,不能再次调用初始化覆盖它们。
36
+ if backbone is not None:
37
+ for module in self.modules():
38
+ module._is_hf_initialized = True
39
+ self.post_init()
40
+
41
+ def get_input_embeddings(self):
42
+ return self.backbone.get_input_embeddings()
43
+
44
+ def set_input_embeddings(self, value):
45
+ self.backbone.set_input_embeddings(value)
46
+
47
+ def forward(self, question=None, **inputs):
48
+ if question is None:
49
+ return self.backbone(**inputs)
50
+ if hasattr(question, "questions"):
51
+ return self.forward_state(question)
52
+ return ValenQwen.forward(self, question)
53
+
54
+ # Use the exact trained readouts and batching implementation.
55
+ # 保留训练时的特征读取和 batch 逻辑。
56
+ extract_features = ValenQwen.extract_features
57
+ extract_state_features = ValenQwen.extract_state_features
58
+ _state_features = ValenQwen._state_features
59
+ forward_state = ValenQwen.forward_state
60
+ forward_state_batch = ValenQwen.forward_state_batch
61
+ forward_batch = ValenQwen.forward_batch
62
+ score_features = ValenQwen.score_features
63
+
64
+ def make_compiler(self, media_root=".", execution=None, processor=None):
65
+ if processor is None:
66
+ if self._processor is None:
67
+ self._processor = AutoProcessor.from_pretrained(self.config._name_or_path, trust_remote_code=True)
68
+ processor = self._processor
69
+ return Compiler(processor, media_root, self.config.valen_max_length, self.config.valen_media_kwargs,
70
+ execution=execution or self.config.qwen_execution)
71
+
72
+ @torch.inference_mode()
73
+ def predict(self, request, *, media_root=".", execution=None, temperature=1.0, processor=None):
74
+ self.eval()
75
+ # Only request content reaches the compiler. / 只编译输入,不读取标签。
76
+ request = request["request"] if "request" in request else request
77
+ compiler = self.make_compiler(media_root, execution, processor)
78
+ state = compiler.compile({"request": request})
79
+ logits = self.forward_state(state) if state.inputs is not None else [self(q) for q in state.questions]
80
+ answers = {q.qid: answer(q, z, temperature[q.kind] if isinstance(temperature, dict) else temperature)
81
+ for q, z in zip(state.questions, logits)}
82
+ return {"model": self.model_name, "answers": answers,
83
+ "usage": {"input_tokens": state.logical_tokens, "output_tokens": 0},
84
+ "internal_usage": {"compute_tokens": state.compute_tokens}}
unmerged/modeling_valen_lora.py ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Original base + separate trained deltas. / 原始基座与未融合的训练权重。"""
2
+ import hashlib
3
+ from pathlib import Path
4
+
5
+ import torch
6
+ from peft import PeftModel
7
+ from safetensors.torch import load_file
8
+ from transformers import Qwen3_5ForConditionalGeneration
9
+
10
+ from .configuration_valen import ValenQwenConfig
11
+ from .modeling_valen import ValenQwenForDecisionMaking
12
+ # Explicit dependencies keep local HF dynamic loading portable.
13
+ # 显式列出依赖,保证 HF 本地动态加载能复制完整的运行代码。
14
+ from .heads import build_head
15
+ from .compiler import Compiler
16
+ from .runtime_model import ValenQwen
17
+ from .responses import answer
18
+ from .batching import collate_branches
19
+ from .schema import candidates
20
+ from .data_types import QuestionSpec
21
+
22
+
23
+ def _verify_local_base(base_path, expected):
24
+ if not Path(base_path).is_dir():
25
+ return
26
+ for filename, digest in expected.items():
27
+ path = Path(base_path) / filename
28
+ if not path.is_file():
29
+ raise FileNotFoundError(f"Original base shard is required: {path}")
30
+ actual = hashlib.sha256()
31
+ with path.open("rb") as stream:
32
+ for chunk in iter(lambda: stream.read(8 << 20), b""):
33
+ actual.update(chunk)
34
+ if actual.hexdigest() != digest:
35
+ raise ValueError(f"Base weights differ from the trained revision: {filename}")
36
+
37
+
38
+ class ValenQwenWithLoRA(ValenQwenForDecisionMaking):
39
+ @classmethod
40
+ def from_pretrained(cls, pretrained_model_name_or_path, *model_args, config=None,
41
+ base_model_path=None, device=None, dtype=None, attn_implementation=None,
42
+ is_trainable=False, local_files_only=True, output_loading_info=False,
43
+ verify_base=True, **kwargs):
44
+ if model_args:
45
+ raise TypeError("Pass loader options as named arguments")
46
+ folder = Path(pretrained_model_name_or_path).resolve(strict=True)
47
+ if config is None:
48
+ config = ValenQwenConfig.from_pretrained(folder, local_files_only=True)
49
+ base = str(base_model_path or config.valen_base["repo"])
50
+ dtype = dtype or kwargs.pop("torch_dtype", None) or config.dtype or torch.bfloat16
51
+ if isinstance(dtype, str):
52
+ dtype = getattr(torch, dtype)
53
+ if dtype != torch.bfloat16:
54
+ raise ValueError("Use dtype=torch.bfloat16 to reproduce this adapter bundle")
55
+ attention = attn_implementation or config._attn_implementation or "sdpa"
56
+ if kwargs.pop("device_map", None) is not None:
57
+ raise ValueError("Use device=... or model.to(...) for this adapter bundle")
58
+ # AutoModel also supplies flags for loading the bundle's custom code.
59
+ # AutoModel 会传入自定义代码标记,它们不应改变原始基座的加载配置。
60
+ for name in ("trust_remote_code", "_from_auto", "_commit_hash", "adapter_kwargs", "revision", "subfolder"):
61
+ kwargs.pop(name, None)
62
+ base_options = {name:kwargs.pop(name) for name in
63
+ ("cache_dir", "token", "force_download", "proxies", "low_cpu_mem_usage") if name in kwargs}
64
+ if kwargs:
65
+ raise TypeError(f"Unsupported loader options: {sorted(kwargs)}")
66
+ if verify_base:
67
+ _verify_local_base(base, config.valen_base["weight_sha256"])
68
+ # Load the published conditional model first to preserve language prefixes.
69
+ # 先完整加载官方模型,再取出主干,避免语言参数前缀被错误映射。
70
+ container, loading = Qwen3_5ForConditionalGeneration.from_pretrained(
71
+ base, revision=config.valen_base["revision"], dtype=dtype,
72
+ attn_implementation=attention, local_files_only=local_files_only,
73
+ output_loading_info=True, **base_options)
74
+ if any(loading.get(key) for key in ("missing_keys", "unexpected_keys", "mismatched_keys", "error_msgs")):
75
+ raise ValueError(f"Incomplete original base load: {loading}")
76
+ backbone = container.model
77
+ del container
78
+ backbone.requires_grad_(False)
79
+ backbone.language_model = PeftModel.from_pretrained(
80
+ backbone.language_model, folder / "lora", is_trainable=is_trainable,
81
+ autocast_adapter_dtype=True, torch_device="cpu", local_files_only=True)
82
+ backbone.visual.merger.load_state_dict(load_file(folder / "visual_merger.safetensors"), strict=True)
83
+ head = build_head(config.text_config.hidden_size, config.valen_head).float()
84
+ head.load_state_dict(load_file(folder / "mixer.safetensors"), strict=True)
85
+ config._name_or_path = str(folder)
86
+ model = cls(config, backbone=backbone, head=head)
87
+ model.head.requires_grad_(is_trainable)
88
+ model.backbone.visual.merger.requires_grad_(is_trainable)
89
+ if device is not None:
90
+ model.to(device)
91
+ model.eval()
92
+ return (model, loading) if output_loading_info else model
unmerged/processor_config.json ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "image_processor": {
3
+ "do_convert_rgb": true,
4
+ "do_normalize": true,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Qwen2VLImageProcessor",
13
+ "image_std": [
14
+ 0.5,
15
+ 0.5,
16
+ 0.5
17
+ ],
18
+ "merge_size": 2,
19
+ "patch_size": 16,
20
+ "resample": 3,
21
+ "rescale_factor": 0.00392156862745098,
22
+ "size": {
23
+ "longest_edge": 16777216,
24
+ "shortest_edge": 65536
25
+ },
26
+ "temporal_patch_size": 2
27
+ },
28
+ "processor_class": "Qwen3VLProcessor",
29
+ "video_processor": {
30
+ "do_convert_rgb": true,
31
+ "do_normalize": true,
32
+ "do_rescale": true,
33
+ "do_resize": true,
34
+ "do_sample_frames": true,
35
+ "fps": 2,
36
+ "image_mean": [
37
+ 0.5,
38
+ 0.5,
39
+ 0.5
40
+ ],
41
+ "image_std": [
42
+ 0.5,
43
+ 0.5,
44
+ 0.5
45
+ ],
46
+ "max_frames": 768,
47
+ "merge_size": 2,
48
+ "min_frames": 4,
49
+ "patch_size": 16,
50
+ "resample": 3,
51
+ "rescale_factor": 0.00392156862745098,
52
+ "return_metadata": false,
53
+ "size": {
54
+ "longest_edge": 25165824,
55
+ "shortest_edge": 4096
56
+ },
57
+ "temporal_patch_size": 2,
58
+ "video_processor_type": "Qwen3VLVideoProcessor"
59
+ }
60
+ }
unmerged/responses.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import math
2
+ import torch
3
+
4
+ def answer(question, logits, temperature=1.0):
5
+ if not math.isfinite(temperature) or temperature <= 0:
6
+ raise ValueError("Calibration temperature must be finite and positive")
7
+ if logits.ndim != 1 or len(logits) != len(question.keys) or not torch.isfinite(logits).all():
8
+ raise ValueError("Expected one finite logit per candidate")
9
+ probs = (logits.float() / temperature).softmax(-1).detach().cpu().tolist()
10
+ total = sum(probs)
11
+ probs = [p / total for p in probs]
12
+ result = {"type": question.kind}
13
+ if question.kind == "noul":
14
+ result["noul"] = probs[question.keys.index("true")]
15
+ return result
16
+ result["probabilities"] = dict(zip(question.keys, probs))
17
+ mode = max(range(len(probs)), key=probs.__getitem__)
18
+ if question.kind == "choice":
19
+ result["choice"] = question.keys[mode]
20
+ result["confidence"] = 1.0 if len(probs) == 1 else max(0.0, (max(probs) - 1/len(probs)) / (1 - 1/len(probs)))
21
+ else:
22
+ result["score"] = sum(i * p for i, p in enumerate(probs))
23
+ result["legend"] = dict(zip(question.keys, question.descriptions))
24
+ # Independently implemented formula from pinned system-one adapter:
25
+ # fb52b1030b7fc1f4f1cf39910afa5da54f9835e3, confidence_metrics.py.
26
+ distance = sum(p * abs(i - mode) for i, p in enumerate(probs))
27
+ uniform_mad = sum(abs(i - (len(probs)-1)/2) for i in range(len(probs))) / len(probs)
28
+ result["confidence"] = max(0.0, 1.0 - distance / uniform_mad)
29
+ return result
unmerged/runtime_model.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import torch
2
+ from torch import nn
3
+ MODEL_NAME = "Valen"
4
+ from .heads import DecisionHead, build_head
5
+ from .batching import branch_batches, collate_branches
6
+
7
+
8
+ class ValenQwen(nn.Module):
9
+ """Qwen3.5 backbone with a shared candidate decision head."""
10
+
11
+ model_name = MODEL_NAME
12
+ architecture = "qwen"
13
+
14
+ def __init__(self, backbone, projection_dim=256, head_config=None):
15
+ super().__init__()
16
+ self.backbone = backbone
17
+ self.head = build_head(backbone.config.text_config.hidden_size,
18
+ dict({"projection_dim": projection_dim}, **(head_config or {})))
19
+
20
+ def forward(self, question):
21
+ device = next(self.backbone.parameters()).device
22
+ outputs = []
23
+ for branch in question.branches:
24
+ inputs = {k: v.to(device) if isinstance(v, torch.Tensor) else v for k, v in branch.inputs.items()}
25
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
26
+ outputs.append(self.head.score_features(self.head.extract_features(hidden, branch)))
27
+ return torch.cat(outputs)
28
+
29
+ def extract_features(self, question):
30
+ """缓存投影前的特征。 / Cache raw readouts before trainable head layers."""
31
+ device = next(self.backbone.parameters()).device
32
+ features = []
33
+ for branch in question.branches:
34
+ inputs = {k: v.to(device) if isinstance(v, torch.Tensor) else v for k, v in branch.inputs.items()}
35
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
36
+ features.append(self.head.extract_features(hidden, branch))
37
+ return features
38
+
39
+ def extract_state_features(self, state):
40
+ """一次编码 state,读取各题特征。 / One backbone graph for every question."""
41
+ if not state.questions:
42
+ return []
43
+ if state.inputs is None:
44
+ raise ValueError("Shared-state features require compiled shared inputs")
45
+ device = next(self.backbone.parameters()).device
46
+ inputs = {k: v.to(device) if isinstance(v, torch.Tensor) else v for k, v in state.inputs.items()}
47
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
48
+ return self._state_features(hidden, state)
49
+
50
+ def _state_features(self, hidden, state):
51
+ return [[self.head.extract_features(hidden, branch) for branch in q.branches]
52
+ for q in state.questions]
53
+
54
+ def forward_state(self, state):
55
+ return [self.score_features(features) for features in self.extract_state_features(state)]
56
+
57
+ def forward_state_batch(self, states, max_tokens=32768):
58
+ """不同 state 组成 batch,同一 state 的题目共用一行。 / One row per shared state."""
59
+ device = next(self.backbone.parameters()).device
60
+ pad_token_id = getattr(self.backbone.config.text_config, "pad_token_id", None) or 0
61
+ outputs = [[] for _ in states]
62
+ representatives = []
63
+ indices = []
64
+ for index, state in enumerate(states):
65
+ if not state.questions:
66
+ continue
67
+ if state.inputs is None or any(branch.inputs is not state.inputs
68
+ for q in state.questions for branch in q.branches):
69
+ raise ValueError("Shared-state batch requires one shared input per state")
70
+ representatives.append(state.questions[0])
71
+ indices.append(index)
72
+ for batch in branch_batches(representatives, max_tokens):
73
+ inputs = collate_branches([branch for _, branch in batch], pad_token_id)
74
+ inputs = {key: value.to(device) for key, value in inputs.items()}
75
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
76
+ for row, (index, _) in enumerate(batch):
77
+ original = indices[index]
78
+ features = self._state_features(hidden[row:row + 1], states[original])
79
+ outputs[original] = [self.score_features(f) for f in features]
80
+ return outputs
81
+
82
+ def forward_batch(self, questions, max_tokens=32768):
83
+ """Forward several QAs together; each keeps its own decision head inputs.
84
+
85
+ 多条 QA 并行;每条保留独立的候选、角色区间和 Score 分支。
86
+ """
87
+ device = next(self.backbone.parameters()).device
88
+ pad_token_id = getattr(self.backbone.config.text_config, "pad_token_id", None) or 0
89
+ outputs = [[] for _ in questions]
90
+ for batch in branch_batches(questions, max_tokens):
91
+ inputs = collate_branches([branch for _, branch in batch], pad_token_id)
92
+ inputs = {key: value.to(device) for key, value in inputs.items()}
93
+ hidden = self.backbone(**inputs, use_cache=False, return_dict=True).last_hidden_state
94
+ for row, (question_index, branch) in enumerate(batch):
95
+ features = self.head.extract_features(hidden[row:row + 1], branch)
96
+ outputs[question_index].append(self.head.score_features(features))
97
+ return [torch.cat(branches) for branches in outputs]
98
+
99
+ def score_features(self, features, head=None):
100
+ head = self.head if head is None else head
101
+ return torch.cat([head.score_features(hidden) for hidden in features])
unmerged/schema.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Strict JSONL contract. IDs and labels never enter the model prompt."""
2
+ import json
3
+ import math
4
+ from pathlib import Path
5
+
6
+
7
+ def candidates(question):
8
+ kind = question.get("type")
9
+ if not isinstance(question.get("instructions"), str) or not question["instructions"].strip():
10
+ raise ValueError("instructions must be nonempty text")
11
+ criteria = question.get("criteria")
12
+ if kind == "noul":
13
+ return [("true", "True / 是:满足问题中的条件。"), ("false", "False / 否:不满足问题中的条件。")]
14
+ if kind == "choice":
15
+ if not isinstance(criteria, dict) or not 1 <= len(criteria) <= 255:
16
+ raise ValueError("Choice needs 1–255 named criteria")
17
+ result = list(criteria.items())
18
+ elif kind == "score":
19
+ if not isinstance(criteria, list) or not 2 <= len(criteria) <= 255:
20
+ raise ValueError("Score criteria must be an ordered list of 2–255 descriptions")
21
+ result = [(str(i), text) for i, text in enumerate(criteria)]
22
+ else:
23
+ raise ValueError(f"Unsupported question type: {kind}")
24
+ if any(not isinstance(k, str) or not k or not isinstance(v, str) or not v.strip() for k, v in result):
25
+ raise ValueError("Candidate names and descriptions must be nonempty strings")
26
+ return result
27
+
28
+
29
+ def target_distribution(target, keys):
30
+ if target is None or target.get("probabilities") is None:
31
+ return None
32
+ probs = target["probabilities"]
33
+ if not isinstance(probs, dict) or set(probs) != set(keys):
34
+ raise ValueError(f"Probability keys must exactly match {keys}")
35
+ values = [probs[k] for k in keys]
36
+ if any(isinstance(v, bool) or not isinstance(v, (int, float)) or not math.isfinite(v) or v < 0 for v in values):
37
+ raise ValueError("Probabilities must be finite nonnegative numbers")
38
+ if not math.isclose(sum(values), 1.0, abs_tol=1e-6):
39
+ raise ValueError("Target probabilities must sum to 1")
40
+ return values
41
+
42
+
43
+ def validate_record(record, candidate_fn=candidates):
44
+ request = record["request"]
45
+ state = request["state"]
46
+ if not isinstance(state, (str, dict)):
47
+ raise ValueError("state must be text or a messages object")
48
+ if not isinstance(request["questions"], dict) or not request["questions"]:
49
+ raise ValueError("questions must be a nonempty mapping")
50
+ targets = record.get("targets", {})
51
+ if set(targets) - set(request["questions"]):
52
+ raise ValueError("Unknown target question IDs")
53
+ for qid, question in request["questions"].items():
54
+ target_distribution(targets.get(qid), [k for k, _ in candidate_fn(question)])
55
+ if not record.get("group_id"):
56
+ raise ValueError("group_id is required for leakage-free splits")
57
+ return record
58
+
59
+
60
+ def read_jsonl(path, candidate_fn=candidates):
61
+ records = []
62
+ with Path(path).open(encoding="utf-8") as stream:
63
+ for line_number, line in enumerate(stream, 1):
64
+ if line.strip():
65
+ try:
66
+ records.append(validate_record(json.loads(line), candidate_fn))
67
+ except (ValueError, KeyError, TypeError, AttributeError) as exc:
68
+ raise ValueError(f"{path}:{line_number}: {exc}") from exc
69
+ if not records:
70
+ raise ValueError("Empty dataset")
71
+ return records
unmerged/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87a7830d63fcf43bf241c3c5242e96e62dd3fdc29224ca26fed8ea333db72de4
3
+ size 19989343
unmerged/tokenizer_config.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "audio_bos_token": "<|audio_start|>",
4
+ "audio_eos_token": "<|audio_end|>",
5
+ "audio_token": "<|audio_pad|>",
6
+ "backend": "tokenizers",
7
+ "bos_token": null,
8
+ "clean_up_tokenization_spaces": false,
9
+ "eos_token": "<|im_end|>",
10
+ "errors": "replace",
11
+ "image_token": "<|image_pad|>",
12
+ "is_local": true,
13
+ "model_max_length": 262144,
14
+ "model_specific_special_tokens": {
15
+ "audio_bos_token": "<|audio_start|>",
16
+ "audio_eos_token": "<|audio_end|>",
17
+ "audio_token": "<|audio_pad|>",
18
+ "image_token": "<|image_pad|>",
19
+ "video_token": "<|video_pad|>",
20
+ "vision_bos_token": "<|vision_start|>",
21
+ "vision_eos_token": "<|vision_end|>"
22
+ },
23
+ "pad_token": "<|endoftext|>",
24
+ "pretokenize_regex": "(?i:'s|'t|'re|'ve|'m|'ll|'d)|[^\\r\\n\\p{L}\\p{N}]?[\\p{L}\\p{M}]+|\\p{N}| ?[^\\s\\p{L}\\p{M}\\p{N}]+[\\r\\n]*|\\s*[\\r\\n]+|\\s+(?!\\S)|\\s+",
25
+ "processor_class": "Qwen3VLProcessor",
26
+ "split_special_tokens": false,
27
+ "tokenizer_class": "TokenizersBackend",
28
+ "unk_token": null,
29
+ "video_token": "<|video_pad|>",
30
+ "vision_bos_token": "<|vision_start|>",
31
+ "vision_eos_token": "<|vision_end|>"
32
+ }
unmerged/validation.json ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "passed": true,
3
+ "all_training_deltas_bitwise_reloaded": true,
4
+ "all_backbone_buffers_bitwise_preserved": true,
5
+ "trainable_tensor_count": 535,
6
+ "reload_vs_checkpoint": {
7
+ "cases": 20,
8
+ "changed_labels": [],
9
+ "max_probability_abs_error": 0.0,
10
+ "max_logit_abs_error": 0.0,
11
+ "details": [
12
+ {
13
+ "case": "shared_state/text_multi/choice",
14
+ "probability_max_abs": 0.0,
15
+ "logit_max_abs": 0.0,
16
+ "label_changed": false
17
+ },
18
+ {
19
+ "case": "shared_state/text_multi/noul",
20
+ "probability_max_abs": 0.0,
21
+ "logit_max_abs": 0.0,
22
+ "label_changed": false
23
+ },
24
+ {
25
+ "case": "shared_state/text_multi/score",
26
+ "probability_max_abs": 0.0,
27
+ "logit_max_abs": 0.0,
28
+ "label_changed": false
29
+ },
30
+ {
31
+ "case": "shared_state/text_multi/score_many",
32
+ "probability_max_abs": 0.0,
33
+ "logit_max_abs": 0.0,
34
+ "label_changed": false
35
+ },
36
+ {
37
+ "case": "shared_state/image_score/decision",
38
+ "probability_max_abs": 0.0,
39
+ "logit_max_abs": 0.0,
40
+ "label_changed": false
41
+ },
42
+ {
43
+ "case": "shared_state/image_noul/decision",
44
+ "probability_max_abs": 0.0,
45
+ "logit_max_abs": 0.0,
46
+ "label_changed": false
47
+ },
48
+ {
49
+ "case": "shared_state/image_choice/decision",
50
+ "probability_max_abs": 0.0,
51
+ "logit_max_abs": 0.0,
52
+ "label_changed": false
53
+ },
54
+ {
55
+ "case": "shared_state/video_multi/q000",
56
+ "probability_max_abs": 0.0,
57
+ "logit_max_abs": 0.0,
58
+ "label_changed": false
59
+ },
60
+ {
61
+ "case": "shared_state/video_multi/score_000",
62
+ "probability_max_abs": 0.0,
63
+ "logit_max_abs": 0.0,
64
+ "label_changed": false
65
+ },
66
+ {
67
+ "case": "shared_state/video_multi/noul_000",
68
+ "probability_max_abs": 0.0,
69
+ "logit_max_abs": 0.0,
70
+ "label_changed": false
71
+ },
72
+ {
73
+ "case": "question/text_multi/choice",
74
+ "probability_max_abs": 0.0,
75
+ "logit_max_abs": 0.0,
76
+ "label_changed": false
77
+ },
78
+ {
79
+ "case": "question/text_multi/noul",
80
+ "probability_max_abs": 0.0,
81
+ "logit_max_abs": 0.0,
82
+ "label_changed": false
83
+ },
84
+ {
85
+ "case": "question/text_multi/score",
86
+ "probability_max_abs": 0.0,
87
+ "logit_max_abs": 0.0,
88
+ "label_changed": false
89
+ },
90
+ {
91
+ "case": "question/text_multi/score_many",
92
+ "probability_max_abs": 0.0,
93
+ "logit_max_abs": 0.0,
94
+ "label_changed": false
95
+ },
96
+ {
97
+ "case": "question/image_score/decision",
98
+ "probability_max_abs": 0.0,
99
+ "logit_max_abs": 0.0,
100
+ "label_changed": false
101
+ },
102
+ {
103
+ "case": "question/image_noul/decision",
104
+ "probability_max_abs": 0.0,
105
+ "logit_max_abs": 0.0,
106
+ "label_changed": false
107
+ },
108
+ {
109
+ "case": "question/image_choice/decision",
110
+ "probability_max_abs": 0.0,
111
+ "logit_max_abs": 0.0,
112
+ "label_changed": false
113
+ },
114
+ {
115
+ "case": "question/video_multi/q000",
116
+ "probability_max_abs": 0.0,
117
+ "logit_max_abs": 0.0,
118
+ "label_changed": false
119
+ },
120
+ {
121
+ "case": "question/video_multi/score_000",
122
+ "probability_max_abs": 0.0,
123
+ "logit_max_abs": 0.0,
124
+ "label_changed": false
125
+ },
126
+ {
127
+ "case": "question/video_multi/noul_000",
128
+ "probability_max_abs": 0.0,
129
+ "logit_max_abs": 0.0,
130
+ "label_changed": false
131
+ }
132
+ ]
133
+ },
134
+ "public_predict_passed": true,
135
+ "scope": "Text/image/video; question/shared_state; Choice/Noul/Score, including 12-level Score."
136
+ }