---
library_name: onnx
language: en
tags:
- autocorrect
- spelling-correction
- browser
- onnx
- offline-page
datasets:
- HuggingFaceFW/fineweb-edu
- HuggingFaceTB/smoltalk
- OpenAssistant/oasst1
---
Spell check can't tell that “form” was meant to be “from”,
since both are real words. This 2.1 MB model can.
Try the demo →
·
Write with it in offline.page →
tinyfix reads the words on both sides of a correctly spelled word and picks the best fit from nearby real words. It runs on the page with [ONNX Runtime Web](https://onnxruntime.ai/docs/tutorials/web/), so nothing you type is sent anywhere.
## What it does
| You type | It becomes |
|---|---|
| I will send it form home tomorrow. | I will send it **from** home tomorrow. |
| Let me now if that works. | Let me **know** if that works. |
| We saw there new house. | We saw **their** new house. |
| Please fill out the **form** and return it. | *No change. “form” is right here.* |
## How well it works
94%of its fixes are right |
31%of real-word typos fixed in Eager mode |
~3 msper check in Chrome |
Measured on 2,460 real-word typos from GitHub commits and 45,000 correct words of email and documentation that it never trained on.
| Setting | Real-word typos fixed | Fixes that were right | Correct email words changed | Correct GitHub words changed |
|---|---|---|---|---|
| Careful *(default)* | **19%** | **94%** | about 1 in 2,500 | about 1 in 1,700 |
| Eager *(demo and offline.page)* | **31%** | **94%** | about 1 in 910 | about 1 in 430 |
It also helps choose the right fix for misspelled words, raising that fix rate from 56% to 61.5% while 96.6% of fixes stay right.
### What it misses
- It misses more real-word typos than it catches, including “don” typed for “do”.
- It can only judge the 20,000 words it knows, so a rarer word like “ware” typed for “were” is left alone.
- It needs the words that come after, so these fixes land a couple of words later.
- English only.
## Using the model
The model scores candidate words for one position in a sentence. Higher scores fit better, and comparing each candidate to the typed word tells you whether a swap is worth making.
Inputs and outputs
| Name | Shape | What it holds |
|---|---|---|
| `left` (input) | `[batch, 16]` int64 | The words before, left-padded with 0, starting with `` when there are fewer than 16 |
| `right` (input) | `[batch, 4]` int64 | The words after, nearest word last, left-padded with 0 |
| `candidates` (input) | `[batch, 9]` int64 | The typed word first, then up to 8 nearby words, padded with 0 at the end |
| `scores` (output) | `[batch, 9]` float | One score per candidate |
IDs are line numbers in `wrong-word-vocab.txt`, starting from 0. Words are lowercased, and capitalized words in the middle of a sentence become ``.
Files
| File | What it is |
|---|---|
| `wrong-word.onnx` | The quantized model |
| `wrong-word-vocab.txt` | The 20,000 words it knows, one per line |
| `wrong-word-confusions.txt` | Mix-ups like “their” and “there” that are far apart on the keyboard |
| `train_realword.py` | The training script |
## Training
A word-level GRU that reads 16 words before and up to 4 words after, trained for 25 minutes on an A10G. It learned from 118M tokens of [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu), [SmolTalk](https://huggingface.co/datasets/HuggingFaceTB/smoltalk) and [OpenAssistant](https://huggingface.co/datasets/OpenAssistant/oasst1), by swapping real words for nearby real words and learning to swap them back.
tinyfix is one of two tiny models behind offline.page, a writing app that works in airplane mode.
Its partner, tinynext, suggests the next few words.