Instructions to use vpermilp/spellman with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- fastText
How to use vpermilp/spellman with fastText:
from huggingface_hub import hf_hub_download import fasttext model = fasttext.load_model(hf_hub_download("vpermilp/spellman", "model.bin")) - Notebooks
- Google Colab
- Kaggle
card: human-first rewrite
Browse files
README.md
CHANGED
|
@@ -38,139 +38,112 @@ language:
|
|
| 38 |
- ara
|
| 39 |
---
|
| 40 |
|
| 41 |
-
# spellman
|
| 42 |
-
|
| 43 |
-
Runtime model for **spellman** — a Cyrillic-optimized language detector.
|
| 44 |
-
30 classes: the G10 world languages plus ~20 Cyrillic-script languages,
|
| 45 |
-
built for the regime general-purpose detectors fail at — closely-related
|
| 46 |
-
Cyrillic pairs (ru/be/uk, bg/mk/sr, kk/ky/tt/ba) on wild, short, real
|
| 47 |
-
internet text — at single-digit µs/sample CPU speed.
|
| 48 |
-
|
| 49 |
-
**v14 (2026-08-31): the architecture-review retrain.** Hash buckets
|
| 50 |
-
2^17 → 2^18 (measured collision load ~100 distinct keys/signed bucket),
|
| 51 |
-
training truncation k 256 → 512 tokens, short-floor 0.5, θ by
|
| 52 |
-
error-detection F1 (0.67). The root artifact is now the **int8-row
|
| 53 |
-
store** (8.9 MB; the loader dequantizes — the runtime graph is
|
| 54 |
-
unchanged, and every store gates within 0.01pp of f16).
|
| 55 |
-
|
| 56 |
-
**v13c (2026-08-30): the crawl datasets + the cap raise.** Six new
|
| 57 |
-
MIT-licensed corpora (`vpermilp/lid-{sah,tyv,kpv,mhr,oss,udm}`: news and
|
| 58 |
-
library sites plus Telegram/VK posts and comments, ~907k rows) join the
|
| 59 |
-
recipe and the per-language cap goes from 32k to 120k rows. Every thin
|
| 60 |
-
Cyrillic class is now cap-bound; on the frozen referees v13c gains
|
| 61 |
-
+3.4pp on wild Russian tweets, +4.0pp on short utterances and +2.4pp on
|
| 62 |
-
literary Russian over v12, with no language losing F1.
|
| 63 |
-
|
| 64 |
-
**v12 (2026-08-24): the commercial-clean rebuild.** Every NC-licensed or
|
| 65 |
-
NC-derived upstream was replaced or row-filtered (license table in the
|
| 66 |
-
dataset card); the replacement crawls carry orthographic pollution gates
|
| 67 |
-
(`ўы` on Tajik sources, `ҕһ` on Kyrgyz HPLT). v13c keeps that license
|
| 68 |
-
posture.
|
| 69 |
|
| 70 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
- **Latin group (5):** eng spa fra por deu
|
| 75 |
-
- **Script-routed, no model columns (4):** cmn jpn hin ara
|
| 76 |
|
| 77 |
-
##
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
canonicalization + lexical flags, calibrated confidence threshold θ.
|
| 82 |
-
- `model.safetensors` — `P` `[262145×30]` int8 with per-row f32
|
| 83 |
-
`scales` (the algebraic fold `P = E·W` of a fastText-style model,
|
| 84 |
-
stored quantized; the loader dequantizes) + `bias` `[30]` f16.
|
| 85 |
-
Inference is pure table lookups — no embedding gathers, no matmul.
|
| 86 |
-
θ (0.67) is calibrated by error-detection F1 on validation, not a
|
| 87 |
-
confidence quantile.
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
|
| 96 |
-
|
| 97 |
-
dequantizes
|
| 98 |
-
accuracy-identical to the f16 original within ±0.02pp.
|
| 99 |
|
| 100 |
| ref | format | size |
|
| 101 |
|---|---|---|
|
| 102 |
-
| `vpermilp/spellman` (root) | int8, per-row scales | 8.
|
| 103 |
-
| `vpermilp/spellman/f16` | f16 | 15.
|
| 104 |
-
| `vpermilp/spellman/int8-
|
| 105 |
-
| `vpermilp/spellman/
|
| 106 |
-
| `vpermilp/spellman/fp8-row` | fp8 e4m3, per-row scales | 8.91 MB |
|
| 107 |
-
| `vpermilp/spellman/fp8-col` | fp8 e4m3, per-column scales | 7.86 MB |
|
| 108 |
-
|
| 109 |
-
The spellman CLI fetches any of them straight from the Hub:
|
| 110 |
|
| 111 |
```bash
|
| 112 |
spellman detect --model hf:vpermilp/spellman/int8-col < text.txt
|
| 113 |
```
|
| 114 |
|
| 115 |
-
##
|
| 116 |
-
|
| 117 |
-
This is not a standalone checkpoint: the featurizer (canonicalizing char
|
| 118 |
-
n-grams + lexical word n-grams + signed feature hashing) lives in the
|
| 119 |
-
runtime, so the model is consumed by the spellman Rust workspace
|
| 120 |
-
(detector crate + CLI):
|
| 121 |
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
|
|
|
| 127 |
|
| 128 |
-
##
|
| 129 |
|
| 130 |
| eval | accuracy |
|
| 131 |
|---|---|
|
| 132 |
-
| held-out mix (719,255 rows,
|
| 133 |
| Tatoeba (37,051, out-of-domain) | 99.01% |
|
| 134 |
-
|
|
| 135 |
-
| wild Russian tweets (2,606, label-audited
|
| 136 |
| COSMUS gold-labeled wild Russian (2,808, unseen) | 97.40% |
|
| 137 |
-
| short
|
| 138 |
-
| literary Russian (2,000
|
| 139 |
-
| throughput | ~3.5 µs/
|
| 140 |
-
|
| 141 |
-
On identical
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
## Training data
|
| 151 |
|
| 152 |
-
|
|
|
|
| 153 |
[vpermilp/spellman](https://huggingface.co/datasets/vpermilp/spellman)
|
| 154 |
-
(dataset repo type)
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
corpus-derived prefix stems for the agglutinative set. Every source is
|
| 175 |
-
LID-hygiene-filtered with twin-language protection, and the low-resource
|
| 176 |
-
crawls carry orthographic pollution gates (ўы/ҕһ).
|
|
|
|
| 38 |
- ara
|
| 39 |
---
|
| 40 |
|
| 41 |
+
# spellman — Cyrillic-optimized language detection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
+
This is the runtime model for **[spellman](https://github.com/vpermilp/spellman)**,
|
| 44 |
+
a fast Rust language detector covering 30 languages: the big world
|
| 45 |
+
languages plus twenty Cyrillic-script languages (Yakut, Tuvan, Udmurt,
|
| 46 |
+
Komi, Mari, Ossetic, Chechen, …) that most detectors don't know exist.
|
| 47 |
+
It is built for the text that breaks language detectors — tweets,
|
| 48 |
+
comments, two-word utterances, and close pairs like Russian/Ukrainian —
|
| 49 |
+
and runs at ~3.5 µs per document on a desktop CPU.
|
| 50 |
|
| 51 |
+
**8.9 MB, one lookup table.** The trained network folds algebraically
|
| 52 |
+
into a single quantized table; inference is pure lookups, no matmul.
|
|
|
|
|
|
|
| 53 |
|
| 54 |
+
## Usage
|
| 55 |
|
| 56 |
+
The featurizer lives in the Rust runtime, so the model is consumed
|
| 57 |
+
through the spellman crate or CLI (not a standalone checkpoint):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
+
```bash
|
| 60 |
+
echo "Съешь ещё этих мягких французских булок" | spellman detect --model hf:vpermilp/spellman # rus
|
| 61 |
+
printf 'Қазақша\nHello\n' | spellman detect --model hf:vpermilp/spellman --lines # kaz / eng
|
| 62 |
+
```
|
| 63 |
|
| 64 |
+
```rust
|
| 65 |
+
use spellman_detector::SingleDetector;
|
| 66 |
+
let mut det = SingleDetector::from_hub(1024)?;
|
| 67 |
+
let d = det.detect("Күн сайын аҕыйах тыл үөрэт")?; // sah
|
| 68 |
+
```
|
| 69 |
|
| 70 |
+
Pick a storage format by variant — all are accuracy-identical (the
|
| 71 |
+
loader dequantizes; gates measured within 0.01pp):
|
|
|
|
| 72 |
|
| 73 |
| ref | format | size |
|
| 74 |
|---|---|---|
|
| 75 |
+
| `vpermilp/spellman` (root) | int8, per-row scales | 8.9 MB |
|
| 76 |
+
| `vpermilp/spellman/f16` | f16 | 15.7 MB |
|
| 77 |
+
| `vpermilp/spellman/int8-col` | int8, per-column scales | 7.9 MB |
|
| 78 |
+
| `vpermilp/spellman/fp8-row` / `fp8-col` | fp8 e4m3 | 8.9 / 7.9 MB |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
```bash
|
| 81 |
spellman detect --model hf:vpermilp/spellman/int8-col < text.txt
|
| 82 |
```
|
| 83 |
|
| 84 |
+
## Languages (30)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
+
- **Cyrillic (21):** Russian, Ukrainian, Belarusian, Bulgarian,
|
| 87 |
+
Macedonian, Serbian, Kazakh, Kyrgyz, Tajik, Uzbek (Cyrillic), Tatar,
|
| 88 |
+
Bashkir, Chuvash, Yakut, Tuvan, Mongolian, Ossetic, Chechen, Udmurt,
|
| 89 |
+
Meadow Mari, Komi-Zyrian
|
| 90 |
+
- **Latin (5):** English, Spanish, French, Portuguese, German
|
| 91 |
+
- **Script-routed (4, no model columns):** Mandarin, Japanese, Hindi, Arabic
|
| 92 |
|
| 93 |
+
## Accuracy (v14, 2026-08-31)
|
| 94 |
|
| 95 |
| eval | accuracy |
|
| 96 |
|---|---|
|
| 97 |
+
| held-out mix (719,255 rows, all registers) | 98.62% |
|
| 98 |
| Tatoeba (37,051, out-of-domain) | 99.01% |
|
| 99 |
+
| single words / pairs / triples (Tatoeba ladder) | 72.06 / 89.60 / 95.21 |
|
| 100 |
+
| wild Russian tweets (2,606, label-audited) | 96.89% |
|
| 101 |
| COSMUS gold-labeled wild Russian (2,808, unseen) | 97.40% |
|
| 102 |
+
| real short utterances (≤19 chars, orthography-certified) | 94.95% |
|
| 103 |
+
| literary Russian (2,000 sentences, held-out novel) | 98.90% |
|
| 104 |
+
| throughput | ~3.5 µs/doc bulk, 7.5 µs single (Ryzen 9 7950X3D) |
|
| 105 |
+
|
| 106 |
+
On identical rows it beats fastText lid.176 and lingua everywhere they
|
| 107 |
+
overlap with it, and beats open-LID SOTA GlotLID v3 on everything except
|
| 108 |
+
clean out-of-domain sentences (99.25 vs 99.01) — while running ~100×
|
| 109 |
+
faster. Wild Russian: 96.89 vs GlotLID's 82.73; short utterances: 94.95
|
| 110 |
+
vs 71.25; single words: 72.06 vs 43.9. Full tables and methodology:
|
| 111 |
+
[docs/benchmarks.md](https://github.com/vpermilp/spellman/blob/main/docs/benchmarks.md).
|
| 112 |
+
|
| 113 |
+
## Files
|
| 114 |
+
|
| 115 |
+
- `model.json` — the runtime contract: language order, hash id/seed,
|
| 116 |
+
n-gram config, canonicalization/lexical flags, and θ — the confidence
|
| 117 |
+
threshold under which a detection is flagged uncertain (0.67,
|
| 118 |
+
calibrated so the flag actually predicts errors).
|
| 119 |
+
- `model.safetensors` — the folded table `P` `[262145×30]` (int8 +
|
| 120 |
+
per-row f32 scales in this root variant) and the class `bias`.
|
| 121 |
+
|
| 122 |
+
Features are canonicalized char 1–5-grams plus whole-word and word-bigram
|
| 123 |
+
keys, sign-hashed into 2^18 buckets (fmix32).
|
| 124 |
|
| 125 |
## Training data
|
| 126 |
|
| 127 |
+
Trained on a 4.2M-row, 26-language mix published with its byte-exact
|
| 128 |
+
recipe and per-upstream license table at
|
| 129 |
[vpermilp/spellman](https://huggingface.co/datasets/vpermilp/spellman)
|
| 130 |
+
(dataset repo type). Sources include FineWeb-2 line-windows, Tatoeba,
|
| 131 |
+
per-language community and parallel corpora, a wild social-media lane,
|
| 132 |
+
a verified short-utterance lane, and the six open crawl datasets
|
| 133 |
+
(`vpermilp/lid-*`: news/library sites + Telegram/VK for
|
| 134 |
+
sah/tyv/kpv/mhr/oss/udm) built for this project. Every source passes
|
| 135 |
+
LID hygiene with twin-language protection; the mix is NC-free (2026-08
|
| 136 |
+
license audit).
|
| 137 |
+
|
| 138 |
+
## Version history
|
| 139 |
+
|
| 140 |
+
- **v14** (2026-08-31): architecture-review retrain — 2^18 buckets,
|
| 141 |
+
full-length training truncation, θ by error-detection F1; int8-row
|
| 142 |
+
root artifact.
|
| 143 |
+
- **v13c** (2026-08-30): the six crawl datasets + per-language cap
|
| 144 |
+
32k → 120k (+3.4pp wild Russian, +4.0pp short vs v12).
|
| 145 |
+
- **v12** (2026-08-24): commercial-clean rebuild — every NC-licensed
|
| 146 |
+
upstream replaced or row-filtered.
|
| 147 |
+
|
| 148 |
+
The full measured experiment log (including what failed):
|
| 149 |
+
[docs/experiments.md](https://github.com/vpermilp/spellman/blob/main/docs/experiments.md).
|
|
|
|
|
|
|
|
|