yujiepan commited on
Commit
76de4e3
·
verified ·
1 Parent(s): bc39b30

Upload folder using huggingface_hub

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
.meta.json ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source_model": {
3
+ "name": "google/embeddinggemma-2",
4
+ "commit_id": "914f7f89142e33e77833254d9c9b90c3cef7303b"
5
+ },
6
+ "env": {
7
+ "python": "3.12.13",
8
+ "packages": {
9
+ "Pillow": "13.0.0",
10
+ "huggingface_hub": "2.3.0",
11
+ "numpy": "2.3.5",
12
+ "safetensors": "0.8.0",
13
+ "tokenizers": "0.23.3",
14
+ "torch": "2.13.0",
15
+ "transformers": "5.19.0"
16
+ },
17
+ "cuda": "13.0"
18
+ }
19
+ }
1_Pooling/config.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "embedding_dimension": 768,
3
+ "pooling_mode": "mean",
4
+ "include_prompt": true
5
+ }
2_Normalize/config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "module_input_name": "sentence_embedding",
3
+ "module_output_name": "sentence_embedding"
4
+ }
README.md ADDED
@@ -0,0 +1,394 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ base_model:
4
+ - google/embeddinggemma-2
5
+ ---
6
+
7
+ This tiny model is intended for debugging. It is randomly initialized using the configuration adapted from [google/embeddinggemma-2](https://huggingface.co/google/embeddinggemma-2).
8
+
9
+ Structural comparison with `google/embeddinggemma-2`:
10
+
11
+ | Feature | Source | Tiny |
12
+ |---|---:|---:|
13
+ | Input modalities | text, image, video, audio | same |
14
+ | Vocabulary rows | 262,144 | same |
15
+ | Output embedding dimension | 768 | same |
16
+ | Text layers | 24 | 12; two 5-sliding + 1-full cycles |
17
+ | Text width / local head dimension | 512 / 256 | 16 / 32 |
18
+ | Full-attention head dimension | 512 | 64 |
19
+ | Vision layers / width | 16 / 768 | 2 / 64 |
20
+ | Audio layers / width | 12 / 1,024 | 2 / 64 |
21
+ | PLE | projection-only | same |
22
+ | Stored precision | BF16 | BF16 |
23
+
24
+ The output embedding dimension intentionally remains 768; it is a source-model
25
+ interface rather than a vocabulary or hidden-width reduction target.
26
+
27
+ | File path | Size |
28
+ |------|------|
29
+ | model.safetensors | 12.0MB |
30
+
31
+
32
+ ### Example usage:
33
+
34
+ - Transformers (✅ verified)
35
+
36
+ ```python
37
+ import numpy as np
38
+ import torch
39
+ from PIL import Image
40
+ from transformers import AutoProcessor, EmbeddingGemma2Model
41
+ from transformers.video_utils import VideoMetadata
42
+
43
+ model_id = "tiny-random/embeddinggemma-2"
44
+ device = "cuda" if torch.cuda.is_available() else "cpu"
45
+ dtype = torch.bfloat16 if device == "cuda" else torch.float32
46
+ model = EmbeddingGemma2Model.from_pretrained(model_id, dtype=dtype).to(device).eval()
47
+ processor = AutoProcessor.from_pretrained(model_id)
48
+ image = Image.new("RGB", (64, 64), "red")
49
+ video = np.stack([np.asarray(Image.new("RGB", (64, 64), color)) for color in ("red", "green", "blue", "yellow")])
50
+ audio = np.zeros(1_600, dtype=np.float32)
51
+ text = f"{processor.image_token} {processor.video_token} {processor.audio_token}"
52
+ inputs = processor(
53
+ text=[text], images=[[image]], videos=[video], audio=[audio], return_tensors="pt",
54
+ do_sample_frames=False,
55
+ video_metadata=[VideoMetadata(total_num_frames=4, fps=2, frames_indices=[0, 1, 2, 3])],
56
+ ).to(device)
57
+ with torch.inference_mode():
58
+ embeddings = model(**inputs).last_hidden_state.mean(dim=1)
59
+ print(embeddings.shape)
60
+ ```
61
+
62
+ ### Codes to create this repo (✅ verified):
63
+
64
+ <details><summary>Click to expand</summary>
65
+
66
+ ```python
67
+ import json
68
+ from pathlib import Path
69
+ from shutil import copyfile
70
+
71
+ import torch
72
+ from huggingface_hub import hf_hub_download, list_repo_files
73
+ from transformers import AutoConfig, EmbeddingGemma2Model, set_seed
74
+
75
+ source_model_id = "google/embeddinggemma-2"
76
+ save_folder = "/tmp/tiny-random/embeddinggemma-2"
77
+ source_revision = "914f7f89142e33e77833254d9c9b90c3cef7303b"
78
+ set_seed(42)
79
+ folder = Path(save_folder)
80
+ folder.mkdir(parents=True, exist_ok=True)
81
+ raw = json.loads(Path(hf_hub_download(source_model_id, "config.json", revision=source_revision)).read_text())
82
+ text = raw["text_config"]
83
+ text.update(
84
+ hidden_size=16, hidden_size_per_layer_input=16, head_dim=32,
85
+ num_attention_heads=1, num_key_value_heads=1, intermediate_size=64,
86
+ num_hidden_layers=12,
87
+ layer_types=["sliding_attention"] * 5 + ["full_attention"] + ["sliding_attention"] * 5 + ["full_attention"],
88
+ per_layer_config={"5": {"head_dim": 64, "num_key_value_heads": 1}, "11": {"head_dim": 64, "num_key_value_heads": 1}},
89
+ )
90
+ raw["vision_config"].update(
91
+ hidden_size=64, intermediate_size=128, num_hidden_layers=2,
92
+ num_attention_heads=2, num_key_value_heads=2, head_dim=32, global_head_dim=32,
93
+ )
94
+ raw["audio_config"].update(
95
+ hidden_size=64, num_attention_heads=2, num_hidden_layers=2,
96
+ # Gemma4Audio flattens frequency bins after two stride-2 convolutions.
97
+ # Its projection formula requires the first channel count to remain 128
98
+ # for the source processor's 128-bin mel features.
99
+ output_proj_dims=64, subsampling_conv_channels=[128, 8],
100
+ )
101
+ (folder / "config.json").write_text(json.dumps(raw, indent=2), encoding="utf-8")
102
+ config = AutoConfig.from_pretrained(folder)
103
+ model = EmbeddingGemma2Model(config).to(torch.bfloat16)
104
+ with torch.no_grad():
105
+ for name, parameter in sorted(model.named_parameters()):
106
+ if not parameter.is_floating_point():
107
+ continue
108
+ if name.endswith("norm.weight"):
109
+ parameter.fill_(1)
110
+ else:
111
+ torch.nn.init.normal_(parameter, mean=0, std=0.02)
112
+ model.save_pretrained(folder, safe_serialization=True)
113
+ assets = {"1_Pooling/config.json", "2_Normalize/config.json", "chat_template.jinja", "config_sentence_transformers.json", "modules.json", "preprocessor_config.json", "processor_config.json", "sentence_bert_config.json", "tokenizer.json", "tokenizer.model", "tokenizer_config.json"}
114
+ for filename in sorted(set(list_repo_files(source_model_id, revision=source_revision)) & assets):
115
+ destination = folder / filename
116
+ destination.parent.mkdir(parents=True, exist_ok=True)
117
+ copyfile(hf_hub_download(source_model_id, filename, revision=source_revision), destination)
118
+ ```
119
+
120
+ </details>
121
+
122
+ ### Printing the model:
123
+
124
+ <details><summary>Click to expand</summary>
125
+
126
+ ```text
127
+ EmbeddingGemma2Model(
128
+ (vision_tower): Gemma4VisionModel(
129
+ (patch_embedder): Gemma4VisionPatchEmbedder(
130
+ (input_proj): Linear(in_features=768, out_features=64, bias=False)
131
+ )
132
+ (encoder): Gemma4VisionEncoder(
133
+ (rotary_emb): Gemma4VisionRotaryEmbedding()
134
+ (layers): ModuleList(
135
+ (0-1): 2 x Gemma4VisionEncoderLayer(
136
+ (self_attn): Gemma4VisionAttention(
137
+ (q_proj): Gemma4ClippableLinear(
138
+ (linear): Linear(in_features=64, out_features=64, bias=False)
139
+ )
140
+ (k_proj): Gemma4ClippableLinear(
141
+ (linear): Linear(in_features=64, out_features=64, bias=False)
142
+ )
143
+ (v_proj): Gemma4ClippableLinear(
144
+ (linear): Linear(in_features=64, out_features=64, bias=False)
145
+ )
146
+ (o_proj): Gemma4ClippableLinear(
147
+ (linear): Linear(in_features=64, out_features=64, bias=False)
148
+ )
149
+ (q_norm): Gemma4RMSNorm()
150
+ (k_norm): Gemma4RMSNorm()
151
+ (v_norm): Gemma4RMSNorm()
152
+ )
153
+ (mlp): Gemma4VisionMLP(
154
+ (gate_proj): Gemma4ClippableLinear(
155
+ (linear): Linear(in_features=64, out_features=128, bias=False)
156
+ )
157
+ (up_proj): Gemma4ClippableLinear(
158
+ (linear): Linear(in_features=64, out_features=128, bias=False)
159
+ )
160
+ (down_proj): Gemma4ClippableLinear(
161
+ (linear): Linear(in_features=128, out_features=64, bias=False)
162
+ )
163
+ (act_fn): GELUTanh()
164
+ )
165
+ (input_layernorm): Gemma4RMSNorm()
166
+ (post_attention_layernorm): Gemma4RMSNorm()
167
+ (pre_feedforward_layernorm): Gemma4RMSNorm()
168
+ (post_feedforward_layernorm): Gemma4RMSNorm()
169
+ )
170
+ )
171
+ )
172
+ (pooler): Gemma4VisionPooler()
173
+ )
174
+ (language_model): EmbeddingGemma2TextModel(
175
+ (embed_tokens): EmbeddingGemma2TextScaledWordEmbedding(262144, 16, padding_idx=0)
176
+ (layers): ModuleList(
177
+ (0-4): 5 x EmbeddingGemma2EncoderLayer(
178
+ (self_attn): EmbeddingGemma2Attention(
179
+ (q_proj): Linear(in_features=16, out_features=32, bias=False)
180
+ (k_proj): Linear(in_features=16, out_features=32, bias=False)
181
+ (v_proj): Linear(in_features=16, out_features=32, bias=False)
182
+ (o_proj): Linear(in_features=32, out_features=16, bias=False)
183
+ (q_norm): EmbeddingGemma2RMSNorm()
184
+ (k_norm): EmbeddingGemma2RMSNorm()
185
+ (v_norm): EmbeddingGemma2RMSNorm()
186
+ )
187
+ (mlp): EmbeddingGemma2MLP(
188
+ (gate_proj): Linear(in_features=16, out_features=64, bias=False)
189
+ (up_proj): Linear(in_features=16, out_features=64, bias=False)
190
+ (down_proj): Linear(in_features=64, out_features=16, bias=False)
191
+ (act_fn): GELUTanh()
192
+ )
193
+ (input_layernorm): EmbeddingGemma2RMSNorm()
194
+ (post_attention_layernorm): EmbeddingGemma2RMSNorm()
195
+ (pre_feedforward_layernorm): EmbeddingGemma2RMSNorm()
196
+ (post_feedforward_layernorm): EmbeddingGemma2RMSNorm()
197
+ (ple_block): EmbeddingGemma2TextPLEBlock(
198
+ (act_fn): GELUTanh()
199
+ (per_layer_input_gate): Linear(in_features=16, out_features=16, bias=False)
200
+ (per_layer_projection): Linear(in_features=16, out_features=16, bias=False)
201
+ (post_per_layer_input_norm): EmbeddingGemma2RMSNorm()
202
+ )
203
+ )
204
+ (5): EmbeddingGemma2EncoderLayer(
205
+ (self_attn): EmbeddingGemma2Attention(
206
+ (q_proj): Linear(in_features=16, out_features=64, bias=False)
207
+ (k_proj): Linear(in_features=16, out_features=64, bias=False)
208
+ (v_proj): Linear(in_features=16, out_features=64, bias=False)
209
+ (o_proj): Linear(in_features=64, out_features=16, bias=False)
210
+ (q_norm): EmbeddingGemma2RMSNorm()
211
+ (k_norm): EmbeddingGemma2RMSNorm()
212
+ (v_norm): EmbeddingGemma2RMSNorm()
213
+ )
214
+ (mlp): EmbeddingGemma2MLP(
215
+ (gate_proj): Linear(in_features=16, out_features=64, bias=False)
216
+ (up_proj): Linear(in_features=16, out_features=64, bias=False)
217
+ (down_proj): Linear(in_features=64, out_features=16, bias=False)
218
+ (act_fn): GELUTanh()
219
+ )
220
+ (input_layernorm): EmbeddingGemma2RMSNorm()
221
+ (post_attention_layernorm): EmbeddingGemma2RMSNorm()
222
+ (pre_feedforward_layernorm): EmbeddingGemma2RMSNorm()
223
+ (post_feedforward_layernorm): EmbeddingGemma2RMSNorm()
224
+ (ple_block): EmbeddingGemma2TextPLEBlock(
225
+ (act_fn): GELUTanh()
226
+ (per_layer_input_gate): Linear(in_features=16, out_features=16, bias=False)
227
+ (per_layer_projection): Linear(in_features=16, out_features=16, bias=False)
228
+ (post_per_layer_input_norm): EmbeddingGemma2RMSNorm()
229
+ )
230
+ )
231
+ (6-10): 5 x EmbeddingGemma2EncoderLayer(
232
+ (self_attn): EmbeddingGemma2Attention(
233
+ (q_proj): Linear(in_features=16, out_features=32, bias=False)
234
+ (k_proj): Linear(in_features=16, out_features=32, bias=False)
235
+ (v_proj): Linear(in_features=16, out_features=32, bias=False)
236
+ (o_proj): Linear(in_features=32, out_features=16, bias=False)
237
+ (q_norm): EmbeddingGemma2RMSNorm()
238
+ (k_norm): EmbeddingGemma2RMSNorm()
239
+ (v_norm): EmbeddingGemma2RMSNorm()
240
+ )
241
+ (mlp): EmbeddingGemma2MLP(
242
+ (gate_proj): Linear(in_features=16, out_features=64, bias=False)
243
+ (up_proj): Linear(in_features=16, out_features=64, bias=False)
244
+ (down_proj): Linear(in_features=64, out_features=16, bias=False)
245
+ (act_fn): GELUTanh()
246
+ )
247
+ (input_layernorm): EmbeddingGemma2RMSNorm()
248
+ (post_attention_layernorm): EmbeddingGemma2RMSNorm()
249
+ (pre_feedforward_layernorm): EmbeddingGemma2RMSNorm()
250
+ (post_feedforward_layernorm): EmbeddingGemma2RMSNorm()
251
+ (ple_block): EmbeddingGemma2TextPLEBlock(
252
+ (act_fn): GELUTanh()
253
+ (per_layer_input_gate): Linear(in_features=16, out_features=16, bias=False)
254
+ (per_layer_projection): Linear(in_features=16, out_features=16, bias=False)
255
+ (post_per_layer_input_norm): EmbeddingGemma2RMSNorm()
256
+ )
257
+ )
258
+ (11): EmbeddingGemma2EncoderLayer(
259
+ (self_attn): EmbeddingGemma2Attention(
260
+ (q_proj): Linear(in_features=16, out_features=64, bias=False)
261
+ (k_proj): Linear(in_features=16, out_features=64, bias=False)
262
+ (v_proj): Linear(in_features=16, out_features=64, bias=False)
263
+ (o_proj): Linear(in_features=64, out_features=16, bias=False)
264
+ (q_norm): EmbeddingGemma2RMSNorm()
265
+ (k_norm): EmbeddingGemma2RMSNorm()
266
+ (v_norm): EmbeddingGemma2RMSNorm()
267
+ )
268
+ (mlp): EmbeddingGemma2MLP(
269
+ (gate_proj): Linear(in_features=16, out_features=64, bias=False)
270
+ (up_proj): Linear(in_features=16, out_features=64, bias=False)
271
+ (down_proj): Linear(in_features=64, out_features=16, bias=False)
272
+ (act_fn): GELUTanh()
273
+ )
274
+ (input_layernorm): EmbeddingGemma2RMSNorm()
275
+ (post_attention_layernorm): EmbeddingGemma2RMSNorm()
276
+ (pre_feedforward_layernorm): EmbeddingGemma2RMSNorm()
277
+ (post_feedforward_layernorm): EmbeddingGemma2RMSNorm()
278
+ (ple_block): EmbeddingGemma2TextPLEBlock(
279
+ (act_fn): GELUTanh()
280
+ (per_layer_input_gate): Linear(in_features=16, out_features=16, bias=False)
281
+ (per_layer_projection): Linear(in_features=16, out_features=16, bias=False)
282
+ (post_per_layer_input_norm): EmbeddingGemma2RMSNorm()
283
+ )
284
+ )
285
+ )
286
+ (norm): EmbeddingGemma2RMSNorm()
287
+ (rotary_emb): EmbeddingGemma2RotaryEmbedding()
288
+ (ple): EmbeddingGemma2TextPLE(
289
+ (per_layer_model_projection): Linear(in_features=16, out_features=192, bias=False)
290
+ (per_layer_projection_norm): EmbeddingGemma2RMSNorm()
291
+ )
292
+ (embedding_projection): Linear(in_features=16, out_features=768, bias=False)
293
+ )
294
+ (audio_tower): Gemma4AudioModel(
295
+ (subsample_conv_projection): Gemma4AudioSubSampleConvProjection(
296
+ (layer0): Gemma4AudioSubSampleConvProjectionLayer(
297
+ (conv): Conv2d(1, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
298
+ (norm): LayerNorm((128,), eps=1e-06, elementwise_affine=True, bias=False)
299
+ (act): ReLU()
300
+ )
301
+ (layer1): Gemma4AudioSubSampleConvProjectionLayer(
302
+ (conv): Conv2d(128, 8, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
303
+ (norm): LayerNorm((8,), eps=1e-06, elementwise_affine=True, bias=False)
304
+ (act): ReLU()
305
+ )
306
+ (input_proj_linear): Linear(in_features=256, out_features=64, bias=False)
307
+ )
308
+ (rel_pos_enc): Gemma4AudioRelPositionalEncoding()
309
+ (layers): ModuleList(
310
+ (0-1): 2 x Gemma4AudioLayer(
311
+ (feed_forward1): Gemma4AudioFeedForward(
312
+ (ffw_layer_1): Gemma4ClippableLinear(
313
+ (linear): Linear(in_features=64, out_features=256, bias=False)
314
+ )
315
+ (ffw_layer_2): Gemma4ClippableLinear(
316
+ (linear): Linear(in_features=256, out_features=64, bias=False)
317
+ )
318
+ (pre_layer_norm): Gemma4RMSNorm()
319
+ (post_layer_norm): Gemma4RMSNorm()
320
+ (act_fn): SiLUActivation()
321
+ )
322
+ (feed_forward2): Gemma4AudioFeedForward(
323
+ (ffw_layer_1): Gemma4ClippableLinear(
324
+ (linear): Linear(in_features=64, out_features=256, bias=False)
325
+ )
326
+ (ffw_layer_2): Gemma4ClippableLinear(
327
+ (linear): Linear(in_features=256, out_features=64, bias=False)
328
+ )
329
+ (pre_layer_norm): Gemma4RMSNorm()
330
+ (post_layer_norm): Gemma4RMSNorm()
331
+ (act_fn): SiLUActivation()
332
+ )
333
+ (self_attn): Gemma4AudioAttention(
334
+ (q_proj): Gemma4ClippableLinear(
335
+ (linear): Linear(in_features=64, out_features=64, bias=False)
336
+ )
337
+ (k_proj): Gemma4ClippableLinear(
338
+ (linear): Linear(in_features=64, out_features=64, bias=False)
339
+ )
340
+ (v_proj): Gemma4ClippableLinear(
341
+ (linear): Linear(in_features=64, out_features=64, bias=False)
342
+ )
343
+ (post): Gemma4ClippableLinear(
344
+ (linear): Linear(in_features=64, out_features=64, bias=False)
345
+ )
346
+ (relative_k_proj): Linear(in_features=64, out_features=64, bias=False)
347
+ )
348
+ (lconv1d): Gemma4AudioLightConv1d(
349
+ (linear_start): Gemma4ClippableLinear(
350
+ (linear): Linear(in_features=64, out_features=128, bias=False)
351
+ )
352
+ (linear_end): Gemma4ClippableLinear(
353
+ (linear): Linear(in_features=64, out_features=64, bias=False)
354
+ )
355
+ (depthwise_conv1d): Gemma4AudioCausalConv1d(64, 64, kernel_size=(5,), stride=(1,), groups=64, bias=False)
356
+ (pre_layer_norm): Gemma4RMSNorm()
357
+ (conv_norm): Gemma4RMSNorm()
358
+ (act_fn): SiLUActivation()
359
+ )
360
+ (norm_pre_attn): Gemma4RMSNorm()
361
+ (norm_post_attn): Gemma4RMSNorm()
362
+ (norm_out): Gemma4RMSNorm()
363
+ )
364
+ )
365
+ (output_proj): Linear(in_features=64, out_features=64, bias=True)
366
+ )
367
+ (embed_vision): EmbeddingGemma2MultimodalEmbedder(
368
+ (embedding_projection): Linear(in_features=64, out_features=16, bias=False)
369
+ (embedding_pre_projection_norm): EmbeddingGemma2RMSNorm()
370
+ )
371
+ (embed_audio): EmbeddingGemma2MultimodalEmbedder(
372
+ (embedding_projection): Linear(in_features=64, out_features=16, bias=False)
373
+ (embedding_pre_projection_norm): EmbeddingGemma2RMSNorm()
374
+ )
375
+ )
376
+ ```
377
+
378
+ </details>
379
+
380
+ ### Test environment:
381
+
382
+ - Pillow: 13.0.0
383
+ - huggingface_hub: 2.3.0
384
+ - numpy: 2.3.5
385
+ - safetensors: 0.8.0
386
+ - tokenizers: 0.23.3
387
+ - torch: 2.13.0
388
+ - transformers: 5.19.0
389
+
390
+ ### Change log:
391
+
392
+ - 2026-10-23: Initial version.
393
+
394
+ This repo is generated by GPT-6.1-Sol
chat_template.jinja ADDED
@@ -0,0 +1 @@
 
 
1
+ {%- for msg in messages if msg.get('role') == 'system' -%}{%- if msg.get('content') is string -%}{{ msg['content'] }}{%- else -%}{%- for item in msg['content'] if item.get('type') == 'text' -%}{{ item['text'] }}{%- endfor -%}{%- endif -%}{%- endfor -%}{%- for msg in messages if msg.get('role') != 'system' -%}{%- if msg.get('content') is string -%}{{ msg['content'] }}{%- else -%}{%- set existing_text = msg['content'] | selectattr('type', 'equalto', 'text') | map(attribute='text') | join -%}{%- set has_manual_placeholders = ('<|image|>' in existing_text) or ('<|video|>' in existing_text) or ('<|audio|>' in existing_text) -%}{%- for item in msg['content'] -%}{%- if item.get('type') == 'text' -%}{{ item['text'] }}{%- elif not has_manual_placeholders and item.get('type') == 'image' -%}<|image|>{%- elif not has_manual_placeholders and item.get('type') == 'video' -%}<|video|>{%- elif not has_manual_placeholders and item.get('type') == 'audio' -%}<|audio|>{%- endif -%}{%- endfor -%}{%- endif -%}{%- endfor -%}
config.json ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "EmbeddingGemma2Model"
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": 64,
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": 2,
31
+ "num_hidden_layers": 2,
32
+ "output_attentions": false,
33
+ "output_hidden_states": false,
34
+ "output_proj_dims": 64,
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
+ 8
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_index": 258883,
50
+ "eoi_token_id": 258882,
51
+ "image_token_id": 258880,
52
+ "initializer_range": 0.02,
53
+ "model_type": "embedding_gemma2",
54
+ "text_config": {
55
+ "attention_bias": false,
56
+ "attention_dropout": 0.0,
57
+ "bos_token_id": 2,
58
+ "dtype": "bfloat16",
59
+ "embedding_dim": 768,
60
+ "eos_token_id": 1,
61
+ "head_dim": 32,
62
+ "hidden_activation": "gelu_pytorch_tanh",
63
+ "hidden_size": 16,
64
+ "hidden_size_per_layer_input": 16,
65
+ "initializer_range": 0.02,
66
+ "intermediate_size": 64,
67
+ "layer_types": [
68
+ "sliding_attention",
69
+ "sliding_attention",
70
+ "sliding_attention",
71
+ "sliding_attention",
72
+ "sliding_attention",
73
+ "full_attention",
74
+ "sliding_attention",
75
+ "sliding_attention",
76
+ "sliding_attention",
77
+ "sliding_attention",
78
+ "sliding_attention",
79
+ "full_attention"
80
+ ],
81
+ "max_position_embeddings": 262144,
82
+ "model_type": "embedding_gemma2_text",
83
+ "num_attention_heads": 1,
84
+ "num_hidden_layers": 12,
85
+ "num_key_value_heads": 1,
86
+ "pad_token_id": 0,
87
+ "per_layer_config": {
88
+ "05": {
89
+ "head_dim": 64
90
+ },
91
+ "11": {
92
+ "head_dim": 64
93
+ }
94
+ },
95
+ "rms_norm_eps": 1e-06,
96
+ "rope_parameters": {
97
+ "full_attention": {
98
+ "rope_theta": 1000000.0,
99
+ "rope_type": "default"
100
+ },
101
+ "sliding_attention": {
102
+ "rope_theta": 10000.0,
103
+ "rope_type": "default"
104
+ }
105
+ },
106
+ "sliding_window": 512,
107
+ "vocab_size": 262144
108
+ },
109
+ "transformers_version": "5.19.0",
110
+ "video_token_id": 258884,
111
+ "vision_config": {
112
+ "_name_or_path": "",
113
+ "architectures": null,
114
+ "attention_bias": false,
115
+ "attention_dropout": 0.0,
116
+ "chunk_size_feed_forward": 0,
117
+ "default_output_length": 280,
118
+ "dtype": "bfloat16",
119
+ "global_head_dim": 32,
120
+ "head_dim": 32,
121
+ "hidden_activation": "gelu_pytorch_tanh",
122
+ "hidden_size": 64,
123
+ "id2label": {
124
+ "0": "LABEL_0",
125
+ "1": "LABEL_1"
126
+ },
127
+ "initializer_range": 0.02,
128
+ "intermediate_size": 128,
129
+ "is_encoder_decoder": false,
130
+ "label2id": {
131
+ "LABEL_0": 0,
132
+ "LABEL_1": 1
133
+ },
134
+ "max_position_embeddings": 131072,
135
+ "model_type": "gemma4_vision",
136
+ "num_attention_heads": 2,
137
+ "num_hidden_layers": 2,
138
+ "num_key_value_heads": 2,
139
+ "output_attentions": false,
140
+ "output_hidden_states": false,
141
+ "patch_size": 16,
142
+ "pooling_kernel_size": 3,
143
+ "position_embedding_size": 10240,
144
+ "problem_type": null,
145
+ "return_dict": true,
146
+ "rms_norm_eps": 1e-06,
147
+ "rope_parameters": {
148
+ "rope_theta": 100.0,
149
+ "rope_type": "axial"
150
+ },
151
+ "standardize": false,
152
+ "use_clipped_linears": false
153
+ },
154
+ "vision_soft_tokens_per_image": 280
155
+ }
config_sentence_transformers.json ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "__version__": {
3
+ "pytorch": "2.14.0+cu130",
4
+ "sentence_transformers": "6.1.0",
5
+ "transformers": "5.18.0.dev0"
6
+ },
7
+ "default_prompt_name": null,
8
+ "model_type": "SentenceTransformer",
9
+ "prompts": {
10
+ "BitextMining": "task: search result | query: ",
11
+ "Classification": "task: classification | query: ",
12
+ "Clustering": "task: clustering | query: ",
13
+ "CodeRetrieval": "task: code retrieval | query: ",
14
+ "Document": "title: none | text: ",
15
+ "FactChecking": "task: fact checking | query: ",
16
+ "InstructionRetrieval": "task: code retrieval | query: ",
17
+ "MultilabelClassification": "task: classification | query: ",
18
+ "PairClassification": "task: sentence similarity | query: ",
19
+ "QuestionAnswering": "task: question answering | query: ",
20
+ "Reranking": "task: search result | query: ",
21
+ "Retrieval": "task: search result | query: ",
22
+ "Retrieval-document": "title: none | text: ",
23
+ "Retrieval-query": "task: search result | query: ",
24
+ "STS": "task: sentence similarity | query: ",
25
+ "SearchQuery": "task: search result | query: ",
26
+ "SentenceSimilarity": "task: sentence similarity | query: ",
27
+ "Summarization": "task: sentence similarity | query: ",
28
+ "document": "title: none | text: ",
29
+ "query": "task: search result | query: "
30
+ },
31
+ "requirements": {
32
+ "sentence-transformers": {
33
+ "reason": "Older versions ignore the order of multimodal dict inputs and cannot put several images or texts into a single embedding.",
34
+ "specifier": ">=6.1.0"
35
+ }
36
+ },
37
+ "similarity_fn_name": "cosine"
38
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aea7d54f9a3b5ad9241a54b0902fe8db48f5e849202a6b30f2e72757c43dd87e
3
+ size 11957968
modules.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "idx": 0,
4
+ "name": "0",
5
+ "path": "",
6
+ "type": "sentence_transformers.base.modules.transformer.Transformer"
7
+ },
8
+ {
9
+ "idx": 1,
10
+ "name": "1",
11
+ "path": "1_Pooling",
12
+ "type": "sentence_transformers.sentence_transformer.modules.pooling.Pooling"
13
+ },
14
+ {
15
+ "idx": 2,
16
+ "name": "2",
17
+ "path": "2_Normalize",
18
+ "type": "sentence_transformers.base.modules.normalize.Normalize"
19
+ }
20
+ ]
preprocessor_config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dither": 0.0,
3
+ "feature_extractor_type": "Gemma4AudioFeatureExtractor",
4
+ "feature_size": 128,
5
+ "fft_length": 512,
6
+ "fft_overdrive": false,
7
+ "frame_length": 320,
8
+ "hop_length": 160,
9
+ "input_scale_factor": 1.0,
10
+ "max_frequency": 8000.0,
11
+ "mel_floor": 0.001,
12
+ "min_frequency": 0.0,
13
+ "padding_side": "right",
14
+ "padding_value": 0.0,
15
+ "per_bin_mean": null,
16
+ "per_bin_stddev": null,
17
+ "preemphasis": 0.0,
18
+ "preemphasis_htk_flavor": true,
19
+ "return_attention_mask": true,
20
+ "sampling_rate": 16000
21
+ }
processor_config.json ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "audio_ms_per_token": 40,
3
+ "audio_seq_length": 280,
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": "EmbeddingGemma2Processor",
50
+ "video_processor": {
51
+ "add_timestamps": false,
52
+ "do_convert_rgb": true,
53
+ "do_normalize": false,
54
+ "do_rescale": true,
55
+ "do_resize": true,
56
+ "do_sample_frames": true,
57
+ "fps": 1,
58
+ "image_mean": [
59
+ 0.0,
60
+ 0.0,
61
+ 0.0
62
+ ],
63
+ "image_std": [
64
+ 1.0,
65
+ 1.0,
66
+ 1.0
67
+ ],
68
+ "max_frames": 32,
69
+ "max_soft_tokens": 140,
70
+ "overflow_strategy": "uniform",
71
+ "patch_size": 16,
72
+ "pooling_kernel_size": 3,
73
+ "resample": 3,
74
+ "rescale_factor": 0.00392156862745098,
75
+ "return_metadata": false,
76
+ "video_processor_type": "EmbeddingGemma2VideoProcessor"
77
+ }
78
+ }
sentence_bert_config.json ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformer_task": "feature-extraction",
3
+ "modality_config": {
4
+ "text": {
5
+ "method": "forward",
6
+ "method_output_name": "last_hidden_state"
7
+ },
8
+ "image": {
9
+ "method": "forward",
10
+ "method_output_name": "last_hidden_state"
11
+ },
12
+ "audio": {
13
+ "method": "forward",
14
+ "method_output_name": "last_hidden_state"
15
+ },
16
+ "video": {
17
+ "method": "forward",
18
+ "method_output_name": "last_hidden_state"
19
+ },
20
+ "message": {
21
+ "method": "forward",
22
+ "method_output_name": "last_hidden_state",
23
+ "format": "structured"
24
+ }
25
+ },
26
+ "module_output_name": "token_embeddings"
27
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d777ef5bdc1aa36227abdfb77c3e49e7b9c892d16e1b6bda41c393504828be4
3
+ size 32170510
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e594c8a90eb08d8bda498ff4747977dc827ae0c3c56b5c0d41a605a22d02ef03
3
+ size 4689013
tokenizer_config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "audio_token": "<|audio|>",
3
+ "backend": "tokenizers",
4
+ "boa_token": "<|audio>",
5
+ "boi_token": "<|image>",
6
+ "bos_token": "<bos>",
7
+ "eoa_token": "<audio|>",
8
+ "eoc_token": "<channel|>",
9
+ "eoi_token": "<image|>",
10
+ "eos_token": "<eos>",
11
+ "eot_token": "<turn|>",
12
+ "escape_token": "<|\"|>",
13
+ "etc_token": "<tool_call|>",
14
+ "etd_token": "<tool|>",
15
+ "etr_token": "<tool_response|>",
16
+ "extra_special_tokens": [
17
+ "<|video|>"
18
+ ],
19
+ "image_token": "<|image|>",
20
+ "is_local": true,
21
+ "local_files_only": false,
22
+ "mask_token": "<mask>",
23
+ "model_max_length": 1000000000000000019884624838656,
24
+ "model_specific_special_tokens": {
25
+ "audio_token": "<|audio|>",
26
+ "boa_token": "<|audio>",
27
+ "boi_token": "<|image>",
28
+ "eoa_token": "<audio|>",
29
+ "eoc_token": "<channel|>",
30
+ "eoi_token": "<image|>",
31
+ "eot_token": "<turn|>",
32
+ "escape_token": "<|\"|>",
33
+ "etc_token": "<tool_call|>",
34
+ "etd_token": "<tool|>",
35
+ "etr_token": "<tool_response|>",
36
+ "image_token": "<|image|>",
37
+ "soc_token": "<|channel>",
38
+ "sot_token": "<|turn>",
39
+ "stc_token": "<|tool_call>",
40
+ "std_token": "<|tool>",
41
+ "str_token": "<|tool_response>",
42
+ "think_token": "<|think|>",
43
+ "video_token": "<|video|>"
44
+ },
45
+ "pad_token": "<pad>",
46
+ "padding_side": "right",
47
+ "processor_class": "EmbeddingGemma2Processor",
48
+ "soc_token": "<|channel>",
49
+ "sot_token": "<|turn>",
50
+ "stc_token": "<|tool_call>",
51
+ "std_token": "<|tool>",
52
+ "str_token": "<|tool_response>",
53
+ "think_token": "<|think|>",
54
+ "tokenizer_class": "GemmaTokenizer",
55
+ "unk_token": "<unk>",
56
+ "video_token": "<|video|>"
57
+ }