card: add v2 (word-piece transformer) with eval results, browser numbers and training details
Browse files
README.md
CHANGED
|
@@ -3,14 +3,60 @@ library_name: onnx
|
|
| 3 |
pipeline_tag: text-generation
|
| 4 |
datasets:
|
| 5 |
- corbt/enron-emails
|
|
|
|
|
|
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
tags:
|
| 9 |
- autocomplete
|
| 10 |
- gru
|
|
|
|
|
|
|
| 11 |
- onnxruntime-web
|
| 12 |
- in-browser
|
| 13 |
- offline-page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
<p align="center">
|
|
@@ -33,7 +79,74 @@ tags:
|
|
| 33 |
|
| 34 |
tinynext is the autocomplete in [offline.page](https://github.com/cfahlgren1/offline-page). It's the same model as [`cfahlgren1/enron-autocomplete`](https://huggingface.co/cfahlgren1/enron-autocomplete), copied here under its new name.
|
| 35 |
|
| 36 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
It finishes the word or short phrase you're typing. Press <kbd>Tab</kbd> to take the suggestion.
|
| 39 |
|
|
@@ -44,7 +157,7 @@ It finishes the word or short phrase you're typing. Press <kbd>Tab</kbd> to take
|
|
| 44 |
| The books are fine. Please call me i | **f you have any** |
|
| 45 |
| Enron N | **orth America Corp.** |
|
| 46 |
|
| 47 |
-
## How sure it has to be
|
| 48 |
|
| 49 |
The model knows how sure it is of each guess. You pick a cutoff, and it only suggests when it's at least that sure. A higher cutoff means fewer suggestions, and more of them right.
|
| 50 |
|
|
@@ -67,14 +180,14 @@ The demo uses 40%, and offline.page uses 50%.
|
|
| 67 |
|
| 68 |
These numbers come from 5,000 places in emails from people the model never saw in training. “Right” means the suggestion exactly matched what the person typed next.
|
| 69 |
|
| 70 |
-
### Limits
|
| 71 |
|
| 72 |
- It only knows office email from 2001. Outside that it has little to say.
|
| 73 |
- With no cutoff it rambles. “Dear Santa,” becomes “I am attaching a copy of the agreement to the Enron Corp.”
|
| 74 |
- It learned real names and sign-offs from the emails, so keep suggestions short.
|
| 75 |
- English only.
|
| 76 |
|
| 77 |
-
## Use it
|
| 78 |
|
| 79 |
The model takes one character and its memory of the text so far. It returns its guess for the next character and an updated memory. So each key press is one small step.
|
| 80 |
|
|
@@ -122,7 +235,7 @@ I also tried a bigger version with 3.46M parameters and 3.5 MB. It wasn't better
|
|
| 122 |
|
| 123 |
</details>
|
| 124 |
|
| 125 |
-
## Training
|
| 126 |
|
| 127 |
It read 40 million characters from 119,859 emails sent from enron.com addresses, 30 times over. Typos were added to what it read, so it keeps predicting when you make one. The run took 14 minutes on one A10G with Hugging Face Jobs and cost 35 cents.
|
| 128 |
|
|
|
|
| 3 |
pipeline_tag: text-generation
|
| 4 |
datasets:
|
| 5 |
- corbt/enron-emails
|
| 6 |
+
- HuggingFaceFW/fineweb-edu
|
| 7 |
+
- HuggingFaceTB/smoltalk
|
| 8 |
language:
|
| 9 |
- en
|
| 10 |
tags:
|
| 11 |
- autocomplete
|
| 12 |
- gru
|
| 13 |
+
- transformer
|
| 14 |
+
- fill-in-the-middle
|
| 15 |
- onnxruntime-web
|
| 16 |
- in-browser
|
| 17 |
- offline-page
|
| 18 |
+
model-index:
|
| 19 |
+
- name: tinynext-v2
|
| 20 |
+
results:
|
| 21 |
+
- task:
|
| 22 |
+
type: text-generation
|
| 23 |
+
name: Autocomplete (typing saved at a 50% cutoff)
|
| 24 |
+
dataset:
|
| 25 |
+
type: wikimedia/wikipedia
|
| 26 |
+
name: Wikipedia articles (held out)
|
| 27 |
+
metrics:
|
| 28 |
+
- type: typing_saved
|
| 29 |
+
name: Typing saved (%)
|
| 30 |
+
value: 4.0
|
| 31 |
+
- type: suggestion_precision
|
| 32 |
+
name: Suggestions that were right (%)
|
| 33 |
+
value: 76
|
| 34 |
+
- task:
|
| 35 |
+
type: text-generation
|
| 36 |
+
name: Autocomplete (typing saved at a 50% cutoff)
|
| 37 |
+
dataset:
|
| 38 |
+
type: OpenAssistant/oasst1
|
| 39 |
+
name: OpenAssistant messages, validation split
|
| 40 |
+
metrics:
|
| 41 |
+
- type: typing_saved
|
| 42 |
+
name: Typing saved (%)
|
| 43 |
+
value: 7.3
|
| 44 |
+
- type: suggestion_precision
|
| 45 |
+
name: Suggestions that were right (%)
|
| 46 |
+
value: 78
|
| 47 |
+
- task:
|
| 48 |
+
type: text-generation
|
| 49 |
+
name: Autocomplete (typing saved at a 50% cutoff)
|
| 50 |
+
dataset:
|
| 51 |
+
type: corbt/enron-emails
|
| 52 |
+
name: Enron emails from held-out senders
|
| 53 |
+
metrics:
|
| 54 |
+
- type: typing_saved
|
| 55 |
+
name: Typing saved (%)
|
| 56 |
+
value: 4.3
|
| 57 |
+
- type: suggestion_precision
|
| 58 |
+
name: Suggestions that were right (%)
|
| 59 |
+
value: 79
|
| 60 |
---
|
| 61 |
|
| 62 |
<p align="center">
|
|
|
|
| 79 |
|
| 80 |
tinynext is the autocomplete in [offline.page](https://github.com/cfahlgren1/offline-page). It's the same model as [`cfahlgren1/enron-autocomplete`](https://huggingface.co/cfahlgren1/enron-autocomplete), copied here under its new name.
|
| 81 |
|
| 82 |
+
## v2: the next few words, with context
|
| 83 |
+
|
| 84 |
+
<sub>In [`v2/`](https://huggingface.co/cfahlgren1/tinynext/tree/main/v2). The files at the root of this repo are still v1.</sub>
|
| 85 |
+
|
| 86 |
+
v1 guesses one letter at a time, so its suggestions are short word endings. v2 is a **12.5M-parameter transformer that predicts word pieces**, so one step can be a whole word, and it reads up to about 1,500 characters before the cursor (and, when there is any, text after it). It runs in a Web Worker in offline.page: add `?autocomplete=v2` to try it.
|
| 87 |
+
|
| 88 |
+
**How much typing it saves.** Every model is scored by [`v2/eval.py`](v2/eval.py) on the same held-out text: type it character by character, pause every 12 characters, and count a suggestion only if the text really continues that way. Same decoding rule and 50% cutoff as the app, suggestions of 4+ characters.
|
| 89 |
+
|
| 90 |
+
| Writing | v1 | v2 | SmolLM2-135M (ceiling, ~100 MB) |
|
| 91 |
+
|---|---|---|---|
|
| 92 |
+
| Articles (Wikipedia) | 1.5% | **4.0%** | 8.1% |
|
| 93 |
+
| Messages (OpenAssistant) | 2.0% | **7.3%** | 16.8% |
|
| 94 |
+
| Email (Enron, unseen senders) | 3.0% | **4.3%** | 5.7% |
|
| 95 |
+
|
| 96 |
+
| Writing (v2) | Suggests at | Right | 2+ words suggested at | 2+ words right |
|
| 97 |
+
|---|---|---|---|---|
|
| 98 |
+
| Articles (Wikipedia) | 11% | 76% | 3% | 74% |
|
| 99 |
+
| Messages (OpenAssistant) | 16% | 78% | 8% | 72% |
|
| 100 |
+
| Email (Enron, unseen senders) | 11% | 79% | 3% | 60% |
|
| 101 |
+
|
| 102 |
+
**In the browser.**
|
| 103 |
+
|
| 104 |
+
| | |
|
| 105 |
+
|---|---|
|
| 106 |
+
| Download | **13.3 MB**: int8 weights with one scale per 64 values, expanded to float32 when the page loads |
|
| 107 |
+
| Matches full precision | same next word 99% of the time, same 5-word path 92%, typing saved within 0.2 points |
|
| 108 |
+
| Speed | **4 ms** per suggestion (14 ms p95) in a Web Worker, Chrome on an M3 Max; typing stays under one frame |
|
| 109 |
+
|
| 110 |
+
The browser computes in float32 on purpose: onnxruntime-web's int8 kernels were 8–11× slower than its float kernels for this model, and int8 activations changed the top word too often. Only the download is compressed.
|
| 111 |
+
|
| 112 |
+
**Training.** 1.5B tokens (60% [FineWeb-Edu](https://huggingface.co/datasets/HuggingFaceFW/fineweb-edu), 30% [SmolTalk](https://huggingface.co/datasets/HuggingFaceTB/smoltalk), 10% Enron email from training senders), half of it as fill-in-the-middle examples. 28 minutes on one A100 (about $1.50) plus 20 minutes of data prep on a CPU job (about $0.34). Validation loss 2.99. [Training curves on Trackio](https://huggingface.co/spaces/cfahlgren1/tinynext-trackio).
|
| 113 |
+
|
| 114 |
+
**Limits.**
|
| 115 |
+
|
| 116 |
+
- Text after the cursor doesn't help yet: when there is some, v2 does slightly worse than with the text before alone. Experiments are under way.
|
| 117 |
+
- It still leans toward office email, and it only sees keyboard characters.
|
| 118 |
+
- It's English only.
|
| 119 |
+
|
| 120 |
+
<details>
|
| 121 |
+
<summary><b>v2 files</b></summary>
|
| 122 |
+
|
| 123 |
+
| File | What it is |
|
| 124 |
+
|---|---|
|
| 125 |
+
| `v2/web/graph.onnx`, `weights.q8`, `weights.json` | The browser model: graph, int8 weights and how to expand them |
|
| 126 |
+
| `v2/web/tokenizer.json`, `config.json` | 8K byte-level BPE tokenizer and model shape |
|
| 127 |
+
| `v2/model.safetensors` | Float32 weights |
|
| 128 |
+
| `v2/train.py` | Data prep, training, eval, export and upload in one script |
|
| 129 |
+
| `v2/eval.py`, `v2/eval_set.json` | The eval harness and the fixed text it scores |
|
| 130 |
+
| `v2/export.py`, `v2/compress.py` | Re-export to ONNX, and the int8 download format |
|
| 131 |
+
| `v2/metrics/*.json` | Eval results for v1, v2 and SmolLM2-135M |
|
| 132 |
+
| `v2/report.json` | Training settings, loss history and export checks |
|
| 133 |
+
|
| 134 |
+
</details>
|
| 135 |
+
|
| 136 |
+
<details>
|
| 137 |
+
<summary><b>Train it yourself</b></summary>
|
| 138 |
+
|
| 139 |
+
```bash
|
| 140 |
+
# Prepare data once on a CPU job, then train on a GPU from the prepared files.
|
| 141 |
+
hf jobs uv run --flavor cpu-xl --secrets HF_TOKEN train.py --stage prepare
|
| 142 |
+
hf jobs uv run --flavor a100-large --secrets HF_TOKEN train.py --stage train
|
| 143 |
+
```
|
| 144 |
+
|
| 145 |
+
</details>
|
| 146 |
+
|
| 147 |
+
## v1: the original character model
|
| 148 |
+
|
| 149 |
+
### What it does
|
| 150 |
|
| 151 |
It finishes the word or short phrase you're typing. Press <kbd>Tab</kbd> to take the suggestion.
|
| 152 |
|
|
|
|
| 157 |
| The books are fine. Please call me i | **f you have any** |
|
| 158 |
| Enron N | **orth America Corp.** |
|
| 159 |
|
| 160 |
+
### How sure it has to be
|
| 161 |
|
| 162 |
The model knows how sure it is of each guess. You pick a cutoff, and it only suggests when it's at least that sure. A higher cutoff means fewer suggestions, and more of them right.
|
| 163 |
|
|
|
|
| 180 |
|
| 181 |
These numbers come from 5,000 places in emails from people the model never saw in training. “Right” means the suggestion exactly matched what the person typed next.
|
| 182 |
|
| 183 |
+
#### Limits
|
| 184 |
|
| 185 |
- It only knows office email from 2001. Outside that it has little to say.
|
| 186 |
- With no cutoff it rambles. “Dear Santa,” becomes “I am attaching a copy of the agreement to the Enron Corp.”
|
| 187 |
- It learned real names and sign-offs from the emails, so keep suggestions short.
|
| 188 |
- English only.
|
| 189 |
|
| 190 |
+
### Use it
|
| 191 |
|
| 192 |
The model takes one character and its memory of the text so far. It returns its guess for the next character and an updated memory. So each key press is one small step.
|
| 193 |
|
|
|
|
| 235 |
|
| 236 |
</details>
|
| 237 |
|
| 238 |
+
### Training
|
| 239 |
|
| 240 |
It read 40 million characters from 119,859 emails sent from enron.com addresses, 30 times over. Typos were added to what it read, so it keeps predicting when you make one. The run took 14 minutes on one A10G with Hugging Face Jobs and cost 35 cents.
|
| 241 |
|