AI-Powered Keyboard Correction
On-device AI models from Hugging Face for real-time spell checking and next-word prediction — fully offline, fully private.
1 Overview
Kwiq integrates on-device AI models via ONNX Runtime to enhance the keyboard with real-time spell checking and next-word prediction. All inference runs locally — no internet connection needed after downloading the model.
Architecture
The AI engine supports three model architectures:
- ONNX Runtime — Inference runtime. Runs on CPU with XNNPACK acceleration. Supports INT8 and FP16 quantization for smaller, faster models.
- T5-SEQ2SEQ — Encoder-decoder models fine-tuned for Grammar Error Correction (GEC). Already converted to ONNX with INT8 quantization. Fast and lightweight (30-40 MB).
- DECODER-SLM — Decoder-only Small Language Models. Use prompt engineering for contextual next-word prediction. Need ONNX export via optimum-cli.
- BYTE-LEVEL — Byte-level models that operate on raw UTF-8 bytes without a tokenizer. Extremely robust to typos and encoding errors.
2 Available Models
Models are sourced from the Hugging Face Hub. The catalog includes several categories:
Spell Correction (T5-based)
Ultra-lightweight T5 models fine-tuned for grammar and spelling correction. Already in ONNX INT8 format, ready to use. 30-40 MB. Ideal for real-time typo correction.
Next-Word Prediction (SmolLM2)
State-of-the-art compact language models from Hugging Face. 135M-360M parameters. Better contextual understanding. Requires ONNX export.
Byte-Level (ByT5)
Google ByT5 models that work directly with UTF-8 bytes. No tokenizer needed. Robust to noise and encoding errors. Multilingual.
Browse and download models directly from the Kwiq Settings → Keyboard → AI Correction. Each model shows its size, supported language, and whether it is ready to use.
3 Downloading Models
Models are downloaded on-the-fly from Hugging Face Hub and cached in internal storage:
- Open Kwiq Settings → Keyboard → AI Correction.
- Choose a model from the catalog.
- Tap Download. You will see a progress bar while the model is being fetched.
- Once downloaded, enable AI Spell Correction and/or AI Prediction.
4 How It Works
The keyboard suggestion pipeline combines multiple data sources in a progressive order:
When you type, suggestions are generated in this order:
- Bigramas — Learned word pairs from your typing history (Room database). Fastest, always on.
- Prefixo — Dictionary prefix matching (Trie + Hunspell). Finds words starting with what you typed.
- IA — AI model inference via ONNX Runtime. Provides intelligent spelling corrections and contextual predictions. Highest score, so AI suggestions appear first when enabled.
- Levenshtein — Classic Levenshtein distance corrections. Always available as fallback for when AI is disabled or fails.
5 MCP Control
AI models can also be managed remotely through the MCP (Model Context Protocol) interface. This allows AI assistants to browse, download, select, and delete models on your device via MCP clients.
Available MCP tools: ai_model_list, ai_model_download, ai_model_status, ai_model_select, ai_model_delete. Access them through the Self-Hosted Dashboard at /mcp.