notforu777 commited on
Commit
74ec9c1
·
verified ·
1 Parent(s): caffe5f

EmbeddingGemma 2 GGUF: BF16, Q8_0, AD-Q6_K, AD-Q4_K_M, mmproj

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
+ embeddinggemma-2-AD-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
37
+ embeddinggemma-2-AD-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
38
+ embeddinggemma-2-BF16.gguf filter=lfs diff=lfs merge=lfs -text
39
+ embeddinggemma-2-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
40
+ mmproj-embeddinggemma-2-BF16.gguf filter=lfs diff=lfs merge=lfs -text
41
+ mmproj-embeddinggemma-2-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,267 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: google/embeddinggemma-2
3
+ base_model_relation: quantized
4
+ quantized_by: AtomicChat
5
+ pipeline_tag: feature-extraction
6
+ library_name: gguf
7
+ license: apache-2.0
8
+ tags:
9
+ - gguf
10
+ - llama.cpp
11
+ - embeddings
12
+ - sentence-similarity
13
+ - multimodal-embedding
14
+ - gemma
15
+ - imatrix
16
+ - quantized
17
+ - atomic-chat
18
+ ---
19
+
20
+ # How to Run EmbeddingGemma 2 Locally
21
+ <p style="margin-top: 0; margin-bottom: 0;">
22
+ <em>Built from Google's original weights with our own importance matrix. The <a href="https://huggingface.co/datasets/AtomicChat/calib-corpora">calibration corpora</a> behind our builds are public.</em>
23
+ </p>
24
+ <div style="display: flex; gap: 8px; align-items: center; margin-top: 10px; margin-bottom: 10px;">
25
+ <a href="https://atomic.chat/?utm_source=huggingface&utm_medium=referral&utm_campaign=hf_embeddinggemma_2&utm_content=btn_atomic"><img src="https://huggingface.co/AtomicChat/Qwen3.8-27B-GGUF/resolve/main/btn_atomic.png" width="162" alt="Atomic Chat"></a>
26
+ <a href="https://discord.gg/8wGSsvmg4V"><img src="https://huggingface.co/AtomicChat/Qwen3.8-27B-GGUF/resolve/main/btn_discord.png" width="119" alt="Discord"></a>
27
+ <a href="https://github.com/AtomicBot-ai/Atomic-Chat"><img src="https://huggingface.co/AtomicChat/Qwen3.8-27B-GGUF/resolve/main/btn_github.png" width="115" alt="GitHub"></a>
28
+ </div>
29
+ <ul style="margin: 0 0 12px 0;">
30
+ <li>EmbeddingGemma 2 puts text, code, images and audio into one vector space, and the text model is 270M parameters.</li>
31
+ <li>See our quantization analysis below for measurements and instructions.</li>
32
+ </ul>
33
+ <hr style="margin: 0 0 16px 0;">
34
+
35
+ ## Pick a file
36
+
37
+ Every number below is measured, not estimated. How we measured it is at the
38
+ bottom, and the raw logs are in
39
+ [the metrics repo](https://huggingface.co/datasets/AtomicChat/embeddinggemma-2-GGUF-metrics)
40
+ so you can check any of it yourself.
41
+
42
+ An embedding model has no next word to predict, so the usual KL divergence does
43
+ not apply. What matters is whether search still finds what the original finds.
44
+ `same top result` is how often a search with this file returns the same best
45
+ passage as the original weights, over 1,000 queries in 30 languages. `cosine to
46
+ BF16` is how close each vector is to the original's vector for the same text (1
47
+ means identical).
48
+
49
+ | File | Size | same top result | cosine to BF16 |
50
+ |---|---:|---:|---:|
51
+ | `BF16` | 558 MB on disk | reference | 1 |
52
+ | `Q8_0` | 310 MB on disk | 98.7% | 0.99989 |
53
+ | `AD-Q6_K` | 245 MB on disk | 96.3% | 0.99945 |
54
+ | `AD-Q4_K_M` | 175 MB on disk | 87.9% | 0.99276 |
55
+
56
+ `AD-` means Atomic Dynamic: the type is chosen per tensor from measurements
57
+ rather than taken from a llama.cpp preset.
58
+
59
+ Which one to take:
60
+ - **`Q8_0`** if you can spare 310 MB. It is practically the original.
61
+ - **`AD-Q6_K`** for a smaller file whose vectors stay very close to the original's.
62
+ - **`AD-Q4_K_M`** when size matters most. Its top result differs from the
63
+ original's on about one query in eight, but it finds the right passage as
64
+ often as the original does (see *Search quality* below).
65
+
66
+ > [!IMPORTANT]
67
+ > Index your documents and embed your queries with the **same file**. Vectors
68
+ > from different quantizations are close, not identical, so do not mix them in
69
+ > one index.
70
+
71
+ > [!NOTE]
72
+ > We do not ship F16. Google reports that the model's activations overflow
73
+ > float16 and produce NaN or silently degraded vectors. Use BF16 or one of the
74
+ > quantized files.
75
+
76
+ ### Images and audio
77
+
78
+ Images and audio go through the vision and audio encoders in a separate
79
+ projector file (`--mmproj`). The model also embeds video; we have not tested
80
+ that path.
81
+
82
+ | File | Size | cosine to BF16 projector |
83
+ |---|---:|---:|
84
+ | `mmproj-embeddinggemma-2-BF16` | 982 MB on disk | reference |
85
+ | `mmproj-embeddinggemma-2-Q8_0` | 555 MB on disk | 0.99993 image, 0.99994 audio |
86
+
87
+ This is a sanity check, not a benchmark: one image and one 17-second speech
88
+ clip. In both projector files the image sits closer to its right caption than
89
+ to a wrong one (0.79 against 0.56), and so does the audio clip (0.59 against
90
+ 0.52).
91
+
92
+ ## Running it
93
+
94
+ ```bash
95
+ llama-server -m embeddinggemma-2-Q8_0.gguf --embeddings --pooling mean \
96
+ -c 2048 -b 2048 -ub 2048 -ngl 99
97
+ ```
98
+
99
+ The model reads the whole input at once (bidirectional attention), so `-ub` has
100
+ to be at least as long as your longest input. Raise `-c`, `-b` and `-ub`
101
+ together for inputs up to the model's 8K context.
102
+
103
+ ```bash
104
+ curl http://127.0.0.1:8080/v1/embeddings -H "Content-Type: application/json" -d '{
105
+ "input": ["task: search result | query: how do I reset my password?",
106
+ "title: none | text: Open Settings, choose Forgot password and follow the link we email you."],
107
+ "encoding_format": "float"}'
108
+ ```
109
+
110
+ The vectors come back L2-normalised, with 768 dimensions.
111
+
112
+ **Task prefixes.** The model was trained with them, and leaving them out costs
113
+ accuracy:
114
+
115
+ | Use | Query | Document |
116
+ |---|---|---|
117
+ | Search | `task: search result \| query: {query}` | `title: {title or none} \| text: {text}` |
118
+ | Question answering | `task: question answering \| query: {question}` | same |
119
+ | Fact checking | `task: fact checking \| query: {claim}` | same |
120
+ | Code search | `task: code retrieval \| query: {query}` | `title: {file name} \| text: {code}` |
121
+ | Classification, clustering, similarity | `task: classification \| query: {text}` (or `clustering`, `sentence similarity`) | - |
122
+
123
+ **Shorter vectors.** Keep the first 512, 256 or 128 values and normalise again.
124
+ At 256 dimensions every file keeps the same standing as in the table above (all
125
+ numbers are in `results.json`).
126
+
127
+ **Images and audio.** Start the server with the projector, then send an
128
+ OpenAI-style content array:
129
+
130
+ ```bash
131
+ llama-server -m embeddinggemma-2-Q8_0.gguf --mmproj mmproj-embeddinggemma-2-Q8_0.gguf \
132
+ --embeddings --pooling mean -c 4096 -b 4096 -ub 4096 -ngl 99
133
+ ```
134
+
135
+ ```json
136
+ {"input": [{"content": [{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}]},
137
+ {"content": [{"type": "input_audio", "input_audio": {"data": "<base64 wav>", "format": "wav"}}]},
138
+ "task: search result | query: a newspaper front page about the moon landing"],
139
+ "encoding_format": "float"}
140
+ ```
141
+
142
+ ## How these compare to other builds
143
+
144
+ We downloaded Unsloth's files and measured them with the same harness, the
145
+ same eval set and the same machine.
146
+
147
+ | File | Size | same top result | 1 - cosine (lower is better) |
148
+ |---|---:|---:|---:|
149
+ | Unsloth `UD-Q6_K_XL` | 249 MB | 97.0% | 0.00080 |
150
+ | **`AD-Q6_K`** | **245 MB** | **96.3%** | **0.00055** |
151
+ | Unsloth `UD-Q5_K_XL` | 210 MB | 93.9% | 0.00199 |
152
+ | Unsloth `UD-Q4_K_XL` | 176 MB | 87.1% | 0.00811 |
153
+ | **`AD-Q4_K_M`** | **175 MB** | **87.9%** | **0.00724** |
154
+
155
+ - At about 245 MB our vectors sit 32% closer to the original's on the
156
+ multilingual set and 40% closer on code. The `same top result` rates differ
157
+ by less than the noise: the 95% intervals are 95.0-97.4% for ours and
158
+ 95.9-98.0% for Unsloth's.
159
+ - At about 175 MB ours is 11% closer. The `same top result` rates again
160
+ overlap.
161
+ - We did not ship a 5-bit file: ours only tied Unsloth's.
162
+ - Our `Q8_0` is tensor-for-tensor identical to Unsloth's and ggml-org's.
163
+
164
+ One honest limit: Unsloth's 4- and 5-bit files also quantize
165
+ `per_layer_model_proj`, which stock `llama-quantize` always keeps in BF16
166
+ (12.6 MB). Ours keeps it in BF16, so at equal size our 4-bit file has about
167
+ 8 MB less for everything else.
168
+
169
+ ## Search quality
170
+
171
+ Quantization reorders near-ties among the candidates. It does not make search
172
+ worse. How often a query finds its own passage among all passages of the set
173
+ (recall@1):
174
+
175
+ | File | 30 languages (1,000 queries) | code (400 queries) |
176
+ |---|---:|---:|
177
+ | `BF16` | 39.1% | 54.0% |
178
+ | `Q8_0` | 39.2% | 54.2% |
179
+ | `AD-Q6_K` | 38.8% | 54.0% |
180
+ | `AD-Q4_K_M` | 38.8% | 56.0% |
181
+
182
+ The task is hard on purpose: the query is the first quarter of a chunk and the
183
+ passage is the rest, so the absolute numbers are low. The point is that they
184
+ do not move.
185
+
186
+ ## What we found while building these
187
+
188
+ - **The embedding table is the cheapest place to save bytes.** `token_embd` is
189
+ half of the text model (134M of 270M parameters). Mean pooling averages its
190
+ rounding noise. Per megabyte saved it costs about 6 times less quality than
191
+ the transformer layers, so our files shrink the table first. Language-model
192
+ layouts usually do the opposite.
193
+ - **The output head is the most fragile tensor.** It is the 512-to-768
194
+ projection after pooling. Putting it alone in Q4_K saves 0.2 MB and costs more
195
+ than putting all of attention's q, k and v in Q4_K. It stays in Q8_0 in every
196
+ file.
197
+ - **Edge layers matter.** Blocks 0-5 and 18-23 are 2-3 times more sensitive than
198
+ the middle, so the middle gets fewer bits.
199
+ - **The imatrix needs three adjustments on this model.**
200
+ - Without `--override-kv tokenizer.ggml.add_eos_token=bool:false`,
201
+ `llama-imatrix` stops on an assertion.
202
+ - It needs `--no-ppl`, because there are no logits.
203
+ - It needs `-ub` equal to `-c`, because attention is bidirectional.
204
+ - The head, the embedding table and `per_layer_model_proj` get no importance
205
+ data at all.
206
+ - **The base is exact.** Our BF16 and projector files are tensor-for-tensor
207
+ identical to ggml-org's conversions of the same checkpoint.
208
+
209
+ ## The calibration data
210
+
211
+ About 1.24M tokens from the [calibration corpora](https://huggingface.co/datasets/AtomicChat/calib-corpora)
212
+ pool: 60% Wikipedia in 30 languages and 40% source code. Everything is written
213
+ the way the model sees it at work:
214
+ - passages as `title: none | text: ...`, or `title: <file name> | text: ...` for code;
215
+ - queries taken from those passages under all seven task prefixes.
216
+
217
+ None of it overlaps the held-out eval set. The builder script and the corpus
218
+ itself are in the metrics repo.
219
+
220
+ ## How we measured
221
+
222
+ - **Reference:** our BF16 file. We ran it twice and got identical vectors.
223
+ - **Held-out set:** calib-corpora `eval/neutral` (81 Wikipedia articles in 30
224
+ languages, 1,000 query and passage pairs) and `eval/code` (100 source files,
225
+ 400 pairs). Each chunk of text is split in two: the first quarter becomes the
226
+ query, the rest becomes the passage.
227
+ - **Metrics:**
228
+ - the cosine between a file's vector and the reference vector for the same text;
229
+ - the share of queries whose best passage, out of every passage in the set,
230
+ is the same as with the reference;
231
+ - 95% intervals by bootstrap over documents.
232
+ - **Setup:** `llama-server --embeddings --pooling mean -fa off` on an Apple M4
233
+ Max (Metal), llama.cpp commit `2690873`. All files embed the 2,800 texts in
234
+ about 25 seconds, and the smaller files are not faster on this machine.
235
+
236
+ ## Reproducing a file
237
+
238
+ ```bash
239
+ python convert_hf_to_gguf.py embeddinggemma-2 --no-lazy --outtype bf16 --model-name embeddinggemma-2 \
240
+ --outfile embeddinggemma-2-BF16.gguf
241
+ python build_calib.py --pool calib-corpora/pool --tokenizer embeddinggemma-2/tokenizer.json --tokens 1000000 -o calib.txt
242
+ llama-imatrix -m embeddinggemma-2-BF16.gguf -f calib.txt -o imatrix.gguf -c 512 -b 512 -ub 512 \
243
+ --parse-special --no-ppl --override-kv tokenizer.ggml.add_eos_token=bool:false
244
+ M='(attn_(q|k|v|output)|ffn_(gate|up|down))\.weight$'
245
+ llama-quantize --imatrix imatrix.gguf \
246
+ --tensor-type '^output\.weight$=q8_0' --tensor-type '^token_embd\.weight$=iq4_xs' \
247
+ --tensor-type '^blk\.\d+\.(inp_gate|proj)\.weight$=q4_k' \
248
+ --tensor-type "^blk\.([0-5])\.$M=q5_k" --tensor-type "^blk\.([6-9]|1[01])\.$M=iq4_xs" \
249
+ --tensor-type "^blk\.(1[2-7])\.$M=iq4_xs" --tensor-type "^blk\.(1[89]|2[0-3])\.$M=q4_k" \
250
+ embeddinggemma-2-BF16.gguf embeddinggemma-2-AD-Q4_K_M.gguf Q4_K_M
251
+ ```
252
+
253
+ `AD-Q6_K` uses these types:
254
+ - `token_embd` in q5_k;
255
+ - `inp_gate` and `proj` in q8_0;
256
+ - blocks 0-5 and 18-23 in q8_0;
257
+ - blocks 6-17 in q6_k;
258
+ - `output` in q8_0.
259
+
260
+ The exact rules are in the quantize logs in the metrics repo.
261
+
262
+ ## Model details
263
+
264
+ - **Base:** [google/embeddinggemma-2](https://huggingface.co/google/embeddinggemma-2), revision `914f7f8`, Apache 2.0.
265
+ - **Text model:** 270M parameters, 24 layers, width 512. It outputs 768-dimensional vectors that can be shortened to 512, 256 or 128, and has an 8K context.
266
+ - **Projector:** the vision encoder (170M) and the audio encoder (300M).
267
+ - **llama.cpp:** needs a build with the `gemma-embedding2` architecture (llama.cpp PR #30054, merged on 6 October 2026). We built and tested with commit `26908739bc8a`.
embeddinggemma-2-AD-Q4_K_M.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89e06b33cfdee673cb8dca25a1619c371217ce9557599183cd7d683cc2535d00
3
+ size 175375936
embeddinggemma-2-AD-Q6_K.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0702bd78997f143a8b53f8997302720866e4cdfc85f162f5c3b5f538cf453f7b
3
+ size 245302848
embeddinggemma-2-BF16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0714447d3cd8d9f55cafdc4a93e5699a8347f59b7dc78f65df43a0ce6828ccc
3
+ size 557950240
embeddinggemma-2-Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60b2a9e5f0673aa25931d285a73ae712e447fcc3439330102a8eabea31da7c73
3
+ size 309855520
mmproj-embeddinggemma-2-BF16.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5eef9a400d02ee8db6c12d60f5ccbdd04481285288484bdc59abc91e22f69e0
3
+ size 982074880
mmproj-embeddinggemma-2-Q8_0.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bebe3951e09e0b232422fb58c9d6f9f271640808a6bfd698f9c65696b315308c
3
+ size 554821120