GoogleMaarten Grootendorst, Ian BallantyneTutorial
EmbeddingGemma 2: The Developer Guide
Summary
Modern search and RAG applications need to work across diverse content types, but finding models with strong retrieval accuracy and low latency without massive compute is challenging. EmbeddingGemma 2 is a compact open model under Apache 2.0, based on Gemma 4, that maps text, code, images, video, and audio into a unified 768-dimensional space with a modular architecture scaling from 270M to 740M parameters. Key capabilities include native multimodal retrieval, superior code understanding, modular memory footprint, and flexible vector storage via Matryoshka Representation Learning enabling dynamic truncation from 768 to 128 dimensions. Under the hood, it uses modular encoders—a text/code decoder, vision encoder, and audio encoder—that project into a shared space and can be loaded selectively to minimize memory. The developer guide demonstrates how to use sentence-transformers to load the model, embed with task prompts, handle media inputs, truncate dimensions, and choose configurations based on storage and recall needs.
Context
Modern search and RAG applications require models that handle diverse content types with strong retrieval accuracy and low latency, without massive compute infrastructure.
Approach / What changed
EmbeddingGemma 2 is a compact open model based on Gemma 4 that uses modular encoders for text/code, vision, and audio, projecting into a shared 768-dimensional space. It supports selective loading of encoders (270M to 740M parameters) and Matryoshka Representation Learning for dimension truncation. The developer guide shows how to use sentence-transformers to load the model, embed with task prompts, handle media inputs, and choose configurations.
Takeaways
EmbeddingGemma 2 maps text, code, images, video, and audio into a unified 768-dimensional vector space using modular encoders that can be loaded selectively (270M to 740M parameters).
Matryoshka Representation Learning (MRL) allows dynamic truncation of embeddings from 768 down to 128 dimensions, reducing storage by up to 6x while retaining most quality (e.g., 95% on image/video/speech at 256 dimensions).
The model shares a tokenizer and audio encoder with Gemma 4, enabling reduced memory footprint in on-device RAG pipelines, and embeddings from different encoder configurations are compatible in the same vector space.
FAQ
How do I load only the encoders I need?
Set vision_config or audio_config to None in config_kwargs when loading the model with SentenceTransformer. Disabled encoders are never loaded into memory, saving both weights and peak allocation. For example, text-only loads 270M parameters, text+vision loads 440M, and full multimodal loads 740M.
How can I reduce storage for embeddings?
Use Matryoshka Representation Learning by passing truncate_dim (512, 256, or 128) with normalize_embeddings=True. At 256 dimensions, storage is reduced by 3x while retaining most quality on text/code and about 95% on image/video/speech. At 128 dimensions, storage is reduced 6x but multimodal quality drops to around 75%.
Can I embed images, video, and audio with the model?
Yes, pass media as a dictionary keyed by modality (e.g., {"image": "sunset_beach.jpg"}) without a prompt. For interleaved text and media, use placeholders <|image|>, <|video|>, or <|audio|> in the text. All modalities project into the same 768-dimensional space for direct similarity comparison.
Source and freshness
- Source
- developers.googleblog.com
- Published
- Added to Yomu
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.