Small, schema-locked language models for the fleet
Harvest a corpus from the repositories, train a tiny transformer, export int8, ship it beside the app. One file per stage, standard library only, no network, no API key.
This kit builds models that turn a sentence into the JSON an app already knows how to use. It does not build chat. A model here is a function with weights: text in, a schema-valid object out, and a refusal when the request does not fit.
The fleet already has both ends. ml-kit is light AI — classic algorithms, no model. The user's own key through sui or ai-bridge is heavy AI. This is the middle.
| Model | Input → output | Pairs |
|---|---|---|
rep | rubric text → id, book, section, graded remedies | 359,432 |
verse | word → ARPAbet pronunciation | 133,309 |
book | prose → book, author, section | 5,502 |
act | description → tool or API, with constraints | 2,626 |
materia | proving paragraph → remedy | 1,709 |
tutor | question + options → key and rationale | 392 |
forge | capability or pitch → KILN spec | 98 |
file | description → the file tool that does it | 72 |
audit | lesson or issue → guard, severity, status | 19 |
| total | 503,159 | |
Two runs of the same checkouts produce byte-identical files and identical hashes. A book whose US public-domain year is still in the future is skipped and the skip is recorded with its reason.
Same corpus, same shape, same 180 steps, same CPU. Only the tokenizer changes.
| byte-level | BPE 4,096 | |
|---|---|---|
| chars per token | 1.00 | 3.29 |
| parameters | 1,083,520 | 1,514,240 |
| eval loss per token | 1.0083 | 3.2267 |
| bits per character | 1.4547 | 1.4149 |
The per-token row is a trap: divide by characters per token and BPE is 2.7% better. What it generates is the point.
byte-level → {"api": "BBdicegi", "auth": "none", "cat": "Bungorincdinaly"
BPE → {"api": "SDD", "auth": "none", "cat": "Games & Comics",
"cors": "unknown", "host": "cems..io", "https": "yes"}
The format is learned; the vocabulary is not. That is the correct result for 1.5 M parameters and three CPU minutes, and it is what the 22 M model with a GPU-week closes.
python3 tools/lm-corpus-harvest.py --root ../src --out ../corpus
python3 tools/lm-bpe.py train --corpus ../corpus --models act --vocab 4096 --bpe bpe-act.json
python3 tools/lm-train.py --corpus ../corpus --model act --out ../run \
--tokenizer bpe --bpe bpe-act.json --steps 180 --batch 4
| Model | Job | Params | Q4 |
|---|---|---|---|
| lm-book | read a book, return its structure | 24 M | 13 MB |
| lm-materia | a proving, as structured remedy knowledge | 30 M | 16 MB |
| lm-rep | case text → rubric IDs, never a remedy | 48 M | 26 MB |
| lm-act | one sentence → one command | 15 M | 8 MB |
| lm-tutor | question, answer, rationale | 34 M | 18 MB |
| lm-forge | idea → spec, or spec → patch | 60 M | 33 MB |
| lm-audit | diff or log → findings and a verdict | 24 M | 13 MB |
| lm-fleet | route and compose across the seven | 90 M | 48 MB |