Zackaryaa Ishraq
Contact

Machine learning experiment · November 2026

Grokking in a Small Transformer

Watching a neural network suddenly understand modular arithmetic.

Grokking is when a neural network that has memorised its training data suddenly starts to generalise. I reproduced it in a single-seed run of a one-layer transformer (about 224k parameters) trained on 30% of modular addition and subtraction pairs mod 97.

Test accuracy rose from about 29% to over 99% between steps 6,000 and 7,800.

Weight decay was the deciding factor: 100% test accuracy with it against about 8% without it after 30,000 steps. I also predicted an 85% training-accuracy ceiling for order-blind subtraction, and the model hit 85.3%.

Code and write-up on GitHub Next: TechMentor National Hackathon Final