new card with the tinyfix banner
Browse files- README.md +55 -20
- banner.png +0 -0
README.md
CHANGED
|
@@ -6,52 +6,73 @@ tags:
|
|
| 6 |
- spelling-correction
|
| 7 |
- browser
|
| 8 |
- onnx
|
|
|
|
| 9 |
datasets:
|
| 10 |
- HuggingFaceFW/fineweb-edu
|
| 11 |
- HuggingFaceTB/smoltalk
|
| 12 |
- OpenAssistant/oasst1
|
| 13 |
---
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|---|---|---|---|
|
| 27 |
-
| **1.9M** | **2.1 MB** | **1.6 MB** | **About 3 ms** in Chrome |
|
| 28 |
|
| 29 |
## What it does
|
| 30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
| You type | It becomes |
|
| 32 |
|---|---|
|
| 33 |
-
| I will send it
|
| 34 |
-
| Let me
|
| 35 |
-
| We saw
|
| 36 |
-
| Please fill out the **form** and return it. | No change |
|
| 37 |
|
| 38 |
## How well it works
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
Measured on 2,460 real-word typos from GitHub commits and 45,000 correct words of email and documentation that it never trained on.
|
| 41 |
|
| 42 |
| Setting | Real-word typos fixed | Fixes that were right | Correct email words changed | Correct GitHub words changed |
|
| 43 |
|---|---|---|---|---|
|
| 44 |
-
| Careful | **19%** | **94%** |
|
| 45 |
-
| Eager | **31%** | **94%** |
|
| 46 |
-
|
| 47 |
-
Careful is the default. The demo runs Eager, so you see more fixes.
|
| 48 |
|
| 49 |
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.
|
| 50 |
|
| 51 |
### What it misses
|
| 52 |
|
| 53 |
-
- It misses more real-word typos than it catches, including
|
| 54 |
-
- It can only judge the 20,000 words it knows, so a rarer word like
|
| 55 |
- It needs the words that come after, so these fixes land a couple of words later.
|
| 56 |
- English only.
|
| 57 |
|
|
@@ -59,6 +80,9 @@ It also helps choose the right fix for misspelled words, raising that fix rate f
|
|
| 59 |
|
| 60 |
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.
|
| 61 |
|
|
|
|
|
|
|
|
|
|
| 62 |
| Name | Shape | What it holds |
|
| 63 |
|---|---|---|
|
| 64 |
| `left` (input) | `[batch, 16]` int64 | The words before, left-padded with 0, starting with `<s>` when there are fewer than 16 |
|
|
@@ -68,15 +92,26 @@ The model scores candidate words for one position in a sentence. Higher scores f
|
|
| 68 |
|
| 69 |
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 `<name>`.
|
| 70 |
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
| File | What it is |
|
| 74 |
|---|---|
|
| 75 |
| `wrong-word.onnx` | The quantized model |
|
| 76 |
| `wrong-word-vocab.txt` | The 20,000 words it knows, one per line |
|
| 77 |
-
| `wrong-word-confusions.txt` | Mix-ups like
|
| 78 |
| `train_realword.py` | The training script |
|
| 79 |
|
|
|
|
|
|
|
| 80 |
## Training
|
| 81 |
|
| 82 |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
- spelling-correction
|
| 7 |
- browser
|
| 8 |
- onnx
|
| 9 |
+
- offline-page
|
| 10 |
datasets:
|
| 11 |
- HuggingFaceFW/fineweb-edu
|
| 12 |
- HuggingFaceTB/smoltalk
|
| 13 |
- OpenAssistant/oasst1
|
| 14 |
---
|
| 15 |
|
| 16 |
+
<p align="center">
|
| 17 |
+
<img src="banner.png" alt="tinyfix: autocorrect that reads both sides of a word" width="880">
|
| 18 |
+
</p>
|
| 19 |
|
| 20 |
+
<p align="center">
|
| 21 |
+
<img alt="params: 1.9M" src="https://img.shields.io/badge/params-1.9M-7b1fe0?style=flat-square&labelColor=1d1d1f">
|
| 22 |
+
<img alt="size: 2.1 MB" src="https://img.shields.io/badge/size-2.1%20MB-7b1fe0?style=flat-square&labelColor=1d1d1f">
|
| 23 |
+
<img alt="speed: ~3 ms / check" src="https://img.shields.io/badge/speed-~3%20ms%20%2F%20check-7b1fe0?style=flat-square&labelColor=1d1d1f">
|
| 24 |
+
<img alt="runs: in your browser" src="https://img.shields.io/badge/runs-in%20your%20browser-7b1fe0?style=flat-square&labelColor=1d1d1f">
|
| 25 |
+
<img alt="data sent: none" src="https://img.shields.io/badge/data%20sent-none-7b1fe0?style=flat-square&labelColor=1d1d1f">
|
| 26 |
+
</p>
|
| 27 |
|
| 28 |
+
<h3 align="center">Spell check can't tell that “form” was meant to be “from”,<br>since both are real words. This 2.1 MB model can.</h3>
|
| 29 |
|
| 30 |
+
<p align="center">
|
| 31 |
+
<a href="https://huggingface.co/spaces/cfahlgren1/tinyfix"><b>Try the demo →</b></a>
|
| 32 |
+
·
|
| 33 |
+
<a href="https://github.com/cfahlgren1/offline-page"><b>Write with it in offline.page →</b></a>
|
| 34 |
+
</p>
|
| 35 |
|
| 36 |
+
<br>
|
| 37 |
|
| 38 |
+
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.
|
|
|
|
|
|
|
| 39 |
|
| 40 |
## What it does
|
| 41 |
|
| 42 |
+
<p align="center">
|
| 43 |
+
<img src="tinyfix.png" alt="The tinyfix demo correcting “I recieve the report tomorow and we saw there new house.” as it is typed" width="760">
|
| 44 |
+
</p>
|
| 45 |
+
|
| 46 |
| You type | It becomes |
|
| 47 |
|---|---|
|
| 48 |
+
| I will send it <del>form</del> home tomorrow. | I will send it **from** home tomorrow. |
|
| 49 |
+
| Let me <del>now</del> if that works. | Let me **know** if that works. |
|
| 50 |
+
| We saw <del>there</del> new house. | We saw **their** new house. |
|
| 51 |
+
| Please fill out the **form** and return it. | *No change. “form” is right here.* |
|
| 52 |
|
| 53 |
## How well it works
|
| 54 |
|
| 55 |
+
<table>
|
| 56 |
+
<tr>
|
| 57 |
+
<td align="center" width="33%"><h2>94%</h2>of its fixes are right</td>
|
| 58 |
+
<td align="center" width="33%"><h2>31%</h2>of real-word typos fixed<br><sub>in Eager mode</sub></td>
|
| 59 |
+
<td align="center" width="33%"><h2>~3 ms</h2>per check in Chrome</td>
|
| 60 |
+
</tr>
|
| 61 |
+
</table>
|
| 62 |
+
|
| 63 |
Measured on 2,460 real-word typos from GitHub commits and 45,000 correct words of email and documentation that it never trained on.
|
| 64 |
|
| 65 |
| Setting | Real-word typos fixed | Fixes that were right | Correct email words changed | Correct GitHub words changed |
|
| 66 |
|---|---|---|---|---|
|
| 67 |
+
| Careful *(default)* | **19%** | **94%** | about 1 in 2,500 | about 1 in 1,700 |
|
| 68 |
+
| Eager *(demo and offline.page)* | **31%** | **94%** | about 1 in 910 | about 1 in 430 |
|
|
|
|
|
|
|
| 69 |
|
| 70 |
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.
|
| 71 |
|
| 72 |
### What it misses
|
| 73 |
|
| 74 |
+
- It misses more real-word typos than it catches, including “don” typed for “do”.
|
| 75 |
+
- It can only judge the 20,000 words it knows, so a rarer word like “ware” typed for “were” is left alone.
|
| 76 |
- It needs the words that come after, so these fixes land a couple of words later.
|
| 77 |
- English only.
|
| 78 |
|
|
|
|
| 80 |
|
| 81 |
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.
|
| 82 |
|
| 83 |
+
<details>
|
| 84 |
+
<summary><b>Inputs and outputs</b></summary>
|
| 85 |
+
|
| 86 |
| Name | Shape | What it holds |
|
| 87 |
|---|---|---|
|
| 88 |
| `left` (input) | `[batch, 16]` int64 | The words before, left-padded with 0, starting with `<s>` when there are fewer than 16 |
|
|
|
|
| 92 |
|
| 93 |
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 `<name>`.
|
| 94 |
|
| 95 |
+
</details>
|
| 96 |
+
|
| 97 |
+
<details>
|
| 98 |
+
<summary><b>Files</b></summary>
|
| 99 |
|
| 100 |
| File | What it is |
|
| 101 |
|---|---|
|
| 102 |
| `wrong-word.onnx` | The quantized model |
|
| 103 |
| `wrong-word-vocab.txt` | The 20,000 words it knows, one per line |
|
| 104 |
+
| `wrong-word-confusions.txt` | Mix-ups like “their” and “there” that are far apart on the keyboard |
|
| 105 |
| `train_realword.py` | The training script |
|
| 106 |
|
| 107 |
+
</details>
|
| 108 |
+
|
| 109 |
## Training
|
| 110 |
|
| 111 |
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.
|
| 112 |
+
|
| 113 |
+
<br>
|
| 114 |
+
|
| 115 |
+
<p align="center">
|
| 116 |
+
<sub>tinyfix is one of two tiny models behind <a href="https://github.com/cfahlgren1/offline-page">offline.page</a>, a writing app that works in airplane mode.<br>Its partner, <a href="https://huggingface.co/cfahlgren1/tinynext">tinynext</a>, suggests the next few words.</sub>
|
| 117 |
+
</p>
|
banner.png
ADDED
|