--- license: gemma base_model: google/embeddinggemma-300m library_name: onnx pipeline_tag: sentence-similarity language: - en tags: - embeddinggemma - onnx - on-device - android - voice-assistant - intent-classification - tool-routing --- # EmbeddingGemma-300M Phone Command Router (ONNX, 4-bit) **What it does:** turns something a person says to their phone ("wake me at half six", "text mom I'm on my way", "how long is the drive to Boston") into a ranking of **205 phone actions**: set an alarm, send a text, start navigation, add to a list, and so on. It is the first stage of a fully on-device voice assistant for Android: this model picks *which* action, and a small companion model, [LFM2.5-350M Phone Command Extractor](https://huggingface.co/bpmatt/LFM2.5-350M-Phone-Command-Extractor-GGUF), fills in *the details* (times, names, messages). It is `google/embeddinggemma-300m`, fine-tuned for this task and exported to ONNX with 4-bit weights (~195 MB). It runs on a phone CPU in about **30-40 ms** per request. ## How it works ``` "remind me in 20 minutes to check the oven" │ query text: "task: search result | query: remind me in 20 minutes to check the oven" ▼ EmbeddingGemma (this model) → 768-d vector → cosine vs. 205 tool embeddings (tool_embeddings.f32) ▼ set_timer 0.64 · add_reminder 0.47 · set_screen_timeout 0.43 … ▼ the app's keyword rule ("remind me … to …" is a reminder) moves add_reminder to the top ``` ## Files | File | What it is | |---|---| | `model_q4.onnx` + `model_q4.onnx_data` | the model (inputs `input_ids`, `attention_mask`; output `sentence_embedding` [batch, 768]) | | `tokenizer.json` | the Gemma tokenizer (for Python / Hugging Face `tokenizers`) | | `gemma_tok.bin` | the same tokenizer in a compact format read by the Android app's Java tokenizer | | `tools.json` | the 205 actions (name + description), in the row order of the embeddings | | `tool_embeddings.f32` | 205 × 768 little-endian float32, unit-length tool embeddings | ## Quick start (Python) ```python import json, numpy as np, onnxruntime as ort from huggingface_hub import snapshot_download from tokenizers import Tokenizer d = snapshot_download("bpmatt/EmbeddingGemma-300M-Phone-Command-Router-ONNX") sess = ort.InferenceSession(f"{d}/model_q4.onnx") tok = Tokenizer.from_file(f"{d}/tokenizer.json") tools = json.load(open(f"{d}/tools.json")) emb = np.fromfile(f"{d}/tool_embeddings.f32", dtype="