Aratako commited on
Commit
4b855c2
·
verified ·
1 Parent(s): 7a3f3dc

Add files using upload-large-folder tool

Browse files
config.json ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Gemma4AudioEncoder"
4
+ ],
5
+ "auto_map": {
6
+ "AutoModel": "gemma4_audio_encoder.Gemma4AudioEncoder"
7
+ },
8
+ "audio_config": {
9
+ "_name_or_path": "",
10
+ "architectures": null,
11
+ "attention_chunk_size": 12,
12
+ "attention_context_left": 13,
13
+ "attention_context_right": 0,
14
+ "attention_invalid_logits_value": -1000000000.0,
15
+ "attention_logit_cap": 50.0,
16
+ "chunk_size_feed_forward": 0,
17
+ "conv_kernel_size": 5,
18
+ "dtype": "bfloat16",
19
+ "gradient_clipping": 10000000000.0,
20
+ "hidden_act": "silu",
21
+ "hidden_size": 1024,
22
+ "id2label": {
23
+ "0": "LABEL_0",
24
+ "1": "LABEL_1"
25
+ },
26
+ "initializer_range": 0.02,
27
+ "is_encoder_decoder": false,
28
+ "label2id": {
29
+ "LABEL_0": 0,
30
+ "LABEL_1": 1
31
+ },
32
+ "model_type": "gemma4_audio",
33
+ "num_attention_heads": 8,
34
+ "num_hidden_layers": 12,
35
+ "output_attentions": false,
36
+ "output_hidden_states": false,
37
+ "output_proj_dims": 1536,
38
+ "problem_type": null,
39
+ "residual_weight": 0.5,
40
+ "return_dict": true,
41
+ "rms_norm_eps": 1e-06,
42
+ "subsampling_conv_channels": [
43
+ 128,
44
+ 32
45
+ ],
46
+ "use_clipped_linears": true
47
+ },
48
+ "audio_token_id": 258881,
49
+ "boa_token_id": 256000,
50
+ "boi_token_id": 255999,
51
+ "dtype": "bfloat16",
52
+ "eoa_token_id": 258883,
53
+ "eoa_token_index": 258883,
54
+ "eoi_token_id": 258882,
55
+ "eos_token_id": [
56
+ 1,
57
+ 106
58
+ ],
59
+ "image_token_id": 258880,
60
+ "initializer_range": 0.02,
61
+ "model_type": "gemma4",
62
+ "text_config": {
63
+ "attention_bias": false,
64
+ "attention_dropout": 0.0,
65
+ "attention_k_eq_v": false,
66
+ "bos_token_id": 2,
67
+ "dtype": "bfloat16",
68
+ "enable_moe_block": false,
69
+ "eos_token_id": 1,
70
+ "expert_intermediate_size": null,
71
+ "final_logit_softcapping": 30.0,
72
+ "global_head_dim": 512,
73
+ "head_dim": 256,
74
+ "hidden_activation": "gelu_pytorch_tanh",
75
+ "hidden_size": 2560,
76
+ "hidden_size_per_layer_input": 256,
77
+ "initializer_range": 0.02,
78
+ "intermediate_size": 10240,
79
+ "layer_types": [
80
+ "sliding_attention",
81
+ "sliding_attention",
82
+ "sliding_attention",
83
+ "sliding_attention",
84
+ "sliding_attention",
85
+ "full_attention",
86
+ "sliding_attention",
87
+ "sliding_attention",
88
+ "sliding_attention",
89
+ "sliding_attention",
90
+ "sliding_attention",
91
+ "full_attention",
92
+ "sliding_attention",
93
+ "sliding_attention",
94
+ "sliding_attention",
95
+ "sliding_attention",
96
+ "sliding_attention",
97
+ "full_attention",
98
+ "sliding_attention",
99
+ "sliding_attention",
100
+ "sliding_attention",
101
+ "sliding_attention",
102
+ "sliding_attention",
103
+ "full_attention",
104
+ "sliding_attention",
105
+ "sliding_attention",
106
+ "sliding_attention",
107
+ "sliding_attention",
108
+ "sliding_attention",
109
+ "full_attention",
110
+ "sliding_attention",
111
+ "sliding_attention",
112
+ "sliding_attention",
113
+ "sliding_attention",
114
+ "sliding_attention",
115
+ "full_attention",
116
+ "sliding_attention",
117
+ "sliding_attention",
118
+ "sliding_attention",
119
+ "sliding_attention",
120
+ "sliding_attention",
121
+ "full_attention"
122
+ ],
123
+ "max_position_embeddings": 131072,
124
+ "model_type": "gemma4_text",
125
+ "num_attention_heads": 8,
126
+ "num_experts": null,
127
+ "num_global_key_value_heads": null,
128
+ "num_hidden_layers": 42,
129
+ "num_key_value_heads": 2,
130
+ "num_kv_shared_layers": 18,
131
+ "pad_token_id": 0,
132
+ "rms_norm_eps": 1e-06,
133
+ "rope_parameters": {
134
+ "full_attention": {
135
+ "partial_rotary_factor": 0.25,
136
+ "rope_theta": 1000000.0,
137
+ "rope_type": "proportional"
138
+ },
139
+ "sliding_attention": {
140
+ "rope_theta": 10000.0,
141
+ "rope_type": "default"
142
+ }
143
+ },
144
+ "sliding_window": 512,
145
+ "tie_word_embeddings": true,
146
+ "top_k_experts": null,
147
+ "use_bidirectional_attention": null,
148
+ "use_cache": true,
149
+ "use_double_wide_mlp": false,
150
+ "vocab_size": 262144,
151
+ "vocab_size_per_layer_input": 262144
152
+ },
153
+ "tie_word_embeddings": true,
154
+ "transformers_version": "5.5.0.dev0",
155
+ "video_token_id": 258884,
156
+ "vision_config": {
157
+ "_name_or_path": "",
158
+ "architectures": null,
159
+ "attention_bias": false,
160
+ "attention_dropout": 0.0,
161
+ "chunk_size_feed_forward": 0,
162
+ "default_output_length": 280,
163
+ "dtype": "bfloat16",
164
+ "global_head_dim": 64,
165
+ "head_dim": 64,
166
+ "hidden_activation": "gelu_pytorch_tanh",
167
+ "hidden_size": 768,
168
+ "id2label": {
169
+ "0": "LABEL_0",
170
+ "1": "LABEL_1"
171
+ },
172
+ "initializer_range": 0.02,
173
+ "intermediate_size": 3072,
174
+ "is_encoder_decoder": false,
175
+ "label2id": {
176
+ "LABEL_0": 0,
177
+ "LABEL_1": 1
178
+ },
179
+ "max_position_embeddings": 131072,
180
+ "model_type": "gemma4_vision",
181
+ "num_attention_heads": 12,
182
+ "num_hidden_layers": 16,
183
+ "num_key_value_heads": 12,
184
+ "output_attentions": false,
185
+ "output_hidden_states": false,
186
+ "patch_size": 16,
187
+ "pooling_kernel_size": 3,
188
+ "position_embedding_size": 10240,
189
+ "problem_type": null,
190
+ "return_dict": true,
191
+ "rms_norm_eps": 1e-06,
192
+ "rope_parameters": {
193
+ "rope_theta": 100.0,
194
+ "rope_type": "default"
195
+ },
196
+ "standardize": false,
197
+ "use_clipped_linears": true
198
+ },
199
+ "vision_soft_tokens_per_image": 280
200
+ }
gemma4_audio_encoder.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import PreTrainedModel
2
+ from transformers.models.gemma4.configuration_gemma4 import Gemma4Config
3
+ from transformers.models.gemma4.modeling_gemma4 import Gemma4AudioModel, Gemma4MultimodalEmbedder
4
+
5
+
6
+ class Gemma4AudioEncoder(PreTrainedModel):
7
+ config_class = Gemma4Config
8
+
9
+ def __init__(self, config):
10
+ super().__init__(config)
11
+ self.audio_tower = Gemma4AudioModel(config.audio_config)
12
+ self.embed_audio = Gemma4MultimodalEmbedder(config.audio_config, config.text_config)
13
+ self.post_init()
14
+
15
+ def forward(self, input_features, input_features_mask, project=True, **kwargs):
16
+ """
17
+ Args:
18
+ input_features: Audio mel-spectrogram features.
19
+ input_features_mask: Attention mask for audio features.
20
+ project: If True, project to LLM embedding space (2560-dim).
21
+ If False, return audio tower output (1536-dim).
22
+
23
+ Returns:
24
+ If project=True: (projected_features, attention_mask)
25
+ If project=False: (encoder_features, attention_mask)
26
+ """
27
+ output = self.audio_tower(input_features, ~input_features_mask)
28
+ if project:
29
+ projected = self.embed_audio(inputs_embeds=output.last_hidden_state)
30
+ return projected, output.attention_mask
31
+ return output.last_hidden_state, output.attention_mask
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:78385ceb0b07b71b45e440ffd436045b14b97459e629c12f1dd70bdc7f1c71eb
3
+ size 617606056
preprocessor_config.json ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "audio_ms_per_token": 40,
3
+ "audio_seq_length": 750,
4
+ "feature_extractor": {
5
+ "dither": 0.0,
6
+ "feature_extractor_type": "Gemma4AudioFeatureExtractor",
7
+ "feature_size": 128,
8
+ "fft_length": 512,
9
+ "fft_overdrive": false,
10
+ "frame_length": 320,
11
+ "hop_length": 160,
12
+ "input_scale_factor": 1.0,
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,
20
+ "preemphasis": 0.0,
21
+ "preemphasis_htk_flavor": true,
22
+ "return_attention_mask": true,
23
+ "sampling_rate": 16000
24
+ },
25
+ "image_processor": {
26
+ "do_convert_rgb": true,
27
+ "do_normalize": false,
28
+ "do_rescale": true,
29
+ "do_resize": true,
30
+ "image_mean": [
31
+ 0.0,
32
+ 0.0,
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,
52
+ "do_normalize": true,
53
+ "do_rescale": true,
54
+ "do_resize": true,
55
+ "do_sample_frames": true,
56
+ "image_mean": [
57
+ 0.0,
58
+ 0.0,
59
+ 0.0
60
+ ],
61
+ "image_std": [
62
+ 1.0,
63
+ 1.0,
64
+ 1.0
65
+ ],
66
+ "max_soft_tokens": 70,
67
+ "num_frames": 32,
68
+ "patch_size": 16,
69
+ "pooling_kernel_size": 3,
70
+ "resample": 3,
71
+ "rescale_factor": 0.00392156862745098,
72
+ "return_metadata": false,
73
+ "video_processor_type": "Gemma4VideoProcessor"
74
+ }
75
+ }