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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- zh
|
| 5 |
license: apache-2.0
|
| 6 |
+
tags:
|
| 7 |
+
- decision-model
|
| 8 |
+
- calibration
|
| 9 |
+
- system-one
|
| 10 |
+
- from-scratch
|
| 11 |
+
- probabilistic-decisions
|
| 12 |
+
- pytorch
|
| 13 |
+
pretty_name: MiniSystemOne
|
| 14 |
---
|
| 15 |
+
|
| 16 |
+
# MiniSystemOne
|
| 17 |
+
|
| 18 |
+
**Train a probabilistic decision model from scratch β no LLM, no decoding, no JSON generation.**
|
| 19 |
+
|
| 20 |
+
A 26.89M-parameter model that takes a **state** plus **typed questions** and returns
|
| 21 |
+
**typed decisions with calibrated probabilities** β in a single parallel forward pass.
|
| 22 |
+
No autoregressive loop, no text output, no constrained-decoding tricks.
|
| 23 |
+
|
| 24 |
+
Built from **random initialization**, MiniMind-style: one shared bidirectional encoder,
|
| 25 |
+
one decision head, one loss. Trained in **4.7 hours** on a single RTX 4070 Laptop (8 GB).
|
| 26 |
+
|
| 27 |
+
> ### β οΈ This is not a Jev reproduction
|
| 28 |
+
>
|
| 29 |
+
> It is an **independent educational implementation**, inspired by the "System One Model"
|
| 30 |
+
> idea popularized by TypeSafe AI's Jev (2026-09-15) β the way MiniMind is an educational
|
| 31 |
+
> reimplementation of the LLaMA/GPT recipe rather than a reproduction of any model.
|
| 32 |
+
> No Jev output was used in training, and no attempt was made to reverse-engineer it.
|
| 33 |
+
> It does **not** claim to beat Jev on any axis.
|
| 34 |
+
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
## Files
|
| 38 |
+
|
| 39 |
+
| File | Stage | Params | What it is |
|
| 40 |
+
|---|---|---|---|
|
| 41 |
+
| `decision.pth` | 2 | 26.89M | **The decision model.** The artifact this repo is about. |
|
| 42 |
+
| `mlm.pth` | 1 | 25.31M | The MLM-pretrained encoder. `decision.pth` was warm-started from it. |
|
| 43 |
+
| `tokenizer.json` / `tokenizer_config.json` | β | vocab 6400 | A **new** BPE, 11 special tokens. Not MiniMind's. |
|
| 44 |
+
|
| 45 |
+
Both checkpoints are **self-describing**: the file carries the config it was built from
|
| 46 |
+
and the provenance of its training data.
|
| 47 |
+
|
| 48 |
+
```
|
| 49 |
+
decision.pth format=1 stage=decision step=33795 n_params=26889729
|
| 50 |
+
tokenizer_sha1=bf7a131a109ea445 gen_version=1.0.0
|
| 51 |
+
encoder_init=mlm.pth trained_on=synth max_len=1024 epochs=3
|
| 52 |
+
|
| 53 |
+
mlm.pth format=1 stage=mlm step=66000 n_params=25309184
|
| 54 |
+
tokenizer_sha1=bf7a131a109ea445 synth_gen_version=1.0.0
|
| 55 |
+
max_len=512 epochs=8
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
---
|
| 59 |
+
|
| 60 |
+
## How to use these weights
|
| 61 |
+
|
| 62 |
+
**There is no `from_pretrained` path, on purpose.** This is a decision-native architecture
|
| 63 |
+
with a custom input packing format, not a causal LM. The packing is canonical and lives in
|
| 64 |
+
exactly one place in the source repository; re-implementing it here would create a second
|
| 65 |
+
implementation that drifts from the first.
|
| 66 |
+
|
| 67 |
+
The code is at **`github.com/huangyusi/MiniSystemOne`** (Apache-2.0).
|
| 68 |
+
|
| 69 |
+
```bash
|
| 70 |
+
git clone https://github.com/huangyusi/MiniSystemOne && cd MiniSystemOne
|
| 71 |
+
pip install -r requirements.txt # torch 2.6.0+cu124, transformers, datasets
|
| 72 |
+
|
| 73 |
+
# put decision.pth + tokenizer.json + tokenizer_config.json into model/ and out/decision/
|
| 74 |
+
python eval/eval_harness.py --ckpt out/decision/decision.pth \
|
| 75 |
+
--data dataset/synth --sets test_known
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
Loading a checkpoint is one call, and it reads the embedded config and refuses a mismatch:
|
| 79 |
+
|
| 80 |
+
```python
|
| 81 |
+
from trainer.trainer_utils import ckpt_info, init_model, verify_tokenizer
|
| 82 |
+
from model.model_system_one import DecisionConfig, MiniSystemOneForDecision
|
| 83 |
+
|
| 84 |
+
verify_tokenizer("decision.pth", "model") # rejects a mismatched vocabulary
|
| 85 |
+
cfg = DecisionConfig(**{k: v for k, v in ckpt_info("decision.pth")["config"].items()
|
| 86 |
+
if k in ("hidden_size", "num_hidden_layers", "vocab_size",
|
| 87 |
+
"num_attention_heads", "num_key_value_heads",
|
| 88 |
+
"intermediate_size")})
|
| 89 |
+
model = init_model(MiniSystemOneForDecision, cfg, "decision.pth", "cuda")
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
---
|
| 93 |
+
|
| 94 |
+
## Results
|
| 95 |
+
|
| 96 |
+
All numbers are from `decision.pth`, reproducible from the GitHub repo.
|
| 97 |
+
|
| 98 |
+
### Calibration β the point of the whole project
|
| 99 |
+
|
| 100 |
+
One-hot labels **cannot** teach calibration: a Brier loss on one-hot targets is just a
|
| 101 |
+
confidence-pushing regularizer. The training data therefore contains samples whose **true
|
| 102 |
+
conditional distribution is known** β a known randomized rule (`explicit_rng`),
|
| 103 |
+
marginalization over a hidden variable (`marginalized`), genuinely tied answer sets
|
| 104 |
+
(`tie_set`), and real human disagreement from ChaosNLI (`human_annotators`).
|
| 105 |
+
|
| 106 |
+
| Synthetic `test_known` (n=18,000, Kβ€255) | acc | ECE | Brier |
|
| 107 |
+
|---|---|---|---|
|
| 108 |
+
| uncalibrated | 0.647 | 0.0047 | 0.0249 |
|
| 109 |
+
| after global temperature | 0.647 | 0.0038 | 0.0249 |
|
| 110 |
+
| **calibration subset** (one-hot `hard` excluded, n=16,361) | **0.612** | **0.0061** | 0.0273 |
|
| 111 |
+
|
| 112 |
+
**Temperature calibration is a no-op** β fitted `T = 0.965`, NLL moves 1.0629 β 1.0628.
|
| 113 |
+
That is the intended result: the model is *natively* calibrated because its targets were
|
| 114 |
+
distributions to begin with.
|
| 115 |
+
|
| 116 |
+
### Read this table, not the accuracy column
|
| 117 |
+
|
| 118 |
+
`accuracy` pools two kinds of sample with structurally different ceilings, so it measures
|
| 119 |
+
the provenance mix more than the model. On a `tie_set` record the target is uniform over
|
| 120 |
+
the valid answers, so soft-accuracy is capped at `1/k` no matter how good the model is.
|
| 121 |
+
The honest denominator is the **oracle ceiling** `mean(max_k t_k)` β computable from the
|
| 122 |
+
data with no model at all.
|
| 123 |
+
|
| 124 |
+
| generator | model | oracle ceiling | achieved |
|
| 125 |
+
|---|---|---|---|
|
| 126 |
+
| `tool_router` | 0.7137 | 0.7140 | **100.0%** |
|
| 127 |
+
| `security_gate` | 0.6403 | 0.6426 | 99.6% |
|
| 128 |
+
| `refund_policy` | 0.7561 | 0.7601 | 99.5% |
|
| 129 |
+
| `agent_trace_score` | 0.6366 | 0.6450 | 98.7% |
|
| 130 |
+
| `banking_balance` | 0.4544 | 0.6091 | 74.6% |
|
| 131 |
+
| `calendar_slot` | 0.0920 | 0.1416 | 65.0% |
|
| 132 |
+
|
| 133 |
+
Four of six are essentially solved. `banking_balance` is the arithmetic one and is also
|
| 134 |
+
where calibration is worst (ECE 0.1637 vs 0.0035β0.0495 elsewhere); `calendar_slot` is the
|
| 135 |
+
large-K one, ambiguous by construction.
|
| 136 |
+
|
| 137 |
+
### Where it fails β real text
|
| 138 |
+
|
| 139 |
+
| ChaosNLI (474 items, Nβ100 annotators) | |
|
| 140 |
+
|---|---|
|
| 141 |
+
| ECE | **0.0613** |
|
| 142 |
+
| binomial noise floor | 0.0068 |
|
| 143 |
+
| noise-corrected | 0.0545 |
|
| 144 |
+
|
| 145 |
+
The floor explains only 11% of it. **On real human disagreement the model is genuinely
|
| 146 |
+
miscalibrated**, and no noise correction rescues that claim.
|
| 147 |
+
|
| 148 |
+
**Synthetic β real gap: 0.612 β 0.424 soft-accuracy β about 19 points lost** crossing from
|
| 149 |
+
program-generated rules to real natural language. This is the most informative single
|
| 150 |
+
number this project produces, reported as a limitation rather than a footnote.
|
| 151 |
+
|
| 152 |
+
### Efficiency
|
| 153 |
+
|
| 154 |
+
| | |
|
| 155 |
+
|---|---|
|
| 156 |
+
| latency (B=1, per request) | 20.24 ms median, 27.09 ms p95 |
|
| 157 |
+
| peak VRAM | **0.13 GB**, flat across K β {2, 32, 128, 255} |
|
| 158 |
+
| K=255 | 49.97 ms median (chunked path) |
|
| 159 |
+
|
| 160 |
+
Latency is **overhead-bound, not compute-bound**: K=2 takes 19.88 ms and K=32 takes
|
| 161 |
+
18.37 ms β 30 extra candidates cost nothing.
|
| 162 |
+
|
| 163 |
+
---
|
| 164 |
+
|
| 165 |
+
## What it cannot do
|
| 166 |
+
|
| 167 |
+
- **Match an LLM's open-domain NLU.** It is a **schema-bound decision model**, not a
|
| 168 |
+
general assistant.
|
| 169 |
+
- **Win on accuracy against a language model.** The claims are latency, native calibrated
|
| 170 |
+
distributions, and **zero schema errors by construction** β not accuracy.
|
| 171 |
+
- **Give reliable probabilities on genuinely OOD inputs.** No model does. The ChaosNLI
|
| 172 |
+
figure above shows the degradation rather than claiming otherwise.
|
| 173 |
+
- **Replace an LLM in any sense.** It is a component.
|
| 174 |
+
|
| 175 |
+
## License
|
| 176 |
+
|
| 177 |
+
Apache-2.0 β see the [source repository](https://github.com/huangyusi/MiniSystemOne).
|