MLX conversion of Google EmbeddingGemma 2 in 5-bit affine format, retaining text, image, audio, and video encoders. The model produces normalized 768-dimensional embeddings. See the original model card for intended use, training information, evaluation, and limitations.
Quantization mode: affine, 5 bits, group size 64. The standard MLX-VLM policy quantizes the text encoder and audio projection. The vision and audio towers and vision projection remain BF16.
import mlx.core as mx
from transformers import AutoTokenizer
from mlx_vlm.embedding_loader import load_embedding_model
from mlx_vlm.utils import get_model_path
path = get_model_path("mlx-community/embeddinggemma-2-5bit")
model = load_embedding_model(path)
tokenizer = AutoTokenizer.from_pretrained(path)
inputs = tokenizer([
"task: search result | query: Which planet is known as the Red Planet?",
"title: none | text: Mars is known as the Red Planet.",
"title: none | text: Venus is often called Earth's twin.",
], padding=True, return_tensors="np")
embeddings = model(**{key: mx.array(value) for key, value in inputs.items()}).text_embeds
print(embeddings[:1] @ embeddings[1:].T)
# Optional Matryoshka truncation: use 128, 256, 512, or 768 dimensions.
embeddings = embeddings[:, :256]
embeddings /= mx.linalg.norm(embeddings, axis=-1, keepdims=True)
Apply the appropriate task prefixes from config_sentence_transformers.json. Queries and documents must use the same embedding dimension. Keep non-quantized weights and activations in BF16; do not cast this model to float16.
All modality weights and processor configuration files are included. Image, audio, and video preprocessing requires a Transformers build that exposes EmbeddingGemma2Processor. Validation used the model's supplied upstream Transformers 5.18.0.dev0 build; stock PyPI Transformers 5.18.0 does not yet expose this processor. The text-only example above uses AutoTokenizer and does not require that processor. With a compatible processor build:
from mlx_vlm import load
model, processor = load("mlx-community/embeddinggemma-2-5bit")
inputs = processor(images=[image], return_tensors="np") # image is a PIL image
embedding = model(**{key: mx.array(value) for key, value in inputs.items()}).text_embeds
All checked outputs were finite, unit-normalized, and had 768 dimensions. The text retrieval smoke test ranked the Mars passage above Venus. Checks cover six multilingual text inputs and synthetic image, audio, two-frame video, and text+image inputs; they are numerical smoke checks, not MTEB or a retrieval-quality benchmark. Cosine and absolute errors compare against the original checkpoint running in PyTorch FP32.
Input
Minimum cosine vs FP32
Maximum absolute error
audio
0.992494
0.012261
image
0.997334
0.007859
text
0.992759
0.013390
text_image
0.996334
0.009012
video
0.996727
0.009256
The full measurements, including truncated-vector comparisons, are in validation.json.
import os
os.environ["HF_ENDPOINT"] = "https://freeweights.allternit.com"
from transformers import AutoModel, AutoTokenizer
tok = AutoTokenizer.from_pretrained("mlx-community/embeddinggemma-2-5bit", revision="261866f6805342b010554507220e02199a579c74")
model = AutoModel.from_pretrained("mlx-community/embeddinggemma-2-5bit", revision="261866f6805342b010554507220e02199a579c74", device_map="auto")
sentence-transformersEmbed text with sentence-transformers.
import os
os.environ["HF_ENDPOINT"] = "https://freeweights.allternit.com"
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("mlx-community/embeddinggemma-2-5bit", revision="261866f6805342b010554507220e02199a579c74")
vectors = model.encode(["Hello"])