Aron Frishberg

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.

Try
Loading a 2 MB brain…
The word as 128 numbers

What you're watching

1

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.

2

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.

3

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.

4

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.