androidfolate / README.md
asermnasr's picture
Add first-class emulated Android desktop host-offloaded inference support to README
ccc9e79 verified
|
Raw History Blame Contribute Delete
10.5 kB
---
license: apache-2.0
language:
- en
base_model:
- google/electra-large-discriminator
pipeline_tag: zero-shot-classification
library_name: litert
tags:
- tflite
- int8
- npu
- android
- accessibility
- mobile-agent
- ui-grounding
- cross-encoder
- computer-use
---
<p align="center">
<img src="./banner.png" alt="AndroidFolate" style="max-height: 220px; object-fit: cover;">
</p>
<p align="center">
<a href="https://huggingface.co/figranium/folate"><strong>Folate (Web)</strong></a>
&nbsp;&bull;&nbsp;
<a href="https://www.apache.org/licenses/LICENSE-2.0"><strong>Apache 2.0 License</strong></a>
</p>
**AndroidFolate** *(Upcoming — January 2027)* is a dedicated, on-device neural UI element ranker built for autonomous Android automation within tight mobile memory constraints (**6 GB physical RAM minimum / 8 GB+ recommended** on physical devices, plus **first-class emulated Android support on desktop** via host-side inference). Fine-tuned from [`google/electra-large-discriminator`](https://huggingface.co/google/electra-large-discriminator) (`335M` parameters) as a discriminative cross-encoder on multi-framework Android accessibility trees and quantized to **INT8 (~335 MB)**, AndroidFolate targets hardware-accelerated mobile NPU inference via **LiteRT** across **Google Tensor**, **Qualcomm Hexagon**, **Samsung Exynos**, and **MediaTek APU**—and routes emulated Android sessions directly to the desktop host's native accelerators without requiring PyTorch or `transformers` at inference time.
AndroidFolate is designed to act as a fast, zero-hallucination UI grounding engine for single-step Android actions (`click`, `type`, `scroll`, `long_click`) across **Native Android Views / Jetpack Compose**, **React Native**, **Flutter**, and embedded **WebViews**.
| Artifact | Backbone | Precision / Format | Disk Size | Target Runtime |
| :--- | :--- | :--- | :--- | :--- |
| **`model_quantized.tflite` (Planned)** | `google/electra-large-discriminator` | Static `INT8` LiteRT | ~335 MB | LiteRT NPU Delegates (Tensor / Hexagon / Exynos / APU) & Desktop Host (ANE / GPU / XNNPACK) |
| **`androidfolate-large` (Checkpoint)** | `google/electra-large-discriminator` | `float32` Safetensors | ~1.34 GB | PyTorch / Training |
### Inputs and outputs
* **Input:**
* A natural-language action query (e.g., `"tap Search flights button"` or `"enter destination city in search field"`).
* Candidate interactive UI nodes extracted from Android `AccessibilityNodeInfo` trees across Native/Compose, React Native, Flutter Semantics, and bridged WebViews, normalized into a unified structured token schema:
```text
[FRAMEWORK] compose [CLASS] Button [ID] search_flights [DESC] Search flights [TEXT] Search [STATE] clickable
```
* **Output:**
* A calibrated relevance probability (`0.0` to `1.0`, derived via sigmoid over a single sequence-classification logit) and a resolved node reference guaranteed to exist in the source accessibility hierarchy, ranked in descending order of relevance.
### Citation
```bibtex
@misc{androidfolate_2027,
title = {AndroidFolate: On-Device Multi-Framework Android UI Element Ranker},
author = {Figranium},
year = {2027}
}
```
---
## Model Data
Data used for model training and how the data was processed.
### Training Dataset
AndroidFolate is trained on multi-framework Android accessibility tree grounding corpora spanning **Native Android Views / Jetpack Compose**, **React Native**, **Flutter**, and embedded **WebView** screens across real-world mobile applications.
### Data Preprocessing
Each Android interaction step is converted into binary `(query, serialized_node)` classification pairs:
* **Query Normalization:** Action instructions are normalized to concise natural-language step descriptions.
* **Unified Multi-Framework Serialization:** Accessibility nodes are normalized across toolkits into a single schema mapping framework origin, shortened widget class/role, resource or test identifier (`resource-id`, `testID`), accessibility label (`contentDescription`, `accessibilityLabel`, Flutter Semantics `label`/`hint`, ARIA label), visible text, and interactive state flags (`clickable`, `focusable`, `scrollable`, `checked`, `selected`), while pruning unlabeled non-interactive layout containers (`ViewGroup` / `FrameLayout`).
* **Negative Sampling & Splitting:** Each ground-truth positive node is paired with sampled hard-negative candidates from the same screen state (including sibling items in `RecyclerView` / `LazyColumn` lists) and evaluated on framework-stratified validation splits.
---
## Implementation Information
Details about the model internals and runtime optimization.
* **Architecture:** `ElectraForSequenceClassification` (`24` transformer layers, `1024` hidden size, `16` attention heads, `num_labels=1`) initialized from `google/electra-large-discriminator`.
* **Sequence Length:** Static bucketed WordPiece token lengths (`vocab_size = 30,522`) for deterministic NPU graph compilation.
* **Quantization & Export:** Converted from PyTorch via `litert-torch` and quantized to **INT8** with `ai-edge-quantizer` (keeping the final classification head in higher precision for calibrated ranking logits), compiled for **Google Tensor**, **Qualcomm Hexagon**, **Samsung Exynos**, and **MediaTek APU** delegates on physical devices, and executed natively via **Apple Neural Engine (ANE)**, **GPU**, or **CPU XNNPACK** when bridged from a desktop emulator.
---
## Evaluation & Benchmarks
*Weights and benchmark results will be published upon the January 2027 release.*
### Framework-Stratified Evaluation Plan
AndroidFolate will report per-framework **Top-1**, **Top-3**, **Top-5**, **MRR**, and on-device **p50/p95 NPU latency** across all four supported UI stacks:
| Split | UI Framework | Steps | Avg Candidates | Top-1 | Top-3 | Top-5 | MRR | NPU Latency |
| :--- | :--- | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| **`eval_native_compose`** | Native Android Views & Jetpack Compose | — | — | *Pending* | *Pending* | *Pending* | *Pending* | *Pending* |
| **`eval_react_native`** | React Native | — | — | *Pending* | *Pending* | *Pending* | *Pending* | *Pending* |
| **`eval_flutter`** | Flutter Semantics | — | — | *Pending* | *Pending* | *Pending* | *Pending* | *Pending* |
| **`eval_webview`** | Android WebView | — | — | *Pending* | *Pending* | *Pending* | *Pending* | *Pending* |
---
## Ethics and Safety
Evaluation approach and results.
### Evaluation Approach
AndroidFolate is a discriminative element ranker rather than a generative text or code model; it does not generate free-form text, execute arbitrary code, or store user credentials. Evaluations focus on node grounding fidelity (verifying that returned references resolve strictly to existing interactive nodes in the provided accessibility tree) and failure-mode analysis on repeated list items.
---
## Usage and Limitations
Instructions on how to use the model as well as its limitations.
### Usage
Model weights and LiteRT NPU inference bindings (`figranium/androidfolate` on GitHub and Hugging Face) will be published upon release in January 2027:
```bash
hf download figranium/androidfolate --local-dir ./androidfolate-int8
```
### System Requirements & Supported Hardware
* **Disk Space:** ~335 MB (`model_quantized.tflite` + `tokenizer.json`)
* **Physical Android Devices — Tiered Memory & NPU Policy:**
* **6 GB Physical RAM (Minimum / ~5.2 GB Usable Floor):** Supported via on-demand NPU session unloading after inference to avoid memory pressure alongside foreground apps.
* **8 GB+ Physical RAM (Recommended / Optimal Tier):** Keeps the ~335 MB INT8 NPU session warm in memory for zero cold-start latency.
* **NPU Acceleration:** Flagship and upper-midrange Android devices (generally 2022 onwards) with **6 GB+ RAM** and dedicated transformer-capable NPUs across all four vendors:
| NPU Vendor | Supported SoCs | Example Supported Devices (6 GB+ RAM) |
| :--- | :--- | :--- |
| **Google Tensor** | Tensor G2 and newer (all Pixel 7 series onwards) | Pixel 7a / 7 / 7 Pro, Pixel 8a / 8 / 8 Pro, Pixel 9 / 9 Pro / 9 Pro Fold, Pixel 10 / 11 series |
| **Qualcomm Hexagon** | Snapdragon 8-series and upper 7-series | Galaxy S22–S26 (Snapdragon), OnePlus 10–15, Nothing Phone (2) / (3) / (4a), Poco F5 / F6 |
| **Samsung Exynos** | Exynos 1380, 1480, 1580, and 2400+ series | Galaxy A54 / A55 / A56 (6 GB / 8 GB+), Galaxy S24 / S24+ (Exynos), Galaxy Z Flip 7, Galaxy S26 |
| **MediaTek APU** | Dimensity 7200, 8000-series, and 9000-series | Redmi Note 13 Pro+, Nothing Phone (2a), Xiaomi 13T / 14T Pro, Vivo X100 / X200 |
* **Emulated Android on Desktop (First-Class Host Offloading):**
* **Supported Environments:** Android Studio AVD, Cuttlefish, Waydroid, Genymotion, and desktop Android VMs on macOS, Linux, and Windows.
* **Architecture:** Rather than emulating a mobile NPU or consuming guest VM RAM inside the emulator, AndroidFolate detects the emulated environment, bypasses physical SoC allowlists, and streams serialized accessibility trees over a local **ADB / gRPC bridge** directly to the desktop host—executing the INT8 model outside the emulator on **Apple Silicon Neural Engine (ANE)**, **desktop GPU**, or **CPU XNNPACK**.
* **Unsupported Hardware Examples:**
* **Physical Devices with <= 4 GB RAM:** Entry-level 4 GB devices fall below the ~5.2 GB usable RAM floor and cannot safely host the runtime alongside foreground apps.
* **Physical Budget / Older SoCs lacking transformer-capable NPUs:** e.g., Galaxy A1x series, 6-series Snapdragon chips (including Nothing Phone (4b) on Snapdragon 6 Gen 4), and non-Android mobile devices (iOS/iPadOS).
### Limitations
* **Single-Step Grounding Only:** AndroidFolate ranks candidate UI nodes for a single action query (`click`, `type`, `scroll`, `long_click`); it does not perform multi-step task planning or screen state tracking.
* **Accessibility Tree Dependency:** Grounding relies on semantic properties exposed via Android's `AccessibilityNodeInfo` API; custom canvas views without accessibility semantics cannot be ranked without a vision fallback.
* **Confidence Calibration:** Because training uses hard-negative sampling (`1:7` positive-to-negative ratio), well-calibrated top-1 positive scores typically fall below `0.90`.
---
*Android is a trademark of Google LLC. AndroidFolate is an independent open-source project by Figranium and is not affiliated with or endorsed by Google.*