Menu

I trained a GPT on my laptop CPU in two minutes, with nothing but NumPy
πŸ“°

I trained a GPT on my laptop CPU in two minutes, with nothing but NumPy

DEV Community: beginnersΒ·AlwyAbdullahΒ·about 8 hours ago
#5Q1gDENZ
#devtobeginners#devto#dev#model#every
Long article (920 words) β€” no AI summary yet.
Reading 0:00
15s threshold

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").…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.