Instructions to use Mannyking/embeddinggemma-2-text-270m-coreml with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use Mannyking/embeddinggemma-2-text-270m-coreml with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("Mannyking/embeddinggemma-2-text-270m-coreml") 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
EmbeddingGemma 2 Text 270M β Core ML
This repository contains Core ML conversions of the 270M text component of
Google's official embeddinggemma-2 checkpoint. Each package uses a fixed
512-token input and returns one normalized 768-dimensional embedding.
Vision and audio are not included.
Conversion scripts, validation details, and the evidence trail live in the source repository.
Packages
| Package | Minimum platform | Saved size |
|---|---|---|
f32-ios15/EmbeddingGemma2F32.mlpackage |
iOS/iPadOS 15, macOS 12 | 1,090.2 MB |
f32-ios18/EmbeddingGemma2F32.mlpackage |
iOS/iPadOS 18, macOS 15 | 1,090.2 MB |
int4-ios18/EmbeddingGemma2Int4.mlpackage |
iOS/iPadOS 18, macOS 15 | 175.9 MB |
The regular F32 package targets iOS 15/macOS 12. The separately exported F32 iOS 18 package is required as the source for Core ML int4 compression; it was also the F32 reference used in NanoNQ below.
The int4 package uses symmetric post-training weight compression in blocks of 32, including attention weights. Activations remain float32. This is not the QAT conversion used by the official LiteRT-LM bundle.
Tokenizer and Inputs
All packages share the unchanged upstream assets in tokenizer/.
Tokenization and prompting happen outside the Core ML model.
| Name | Type and shape |
|---|---|
input_ids |
Int32 [1, 512] |
attention_mask |
Int32 [1, 512] |
embedding |
Float32 [1, 768] |
Use right padding. Include BOS and EOS tokens; <pad> is ID 0, <eos> is
ID 1, <bos> is ID 2, and <unk> is ID 3. The attention mask is 1 for input
tokens and 0 for padding. The 512-token limit includes prompts and special
tokens. Reject empty inputs and split longer documents before tokenization
rather than silently truncating them.
Use these prompts before tokenization, as advised by the Gemma team:
- Query:
task: search result | query: - Document:
title: none | text:
Validation
The original checkpoint is pinned to
914f7f89142e33e77833254d9c9b90c3cef7303b.
Both saved F32 packages passed macOS CPU parity checks against 13
original-model fixtures, including exact 511- and 512-token inputs.
Maximum absolute error against the padded F32 baseline was approximately
2.7e-7.
NanoNQ Retrieval
The models searched the same 5,012 passages for 50 questions from NanoNQ. Twenty-three passages above 512 prompted tokens were excluded; none contained a labeled relevant passage. Hit@k counts questions with at least one labeled relevant passage in the first k results.
| Model | Saved size | Hit@1 | Hit@5 | Hit@10 |
|---|---|---|---|---|
| Core ML F32 (iOS 18 source) | 1,090.2 MB | 35/50 | 44/50 | 45/50 |
| Core ML int4 | 175.9 MB | 33/50 | 43/50 | 46/50 |
| LiteRT-LM int4 | 164.6 MB | 34/50 | 43/50 | 44/50 |
This is a quick, single-dataset check for large retrieval quality regressions. All three appear capable on this check. Validation was performed on macOS CPU; these results do not measure device performance.
Source and License
Based on google/embeddinggemma-2, created by Google DeepMind and licensed under Apache 2.0. The tokenizer assets are unchanged. The weights were converted to text-only Core ML packages by Mannyking; the int4 package additionally applies post-training weight compression. These conversions are distributed under Apache 2.0.
- Downloads last month
- -
Model tree for Mannyking/embeddinggemma-2-text-270m-coreml
Base model
google/embeddinggemma-2