Text Generation
Transformers
Safetensors
English
qwen3
typing
autocomplete
word-prediction
next-word-prediction
keyboard
typo-correction
text-generation-inference
Instructions to use ScarletKc/Typeling-25M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ScarletKc/Typeling-25M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ScarletKc/Typeling-25M")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ScarletKc/Typeling-25M") model = AutoModelForCausalLM.from_pretrained("ScarletKc/Typeling-25M", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ScarletKc/Typeling-25M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ScarletKc/Typeling-25M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ScarletKc/Typeling-25M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ScarletKc/Typeling-25M
- SGLang
How to use ScarletKc/Typeling-25M with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ScarletKc/Typeling-25M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ScarletKc/Typeling-25M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ScarletKc/Typeling-25M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ScarletKc/Typeling-25M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ScarletKc/Typeling-25M with Docker Model Runner:
docker model run hf.co/ScarletKc/Typeling-25M
Model card: footprint, data cleaning, sample sizes and limitations in line with the technical report
Browse files
README.md
CHANGED
|
@@ -25,8 +25,9 @@ tags:
|
|
| 25 |
|
| 26 |
A small English language model for typing prediction: it completes the word being typed and predicts the next word,
|
| 27 |
for ghost text or a candidate bar in chat and everyday writing. 25.4M parameters, 50.8 MB at 16 bits (27.6 MB as Q8_0
|
| 28 |
-
in [Typeling-25M-GGUF](https://huggingface.co/ScarletKc/Typeling-25M-GGUF))
|
| 29 |
-
CPU
|
|
|
|
| 30 |
|
| 31 |
## Quick start
|
| 32 |
|
|
@@ -46,8 +47,11 @@ p.topk("See you tomm", 3) # [('tomorrow', 0.90), ('tommy', 0.07), ...]
|
|
| 46 |
|
| 47 |
The model predicts tokens; the [Typeling decoder](https://github.com/scarletkc/typeling) turns them into word
|
| 48 |
suggestions. It searches the words that fit the letters typed so far and gives each a probability, repairs typing
|
| 49 |
-
errors (adjacent keys, extra or missing letters, swapped letters), mixes in a small n-gram model
|
| 50 |
-
learns the user's own words locally. All results below are with this decoder.
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
### With Transformers only
|
| 53 |
|
|
@@ -75,8 +79,9 @@ types 0, 1, 2, ... letters and accepts the suggestion with one keystroke as soon
|
|
| 75 |
|
| 76 |
- **KSR** (keystroke savings rate) with ghost text: the top suggestion is shown when its probability is at least 0.3
|
| 77 |
and it extends the typed letters.
|
| 78 |
-
- **KSR@3** with a candidate bar: the top 3 candidates are always shown.
|
| 79 |
-
- 2,000 words per source. Chat is SODA, WildChat and oasst2, casual is Ubuntu
|
|
|
|
| 80 |
|
| 81 |
| | n-gram, 5 MB | n-gram, 23 MB | **Typeling-25M** |
|
| 82 |
|---|---|---|---|
|
|
@@ -86,7 +91,9 @@ types 0, 1, 2, ... letters and accepts the suggestion with one keystroke as soon
|
|
| 86 |
| Chat: precision of ghost text | 51.0% | 51.2% | **54.7%** |
|
| 87 |
|
| 88 |
The n-gram models are Typeling's pure-Python kernel (an interpolated Kneser-Ney trigram model built from the same
|
| 89 |
-
corpus; 23 MB is the unpruned model).
|
|
|
|
|
|
|
| 90 |
|
| 91 |
Next word, before any letter is typed: the right word on top / among the top 3.
|
| 92 |
|
|
@@ -99,8 +106,9 @@ Next word, before any letter is typed: the right word on top / among the top 3.
|
|
| 99 |
| FineWeb | 15.0% / 27.1% | 24.8% / 37.7% |
|
| 100 |
|
| 101 |
Typing errors: the same simulation with every word of 3+ letters mistyped (one error, two in one word out of five;
|
| 102 |
-
1,000 words per source). KSR@3 typed correctly -> with errors, and the share of
|
| 103 |
-
is picked from the candidate bar. Corrections appear only in the bar:
|
|
|
|
| 104 |
|
| 105 |
| | n-gram, 5 MB | Typeling-25M |
|
| 106 |
|---|---|---|
|
|
@@ -109,14 +117,18 @@ is picked from the candidate bar. Corrections appear only in the bar: ghost text
|
|
| 109 |
| Writing | 42.3% -> 32.0% (62.9%) | 50.8% -> 45.5% (90.5%) |
|
| 110 |
|
| 111 |
The errors come from the same keyboard model that the repair undoes, and earlier words are never mistyped, so these
|
| 112 |
-
numbers are optimistic. The
|
| 113 |
-
table compares two systems rather than isolating
|
|
|
|
| 114 |
|
| 115 |
Perplexity per word on the test splits: SODA 17.7, WildChat 180, oasst2 107, Ubuntu IRC 323, FineWeb 175.
|
| 116 |
|
| 117 |
-
Speed on a laptop CPU (AMD Ryzen 9 9955HX, 4 threads, PyTorch, float32), per suggestion
|
| 118 |
-
(39–48 / 51–60 ms) on chat, 33 ms (63 / 82 ms) on long web text
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
## Training
|
| 122 |
|
|
@@ -130,9 +142,10 @@ tokens/s for prompts and 2,800 tokens/s for single-token steps on the same 4 thr
|
|
| 130 |
- `</s>` separates texts; its embedding was initialized from the newline token's before training.
|
| 131 |
- In 1% of words, `" word"` was re-tokenized as `" "` + `"word"`, so the model also continues text that ends in a
|
| 132 |
space.
|
| 133 |
-
- **Data:** chat and writing
|
| 134 |
-
look typed by a person
|
| 135 |
-
SODA
|
|
|
|
| 136 |
|
| 137 |
| Corpus | License | Words | Share of training |
|
| 138 |
|---|---|---|---|
|
|
@@ -158,9 +171,15 @@ experiment.
|
|
| 158 |
- SODA was generated by InstructGPT, and OpenAI's terms restrict using its outputs to build competing models.
|
| 159 |
- The base model was trained on FineWeb-Edu, which is filtered from FineWeb, so writing-domain results may be
|
| 160 |
slightly optimistic.
|
| 161 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 162 |
- The model can suggest offensive words or reproduce biases from web and chat text. The Typeling decoder does not
|
| 163 |
-
suggest words from a blocklist, nor common misspellings.
|
|
|
|
|
|
|
| 164 |
- Without the Typeling decoder you get raw next-token predictions, with no word-level probabilities, typo repair or
|
| 165 |
filtering.
|
| 166 |
|
|
|
|
| 25 |
|
| 26 |
A small English language model for typing prediction: it completes the word being typed and predicts the next word,
|
| 27 |
for ghost text or a candidate bar in chat and everyday writing. 25.4M parameters, 50.8 MB at 16 bits (27.6 MB as Q8_0
|
| 28 |
+
in [Typeling-25M-GGUF](https://huggingface.co/ScarletKc/Typeling-25M-GGUF)). Through the PyTorch decoder it takes about
|
| 29 |
+
25 ms per suggestion on a high-end laptop CPU and about 549 MB of memory; the word-level decoder does not run on the
|
| 30 |
+
GGUF file yet.
|
| 31 |
|
| 32 |
## Quick start
|
| 33 |
|
|
|
|
| 47 |
|
| 48 |
The model predicts tokens; the [Typeling decoder](https://github.com/scarletkc/typeling) turns them into word
|
| 49 |
suggestions. It searches the words that fit the letters typed so far and gives each a probability, repairs typing
|
| 50 |
+
errors (adjacent keys, extra or missing letters, swapped letters), mixes in a small n-gram model that pushes non-words
|
| 51 |
+
down the list, and learns the user's own words locally. All results below are with this decoder and the 16-bit weights.
|
| 52 |
+
|
| 53 |
+
The model is downloaded once and typed text never leaves the machine, but loading it still asks Hugging Face for the
|
| 54 |
+
latest revision unless `HF_HUB_OFFLINE=1` is set ([issue #1](https://github.com/scarletkc/typeling/issues/1)).
|
| 55 |
|
| 56 |
### With Transformers only
|
| 57 |
|
|
|
|
| 79 |
|
| 80 |
- **KSR** (keystroke savings rate) with ghost text: the top suggestion is shown when its probability is at least 0.3
|
| 81 |
and it extends the typed letters.
|
| 82 |
+
- **KSR@3** with a candidate bar: the top 3 candidates are always shown, and picking one counts as one keystroke.
|
| 83 |
+
- The first 2,000 words per source (for FineWeb, three documents). Chat is SODA, WildChat and oasst2, casual is Ubuntu
|
| 84 |
+
IRC, writing is FineWeb.
|
| 85 |
|
| 86 |
| | n-gram, 5 MB | n-gram, 23 MB | **Typeling-25M** |
|
| 87 |
|---|---|---|---|
|
|
|
|
| 91 |
| Chat: precision of ghost text | 51.0% | 51.2% | **54.7%** |
|
| 92 |
|
| 93 |
The n-gram models are Typeling's pure-Python kernel (an interpolated Kneser-Ney trigram model built from the same
|
| 94 |
+
corpus; 23 MB is the unpruned model). It is not the strongest possible n-gram model (no higher orders, larger
|
| 95 |
+
vocabularies or lower count cutoffs were tried), and the language model also has the base model's 20B tokens of
|
| 96 |
+
pretraining behind it.
|
| 97 |
|
| 98 |
Next word, before any letter is typed: the right word on top / among the top 3.
|
| 99 |
|
|
|
|
| 106 |
| FineWeb | 15.0% / 27.1% | 24.8% / 37.7% |
|
| 107 |
|
| 108 |
Typing errors: the same simulation with every word of 3+ letters mistyped (one error, two in one word out of five;
|
| 109 |
+
the first 1,000 words per source, for FineWeb one document). KSR@3 typed correctly -> with errors, and the share of
|
| 110 |
+
mistyped words whose intended word is picked from the candidate bar at any step. Corrections appear only in the bar:
|
| 111 |
+
ghost text extends what was typed.
|
| 112 |
|
| 113 |
| | n-gram, 5 MB | Typeling-25M |
|
| 114 |
|---|---|---|
|
|
|
|
| 117 |
| Writing | 42.3% -> 32.0% (62.9%) | 50.8% -> 45.5% (90.5%) |
|
| 118 |
|
| 119 |
The errors come from the same keyboard model that the repair undoes, and earlier words are never mistyped, so these
|
| 120 |
+
numbers are optimistic. The share also counts words picked before the error is typed. The n-gram kernel does not
|
| 121 |
+
repair typos, and the bar was not measured without repair, so the table compares two systems rather than isolating
|
| 122 |
+
repair.
|
| 123 |
|
| 124 |
Perplexity per word on the test splits: SODA 17.7, WildChat 180, oasst2 107, Ubuntu IRC 323, FineWeb 175.
|
| 125 |
|
| 126 |
+
Speed on a high-end laptop CPU (AMD Ryzen 9 9955HX, 4 threads, PyTorch, float32), per suggestion over 300 words per
|
| 127 |
+
source, mean (p95 / p99): 23–25 ms (39–48 / 51–60 ms) on chat and IRC, 33 ms (63 / 82 ms) on long web text (one
|
| 128 |
+
document). Resident memory is 549 MB. Startup is 4.6 s to import PyTorch plus 2.5 s to load the cached model with
|
| 129 |
+
`HF_HUB_OFFLINE=1`, or 9.3 to 12.6 s with the default revision check. llama.cpp runs the Q8_0 file at about 12,000
|
| 130 |
+
tokens/s for prompts and 2,800 tokens/s for single-token steps on the same 4 threads, but no word-level decoder runs on
|
| 131 |
+
it yet, so it has not been through this benchmark.
|
| 132 |
|
| 133 |
## Training
|
| 134 |
|
|
|
|
| 142 |
- `</s>` separates texts; its embedding was initialized from the newline token's before training.
|
| 143 |
- In 1% of words, `" word"` was re-tokenized as `" "` + `"word"`, so the model also continues text that ends in a
|
| 144 |
space.
|
| 145 |
+
- **Data:** chat and writing. FineWeb has emails, URLs and phone numbers removed; WildChat, oasst2 and IRC keep only
|
| 146 |
+
turns that look typed by a person and contain none of them, and WildChat also drops turns flagged as toxic or
|
| 147 |
+
redacted; SODA, which is generated, is used as released. About 1% of FineWeb, WildChat and IRC is held out for
|
| 148 |
+
development and 1% for testing; SODA and oasst2 keep their official splits.
|
| 149 |
|
| 150 |
| Corpus | License | Words | Share of training |
|
| 151 |
|---|---|---|---|
|
|
|
|
| 171 |
- SODA was generated by InstructGPT, and OpenAI's terms restrict using its outputs to build competing models.
|
| 172 |
- The base model was trained on FineWeb-Edu, which is filtered from FineWeb, so writing-domain results may be
|
| 173 |
slightly optimistic.
|
| 174 |
+
- Typing and typo results are simulated, with no user study; the errors do not come from recorded human typing. The
|
| 175 |
+
benchmark cannot show whether learning the user's words helps, because its texts come from many different people.
|
| 176 |
+
- Each result uses the first 1,000 to 2,000 words of a split, with no confidence intervals or repeated samples. System
|
| 177 |
+
comparisons are on the same words, but absolute numbers depend on the sample: the 23 MB n-gram scores 28.9% KSR on
|
| 178 |
+
WildChat's development sample and 34.8% on its test sample.
|
| 179 |
- The model can suggest offensive words or reproduce biases from web and chat text. The Typeling decoder does not
|
| 180 |
+
suggest words from a blocklist, nor common misspellings, but other harmful completions are possible. The model was
|
| 181 |
+
not tested for verbatim reproduction of training text or personal information.
|
| 182 |
+
- The candidate bar can still offer non-words right after a finished word (`muchfor`).
|
| 183 |
- Without the Typeling decoder you get raw next-token predictions, with no word-level probabilities, typo repair or
|
| 184 |
filtering.
|
| 185 |
|