OshonSoft AI Language Model Lab
Finding the Smallest Language Model That Can Learn Three-Digit Addition
PRODUCT HOMEPAGE - GUIDED EXAMPLES AND SCREENSHOTS - USER MANUAL
Three-digit addition capacity study
Experiments with random training examples, small MLPs and Transformers.
Give the model two numbers from 000 to 999. The reply shows the ones, tens and hundreds calculations, including each carry, then writes the sum with four digits.
With 7,000 random training examples, a 24,870-parameter MLP after seven epochs and a 7,144-parameter Transformer after fourteen both gave 3,472/3,472 exact replies on the shared Final evaluation. These were the smallest successful configurations within the study's fourteen-epoch reporting budget.
BRACKET LOGIC - THREE-DIGIT ADDITION - TRANSLATION PATTERNS
On this page
1. Try the trained models
2. Read the carry trace
3. Compare saved replies during training
4. See what changed with more examples and smaller models
5. Repeat the training
1. Try the trained models
The download contains four projects, their initial and trained models, and complete saved replies. The primary MLP and Transformer both reproduced 3,472/3,472 exact Final evaluation replies with the current Lab training and generation code. The second-seed results are included as well.
DOWNLOAD PROJECTS AND MODELS - DOWNLOAD THE LAB
The trained model is supplied as models/selected.osai in its project. Load it through Persistence, using Choose load file and Load checkpoint. In Conversation, choose Greedy, set the reply limit shown below and clear the conversation before each independent question.
The mlp and transformer folders hold the primary recipes. Use a reply limit of 128 and ask, for example, Add 325 and 386.
Click either screenshot to open it at full size.


WATCH THE TRANSFORMER GENERATE THE REPLY (MP4)
Add 325 and 386. 5 + 6 + ↑0 -> 1 ↑1 2 + 8 + ↑1 -> 1 ↑1 3 + 3 + ↑1 -> 7 ↑0 result: 0711 [EOT]
Add 468 and 945. 8 + 5 + ↑0 -> 3 ↑1 6 + 4 + ↑1 -> 1 ↑1 4 + 9 + ↑1 -> 4 ↑1 result: 1413 [EOT]
2. Read the carry trace
Each line adds the two digits for that column and the incoming carry. The digit after the arrow stays in that column. The carry goes into the next column. For 325 + 386, the ones column adds 5 + 6 + 0 to give digit 1 and carry 1. The tens column uses that carry. The four-digit result is 0711.
The numeric tokenizer keeps digits, carry markers and line breaks. An exact reply has all three correct lines, the four-digit sum and the end-of-turn token. Gold answers are the reference for scoring. Each saved model reply was generated from the prompt with its own preceding tokens.
The training examples and the questions were split by operand pair, including the reversed order. TRAIN teaches the task. Training checks show progress during training. The shared random Final evaluation is scored at the planned endpoint.
A right sum can still have a wrong trace. In this saved 105,584-parameter MLP reply, the tens column ends with a bare 6 where the reference has an outgoing carry ↑1. The final sum 0332 is correct.
Add 266 and 066. 6 + 6 + ↑0 -> 2 ↑1 6 + 6 + ↑1 -> 3 6 2 + 0 + ↑1 -> 3 ↑0 result: 0332 [EOT]
3. Compare saved replies during training
Choose a run, a Training checks question and a saved epoch. The two panels show the generated reply and the reference. Use the token view to see <lf>, digit joins and <eot>.
Saved model reply
Reference answer
4. See what changed with more examples and smaller models
How much practice? The three random training sets below use the same 105,584-parameter MLP and the same Training checks and Final evaluation questions. Seven epochs on more examples also mean more SGD updates. All three training sets contain the 500 local digit and incoming carry facts. The rarest fact occurs 1, 8 and 18 times in the three sets, respectively.
| TRAIN examples | SGD updates | TRAIN exact | Training checks exact | Shared Final evaluation exact |
|---|---|---|---|---|
| 1,000 | 280,000 | 941/1,000 | 804/1,168 | 2,337/3,472 |
| 3,740 | 1,047,200 | 3,740/3,740 | 1,168/1,168 | 3,470/3,472 |
| 7,000 | 1,960,000 | 7,000/7,000 | 1,168/1,168 | 3,472/3,472 |
How small? These runs used the same 7,000 TRAIN examples, numeric vocabulary and 80-token context. A successful endpoint had exact replies on all TRAIN examples and on both of its last two Training checks and known-question checkpoints. The shared Final evaluation is reported separately.
| Model | Parameters | Epochs | First perfect Training checks epoch | Shared Final evaluation exact |
|---|---|---|---|---|
| MLP | 24,870 | 7 | 4 | 3,472/3,472 |
| MLP | 50,090 | 7 | 3 | 3,471/3,472 |
| MLP | 105,584 | 7 | 3 | 3,472/3,472 |
| Transformer | 7,144 | 14 | 10 | 3,472/3,472 |
| Transformer | 13,072 | 14 | 10 | 3,472/3,472 |
| Transformer | 23,664 | 7 | 3 | 3,472/3,472 |
| Transformer | 49,592 | 7 | 4 | 3,472/3,472 |
At roughly 25,000 parameters, the D4/H70 MLP reached 3,472/3,472 on the shared Final evaluation. D16/H19 reached 650/3,472 with the same seven-epoch budget. The best of the five approximately 10,000-parameter MLPs within fourteen epochs reached 750/3,472. The 13,072-parameter Transformer had 3/3,472 after seven epochs and 3,472/3,472 after fourteen.
How well did it repeat? The second seed used the same dimensions and learning rate, with its own initial weights and shuffled training order. The small Transformer gave very different outcomes in the two runs.
| Model | Seed | Epochs | TRAIN exact | Training checks exact | Shared Final evaluation exact |
|---|---|---|---|---|---|
| MLP 24,870 | 12345 | 7 | 7,000/7,000 | 1,168/1,168 | 3,472/3,472 |
| MLP 24,870 | 23456 | 14 | 7,000/7,000 | 1,167/1,168 | 3,465/3,472 |
| Transformer 7,144 | 12345 | 14 | 7,000/7,000 | 1,168/1,168 | 3,472/3,472 |
| Transformer 7,144 | 23456 | 14 | 16/7,000 | 4/1,168 | 10/3,472 |
The separate MLP final set, supplied as test_capacity.txt, gave 3,472/3,472 for the primary model and 3,465/3,472 for its confirmation. The table above uses test_random.txt; the two final sets are scored separately.
5. Repeat the training
On an AMD Ryzen 7 7735HS laptop, the repeated primary MLP run took about 1 h 10 min and the primary Transformer run 2 h 9 min. These times include training and all configured checks while several projects shared the CPU. Time spent paused is excluded. Other hardware and workloads will give different timings.
Extract the projects into Documents/OshonSoft AI Language Model Lab. Choose three_digit_addition/mlp or three_digit_addition/transformer. Each already contains its training file and questions. The mlp_confirmation and transformer_confirmation folders use seed 23456.
| Setting | MLP | Transformer |
|---|---|---|
| Dimensions | V32 / C80 / D4 / H70 | V32 / C80 / D14 / F56; 2 heads, 2 blocks |
| Parameters | 24,870 | 7,144 |
| Initialization | Wider embeddings, +/-1.0 | Standard Transformer |
| Primary seed / SGD | 12345 / 0.01 | 12345 / 0.003 |
| Epoch target | 7; confirmation 14 | 14; confirmation 14 |
| Checks / reply limit | Every epoch / 128 | Every epoch / 128 |
Use the numeric tokenizer with Preserve line breaks, Global epochs and MODEL body/EOT targets. Standalone carry signs ↑0 and ↑1 each form one token. Each complete reply has 40 targets including EOT. With 7,000 training conversations, one epoch contains 280,000 updates: 1,960,000 for seven epochs or 3,920,000 for fourteen. Model dimensions and parameter counts stay the same. Train fresh models with this token sequence; checkpoints trained with split carry signs cannot be reused.
- Open the installed OshonSoft AI Language Model Lab. On Project, click Choose project... and select the folder containing
experiment.json. The saved settings fill the controls; this does not start training. - Review the dimensions, tokenizer, initialization, learning rate and target. Click Prepare and initialize model. Use the prepared target count to read the update budget.
- Start a fresh run. The Lab saves checkpoints and full Prompt/Gold/Raw replies under
runs/run-000001/. Use Open run folder or Read replies... to inspect them. - Use Pause + save before closing. Later choose the saved
run.json, click Open / recover run, then Resume. Resume keeps the original target.
Use questions/ for Training checks. Select the checkpoint under the study's stated rule, then use Use checkpoint... and Final evaluation for questions/final/. Reusing these already evaluated question sets is a reproduction check; it is not a new unseen test.
For the original capacity comparison, a qualifying endpoint had exact replies on every training example and on both of its last two Training checks and known-question checkpoints. The shared benchmark and fresh MLP evaluation remained separate. Retain the second-seed failures when interpreting the smallest successful run.
Each project supplies models/initial.osai and models/selected.osai. Complete replies are grouped by update in answers/, including the full training check at the endpoint; answers/final/ keeps each final set in its own file. A fresh run creates its own runs/ folder.
