drsamonline · kit 23

lm-kit

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.

offline zero dependencies python 3.8+ polyform noncommercial pipeline built · models not trained

The boundary

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.

Nothing here is a diagnostic engine. Mapping case text to rubric identifiers is a retrieval aid. It is not a clinical judgement and must never be presented as one. See DISCLAIMER.md.

What it harvests

ModelInput → outputPairs
reprubric text → id, book, section, graded remedies359,432
verseword → ARPAbet pronunciation133,309
bookprose → book, author, section5,502
actdescription → tool or API, with constraints2,626
materiaproving paragraph → remedy1,709
tutorquestion + options → key and rationale392
forgecapability or pitch → KILN spec98
filedescription → the file tool that does it72
auditlesson or issue → guard, severity, status19
total503,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.

What it trained

Same corpus, same shape, same 180 steps, same CPU. Only the tokenizer changes.

byte-levelBPE 4,096
chars per token1.003.29
parameters1,083,5201,514,240
eval loss per token1.00833.2267
bits per character1.45471.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.

Run it

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

The family

ModelJobParamsQ4
lm-bookread a book, return its structure24 M13 MB
lm-materiaa proving, as structured remedy knowledge30 M16 MB
lm-repcase text → rubric IDs, never a remedy48 M26 MB
lm-actone sentence → one command15 M8 MB
lm-tutorquestion, answer, rationale34 M18 MB
lm-forgeidea → spec, or spec → patch60 M33 MB
lm-auditdiff or log → findings and a verdict24 M13 MB
lm-fleetroute and compose across the seven90 M48 MB