gsmlg commited on
Commit
604b4b8
·
verified ·
1 Parent(s): 27ddc85

Mirror EmbeddingGemma 2 text-embedding ONNX models and tokenizer

Browse files
.gitattributes CHANGED
@@ -33,3 +33,9 @@ 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
+ onnx/model.onnx_data filter=lfs diff=lfs merge=lfs -text
37
+ onnx/model_fp16.onnx_data filter=lfs diff=lfs merge=lfs -text
38
+ onnx/model_q4.onnx_data filter=lfs diff=lfs merge=lfs -text
39
+ onnx/model_q4f16.onnx_data filter=lfs diff=lfs merge=lfs -text
40
+ onnx/model_quantized.onnx_data filter=lfs diff=lfs merge=lfs -text
41
+ tokenizer.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ pipeline_tag: feature-extraction
4
+ library_name: onnx
5
+ base_model:
6
+ - google/embeddinggemma-2
7
+ tags:
8
+ - embedding
9
+ - feature-extraction
10
+ - sentence-similarity
11
+ - onnx
12
+ - text-embeddings-inference
13
+ language:
14
+ - multilingual
15
+ ---
16
+
17
+ # EmbeddingGemma 2 — text embedding ONNX mirror
18
+
19
+ Text-embedding subset of [EmbeddingGemma 2](https://huggingface.co/google/embeddinggemma-2)
20
+ by Google DeepMind, mirrored for on-device use with
21
+ [`lib_onnx`](https://pub.dev/packages/lib_onnx) (ONNX Runtime for Dart/Flutter).
22
+
23
+ Files are unmodified copies of:
24
+
25
+ | Files | Source | Revision |
26
+ |---|---|---|
27
+ | `onnx/model*.onnx`, `onnx/model*.onnx_data`, `config.json`, `config_sentence_transformers.json`, `tokenizer.json`, `tokenizer_config.json` | [onnx-community/embeddinggemma-2-ONNX](https://huggingface.co/onnx-community/embeddinggemma-2-ONNX) | `daa72c51243991dfcaf9f9137d2c573d8f7790c0` |
28
+ | `tokenizer.model` (SentencePiece) | [google/embeddinggemma-2](https://huggingface.co/google/embeddinggemma-2) | `f9972ac22e696a105c482202646979e33e4b5a1e` |
29
+
30
+ The vision and audio encoders are not mirrored. License: Apache 2.0, as published
31
+ by the upstream repositories ([Gemma license](https://ai.google.dev/gemma/docs/gemma_4_license)).
32
+
33
+ ## Model contract
34
+
35
+ | Input | Type | Shape | Text-only value |
36
+ |---|---|---|---|
37
+ | `input_ids` | int64 | `[batch, sequence]` | Gemma tokenizer ids |
38
+ | `attention_mask` | int64 | `[batch, sequence]` | 1 for tokens, 0 for padding |
39
+ | `image_features` | float32 | `[num_image_tokens, 512]` | empty `[0, 512]` |
40
+ | `video_features` | float32 | `[num_video_tokens, 512]` | empty `[0, 512]` |
41
+ | `audio_features` | float32 | `[num_audio_tokens, 512]` | empty `[0, 512]` |
42
+
43
+ | Output | Shape | Meaning |
44
+ |---|---|---|
45
+ | `sentence_embedding` | `[batch, 768]` | pooled, projected embedding (L2-normalize before cosine/dot) |
46
+ | `last_hidden_state` | `[batch, sequence, 768]` | per-token states |
47
+
48
+ Matryoshka truncation to 512, 256 or 128 dimensions is supported: keep the
49
+ leading dimensions and re-normalize.
50
+
51
+ Prefix text inputs with a task instruction:
52
+
53
+ - query: `task: search result | query: {text}`
54
+ - document: `title: {title or none} | text: {text}`
55
+ - symmetric tasks: `task: sentence similarity | query: {text}` (also `classification`, `clustering`)
56
+
57
+ ## Variants
58
+
59
+ | File | Precision | Size (data) |
60
+ |---|---|---|
61
+ | `onnx/model_q4f16.onnx` | 4-bit weights, fp16 | 157 MB |
62
+ | `onnx/model_q4.onnx` | 4-bit weights | 174 MB |
63
+ | `onnx/model_quantized.onnx` | int8 | 314 MB |
64
+ | `onnx/model_fp16.onnx` | fp16 | 542 MB |
65
+ | `onnx/model.onnx` | fp32 | 1.08 GB |
66
+
67
+ Each `.onnx` graph loads its `.onnx_data` external-data file from the same directory.
68
+
69
+ ## SHA-256
70
+
71
+ ```
72
+ 4d777ef5bdc1aa36227abdfb77c3e49e7b9c892d16e1b6bda41c393504828be4 tokenizer.json
73
+ e594c8a90eb08d8bda498ff4747977dc827ae0c3c56b5c0d41a605a22d02ef03 tokenizer.model
74
+ a49e227d7e0e5f4ee606d79879d084264366367bc6318f344ab179e35d4fd6a4 onnx/model_fp16.onnx
75
+ b9dbe09415d77c8686ba6e216a244086f4ada1608238c13f2bfaa587ba627207 onnx/model_fp16.onnx_data
76
+ f9eeba97acddf139b8ee2ddf04bc30dceafa88de93fadf74d7644e0d61a477a9 onnx/model_q4.onnx
77
+ c3975f2d1ab7a1878ae31a7d7a9b7804a827aff3800b60dfceafce21cac3df49 onnx/model_q4.onnx_data
78
+ 53feeced79582d661e30adeaa9829cea90d92b1c78347e26fd123773580f71d0 onnx/model_q4f16.onnx
79
+ c39fbaa1fb4221f04beb82786a06b81999c514fd39e84fcd58ef79413c87fa56 onnx/model_q4f16.onnx_data
80
+ d06edd601f851c633a2519304cbeb8dc6170d7ceb61b436625c17fb9b6e74953 onnx/model_quantized.onnx
81
+ 278a7ff1248c3618e4bd11a607fc54f7bdc7778854230f3956d3f86bd9db4f3b onnx/model_quantized.onnx_data
82
+ bc47de15f81208a5c99e5ab10f746d5e33b51ea228b7dc0bef9c133a94f1c1c3 onnx/model.onnx
83
+ 9fd452bfc6916e5a92f080f8dada35598ca4512b21c65897d4c5974d5f9630a2 onnx/model.onnx_data
84
+ ```
config.json ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": 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_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": 256,
62
+ "hidden_activation": "gelu_pytorch_tanh",
63
+ "hidden_size": 512,
64
+ "hidden_size_per_layer_input": 512,
65
+ "initializer_range": 0.02,
66
+ "intermediate_size": 2048,
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
+ "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
+ ],
93
+ "max_position_embeddings": 262144,
94
+ "model_type": "embedding_gemma2_text",
95
+ "num_attention_heads": 4,
96
+ "num_hidden_layers": 24,
97
+ "num_key_value_heads": 2,
98
+ "pad_token_id": 0,
99
+ "per_layer_config": {
100
+ "05": {
101
+ "head_dim": 512,
102
+ "num_key_value_heads": 1
103
+ },
104
+ "11": {
105
+ "head_dim": 512,
106
+ "num_key_value_heads": 1
107
+ },
108
+ "17": {
109
+ "head_dim": 512,
110
+ "num_key_value_heads": 1
111
+ },
112
+ "23": {
113
+ "head_dim": 512,
114
+ "num_key_value_heads": 1
115
+ }
116
+ },
117
+ "rms_norm_eps": 1e-06,
118
+ "rope_parameters": {
119
+ "full_attention": {
120
+ "rope_theta": 1000000.0,
121
+ "rope_type": "default"
122
+ },
123
+ "sliding_attention": {
124
+ "rope_theta": 10000.0,
125
+ "rope_type": "default"
126
+ }
127
+ },
128
+ "sliding_window": 512,
129
+ "vocab_size": 262144
130
+ },
131
+ "transformers_version": "5.18.0.dev0",
132
+ "video_token_id": 258884,
133
+ "vision_config": {
134
+ "_name_or_path": "",
135
+ "architectures": null,
136
+ "attention_bias": false,
137
+ "attention_dropout": 0.0,
138
+ "chunk_size_feed_forward": 0,
139
+ "default_output_length": 280,
140
+ "dtype": "bfloat16",
141
+ "global_head_dim": 64,
142
+ "head_dim": 64,
143
+ "hidden_activation": "gelu_pytorch_tanh",
144
+ "hidden_size": 768,
145
+ "id2label": {
146
+ "0": "LABEL_0",
147
+ "1": "LABEL_1"
148
+ },
149
+ "initializer_range": 0.02,
150
+ "intermediate_size": 3072,
151
+ "is_encoder_decoder": false,
152
+ "label2id": {
153
+ "LABEL_0": 0,
154
+ "LABEL_1": 1
155
+ },
156
+ "max_position_embeddings": 131072,
157
+ "model_type": "gemma4_vision",
158
+ "num_attention_heads": 12,
159
+ "num_hidden_layers": 16,
160
+ "num_key_value_heads": 12,
161
+ "output_attentions": false,
162
+ "output_hidden_states": false,
163
+ "patch_size": 16,
164
+ "pooling_kernel_size": 3,
165
+ "position_embedding_size": 10240,
166
+ "problem_type": null,
167
+ "return_dict": true,
168
+ "rms_norm_eps": 1e-06,
169
+ "rope_parameters": {
170
+ "rope_theta": 100.0,
171
+ "rope_type": "axial"
172
+ },
173
+ "standardize": false,
174
+ "use_clipped_linears": false
175
+ },
176
+ "vision_soft_tokens_per_image": 280,
177
+ "transformers.js_config": {
178
+ "use_external_data_format": {
179
+ "audio_encoder.onnx": 1,
180
+ "audio_encoder_fp16.onnx": 1,
181
+ "audio_encoder_q4.onnx": 1,
182
+ "audio_encoder_q4f16.onnx": 1,
183
+ "audio_encoder_quantized.onnx": 1,
184
+ "model.onnx": 1,
185
+ "model_fp16.onnx": 1,
186
+ "model_q4.onnx": 1,
187
+ "model_q4f16.onnx": 1,
188
+ "model_quantized.onnx": 1,
189
+ "vision_encoder.onnx": 1,
190
+ "vision_encoder_fp16.onnx": 1,
191
+ "vision_encoder_q4.onnx": 1,
192
+ "vision_encoder_q4f16.onnx": 1,
193
+ "vision_encoder_quantized.onnx": 1
194
+ }
195
+ }
196
+ }
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
+ }
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc47de15f81208a5c99e5ab10f746d5e33b51ea228b7dc0bef9c133a94f1c1c3
3
+ size 421421
onnx/model.onnx_data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9fd452bfc6916e5a92f080f8dada35598ca4512b21c65897d4c5974d5f9630a2
3
+ size 1084170240
onnx/model_fp16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a49e227d7e0e5f4ee606d79879d084264366367bc6318f344ab179e35d4fd6a4
3
+ size 425780
onnx/model_fp16.onnx_data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9dbe09415d77c8686ba6e216a244086f4ada1608238c13f2bfaa587ba627207
3
+ size 542085120
onnx/model_q4.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f9eeba97acddf139b8ee2ddf04bc30dceafa88de93fadf74d7644e0d61a477a9
3
+ size 490742
onnx/model_q4.onnx_data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c3975f2d1ab7a1878ae31a7d7a9b7804a827aff3800b60dfceafce21cac3df49
3
+ size 174028800
onnx/model_q4f16.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:53feeced79582d661e30adeaa9829cea90d92b1c78347e26fd123773580f71d0
3
+ size 495298
onnx/model_q4f16.onnx_data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c39fbaa1fb4221f04beb82786a06b81999c514fd39e84fcd58ef79413c87fa56
3
+ size 156862464
onnx/model_quantized.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d06edd601f851c633a2519304cbeb8dc6170d7ceb61b436625c17fb9b6e74953
3
+ size 495165
onnx/model_quantized.onnx_data ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:278a7ff1248c3618e4bd11a607fc54f7bdc7778854230f3956d3f86bd9db4f3b
3
+ size 313724928
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
+ }