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.

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 (or TextEmbeddingTextRole.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

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-300m for full upstream model card details, supported languages, and evaluation benchmarks.
  • DecisionMaker bi-encoder tip: Decompose counterfactual "A unless B" policy rules into separate atomic BooleanQuestions (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 bundle manifest.pb and upstream embeddinggemma-300m repository.

Citation

Upstream base model: google/embeddinggemma-300m and litert-community/embeddinggemma-300m.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for litert-community/MediaPipe-TextEmbedder-EmbeddingGemma-300M

Quantized
(325)
this model

Collection including litert-community/MediaPipe-TextEmbedder-EmbeddingGemma-300M