The Archive · AI · Interactive
Looking Into an LLM as It Runs
A real language model is running right here in your browser. Start a story and follow each word through every layer of the math, from tokens to the final roll of the dice.
What you're watching
Words become numbers
Text is chopped into tokens from a vocabulary of 2,048, and each one is looked up in a table to become a list of 128 numbers.
Words look at each other
In every layer, attention lets the newest word look back at earlier ones and borrow what it needs. Four heads each look for something different.
Neurons weigh in
Then 512 neurons per layer react to what was gathered and nudge the numbers. The guess on the right sharpens as it climbs.
Odds, then dice
Every word in the vocabulary gets a score, the scores become odds, and a random roll picks one. Then it all starts again.
How it was made
The model is Andrej Karpathy's nanoGPT, the same design as GPT-2, shrunk to about a million parameters (GPT-2 had 1.5 billion). It learned English from TinyStories, a set of simple children's stories, which is why it mostly writes about Lily, Tom, dogs and parks.
There's no server. The weights download to your browser and a few hundred lines of JavaScript do every multiplication by hand, keeping each number so it can be drawn. Inspired by 3Blue1Brown's explainer on transformers.