simonlehmann commited on
Commit
817ac58
·
verified ·
1 Parent(s): d8089a6

Add files using upload-large-folder tool

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ 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
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.
README.md ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ library_name: transformers
4
+ pipeline_tag: image-text-to-text
5
+ base_model: Cloudflare/clef
6
+ base_model_relation: quantized
7
+ tags:
8
+ - clef
9
+ - systemone
10
+ - nvfp4
11
+ - fp8
12
+ - compressed-tensors
13
+ - llm-compressor
14
+ - vllm
15
+ - multimodal
16
+ - structured-output
17
+ - classification
18
+ - custom-code
19
+ ---
20
+
21
+ # Clef — NVFP4
22
+
23
+ A mixed NVFP4 / FP8 quantization of [Cloudflare/clef](https://huggingface.co/Cloudflare/clef),
24
+ the 27B multimodal decision model. **Unofficial — not affiliated with or endorsed by Cloudflare.**
25
+
26
+ Clef answers typed questions about a state (text, JSON, images, video) with one probability per
27
+ allowed option, in a single prefill pass. Its value is the probabilities, so this quant was checked
28
+ option by option against the BF16 release, not only on accuracy.
29
+
30
+ **23 GB on disk (BF16 release: 55 GB); 20.2 GiB of weights in vLLM.**
31
+
32
+ ## What is quantized
33
+
34
+ | Part | Format |
35
+ |---|---|
36
+ | MLP `gate/up/down_proj`, layers 0–55 | NVFP4 (W4A4, group 16, FP8 scales, static activation global scale) |
37
+ | MLP `gate/up/down_proj`, layers 56–63 | FP8 (per-channel weights, dynamic per-token activations) |
38
+ | Full-attention `q/k/v/o_proj`; linear-attention `in_proj_qkv/in_proj_z/out_proj` | FP8 (as above) |
39
+ | Linear-attention `in_proj_a/in_proj_b`, norms, conv, embeddings | BF16 |
40
+ | Vision encoder | BF16 |
41
+ | `lm_head` | BF16 — the joint head reads its rows directly as option embeddings |
42
+ | Joint schema head (`joint_head.safetensors`) | BF16, unchanged from the release |
43
+
44
+ The layout follows the community recipe for Qwen3.8-27B with one change: `lm_head` stays BF16.
45
+ The last eight layers stay FP8 on purpose: comparing the release against
46
+ [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B), the vision encoder and early layers
47
+ are byte-identical, and Clef's post-training lives in the upper layers.
48
+
49
+ **Method:** llm-compressor `QuantizationModifier` (round-to-nearest, no GPTQ), calibrated on 374
50
+ Clef-format records — 128 BANKING77 intent questions (77-way and 10-way schemas), 150 game-agent
51
+ state records with a `choice` question, and 96 Flickr30k photos with `noul`/`choice`/`score`
52
+ questions. Calibration and evaluation records are disjoint. `recipe.yaml` is the exact recipe.
53
+
54
+ ## Drift vs BF16
55
+
56
+ Same 615 records through the BF16 release and through this checkpoint on **vLLM's real NVFP4/FP8
57
+ kernels** (FlashInfer CUTLASS FP4 GEMM). `agreement` = top option identical to BF16. `TV` = mean
58
+ total-variation distance between the per-question distributions (0 = identical, 1 = disjoint).
59
+
60
+ | Eval set | Questions | Agreement | Mean TV | Accuracy BF16 → NVFP4 |
61
+ |---|---:|---:|---:|---|
62
+ | BANKING77 test, full 77-way schema | 400 | 98.5% | 0.019 | 94.25% → 94.50% |
63
+ | Flickr30k photos, 4 mixed-type questions each | 256 | 96.9% | 0.017 | (no labels) |
64
+ | Game-agent states, 2–4 option `choice` | 150 | 96.7% | 0.047 | 68.7% → 67.3% * |
65
+ | README invoice example | 2 | 100% | 0.0007 | — |
66
+
67
+ \* graded against synthetic labels that the BF16 model itself matches only 69% of the time; read the
68
+ agreement column, not the accuracy, for that row.
69
+
70
+ Disagreements are near-ties: in the calibration-time (fake-quant) run, the 15 flipped questions had a
71
+ median BF16 top-1/top-2 margin of 0.13 (11 of 15 under 0.2), against 0.95 for questions that agreed.
72
+
73
+ ## Speed
74
+
75
+ One decision at a time (batch 1, the latency case) on an NVIDIA DGX Spark (GB10, 273 GB/s unified
76
+ memory), vLLM 0.23.1, CUDA graphs on:
77
+
78
+ | Record | Input tokens | Median latency |
79
+ |---|---:|---:|
80
+ | text state, 1 question | 288 | 177 ms |
81
+ | 640 px image + 4 questions | 621 | 257 ms |
82
+ | BANKING77, 77 options | 1834 | 705 ms |
83
+
84
+ The joint head adds 3–6 ms of that. On this machine the floor (~170 ms) is set by reading the
85
+ weights once per pass; GPUs with more memory bandwidth should be considerably quicker (not measured here).
86
+
87
+ ## Usage
88
+
89
+ The files, record format and `systemone` API are the same as the BF16 release; see the
90
+ [Clef model card](https://huggingface.co/Cloudflare/clef) for the full input format.
91
+
92
+ ### vLLM (recommended — real FP4 kernels)
93
+
94
+ `clef_vllm.py` runs the backbone in vLLM as a pooling model (final hidden state of every token)
95
+ and Clef's joint head on top, in the same process. Needs a Blackwell GPU for NVFP4 and a vLLM build
96
+ with `Qwen3_5ForConditionalGeneration` (tested: 0.23.1 nightly).
97
+
98
+ ```python
99
+ import sys
100
+ from huggingface_hub import snapshot_download
101
+
102
+ path = snapshot_download("simonlehmann/clef-NVFP4")
103
+ sys.path.insert(0, path)
104
+ from clef_vllm import ClefVLLM
105
+
106
+ clef = ClefVLLM(path, max_model_len=16384, gpu_memory_utilization=0.4)
107
+ response = clef.systemone({
108
+ "model": "clef",
109
+ "state": "Our checkout started returning errors and orders are blocked.",
110
+ "questions": {
111
+ "department": {
112
+ "type": "choice",
113
+ "instructions": "Which team should handle the message?",
114
+ "criteria": {"billing": "Payments or invoices", "technical": "Bugs or outages"},
115
+ },
116
+ "urgency": {"type": "score", "criteria": ["Can wait", "This week", "Today"]},
117
+ "outage": {"type": "noul", "instructions": "Is a service down?"},
118
+ },
119
+ })
120
+ print(response["answers"])
121
+
122
+ # Many records at once, images included (PIL), batched through vLLM:
123
+ # clef.probabilities([record, ...]) -> [{question_id: {option_id: probability}}, ...]
124
+ ```
125
+
126
+ `max_images` / `max_videos` in the constructor set vLLM's per-request media limits (default 1 image).
127
+
128
+ ### transformers (compatibility — decompresses to BF16)
129
+
130
+ transformers' compressed-tensors integration cannot run the mixed NVFP4/FP8 layers compressed, so
131
+ load with `run_compressed=False`. This decompresses to BF16 at load time (~57 GB of GPU memory, no
132
+ speed-up): useful to check outputs, not to save memory.
133
+
134
+ ```python
135
+ import sys
136
+ from huggingface_hub import snapshot_download
137
+ from transformers import CompressedTensorsConfig
138
+
139
+ path = snapshot_download("simonlehmann/clef-NVFP4")
140
+ sys.path.insert(0, path)
141
+ from joint_schema_model import load_release_model, systemone
142
+
143
+ model, processor = load_release_model(
144
+ path, device="cuda", quantization_config=CompressedTensorsConfig(run_compressed=False)
145
+ )
146
+ ```
147
+
148
+ Requires `compressed-tensors` in addition to `torch` and `transformers`.
149
+
150
+ ## License
151
+
152
+ Apache-2.0, following [Cloudflare/clef](https://huggingface.co/Cloudflare/clef) and
153
+ [Qwen/Qwen3.8-27B](https://huggingface.co/Qwen/Qwen3.8-27B). `joint_schema_model.py`,
154
+ `joint_head.safetensors`, `LICENSE` and the tokenizer/processor files are redistributed unchanged
155
+ from the Cloudflare release; `clef_vllm.py` and the quantized weights are new.
chat_template.jinja ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {%- set reasoning_instructions = '' %}
46
+ {%- if enable_thinking is undefined or enable_thinking is true %}
47
+ {%- set resolved_reasoning_effort = reasoning_effort|default('xhigh') %}
48
+ {%- if resolved_reasoning_effort not in ('xhigh', 'medium', 'low') %}
49
+ {{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported types are xhigh (default), medium, and low.') }}
50
+ {%- endif %}
51
+ {%- if resolved_reasoning_effort == 'xhigh' %}
52
+ {%- set reasoning_instructions = 'Reasoning effort is set to xhigh. Please think carefully through the task, validate key assumptions, consider plausible alternatives, and prioritize correctness, consistency, and clarity in the final answer.' %}
53
+ {%- elif resolved_reasoning_effort == 'low' %}
54
+ {%- set reasoning_instructions = 'Reasoning effort is set to low. Keep your thinking brief and focused, moving directly to the conclusion without unnecessary elaboration.' %}
55
+ {%- endif %}
56
+ {%- endif %}
57
+ {%- if tools and tools is iterable and tools is not mapping %}
58
+ {{- '<|im_start|>system\n' }}
59
+ {%- if reasoning_instructions %}
60
+ {{- reasoning_instructions + '\n\n' }}
61
+ {%- endif %}
62
+ {{- "# Tools\n\nYou have access to the following functions:\n\n<tools>" }}
63
+ {%- for tool in tools %}
64
+ {{- "\n" }}
65
+ {{- tool | tojson }}
66
+ {%- endfor %}
67
+ {{- "\n</tools>" }}
68
+ {{- '\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>' }}
69
+ {%- if messages[0].role == 'system' %}
70
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
71
+ {%- if content %}
72
+ {{- '\n\n' + content }}
73
+ {%- endif %}
74
+ {%- endif %}
75
+ {{- '<|im_end|>\n' }}
76
+ {%- else %}
77
+ {%- if messages[0].role == 'system' %}
78
+ {%- set content = render_content(messages[0].content, false, true)|trim %}
79
+ {%- if content %}
80
+ {{- '<|im_start|>system\n' + (reasoning_instructions + '\n\n' if reasoning_instructions else '') + content + '<|im_end|>\n' }}
81
+ {%- elif reasoning_instructions %}
82
+ {{- '<|im_start|>system\n' + reasoning_instructions + '<|im_end|>\n' }}
83
+ {%- endif %}
84
+ {%- elif reasoning_instructions %}
85
+ {{- '<|im_start|>system\n' + reasoning_instructions + '<|im_end|>\n' }}
86
+ {%- endif %}
87
+ {%- endif %}
88
+ {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
89
+ {%- for message in messages[::-1] %}
90
+ {%- set index = (messages|length - 1) - loop.index0 %}
91
+ {%- if ns.multi_step_tool and message.role == "user" %}
92
+ {%- set content = render_content(message.content, false)|trim %}
93
+ {%- if not(content.startswith('<tool_response>') and content.endswith('</tool_response>')) %}
94
+ {%- set ns.multi_step_tool = false %}
95
+ {%- set ns.last_query_index = index %}
96
+ {%- endif %}
97
+ {%- endif %}
98
+ {%- endfor %}
99
+ {%- if ns.multi_step_tool %}
100
+ {{- raise_exception('No user query found in messages.') }}
101
+ {%- endif %}
102
+ {%- for message in messages %}
103
+ {%- set content = render_content(message.content, true)|trim %}
104
+ {%- if message.role == "system" %}
105
+ {%- if not loop.first %}
106
+ {{- raise_exception('System message must be at the beginning.') }}
107
+ {%- endif %}
108
+ {%- elif message.role == "user" %}
109
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
110
+ {%- elif message.role == "assistant" %}
111
+ {%- set reasoning_content = '' %}
112
+ {%- if message.reasoning_content is string %}
113
+ {%- set reasoning_content = message.reasoning_content %}
114
+ {%- endif %}
115
+ {%- set reasoning_content = reasoning_content|trim %}
116
+ {%- if preserve_thinking is undefined or preserve_thinking is true or loop.index0 > ns.last_query_index %}
117
+ {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
118
+ {%- else %}
119
+ {{- '<|im_start|>' + message.role + '\n' + content }}
120
+ {%- endif %}
121
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
122
+ {%- for tool_call in message.tool_calls %}
123
+ {%- if tool_call.function is defined %}
124
+ {%- set tool_call = tool_call.function %}
125
+ {%- endif %}
126
+ {%- if loop.first %}
127
+ {%- if content|trim %}
128
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
129
+ {%- else %}
130
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
131
+ {%- endif %}
132
+ {%- else %}
133
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
134
+ {%- endif %}
135
+ {%- if tool_call.arguments is defined and tool_call.arguments != '' %}
136
+ {%- for args_name, args_value in tool_call.arguments|items %}
137
+ {{- '<parameter=' + args_name + '>\n' }}
138
+ {%- set args_value = args_value | string if args_value is string else args_value | tojson | safe %}
139
+ {{- args_value }}
140
+ {{- '\n</parameter>\n' }}
141
+ {%- endfor %}
142
+ {%- endif %}
143
+ {{- '</function>\n</tool_call>' }}
144
+ {%- endfor %}
145
+ {%- endif %}
146
+ {{- '<|im_end|>\n' }}
147
+ {%- elif message.role == "tool" %}
148
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
149
+ {{- '<|im_start|>user' }}
150
+ {%- endif %}
151
+ {{- '\n<tool_response>\n' }}
152
+ {{- content }}
153
+ {{- '\n</tool_response>' }}
154
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
155
+ {{- '<|im_end|>\n' }}
156
+ {%- elif loop.last %}
157
+ {{- '<|im_end|>\n' }}
158
+ {%- endif %}
159
+ {%- else %}
160
+ {{- raise_exception('Unexpected message role.') }}
161
+ {%- endif %}
162
+ {%- endfor %}
163
+ {%- if add_generation_prompt %}
164
+ {{- '<|im_start|>assistant\n' }}
165
+ {%- if enable_thinking is defined and enable_thinking is false %}
166
+ {{- '<think>\n\n</think>\n\n' }}
167
+ {%- else %}
168
+ {{- '<think>\n' }}
169
+ {%- endif %}
170
+ {%- endif %}
clef_vllm.py ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Run Clef-NVFP4 on vLLM: the backbone as a pooling model (final hidden state of every
2
+ token, on NVFP4/FP8 kernels), Clef's joint schema head on top in the same process.
3
+
4
+ from clef_vllm import ClefVLLM
5
+ clef = ClefVLLM("path/to/clef-NVFP4")
6
+ clef.systemone({"model": "clef", "state": "...", "questions": {...}})
7
+
8
+ Tested with vLLM 0.23.1 (nightly, CUDA 13, aarch64 / Blackwell sm_121).
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import json
13
+ import os
14
+ import sys
15
+ from pathlib import Path
16
+ from typing import Any
17
+
18
+ # The engine runs in this process: no __main__ guard needed, no IPC per decision.
19
+ os.environ.setdefault("VLLM_ENABLE_V1_MULTIPROCESSING", "0")
20
+
21
+ import torch # noqa: E402
22
+ from safetensors import safe_open # noqa: E402
23
+ from safetensors.torch import load_file # noqa: E402
24
+
25
+ sys.path.insert(0, str(Path(__file__).resolve().parent))
26
+ from joint_schema_model import ( # noqa: E402
27
+ QUESTION_TYPES,
28
+ JointSchemaHead,
29
+ collate_records,
30
+ encode_record,
31
+ systemone_answer,
32
+ )
33
+
34
+
35
+ class ClefVLLM:
36
+ def __init__(self, path: str | Path, max_model_len: int = 16384, gpu_memory_utilization: float = 0.4,
37
+ max_images: int = 1, max_videos: int = 0, **llm_kwargs: Any) -> None:
38
+ from transformers import AutoProcessor
39
+ from vllm import LLM
40
+ from vllm.config import PoolerConfig
41
+
42
+ path = Path(path)
43
+ self.processor = AutoProcessor.from_pretrained(path)
44
+ self.tokenizer = self.processor.tokenizer
45
+ self.media_pads = {self.tokenizer.convert_tokens_to_ids(t) for t in ("<|image_pad|>", "<|video_pad|>")}
46
+ self.llm = LLM(
47
+ model=str(path),
48
+ runner="pooling",
49
+ pooler_config=PoolerConfig(task="token_embed", tok_pooling_type="ALL", use_activation=False),
50
+ max_model_len=max_model_len,
51
+ gpu_memory_utilization=gpu_memory_utilization,
52
+ limit_mm_per_prompt={"image": max_images, "video": max_videos},
53
+ enable_prefix_caching=False,
54
+ **llm_kwargs,
55
+ )
56
+ self.device = torch.device("cuda")
57
+ head = JointSchemaHead(**json.loads((path / "joint_head_config.json").read_text()))
58
+ head.load_state_dict(load_file(path / "joint_head.safetensors"), strict=True)
59
+ self.head = head.to(self.device, torch.bfloat16).eval()
60
+ # The head reads lm_head rows as option embeddings; vLLM's pooling model drops lm_head.
61
+ weight_map = json.loads((path / "model.safetensors.index.json").read_text())["weight_map"]
62
+ with safe_open(str(path / weight_map["lm_head.weight"]), framework="pt", device="cuda") as f:
63
+ self.lm_head = f.get_tensor("lm_head.weight").to(torch.bfloat16)
64
+
65
+ def _prompt(self, record: dict[str, Any], input_ids: tuple[int, ...]) -> dict[str, Any]:
66
+ # Collapse each expanded image/video pad run to one token; vLLM re-expands it from the
67
+ # media, so the returned hidden states line up with Clef's input_ids position for position.
68
+ ids: list[int] = []
69
+ for i, token in enumerate(input_ids):
70
+ if token in self.media_pads and i and input_ids[i - 1] == token:
71
+ continue
72
+ ids.append(token)
73
+ prompt: dict[str, Any] = {"prompt_token_ids": ids}
74
+ media = {}
75
+ if record.get("images"):
76
+ media["image"] = record["images"] if len(record["images"]) > 1 else record["images"][0]
77
+ if record.get("videos"):
78
+ media["video"] = record["videos"] if len(record["videos"]) > 1 else record["videos"][0]
79
+ if media:
80
+ prompt["multi_modal_data"] = media
81
+ return prompt
82
+
83
+ @torch.inference_mode()
84
+ def probabilities(self, records: list[dict[str, Any]], max_length: int = 16384) -> list[dict[str, dict[str, float]]]:
85
+ """Per record, per question: {option_id: probability}. Records are batched through vLLM."""
86
+ encoded = [encode_record(self.tokenizer, r, max_length=max_length, processor=self.processor) for r in records]
87
+ outputs = self.llm.encode([self._prompt(r, e.input_ids) for r, e in zip(records, encoded)],
88
+ pooling_task="token_embed", use_tqdm=False)
89
+ results = []
90
+ for enc, out in zip(encoded, outputs):
91
+ hidden = out.outputs.data.to(self.device, torch.bfloat16)
92
+ if hidden.shape[0] != len(enc.input_ids):
93
+ raise RuntimeError(f"vLLM returned {hidden.shape[0]} positions for {len(enc.input_ids)} input tokens")
94
+ batch = collate_records([enc], self.tokenizer.pad_token_id, self.device)
95
+ logits = self.head(hidden.unsqueeze(0), batch["input_ids"], batch["attention_mask"],
96
+ batch["records"], self.lm_head)[0]
97
+ results.append({
98
+ q.question_id: dict(zip(q.option_ids, l.float().softmax(-1).tolist()))
99
+ for q, l in zip(enc.questions, logits)
100
+ })
101
+ return results
102
+
103
+ def systemone(self, request: dict[str, Any], max_length: int = 16384) -> dict[str, Any]:
104
+ """Same request/response body as joint_schema_model.systemone (Jev/SystemOne /v1/systemone)."""
105
+ questions = request.get("questions")
106
+ if not isinstance(request.get("model"), str) or "state" not in request:
107
+ raise ValueError("model and state are required")
108
+ if not isinstance(questions, dict) or not questions:
109
+ raise ValueError("at least one question is required")
110
+ for question_id, question in questions.items():
111
+ if question.get("type") not in QUESTION_TYPES:
112
+ raise ValueError(f"{question_id}: type must be noul, choice, or score")
113
+ if question["type"] != "noul" and not question.get("criteria"):
114
+ raise ValueError(f"{question_id}: criteria must not be empty")
115
+ probs = self.probabilities([request], max_length=max_length)[0]
116
+ encoded_len = len(encode_record(self.tokenizer, request, max_length=max_length, processor=self.processor).input_ids)
117
+ return {
118
+ "model": request["model"],
119
+ "answers": {qid: systemone_answer(questions[qid], p) for qid, p in probs.items()},
120
+ "usage": {"input_tokens": encoded_len, "output_tokens": 0},
121
+ }
config.json ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "dtype": "bfloat16",
6
+ "image_token_id": 248056,
7
+ "language_model_only": false,
8
+ "model_type": "qwen3_5",
9
+ "quantization_config": {
10
+ "config_groups": {
11
+ "group_0": {
12
+ "format": "float-quantized",
13
+ "input_activations": {
14
+ "actorder": null,
15
+ "block_structure": null,
16
+ "dynamic": true,
17
+ "group_size": null,
18
+ "num_bits": 8,
19
+ "observer": null,
20
+ "observer_kwargs": {},
21
+ "scale_dtype": null,
22
+ "strategy": "token",
23
+ "symmetric": true,
24
+ "type": "float",
25
+ "zp_dtype": null
26
+ },
27
+ "output_activations": null,
28
+ "targets": [
29
+ "re:.*self_attn\\.(q|k|v|o)_proj$",
30
+ "re:.*linear_attn\\.(in_proj_qkv|in_proj_z|out_proj)$",
31
+ "re:.*layers\\.(56|57|58|59|60|61|62|63)\\.mlp\\.(gate|up|down)_proj$"
32
+ ],
33
+ "weights": {
34
+ "actorder": null,
35
+ "block_structure": null,
36
+ "dynamic": false,
37
+ "group_size": null,
38
+ "num_bits": 8,
39
+ "observer": "memoryless_minmax",
40
+ "observer_kwargs": {},
41
+ "scale_dtype": null,
42
+ "strategy": "channel",
43
+ "symmetric": true,
44
+ "type": "float",
45
+ "zp_dtype": null
46
+ }
47
+ },
48
+ "group_1": {
49
+ "format": "nvfp4-pack-quantized",
50
+ "input_activations": {
51
+ "actorder": null,
52
+ "block_structure": null,
53
+ "dynamic": "local",
54
+ "group_size": 16,
55
+ "num_bits": 4,
56
+ "observer": "static_minmax",
57
+ "observer_kwargs": {},
58
+ "scale_dtype": "torch.float8_e4m3fn",
59
+ "strategy": "tensor_group",
60
+ "symmetric": true,
61
+ "type": "float",
62
+ "zp_dtype": null
63
+ },
64
+ "output_activations": null,
65
+ "targets": [
66
+ "re:.*layers\\.([0-9]|[1-4][0-9]|5[0-5])\\.mlp\\.(gate|up|down)_proj$"
67
+ ],
68
+ "weights": {
69
+ "actorder": null,
70
+ "block_structure": null,
71
+ "dynamic": false,
72
+ "group_size": 16,
73
+ "num_bits": 4,
74
+ "observer": "memoryless_minmax",
75
+ "observer_kwargs": {},
76
+ "scale_dtype": "torch.float8_e4m3fn",
77
+ "strategy": "tensor_group",
78
+ "symmetric": true,
79
+ "type": "float",
80
+ "zp_dtype": null
81
+ }
82
+ }
83
+ },
84
+ "format": "mixed-precision",
85
+ "global_compression_ratio": null,
86
+ "ignore": [
87
+ "model.visual.blocks.0.attn.qkv",
88
+ "model.visual.blocks.0.attn.proj",
89
+ "model.visual.blocks.0.mlp.linear_fc1",
90
+ "model.visual.blocks.0.mlp.linear_fc2",
91
+ "model.visual.blocks.1.attn.qkv",
92
+ "model.visual.blocks.1.attn.proj",
93
+ "model.visual.blocks.1.mlp.linear_fc1",
94
+ "model.visual.blocks.1.mlp.linear_fc2",
95
+ "model.visual.blocks.2.attn.qkv",
96
+ "model.visual.blocks.2.attn.proj",
97
+ "model.visual.blocks.2.mlp.linear_fc1",
98
+ "model.visual.blocks.2.mlp.linear_fc2",
99
+ "model.visual.blocks.3.attn.qkv",
100
+ "model.visual.blocks.3.attn.proj",
101
+ "model.visual.blocks.3.mlp.linear_fc1",
102
+ "model.visual.blocks.3.mlp.linear_fc2",
103
+ "model.visual.blocks.4.attn.qkv",
104
+ "model.visual.blocks.4.attn.proj",
105
+ "model.visual.blocks.4.mlp.linear_fc1",
106
+ "model.visual.blocks.4.mlp.linear_fc2",
107
+ "model.visual.blocks.5.attn.qkv",
108
+ "model.visual.blocks.5.attn.proj",
109
+ "model.visual.blocks.5.mlp.linear_fc1",
110
+ "model.visual.blocks.5.mlp.linear_fc2",
111
+ "model.visual.blocks.6.attn.qkv",
112
+ "model.visual.blocks.6.attn.proj",
113
+ "model.visual.blocks.6.mlp.linear_fc1",
114
+ "model.visual.blocks.6.mlp.linear_fc2",
115
+ "model.visual.blocks.7.attn.qkv",
116
+ "model.visual.blocks.7.attn.proj",
117
+ "model.visual.blocks.7.mlp.linear_fc1",
118
+ "model.visual.blocks.7.mlp.linear_fc2",
119
+ "model.visual.blocks.8.attn.qkv",
120
+ "model.visual.blocks.8.attn.proj",
121
+ "model.visual.blocks.8.mlp.linear_fc1",
122
+ "model.visual.blocks.8.mlp.linear_fc2",
123
+ "model.visual.blocks.9.attn.qkv",
124
+ "model.visual.blocks.9.attn.proj",
125
+ "model.visual.blocks.9.mlp.linear_fc1",
126
+ "model.visual.blocks.9.mlp.linear_fc2",
127
+ "model.visual.blocks.10.attn.qkv",
128
+ "model.visual.blocks.10.attn.proj",
129
+ "model.visual.blocks.10.mlp.linear_fc1",
130
+ "model.visual.blocks.10.mlp.linear_fc2",
131
+ "model.visual.blocks.11.attn.qkv",
132
+ "model.visual.blocks.11.attn.proj",
133
+ "model.visual.blocks.11.mlp.linear_fc1",
134
+ "model.visual.blocks.11.mlp.linear_fc2",
135
+ "model.visual.blocks.12.attn.qkv",
136
+ "model.visual.blocks.12.attn.proj",
137
+ "model.visual.blocks.12.mlp.linear_fc1",
138
+ "model.visual.blocks.12.mlp.linear_fc2",
139
+ "model.visual.blocks.13.attn.qkv",
140
+ "model.visual.blocks.13.attn.proj",
141
+ "model.visual.blocks.13.mlp.linear_fc1",
142
+ "model.visual.blocks.13.mlp.linear_fc2",
143
+ "model.visual.blocks.14.attn.qkv",
144
+ "model.visual.blocks.14.attn.proj",
145
+ "model.visual.blocks.14.mlp.linear_fc1",
146
+ "model.visual.blocks.14.mlp.linear_fc2",
147
+ "model.visual.blocks.15.attn.qkv",
148
+ "model.visual.blocks.15.attn.proj",
149
+ "model.visual.blocks.15.mlp.linear_fc1",
150
+ "model.visual.blocks.15.mlp.linear_fc2",
151
+ "model.visual.blocks.16.attn.qkv",
152
+ "model.visual.blocks.16.attn.proj",
153
+ "model.visual.blocks.16.mlp.linear_fc1",
154
+ "model.visual.blocks.16.mlp.linear_fc2",
155
+ "model.visual.blocks.17.attn.qkv",
156
+ "model.visual.blocks.17.attn.proj",
157
+ "model.visual.blocks.17.mlp.linear_fc1",
158
+ "model.visual.blocks.17.mlp.linear_fc2",
159
+ "model.visual.blocks.18.attn.qkv",
160
+ "model.visual.blocks.18.attn.proj",
161
+ "model.visual.blocks.18.mlp.linear_fc1",
162
+ "model.visual.blocks.18.mlp.linear_fc2",
163
+ "model.visual.blocks.19.attn.qkv",
164
+ "model.visual.blocks.19.attn.proj",
165
+ "model.visual.blocks.19.mlp.linear_fc1",
166
+ "model.visual.blocks.19.mlp.linear_fc2",
167
+ "model.visual.blocks.20.attn.qkv",
168
+ "model.visual.blocks.20.attn.proj",
169
+ "model.visual.blocks.20.mlp.linear_fc1",
170
+ "model.visual.blocks.20.mlp.linear_fc2",
171
+ "model.visual.blocks.21.attn.qkv",
172
+ "model.visual.blocks.21.attn.proj",
173
+ "model.visual.blocks.21.mlp.linear_fc1",
174
+ "model.visual.blocks.21.mlp.linear_fc2",
175
+ "model.visual.blocks.22.attn.qkv",
176
+ "model.visual.blocks.22.attn.proj",
177
+ "model.visual.blocks.22.mlp.linear_fc1",
178
+ "model.visual.blocks.22.mlp.linear_fc2",
179
+ "model.visual.blocks.23.attn.qkv",
180
+ "model.visual.blocks.23.attn.proj",
181
+ "model.visual.blocks.23.mlp.linear_fc1",
182
+ "model.visual.blocks.23.mlp.linear_fc2",
183
+ "model.visual.blocks.24.attn.qkv",
184
+ "model.visual.blocks.24.attn.proj",
185
+ "model.visual.blocks.24.mlp.linear_fc1",
186
+ "model.visual.blocks.24.mlp.linear_fc2",
187
+ "model.visual.blocks.25.attn.qkv",
188
+ "model.visual.blocks.25.attn.proj",
189
+ "model.visual.blocks.25.mlp.linear_fc1",
190
+ "model.visual.blocks.25.mlp.linear_fc2",
191
+ "model.visual.blocks.26.attn.qkv",
192
+ "model.visual.blocks.26.attn.proj",
193
+ "model.visual.blocks.26.mlp.linear_fc1",
194
+ "model.visual.blocks.26.mlp.linear_fc2",
195
+ "model.visual.merger.linear_fc1",
196
+ "model.visual.merger.linear_fc2",
197
+ "model.language_model.layers.0.linear_attn.in_proj_b",
198
+ "model.language_model.layers.0.linear_attn.in_proj_a",
199
+ "model.language_model.layers.1.linear_attn.in_proj_b",
200
+ "model.language_model.layers.1.linear_attn.in_proj_a",
201
+ "model.language_model.layers.2.linear_attn.in_proj_b",
202
+ "model.language_model.layers.2.linear_attn.in_proj_a",
203
+ "model.language_model.layers.4.linear_attn.in_proj_b",
204
+ "model.language_model.layers.4.linear_attn.in_proj_a",
205
+ "model.language_model.layers.5.linear_attn.in_proj_b",
206
+ "model.language_model.layers.5.linear_attn.in_proj_a",
207
+ "model.language_model.layers.6.linear_attn.in_proj_b",
208
+ "model.language_model.layers.6.linear_attn.in_proj_a",
209
+ "model.language_model.layers.8.linear_attn.in_proj_b",
210
+ "model.language_model.layers.8.linear_attn.in_proj_a",
211
+ "model.language_model.layers.9.linear_attn.in_proj_b",
212
+ "model.language_model.layers.9.linear_attn.in_proj_a",
213
+ "model.language_model.layers.10.linear_attn.in_proj_b",
214
+ "model.language_model.layers.10.linear_attn.in_proj_a",
215
+ "model.language_model.layers.12.linear_attn.in_proj_b",
216
+ "model.language_model.layers.12.linear_attn.in_proj_a",
217
+ "model.language_model.layers.13.linear_attn.in_proj_b",
218
+ "model.language_model.layers.13.linear_attn.in_proj_a",
219
+ "model.language_model.layers.14.linear_attn.in_proj_b",
220
+ "model.language_model.layers.14.linear_attn.in_proj_a",
221
+ "model.language_model.layers.16.linear_attn.in_proj_b",
222
+ "model.language_model.layers.16.linear_attn.in_proj_a",
223
+ "model.language_model.layers.17.linear_attn.in_proj_b",
224
+ "model.language_model.layers.17.linear_attn.in_proj_a",
225
+ "model.language_model.layers.18.linear_attn.in_proj_b",
226
+ "model.language_model.layers.18.linear_attn.in_proj_a",
227
+ "model.language_model.layers.20.linear_attn.in_proj_b",
228
+ "model.language_model.layers.20.linear_attn.in_proj_a",
229
+ "model.language_model.layers.21.linear_attn.in_proj_b",
230
+ "model.language_model.layers.21.linear_attn.in_proj_a",
231
+ "model.language_model.layers.22.linear_attn.in_proj_b",
232
+ "model.language_model.layers.22.linear_attn.in_proj_a",
233
+ "model.language_model.layers.24.linear_attn.in_proj_b",
234
+ "model.language_model.layers.24.linear_attn.in_proj_a",
235
+ "model.language_model.layers.25.linear_attn.in_proj_b",
236
+ "model.language_model.layers.25.linear_attn.in_proj_a",
237
+ "model.language_model.layers.26.linear_attn.in_proj_b",
238
+ "model.language_model.layers.26.linear_attn.in_proj_a",
239
+ "model.language_model.layers.28.linear_attn.in_proj_b",
240
+ "model.language_model.layers.28.linear_attn.in_proj_a",
241
+ "model.language_model.layers.29.linear_attn.in_proj_b",
242
+ "model.language_model.layers.29.linear_attn.in_proj_a",
243
+ "model.language_model.layers.30.linear_attn.in_proj_b",
244
+ "model.language_model.layers.30.linear_attn.in_proj_a",
245
+ "model.language_model.layers.32.linear_attn.in_proj_b",
246
+ "model.language_model.layers.32.linear_attn.in_proj_a",
247
+ "model.language_model.layers.33.linear_attn.in_proj_b",
248
+ "model.language_model.layers.33.linear_attn.in_proj_a",
249
+ "model.language_model.layers.34.linear_attn.in_proj_b",
250
+ "model.language_model.layers.34.linear_attn.in_proj_a",
251
+ "model.language_model.layers.36.linear_attn.in_proj_b",
252
+ "model.language_model.layers.36.linear_attn.in_proj_a",
253
+ "model.language_model.layers.37.linear_attn.in_proj_b",
254
+ "model.language_model.layers.37.linear_attn.in_proj_a",
255
+ "model.language_model.layers.38.linear_attn.in_proj_b",
256
+ "model.language_model.layers.38.linear_attn.in_proj_a",
257
+ "model.language_model.layers.40.linear_attn.in_proj_b",
258
+ "model.language_model.layers.40.linear_attn.in_proj_a",
259
+ "model.language_model.layers.41.linear_attn.in_proj_b",
260
+ "model.language_model.layers.41.linear_attn.in_proj_a",
261
+ "model.language_model.layers.42.linear_attn.in_proj_b",
262
+ "model.language_model.layers.42.linear_attn.in_proj_a",
263
+ "model.language_model.layers.44.linear_attn.in_proj_b",
264
+ "model.language_model.layers.44.linear_attn.in_proj_a",
265
+ "model.language_model.layers.45.linear_attn.in_proj_b",
266
+ "model.language_model.layers.45.linear_attn.in_proj_a",
267
+ "model.language_model.layers.46.linear_attn.in_proj_b",
268
+ "model.language_model.layers.46.linear_attn.in_proj_a",
269
+ "model.language_model.layers.48.linear_attn.in_proj_b",
270
+ "model.language_model.layers.48.linear_attn.in_proj_a",
271
+ "model.language_model.layers.49.linear_attn.in_proj_b",
272
+ "model.language_model.layers.49.linear_attn.in_proj_a",
273
+ "model.language_model.layers.50.linear_attn.in_proj_b",
274
+ "model.language_model.layers.50.linear_attn.in_proj_a",
275
+ "model.language_model.layers.52.linear_attn.in_proj_b",
276
+ "model.language_model.layers.52.linear_attn.in_proj_a",
277
+ "model.language_model.layers.53.linear_attn.in_proj_b",
278
+ "model.language_model.layers.53.linear_attn.in_proj_a",
279
+ "model.language_model.layers.54.linear_attn.in_proj_b",
280
+ "model.language_model.layers.54.linear_attn.in_proj_a",
281
+ "model.language_model.layers.56.linear_attn.in_proj_b",
282
+ "model.language_model.layers.56.linear_attn.in_proj_a",
283
+ "model.language_model.layers.57.linear_attn.in_proj_b",
284
+ "model.language_model.layers.57.linear_attn.in_proj_a",
285
+ "model.language_model.layers.58.linear_attn.in_proj_b",
286
+ "model.language_model.layers.58.linear_attn.in_proj_a",
287
+ "model.language_model.layers.60.linear_attn.in_proj_b",
288
+ "model.language_model.layers.60.linear_attn.in_proj_a",
289
+ "model.language_model.layers.61.linear_attn.in_proj_b",
290
+ "model.language_model.layers.61.linear_attn.in_proj_a",
291
+ "model.language_model.layers.62.linear_attn.in_proj_b",
292
+ "model.language_model.layers.62.linear_attn.in_proj_a",
293
+ "lm_head"
294
+ ],
295
+ "kv_cache_scheme": null,
296
+ "quant_method": "compressed-tensors",
297
+ "quantization_status": "compressed",
298
+ "sparsity_config": {},
299
+ "transform_config": {},
300
+ "version": "0.19.0"
301
+ },
302
+ "text_config": {
303
+ "attention_bias": false,
304
+ "attention_dropout": 0.0,
305
+ "attn_output_gate": true,
306
+ "bos_token_id": 248044,
307
+ "dtype": "bfloat16",
308
+ "eos_token_id": 248044,
309
+ "full_attention_interval": 4,
310
+ "head_dim": 256,
311
+ "hidden_act": "silu",
312
+ "hidden_size": 5120,
313
+ "initializer_range": 0.02,
314
+ "intermediate_size": 17408,
315
+ "layer_types": [
316
+ "linear_attention",
317
+ "linear_attention",
318
+ "linear_attention",
319
+ "full_attention",
320
+ "linear_attention",
321
+ "linear_attention",
322
+ "linear_attention",
323
+ "full_attention",
324
+ "linear_attention",
325
+ "linear_attention",
326
+ "linear_attention",
327
+ "full_attention",
328
+ "linear_attention",
329
+ "linear_attention",
330
+ "linear_attention",
331
+ "full_attention",
332
+ "linear_attention",
333
+ "linear_attention",
334
+ "linear_attention",
335
+ "full_attention",
336
+ "linear_attention",
337
+ "linear_attention",
338
+ "linear_attention",
339
+ "full_attention",
340
+ "linear_attention",
341
+ "linear_attention",
342
+ "linear_attention",
343
+ "full_attention",
344
+ "linear_attention",
345
+ "linear_attention",
346
+ "linear_attention",
347
+ "full_attention",
348
+ "linear_attention",
349
+ "linear_attention",
350
+ "linear_attention",
351
+ "full_attention",
352
+ "linear_attention",
353
+ "linear_attention",
354
+ "linear_attention",
355
+ "full_attention",
356
+ "linear_attention",
357
+ "linear_attention",
358
+ "linear_attention",
359
+ "full_attention",
360
+ "linear_attention",
361
+ "linear_attention",
362
+ "linear_attention",
363
+ "full_attention",
364
+ "linear_attention",
365
+ "linear_attention",
366
+ "linear_attention",
367
+ "full_attention",
368
+ "linear_attention",
369
+ "linear_attention",
370
+ "linear_attention",
371
+ "full_attention",
372
+ "linear_attention",
373
+ "linear_attention",
374
+ "linear_attention",
375
+ "full_attention",
376
+ "linear_attention",
377
+ "linear_attention",
378
+ "linear_attention",
379
+ "full_attention"
380
+ ],
381
+ "linear_conv_kernel_dim": 4,
382
+ "linear_key_head_dim": 128,
383
+ "linear_num_key_heads": 16,
384
+ "linear_num_value_heads": 48,
385
+ "linear_value_head_dim": 128,
386
+ "mamba_ssm_dtype": "float32",
387
+ "max_position_embeddings": 262144,
388
+ "model_type": "qwen3_5_text",
389
+ "mtp_num_hidden_layers": 0,
390
+ "mtp_use_dedicated_embeddings": false,
391
+ "num_attention_heads": 24,
392
+ "num_hidden_layers": 64,
393
+ "num_key_value_heads": 4,
394
+ "output_gate_type": "swish",
395
+ "pad_token_id": null,
396
+ "partial_rotary_factor": 0.25,
397
+ "rms_norm_eps": 1e-06,
398
+ "rope_parameters": {
399
+ "mrope_interleaved": true,
400
+ "mrope_section": [
401
+ 11,
402
+ 11,
403
+ 10
404
+ ],
405
+ "partial_rotary_factor": 0.25,
406
+ "rope_theta": 10000000,
407
+ "rope_type": "default"
408
+ },
409
+ "tie_word_embeddings": false,
410
+ "use_cache": true,
411
+ "vocab_size": 248320
412
+ },
413
+ "tie_word_embeddings": false,
414
+ "transformers_version": "5.10.2",
415
+ "video_token_id": 248057,
416
+ "vision_config": {
417
+ "deepstack_visual_indexes": [],
418
+ "depth": 27,
419
+ "dtype": "bfloat16",
420
+ "hidden_act": "gelu_pytorch_tanh",
421
+ "hidden_size": 1152,
422
+ "in_channels": 3,
423
+ "initializer_range": 0.02,
424
+ "intermediate_size": 4304,
425
+ "model_type": "qwen3_5_vision",
426
+ "num_heads": 16,
427
+ "num_position_embeddings": 2304,
428
+ "out_hidden_size": 5120,
429
+ "patch_size": 16,
430
+ "spatial_merge_size": 2,
431
+ "temporal_patch_size": 2
432
+ },
433
+ "vision_end_token_id": 248054,
434
+ "vision_start_token_id": 248053
435
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 248044,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 248046,
6
+ 248044
7
+ ],
8
+ "pad_token_id": 248044,
9
+ "temperature": 1.0,
10
+ "top_k": 20,
11
+ "top_p": 0.95,
12
+ "transformers_version": "5.10.2"
13
+ }
joint_head.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a010ac04f078e699988e4049cbea5e62c962393f59fec366640b64e8d69a4953
3
+ size 256125024
joint_head_config.json ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "hidden_size": 5120,
3
+ "width": 1024,
4
+ "routing_layers": 2,
5
+ "layers": 4,
6
+ "heads": 16,
7
+ "feedforward": 4096
8
+ }
joint_schema_model.py ADDED
@@ -0,0 +1,576 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Clef: a multimodal Qwen backbone with a joint schema head for typed decisions.
2
+
3
+ A record provides a ``state`` (any JSON value), optional ``images`` and ``videos``,
4
+ and ``questions``. Each question has a ``type`` (``noul``, ``choice``, or ``score``),
5
+ ``instructions``, and, for ``choice`` and ``score``, ``criteria`` describing the
6
+ allowed options. The model returns one logit per allowed option for every question.
7
+ ``systemone`` answers a Jev/SystemOne ``/v1/systemone`` request body with the same
8
+ response body.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import json
14
+ import math
15
+ from dataclasses import dataclass
16
+ from dataclasses import field as dataclass_field
17
+ from pathlib import Path
18
+ from typing import Any
19
+
20
+ import torch
21
+ import torch.nn.functional as functional
22
+
23
+
24
+ SYSTEM_PROMPT = (
25
+ "Read the complete state and schema. Decide every field jointly. Each answer "
26
+ "must be exactly one of that field's allowed options."
27
+ )
28
+ IMAGE_PLACEHOLDER = "<|vision_start|><|image_pad|><|vision_end|>"
29
+ VIDEO_PLACEHOLDER = "<|vision_start|><|video_pad|><|vision_end|>"
30
+ MEDIA_BATCH_KEYS = ("pixel_values", "image_grid_thw", "pixel_values_videos", "video_grid_thw")
31
+ MEDIA_TOKEN_KEYS = ("mm_token_type_ids",)
32
+ QUESTION_TYPES = {"noul": 0, "choice": 1, "score": 2}
33
+
34
+
35
+ def render(value: Any) -> str:
36
+ if isinstance(value, str):
37
+ return value
38
+ return json.dumps(
39
+ value,
40
+ ensure_ascii=False,
41
+ separators=(",", ":"),
42
+ sort_keys=True,
43
+ )
44
+
45
+
46
+ def question_options(question: dict[str, Any]) -> list[tuple[str, Any]]:
47
+ question_type = str(question["type"])
48
+ if question_type == "noul":
49
+ criteria = {
50
+ "true": "The proposition is true or the answer is yes.",
51
+ "false": "The proposition is false or the answer is no.",
52
+ }
53
+ criteria.update(question.get("criteria") or {})
54
+ return [(key, criteria[key]) for key in ("true", "false")]
55
+ if question_type == "choice":
56
+ return sorted((str(key), value) for key, value in question["criteria"].items())
57
+ return [(str(index), value) for index, value in enumerate(question["criteria"])]
58
+
59
+
60
+ @dataclass(frozen=True)
61
+ class EncodedQuestion:
62
+ question_id: str
63
+ question_type: int
64
+ question_span: tuple[int, int]
65
+ option_spans: tuple[tuple[int, int], ...]
66
+ option_ids: tuple[str, ...]
67
+
68
+
69
+ @dataclass(frozen=True)
70
+ class EncodedRecord:
71
+ input_ids: tuple[int, ...]
72
+ questions: tuple[EncodedQuestion, ...]
73
+ record_id: str
74
+ media: dict[str, Any] | None = dataclass_field(default=None, compare=False, repr=False)
75
+
76
+
77
+ def _tokens(tokenizer: Any, text: str) -> list[int]:
78
+ return tokenizer(text, add_special_tokens=False).input_ids
79
+
80
+
81
+ def _encode_media(processor: Any, record: dict[str, Any]) -> tuple[list[int], dict[str, Any] | None]:
82
+ images = list(record.get("images") or [])
83
+ videos = list(record.get("videos") or [])
84
+ if not images and not videos:
85
+ return [], None
86
+ if processor is None:
87
+ raise ValueError("records with images or videos require a processor")
88
+ text = IMAGE_PLACEHOLDER * len(images) + VIDEO_PLACEHOLDER * len(videos) + "\n"
89
+ encoded = processor(
90
+ text=[text],
91
+ images=images or None,
92
+ videos=videos or None,
93
+ return_tensors="pt",
94
+ **(record.get("media_kwargs") or {}),
95
+ )
96
+ media = {key: encoded[key] for key in MEDIA_BATCH_KEYS if key in encoded}
97
+ for key in MEDIA_TOKEN_KEYS:
98
+ if key in encoded:
99
+ media[key] = encoded[key][0].tolist()
100
+ return encoded["input_ids"][0].tolist(), media
101
+
102
+
103
+ def encode_record(
104
+ tokenizer: Any,
105
+ record: dict[str, Any],
106
+ max_length: int = 16384,
107
+ max_state_tokens: int | None = None,
108
+ processor: Any | None = None,
109
+ ) -> EncodedRecord:
110
+ schema_ids = _tokens(tokenizer, "\n\nSCHEMA FIELDS:\n")
111
+ questions: list[EncodedQuestion] = []
112
+ for question_index, (question_id, question) in enumerate(record["questions"].items()):
113
+ schema_ids.extend(
114
+ _tokens(
115
+ tokenizer,
116
+ f"\nFIELD {question_index + 1}\nID: {question_id}\nTYPE: {question['type']}\nINSTRUCTION: ",
117
+ )
118
+ )
119
+ question_start = len(schema_ids)
120
+ instructions = question.get("instructions")
121
+ if instructions is None or instructions == "":
122
+ instructions = str(question_id)
123
+ schema_ids.extend(_tokens(tokenizer, render(instructions)))
124
+ question_end = len(schema_ids)
125
+ schema_ids.extend(_tokens(tokenizer, "\nALLOWED OPTIONS:\n"))
126
+
127
+ option_spans: list[tuple[int, int]] = []
128
+ option_ids: list[str] = []
129
+ for option_index, (option_id, description) in enumerate(question_options(question)):
130
+ schema_ids.extend(_tokens(tokenizer, f"OPTION {option_index + 1}: "))
131
+ option_start = len(schema_ids)
132
+ semantics = {"option_id": option_id}
133
+ if description is not None:
134
+ semantics["description"] = description
135
+ schema_ids.extend(_tokens(tokenizer, render(semantics)))
136
+ option_spans.append((option_start, len(schema_ids)))
137
+ option_ids.append(option_id)
138
+ schema_ids.extend(_tokens(tokenizer, "\n"))
139
+ schema_ids.extend(_tokens(tokenizer, "END FIELD\n"))
140
+ questions.append(
141
+ EncodedQuestion(
142
+ question_id=str(question_id),
143
+ question_type=QUESTION_TYPES[str(question["type"])],
144
+ question_span=(question_start, question_end),
145
+ option_spans=tuple(option_spans),
146
+ option_ids=tuple(option_ids),
147
+ )
148
+ )
149
+
150
+ prefix_ids = _tokens(
151
+ tokenizer,
152
+ f"<|im_start|>system\n{SYSTEM_PROMPT}<|im_end|>\n<|im_start|>user\nSTATE:\n",
153
+ )
154
+ suffix_ids = _tokens(
155
+ tokenizer,
156
+ "\n<|im_end|>\n<|im_start|>assistant\n<think>\n\n</think>\n\nJOINT SCHEMA DECISIONS:",
157
+ )
158
+ media_ids, media = _encode_media(processor, record)
159
+ if media is not None:
160
+ media["token_offset"] = len(prefix_ids)
161
+ prefix_ids = prefix_ids + media_ids
162
+ state_ids = _tokens(tokenizer, render(record["state"]))
163
+ if max_state_tokens is not None:
164
+ state_ids = state_ids[:max_state_tokens]
165
+ fixed_length = len(prefix_ids) + len(schema_ids) + len(suffix_ids)
166
+ if fixed_length > max_length:
167
+ raise ValueError(
168
+ f"schema requires {fixed_length} tokens before state; maximum is {max_length}"
169
+ )
170
+ state_ids = state_ids[: max_length - fixed_length]
171
+ schema_offset = len(prefix_ids) + len(state_ids)
172
+ shifted_questions = tuple(
173
+ EncodedQuestion(
174
+ question_id=question.question_id,
175
+ question_type=question.question_type,
176
+ question_span=(
177
+ question.question_span[0] + schema_offset,
178
+ question.question_span[1] + schema_offset,
179
+ ),
180
+ option_spans=tuple(
181
+ (start + schema_offset, end + schema_offset)
182
+ for start, end in question.option_spans
183
+ ),
184
+ option_ids=question.option_ids,
185
+ )
186
+ for question in questions
187
+ )
188
+ input_ids = tuple(prefix_ids + state_ids + schema_ids + suffix_ids)
189
+ if not input_ids or not shifted_questions:
190
+ raise ValueError("record produced no model input or questions")
191
+ return EncodedRecord(
192
+ input_ids=input_ids,
193
+ questions=shifted_questions,
194
+ record_id=str(record.get("id", "unknown")),
195
+ media=media,
196
+ )
197
+
198
+
199
+ def collate_records(
200
+ records: list[EncodedRecord],
201
+ pad_token_id: int,
202
+ device: torch.device,
203
+ ) -> dict[str, Any]:
204
+ maximum_length = max(len(record.input_ids) for record in records)
205
+ input_ids = torch.full(
206
+ (len(records), maximum_length),
207
+ pad_token_id,
208
+ dtype=torch.long,
209
+ device=device,
210
+ )
211
+ attention_mask = torch.zeros(
212
+ (len(records), maximum_length),
213
+ dtype=torch.long,
214
+ device=device,
215
+ )
216
+ for index, record in enumerate(records):
217
+ length = len(record.input_ids)
218
+ input_ids[index, :length] = torch.tensor(record.input_ids, device=device)
219
+ attention_mask[index, :length] = 1
220
+ media: dict[str, torch.Tensor] = {}
221
+ for key in MEDIA_BATCH_KEYS:
222
+ values = [record.media[key] for record in records if record.media and key in record.media]
223
+ if values:
224
+ media[key] = torch.cat(values, dim=0).to(device)
225
+ for key in MEDIA_TOKEN_KEYS:
226
+ if any(record.media and key in record.media for record in records):
227
+ token_values = torch.zeros((len(records), maximum_length), dtype=torch.long, device=device)
228
+ for index, record in enumerate(records):
229
+ if record.media and key in record.media:
230
+ offset = record.media["token_offset"]
231
+ values = torch.tensor(record.media[key], dtype=torch.long, device=device)
232
+ token_values[index, offset : offset + len(values)] = values
233
+ media[key] = token_values
234
+ return {
235
+ "input_ids": input_ids,
236
+ "attention_mask": attention_mask,
237
+ "records": records,
238
+ "media": media,
239
+ }
240
+
241
+
242
+ class EvidenceRoutingLayer(torch.nn.Module):
243
+ def __init__(
244
+ self,
245
+ width: int,
246
+ heads: int,
247
+ feedforward: int,
248
+ dropout: float = 0.0,
249
+ ) -> None:
250
+ super().__init__()
251
+ self.query_norm = torch.nn.LayerNorm(width)
252
+ self.memory_norm = torch.nn.LayerNorm(width)
253
+ self.attention = torch.nn.MultiheadAttention(
254
+ width,
255
+ heads,
256
+ dropout=dropout,
257
+ batch_first=True,
258
+ )
259
+ self.attention_dropout = torch.nn.Dropout(dropout)
260
+ self.feedforward_norm = torch.nn.LayerNorm(width)
261
+ self.feedforward = torch.nn.Sequential(
262
+ torch.nn.Linear(width, feedforward),
263
+ torch.nn.GELU(),
264
+ torch.nn.Dropout(dropout),
265
+ torch.nn.Linear(feedforward, width),
266
+ torch.nn.Dropout(dropout),
267
+ )
268
+
269
+ def forward(self, queries: torch.Tensor, memory: torch.Tensor) -> torch.Tensor:
270
+ normalized_queries = self.query_norm(queries)
271
+ routed, _ = self.attention(
272
+ normalized_queries,
273
+ self.memory_norm(memory),
274
+ self.memory_norm(memory),
275
+ need_weights=False,
276
+ )
277
+ queries = queries + self.attention_dropout(routed)
278
+ return queries + self.feedforward(self.feedforward_norm(queries))
279
+
280
+
281
+ class JointSchemaHead(torch.nn.Module):
282
+ def __init__(
283
+ self,
284
+ hidden_size: int,
285
+ width: int,
286
+ routing_layers: int,
287
+ layers: int,
288
+ heads: int,
289
+ feedforward: int,
290
+ dropout: float = 0.0,
291
+ ) -> None:
292
+ super().__init__()
293
+ self.hidden_norm = torch.nn.LayerNorm(hidden_size)
294
+ self.memory_projection = torch.nn.Linear(hidden_size, width, bias=False)
295
+ self.question_projection = torch.nn.Linear(hidden_size, width, bias=False)
296
+ self.option_question_projection = torch.nn.Linear(hidden_size, width, bias=False)
297
+ self.global_projection = torch.nn.Linear(hidden_size, width, bias=False)
298
+ self.option_context_projection = torch.nn.Linear(hidden_size, width, bias=False)
299
+ self.option_lexical_projection = torch.nn.Linear(hidden_size, width, bias=False)
300
+ self.type_embedding = torch.nn.Embedding(3, width)
301
+ self.evidence_layers = torch.nn.ModuleList(
302
+ [
303
+ EvidenceRoutingLayer(
304
+ width=width,
305
+ heads=heads,
306
+ feedforward=feedforward,
307
+ dropout=dropout,
308
+ )
309
+ for _ in range(routing_layers)
310
+ ]
311
+ )
312
+ self.option_summary_norm = torch.nn.LayerNorm(width)
313
+ self.layers = torch.nn.ModuleList(
314
+ [
315
+ torch.nn.TransformerDecoderLayer(
316
+ d_model=width,
317
+ nhead=heads,
318
+ dim_feedforward=feedforward,
319
+ dropout=dropout,
320
+ activation="gelu",
321
+ batch_first=True,
322
+ norm_first=True,
323
+ )
324
+ for _ in range(layers)
325
+ ]
326
+ )
327
+ self.field_norm = torch.nn.LayerNorm(width)
328
+ self.option_norm = torch.nn.LayerNorm(width)
329
+ self.residual_scorer = torch.nn.Sequential(
330
+ torch.nn.Linear(width * 4, width),
331
+ torch.nn.GELU(),
332
+ torch.nn.Dropout(dropout),
333
+ torch.nn.Linear(width, 1),
334
+ )
335
+ self.prior_logit_scale = torch.nn.Parameter(torch.zeros(()))
336
+ self.joint_logit_scale = torch.nn.Parameter(torch.zeros(()))
337
+ self.residual_gate = torch.nn.Parameter(torch.zeros(()))
338
+
339
+ @staticmethod
340
+ def _mean_span(values: torch.Tensor, span: tuple[int, int]) -> torch.Tensor:
341
+ start, end = span
342
+ return values[start:end].mean(dim=0)
343
+
344
+ def forward(
345
+ self,
346
+ hidden_states: torch.Tensor,
347
+ input_ids: torch.Tensor,
348
+ attention_mask: torch.Tensor,
349
+ records: list[EncodedRecord],
350
+ output_embedding_weight: torch.Tensor,
351
+ ) -> list[list[torch.Tensor]]:
352
+ results: list[list[torch.Tensor]] = []
353
+ normalized_hidden = self.hidden_norm(hidden_states)
354
+ for batch_index, record in enumerate(records):
355
+ sequence_length = int(attention_mask[batch_index].sum().item())
356
+ sequence_hidden = normalized_hidden[batch_index, :sequence_length]
357
+ memory = self.memory_projection(sequence_hidden).unsqueeze(0)
358
+ global_vector = sequence_hidden[-1]
359
+ question_vectors = torch.stack(
360
+ [
361
+ self._mean_span(sequence_hidden, question.question_span)
362
+ for question in record.questions
363
+ ]
364
+ )
365
+ type_ids = torch.tensor(
366
+ [question.question_type for question in record.questions],
367
+ device=hidden_states.device,
368
+ )
369
+ option_contexts: list[torch.Tensor] = []
370
+ lexical_options: list[torch.Tensor] = []
371
+ option_counts = []
372
+ for question in record.questions:
373
+ context_vectors = torch.stack(
374
+ [
375
+ self._mean_span(sequence_hidden, span)
376
+ for span in question.option_spans
377
+ ]
378
+ )
379
+ lexical_vectors = []
380
+ for start, end in question.option_spans:
381
+ token_ids = input_ids[batch_index, start:end]
382
+ lexical_vectors.append(output_embedding_weight[token_ids].mean(dim=0))
383
+ lexical = torch.stack(lexical_vectors)
384
+ option_contexts.append(context_vectors)
385
+ lexical_options.append(lexical)
386
+ option_counts.append(len(question.option_spans))
387
+
388
+ option_queries = []
389
+ for question_index, (context_vectors, lexical) in enumerate(
390
+ zip(option_contexts, lexical_options)
391
+ ):
392
+ option_queries.append(
393
+ self.option_context_projection(context_vectors)
394
+ + self.option_lexical_projection(lexical)
395
+ + self.option_question_projection(
396
+ question_vectors[question_index]
397
+ ).unsqueeze(0)
398
+ )
399
+ routed_options = torch.cat(option_queries, dim=0).unsqueeze(0)
400
+ for layer in self.evidence_layers:
401
+ routed_options = layer(routed_options, memory)
402
+ routed_options = routed_options[0]
403
+ split_options = list(torch.split(routed_options, option_counts, dim=0))
404
+
405
+ base_fields = self.question_projection(question_vectors)
406
+ option_summaries = []
407
+ for field, options in zip(base_fields, split_options):
408
+ routing_weights = torch.softmax(
409
+ torch.matmul(options, field) / math.sqrt(options.shape[-1]),
410
+ dim=0,
411
+ )
412
+ option_summaries.append(
413
+ torch.sum(routing_weights.unsqueeze(-1) * options, dim=0)
414
+ )
415
+ fields = (
416
+ base_fields
417
+ + self.option_summary_norm(torch.stack(option_summaries))
418
+ + self.global_projection(global_vector).unsqueeze(0)
419
+ + self.type_embedding(type_ids)
420
+ )
421
+ fields = fields.unsqueeze(0)
422
+ for layer in self.layers:
423
+ fields = layer(fields, memory)
424
+ fields = self.field_norm(fields[0])
425
+
426
+ record_logits: list[torch.Tensor] = []
427
+ for field, question, lexical, routed in zip(
428
+ fields,
429
+ record.questions,
430
+ lexical_options,
431
+ split_options,
432
+ ):
433
+ anchor = functional.normalize(
434
+ question_vectors[len(record_logits)] + global_vector,
435
+ dim=-1,
436
+ )
437
+ lexical_anchor = functional.normalize(lexical, dim=-1)
438
+ prior_scale = self.prior_logit_scale.clamp(max=math.log(100.0)).exp()
439
+ prior = prior_scale * torch.matmul(lexical_anchor, anchor)
440
+ options = self.option_norm(routed)
441
+ repeated_field = field.unsqueeze(0).expand_as(options)
442
+ cosine = functional.cosine_similarity(repeated_field, options, dim=-1)
443
+ features = torch.cat(
444
+ [
445
+ repeated_field,
446
+ options,
447
+ repeated_field * options,
448
+ torch.abs(repeated_field - options),
449
+ ],
450
+ dim=-1,
451
+ )
452
+ residual = self.residual_scorer(features).squeeze(-1)
453
+ joint_scale = self.joint_logit_scale.clamp(max=math.log(100.0)).exp()
454
+ joint = joint_scale * cosine + residual
455
+ record_logits.append(
456
+ prior + torch.sigmoid(self.residual_gate) * joint
457
+ )
458
+ results.append(record_logits)
459
+ return results
460
+
461
+
462
+ class ClefModel(torch.nn.Module):
463
+ def __init__(self, language_model: Any, head: JointSchemaHead) -> None:
464
+ super().__init__()
465
+ self.language_model = language_model
466
+ self.head = head
467
+
468
+ def forward(self, batch: dict[str, Any]) -> list[list[torch.Tensor]]:
469
+ base_model = (
470
+ self.language_model.get_base_model()
471
+ if hasattr(self.language_model, "get_base_model")
472
+ else self.language_model
473
+ )
474
+ media = batch.get("media") or {}
475
+ text_model = base_model.model
476
+ if not media and hasattr(text_model, "language_model"):
477
+ text_model = text_model.language_model
478
+ outputs = text_model(
479
+ input_ids=batch["input_ids"],
480
+ attention_mask=batch["attention_mask"],
481
+ use_cache=False,
482
+ return_dict=True,
483
+ **media,
484
+ )
485
+ return self.head(
486
+ outputs.last_hidden_state,
487
+ batch["input_ids"],
488
+ batch["attention_mask"],
489
+ batch["records"],
490
+ base_model.get_output_embeddings().weight,
491
+ )
492
+
493
+
494
+ def load_release_model(
495
+ model_path: str | Path,
496
+ device: str | torch.device = "cuda",
497
+ dtype: torch.dtype = torch.bfloat16,
498
+ **from_pretrained_kwargs: Any,
499
+ ) -> tuple[ClefModel, Any]:
500
+ """Load a Clef release (merged backbone, joint schema head, and processor)."""
501
+ from huggingface_hub import snapshot_download
502
+ from safetensors.torch import load_file
503
+ from transformers import AutoProcessor, Qwen3_5ForConditionalGeneration
504
+
505
+ path = Path(model_path)
506
+ if not path.is_dir():
507
+ path = Path(snapshot_download(str(model_path)))
508
+ backbone = Qwen3_5ForConditionalGeneration.from_pretrained(
509
+ path,
510
+ dtype=dtype,
511
+ device_map={"": str(device)},
512
+ **from_pretrained_kwargs,
513
+ )
514
+ backbone.config.use_cache = False
515
+ head_config = json.loads((path / "joint_head_config.json").read_text())
516
+ head = JointSchemaHead(**head_config)
517
+ head.load_state_dict(load_file(path / "joint_head.safetensors"), strict=True)
518
+ head = head.to(device=device, dtype=dtype)
519
+ processor = AutoProcessor.from_pretrained(path)
520
+ return ClefModel(backbone, head).eval(), processor
521
+
522
+
523
+ def systemone_answer(question: dict[str, Any], probabilities: dict[str, float]) -> dict[str, Any]:
524
+ """Convert per-option probabilities for one question into a SystemOne answer."""
525
+ if question["type"] == "noul":
526
+ return {"type": "noul", "noul": round(probabilities["true"], 4)}
527
+ if question["type"] == "choice":
528
+ options = [str(option) for option in question["criteria"]]
529
+ choice = max(options, key=probabilities.__getitem__)
530
+ return {
531
+ "type": "choice",
532
+ "choice": choice,
533
+ "confidence": round(probabilities[choice], 4),
534
+ "probabilities": {option: round(probabilities[option], 4) for option in options},
535
+ }
536
+ levels = [str(index) for index in range(len(question["criteria"]))]
537
+ return {
538
+ "type": "score",
539
+ "score": round(sum(index * probabilities[level] for index, level in enumerate(levels)), 4),
540
+ "confidence": round(max(probabilities[level] for level in levels), 4),
541
+ "legend": dict(zip(levels, question["criteria"])),
542
+ "probabilities": {level: round(probabilities[level], 4) for level in levels},
543
+ }
544
+
545
+
546
+ @torch.inference_mode()
547
+ def systemone(model: ClefModel, processor: Any, request: dict[str, Any], max_length: int = 16384) -> dict[str, Any]:
548
+ """Answer a Jev/SystemOne ``/v1/systemone`` request body with a SystemOne response body.
549
+
550
+ The request has ``model``, ``state``, and ``questions``, plus optional ``images`` and ``videos``.
551
+ """
552
+ questions = request.get("questions")
553
+ if not isinstance(request.get("model"), str) or "state" not in request:
554
+ raise ValueError("model and state are required")
555
+ if not isinstance(questions, dict) or not questions:
556
+ raise ValueError("at least one question is required")
557
+ for question_id, question in questions.items():
558
+ if question.get("type") not in QUESTION_TYPES:
559
+ raise ValueError(f"{question_id}: type must be noul, choice, or score")
560
+ if question["type"] != "noul" and not question.get("criteria"):
561
+ raise ValueError(f"{question_id}: criteria must not be empty")
562
+ encoded = encode_record(processor.tokenizer, request, max_length=max_length, processor=processor)
563
+ device = next(model.parameters()).device
564
+ logits = model(collate_records([encoded], processor.tokenizer.pad_token_id, device))[0]
565
+ answers = {
566
+ question.question_id: systemone_answer(
567
+ questions[question.question_id],
568
+ dict(zip(question.option_ids, question_logits.float().softmax(-1).tolist())),
569
+ )
570
+ for question, question_logits in zip(encoded.questions, logits)
571
+ }
572
+ return {
573
+ "model": request["model"],
574
+ "answers": answers,
575
+ "usage": {"input_tokens": len(encoded.input_ids), "output_tokens": 0},
576
+ }
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc67e4a4122c9b8fabfc2b6ee905a928038fa89d394f0c2ede91ed62c3bf0391
3
+ size 19977722616
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7a9dacc83478f3ee2db969bcb73c8f755f300993b677fda086369ef481bcec39
3
+ size 3861367144
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
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
+ }
recipe.yaml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ default_stage:
2
+ default_modifiers:
3
+ QuantizationModifier:
4
+ config_groups:
5
+ group_0:
6
+ targets: ['re:.*self_attn\.(q|k|v|o)_proj$', 're:.*linear_attn\.(in_proj_qkv|in_proj_z|out_proj)$',
7
+ 're:.*layers\.(56|57|58|59|60|61|62|63)\.mlp\.(gate|up|down)_proj$']
8
+ weights:
9
+ num_bits: 8
10
+ type: float
11
+ symmetric: true
12
+ group_size: null
13
+ strategy: channel
14
+ block_structure: null
15
+ dynamic: false
16
+ actorder: null
17
+ scale_dtype: null
18
+ zp_dtype: null
19
+ observer: memoryless_minmax
20
+ observer_kwargs: {}
21
+ input_activations:
22
+ num_bits: 8
23
+ type: float
24
+ symmetric: true
25
+ group_size: null
26
+ strategy: token
27
+ block_structure: null
28
+ dynamic: true
29
+ actorder: null
30
+ scale_dtype: null
31
+ zp_dtype: null
32
+ observer: null
33
+ observer_kwargs: {}
34
+ output_activations: null
35
+ format: null
36
+ group_1:
37
+ targets: ['re:.*layers\.([0-9]|[1-4][0-9]|5[0-5])\.mlp\.(gate|up|down)_proj$']
38
+ weights:
39
+ num_bits: 4
40
+ type: float
41
+ symmetric: true
42
+ group_size: 16
43
+ strategy: tensor_group
44
+ block_structure: null
45
+ dynamic: false
46
+ actorder: null
47
+ scale_dtype: torch.float8_e4m3fn
48
+ zp_dtype: null
49
+ observer: memoryless_minmax
50
+ observer_kwargs: {}
51
+ input_activations:
52
+ num_bits: 4
53
+ type: float
54
+ symmetric: true
55
+ group_size: 16
56
+ strategy: tensor_group
57
+ block_structure: null
58
+ dynamic: local
59
+ actorder: null
60
+ scale_dtype: torch.float8_e4m3fn
61
+ zp_dtype: null
62
+ observer: static_minmax
63
+ observer_kwargs: {}
64
+ output_activations: null
65
+ format: null
66
+ targets: [Linear]
67
+ ignore: [lm_head, 're:.*visual.*']
68
+ bypass_divisibility_checks: false
69
+ requires_calibration_data: true
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06b9509352d2af50381ab2247e083b80d32d5c0aba91c272ca9ff729b6a0e523
3
+ size 19989325
tokenizer_config.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "model_max_length": 262144,
13
+ "model_specific_special_tokens": {
14
+ "audio_bos_token": "<|audio_start|>",
15
+ "audio_eos_token": "<|audio_end|>",
16
+ "audio_token": "<|audio_pad|>",
17
+ "image_token": "<|image_pad|>",
18
+ "video_token": "<|video_pad|>",
19
+ "vision_bos_token": "<|vision_start|>",
20
+ "vision_eos_token": "<|vision_end|>"
21
+ },
22
+ "pad_token": "<|endoftext|>",
23
+ "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+",
24
+ "split_special_tokens": false,
25
+ "tokenizer_class": "Qwen2Tokenizer",
26
+ "unk_token": null,
27
+ "video_token": "<|video_pad|>",
28
+ "vision_bos_token": "<|vision_start|>",
29
+ "vision_eos_token": "<|vision_end|>"
30
+ }