Instructions to use spawnlau/embeddinggemma-2-text-vision-440m-compact with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT-LM
How to use spawnlau/embeddinggemma-2-text-vision-440m-compact with LiteRT-LM:
# LiteRT-LM runs on various platforms (Android, iOS, Windows, Linux, macOS, IoT, Web/WASM) # and supports many APIs (C++, Python, Kotlin, Swift, JavaScript, Flutter). # For platform-specific integration guides, please refer to the official developer website: # https://ai.google.dev/edge/litert-lm # To try LiteRT-LM, the easiest way is to use our CLI tool. # 1. Install the LiteRT-LM CLI tool: pip install -U litert-lm # 2. Download and run this model locally: # See: https://ai.google.dev/edge/litert-lm/cli # A single .litertlm file in the repo is picked automatically; otherwise the CLI asks which one to run # (or pass its name right after the repo id). litert-lm run \ --from-huggingface-repo=spawnlau/embeddinggemma-2-text-vision-440m-compact \ --prompt="Write me a poem"
- Notebooks
- Google Colab
- Kaggle
EmbeddingGemma 2 Text-Vision 440M Compact
A compact LiteRT-LM package for on-device text and image retrieval in Gemma Gallery. The file is 309.56 MB, down from 387.71 MB (20.2% smaller).
This release specializes the existing quantized text-vision bundle for 256 input tokens, 70 vision tokens per image, and 768-dimensional normalized embeddings. The tokenizer, transformer layers, and weight precision are unchanged. The smaller file comes from removing unused input-size graphs, unreachable vision position entries, and redundant serialized data. No training or fine-tuning was performed.
The original and compact bundles produced bitwise-identical embeddings on the regression inputs tested on Windows and a Samsung Galaxy S25, when compared on the same backend. This is evidence for the tested workload, not a guarantee for every input or a new general accuracy benchmark.
Gemma Gallery app and downloads
The Android/iOS app source, photo-search features and demo videos are in Gemma Gallery on GitHub. This Hugging Face repository distributes the compact model, its build scripts and validation results.
The app's model download page links back to this model card and lists the compact and original download files, pinned revisions, SHA-256 values and integration status. The app README explains the local indexing and search behavior.
The current app manifest still pins the original bundle. The compact bundle has passed native model-loading and embedding checks on Samsung Galaxy S25; full app flows and iOS runtime validation remain pending. Use the download page to distinguish the released model artifact from the app's current default configuration.
Model details
| Item | Value |
|---|---|
| Original model | Google DeepMind EmbeddingGemma 2 |
| Source conversion | LiteRT Community text-vision 440M |
| Source revision | e301f74d5551b0c2641bd5cb4652a76239d5c5f8 |
| Source file | embeddinggemma-2-text-vision-440m.litertlm (generic CPU/GPU bundle) |
| Released file | eg2-gallery-compact.litertlm |
| Exact file size | 309,559,296 bytes |
| Format | LiteRT-LM .litertlm; tokenizer included |
| Inputs | Text and images; tested separately |
| Runtime configuration | max_input_length=256, vision_tokens_per_image=70 |
| Output | 768-dimensional embeddings, L2-normalized in the examples and tests |
| Retained text signatures | encoder_1x128, encoder_1x256 |
| Retained vision signatures | vision_70, vision_adapter_70 |
| Weight precision | Existing INT4 text/word embeddings, INT8 vision weights, and FP32 components retained |
| Tested runtime | LiteRT-LM 0.18.0 |
| License | Apache-2.0 |
The 440M name identifies the source text-vision variant. It is not a newly measured parameter count after removing unused position entries.
Samsung Galaxy S25 GPU results
Measured on Samsung Galaxy S25 / SM-S931U, Android 16, Qualcomm SM8750, using com.google.ai.edge.litertlm:litertlm-android:0.18.0. Both the text and vision backends used GPU.
| Metric | Original | Compact | Reduction |
|---|---|---|---|
| Model file size | 387.71 MB | 309.56 MB | 20.2% |
| Observed peak process memory (PSS) | 903.8 MiB | 768.8 MiB | 14.9% |
| Model initialization time | 2.87 s | 2.41 s | 16.1% |
| Text encoding latency (P50) | 29.25 ms | 28.58 ms | 2.3% |
| Image encoding latency (per image, P50) | 153.07 ms | 147.75 ms | 3.5% |
Each version had one GPU run with 73 English/Chinese text queries and 20 images. All 93 embeddings were bitwise identical between the original and compact bundles; the maximum absolute element difference was 0.0. Text-to-image rankings and decisions at cosine threshold 0.68 also matched.
P50 is the median across the inputs in that run. Each run used a fresh process and a fresh runtime cache; the OS page cache was not flushed. Initialization excludes model download and SHA-256 verification. Encoding times cover computeEmbedding, including preprocessing inside the runtime, but exclude image file reads, additional application preprocessing, database search, and UI work. PSS is a sampled whole-process memory measurement, not a separate GPU-memory measurement.
Both GPU runs started at a battery temperature of 36.6 degrees C, with Android thermal status 0. One run per version is not enough to establish a stable latency improvement or long-term thermal behavior. MB means 1,000,000 bytes; MiB means 1,048,576 bytes. Exact values and per-input timings are in the GPU report.
Download and run
Download the single bundle with the Hugging Face CLI:
hf download spawnlau/embeddinggemma-2-text-vision-440m-compact eg2-gallery-compact.litertlm --local-dir models
Use the embedding API in LiteRT-LM 0.18.0. Set both the engine and embedding options to the 70-token vision configuration; do not rely on upstream defaults.
pip install "litert-lm==0.18.0"
from pathlib import Path
from litert_lm import Backend, Content, EmbeddingEngine, EmbeddingOptions
cache = Path("runtime-cache")
cache.mkdir(exist_ok=True)
backend = Backend.GPU()
options = EmbeddingOptions(
normalize=True,
insert_special_tokens=True,
output_size=768,
vision_tokens_per_image=70,
)
with EmbeddingEngine(
"models/eg2-gallery-compact.litertlm",
backend=backend,
vision_backend=backend,
max_input_length=256,
vision_tokens_per_image=70,
cache_dir=str(cache),
) as engine:
query = engine.compute_embedding(
"task: search result | query: a cat by the window",
options=options,
).embedding
image = engine.compute_embedding(
Content.ImageFile("photo.jpg"), options=options,
).embedding
cosine_similarity = sum(float(a) * float(b) for a, b in zip(query, image))
print(len(query), cosine_similarity)
GPU support depends on the platform and driver. CPU loading and embedding parity were also tested; use Backend.CPU(thread_count=4) for both backends if needed. The file is for the LiteRT-LM embedding API, rather than AutoModel, SentenceTransformers, or a text-generation endpoint. Gemma Gallery provides Android/iOS integration code; this compact file has not yet completed iOS runtime validation or full app integration testing.
For text retrieval, the tested query format is task: search result | query: {query}. Keep text within the 256-token runtime budget, including prefixes and special tokens. For documents, follow the task-specific guidance in the original model card. Images are passed without a text prefix. Similarity scores are not calibrated probabilities.
What changed
- Input-size graphs: keep the 128/256-token text signatures and 70-token vision/adapter signatures, including their referenced decomposition graphs. Remove the unused 512/1024/2048/8192-token text signatures and 140-token vision paths.
- Vision position tables: crop two FP32 tables from
[768, 10240]to[768, 210], keeping coordinates 0 through 209 bit for bit. Under LiteRT-LM 0.18.0 native preprocessing at 70 vision tokens, the patch grid has at most 630 patches, a minimum side of 3, and therefore a maximum side of 210. The retained values cover that configuration. The preprocessor implementation defines the boundary. - Serialization: remove unreferenced buffer records and share identical inline constants and strings.
No transformer layers, attention heads, vocabulary entries, or embedding dimensions were removed. There is no additional quantization, distillation, or retraining. A build report records the transformations and hashes.
Validation and limitations
- Regression inputs: 73 English/Chinese queries, 14 hash-verified public Lab photos, and 6 deterministic synthetic images covering extreme sizes and aspect ratios. The photos are not redistributed in this repository.
- Windows: two CPU runs per model and one GPU run per model. All tested vectors, text-image/image-image rankings, and threshold decisions matched on the same backend. See validation results.
- Samsung Galaxy S25: original and compact model loading plus text/image embedding succeeded on CPU and GPU. Comparisons are original versus compact on the same backend; this does not assert bitwise equality between CPU and GPU outputs.
- No MTEB or broad independent accuracy evaluation was run for this derivative. No new training data was used. Original training-data, language-coverage, and bias information is in Google's model card.
- The published contract is 256 input tokens, 70 vision tokens per image, and 768 output dimensions. Longer contexts, 140-token images, custom patch coordinates/preprocessors, multiple-image/interleaved inputs, other output sizes, audio, video, NPU-specific delegates, and iOS execution are outside this release's validation.
- The source bundle supports input sizes that were intentionally removed here. Use the upstream bundle when you need those configurations. Do not describe this artifact as a replacement for every upstream use case.
- This model produces retrieval embeddings. It does not generate captions or answers, return OCR text, or detect object bounding boxes. Retrieval quality and any downstream classification or grouping need evaluation in the target application.
- Native model loading and embedding were tested in an isolated Android package. Full photo-library indexing and the app's Search, Tags, Similar, and Groups flows were not exercised with this compact bundle.
Rebuild and verify
The build scripts reproduce the transformations from the exact generic upstream file. Use Python 3.12 and the pinned build dependencies. The output directory must be new; intermediate unpacked models require additional disk space.
pip install -r requirements-build.txt
hf download litert-community/embeddinggemma-2-text-vision-440m-litert-lm embeddinggemma-2-text-vision-440m.litertlm --revision e301f74d5551b0c2641bd5cb4652a76239d5c5f8 --local-dir upstream
python scripts/rebuild.py --model upstream/embeddinggemma-2-text-vision-440m.litertlm --work-dir build/reproduce
The wrapper checks the upstream input SHA-256 and verifies the rebuilt bundle against the published size and SHA-256. It fixes the container UUID and creation timestamp to the tested release because LiteRT-LM builder otherwise regenerates those fields on each pack. Build details are in build-report.json. model-manifest.json records the source, runtime contract, size, and checksum.
Upstream SHA-256:
92dcbea108899e5d6e30d919b0744f90d9967e80c67a4ab5503ac16d54f62eb0
Compact SHA-256:
a08a6bcbcba893d8e52dcf2ae05ce06847f942e3b0e5ea8b8df93f32aa23b027
License and attribution
Apache-2.0. See LICENSE and NOTICE. The original model is by Google DeepMind, and the source LiteRT-LM conversion is from LiteRT Community / Google AI Edge. This compact derivative and its release documentation are maintained by Spawn Lau. It is a community modification, with no claim of Google endorsement.
- Downloads last month
- 7
Model tree for spawnlau/embeddinggemma-2-text-vision-440m-compact
Base model
google/embeddinggemma-2