Add RESULTS.md
Browse files- RESULTS.md +36 -41
RESULTS.md
CHANGED
|
@@ -1,57 +1,52 @@
|
|
| 1 |
# Lesson 07 RESULTS: tiny transformer decider (pankh-decider-v0)
|
| 2 |
|
| 3 |
-
Run: 2026-10-11, Apple M4 Max, PyTorch 2.14.1, device `mps` for training, CPU for latency. Executed end to end with papermill (`lesson_07.executed.ipynb`, kept locally). Whole notebook: **
|
| 4 |
|
| 5 |
## Data
|
| 6 |
-
- pankhllm `evals/pharma-kpi/gen.py` (MIT), run with `python -I`: `gen.py 20000` (training templates,
|
| 7 |
-
- Templates: 71 training, 35 held out
|
| 8 |
-
- Shape abstraction (dates, codes, numbers, quoted text
|
| 9 |
-
-
|
| 10 |
-
- Share of held-out-template words never seen in training: 13.9%.
|
| 11 |
-
|
| 12 |
-
## Leakage check (done in the notebook)
|
| 13 |
-
- Identical question text in train and test: **0**.
|
| 14 |
-
- Shapes shared by train and test: **0**.
|
| 15 |
-
- Every test question matches one of its own operation's held-out templates (2,000 / 2,000).
|
| 16 |
-
- 271 / 2,000 test questions also fit the pattern of a training template of the same operation (loose patterns such as "{m} for {g} {c}" match text produced by other templates). They are generated from held-out templates; they are not copies. Reported, not removed.
|
| 17 |
|
| 18 |
-
##
|
| 19 |
-
-
|
| 20 |
-
- Tiny GPT decider: Lesson 01 GPT class, 4 layers, 4 heads, 128 wide, block 64, dropout 0.1; **word-level tokenizer** over abstracted shapes (210 tokens incl. `<pad>`, `<unk>`, `<sep>` and the 8 operation tokens). 828,416 parameters. Masked loss on the decision token only; word dropout 0.15. 800 steps x batch 64, AdamW, lr 1e-3, warm-up 50 + cosine. Trained in 11.8 s on MPS. Final loss 0.0154.
|
| 21 |
|
| 22 |
-
##
|
| 23 |
-
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
| Logistic regression | 66.2% | 7.8% | 97.45% | 4 | 6.6% | 98.48% |
|
| 28 |
-
| Tiny GPT decider | 82.3% | 46.5% | 94.52% | 51 | 36.4% | 99.45% |
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
-
|
| 41 |
-
-
|
| 42 |
-
- pankhllm's published 14/14 (BENCHMARK-DECISIONS.md) is a model trained on 120 questions of that three-operation catalog: different test, quoted only as published.
|
| 43 |
|
| 44 |
-
##
|
| 45 |
-
|
| 46 |
-
- Tiny GPT decider (PyTorch, 4 threads): p50 0.47 ms, p95 0.526 ms.
|
| 47 |
-
- Model file: pankh-decider-v0/model.pt 3.3 MB (fp32).
|
| 48 |
|
| 49 |
-
##
|
| 50 |
-
|
| 51 |
|
| 52 |
-
##
|
| 53 |
-
-
|
| 54 |
-
- Prototype runs before the notebook (not quoted) showed the same spread across runs (test accuracy 0.68 to 0.80 depending on word dropout and run).
|
| 55 |
-
- Our pure-NumPy LR is not pankhllm's Rust binary; its latency and its features (no capitalised-word or product-vocabulary text slots, no known-words guard) differ.
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
| 1 |
# Lesson 07 RESULTS: tiny transformer decider (pankh-decider-v0)
|
| 2 |
|
| 3 |
+
Run (after grading fixes): 2026-10-11, Apple M4 Max, PyTorch 2.14.1, device `mps` for training (GPU shared with other jobs, so training was slower than the first run), CPU for latency. Executed end to end with papermill (`lesson_07.executed.ipynb`, kept locally; re-executed, not hand-patched). Whole notebook: **172.4 s**. Seed 42 (plus 43, 44). Colab T4 time: estimated, not timed. This run supersedes the first run (whose numbers were 82.3% / 46.5% at 94.52%); every number below is from this run.
|
| 4 |
|
| 5 |
## Data
|
| 6 |
+
- pankhllm `evals/pharma-kpi/gen.py` (MIT), run with `python -I`: `gen.py 20000` (training templates, seed 7) and `gen.py 2000 --heldout` (held-out templates, seed 99). 7 operations + UNSUPPORTED, 250 test questions per class.
|
| 7 |
+
- Templates: 71 training, 35 held out. 2,000 test questions = **1,150 distinct shapes**; UNSUPPORTED = **9 shapes**, the most repeated being "what's our company holiday schedule?" **x 46**.
|
| 8 |
+
- Shape abstraction (dates, codes, numbers, quoted text), after pankhllm `learn.rs` (its capitalised-word-run -> `<text>` rule is omitted).
|
| 9 |
+
- Shape-hash split (pankhllm miner style): fit 15,205 questions (5,892 shapes), calibration 4,795 (1,499 shapes). Calibration shapes share templates with training, so they are easier than held-out templates. 13.9% of held-out words never seen in training.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
+
## Leakage check
|
| 12 |
+
- Identical questions train/test: **0**. Shared shapes: **0**. 2,000/2,000 test questions match their own held-out templates; 271/2,000 also fit a loose training-template pattern (generated from held-out templates; not copies).
|
|
|
|
| 13 |
|
| 14 |
+
## Models
|
| 15 |
+
- Logistic regression (pankhllm recipe, NumPy): hashed word + bigram, 2^16 buckets, 5,892 distinct shapes, class-balanced SGD, L2 1e-3, 30 epochs; 2.5 s.
|
| 16 |
+
- Tiny GPT (Lesson 01 class): 4 layers, 4 heads, 128 wide, block 64, dropout 0.1, word-level tokenizer (210 tokens), 828,416 params, masked loss on the decision token, word dropout 0.15, 800 steps x 64; 62.3 s on shared MPS; final loss 0.0146.
|
| 17 |
|
| 18 |
+
## Thresholds
|
| 19 |
+
Fixed = lowest threshold at which the calibration shapes hold >= 98% (LR 0.9666, GPT 0.9956). pankhllm's miner searches a 0.5-0.95 grid; under that rule neither model would get a threshold on this calibration set. Oracle = swept on the test set (not deployable).
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
## Known-words gate (new, pankhllm `decisions.min_known_words` = 0.7)
|
| 22 |
+
An operation is not acted on if < 70% of the shape's words were seen in non-UNSUPPORTED fit questions; UNSUPPORTED unaffected. Applied at the same fixed thresholds. It stops 336 of 2,000 held-out questions (for any operation choice).
|
| 23 |
|
| 24 |
+
## Numbers (held-out templates, 2,000 questions)
|
| 25 |
+
| Model | Accuracy | Decided @ fixed | Precision | Wrong | Oracle 98% |
|
| 26 |
+
|---|---|---|---|---|---|
|
| 27 |
+
| Logistic regression | 66.2% | 7.8% | 97.45% | 4 | 6.6% |
|
| 28 |
+
| Logistic regression + gate | 66.2% | 7.8% | 97.45% | 4 | 33.9% |
|
| 29 |
+
| Tiny GPT | 81.5% | 49.6% | 94.46% | 55 | 42.2% |
|
| 30 |
+
| Tiny GPT + gate | 81.5% | 41.2% | **98.91%** | 9 | 51.5% |
|
| 31 |
|
| 32 |
+
**CHECK (Lesson 07):** without pankhllm's known-words gate neither model holds 98% at its fixed threshold (transformer 49.6% at 94.46%, regression 7.8% at 97.45%). With the gate the transformer does, deciding **41.2% at 98.91%** (9 wrong); the regression is unchanged at 7.8% at 97.45%.
|
| 33 |
|
| 34 |
+
The transformer's 55 wrong decisions (no gate) are **10 distinct shapes**, 46 of them one question ("what's our company holiday schedule?", said kpi_value): the 94.46% figure is effectively decided by one template. Other confident errors: "give me <metric> for <code> MTD/QTD/YTD" -> prescriber_list (~0.996-0.998).
|
| 35 |
+
Calibration: LR accuracy 89.4%, GPT 95.5% (decided 87.2% at 100%).
|
| 36 |
|
| 37 |
+
Seed check (accuracy; decided at its own fixed threshold, precision; oracle-98):
|
| 38 |
+
- seed 42: 81.55%; 49.6% at 94.46%; 42.25% (kept)
|
| 39 |
+
- seed 43: 88.3%; 53.7% at 95.25%; 34.75%
|
| 40 |
+
- seed 44: 81.4%; 56.85% at 93.93%; 26.7%
|
|
|
|
| 41 |
|
| 42 |
+
## 14 decisions benchmark questions (mapped onto the pharma catalog; "revenue" not in it)
|
| 43 |
+
LR 10/14 correct, decided 5/14 at its fixed threshold, 0 wrong. GPT 13/14 correct (missed "Why did calls fall in T-112 in 2026-08?" -> kpi_value 0.870), decided 7/14, 0 wrong. pankhllm's published 14/14 is a different model on a three-operation catalog.
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
## Latency (CPU, batch 1, 2,000 questions, shape -> decision)
|
| 46 |
+
LR p50 0.016 ms, p95 0.023 ms; GPT p50 0.5 ms, p95 0.545 ms (4 threads). model.pt 3.3 MB fp32.
|
| 47 |
|
| 48 |
+
## Published pankhllm numbers (BENCHMARK-DECISIONS.md, NOT measured here)
|
| 49 |
+
Template-only: templates 52.5% at 100% (0 wrong of 1,049); + 183 teacher labels: templates 63.3% at 100%, teacher-written A 67.1% at 100%, B 61.4% at 96.5%. These include pankhllm's structural and disagreement checks.
|
|
|
|
|
|
|
| 50 |
|
| 51 |
+
## History / caveats
|
| 52 |
+
- First draft omitted the regression cell (NameError), fixed. A first full run gave different numbers (MPS training is not bit-exact); after grading, the notebook gained the gate, distinct-shape counts, per-seed fixed-threshold numbers, a broken precision line at zero coverage in the widget and figure alt text, and was re-executed. Lesson 08 was re-executed from this run's v0.
|