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] - Notebooks
- Google Colab
- Kaggle
Fast CPU inference for EmbeddingGemma 2: 2.46x over PyTorch / ONNX Runtime (open source)
A short text query was stuck waiting 5.5 seconds behind one big image.
Now it waits 9 ms.
That's one of the things I fixed while making Google's EmbeddingGemma 2 fast on plain CPUs, with no GPU, for text, images, audio and video.
Starting from @QuixiAI's embeddinggemma.c, I rewrote the hot paths:
β‘ AVX-VNNI int8 matrix kernel, about 7x faster per core, on CPUs without AVX-512
π§ Tiled online-softmax attention (GQA + sliding windows)
π§΅ P/E-core aware scheduling, so small queries never starve behind big ones
πΎ One copy of the weights in memory: ~1.4 GB vs ~4.8 GB for PyTorch
Results on a laptop i7-14700HX:
π Faster than PyTorch and ONNX Runtime on 16/16 workloads
π 2.46x geometric-mean speedup over the fastest alternative per test
π― Cosine to the official FP32 embeddings β₯ 0.9991
I've only measured it on one machine so far, so I'd love benchmark runs on your CPU π
https://github.com/Yazeedx0/embeddinggemma-cpu-max