johnsonchromia commited on
Commit
7bbba62
·
verified ·
1 Parent(s): eafbc61

merged weights

Browse files
config.json CHANGED
@@ -1,198 +1,197 @@
1
  {
2
- "architectures": [
3
- "Gemma4ForConditionalGeneration"
4
- ],
5
- "audio_config": {
6
- "_name_or_path": "",
7
- "architectures": null,
8
- "attention_chunk_size": 12,
9
- "attention_context_left": 13,
10
- "attention_context_right": 0,
11
- "attention_invalid_logits_value": -1000000000.0,
12
- "attention_logit_cap": 50.0,
13
- "chunk_size_feed_forward": 0,
14
- "conv_kernel_size": 5,
15
- "torch_dtype": "bfloat16",
16
- "gradient_clipping": 10000000000.0,
17
- "hidden_act": "silu",
18
- "hidden_size": 1024,
19
- "id2label": {
20
- "0": "LABEL_0",
21
- "1": "LABEL_1"
22
- },
23
- "initializer_range": 0.02,
24
- "is_encoder_decoder": false,
25
- "label2id": {
26
- "LABEL_0": 0,
27
- "LABEL_1": 1
28
- },
29
- "model_type": "gemma4_audio",
30
- "num_attention_heads": 8,
31
- "num_hidden_layers": 12,
32
- "output_attentions": false,
33
- "output_hidden_states": false,
34
- "output_proj_dims": 1536,
35
- "problem_type": null,
36
- "residual_weight": 0.5,
37
- "return_dict": true,
38
- "rms_norm_eps": 1e-06,
39
- "subsampling_conv_channels": [
40
- 128,
41
- 32
42
- ],
43
- "use_clipped_linears": true
44
  },
45
- "audio_token_id": 258881,
46
- "boa_token_id": 256000,
47
- "boi_token_id": 255999,
48
- "torch_dtype": "bfloat16",
49
- "eoa_token_id": 258883,
50
- "eoa_token_index": 258883,
51
- "eoi_token_id": 258882,
52
- "eos_token_id": 106,
53
- "image_token_id": 258880,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  "initializer_range": 0.02,
55
- "model_name": "outputs/abliterated-e4b-may15",
56
- "model_type": "gemma4",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  "pad_token_id": 0,
58
- "text_config": {
59
- "attention_bias": false,
60
- "attention_dropout": 0.0,
61
- "attention_k_eq_v": false,
62
- "bos_token_id": 2,
63
- "torch_dtype": "bfloat16",
64
- "enable_moe_block": false,
65
- "eos_token_id": 1,
66
- "expert_intermediate_size": null,
67
- "final_logit_softcapping": 30.0,
68
- "global_head_dim": 512,
69
- "head_dim": 256,
70
- "hidden_activation": "gelu_pytorch_tanh",
71
- "hidden_size": 2560,
72
- "hidden_size_per_layer_input": 256,
73
- "initializer_range": 0.02,
74
- "intermediate_size": 10240,
75
- "layer_types": [
76
- "sliding_attention",
77
- "sliding_attention",
78
- "sliding_attention",
79
- "sliding_attention",
80
- "sliding_attention",
81
- "full_attention",
82
- "sliding_attention",
83
- "sliding_attention",
84
- "sliding_attention",
85
- "sliding_attention",
86
- "sliding_attention",
87
- "full_attention",
88
- "sliding_attention",
89
- "sliding_attention",
90
- "sliding_attention",
91
- "sliding_attention",
92
- "sliding_attention",
93
- "full_attention",
94
- "sliding_attention",
95
- "sliding_attention",
96
- "sliding_attention",
97
- "sliding_attention",
98
- "sliding_attention",
99
- "full_attention",
100
- "sliding_attention",
101
- "sliding_attention",
102
- "sliding_attention",
103
- "sliding_attention",
104
- "sliding_attention",
105
- "full_attention",
106
- "sliding_attention",
107
- "sliding_attention",
108
- "sliding_attention",
109
- "sliding_attention",
110
- "sliding_attention",
111
- "full_attention",
112
- "sliding_attention",
113
- "sliding_attention",
114
- "sliding_attention",
115
- "sliding_attention",
116
- "sliding_attention",
117
- "full_attention"
118
- ],
119
- "max_position_embeddings": 131072,
120
- "model_type": "gemma4_text",
121
- "moe_intermediate_size": null,
122
- "num_attention_heads": 8,
123
- "num_experts": null,
124
- "num_global_key_value_heads": null,
125
- "num_hidden_layers": 42,
126
- "num_key_value_heads": 2,
127
- "num_kv_shared_layers": 18,
128
- "pad_token_id": 0,
129
- "rms_norm_eps": 1e-06,
130
- "rope_parameters": {
131
- "full_attention": {
132
- "partial_rotary_factor": 0.25,
133
- "rope_theta": 1000000.0,
134
- "rope_type": "proportional"
135
- },
136
- "sliding_attention": {
137
- "rope_theta": 10000.0,
138
- "rope_type": "default"
139
- }
140
- },
141
- "sliding_window": 512,
142
- "tie_word_embeddings": true,
143
- "top_k_experts": null,
144
- "use_bidirectional_attention": null,
145
- "use_cache": true,
146
- "use_double_wide_mlp": false,
147
- "vocab_size": 262144,
148
- "vocab_size_per_layer_input": 262144
149
  },
 
150
  "tie_word_embeddings": true,
151
- "unsloth_fixed": true,
152
- "unsloth_version": "2026.4.2",
153
- "video_token_id": 258884,
154
- "vision_config": {
155
- "_name_or_path": "",
156
- "architectures": null,
157
- "attention_bias": false,
158
- "attention_dropout": 0.0,
159
- "chunk_size_feed_forward": 0,
160
- "default_output_length": 280,
161
- "torch_dtype": "bfloat16",
162
- "global_head_dim": 64,
163
- "head_dim": 64,
164
- "hidden_activation": "gelu_pytorch_tanh",
165
- "hidden_size": 768,
166
- "id2label": {
167
- "0": "LABEL_0",
168
- "1": "LABEL_1"
169
- },
170
- "initializer_range": 0.02,
171
- "intermediate_size": 3072,
172
- "is_encoder_decoder": false,
173
- "label2id": {
174
- "LABEL_0": 0,
175
- "LABEL_1": 1
176
- },
177
- "max_position_embeddings": 131072,
178
- "model_type": "gemma4_vision",
179
- "num_attention_heads": 12,
180
- "num_hidden_layers": 16,
181
- "num_key_value_heads": 12,
182
- "output_attentions": false,
183
- "output_hidden_states": false,
184
- "patch_size": 16,
185
- "pooling_kernel_size": 3,
186
- "position_embedding_size": 10240,
187
- "problem_type": null,
188
- "return_dict": true,
189
- "rms_norm_eps": 1e-06,
190
- "rope_parameters": {
191
- "rope_theta": 100.0,
192
- "rope_type": "default"
193
- },
194
- "standardize": false,
195
- "use_clipped_linears": true
 
 
 
 
 
196
  },
197
- "vision_soft_tokens_per_image": 280
198
- }
 
 
 
 
1
  {
2
+ "architectures": [
3
+ "Gemma4ForConditionalGeneration"
4
+ ],
5
+ "audio_config": {
6
+ "_name_or_path": "",
7
+ "architectures": null,
8
+ "attention_chunk_size": 12,
9
+ "attention_context_left": 13,
10
+ "attention_context_right": 0,
11
+ "attention_invalid_logits_value": -1000000000.0,
12
+ "attention_logit_cap": 50.0,
13
+ "chunk_size_feed_forward": 0,
14
+ "conv_kernel_size": 5,
15
+ "dtype": "bfloat16",
16
+ "gradient_clipping": 10000000000.0,
17
+ "hidden_act": "silu",
18
+ "hidden_size": 1024,
19
+ "id2label": {
20
+ "0": "LABEL_0",
21
+ "1": "LABEL_1"
22
+ },
23
+ "initializer_range": 0.02,
24
+ "is_encoder_decoder": false,
25
+ "label2id": {
26
+ "LABEL_0": 0,
27
+ "LABEL_1": 1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  },
29
+ "model_type": "gemma4_audio",
30
+ "num_attention_heads": 8,
31
+ "num_hidden_layers": 12,
32
+ "output_attentions": false,
33
+ "output_hidden_states": false,
34
+ "output_proj_dims": 1536,
35
+ "problem_type": null,
36
+ "residual_weight": 0.5,
37
+ "return_dict": true,
38
+ "rms_norm_eps": 1e-06,
39
+ "subsampling_conv_channels": [
40
+ 128,
41
+ 32
42
+ ],
43
+ "use_clipped_linears": true
44
+ },
45
+ "audio_token_id": 258881,
46
+ "boa_token_id": 256000,
47
+ "boi_token_id": 255999,
48
+ "dtype": "bfloat16",
49
+ "eoa_token_id": 258883,
50
+ "eoa_token_index": 258883,
51
+ "eoi_token_id": 258882,
52
+ "eos_token_id": 106,
53
+ "image_token_id": 258880,
54
+ "initializer_range": 0.02,
55
+ "model_type": "gemma4",
56
+ "pad_token_id": 0,
57
+ "text_config": {
58
+ "attention_bias": false,
59
+ "attention_dropout": 0.0,
60
+ "attention_k_eq_v": false,
61
+ "bos_token_id": 2,
62
+ "dtype": "bfloat16",
63
+ "enable_moe_block": false,
64
+ "eos_token_id": 1,
65
+ "expert_intermediate_size": null,
66
+ "final_logit_softcapping": 30.0,
67
+ "global_head_dim": 512,
68
+ "head_dim": 256,
69
+ "hidden_activation": "gelu_pytorch_tanh",
70
+ "hidden_size": 2560,
71
+ "hidden_size_per_layer_input": 256,
72
  "initializer_range": 0.02,
73
+ "intermediate_size": 10240,
74
+ "layer_types": [
75
+ "sliding_attention",
76
+ "sliding_attention",
77
+ "sliding_attention",
78
+ "sliding_attention",
79
+ "sliding_attention",
80
+ "full_attention",
81
+ "sliding_attention",
82
+ "sliding_attention",
83
+ "sliding_attention",
84
+ "sliding_attention",
85
+ "sliding_attention",
86
+ "full_attention",
87
+ "sliding_attention",
88
+ "sliding_attention",
89
+ "sliding_attention",
90
+ "sliding_attention",
91
+ "sliding_attention",
92
+ "full_attention",
93
+ "sliding_attention",
94
+ "sliding_attention",
95
+ "sliding_attention",
96
+ "sliding_attention",
97
+ "sliding_attention",
98
+ "full_attention",
99
+ "sliding_attention",
100
+ "sliding_attention",
101
+ "sliding_attention",
102
+ "sliding_attention",
103
+ "sliding_attention",
104
+ "full_attention",
105
+ "sliding_attention",
106
+ "sliding_attention",
107
+ "sliding_attention",
108
+ "sliding_attention",
109
+ "sliding_attention",
110
+ "full_attention",
111
+ "sliding_attention",
112
+ "sliding_attention",
113
+ "sliding_attention",
114
+ "sliding_attention",
115
+ "sliding_attention",
116
+ "full_attention"
117
+ ],
118
+ "max_position_embeddings": 131072,
119
+ "model_type": "gemma4_text",
120
+ "moe_intermediate_size": null,
121
+ "num_attention_heads": 8,
122
+ "num_experts": null,
123
+ "num_global_key_value_heads": null,
124
+ "num_hidden_layers": 42,
125
+ "num_key_value_heads": 2,
126
+ "num_kv_shared_layers": 18,
127
  "pad_token_id": 0,
128
+ "rms_norm_eps": 1e-06,
129
+ "rope_parameters": {
130
+ "full_attention": {
131
+ "partial_rotary_factor": 0.25,
132
+ "rope_theta": 1000000.0,
133
+ "rope_type": "proportional"
134
+ },
135
+ "sliding_attention": {
136
+ "rope_theta": 10000.0,
137
+ "rope_type": "default"
138
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  },
140
+ "sliding_window": 512,
141
  "tie_word_embeddings": true,
142
+ "top_k_experts": null,
143
+ "use_bidirectional_attention": null,
144
+ "use_cache": true,
145
+ "use_double_wide_mlp": false,
146
+ "vocab_size": 262144,
147
+ "vocab_size_per_layer_input": 262144
148
+ },
149
+ "tie_word_embeddings": true,
150
+ "transformers_version": "5.8.1",
151
+ "unsloth_fixed": true,
152
+ "video_token_id": 258884,
153
+ "vision_config": {
154
+ "_name_or_path": "",
155
+ "architectures": null,
156
+ "attention_bias": false,
157
+ "attention_dropout": 0.0,
158
+ "chunk_size_feed_forward": 0,
159
+ "default_output_length": 280,
160
+ "dtype": "bfloat16",
161
+ "global_head_dim": 64,
162
+ "head_dim": 64,
163
+ "hidden_activation": "gelu_pytorch_tanh",
164
+ "hidden_size": 768,
165
+ "id2label": {
166
+ "0": "LABEL_0",
167
+ "1": "LABEL_1"
168
+ },
169
+ "initializer_range": 0.02,
170
+ "intermediate_size": 3072,
171
+ "is_encoder_decoder": false,
172
+ "label2id": {
173
+ "LABEL_0": 0,
174
+ "LABEL_1": 1
175
+ },
176
+ "max_position_embeddings": 131072,
177
+ "model_type": "gemma4_vision",
178
+ "num_attention_heads": 12,
179
+ "num_hidden_layers": 16,
180
+ "num_key_value_heads": 12,
181
+ "output_attentions": false,
182
+ "output_hidden_states": false,
183
+ "patch_size": 16,
184
+ "pooling_kernel_size": 3,
185
+ "position_embedding_size": 10240,
186
+ "problem_type": null,
187
+ "return_dict": true,
188
+ "rms_norm_eps": 1e-06,
189
+ "rope_parameters": {
190
+ "rope_theta": 100.0,
191
+ "rope_type": "default"
192
  },
193
+ "standardize": false,
194
+ "use_clipped_linears": true
195
+ },
196
+ "vision_soft_tokens_per_image": 280
197
+ }
generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 1,
6
+ 106,
7
+ 50
8
+ ],
9
+ "pad_token_id": 0,
10
+ "temperature": 1.0,
11
+ "top_k": 64,
12
+ "top_p": 0.95,
13
+ "transformers_version": "5.8.1"
14
+ }
model-00002-of-00004.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6d0cef83d80071cd15e9db396e55dd31843a590fd99d56c06caf693d1ad18647
3
- size 4994573930
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b4e06448a42881ca44c63a47e27ff15253fa85c26d6bdd8d7960dd523080c31
3
+ size 4994573962
model-00003-of-00004.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6ad991146584e7062f49ed1890dd6d770effc71fabe86be96c1663fdbbebc70f
3
- size 4996204598
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:25a2d50af7196b1691d00cc45f7819eedf06e6929fb62acfdaeeffe5529886f7
3
+ size 4996204630
model-00004-of-00004.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:e055265787e9f72378f01e5b0e48b3c57a062a2e0ae7331bc5db18442621e08e
3
- size 254550404
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8080cb1ab73a91528449fc238665f6a2938583e5f1dc877c099292a1f31f6144
3
+ size 254550436
processor_config.json CHANGED
@@ -13,7 +13,7 @@
13
  "max_frequency": 8000.0,
14
  "mel_floor": 0.001,
15
  "min_frequency": 0.0,
16
- "padding_side": "left",
17
  "padding_value": 0.0,
18
  "per_bin_mean": null,
19
  "per_bin_stddev": null,
 
13
  "max_frequency": 8000.0,
14
  "mel_floor": 0.001,
15
  "min_frequency": 0.0,
16
+ "padding_side": "right",
17
  "padding_value": 0.0,
18
  "per_bin_mean": null,
19
  "per_bin_stddev": null,
tokenizer_config.json CHANGED
@@ -92,6 +92,5 @@
92
  "str_token": "<|tool_response>",
93
  "think_token": "<|think|>",
94
  "tokenizer_class": "GemmaTokenizer",
95
- "unk_token": "<unk>",
96
- "chat_template": "{%- macro format_parameters(properties, required, filter_keys=false) -%}\n {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in properties | dictsort -%}\n {%- set add_comma = false -%}\n {%- if not filter_keys or key not in standard_keys -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {{ key }}:{\n {%- if value['description'] -%}\n description:<|\"|>{{ value['description'] }}<|\"|>\n {%- set add_comma = true -%}\n {%- endif -%}\n {%- if value['type'] | upper == 'STRING' -%}\n {%- if value['enum'] -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n enum:{{ format_argument(value['enum']) }}\n {%- endif -%}\n {%- elif value['type'] | upper == 'ARRAY' -%}\n {%- if value['items'] is mapping and value['items'] -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n items:{\n {%- set ns_items = namespace(found_first=false) -%}\n {%- for item_key, item_value in value['items'] | dictsort -%}\n {%- if item_value is not none -%}\n {%- if ns_items.found_first %},{% endif -%}\n {%- set ns_items.found_first = true -%}\n {%- if item_key == 'properties' -%}\n properties:{\n {%- if item_value is mapping -%}\n {{- format_parameters(item_value, value['items']['required'] | default([])) -}}\n {%- endif -%}\n }\n {%- elif item_key == 'required' -%}\n required:[\n {%- for req_item in item_value -%}\n <|\"|>{{- req_item -}}<|\"|>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- elif item_key == 'type' -%}\n {%- if item_value is string -%}\n type:{{ format_argument(item_value | upper) }}\n {%- else -%}\n type:{{ format_argument(item_value | map('upper') | list) }}\n {%- endif -%}\n {%- else -%}\n {{ item_key }}:{{ format_argument(item_value) }}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n }\n {%- endif -%}\n {%- endif -%}\n {%- if value['nullable'] %}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n nullable:true\n {%- endif -%}\n {%- if value['type'] | upper == 'OBJECT' -%}\n {%- if value['properties'] is defined and value['properties'] is mapping -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n properties:{\n {{- format_parameters(value['properties'], value['required'] | default([])) -}}\n }\n {%- elif value is mapping -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n properties:{\n {{- format_parameters(value, value['required'] | default([]), filter_keys=true) -}}\n }\n {%- endif -%}\n {%- if value['required'] -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n required:[\n {%- for item in value['required'] | default([]) -%}\n <|\"|>{{- item -}}<|\"|>\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n ]\n {%- endif -%}\n {%- endif -%}\n {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}\n type:<|\"|>{{ value['type'] | upper }}<|\"|>}\n {%- endif -%}\n {%- endfor -%}\n{%- endmacro -%}\n{%- macro format_function_declaration(tool_data) -%}\n declaration:{{- tool_data['function']['name'] -}}{description:<|\"|>{{- tool_data['function']['description'] -}}<|\"|>\n {%- set params = tool_data['function']['parameters'] -%}\n {%- if params -%}\n ,parameters:{\n {%- if params['properties'] -%}\n properties:{ {{- format_parameters(params['properties'], params['required']) -}} },\n {%- endif -%}\n {%- if params['required'] -%}\n required:[\n {%- for item in params['required'] -%}\n <|\"|>{{- item -}}<|\"|>\n {{- ',' if not loop.last -}}\n {%- endfor -%}\n ],\n {%- endif -%}\n {%- if params['type'] -%}\n type:<|\"|>{{- params['type'] | upper -}}<|\"|>}\n {%- endif -%}\n {%- endif -%}\n {%- if 'response' in tool_data['function'] -%}\n {%- set response_declaration = tool_data['function']['response'] -%}\n ,response:{\n {%- if response_declaration['description'] -%}\n description:<|\"|>{{- response_declaration['description'] -}}<|\"|>,\n {%- endif -%}\n {%- if response_declaration['type'] | upper == 'OBJECT' -%}\n type:<|\"|>{{- response_declaration['type'] | upper -}}<|\"|>}\n {%- endif -%}\n {%- endif -%}\n }\n{%- endmacro -%}\n{%- macro format_argument(argument, escape_keys=True) -%}\n {%- if argument is string -%}\n {{- '<|\"|>' + argument + '<|\"|>' -}}\n {%- elif argument is boolean -%}\n {{- 'true' if argument else 'false' -}}\n {%- elif argument is mapping -%}\n {{- '{' -}}\n {%- set ns = namespace(found_first=false) -%}\n {%- for key, value in argument | dictsort -%}\n {%- if ns.found_first %},{% endif -%}\n {%- set ns.found_first = true -%}\n {%- if escape_keys -%}\n {{- '<|\"|>' + key + '<|\"|>' -}}\n {%- else -%}\n {{- key -}}\n {%- endif -%}\n :{{- format_argument(value, escape_keys=escape_keys) -}}\n {%- endfor -%}\n {{- '}' -}}\n {%- elif argument is sequence -%}\n {{- '[' -}}\n {%- for item in argument -%}\n {{- format_argument(item, escape_keys=escape_keys) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- ']' -}}\n {%- else -%}\n {{- argument -}}\n {%- endif -%}\n{%- endmacro -%}\n{%- macro strip_thinking(text) -%}\n {%- set ns = namespace(result='') -%}\n {%- for part in text.split('<channel|>') -%}\n {%- if '<|channel>' in part -%}\n {%- set ns.result = ns.result + part.split('<|channel>')[0] -%}\n {%- else -%}\n {%- set ns.result = ns.result + part -%}\n {%- endif -%}\n {%- endfor -%}\n {{- ns.result | trim -}}\n{%- endmacro -%}\n\n{%- macro format_tool_response_block(tool_name, response) -%}\n {{- '<|tool_response>' -}}\n {%- if response is mapping -%}\n {{- 'response:' + tool_name + '{' -}}\n {%- for key, value in response | dictsort -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- if not loop.last %},{% endif -%}\n {%- endfor -%}\n {{- '}' -}}\n {%- else -%}\n {{- 'response:' + tool_name + '{value:' + format_argument(response, escape_keys=False) + '}' -}}\n {%- endif -%}\n {{- '<tool_response|>' -}}\n{%- endmacro -%}\n\n{%- set ns = namespace(prev_message_type=None) -%}\n{%- set loop_messages = messages -%}\n{{- bos_token -}}\n{#- Handle System/Tool Definitions Block -#}\n{%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}\n {{- '<|turn>system\\n' -}}\n {#- Inject Thinking token at the very top of the FIRST system turn -#}\n {%- if enable_thinking is defined and enable_thinking -%}\n {{- '<|think|>\\n' -}}\n {%- set ns.prev_message_type = 'think' -%}\n {%- endif -%}\n {%- if messages[0]['role'] in ['system', 'developer'] -%}\n {%- if messages[0]['content'] is string -%}\n {{- messages[0]['content'] | trim -}}\n {%- elif messages[0]['content'] is sequence -%}\n {%- for item in messages[0]['content'] -%}\n {{- item['text'] | trim + ' '-}}\n {%- endfor -%}\n {%- endif -%}\n {%- set loop_messages = messages[1:] -%}\n {%- endif -%}\n {%- if tools -%}\n {%- for tool in tools %}\n {{- '<|tool>' -}}\n {{- format_function_declaration(tool) | trim -}}\n {{- '<tool|>' -}}\n {%- endfor %}\n {%- set ns.prev_message_type = 'tool' -%}\n {%- endif -%}\n {{- '<turn|>\\n' -}}\n{%- endif %}\n\n{#- Pre-scan: find last user message index for reasoning guard -#}\n{%- set ns_turn = namespace(last_user_idx=-1) -%}\n{%- for i in range(loop_messages | length) -%}\n {%- if loop_messages[i]['role'] == 'user' -%}\n {%- set ns_turn.last_user_idx = i -%}\n {%- endif -%}\n{%- endfor -%}\n\n{#- Loop through messages -#}\n{%- for message in loop_messages -%}\n {%- if message['role'] != 'tool' -%}\n {%- set ns.prev_message_type = None -%}\n {%- set role = 'model' if message['role'] == 'assistant' else message['role'] -%}\n {#- Detect continuation: suppress duplicate <|turn>model when previous non-tool message was also assistant -#}\n {%- set prev_nt = namespace(role=None, found=false) -%}\n {%- if loop.index0 > 0 -%}\n {%- for j in range(loop.index0 - 1, -1, -1) -%}\n {%- if not prev_nt.found -%}\n {%- if loop_messages[j]['role'] != 'tool' -%}\n {%- set prev_nt.role = loop_messages[j]['role'] -%}\n {%- set prev_nt.found = true -%}\n {%- endif -%}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {%- set continue_same_model_turn = (role == 'model' and prev_nt.role == 'assistant') -%}\n {%- if not continue_same_model_turn -%}\n {{- '<|turn>' + role + '\\n' }}\n {%- endif -%}\n\n {#- Render reasoning/reasoning_content as thinking channel -#}\n {%- set thinking_text = message.get('reasoning') or message.get('reasoning_content') -%}\n {%- if thinking_text and loop.index0 > ns_turn.last_user_idx and message.get('tool_calls') -%}\n {{- '<|channel>thought\\n' + thinking_text + '\\n<channel|>' -}}\n {%- endif -%}\n\n {%- if message['tool_calls'] -%}\n {%- for tool_call in message['tool_calls'] -%}\n {%- set function = tool_call['function'] -%}\n {{- '<|tool_call>call:' + function['name'] + '{' -}}\n {%- if function['arguments'] is mapping -%}\n {%- set ns_args = namespace(found_first=false) -%}\n {%- for key, value in function['arguments'] | dictsort -%}\n {%- if ns_args.found_first %},{% endif -%}\n {%- set ns_args.found_first = true -%}\n {{- key -}}:{{- format_argument(value, escape_keys=False) -}}\n {%- endfor -%}\n {%- elif function['arguments'] is string -%}\n {{- function['arguments'] -}}\n {%- endif -%}\n {{- '}<tool_call|>' -}}\n {%- endfor -%}\n {%- set ns.prev_message_type = 'tool_call' -%}\n {%- endif -%}\n\n {%- set ns_tr_out = namespace(flag=false) -%}\n {%- if message.get('tool_responses') -%}\n {#- Legacy: tool_responses embedded on the assistant message (Google/Gemma native) -#}\n {%- for tool_response in message['tool_responses'] -%}\n {{- format_tool_response_block(tool_response['name'] | default('unknown'), tool_response['response']) -}}\n {%- set ns_tr_out.flag = true -%}\n {%- set ns.prev_message_type = 'tool_response' -%}\n {%- endfor -%}\n {%- elif message.get('tool_calls') -%}\n {#- OpenAI Chat Completions: forward-scan consecutive role:tool messages -#}\n {%- set ns_tool_scan = namespace(stopped=false) -%}\n {%- for k in range(loop.index0 + 1, loop_messages | length) -%}\n {%- if ns_tool_scan.stopped -%}\n {%- elif loop_messages[k]['role'] != 'tool' -%}\n {%- set ns_tool_scan.stopped = true -%}\n {%- else -%}\n {%- set follow = loop_messages[k] -%}\n {#- Resolve tool_call_id to function name -#}\n {%- set ns_tname = namespace(name=follow.get('name') | default('unknown')) -%}\n {%- for tc in message['tool_calls'] -%}\n {%- if tc.get('id') == follow.get('tool_call_id') -%}\n {%- set ns_tname.name = tc['function']['name'] -%}\n {%- endif -%}\n {%- endfor -%}\n {#- Handle content as string or content-parts array -#}\n {%- set tool_body = follow.get('content') -%}\n {%- if tool_body is string -%}\n {{- format_tool_response_block(ns_tname.name, tool_body) -}}\n {%- elif tool_body is sequence and tool_body is not string -%}\n {%- set ns_txt = namespace(s='') -%}\n {%- for part in tool_body -%}\n {%- if part.get('type') == 'text' -%}\n {%- set ns_txt.s = ns_txt.s + (part.get('text') | default('')) -%}\n {%- endif -%}\n {%- endfor -%}\n {{- format_tool_response_block(ns_tname.name, ns_txt.s) -}}\n {%- else -%}\n {{- format_tool_response_block(ns_tname.name, tool_body) -}}\n {%- endif -%}\n {%- set ns_tr_out.flag = true -%}\n {%- set ns.prev_message_type = 'tool_response' -%}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n\n {%- set captured_content -%}\n {%- if message['content'] is string -%}\n {%- if role == 'model' -%}\n {{- strip_thinking(message['content']) -}}\n {%- else -%}\n {{- message['content'] | trim -}}\n {%- endif -%}\n {%- elif message['content'] is sequence -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'text' -%}\n {%- if role == 'model' -%}\n {{- strip_thinking(item['text']) -}}\n {%- else -%}\n {{- item['text'] | trim -}}\n {%- endif -%}\n {%- elif item['type'] == 'image' -%}\n {{- '<|image|>' -}}\n {%- set ns.prev_message_type = 'image' -%}\n {%- elif item['type'] == 'audio' -%}\n {{- '<|audio|>' -}}\n {%- set ns.prev_message_type = 'audio' -%}\n {%- elif item['type'] == 'video' -%}\n {{- '<|video|>' -}}\n {%- set ns.prev_message_type = 'video' -%}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n {%- endset -%}\n\n {{- captured_content -}}\n {%- set has_content = captured_content | trim | length > 0 -%}\n\n {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}\n {{- '<|tool_response>' -}}\n {%- elif not (ns_tr_out.flag and not has_content) -%}\n {{- '<turn|>\\n' -}}\n {%- endif -%}\n {%- endif -%}\n{%- endfor -%}\n\n{%- if add_generation_prompt -%}\n {%- if ns.prev_message_type != 'tool_response' and ns.prev_message_type != 'tool_call' -%}\n {{- '<|turn>model\\n' -}}\n {%- endif -%}\n{%- endif -%}"
97
- }
 
92
  "str_token": "<|tool_response>",
93
  "think_token": "<|think|>",
94
  "tokenizer_class": "GemmaTokenizer",
95
+ "unk_token": "<unk>"
96
+ }