graphemetech/understanding-v2
an on-device emotion and situation classifier built on EmbeddingGemma
2 min readupdated
This model turns short user notes into numerical vectors (embeddings) and matches them against a predefined set of feelings and life situations. Built by the graphemetech team for the Uns app on top of google/embeddinggemma-300m, it is packaged in the LiteRT format (formerly TensorFlow Lite) to run directly on mobile devices without sending any text to a server. Unlike the base checkpoint, it was fine-tuned on an emotion taxonomy across 8 languages (English, Indonesian, Malay, Turkish, Bengali, Arabic, Urdu, and Persian) and merged 50/50 with the original weights. It's a solid fit for mobile developers who need lightweight, offline sentiment and context analysis.
Key features
- Full pipeline in a single graph: the encoder, mean pooling, dense layers, and L2 normalization are packed into one
model.tflitefile with dynamic int8 quantization. - High conversion fidelity: cosine similarity against the original PyTorch model stays at 0.998 or higher, and the binary tokenizer
tokenizer.binmatches the baseline character-for-character across 36,081 test texts. - Weight averaging (WiSE-FT): blending the fine-tuned and original checkpoints 50/50 preserves the base model's general and religious vocabulary while boosting classification accuracy.
- Ready-to-use centroids: the repo includes
centroids.jsonwith reference vectors for every feeling and situation, along with a rejection threshold.
What you can do
- Embed it in a mobile mood journal or mental health tracker for completely private, on-device entry categorization.
- Power multilingual recommendation engines that match quotes, articles, or advice to a user's current life situation.
- Use it as a working reference for converting
embeddinggemma-300mto LiteRT while bypassing attention-layer translation bugs.
Example
Rather than generating text, the model outputs an L2-normalized vector of shape [1, 768]. Before tokenization, prepend the required prefix task: classification | query: to any input phrase (sequences are then fixed to 128 tokens, and the resulting vector is compared against the centroids in centroids.json).
Read more
DetailsHoldout metrics: feelings top-1 — 79 / 73 / 94 (compared to 71 / 54 / 60 for base
embeddinggemma-300m), situations top-1 — 79 / 81 / 88, relevant topic retrieval (hit@3) — 58.5%.Format and inputs:
model.tflite (int8), taking int32 input_ids and attention_mask of shape [1, 128].Training: 4 epochs, batch semi-hard triplet loss (margin 0.5, lr 2e-5) on ~4,000 labeled phrases across 8 languages.
Limitations: works only with a closed set of categories and is distributed under the Gemma Terms of Use.










Comments