File size: 24,894 Bytes
2d5c26a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 | # Handover: Build a Jev-like Decision Model on 3 DGX Sparks
## Objective
Build and evaluate a small-scale reproduction of the core ideas behind TypeSafe.ai's Jev / βSystem Oneβ model using approximately three NVIDIA DGX Sparks.
The objective is **not** to reproduce TypeSafe's proprietary implementation exactly. The objective is to determine whether the following design can be made practical:
> A pretrained Transformer is converted from an autoregressive text generator into a low-latency, zero-shot decision model that evaluates arbitrary natural-language questions and candidate outcomes in parallel and returns calibrated probability distributions directly.
The primary success criterion is evidence that this architecture can outperform or materially improve upon ordinary prompt-and-generate classification in at least some combination of:
- latency;
- throughput;
- probability calibration;
- consistency;
- cost per decision;
- scaling to many independent questions over one shared context.
Treat architecture claims about Jev as hypotheses unless independently verified.
---
# 1. Available hardware
Assume access to:
- 3 Γ NVIDIA DGX Spark;
- 128 GB unified memory per Spark;
- GB10 GPU;
- approximately 273 GB/s local memory bandwidth per node;
- 200 Gbit/s ConnectX-7 networking between Sparks;
- direct Spark-to-Spark topology if practical.
Do not assume that the combined 384 GB behaves as unified GPU memory.
Prefer models that fit entirely on one Spark for inference.
Use multiple Sparks primarily for:
- distributed fine-tuning;
- synthetic data generation;
- evaluation;
- teacher inference;
- parallel experiments.
Avoid tensor-parallel inference across Sparks unless necessary because network bandwidth is much lower than local memory bandwidth.
---
# 2. Core hypothesis
The highest-priority architecture to test is:
```text
shared state/context
|
v
pretrained Transformer
|
shared representation / KV cache
|
+-------------------------------+
| | |
question 1 question 2 question N
| | |
candidate set candidate set candidate set
| | |
v v v
scalar logits scalar logits scalar logits
| | |
softmax / sigmoid / ordinal mapping
|
calibrated probabilities
```
The model should **not generate answer text**.
It should directly compute probabilities over caller-provided decisions.
Examples:
```text
state:
Customer has made 3 late payments...
question:
"Will this customer churn within 30 days?"
output:
p_yes = 0.71
```
or:
```text
question:
"Which team should handle this ticket?"
choices:
- billing
- security
- infrastructure
- sales
output:
billing 0.03
security 0.83
infrastructure 0.12
sales 0.02
```
Choices must be dynamic natural-language values supplied at inference time.
Do not implement the task as a fixed classifier head whose labels are predetermined at training time.
---
# 3. Research questions
The work should answer these questions.
## RQ1 β Can a normal pretrained decoder LLM provide the required capability?
Start with an existing 1.5Bβ8B pretrained model rather than training a foundation model from scratch.
Likely candidates:
- Qwen-family base models;
- Llama-family base models if practical;
- Gemma-family base models;
- another strong dense 3Bβ8B base model.
Prefer a **base model rather than an instruction/chat model** for the main experiment if tooling permits.
Test at least:
- ~1.5B;
- ~3B;
- ~7B/8B.
A 3B model is the most interesting target.
## RQ2 β Is explicit decision training necessary?
Compare:
A. unmodified model using candidate token logits;
B. model fine-tuned for decision scoring;
C. model with a dedicated scalar decision readout;
D. optionally, model with a shallow decision decoder over shared state representations.
## RQ3 β Can the state computation be amortised?
Measure latency as the number of questions grows.
The desirable behaviour is roughly:
```text
1 question ~ X ms
10 questions ~ X + small overhead
100 questions ~ X + moderate overhead
```
rather than linear full-model execution per question.
## RQ4 β Can the probabilities be made genuinely calibrated?
Do not equate softmax output with calibration.
Evaluate:
- expected calibration error;
- Brier score;
- log loss;
- reliability diagrams;
- selective accuracy / coverage;
- calibration under domain shift.
## RQ5 β What is the best architectural split?
Compare at least two architectures if feasible:
### Architecture A β Shared-prefix decoder
Use the pretrained causal model normally for the state.
Prefill once.
Reuse the state KV cache across many independent branches.
Each branch contains:
```text
question + candidate
```
and yields one scalar score.
### Architecture B β Shared state encoder + shallow decision decoder
Run the main Transformer once over state.
Use the resulting state representation as memory.
Run only a small number of layers for each question/candidate.
Conceptually:
```text
state
|
large Transformer
|
H_state
|
+--> short question/candidate decoder --> scalar
+--> short question/candidate decoder --> scalar
+--> ...
```
Architecture B is more speculative but potentially closer to the ideal latency characteristics.
---
# 4. First implementation: baseline before training
Build the cheapest useful reproduction first.
Use an off-the-shelf small decoder model.
## Shared-prefix classifier
For every request:
1. Tokenise `state`.
2. Prefill the model once.
3. Save KV cache.
4. For every `(question, candidate)` pair:
- append a canonical decision prompt;
- reuse the same state KV cache;
- compute a score.
5. Normalise scores across candidates.
Example canonical input:
```text
STATE:
{state}
QUESTION:
{question}
CANDIDATE:
{candidate}
DECISION:
```
Initially score candidates using one of:
- probability of a special positive token;
- difference between positive and negative logits;
- a small learned scalar head applied to the final hidden representation.
The third is preferred.
Implement batching so all candidate branches execute together.
The purpose of this baseline is to establish:
- achievable latency;
- scaling behaviour;
- memory footprint;
- calibration before dedicated training.
Do this before designing a complicated training stack.
---
# 5. Preferred model interface
Expose three primitives.
## Boolean / Noul-like decision
Input:
```json
{
"state": "...",
"question": "..."
}
```
Output:
```json
{
"false": 0.21,
"true": 0.79
}
```
## Choice
Input:
```json
{
"state": "...",
"question": "...",
"choices": [
"billing",
"fraud",
"security",
"technical support"
]
}
```
Output:
```json
{
"billing": 0.05,
"fraud": 0.02,
"security": 0.88,
"technical support": 0.05
}
```
## Ordinal score
Input:
```json
{
"state": "...",
"question": "How severe is the incident?",
"levels": [
"none",
"low",
"medium",
"high",
"critical"
]
}
```
Output:
```json
{
"distribution": [0.01, 0.04, 0.20, 0.50, 0.25],
"expected_score": 3.94
}
```
Internally, all three should preferably reduce to the same primitive:
```text
score(state, question, candidate) -> scalar logit
```
---
# 6. Candidate scoring architecture
Preferred target:
```python
logit = model.score(
state=state,
question=question,
candidate=candidate
)
```
The candidate can be arbitrary natural language.
Do not bind a candidate to a vocabulary token.
A possible implementation:
```text
Transformer final hidden state
|
candidate/question representation
|
projection / interaction
|
scalar
```
Possible scalar head:
```python
Linear(hidden_size, 1)
```
applied to a special `<decision>` position.
A more advanced version may use:
```text
state representation
|
cross attention from candidate/question tokens
|
pooling
|
MLP
|
scalar
```
Keep the first implementation simple.
---
# 7. Training data
The model must learn the meta-task:
> Given arbitrary context, arbitrary natural-language decision criteria, and arbitrary natural-language candidates, assign useful probabilities.
This is substantially different from training a classifier on a fixed taxonomy.
Create a heterogeneous synthetic and real dataset.
Important categories:
- sentiment;
- topic classification;
- NLI;
- entailment;
- routing;
- moderation-like policy classification;
- intent classification;
- relevance judgement;
- document matching;
- fraud/risk-style decisions;
- medical-style abstract reasoning datasets, excluding unsafe deployment claims;
- legal issue classification;
- code defect categorisation;
- support ticket routing;
- factual yes/no;
- uncertain factual questions;
- ranking/recommendation tasks;
- ordinal severity;
- forecasting datasets where outcomes are known.
Use public datasets where licensing permits.
Convert every source dataset into the universal decision schema.
---
# 8. Synthetic transformation
Convert ordinary examples such as:
```text
text: "The package arrived damaged."
label: complaint
```
into:
```text
state:
The package arrived damaged.
question:
Which type of customer message is this?
choices:
- complaint
- sales enquiry
- praise
- account cancellation
```
Then aggressively vary:
- wording of question;
- wording of choices;
- order of choices;
- number of choices;
- irrelevant distractors;
- synonymous labels;
- label descriptions instead of label names;
- long and short contexts;
- multiple questions sharing the same state.
Candidate permutation is mandatory.
Without permutation, the model may learn positional priors.
---
# 9. Probability targets
Whenever possible, train against a distribution rather than only one-hot labels.
Sources include:
- empirical frequencies;
- multiple human annotations;
- multiple teacher-model samples;
- disagreement among teacher models;
- synthetic uncertainty;
- known probabilistic forecasting datasets.
Example:
```text
candidate A: 0.52
candidate B: 0.43
candidate C: 0.05
```
Do not collapse this to:
```text
A = 1
B = 0
C = 0
```
unless only hard labels are available.
---
# 10. Training losses
Start with ordinary differentiable losses.
For Boolean decisions:
```text
binary cross entropy
+
optional Brier loss
```
For categorical choices:
```text
cross entropy
```
or, with soft targets:
```text
KL(target_distribution || predicted_distribution)
```
For ordinal scores:
```text
distributional cross entropy
+
optional ordinal / earth mover distance loss
```
Consider adding calibration-aware terms only after establishing strong baseline accuracy.
Do not begin with PPO, GRPO or another RL algorithm.
The problem is directly differentiable.
---
# 11. RLCD-like experiment
TypeSafe has not disclosed the exact RLCD algorithm.
Treat this only as an experiment.
One plausible objective is a proper scoring rule based on observed outcomes.
Candidates:
### Log score
```text
reward = log p(actual_outcome)
```
### Brier score
```text
reward = -sum((p_i - y_i)^2)
```
These incentivise honest probability estimates in expectation.
Compare:
- plain cross entropy;
- Brier-trained model;
- mixed CE+Brier;
- post-hoc temperature calibration;
- optional RL optimisation against a proper scoring-rule reward.
Only keep RL if it provides a measurable advantage.
---
# 12. Teacher distillation
A useful way to bootstrap decision intelligence is to generate a large synthetic dataset using stronger models.
For each training example:
```text
state
question
choices
```
ask one or more strong teacher models for probability estimates.
Prefer collecting:
```text
full probability distribution
```
instead of a single selected answer.
Potential strategy:
1. ask several independent teachers;
2. collect multiple samples;
3. convert agreement/disagreement into a target distribution;
4. remove examples with obviously malformed outputs;
5. use real labelled outcomes where available to correct teacher bias.
Do not assume teacher confidence is calibrated.
Treat teacher probabilities as noisy soft supervision.
---
# 13. Multi-question training
This is important.
Training examples should include:
```text
one shared state
+
many independent questions
```
Example:
```text
state = long customer conversation
question 1:
Will the customer churn?
question 2:
Should this be escalated?
question 3:
Which department should own this?
question 4:
How angry is the customer?
question 5:
Is fraud suspected?
```
The implementation should batch these branches while preventing branch-to-branch leakage.
The model should behave approximately as though each question were evaluated independently against the same state.
---
# 14. Branching attention
Once the simple KV-cache version works, test a packed branching attention implementation.
Conceptually:
```text
[STATE]
[QUESTION 1 + CANDIDATE A]
[QUESTION 1 + CANDIDATE B]
[QUESTION 1 + CANDIDATE C]
[QUESTION 2 + CANDIDATE A]
...
```
Attention rules:
- state tokens attend normally;
- each branch can attend to the state;
- each branch can attend to itself;
- branches cannot attend to other branches.
This should allow many decision branches inside one model invocation.
Initially implement with an attention mask even if inefficient.
Only write a custom kernel after profiling proves this is important.
---
# 15. Benchmark suite
Create a reproducible benchmark before serious optimisation.
The benchmark should contain at least:
### Accuracy
- binary classification;
- 4-way classification;
- 20-way classification;
- 255-way classification;
- ordinal scoring.
### Context sizes
- 128 tokens;
- 1k;
- 4k;
- 16k;
- optionally 32k.
### Number of independent questions
- 1;
- 4;
- 16;
- 64;
- 256.
### Candidates per question
- 2;
- 4;
- 10;
- 100;
- 255.
Measure:
- first-request latency;
- warm latency;
- throughput;
- GPU utilisation;
- memory use;
- state prefill time;
- branch evaluation time;
- probability quality.
---
# 16. Baselines
Compare the system against:
## Baseline 1 β ordinary generation
Prompt the same base model:
```text
Select one answer and return JSON.
```
Measure:
- latency;
- parse failures;
- accuracy.
## Baseline 2 β constrained decoding
Use grammar / JSON / token restrictions.
## Baseline 3 β token-logit classification
Use the next-token probabilities of candidate labels.
## Baseline 4 β separate full forward pass per candidate
This demonstrates the value of shared computation.
## Baseline 5 β dedicated decision scorer
The proposed architecture.
---
# 17. Calibration evaluation
Calibration is a core part of this project.
For binary tasks compute:
- accuracy;
- AUROC if relevant;
- negative log likelihood;
- Brier score;
- expected calibration error;
- maximum calibration error.
Create reliability plots.
Example bins:
```text
predicted 0.0β0.1 -> actual frequency
predicted 0.1β0.2 -> actual frequency
...
```
Test calibration separately on:
- in-distribution examples;
- unseen datasets;
- paraphrased questions;
- adversarial distractors;
- long contexts;
- low-information inputs.
A model whose accuracy is good but whose confidence is systematically wrong should not be considered successful.
---
# 18. Calibration methods
Evaluate:
- raw logits;
- global temperature scaling;
- per-task-family temperature scaling;
- isotonic regression for evaluation purposes;
- Platt scaling;
- training with Brier loss;
- entropy regularisation;
- label smoothing.
Prefer methods that generalise across unknown tasks.
Avoid solutions that require task-specific calibration at deployment, because the intended product is zero-shot arbitrary decision-making.
---
# 19. Hardware deployment strategy
Recommended split:
## Spark A
Main training / serving experiment.
Keep the 3Bβ8B model entirely local where possible.
## Spark B
Teacher inference / synthetic-data generation.
## Spark C
Evaluation, alternate checkpoint training, or parallel data generation.
For distributed training, test:
- DDP;
- FSDP where necessary;
- DeepSpeed if useful.
Do not introduce distributed training merely because three machines exist.
A model that fits on one Spark should first be proven on one Spark.
---
# 20. Precision
Test:
Training:
- BF16;
- LoRA;
- QLoRA if necessary.
Inference:
- BF16 baseline;
- FP8 if supported and accurate;
- INT8;
- 4-bit weight-only quantisation.
Measure calibration before and after quantisation.
A quantised classifier may preserve top-1 accuracy while damaging probability calibration.
That distinction matters.
---
# 21. Suggested development stages
## Stage 0 β Environment
Verify:
- CUDA;
- PyTorch;
- NCCL;
- inter-node communication;
- FlashAttention / compatible attention implementation;
- Transformers;
- vLLM or alternative only where useful.
Record exact versions.
## Stage 1 β No-training proof of concept
Implement shared-prefix candidate scoring.
Goal:
- one context;
- many independent questions;
- no generated text.
Deliver metrics.
## Stage 2 β Scalar decision head
Add a learned scalar readout.
Fine-tune a small model on public classification datasets.
Goal:
- outperform token-logit baseline.
## Stage 3 β Universal decision training
Create heterogeneous transformed dataset.
Goal:
- zero-shot generalisation to unseen task types.
## Stage 4 β Soft-target distillation
Generate probabilistic teacher targets.
Goal:
- stronger judgement and uncertainty quality.
## Stage 5 β Calibration
Run held-out calibration experiments.
Goal:
- substantially lower Brier/ECE than ordinary LLM confidence prompting.
## Stage 6 β Multi-question optimisation
Implement branch batching / branch masks.
Goal:
- sublinear latency growth with question count.
## Stage 7 β 3B model
Train the most promising design at ~3B.
Goal:
- practical single-Spark inference.
## Stage 8 β 7B/8B model
Only proceed if 3B scaling results suggest it is worthwhile.
## Stage 9 β Kernel optimisation
Profile first.
Only build custom CUDA/CuTe kernels for verified bottlenecks.
---
# 22. Initial target metrics
These are engineering targets, not claims about TypeSafe.
For a ~3B model on one Spark, aim initially for:
```text
short context + 1 decision:
<150 ms warm
short context + 16 questions:
<250 ms
short context + 100 questions:
<500 ms
```
These targets may need adjustment after profiling.
More important than absolute latency is the scaling curve:
```text
latency(100 questions)
```
should be dramatically less than:
```text
100 * latency(1 question)
```
---
# 23. Repository structure
Suggested layout:
```text
decision-model/
βββ README.md
βββ pyproject.toml
βββ configs/
βββ data/
β βββ adapters/
β βββ synthetic/
β βββ benchmarks/
βββ src/
β βββ model/
β β βββ scorer.py
β β βββ scalar_head.py
β β βββ branching_attention.py
β β βββ calibration.py
β βββ inference/
β β βββ shared_prefix.py
β β βββ batching.py
β β βββ server.py
β βββ training/
β β βββ datasets.py
β β βββ losses.py
β β βββ trainer.py
β β βββ distillation.py
β βββ eval/
β βββ accuracy.py
β βββ calibration.py
β βββ latency.py
β βββ scaling.py
βββ scripts/
βββ tests/
βββ results/
```
Every experiment must save:
- config;
- git commit;
- model;
- dataset version;
- hardware;
- software versions;
- metrics;
- raw benchmark results.
---
# 24. API prototype
Expose a minimal HTTP API.
Example:
```http
POST /decide
```
```json
{
"state": "The server emitted 500 errors after the deployment...",
"questions": [
{
"type": "boolean",
"question": "Should the deployment be rolled back?"
},
{
"type": "choice",
"question": "What is the most likely cause?",
"choices": [
"database migration",
"network outage",
"expired TLS certificate",
"traffic spike"
]
}
]
}
```
Return:
```json
{
"results": [
{
"probability": 0.84
},
{
"distribution": {
"database migration": 0.67,
"network outage": 0.10,
"expired TLS certificate": 0.08,
"traffic spike": 0.15
}
}
]
}
```
Questions must not influence each other.
---
# 25. Important failure modes
Watch specifically for:
### Candidate-position bias
The first or last choice gets systematically favoured.
### Label-token bias
The model scores familiar words better merely because of token frequency.
### Length bias
Longer candidate descriptions receive consistently different scores.
### Confidence collapse
Predictions cluster around 0.5.
### Overconfidence
Model assigns >0.95 far too frequently.
### Question leakage
One question affects another question in the same batch.
### Distribution-shift failure
Calibration works only on training datasets.
### Teacher imitation
The student reproduces quirks of one teacher instead of learning a robust decision representation.
### Quantisation damage
Accuracy remains stable but probabilities become badly calibrated.
---
# 26. Things not to do initially
Do not:
- pretrain a Transformer from scratch;
- build a diffusion LM;
- write custom CUDA before obtaining profiles;
- use an enormous >30B model;
- perform multi-node tensor parallelism by default;
- optimise only top-1 accuracy;
- evaluate confidence using self-reported generated numbers;
- assume raw softmax is calibrated;
- assume TypeSafe's implementation uses any specific architecture.
---
# 27. Most important experiments
If time is limited, prioritise these five.
## Experiment 1
Qwen-like 1.5B model.
Shared state KV cache.
Candidate token logits.
Measure latency scaling.
## Experiment 2
Same model with a learned scalar `<decision>` head.
Fine-tune on several classification datasets.
Compare accuracy and calibration.
## Experiment 3
Train using candidate descriptions instead of fixed labels.
Evaluate zero-shot on unseen label sets.
## Experiment 4
Train on soft probability distributions and Brier/log-loss objectives.
Compare calibration against ordinary instruction-prompt confidence.
## Experiment 5
Run 1, 4, 16, 64 and 256 questions over one context and measure whether computation amortises as expected.
Those experiments will determine whether the project is worth scaling.
---
# 28. Main architectural decision gate
After the first experiments, explicitly decide between:
```text
A. Shared KV decoder branch architecture
```
and
```text
B. Shared state encoder + shallow cross-attention decision decoder
```
Choose based on measured:
- latency;
- accuracy;
- training stability;
- implementation complexity;
- multi-question scaling.
Do not choose based on similarity to TypeSafe marketing.
---
# 29. Definition of success
A convincing prototype should demonstrate all of:
1. Dynamic natural-language choices with no fixed label vocabulary.
2. Direct probability output without autoregressive answer generation.
3. Shared context computation across many questions.
4. Better latency scaling than independent LLM calls.
5. Calibration materially better than generated βconfidence scores.β
6. Useful zero-shot performance on task families absent from training.
7. Inference of a 3B-class model entirely on one DGX Spark.
8. Reproducible benchmarks and ablations showing which architectural components matter.
The ideal result is not necessarily a model matching Jev.
A successful result would establish that:
> a pretrained small language model can be transformed into a specialised probabilistic decision engine whose inference characteristics are qualitatively different from those of a normal generative LLM.
---
# 30. First action
Begin with the smallest falsifiable implementation.
Use a ~1.5B pretrained model.
Implement:
```text
state prefill once
+
batched independent question/candidate branches
+
direct candidate logits
```
Create a benchmark with:
```text
1 state
1 / 4 / 16 / 64 questions
2 / 4 / 16 / 255 candidates
```
Record:
```text
prefill latency
branch latency
total latency
peak memory
accuracy
Brier score
ECE
```
Only after those results exist should the model architecture or training pipeline become more complicated.
|