EmbeddingGemma 2
Follow modular encoders into one bidirectional backbone, the contrastive objective and training curriculum, and the trade-offs behind its new Pareto frontier.
Jump to a section
One vector for text, images, audio and video
EmbeddingGemma 2 maps text, code, images, audio, video and interleaved mixtures of them to a single 768-dimensional unit vector. Every input lands in the same space, so a query in one modality can retrieve a target in another.
Earlier designs forced a choice. CLIP-style models give each modality its own tower, so they can compare an image with a caption but cannot read an image and a caption together as one input. Embedding models adapted from multimodal LLMs can read mixed input, but they usually have several billion parameters. EmbeddingGemma 2 reads mixed input at 744M parameters and loads only the encoders a task needs.
The paper's headline result is a new size–quality frontier on four benchmark suites. In each panel the star sits above the previous frontier at its parameter count, which counts only the parts each benchmark uses: 271M for code, 439M for vision and 577M for audio.
A new size–quality frontier on four benchmarks
- New frontier
- Prior frontier
- Gain
- Other models
Horizontal: parameters, log scale. Vertical: leaderboard score, Mean(Task) except MIEB(lite), which uses Mean(Type).
Redrawn from Figure 2. Points were digitized from the paper’s vector graphic; the starred and frontier values match Tables 6–10. EmbeddingGemma 2 counts only the parameters each benchmark uses: 271M for code, 439M for vision, 577M for audio. Baselines are as reported on public leaderboards.
Read the plotted frontier values
| Benchmark | EmbeddingGemma 2 | Closest prior frontier point |
|---|---|---|
| MTEB(Code) | 271M · 78.68 | pplx-0.6B · 596M · 75.85 |
| MMEB-v2 | 439M · 59.01 | CAFe-0.5B · 894M · 49.33 |
| MAEB | 577M · 49.87 | jina-v5-nano · 986M · 50.14 |
| MIEB(lite) | 439M · 65.67 | SigLIP-SoViT · 878M · 53.50 |
The modularity shows up in memory too. On a Google Pixel 11 Pro the int4 per-channel checkpoint peaks at 191 MB for text, 447 MB with vision and 567 MB with every encoder, runtime compilation overhead included.
Encoders that only produce tokens
Think of the model as one reader with optional eyes and ears. A vision encoder turns an image, or each sampled video frame, into a short sequence of "soft tokens". An audio encoder does the same for sound at 25 tokens per second. Text goes through the ordinary embedding table. Linear adapters project every soft token to the backbone width of 512, and the pieces are concatenated in their original order between delimiter tokens.
Because the encoders only produce input tokens, they are modular. Text-only search skips both of them and runs 271M parameters. The audio encoder is frozen and bit-identical to Gemma 4's; the vision encoder is trained, which matters later. Use the selector to see which pieces each configuration loads.
Choose which encoders to load
Soft tokens are projected to dM = 512 and interleaved at their positions in the input.
Redrawn from Figure 1 and §2.1. Component sizes are the paper’s rounded figures; totals are as reported (text 271M, vision–language 439M, audio–language 577M, all 744M). The audio encoder is frozen and identical to Gemma 4’s; the vision encoder is trained.
EmbeddingGemma 2 · Figure 1, §2.1–2.2The backbone is a Gemma 4 decoder with its causal mask switched to bidirectional attention. A generator must not see future tokens. An embedding model should, because its vector summarises the whole input. After 24 layers the model mean-pools every position, projects 512 to 768 dimensions and rescales the result to unit length. For token embeddings and the bidirectional transformer ,
where is a linear map. Whatever its length or modality, every input becomes one point on the unit sphere, and similarity is a dot product.
One part of Gemma 4 did not survive the move to multimodal input. Gemma 3n and Gemma 4 give each layer an extra input built from a projection of the token embeddings plus a dedicated lookup table indexed by token ID. Image and audio soft tokens have no token ID, so the table cannot help them, and it costs memory. EmbeddingGemma 2 keeps only the projection. In the paper's ablation, dropping the table scored higher in every MMEB-v2 category, 55.46 overall against 55.07.
Where each layer’s extra input comes from
| MMEB-v2 (Table 2) | Overall | Image | Video | VisDoc |
|---|---|---|---|---|
| Projection only | 55.46 | 54.67 | 47.82 | 62.37 |
| With lookup table | 55.07 | 54.57 | 47.13 | 61.76 |
One layer l of 24, from §2.1, with dP = dM = 512. Dropping the table removed parameters and scored higher in every category of this intermediate-recipe ablation; the paper reports similar gains on text-only evaluations.
EmbeddingGemma 2 · §2.1, §3.1, Table 2How long one input can get
Each modality has its own token budget. Images are pooled to at most soft tokens, 280 by default and anywhere from 70 to 1,120 at inference. Audio gives 25 per second. Video is sampled at 1 frame per second and capped at 32 frames, at 140 tokens per frame by default. Each image, frame or audio segment adds two delimiters, and training sequences reach 8,192 positions.
A 120-second clip with its soundtrack therefore needs at most positions, which fits. The same 32 frames at the image budget need on their own, more than any training sequence. Change the inputs and budgets below.
Count the positions one input can occupy
6,075 positions at most. This fits within the 8,192 positions used in training. The video yields 45 frames at 1 fps; only 32 are kept, by truncation or uniform sampling.
- Text32
- Image 1280
- 32 video frames4,480
- 45 × 1 s soundtrack1,125
- Delimiters and BOS/EOS158
Upper bound from §2.2. Images are pooled to at most the chosen budget; audio produces 25 soft tokens per second; video is sampled at 1 fps and capped at 32 frames. Each image, frame and audio segment adds two delimiters. We count each 1-second soundtrack segment with its own delimiters and do not count the MM:SS timestamp text, so a real sequence differs slightly. The text count is yours to set; it depends on the tokenizer.
EmbeddingGemma 2 · §2.2What the loss pushes apart
Each training example has a query , a positive target and hard negatives . With cosine similarity and temperature , the contrastive loss is
The denominator collects three kinds of competitor. sums over the example's own hard negatives, and over the other examples' positive targets. The same-tower term also pushes query away from query and target away from target, which keeps queries and documents from settling into two separate regions of the sphere. A mask removes example when its query or target duplicates example 's, so a repeated target is never penalised as a negative.
What query 1 is contrasted against
| p⁺1 | p⁺2 | p⁺3 | p⁺4 | p⁻1 | p⁻2 | p⁻3 | p⁻4 | q1 | q2 | q3 | q4 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| p⁺1 | Targets are also pushed apart: sim(p⁺i, p⁺j) | |||||||||||
- Positive (numerator)
- Hard negative
- In-batch negative
- Same-tower negative
- Masked by 1TN
11 terms in the denominator for query 1: 1 positive, 1 hard negative, 3 in-batch and 6 same-tower.
A batch of B = 4 with one hard negative each. Select a query row. Other examples’ hard negatives are not in LC; the listwise loss in Equation 4 does use them. The 1TN mask removes pairs whose query or target duplicates another example’s, so a repeated target is never treated as a negative.
EmbeddingGemma 2 · §2.3, Equations 2–3Three supporting losses shape the space further. A spread-out regulariser penalises and for random pairs. Independent uniform points on a -dimensional sphere have mean dot product 0 and mean squared dot product , so the penalty pushes the space toward that isotropic baseline.
Distillation matches the student's vectors to truncated, normalised Gemini Embedding 2 vectors, . For unit vectors that equals , so matching a teacher is the same as maximising cosine similarity with it. Matryoshka Representation Learning applies each loss to the first 768, 512, 256 and 128 coordinates, which makes every one of those prefixes a usable embedding.
The contrastive loss in code
This implements Equation 2 with one hard negative per example, on a batch where the third example repeats the first one's target. The temperature is our illustrative choice, because the paper does not report . The last lines check the sequence-length bounds from the previous section.
1import math
2
3def cos(a, b):
4 dot = sum(x * y for x, y in zip(a, b))
5 return dot / math.sqrt(sum(x * x for x in a) * sum(y * y for y in b))
6
7def contrastive_loss(q, p, hard, tau=0.2, mask=True):
8 """Equation 2 with one hard negative per example."""
9 B, total = len(q), 0.0
10 e = lambda a, b: math.exp(cos(a, b) / tau)
11 for i in range(B):
12 if mask: # 1_TN drops j when its query or target duplicates example i
13 others = [j for j in range(B) if q[j] != q[i] and p[j] != p[i]]
14 else:
15 others = [j for j in range(B) if j != i]
16 z_p = e(q[i], p[i])
17 z_hn = e(q[i], hard[i])
18 z_ib = sum(e(q[i], p[j]) for j in others)
19 z_stn = sum(e(q[i], q[j]) + e(p[i], p[j]) for j in others)
20 total -= math.log(z_p / (z_p + z_hn + z_ib + z_stn))
21 return total / B
22
23q = [[1.0, 0.2], [0.1, 1.0], [0.9, 0.4]]
24p = [[0.9, 0.1], [0.1, 0.9], [0.9, 0.1]] # example 3 repeats example 1's target
25hard = [[0.2, 1.0], [1.0, 0.3], [0.3, 1.0]]
26
27masked, unmasked = contrastive_loss(q, p, hard), contrastive_loss(q, p, hard, mask=False)
28assert masked < unmasked # without 1_TN, a duplicate target is punished as a negative
29print(round(masked, 3), round(unmasked, 3))
30
31# Section 2.2 upper bounds: soft tokens plus two delimiters per image, frame or audio segment
32video_120s = min(120, 32) * (140 + 2) + 120 * (25 + 2) + 2 # frames, soundtrack, BOS/EOS
33assert video_120s == 7786 and video_120s <= 8192
34assert 32 * (280 + 2) > 8192 # 32 frames at the image budget alone exceed the training lengthWithout the mask, examples 1 and 3 each treat the other's identical target as a negative, and the loss rises for no reason the model can fix. A production loss also needs batched matrix operations, multiple hard negatives, the MRL sub-losses and the listwise Plackett–Luce variant for ranked targets.
Distil first, then contrast
The recipe separates what the model sees from what it optimises. Text pre-finetuning comes first, on roughly 300B tokens and almost entirely distillation. Multimodal pre-finetuning adds images, audio, video and documents over about 2T tokens under pure distillation. Multimodal finetuning, about 600B tokens, drops the teacher in favour of the contrastive loss, the spread-out regulariser and MRL. The final checkpoint averages the end of finetuning with a much earlier checkpoint from the same run.
Change the data first, then the objective
Width is proportional to tokens seen, about 2.9T in total.
- Text pre-finetuningText: QA, similarity, code and web search pairs
Distillationalmost allContrastivesmall weight
- Multimodal pre-finetuningAdds images, audio, video and documents
Distillationonly
- Multimodal finetuningHigher-quality, task-specific data
Contrastivereplaces distillationSpread-outregularizerMRL768/512/256/128
- Model mergingUnweighted average of the final finetuning checkpoint and a significantly earlier one from the same run.
- Quantization tail patchA separate stage distills int4 (Q4_0, Q4_C) backbone and W8A8 vision checkpoints from the frozen float model.
From §2.4. Distillation matches truncated, normalized Gemini Embedding 2 vectors for queries, positives and hard negatives. Finetuning drops it so the space can fit this model’s size and Matryoshka dimensions.
EmbeddingGemma 2 · §2.4The reason to stop distilling is that the teacher's space was not shaped for a 744M student or for 128-dimensional prefixes. When the paper continued distillation for roughly the same compute, MMEB-v2 stayed flat at 52.28; switching to the contrastive recipe reached 55.46. A second ablation explains why the trained vision encoder matters: freezing the Gemma 4 vision encoder instead cost 4.1 points.
Third stage
- Multimodal pre-finetuning
- + Extra distillation
- + Contrastive finetuning
Same starting checkpoint and a similar compute budget. More distillation plateaus; the contrastive finetuning recipe adds 3.2 points overall, mostly on images and video. MMEB-v2 on intermediate recipes, so these are not final-model numbers.
EmbeddingGemma 2 · §3, Table 3These ablations use intermediate recipes, so their scores are not final-model numbers.
What cheaper settings cost
Fewer vision tokens. More tokens help visual documents, where small text matters, well past the 280-token training budget. Images flatten at 280. Video gets worse at 560 per frame, which the authors attribute to diluted attention and mean pooling over very long sequences.
More vision tokens help documents, not video
Table 5 (top): one intermediate checkpoint trained at 280 tokens per image and 140 per video frame, evaluated with a single budget for all MMEB-v2 tasks. Visual documents keep improving past the training budget; images flatten at 280; video drops from 48.51 to 46.52 at 560, which the paper attributes to diluted attention and mean pooling over long sequences.
EmbeddingGemma 2 · §3.4, Table 5Shorter vectors. Every suite keeps at least 95% of its score at 256 dimensions, a third of the storage. At 128, MMEB-v2 and spoken-query retrieval drop sharply. Native audio also beats transcribing speech first: even 256-dimensional native embeddings outscore full-width embeddings of ASR text. The paper attributes the gap to transcription errors from accents, homophones and audio artifacts, which native audio avoids.
Truncate the vector, keep most of the score
Mean scores from Tables 7–11 (MSEB is overall MRR@10). Byte counts are our arithmetic for uncompressed float32 vectors. Every suite keeps at least 95% of its score at 256 dimensions; MMEB-v2 and MSEB fall sharply at 128. Even the 256-d native-audio embedding beats full-width embeddings of ASR transcripts.
EmbeddingGemma 2 · Tables 7–11Consider a team that stores 768-dimensional vectors for scanned invoices embedded at 280 vision tokens, and proposes truncating to 128 dimensions and embedding at 70 tokens to cut cost. Both changes hit documents hardest. In the budget ablation, visual-document NDCG@5 fell from 63.38 at 280 tokens to 51.61 at 70, while 560 tokens raised it to 67.62. Truncating to 128 dimensions cut the MMEB-v2 visual-document average from 67.8 to 49.5. Truncating to 256 is the safer saving, at 62.6 on visual documents for a third of the storage. Whatever width you pick, re-embed queries and documents at the same width, compare them with cosine similarity, and measure on your own documents: these are benchmark averages.
Two limits hold at any setting. On English text the model regresses slightly against EmbeddingGemma 1 (MTEB English 68.46 versus 69.67) while improving on multilingual text and code. And its speech representations are dominated by meaning: zero-shot clustering by speaker gender scores 0.40, yet a linear probe recovers gender at 66.40. The information is present, but it is not the main axis of similarity.
Sources and further reading
- EmbeddingGemma 2: Unified and Efficient Multimodal Representations, arXiv:2610.37364, §2 to 4, Tables 1 to 11 and Figures 1 and 2. Architecture, objectives, recipe and all scores come from the paper, and the ablations use intermediate recipes. Figure 2 was digitized from the paper's vector graphic. Sequence-length totals, byte counts and the code are LiminalML derivations and teaching examples; we have not run the model or reproduced its benchmarks.
- Radford et al., Learning Transferable Visual Models From Natural Language Supervision (2021): CLIP, the separate-tower design described above.
- Kusupati et al., Matryoshka Representation Learning (2022): training nested prefixes of one embedding.