Feature Extraction
Transformers
Safetensors
sentence-transformers
multilingual
embedding_gemma2
embedding
multimodal-embedding
multimodal
vision
audio
video
image-feature-extraction
audio-feature-extraction
video-feature-extraction
sentence-similarity
Instructions to use google/embeddinggemma-2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use google/embeddinggemma-2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="google/embeddinggemma-2")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("google/embeddinggemma-2") model = AutoModel.from_pretrained("google/embeddinggemma-2", device_map="auto") - sentence-transformers
How to use google/embeddinggemma-2 with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("google/embeddinggemma-2") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Inference
- Notebooks
- Google Colab
- Kaggle
Commit ·
557f468
1
Parent(s): eaab874
Update README.md (#2)
Browse files- Update README.md (4e4b8d86ae5f7f5d1ce435f7059814849f786ca0)
31 unmodified lines323334353637383940414243444546474849505152535455565758596061626364656667683 unmodified lines7273747576777879807 unmodified lines88899091929394959697989910010110210310410510610710810911069 unmodified lines18018118218318418518631 unmodified lines<b>License</b>: <a href="https://ai.google.dev/gemma/docs/gemma_4_license" target="_blank">Apache 2.0</a> | <b>Authors</b>: <a href="https://deepmind.google/models/gemma/" target="_blank">Google DeepMind</a></p>**EmbeddingGemma 2** is an open multimodal embedding model built by Google DeepMind. Built on top of the Gemma 4 decoder architecture, EmbeddingGemma 2 maps text (incl. code), images, video, and audio inputs into a single, unified 768-dimensional vector space. This open-weight model has 740M total parameters, combining a 270M parameter text model with modular vision (170M) and audio (300M) encoders.Designed to run on consumer hardware such as mobile devices and laptops, EmbeddingGemma 2 delivers low-latency semantic representations for on-device applications, like search, retrieval-augmented generation (RAG), classification, and clustering.EmbeddingGemma 2 builds upon the architectural and capability advancements of Gemma 4, introducing several core features: * **Native multimodality:** Unifies 4 modalities (text, images, video, and audio) in a single shared 768-dimensional embedding space.* **Multilinguality and code:** EmbeddingGemma 2 understands 100+ languages, and achieves a \~14% improvement on code tasks relative to our last EmbeddingGemma (MTEB code). * **Cross-modality semantics:** Trained to capture semantic similarity, across the modality boundaries. This means equivalent concepts, whether expressed in text, source code, images, video, or audio, are co-located in the embedding space.* **Flexible footprint:** Combines a 270M parameter text backbone (130M transformer \+ 140M embedder) with selectively loadable vision (170M) and audio (300M) encoders, allowing developers to load only the modalities required for their use case.* **Matryoshka Representation Learning (MRL):** Native support for truncated vector projections across 128d, 256d, 512d, and 768d, enabling up to a **6x reduction** in vector storage costs with minimal impact on quality.* **Context length:** 8K token context window, capable of processing interleaved multimodal input.* **Task-steered representations:** Uses lightweight text instruction prefixes to optimize vector projections for different tasks (search, classification, clustering, semantic similarity, etc).## **Model Overview**EmbeddingGemma 2 is designed to reduce fragmentation of per-modality retrieval stacks, where text, image, and audio each require a separate model and a separate vector index. It employs a decoder-based architecture, built on the Gemma 4 backbone, that projects all four supported modalities into a single shared embedding space.Modality-specific encoders operate in a front-end capacity, converting raw image, video, and audio input into token representations that match the decoder's input specification. The decoder then processes the resulting sequence \- including interleaved modalities \- and a mean-pooling layer collapses it into a single vector, which a final head projects from the 512-dimensional model space to the 768-dimensional output space. Encoders are modular, so they can be selectively loaded at runtime: text-only fits in 270M parameters, and the vision and audio towers are added only when those modalities are needed.During inference, all modalities draw from one shared 8,192-token context window at differing token costs, so a single request can embed an image and its caption into the same vector. Rather than emitting a fixed-width representation, EmbeddingGemma 2 is trained with Matryoshka Representation Learning, allowing the 768-dimensional output to be truncated to 512, 256, or 128 dimensions at serving time. Applications can optimize vector storage against retrieval quality without re-encoding its corpus or swapping checkpoints.### EmbeddingGemma 2| Parameters | Total | 740M || :---- | :---- | :---- || | **Transformer** | 130M || | **Embeddings** | 140M || | **Encoders** | *Vision:* 170M *Audio:* 300M || **Architecture** | **Layers** | 24 || | **Model Dimension** | 512 || | **Hidden Dimension** | 2048 |3 unmodified lines| | **\# KV-Heads (Local/Global)** | 2/1 || | **Local:Global** | 5:1 || | **Attention** | GQA/MQA || | **Head Projection** | 512→768 || | **Activation** | Gated FFN with GELU || | **Pooling** | Mean Pooling || **Input/Output** | **Supported Modalities** | Text, Images, Video, Audio || | **Context Window** | 8,192 tokens || | **Native Output Dimension** | 768 |7 unmodified lines| Modality | Benchmark | Metric | EmbeddingGemma 2 | EmbeddingGemma 1 || :---- | :---- | :---- | :---- | :---- || *Text* | Massive Text Embedding Benchmark (MTEB, multilingual, v2) *Hugging Face* | Mean (Task) | 61.36 | 61.15 || | Massive Text Embedding Benchmark (MTEB, code, v1) *Hugging Face* | Mean (Task) | 78.54 | 68.76 || *Image* | Massive Image Embedding Benchmark (MIEB, lite) *Hugging Face* | Mean (TaskType) | 64.64 | \- || | Massive Multimodal Embedding Benchmark (MMEB v2 \- Image) *Tiger-Lab* | Recall@1 | 57.28 | \- || | Massive Multimodal Embedding Benchmark (MMEB v2 \- VisDoc) *Tiger-Lab* | NDCG@5 | 67.84 | \- || *Video* | Massive Multimodal Embedding Benchmark (MMEB v2 \- Video) *Tiger-Lab* | Recall@1 | 50.67 | \- || *Audio* | Massive Sound Embedding Benchmark (MSEB, Retrieval) *Google Research* | MRR@10 | 69.54 | \- || | Massive Audio Embedding Benchmark (MAEB) *Hugging Face* | Overall | 49.39 | \- |### Evaluation Results with Vector TruncationWith MRL, EmbeddingGemma 2 embedding representations can be truncated below the native 768d, to 128d, 256d, and 512d representations and re-normalized.With this, model users can reduce storage requirements, with minimal quality impact down to 256d. 128d is best suited to text-only workloads.| Output Dimension | Compression Ratio | MTEB *(multilingual, v2) Mean(Task)* | MTEB *(eng, v2) Mean(Task)* | MTEB *(code, v1) Mean(Task)* | MIEB *(lite) Mean(TaskType)* | MMEB (v2) *Overall* | MSEB *(Retrieval) Overall* | MAEB *Overall* || :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: || 768d (Full) | 1:1 | 61.36 | 68.46 | 78.54 | 64.64 | 59.01 | 69.54 | 49.39 || 512d | 1:1.5 | 61.17 | 68.41 | 77.24 | 64.32 | 58.38 | 69.18 | 49.21 || 256d | 1:3 | 60.41 | 67.78 | 76.18 | 63.13 | 56.24 | 66.76 | 48.91 || 128d | 1:6 | 57.89 | 65.68 | 71.41 | 59.06 | 45.65 | 56.71 | 46.92 |69 unmodified linesAt runtime, please adhere to the following guidelines:* **Re-normalize after truncating:** slicing a unit-length vector does not preserve unit length. The shortened vector must be L2-normalized before it is used for cosine similarity. Skipping this step degrades ranking quality silently — it produces plausible-looking scores rather than an error.* **Queries and documents must share a dimension.** A 768-dimensional query cannot be scored against a 128-dimensional corpus.*To avoid truncating and normalizing yourself, you should pass in the `truncate_dim` and `normalize_embeddings` fields when calling `model.encode()`:31 unmodified lines32333435363738394041424344454647484950515253545556575859603 unmodified lines6465666768697071727 unmodified lines808182838485868788899091929394959697989910010110269 unmodified lines17217317417517617717831 unmodified lines<b>License</b>: <a href="https://ai.google.dev/gemma/docs/gemma_4_license" target="_blank">Apache 2.0</a> | <b>Authors</b>: <a href="https://deepmind.google/models/gemma/" target="_blank">Google DeepMind</a></p>**EmbeddingGemma 2** is an open multimodal embedding model built by Google DeepMind which maps text (incl. code), images, video, and audio inputs—and combinations thereof—into a single, unified 768-dimensional vector space. The model has 740M total parameters, combining a 270M parameter text model with modular vision (170M) and audio (300M) encoders.Designed to run on consumer hardware such as mobile devices and laptops, EmbeddingGemma 2 delivers low-latency semantic representations for on-device applications, like search, retrieval-augmented generation (RAG), classification, and clustering.## **Model Overview**EmbeddingGemma 2 builds upon the architectural and capability advancements of Gemma 4, offering several core features: * **Native multimodality:** Native multimodality: Unifies 4 modalities (text, images, video, and audio) in a single shared 768-dimensional embedding space.* **Multilinguality and code:** EmbeddingGemma 2 understands 100+ languages, and achieves a \~14% improvement on code tasks relative to its predecessor. * **Flexible footprint:** Combines a 270M parameter text backbone (130M transformer \+ 140M embedder) with selectively loadable vision (170M) and audio (300M) encoders, allowing developers to load only the modalities required for their use case.* **Matryoshka Representation Learning (MRL):** Native support for truncated embeddings across 128d, 256d, 512d, and 768d, enabling up to a **6x reduction** in vector storage costs with minimal impact on quality.* **Context length:** 8K token context window, capable of processing minutes of audio or video.* **Task-steered representations:** Uses lightweight text instruction prefixes to optimize embeddings for different tasks (search, classification, clustering, semantic similarity, etc.).### EmbeddingGemma 2| Parameters | Total | 740M || :---- | :---- | :---- || | **Backbone** | 130M || | **Embedder** | 140M || | **Modality Encoders** | *Vision:* 170M *Audio:* 300M || **Architecture** | **Layers** | 24 || | **Model Dimension** | 512 || | **Hidden Dimension** | 2048 |3 unmodified lines| | **\# KV-Heads (Local/Global)** | 2/1 || | **Local:Global** | 5:1 || | **Attention** | GQA/MQA || | **Activation** | Gated FFN with GELU || | **Pooling** | Mean Pooling || | **Projection Layer** | 512→768 || **Input/Output** | **Supported Modalities** | Text, Images, Video, Audio || | **Context Window** | 8,192 tokens || | **Native Output Dimension** | 768 |7 unmodified lines| Modality | Benchmark | Metric | EmbeddingGemma 2 | EmbeddingGemma 1 || :---- | :---- | :---- | :---- | :---- || *Text* | Massive Text Embedding Benchmark (MTEB, multilingual, v2) | Mean(Task), Multiple | 61.36 | 61.15 || | Massive Text Embedding Benchmark (MTEB, code, v1) | Mean(Task), NDCG@10 | 78.68 | 68.76 || *Image* | Massive Image Embedding Benchmark (MIEB, lite) | Mean(TaskType), Multiple | 64.64 | \- || | Massive Multimodal Embedding Benchmark (MMEB v2 \- Image) | Mean(Task), Hit@1 | 57.28 | \- || | Massive Multimodal Embedding Benchmark (MMEB v2 \- VisDoc) | Mean(Task), NDCG@5 | 67.84 | \- || *Video* | Massive Multimodal Embedding Benchmark (MMEB v2 \- Video) | Mean(Task), Hit@1 | 50.67 | \- || *Audio* | Massive Sound Embedding Benchmark (MSEB, Retrieval) | Mean(Task), MRR@10 | 69.54 | \- || | Massive Audio Embedding Benchmark (MAEB) *Hugging Face* | Mean(Task), Multiple | 49.39 | \- |### Evaluation Results with Vector TruncationWith MRL, EmbeddingGemma 2 representations can be truncated below the native 768d to 128d, 256d, and 512d representations and re-normalized.With this, model users can reduce storage requirements, with minimal quality impact down to 256d. 128d is best suited to text-only workloads.| Output Dimension | Compression Ratio | MTEB *(multilingual, v2) Mean(Task)* | MTEB *(eng, v2) Mean(Task)* | MTEB *(code, v1) Mean(Task)* | MIEB *(lite) Mean(TaskType)* | MMEB (v2) *Overall* | MSEB *(Retrieval) Mean(Task)* | MAEB *Mean(Task)* || :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: || 768d (Full) | 1:1 | 61.36 | 68.46 | 78.68 | 64.64 | 59.01 | 69.54 | 49.39 || 512d | 1:1.5 | 61.17 | 68.41 | 77.24 | 64.32 | 58.38 | 69.18 | 49.21 || 256d | 1:3 | 60.41 | 67.78 | 76.18 | 63.13 | 56.24 | 66.76 | 48.91 || 128d | 1:6 | 57.89 | 65.68 | 71.41 | 59.06 | 45.65 | 56.71 | 46.92 |69 unmodified linesAt runtime, please adhere to the following guidelines:* **Re-normalize after truncating:** slicing a unit-length vector does not preserve unit length. The shortened vector must be L2-normalized before it is used for cosine similarity. Skipping this step degrades ranking quality silently—it produces plausible-looking scores rather than an error.* **Queries and documents must share a dimension.** A 768-dimensional query cannot be scored against a 128-dimensional corpus.*To avoid truncating and normalizing yourself, you should pass in the `truncate_dim` and `normalize_embeddings` fields when calling `model.encode()`:
README.md+24-32