albertvillanova HF Staff commited on
Commit
8b4dab8
·
verified ·
1 Parent(s): 906c384

Upload Gemma4ForConditionalGeneration

Browse files
chat_template.jinja CHANGED
@@ -1,9 +1,9 @@
1
- {%- macro format_parameters(properties, required) -%}
2
  {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
3
  {%- set ns = namespace(found_first=false) -%}
4
  {%- for key, value in properties | dictsort -%}
5
  {%- set add_comma = false -%}
6
- {%- if key not in standard_keys -%}
7
  {%- if ns.found_first %},{% endif -%}
8
  {%- set ns.found_first = true -%}
9
  {{ key }}:{
@@ -65,7 +65,7 @@
65
  {%- elif value is mapping -%}
66
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
67
  properties:{
68
- {{- format_parameters(value, value['required'] | default([])) -}}
69
  }
70
  {%- endif -%}
71
  {%- if value['required'] -%}
@@ -178,18 +178,21 @@
178
  {#- Handle System/Tool Definitions Block -#}
179
  {%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}
180
  {{- '<|turn>system\n' -}}
181
-
182
  {#- Inject Thinking token at the very top of the FIRST system turn -#}
183
  {%- if enable_thinking is defined and enable_thinking -%}
184
  {{- '<|think|>\n' -}}
185
  {%- set ns.prev_message_type = 'think' -%}
186
  {%- endif -%}
187
-
188
  {%- if messages[0]['role'] in ['system', 'developer'] -%}
189
- {{- messages[0]['content'] | trim -}}
 
 
 
 
 
 
190
  {%- set loop_messages = messages[1:] -%}
191
  {%- endif -%}
192
-
193
  {%- if tools -%}
194
  {%- for tool in tools %}
195
  {{- '<|tool>' -}}
@@ -198,7 +201,6 @@
198
  {%- endfor %}
199
  {%- set ns.prev_message_type = 'tool' -%}
200
  {%- endif -%}
201
-
202
  {{- '<turn|>\n' -}}
203
  {%- endif %}
204
 
@@ -302,6 +304,7 @@
302
  {%- endfor -%}
303
  {%- endif -%}
304
 
 
305
  {%- if message['content'] is string -%}
306
  {%- if role == 'model' -%}
307
  {{- strip_thinking(message['content']) -}}
@@ -328,10 +331,14 @@
328
  {%- endif -%}
329
  {%- endfor -%}
330
  {%- endif -%}
 
 
 
 
331
 
332
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
333
  {{- '<|tool_response>' -}}
334
- {%- elif not (ns_tr_out.flag and not message.get('content')) -%}
335
  {{- '<turn|>\n' -}}
336
  {%- endif -%}
337
  {%- endif -%}
 
1
+ {%- macro format_parameters(properties, required, filter_keys=false) -%}
2
  {%- set standard_keys = ['description', 'type', 'properties', 'required', 'nullable'] -%}
3
  {%- set ns = namespace(found_first=false) -%}
4
  {%- for key, value in properties | dictsort -%}
5
  {%- set add_comma = false -%}
6
+ {%- if not filter_keys or key not in standard_keys -%}
7
  {%- if ns.found_first %},{% endif -%}
8
  {%- set ns.found_first = true -%}
9
  {{ key }}:{
 
65
  {%- elif value is mapping -%}
66
  {%- if add_comma %},{%- else -%} {%- set add_comma = true -%} {% endif -%}
67
  properties:{
68
+ {{- format_parameters(value, value['required'] | default([]), filter_keys=true) -}}
69
  }
70
  {%- endif -%}
71
  {%- if value['required'] -%}
 
178
  {#- Handle System/Tool Definitions Block -#}
179
  {%- if (enable_thinking is defined and enable_thinking) or tools or messages[0]['role'] in ['system', 'developer'] -%}
180
  {{- '<|turn>system\n' -}}
 
181
  {#- Inject Thinking token at the very top of the FIRST system turn -#}
182
  {%- if enable_thinking is defined and enable_thinking -%}
183
  {{- '<|think|>\n' -}}
184
  {%- set ns.prev_message_type = 'think' -%}
185
  {%- endif -%}
 
186
  {%- if messages[0]['role'] in ['system', 'developer'] -%}
187
+ {%- if messages[0]['content'] is string -%}
188
+ {{- messages[0]['content'] | trim -}}
189
+ {%- elif messages[0]['content'] is sequence -%}
190
+ {%- for item in messages[0]['content'] -%}
191
+ {{- item['text'] | trim + ' '-}}
192
+ {%- endfor -%}
193
+ {%- endif -%}
194
  {%- set loop_messages = messages[1:] -%}
195
  {%- endif -%}
 
196
  {%- if tools -%}
197
  {%- for tool in tools %}
198
  {{- '<|tool>' -}}
 
201
  {%- endfor %}
202
  {%- set ns.prev_message_type = 'tool' -%}
203
  {%- endif -%}
 
204
  {{- '<turn|>\n' -}}
205
  {%- endif %}
206
 
 
304
  {%- endfor -%}
305
  {%- endif -%}
306
 
307
+ {%- set captured_content -%}
308
  {%- if message['content'] is string -%}
309
  {%- if role == 'model' -%}
310
  {{- strip_thinking(message['content']) -}}
 
331
  {%- endif -%}
332
  {%- endfor -%}
333
  {%- endif -%}
334
+ {%- endset -%}
335
+
336
+ {{- captured_content -}}
337
+ {%- set has_content = captured_content | trim | length > 0 -%}
338
 
339
  {%- if ns.prev_message_type == 'tool_call' and not ns_tr_out.flag -%}
340
  {{- '<|tool_response>' -}}
341
+ {%- elif not (ns_tr_out.flag and not has_content) -%}
342
  {{- '<turn|>\n' -}}
343
  {%- endif -%}
344
  {%- endif -%}
config.json CHANGED
@@ -33,7 +33,7 @@
33
  "hidden_size": 16,
34
  "hidden_size_per_layer_input": 16,
35
  "initializer_range": 0.02,
36
- "intermediate_size": 6144,
37
  "layer_types": [
38
  "sliding_attention",
39
  "full_attention"
@@ -70,7 +70,7 @@
70
  "vocab_size_per_layer_input": 262144
71
  },
72
  "tie_word_embeddings": true,
73
- "transformers_version": "5.5.0",
74
  "video_token_id": 258884,
75
  "vision_config": {
76
  "_name_or_path": "",
@@ -78,7 +78,7 @@
78
  "attention_bias": false,
79
  "attention_dropout": 0.0,
80
  "chunk_size_feed_forward": 0,
81
- "default_output_length": 280,
82
  "dtype": "bfloat16",
83
  "embed_dim": 64,
84
  "global_head_dim": 64,
@@ -90,7 +90,7 @@
90
  "1": "LABEL_1"
91
  },
92
  "initializer_range": 0.02,
93
- "intermediate_size": 3072,
94
  "is_encoder_decoder": false,
95
  "label2id": {
96
  "LABEL_0": 0,
@@ -105,7 +105,7 @@
105
  "output_hidden_states": false,
106
  "patch_size": 16,
107
  "pooling_kernel_size": 3,
108
- "position_embedding_size": 10240,
109
  "problem_type": null,
110
  "return_dict": true,
111
  "rms_norm_eps": 1e-06,
 
33
  "hidden_size": 16,
34
  "hidden_size_per_layer_input": 16,
35
  "initializer_range": 0.02,
36
+ "intermediate_size": 32,
37
  "layer_types": [
38
  "sliding_attention",
39
  "full_attention"
 
70
  "vocab_size_per_layer_input": 262144
71
  },
72
  "tie_word_embeddings": true,
73
+ "transformers_version": "5.6.0",
74
  "video_token_id": 258884,
75
  "vision_config": {
76
  "_name_or_path": "",
 
78
  "attention_bias": false,
79
  "attention_dropout": 0.0,
80
  "chunk_size_feed_forward": 0,
81
+ "default_output_length": 70,
82
  "dtype": "bfloat16",
83
  "embed_dim": 64,
84
  "global_head_dim": 64,
 
90
  "1": "LABEL_1"
91
  },
92
  "initializer_range": 0.02,
93
+ "intermediate_size": 32,
94
  "is_encoder_decoder": false,
95
  "label2id": {
96
  "LABEL_0": 0,
 
105
  "output_hidden_states": false,
106
  "patch_size": 16,
107
  "pooling_kernel_size": 3,
108
+ "position_embedding_size": 630,
109
  "problem_type": null,
110
  "return_dict": true,
111
  "rms_norm_eps": 1e-06,
generation_config.json CHANGED
@@ -10,5 +10,5 @@
10
  "temperature": 1.0,
11
  "top_k": 64,
12
  "top_p": 0.95,
13
- "transformers_version": "5.5.0"
14
  }
 
10
  "temperature": 1.0,
11
  "top_k": 64,
12
  "top_p": 0.95,
13
+ "transformers_version": "5.6.0"
14
  }
model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:624ce981227809cfac5aebdb3270118ef11801c6366edd5604ab23a10af513fc
3
- size 27787476
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e867f4cc867e66065215e0e5dfa761b7e715cf3dfcf2c5938da29f395fbe7054
3
+ size 25415228
processor_config.json CHANGED
@@ -33,19 +33,19 @@
33
  0.0
34
  ],
35
  "image_processor_type": "Gemma4ImageProcessor",
36
- "image_seq_length": 280,
37
  "image_std": [
38
  1.0,
39
  1.0,
40
  1.0
41
  ],
42
- "max_soft_tokens": 280,
43
  "patch_size": 16,
44
  "pooling_kernel_size": 3,
45
  "resample": 3,
46
  "rescale_factor": 0.00392156862745098
47
  },
48
- "image_seq_length": 280,
49
  "processor_class": "Gemma4Processor",
50
  "video_processor": {
51
  "do_convert_rgb": true,
 
33
  0.0
34
  ],
35
  "image_processor_type": "Gemma4ImageProcessor",
36
+ "image_seq_length": 70,
37
  "image_std": [
38
  1.0,
39
  1.0,
40
  1.0
41
  ],
42
+ "max_soft_tokens": 70,
43
  "patch_size": 16,
44
  "pooling_kernel_size": 3,
45
  "resample": 3,
46
  "rescale_factor": 0.00392156862745098
47
  },
48
+ "image_seq_length": 70,
49
  "processor_class": "Gemma4Processor",
50
  "video_processor": {
51
  "do_convert_rgb": true,
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:cc8d3a0ce36466ccc1278bf987df5f71db1719b9ca6b4118264f45cb627bfe0f
3
- size 32169626
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2619fe11b50dbed06ac443c51d757b354d0b62d64baa514404d4e84e6713519
3
+ size 32169780
tokenizer_config.json CHANGED
@@ -16,9 +16,12 @@
16
  "extra_special_tokens": [
17
  "<|video|>"
18
  ],
 
19
  "image_token": "<|image|>",
20
  "is_local": false,
 
21
  "mask_token": "<mask>",
 
22
  "model_max_length": 1000000000000000019884624838656,
23
  "model_specific_special_tokens": {
24
  "audio_token": "<|audio|>",
 
16
  "extra_special_tokens": [
17
  "<|video|>"
18
  ],
19
+ "image_seq_length": 70,
20
  "image_token": "<|image|>",
21
  "is_local": false,
22
+ "local_files_only": false,
23
  "mask_token": "<mask>",
24
+ "max_soft_tokens": 70,
25
  "model_max_length": 1000000000000000019884624838656,
26
  "model_specific_special_tokens": {
27
  "audio_token": "<|audio|>",