Keendata commited on
Commit
a0122bb
·
verified ·
1 Parent(s): 6282dc0

KeenSQL1.0

Browse files
.gitattributes CHANGED
@@ -1,35 +1,2 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
  *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  *.safetensors filter=lfs diff=lfs merge=lfs -text
2
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
README.md ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: apache-2.0
4
+ base_model: Qwen/Qwen3.5-9B
5
+ tags:
6
+ - text-to-sql
7
+ - agent
8
+ - tool-use
9
+ - sqlite
10
+ - reinforcement-learning
11
+ - qwen3_5
12
+ language:
13
+ - en
14
+ pipeline_tag: text-generation
15
+ ---
16
+
17
+ # KeenSQL1.0
18
+
19
+ A **9B tool-using Text-to-SQL agent** for SQLite databases. Given a natural-language
20
+ question, a database, and optional evidence, the model runs a multi-turn agent loop —
21
+ inspecting the schema, executing probe queries, then emitting a final SQL answer — and
22
+ returns a single SQL statement.
23
+
24
+ KeenSQL1.0 is the final checkpoint (global step 240) of a reinforcement fine-tuning run
25
+ started from a full-parameter SFT of Qwen3.5-9B, trained with GRPO plus a
26
+ KL-to-reference penalty on execution-based rewards.
27
+
28
+ ## Model details
29
+
30
+ | | |
31
+ |---|---|
32
+ | Base architecture | Qwen3.5 (hybrid linear/full attention, `Qwen3_5ForConditionalGeneration`) |
33
+ | Parameters | ~9B |
34
+ | Precision | bfloat16 |
35
+ | Hidden / layers | 4096 / 32 |
36
+ | Attention | 16 Q heads, 4 KV heads, head_dim 256, mRoPE (partial 0.25) |
37
+ | Vocabulary | 248,320 |
38
+ | Context | 262,144 |
39
+ | Training start point | SFT checkpoint at global step 286 (full-parameter SFT of Qwen3.5-9B) |
40
+ | Training steps | 240 optimizer steps (1 update per step) |
41
+ | Batch | 8 question groups × 3 candidates × 8 rollouts per step |
42
+ | Optimizer | AdamW, lr 1e-6 with 7-step warmup, cosine decay to 0.3× |
43
+ | KL controller | target 0.03 nats/token, adaptive coefficient in [0.02, 0.5] |
44
+
45
+ The checkpoint also carries an (unused) vision tower from the Qwen3.5 multimodal
46
+ architecture; this model is **text-only** in practice.
47
+
48
+ ## ⚠️ Use this model's own chat template
49
+
50
+ `chat_template.jinja` (also embedded in `tokenizer_config.json`) is a **modified**
51
+ variant, not the stock Qwen3.5 template. It emits a *plain* assistant header on every
52
+ turn and adds no `think` block.
53
+
54
+ The stock template gives the assistant message that follows the last non-tool user turn
55
+ a closed empty think block, which acts as a perfect "this is the final turn" flag — a
56
+ signal that a rollout cannot reproduce, because whether a turn ends the episode is
57
+ decided by tokens sampled *after* the header is already fixed in the context.
58
+
59
+ **Training, rollout and evaluation all use the plain-header shape.** Loading this model
60
+ with the default Qwen template produces a train/inference format mismatch and will
61
+ degrade accuracy substantially.
62
+
63
+ ```python
64
+ from transformers import AutoTokenizer
65
+
66
+ tok = AutoTokenizer.from_pretrained("<this-repo>", trust_remote_code=True)
67
+ # chat_template is already set from tokenizer_config.json — do not override it
68
+ assert "plain-header" in tok.chat_template
69
+ ```
70
+
71
+ ## Agent protocol
72
+
73
+ The model expects to be driven by an agent loop with these properties:
74
+
75
+ | Item | Value |
76
+ |---|---|
77
+ | Max turns | 8 tool calls + 1 final answer |
78
+ | Max tokens per turn | 2048 |
79
+ | Max observation size | 2048 tokens per tool return |
80
+ | Tool | `sqlite_query` (single SQL statement; returns rows or an error) |
81
+ | Final answer | a turn containing a `sql` block instead of a tool call |
82
+
83
+ Turns must alternate: one tool call per turn, observation fed back as a user message
84
+ wrapped in `<observation>`. The model was trained with this exact wrapper and turn budget.
85
+
86
+ Sampling used for evaluation: **temperature 0.7, top_p 0.95, top_k -1**.
87
+
88
+ ## Evaluation
89
+
90
+ ### BIRD dev (1,534 questions, self-consistency)
91
+
92
+ `sc_ex` = execution accuracy after majority vote over k samples.
93
+ `pass@k` = fraction of questions with at least one correct sample out of k.
94
+
95
+ | Checkpoint | sc_ex (k=8) | pass@8 | all-attempt protocol rate |
96
+ |---|---|---|---|
97
+ | SFT start point (step 286) | 0.6851 | 0.7992 | 0.8801 |
98
+ | RFT step 120 | 0.6930 | 0.7621 | 0.9720 |
99
+ | **KeenSQL1.0 (RFT step 240)** | **0.7053** | **0.7901** | **0.8911** |
100
+
101
+ At higher sampling budgets (step 240): **sc_ex@16 = 0.7112**, **sc_ex@32 = 0.7125**,
102
+ **pass@32 = 0.8305**.
103
+
104
+ ### By difficulty (BIRD dev, sc@8)
105
+
106
+ | Difficulty | Questions | SFT start | KeenSQL1.0 | Δ |
107
+ |---|---|---|---|---|
108
+ | simple | 925 | 0.7351 | **0.7514** | +1.63 |
109
+ | moderate | 464 | 0.6207 | **0.6466** | +2.59 |
110
+ | challenging | 145 | 0.5724 | **0.6000** | +2.76 |
111
+
112
+ The gain grows with difficulty, which is what one wants from execution-reward training.
113
+
114
+ ### Internal held-out split (323 questions, n=2, temp 0.7)
115
+
116
+ Weighted execution accuracy: **0.6502** at the SFT start point → **0.7167** at its peak
117
+ (step 120) → **0.6796** at step 240.
118
+
119
+ **This internal split disagreed with the full BIRD dev set**: it made step 120 look like
120
+ the best checkpoint (0.7167) while on BIRD dev step 240 scored higher (0.7053 vs 0.6930).
121
+ The internal split is only 323 questions from a narrow set of databases, so its
122
+ step-to-step swings (roughly ±1.5 points) are dominated by sampling noise.
123
+
124
+ ## How to read these numbers
125
+
126
+ * The gain over the SFT start point is **modest but consistent**: **+2.0 points sc_ex** on
127
+ BIRD dev, concentrated on the harder questions.
128
+ * `pass@8` is slightly *lower* than the SFT start point (0.7901 vs 0.7992), while
129
+ sc_ex@8 is higher. In other words RFT improved *per-sample reliability under majority
130
+ voting* rather than the *capability ceiling* — expected, since the SFT start point
131
+ already solved 80% of questions at least once in 8 tries.
132
+ * Output diversity increased during training (mean entropy 0.23 nats/token, up from
133
+ 0.19), so self-consistency needs k≥8 to pay off. At k=2 expect considerably lower
134
+ numbers.
135
+
136
+ ## Limitations
137
+
138
+ * **SQLite only.** Trained and evaluated on SQLite databases. Other dialects untested.
139
+ * **Schema must be provided** in the prompt; the model does not connect to a database.
140
+ * **Needs the agent loop.** Loaded as a plain chat model without the tool protocol and
141
+ turn budget, quality drops sharply.
142
+ * **Late-training drift.** From roughly step 120 onward the KL-to-reference penalty was
143
+ pushed to its operating point, output diversity rose, and self-consistency consensus
144
+ fell. If you need maximum stability rather than maximum accuracy, evaluate step 120 as
145
+ well.
146
+ * **Small validation set.** The internal split used to monitor training was too small to
147
+ distinguish nearby checkpoints reliably; the BIRD dev numbers above are the trustworthy
148
+ ones.
149
+ * Not safety-tuned beyond whatever the base SFT model carried. No guarantee against
150
+ generating destructive SQL — **never run its output against a production database
151
+ without review.**
152
+
153
+ ## Files
154
+
155
+ | File | Notes |
156
+ |---|---|
157
+ | `model.safetensors` | single-file bf16 weights, 760 tensors, ~17.5 GB |
158
+ | `config.json` | Qwen3.5 text config (+ unused vision_config) |
159
+ | `tokenizer.json`, `tokenizer_config.json` | fast tokenizer, **custom chat template embedded** |
160
+ | `chat_template.jinja` | same template as a standalone file |
161
+ | `generation_config.json` | default generation parameters |
162
+ | `processor_config.json` | Qwen3VLProcessor (multimodal; unused for text-only SQL) |
163
+
164
+ Requires a `transformers` release that supports the `qwen3_5` architecture
165
+ (the checkpoint was exported with `transformers` 5.9.0).
chat_template.jinja ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ {#-
68
+ KeenSQL RFT/ SFT plain-header variant.
69
+
70
+ The stock Qwen3.5 template gives an assistant message that follows the last
71
+ non-tool user turn a closed empty think block
72
+ ("<|im_start|>assistant\n<think>\n\n</think>\n\n"), and every earlier one a
73
+ plain header. On this data that marker is a perfect "this is the final turn"
74
+ flag (8,935/8,935 final turns, 0/16,360 intermediate turns), which a rollout
75
+ cannot reproduce: whether a turn ends the episode is decided by the tokens
76
+ sampled *after* the header is already fixed in the context.
77
+
78
+ This variant emits the plain header for every assistant message and no
79
+ suffix at all for the generation prompt, so training, rollout and evaluation
80
+ share one shape and position in the episode carries no signal.
81
+
82
+ The stock reasoning_content split is intentionally dropped: under plain
83
+ headers there is no think block to strip, and re-rendering a turn that
84
+ happened to contain "</think>" would silently delete model output from the
85
+ context.
86
+ -#}
87
+ {%- for message in messages %}
88
+ {%- set content = render_content(message.content, true)|trim %}
89
+ {%- if message.role == 'system' %}
90
+ {%- if not loop.first %}
91
+ {{- raise_exception('System message must be at the beginning.') }}
92
+ {%- endif %}
93
+ {%- elif message.role == 'user' %}
94
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
95
+ {%- elif message.role == 'assistant' %}
96
+ {{- '<|im_start|>' + message.role + '\n' + content }}
97
+ {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
98
+ {%- for tool_call in message.tool_calls %}
99
+ {%- if tool_call.function is defined %}
100
+ {%- set tool_call = tool_call.function %}
101
+ {%- endif %}
102
+ {%- if loop.first %}
103
+ {%- if content|trim %}
104
+ {{- '\n\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
105
+ {%- else %}
106
+ {{- '<tool_call>\n<function=' + tool_call.name + '>\n' }}
107
+ {%- endif %}
108
+ {%- else %}
109
+ {{- '\n<tool_call>\n<function=' + tool_call.name + '>\n' }}
110
+ {%- endif %}
111
+ {%- if tool_call.arguments is defined %}
112
+ {%- for args_name, args_value in tool_call.arguments|items %}
113
+ {{- '<parameter=' + args_name + '>\n' }}
114
+ {%- 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 %}
115
+ {{- args_value }}
116
+ {{- '\n</parameter>\n' }}
117
+ {%- endfor %}
118
+ {%- endif %}
119
+ {{- '</function>\n</tool_call>' }}
120
+ {%- endfor %}
121
+ {%- endif %}
122
+ {{- '<|im_end|>\n' }}
123
+ {%- elif message.role == "tool" %}
124
+ {%- if loop.previtem and loop.previtem.role != "tool" %}
125
+ {{- '<|im_start|>user' }}
126
+ {%- endif %}
127
+ {{- '\n<tool_response>\n' }}
128
+ {{- content }}
129
+ {{- '\n</tool_response>' }}
130
+ {%- if not loop.last and loop.nextitem.role != "tool" %}
131
+ {{- '<|im_end|>\n' }}
132
+ {%- elif loop.last %}
133
+ {{- '<|im_end|>\n' }}
134
+ {%- endif %}
135
+ {%- else %}
136
+ {{- raise_exception('Unexpected message role.') }}
137
+ {%- endif %}
138
+ {%- endfor %}
139
+ {%- if add_generation_prompt %}
140
+ {#- No think block: the policy's first sampled token is the action. #}
141
+ {{- '<|im_start|>assistant\n' }}
142
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen3_5ForConditionalGeneration"
4
+ ],
5
+ "bos_token_id": null,
6
+ "dtype": "bfloat16",
7
+ "eos_token_id": 248046,
8
+ "image_token_id": 248056,
9
+ "model_type": "qwen3_5",
10
+ "pad_token_id": 248044,
11
+ "text_config": {
12
+ "attention_bias": false,
13
+ "attention_dropout": 0.0,
14
+ "attn_output_gate": true,
15
+ "bos_token_id": null,
16
+ "dtype": "bfloat16",
17
+ "eos_token_id": 248044,
18
+ "full_attention_interval": 4,
19
+ "head_dim": 256,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 4096,
22
+ "initializer_range": 0.02,
23
+ "intermediate_size": 12288,
24
+ "layer_types": [
25
+ "linear_attention",
26
+ "linear_attention",
27
+ "linear_attention",
28
+ "full_attention",
29
+ "linear_attention",
30
+ "linear_attention",
31
+ "linear_attention",
32
+ "full_attention",
33
+ "linear_attention",
34
+ "linear_attention",
35
+ "linear_attention",
36
+ "full_attention",
37
+ "linear_attention",
38
+ "linear_attention",
39
+ "linear_attention",
40
+ "full_attention",
41
+ "linear_attention",
42
+ "linear_attention",
43
+ "linear_attention",
44
+ "full_attention",
45
+ "linear_attention",
46
+ "linear_attention",
47
+ "linear_attention",
48
+ "full_attention",
49
+ "linear_attention",
50
+ "linear_attention",
51
+ "linear_attention",
52
+ "full_attention",
53
+ "linear_attention",
54
+ "linear_attention",
55
+ "linear_attention",
56
+ "full_attention"
57
+ ],
58
+ "linear_conv_kernel_dim": 4,
59
+ "linear_key_head_dim": 128,
60
+ "linear_num_key_heads": 16,
61
+ "linear_num_value_heads": 32,
62
+ "linear_value_head_dim": 128,
63
+ "mamba_ssm_dtype": "float32",
64
+ "max_position_embeddings": 262144,
65
+ "mlp_only_layers": [],
66
+ "model_type": "qwen3_5_text",
67
+ "mtp_num_hidden_layers": 0,
68
+ "mtp_use_dedicated_embeddings": false,
69
+ "num_attention_heads": 16,
70
+ "num_hidden_layers": 32,
71
+ "num_key_value_heads": 4,
72
+ "pad_token_id": null,
73
+ "partial_rotary_factor": 0.25,
74
+ "rms_norm_eps": 1e-06,
75
+ "rope_parameters": {
76
+ "mrope_interleaved": true,
77
+ "mrope_section": [
78
+ 11,
79
+ 11,
80
+ 10
81
+ ],
82
+ "partial_rotary_factor": 0.25,
83
+ "rope_theta": 10000000,
84
+ "rope_type": "default"
85
+ },
86
+ "tie_word_embeddings": false,
87
+ "use_cache": true,
88
+ "vocab_size": 248320
89
+ },
90
+ "tie_word_embeddings": false,
91
+ "transformers_version": "5.9.0",
92
+ "video_token_id": 248057,
93
+ "vision_config": {
94
+ "deepstack_visual_indexes": [],
95
+ "depth": 27,
96
+ "dtype": "bfloat16",
97
+ "hidden_act": "gelu_pytorch_tanh",
98
+ "hidden_size": 1152,
99
+ "in_channels": 3,
100
+ "initializer_range": 0.02,
101
+ "intermediate_size": 4304,
102
+ "model_type": "qwen3_5_vision",
103
+ "num_heads": 16,
104
+ "num_position_embeddings": 2304,
105
+ "out_hidden_size": 4096,
106
+ "patch_size": 16,
107
+ "spatial_merge_size": 2,
108
+ "temporal_patch_size": 2
109
+ },
110
+ "vision_end_token_id": 248054,
111
+ "vision_start_token_id": 248053
112
+ }
generation_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": 248046,
4
+ "output_attentions": false,
5
+ "output_hidden_states": false,
6
+ "pad_token_id": 248044,
7
+ "transformers_version": "5.9.0",
8
+ "use_cache": true
9
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bdc58c94de871f13102707c6c402ac35d7a3c690efbc030b61b81c1a453fb46
3
+ size 18819722392
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
+ }
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,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "local_files_only": false,
14
+ "model_max_length": 262144,
15
+ "model_specific_special_tokens": {
16
+ "audio_bos_token": "<|audio_start|>",
17
+ "audio_eos_token": "<|audio_end|>",
18
+ "audio_token": "<|audio_pad|>",
19
+ "image_token": "<|image_pad|>",
20
+ "video_token": "<|video_pad|>",
21
+ "vision_bos_token": "<|vision_start|>",
22
+ "vision_eos_token": "<|vision_end|>"
23
+ },
24
+ "pad_token": "<|endoftext|>",
25
+ "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+",
26
+ "processor_class": "Qwen3VLProcessor",
27
+ "split_special_tokens": false,
28
+ "tokenizer_class": "Qwen2Tokenizer",
29
+ "unk_token": null,
30
+ "video_token": "<|video_pad|>",
31
+ "vision_bos_token": "<|vision_start|>",
32
+ "vision_eos_token": "<|vision_end|>",
33
+ "chat_template": "{%- set image_count = namespace(value=0) %}\n{%- set video_count = namespace(value=0) %}\n{%- macro render_content(content, do_vision_count, is_system_content=false) %}\n {%- if content is string %}\n {{- content }}\n {%- elif content is iterable and content is not mapping %}\n {%- for item in content %}\n {%- if 'image' in item or 'image_url' in item or item.type == 'image' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain images.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set image_count.value = image_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Picture ' ~ image_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|image_pad|><|vision_end|>' }}\n {%- elif 'video' in item or item.type == 'video' %}\n {%- if is_system_content %}\n {{- raise_exception('System message cannot contain videos.') }}\n {%- endif %}\n {%- if do_vision_count %}\n {%- set video_count.value = video_count.value + 1 %}\n {%- endif %}\n {%- if add_vision_id %}\n {{- 'Video ' ~ video_count.value ~ ': ' }}\n {%- endif %}\n {{- '<|vision_start|><|video_pad|><|vision_end|>' }}\n {%- elif 'text' in item %}\n {{- item.text }}\n {%- else %}\n {{- raise_exception('Unexpected item type in content.') }}\n {%- endif %}\n {%- endfor %}\n {%- elif content is none or content is undefined %}\n {{- '' }}\n {%- else %}\n {{- raise_exception('Unexpected content type.') }}\n {%- endif %}\n{%- endmacro %}\n{%- if not messages %}\n {{- raise_exception('No messages provided.') }}\n{%- endif %}\n{%- if tools and tools is iterable and tools is not mapping %}\n {{- '<|im_start|>system\\n' }}\n {{- \"# Tools\\n\\nYou have access to the following functions:\\n\\n<tools>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\n</tools>\" }}\n {{- '\\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>' }}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {%- if content %}\n {{- '\\n\\n' + content }}\n {%- endif %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n{%- else %}\n {%- if messages[0].role == 'system' %}\n {%- set content = render_content(messages[0].content, false, true)|trim %}\n {{- '<|im_start|>system\\n' + content + '<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{#-\n KeenSQL RFT/ SFT plain-header variant.\n\n The stock Qwen3.5 template gives an assistant message that follows the last\n non-tool user turn a closed empty think block\n (\"<|im_start|>assistant\\n<think>\\n\\n</think>\\n\\n\"), and every earlier one a\n plain header. On this data that marker is a perfect \"this is the final turn\"\n flag (8,935/8,935 final turns, 0/16,360 intermediate turns), which a rollout\n cannot reproduce: whether a turn ends the episode is decided by the tokens\n sampled *after* the header is already fixed in the context.\n\n This variant emits the plain header for every assistant message and no\n suffix at all for the generation prompt, so training, rollout and evaluation\n share one shape and position in the episode carries no signal.\n\n The stock reasoning_content split is intentionally dropped: under plain\n headers there is no think block to strip, and re-rendering a turn that\n happened to contain \"</think>\" would silently delete model output from the\n context.\n-#}\n{%- for message in messages %}\n {%- set content = render_content(message.content, true)|trim %}\n {%- if message.role == 'system' %}\n {%- if not loop.first %}\n {{- raise_exception('System message must be at the beginning.') }}\n {%- endif %}\n {%- elif message.role == 'user' %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == 'assistant' %}\n {{- '<|im_start|>' + message.role + '\\n' + content }}\n {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {%- if loop.first %}\n {%- if content|trim %}\n {{- '\\n\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- else %}\n {{- '<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- else %}\n {{- '\\n<tool_call>\\n<function=' + tool_call.name + '>\\n' }}\n {%- endif %}\n {%- if tool_call.arguments is defined %}\n {%- for args_name, args_value in tool_call.arguments|items %}\n {{- '<parameter=' + args_name + '>\\n' }}\n {%- 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 %}\n {{- args_value }}\n {{- '\\n</parameter>\\n' }}\n {%- endfor %}\n {%- endif %}\n {{- '</function>\\n</tool_call>' }}\n {%- endfor %}\n {%- endif %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if loop.previtem and loop.previtem.role != \"tool\" %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- content }}\n {{- '\\n</tool_response>' }}\n {%- if not loop.last and loop.nextitem.role != \"tool\" %}\n {{- '<|im_end|>\\n' }}\n {%- elif loop.last %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- else %}\n {{- raise_exception('Unexpected message role.') }}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {#- No think block: the policy's first sampled token is the action. #}\n {{- '<|im_start|>assistant\\n' }}\n{%- endif %}\n"
34
+ }