Instructions to use litert-community/MediaPipe-TextEmbedder-EmbeddingGemma-300M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- LiteRT
How to use litert-community/MediaPipe-TextEmbedder-EmbeddingGemma-300M with LiteRT:
# No code snippets available yet for this library. # To use this model, check the repository files and the library's documentation. # Want to help? PRs adding snippets are welcome at: # https://github.com/huggingface/huggingface.js
- Notebooks
- Google Colab
- Kaggle
MediaPipe EmbeddingGemma 300M (Text Embedder & Decision Maker)
MediaPipe .task bundle of google/embeddinggemma-300m (embedding_gemma.task, 183.8 MB, mixed precision int4+int8, 512-token sequence length, 768D embeddings), shared by both the MediaPipe Text Embedder (TextEmbedder) task and the MediaPipe Decision Maker (DecisionMaker) task.
Documentation: MediaPipe Text Embedder Docs · Decision Maker Docs
Samples: Android · iOS · Python Colab · Web · Flutter
Try live: Text Embedder Web Demo · Decision Maker Web Demo
embedding_gemma.task packages the 512-token mixed-precision gemma.tflite graph (byte-identical to embeddinggemma-300M_seq512_mixed-precision.tflite in litert-community/embeddinggemma-300m), sentencepiece.model, and manifest.pb.
Prompt Formatting with TextEmbedder
Using TextEmbeddingFormatContext, MediaPipe formats inputs according to the official EmbeddingGemma prompt instructions:
- Queries (
task: <task> | query: <text>):RETRIEVAL_QUERY("search result"),SEMANTIC_SIMILARITY("sentence similarity"),CLASSIFICATION("classification"),CLUSTERING("clustering"),QUESTION_ANSWERING,FACT_CHECKING,CODE_RETRIEVAL. - Documents (
title: <title> | text: <text>):RETRIEVAL_DOCUMENT(orTextEmbeddingTextRole.DOCUMENT).
Zero-Decoding Classification with DecisionMaker
In DecisionMaker, embedding_gemma.task acts as a symmetric 768D bi-encoder supporting ChoiceQuestion, BooleanQuestion, ScoreQuestion, automatic LogSumExp long-context chunking (up to 2,048 tokens), and prewarm_choice() option caching. Leave temperature=0.0 (auto-calibrated ≈0.045) and phrase boolean conditions affirmatively without compound unless exceptions.
Files
| File | Precision | Size | SHA-256 |
|---|---|---|---|
embedding_gemma.task |
— |
183.82 MB (183,816,181 B) | 913b7a1edc7c7c3d1da3979ec1d0648ed9e0a370f181bb59ab177ca4b97707ad |
Download
pip install -U huggingface_hub
hf download litert-community/MediaPipe-TextEmbedder-EmbeddingGemma-300M embedding_gemma.task --local-dir .
Inputs, Outputs, and Model Specifications
Bundle Contents (embedding_gemma.task)
| Bundled Member | Uncompressed Size | SHA-256 (prefix) |
|---|---|---|
gemma.tflite |
179.13 MB (179,132,472 B) | ad09e81557203cb0… |
manifest.pb |
0.1 KB (50 B) | c476161445720a7e… |
sentencepiece.model |
4.68 MB (4,683,319 B) | d6daa52d93d7aad1… |
Sub-model gemma.tflite
| Direction | Tensor | Shape | Type | Notes |
|---|---|---|---|---|
| Input | embed_512_text_batch:0 |
[1, 512] |
int32 |
— |
| Output | StatefulPartitionedCall:0 |
[1, 768] |
float32 |
— |
Use with MediaPipe Tasks
Python Quickstart
pip install -U mediapipe huggingface_hub
import mediapipe as mp
from huggingface_hub import hf_hub_download
model_path = hf_hub_download(repo_id="litert-community/MediaPipe-TextEmbedder-EmbeddingGemma-300M", filename="embedding_gemma.task")
# 1) Use as a 768D TextEmbedder with task-specific formatting
BaseOptions = mp.tasks.BaseOptions
text = mp.tasks.text
with text.TextEmbedder.create_from_options(
text.TextEmbedderOptions(base_options=BaseOptions(model_asset_path=model_path), l2_normalize=True)
) as embedder:
q = embedder.embed(
"Which model handles on-device embeddings?",
format_context=text.TextEmbeddingFormatContext(task_type=text.TextEmbeddingType.RETRIEVAL_QUERY),
).embeddings[0]
d = embedder.embed(
"EmbeddingGemma 300M generates 768D embeddings locally on edge devices.",
format_context=text.TextEmbeddingFormatContext(
task_type=text.TextEmbeddingType.RETRIEVAL_DOCUMENT, title="MediaPipe Docs", role=text.TextEmbeddingTextRole.DOCUMENT
),
).embeddings[0]
print("Cosine similarity:", text.TextEmbedder.cosine_similarity(q, d))
# 2) Or use the same bundle in MediaPipe DecisionMaker
decision = mp.tasks.decision
with decision.DecisionMaker.create_from_options(
decision.DecisionMakerOptions(base_options=BaseOptions(model_asset_path=model_path), max_num_tokens=512)
) as maker:
q = decision.ChoiceQuestion(
criteria={
"billing": "Refunds, invoices, or subscription charges.",
"technical": "App crashes, login errors, or broken features.",
},
normalize_prior=True,
)
maker.prewarm_choice(q)
res = maker.evaluate_choice("Double charged on my card.", q)
print("Decision:", res.selected_key, res.probabilities)
Cross-Platform Guides & Samples
- Task overview & options: Text Embedder / Decision Maker documentation
- Platform setup guides: Python · Web / JavaScript · Android (Kotlin / Java) · iOS (Swift) · Flutter (Dart)
- Runnable sample apps: Web Demo · Decision Maker Web Demo · Web Source · Android · iOS · Python Notebook · Flutter
Latency Benchmarks
Average CPU pipeline latency reported by the Text Embedder documentation (see also litert-community/embeddinggemma-300m#performance):
| Model Variant | Device | CPU Latency |
|---|---|---|
| EmbeddingGemma 300M | Galaxy S26 Ultra (4 threads) | 200 ms |
Intended Use, Limitations, and Fairness
- Intended applications: On-device semantic search/retrieval embeddings (
TextEmbedder) and fast zero-decoding intent routing, boolean verification, or ordinal scoring (DecisionMaker). - Terms & conditions: Subject to the Gemma Terms of Use. Refer to
google/embeddinggemma-300mfor full upstream model card details, supported languages, and evaluation benchmarks. - DecisionMaker bi-encoder tip: Decompose counterfactual
"A unless B"policy rules into separate atomicBooleanQuestions (evaluated together at near-zero marginal cost from a single context embedding).
Provenance
Every model binary in this repository is byte-identical (unmodified weights, metadata, and .task bundle archive bytes) to the official artifact served by Google from storage.googleapis.com/mediapipe-models.
| Repo File | Upstream URL | GCS Generation | Upstream Last-Modified |
Pinned Bucket Version |
|---|---|---|---|---|
embedding_gemma.task |
embedding_gemma.task |
1782238479465541 |
Tue, 23 Jun 2026 18:14:39 GMT | /1/ |
License and Citation
- License:
gemma— Subject to the Gemma Terms of Use, as specified in the embedded bundlemanifest.pband upstreamembeddinggemma-300mrepository.
Citation
Upstream base model: google/embeddinggemma-300m and litert-community/embeddinggemma-300m.
Model tree for litert-community/MediaPipe-TextEmbedder-EmbeddingGemma-300M
Base model
google/embeddinggemma-300m