Case study · ML research at DNU Labs

Teaching Tiny Transformers Arithmetic

Does the way you write the training data decide whether a language model can do arithmetic? I trained small character-level transformers on the same problems written three different ways and measured what changed.

100%accuracy with Chain-of-Thought, up from 1%
5.60MAE with reversed digits, down from 24.24
20Karithmetic problems generated
0.79Mparameters, small on purpose
01Question

Autoregressive models write one character at a time, left to right. If a tiny model gets arithmetic wrong, is the problem the model's size, or the way the problem is presented to it? Keeping the model fixed and changing only the data format isolates that question.

02Approach

Baseline

Problem, then the answer, written normally. 123+456=579

Chain-of-Thought

The model writes out intermediate reasoning steps before giving the final answer.

Reverse-Output

Same problem, but the answer's digits are written in reverse order. 123+456=975

Everything else held fixed

Same architecture and parameter count, so any difference comes from the format.

Generate20,000 problemsProgrammatic data pipeline
Encode3 formatsBaseline · CoT · Reverse
TrainnanoGPTCharacter-level, 0.79M params
EvaluateHarness100 unseen problems, answers read back
AnalyseFailure logError distribution per format
03Findings

Format beat size

Same model, same problems. Only the way the data was written changed.

Exact-answer accuracy

Writing out intermediate steps made the difference.

Baseline1%
Chain-of-Thought100%

100 unseen problems per model.

Mean absolute error

Lower is better. Reversing the answer's digits alone cut error by 77%.

Baseline24.24
Reversed5.60

Bars scaled to the baseline error.

Intermediate computation space outweighs raw parameter count

The model didn't get bigger, it got room to think. Giving it space for intermediate steps took accuracy from 1% to 100%.

Order matters too

Just reversing the order of the answer's digits, with no extra reasoning steps, still cut error by more than three-quarters.