Feature Extraction
LiteRT-LM
multilingual
embedding
multimodal
text-image-retrieval
image-feature-extraction
on-device
android
gemma-gallery
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
Download scripts/rebuild.py from spawnlau/embeddinggemma-2-text-vision-440m-compact: direct link, hf CLI and curl.
- Browser
- Download file 2.11 kB
-
https://huggingface.co/spawnlau/embeddinggemma-2-text-vision-440m-compact/resolve/main/scripts/rebuild.py
- Command line
-
hf download hf://spawnlau/embeddinggemma-2-text-vision-440m-compact/scripts/rebuild.py
-
curl -L -o rebuild.py https://huggingface.co/spawnlau/embeddinggemma-2-text-vision-440m-compact/resolve/main/scripts/rebuild.py
2.11 kB
| # Copyright 2026 Spawn Lau | |
| # SPDX-License-Identifier: Apache-2.0 | |
| """Rebuild the published compact bundle from the pinned upstream file.""" | |
| import argparse | |
| import hashlib | |
| import json | |
| from pathlib import Path | |
| import subprocess | |
| import sys | |
| SOURCE_BYTES = 387710976 | |
| SOURCE_SHA256 = "92dcbea108899e5d6e30d919b0744f90d9967e80c67a4ab5503ac16d54f62eb0" | |
| OUTPUT_BYTES = 309559296 | |
| OUTPUT_SHA256 = "a08a6bcbcba893d8e52dcf2ae05ce06847f942e3b0e5ea8b8df93f32aa23b027" | |
| def sha256(path): | |
| with path.open("rb") as stream: | |
| return hashlib.file_digest(stream, "sha256").hexdigest() | |
| def main(): | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("--model", type=Path, required=True) | |
| parser.add_argument("--work-dir", type=Path, required=True, | |
| help="A new directory; existing directories are never overwritten.") | |
| args = parser.parse_args() | |
| model = args.model.resolve(strict=True) | |
| if model.stat().st_size != SOURCE_BYTES or sha256(model) != SOURCE_SHA256: | |
| raise ValueError("Input is not the pinned generic CPU/GPU upstream bundle.") | |
| args.work_dir.mkdir(parents=True, exist_ok=False) | |
| scripts = Path(__file__).resolve().parent | |
| candidate_dir = args.work_dir.resolve() / "candidates" | |
| commands = [ | |
| ["build_size_candidates.py", "--model", str(model), "--output-dir", str(candidate_dir)], | |
| ["refine_position_candidate.py", "--candidate-dir", str(candidate_dir)], | |
| ["compact_candidate_metadata.py", "--candidate-dir", str(candidate_dir), "--reproducible"], | |
| ] | |
| for script, *arguments in commands: | |
| subprocess.run([sys.executable, str(scripts / script), *arguments], check=True) | |
| output = candidate_dir / "eg2-gallery-compact.litertlm" | |
| result = {"path": str(output), "bytes": output.stat().st_size, "sha256": sha256(output)} | |
| if result["bytes"] != OUTPUT_BYTES or result["sha256"] != OUTPUT_SHA256: | |
| raise RuntimeError(f"Rebuild differs from the published bundle: {result}") | |
| print(json.dumps({"status": "verified", **result}, indent=2)) | |
| if __name__ == "__main__": | |
| main() | |