Every explanation of GPT I read either stopped at a diagram or jumped straight to PyTorch, where loss.backward() hides the most interesting part. So I built one where nothing is hidden: a complete GPT, trained from random numbers to fluent output, in plain Python and NumPy. No framework, no GPU.
It has 112,640 parameters. It trains in about two minutes on a laptop CPU. And it learns grammar rules nobody told it.
The trick: a language small enough to learn, with rules we can check
Real text is far too big to learn in two minutes. So the model learns a tiny invented language instead: eight animals and robots, four verbs, four adjectives, four places, and real grammar.
the eagle is tired. an eagle likes the owl. the children follow a dog near the river.
Enter fullscreen mode
Exit fullscreen mode
It has the two things that make language hard: agreement ("the cat is ", "the cats are ") and rules that depend on the next word (" a fox", " an owl").β¦