vpermilp commited on
Commit
22f386e
·
verified ·
1 Parent(s): 933d44e

card: human-first rewrite

Browse files
Files changed (1) hide show
  1. README.md +83 -110
README.md CHANGED
@@ -38,139 +38,112 @@ language:
38
  - ara
39
  ---
40
 
41
- # spellman model
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
- ## Languages (30)
 
 
 
 
 
 
71
 
72
- - **Cyrillic group (21):** rus ukr bel bul mkd srp kaz kir tgk uzn tat
73
- bak chv sah tyv mon oss che udm mhr kpv
74
- - **Latin group (5):** eng spa fra por deu
75
- - **Script-routed, no model columns (4):** cmn jpn hin ara
76
 
77
- ## Files
78
 
79
- - `model.json` — the runtime contract (`version: 3`): language order
80
- (model columns), hash id/seed, char n-gram config (1..=5),
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
- The feature space is char n-grams **plus a lexical channel**: every word
90
- also contributes its whole-word FNV-1a-64 key and an adjacent-word bigram
91
- key (fastText's word / wordNgram features) hashed into the same bucket
92
- space.
93
 
94
- ## Storage formats
 
 
 
 
95
 
96
- The same model in every folded-table storage format; the runtime
97
- dequantizes at load and the graph is unchanged — every variant is
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.91 MB |
103
- | `vpermilp/spellman/f16` | f16 | 15.73 MB |
104
- | `vpermilp/spellman/int8-row` | int8, per-row scales | 8.91 MB |
105
- | `vpermilp/spellman/int8-col` | int8, per-column scales | 7.86 MB |
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
- ## Usage
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
- ```bash
123
- hf download vpermilp/spellman --local-dir model
124
- echo "Съешь ещё этих мягких французских булок" | spellman detect # rus
125
- printf 'Қазақша\nHello\n' | spellman detect --lines # kaz / eng
126
- ```
 
127
 
128
- ## Metrics
129
 
130
  | eval | accuracy |
131
  |---|---|
132
- | held-out mix (719,255 rows, pristine test) | 98.62% |
133
  | Tatoeba (37,051, out-of-domain) | 99.01% |
134
- | Tatoeba granularity ladder (word / pair / triple) | 72.06 / 89.60 / 95.21 |
135
- | wild Russian tweets (2,606, label-audited; 61% @mentions, 20% URLs) | 96.89% |
136
  | COSMUS gold-labeled wild Russian (2,808, unseen) | 97.40% |
137
- | short-utterance referee (orthography-certified, ≤19 chars) | 94.95% |
138
- | literary Russian (2,000 classic-prose sentences, held-out novel) | 98.90% |
139
- | throughput | ~3.5 µs/sample bulk, 7.5 µs single-doc (svod JIT, BEAM=16, Ryzen 9 7950X3D) |
140
-
141
- On identical eval rows it beats fastText lid.176 (Tatoeba 94.90% vs
142
- 98.98%) and lingua 1.8 high-accuracy on the shared languages at ~30x
143
- its speed; whichlang and lingua cover only 10 and 17 of these 30
144
- classes. Against open-LID SOTA GlotLID v3 it wins the wild held-out
145
- workload (98.62 vs 92.57), the single-word rung (72.06 vs 43.9), the
146
- wild-Russian referee (96.89 vs 82.73) and the short-utterance referee
147
- (94.95 vs 71.25) while running ~100x faster; GlotLID's larger training
148
- set still leads clean out-of-domain sentences (99.25 vs 98.98).
 
 
 
 
 
 
 
 
 
 
149
 
150
  ## Training data
151
 
152
- The full training mix (4,214,787 rows, 26 languages) is published at
 
153
  [vpermilp/spellman](https://huggingface.co/datasets/vpermilp/spellman)
154
- (dataset repo type) — the byte-exact recipe lives in its `manifest.json`,
155
- and every upstream's license is tabulated in its README card. The mix is
156
- NC-free (2026-08 license audit): no non-commercial upstream remains.
157
-
158
- Built from FineWeb-2 per-language configs (120k rows/language cap; also
159
- the source of the model-labeled hard-negative boundary windows),
160
- ~104k Tatoeba sentences (CC BY 2.0 FR), per-language community/parallel
161
- corpora (v12 replacements: HPLT2.0 CC0 Kyrgyz/Tajik, alifbank MIT Tajik
162
- 1.55M sentences, MADLAD-400 ODC-By ce/ky/tg, tahrirchi MIT Uzbek books
163
- and Telegram crawl, Glot500 row-filtered to its clean slices, GoURMET
164
- CC0 Kyrgyz bitext, wikimedia CE/KY/TG/TT dumps), the six spellman crawl
165
- datasets `vpermilp/lid-*` (v13: news/library sites + Telegram/VK posts
166
- and comments for sah/tyv/kpv/mhr/oss/udm, MIT), a wild social-media
167
- lane (1.85M Ukrainian tweets, cardiffnlp multilingual tweets,
168
- sentiment140, 2025 German-politics tweets, Iberian/Roman tweet sets), a
169
- verified short-utterance lane (3-19 char wild rows under 2-of-3 judge
170
- consensus and orthographic twin rules), a 12k-row literary Russian lane
171
- (wikisource classic prose), and 12 lexically-diverse lanes selected by
172
- banded lemma coverage (algo=6) over wild pools, with real normalizers —
173
- pymorphy3 for rus/ukr, Stanza for bel/bul/srp/kaz/kir, Apertium for mkd,
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).