# GLiClass Edge — Android zero-shot text classification Type English text and the labels to choose from, one per line. Pick **Single label** (softmax, the top label) or **Multi-label** (sigmoid, every label at or above a threshold), GPU or CPU, and tap **Classify** for every label's score with the chosen labels highlighted, the graph window and timings. An optional prompt (a task description) goes right before the text. For the prefilled request (an invented support message with five labels) the app answers `connectivity problem` (0.856), the same decision as the official gliclass pipeline. ## Model and requirements - Model: [litert-community/GLiClass-Edge-v3.0-LiteRT](https://huggingface.co/litert-community/GLiClass-Edge-v3.0-LiteRT). - Upstream: [knowledgator/gliclass-edge-v3.0](https://huggingface.co/knowledgator/gliclass-edge-v3.0) revision `df03993a2ed98e5e4a0d2dd7efbbd105abe874cf`, Apache-2.0; encoder [jhu-clsp/ettin-encoder-32m](https://huggingface.co/jhu-clsp/ettin-encoder-32m) (ModernBERT, MIT). - Semantics: `gliclass` 0.1.20 `ZeroShotClassificationPipeline` (uni-encoder): single-label and multi-label classification with an optional prompt. - Android: arm64-v8a, Android 8.0 / API 26 or newer; compile/target SDK 35. - Runtime: LiteRT **2.2.0** `CompiledModel`; Material 1 Compose with MVVM. **Explicit GPU FP32 precision is mandatory.** On a Galaxy S26 the default GPU precision ran the 128-token graph but changed decisions near the decision boundary: 475 of 482 single-label and 455 of 482 multi-label decisions matched the official pipeline. The app requests `CompiledModel.GpuOptions(precision = CompiledModel.GpuOptions.Precision.FP32)`. CPU (four threads) is a second backend you choose in the app; the app never switches to it on its own. ## Download, build and install Use JDK 17, Android SDK platform 35 / build-tools 35.0.0, Android platform-tools (`adb`) and the Hugging Face CLI (`hf`). The app needs four files of the model repository: ```bash hf download litert-community/GLiClass-Edge-v3.0-LiteRT \ gliclass_edge_v3_s128_fp32.tflite gliclass_edge_v3_s256_fp32.tflite \ host_assets/tok_embeddings_fp16.bin host_assets/tokenizer.json \ --local-dir "$HOME/Downloads/GLiClass-Edge-v3.0-LiteRT" ./gradlew :app:assembleDebug # Optional when multiple devices are connected: # export ANDROID_SERIAL=your-device-serial adb install app/build/outputs/apk/debug/app-debug.apk ./scripts/install_to_device.sh "$HOME/Downloads/GLiClass-Edge-v3.0-LiteRT" adb shell am start -n com.gliclass/.MainActivity ``` The install script's argument defaults to the download directory above. It validates all four files before contacting the device, pushes through `/data/local/tmp/gliclass/`, copies with `run-as com.gliclass` into private `files/` and removes the temporary files. Install the debug APK first; `run-as` requires a debuggable package. Model files are external and are not needed to build the APK. A launch before the install script ran shows "Model unavailable" with "Missing . Run scripts/install_to_device.sh, then retry." ## External files The app loads the graphs by path and memory-maps the embedding table. Four files, 149,936,711 bytes. | File | Bytes | Purpose | |---|---:|---| | `gliclass_edge_v3_s128_fp32.tflite` | 53,703,480 | Up to 128 tokens (labels + prompt + text) | | `gliclass_edge_v3_s256_fp32.tflite` | 53,965,476 | Up to 256 tokens | | `host_assets/tok_embeddings_fp16.bin` | 38,684,160 | Float16 `[50370,384]` token-embedding table, upcast to float32 on lookup | | `host_assets/tokenizer.json` | 3,583,595 | Byte-level BPE vocabulary, merges and added tokens (the upstream file, unchanged) | Each graph takes `inputs_embeds [1,N,384]`, `attention_mask [1,N]` and `label_routing [1,25,N]` (float32) and returns `logits [1,1,1,25]`; the first n logits belong to the n labels. The model repository also holds float16-weight graphs (`*_wfp16.tflite`, half the size); this app uses the float32 graphs. ## App architecture ```text Text + labels (+ prompt) → linearized string → Kotlin byte-level BPE tokenizer ([CLS] … [SEP]) → IDs, attention, one-hot <