00 AI in Tech Ops · The weights view

Watch a model write the next word

Type a sentence. A small AI model of the same design as Millie's runs in your browser, and you watch every word go in one side, pass through the layers, and come out the other side as the next word. Then you can open any word up and see exactly what happened to it.

This is not Millie live. Nothing you type leaves your device. The two models here are about 15 and 27 million numbers each; Millie's model is about 117 billion. Same shape, much smaller. Everything on this page is marked ran for real or estimated.

01 The weights web

A word goes in, a word comes out

The whole network as one picture. Each word flows left to right through the layers. In the experts model, a small router in every layer picks two of sixteen experts for that word and the rest sit idle. The word that comes out the far end is added to the sentence and goes back in.

These models were trained on children's stories, so give them a story. The first run downloads both models (44 MB) to your browser once.

Brighter expert = picked more often in the last few words. The small bar on each layer is the router's confidence. Tap any word in the sentence to open it up.

What L1 to L6 are: the model's six layers, worked through in order. Every word goes through all six:

In each layer the word does two things. First it looks back at the words before it (attention). Then a couple of experts work on it (the plain model has one block that does it all). Whatever the layer works out gets added to the word's row of numbers, and the row moves on to the next layer.

Roughly, the early layers sort out the word itself and the grammar around it, the middle layers what the sentence means, and the last layers what should come next. Millie's model works the same way with 36 layers, L1 to L36.

Nothing running yet.

02 Under the hood

One word, all the way through

Pick a word from the sentence above and this is everything that happened to it, with the real numbers from the run.

1 · The split

Text is cut into pieces (tokens). Each piece has a number in a 32,000-entry list. The piece you picked is marked.

2 · The embedding

The piece's number is swapped for a row of 288 numbers. Drawn as a strip: each stripe is one number, blue below zero, amber above. Words used in similar ways get similar strips. Below it: the five vocabulary entries whose strips are closest to this one.

3 · Attention

In every layer the word looks back at the words before it and takes a weighted mix of them. Darker = looked at more. Six heads per layer each look for something different; the default shows their average.

4 · The router's scores

Each layer's router scores every expert for this word and the top two run. Darker = higher score; the picked ones are outlined, with their share of the mix.

5 · How the word changes

Every layer adds its result to the word's row of numbers. Left: how long the row is after each layer, and how much its direction turned. Right: the rows of every word in the sentence squashed onto two axes, with this word's path drawn in full.

6 · The next word

After the last layer, the row is compared with all 32,000 vocabulary entries and the scores become shares that add up to 100%. The one that was picked is marked.

03 Different models

Plain against experts, and bigger than this

Two real models, same sentence ran for real

The plain model runs every number it has for every word. The experts model is bigger on disk but reads less per word, because only two of its sixteen experts per layer wake up. Both run here, now, in your browser, and the times are measured on your device.

Build your own estimated

Writing one word means reading every number the word touches out of memory. So the speed limit is simple: memory speed divided by the bytes read per word. In practice you get about half of that. Set up a model and a machine and see what happens.

04 What we've learned

The lab log

Numbers from the lab, in the order they came in. Each one says how it was made. The full write-up is on the expert routing research page.

Measured: I ran it and timed it. Simulated: I replayed measured routing through a cache model. Estimated: a projection from a fitted model. Not measured.

Loading the log…

05 What's real here

What ran, what's estimated, what's borrowed

  • The two browser models

    Plain model: a 15-million-number story model (Andrej Karpathy's stories15M, MIT licence), the Llama design: 6 layers, 6 attention heads, one feed-forward block per layer. Trained by him on the TinyStories data set.

    Experts model: the same model with every feed-forward block cut into experts. I started each of 16 experts from a slice of the plain model's block (a known trick called upcycling), added a router to each layer, and trained the whole thing on the same stories on a 16-core desktop CPU. The router picks 2 of 16 experts per word, the same way Millie's model picks 4 of 128. Details and the training numbers are in the lab log above.

    Both are stored at 8 bits per number and run in a small program I wrote for this page, which is why every in-between value is available to draw. They write like a four-year-old. That's the honest size of what a browser can run with the hood open.

  • What's the same as Millie's model

    The shape: tokens, embeddings, attention, a router choosing a few experts per layer, a residual stream that each layer adds to, and a final comparison against the vocabulary. The big-model recordings, when they're present, come from the actual 117-billion-number model on the lab machine.

  • What's different

    Size, by about 4,000 to 8,000 times. Millie's model has 36 layers, 128 experts per layer, 64 attention heads, a 201,000-entry vocabulary, and was trained on far more than children's stories. It also has a few design details (grouped attention, a sliding window on half the layers, attention sinks) the small models don't.

  • Nothing leaves your device

    The models are downloaded once (about 44 MB) and run entirely in your browser. There is no endpoint behind this page; your sentences are never sent anywhere.

  • Labels

    ran for real means the number came out of an actual run: in your browser, or on the lab machine for the recordings and lab log. estimated means a calculation, like the simulator's speeds. simulated means measured routing replayed through a cache model.