dkssudTap an example belowThe model runs in your browser, and nothing you type is sent anywhere.
Features
- 100% localIt only ever runs offline. I would love your personal data too, but..
- Tpyos are fineHowever many typos you make, we are forgiving.
- Within 100msWe know you have no patience.
- Korean and English alikeWe love English speakers just as much as Korean speakers.
How it works
-
Judging every key
The model reads the word again at every key and labels each key Korean or English. At Space the word becomes what the labels say.
-
Understanding context
Sometimes it looks at what comes after to judge better. Once the next word is typed, it reads the word before again and fixes it or puts it back if it was wrong.
-
Splitting mixed words
Two languages glued together with no space are split inside the word, and each part is fixed on its own.
Specs
- 0.79%word error rate in real use
one person's typing log over 32 days, mostly technical writing, n = 17,876 words
- 3.8 msinference latency per keystroke
one pass over a 64-key line, one Ryzen 5 5600 thread
- 3.2Mparameters
every trained weight
- 13 MBmodel size
FP32 weights as trained, no quantization
- 152 mintraining time
one graphics card (RX 9060 XT)
- 428Mwords seen in training
102K steps × batch 1,024, 4.1 words per example on average
Model card
- Model
TR5n-102K. Weights published on Hugging Face- Input
- The raw key sequence of the line so far, spaces included, as typed on a 2-set (두벌식) layout
- Output
- A Korean or English label for every key; a CRF picks the best path through each word
- Architecture
- 4-layer Transformer encoder (d_model 256, 4 heads, FF 1024) with a CRF
- Training labels
- None by hand: text written in Hangul is Korean, text in Latin letters is English
- Runs on
- ONNX Runtime on CPU; in this page, ONNX Runtime Web
Benchmark
Times fewer errors than the runner-up on each measure
- 3.0×Mean over the 13 sets
3.38% vs 10.31% (Word statistics input method)
- 4.8×All 123,075 points
0.70% vs 3.37% (Word statistics input method)
- 15×Words with a typo
0.58% vs 9.00% (Word statistics input method)
Public benchmark
- lower is better
Figure 1. Error rate per model: on the left the mean over the 13 sets, each weighted the same; on the right all decision points pooled. 65% of the points are easy lines with no switch, so the pooled value is mostly the easy sets.
| Error rate (%), lower is betterSet | Points | TR5n-102K | Released input methods (unnamed) | ||||
|---|---|---|---|---|---|---|---|
| Word statistics | 3-gram A | 3-gram B | Heuristic | ||||
| Basics | Korean only | 40,006 | 0.04 | 0.18 | 1.01 | 1.03 | 4.07 |
| English only | 40,022 | 0.01 | 0.02 | 0.04 | 0.01 | 0.00 | |
| Switching | Korean → English switch | 5,368 | 1.42 | 7.13 | 3.39 | 6.91 | 2.63 |
| English → Korean switch | 6,693 | 2.63 | 13.36 | 5.72 | 6.04 | 23.70 | |
| Words with numbers | 3,579 | 0.20 | 0.47 | 21.49 | 4.14 | 14.00 | |
| Ambiguous keys | English that is also a Korean word (so = 내) | 2,001 | 5.60 | 18.99 | 1.90 | 18.64 | 7.40 |
| Korean that is also an English word (해 = go) | 2,500 | 0.88 | 3.08 | 38.64 | 25.56 | 28.88 | |
| Single jamo in Korean text (ㅋ, ㅠ) | 2,502 | 3.88 | 8.39 | 100.00 | 35.05 | 100.00 | |
| Keys that read in both languages | 620 | 16.61 | 25.16 | 40.48 | 35.32 | 0.97 | |
| Word forms | Two languages in one word | 1,000 | 10.30 | 31.00 | 54.70 | 32.30 | 100.00 |
| Acronyms | 1,000 | 0.10 | 10.60 | 0.20 | 0.00 | 0.00 | |
| A line of one word | 3,000 | 1.73 | 6.67 | 15.87 | 7.60 | 37.50 | |
| Typing slips | A typo in the word | 14,784 | 0.58 | 9.00 | 11.82 | 36.93 | 44.01 |
| Mean over sets | 13 sets | 3.38 | 10.31 | 22.71 | 16.12 | 27.93 | |
| All points (weighted) | 123,075 | 0.70 | 3.37 | 6.73 | 7.68 | 12.89 | |
Experiments
Diminishing returns of training length
- measured
- fit
- 204k predicted
- 204k actual
Model size against latency
- base 256×4 layers (3.2M)
- wide 384×4 layers (7.2M)
- deep 320×6 layers (7.5M)
- joined points differ only in seed
Divergence of validation loss and real errors
- 102k steps, seed 0
- 102k steps, seed 1
- 204k steps, seed 0
Data reweighting and the error trade-off
- original data, 10k steps
- more ambiguous English data, 10k steps
- original data, 51k steps (5× longer)
- dots: bias 0 (default); dashed: seed 1
Discussion
- Optimistic bias of word-level evaluation
I first tested on a word list, saw 0.02% wrong corrections and thought that was low enough. But on real sentences it was 1.03%, fifty times worse. Short, ambiguous words like 그 (
rm) and 내 (so) barely appear in word lists but show up all the time in real text. From then on, every result was measured on sentences.Figure 6. Wrong corrections of the first model, which judged one word at a time, measured on a word list and on real sentences. - Sampling bias from data filtering
To keep Korean typed in the wrong mode out of the training data, I dropped every sentence with English whose keys spell a Korean word. That also removed
so,go,work,B급and almost every single letter, so the model never saw short English inside Korean and turned all of it into Korean. Deciding by word frequency instead brought them back, and errors on real mixed sentences went from 76 to 62.Figure 7. Errors on real mixed sentences before and after changing only the filter. The next step (translation swaps) took 63 to 52. - Key-level sequence labelling
The first models picked one language per word, so a word that switches language halfway could not even be written down. With a label on every key,
githubdpis simply six keys marked English and two marked Korean. A model reading word summaries forgot things like particles, so one Transformer reads the whole key stream, spaces included.Figure 8. Key-level sequence labelling. E is English, K is Korean; a label that changes once inside a word splits it in two. - Train-inference information mismatch
While you type, there is at most one word after the one being decided. Training masked attention to one word ahead as well, but with four layers a word still reaches four words ahead through its neighbours. Training scores look great because the model peeks at the future, which typing never has. So only the word being decided gets a label, and training sees exactly what typing does.
- typed so far
- the next word, also there while typing
- leaked in training only
- the end of what typing shows
Figure 9. Schematic. Where word t reaches at each layer: the mask allows one word ahead, and every layer reaches one further. - Decision timing and available information
I measured how often a word is wrong if it is judged before it is finished. One-language words of 4 or more keys are wrong 36.7% of the time after 1 key, 7.3% after 2 and 4.4% after 3, but 0.09% at Space and 0.08% one word later. Over all words it is 0.92% at Space and 0.72% one word later, 21% fewer, and looking three words ahead gives no more (18%). The information arrives at Space, and one word after it holds almost all the rest. So Nunchi decides at Space and fixes a word once more one word later.
Figure 10. Error on one-language words of 4+ keys (dev) by when they are judged: high before the word is finished, a steep drop at Space, and almost none left to gain one word later. - Seed variance and evaluation noise
At first, when a change improved the score, I credited the change. But the same recipe with only the random seed changed came out 44 words different. After that I added more dev sets and trained more seeds, and only trusted differences bigger than that wobble.
Figure 11. One point per training run. Joined points share the setting and differ only in seed. - Symmetric errors on key-collision pairs
Reading the remaining errors by hand, 46% are words where both languages make sense. The same keys go wrong as English in one set and as Korean in another. Tilting the data one way only moved errors to the other side; what is left has to be settled by context.
Figure 12. Kinds of errors the current model still makes: 245 read by hand, weighted by set size, error bars ±6 points.
Every experiment, in order: EXPERIMENTS.md.
Conclusion
One Transformer with 3.2M parameters labels every key with a language and fixes typing one word at a time. It gets 0.79% of words wrong in real use and 3.38% on the public benchmark, its 13 sets weighted the same, at 3.8 ms a keystroke on your own PC. But as the experiments show, changing the data mix only moved errors from one side to the other, and longer training stopped paying off at 102k steps. Nearly half of what is left are words that make sense in both languages, and they gather where there is little context before them, such as the first word of a line or a short sentence. How to bring those down is still a hypothesis; the candidates are under future work below.
Future work
- Disambiguating key-collision pairs
sois English, but the same keys in Korean mode spell 내. Only the words around it can settle which one you meant, and a short sentence often does not give enough. Nearly half of the remaining errors are of this kind, so the plan is to set the line by how often people actually mean each one.e.g.
so/ 내,go/ 해,gg/ ㅎㅎ - First-word decisions without context
The first word of a line has no context at all. In my own typing, it is where wrong words pile up most.
e.g.2.5% of first words wrong in my typing, e.g.
so→ 내 at the start of a line - Abbreviations fused with Korean particles
When a lower-case abbreviation runs straight into a Korean particle, the model often reads the whole thing as Korean. Developer talk is full of these: in my own typing, 34% of such words came out wrong.
e.g.
wsl로,ml에서,k키트 - Overconfidence on partial words
The app switches the input mode before a word is finished when it is very sure. But the model only ever trained on finished words, so it mistakes a half-typed word for a whole one. Waiting for a few letters first, or training on half-typed words too, are the candidates to measure next.
e.g.typing
what, atwhait reads 좀 in Korean and calls it Korean at 99.9%
Download
Windows, 37 MB, version 0.1.0. An early release without code signing, so Windows may warn you the first time you run it.
Data and license
The code is under the MIT License. The trained weights are offered as is, for trying the app and for research. Because part of the data is CC BY-SA, they are offered under CC BY-SA 4.0 as far as the author is able to do so. The demo on this page uses those weights. No rights are granted in third-party text.
Not every source states a license. If you hold rights in any of this data and object to its use, please open an issue: the model will be retrained without it or taken down.
- NSMC (CC0)
- KcBERT pre-training corpus (CC BY-SA 4.0)
- mC4 Korean (ODC-BY, Common Crawl terms of use)
- Tatoeba (CC BY 2.0 FR)
- Wiktionary via kaikki.org (CC BY-SA 4.0 / GFDL)
- wordfreq (data CC BY-SA 4.0)
- WikiText-103 (CC BY-SA)
- REDDIT_comments (no license stated)
- GoEmotions (Apache-2.0 on its card)
- IMDB reviews (license "other", no terms on its card)