It remembers now.
One nudge = one flashcard from the text: two words in a row, and the word that really comes after them. The model builds its question in the room, bets on what comes next, checks the text, and moves all its numbers a tiny bit so the right word would get a bigger bet next time. Step size is how big that tiny bit is. New start throws every number back to random (a new start number). Card size is how many numbers each word's cards hold: 2 draws a flat map, 3 a 3D one. Changing it starts training over, because the model itself changes size.
Keys: Space plays or pauses, N does one nudge.
Measured after each read of the text: 0 would mean it bet 100% on every right answer. It can never get there, because some words are followed by several different words, so even a perfect model has to split its bet. The red line is the best any model that remembers two words could ever do on this text (the leftover surprise in the text itself). The grey line is the old limit, the best with one word of memory: Word Nursery can never go below it. Watch the curve dive under the grey line: that's the room at work.
Reads 0 Β· Nudges 0 Β· Start #7 Β· β
A dot β is a final question: the question a word asks after the room, once it has heard the word before it. So there's one dot per pair of words in the text, like βthree potatoβ, and the same word can have several dots. A diamond β is a word's answer card, used as a contestant, βpick me as the next word!β.
Click a dot to focus on that word: its starter, the hollow ring (the first draft of its question, straight from the phone book), an arrow from it to each of its final questions (the arrow is what the room added: what it heard), and the answer cards of the words that really come next. Click it again, or on empty space, to go back. The ruler is squashed: every card points the right way, but distances from the centre are squeezed, like a poster of the solar system. The room makes final questions very long, and on a straight ruler every answer card would shrink to a dot. Further out still means longer (more confident). In 2D, the dashed rings show real lengths. Scroll to zoom; drag to move (in 3D, drag to turn it). The colours are just for you: one per word, never per group, so they can't give the answer away.
β shows or hides a word's question card, β its answer card. Click a name to focus on that word, and click it again to go back.
First, the red bars: in the room, how much the word listened to the word before it and to itself. Then the bets. The model never picks just one word. It spreads 100% of its bet across every word it knows. Pick two words in a row to see how it bets on what comes next: the striped bars show how often each word really comes next after that pair in the text, the solid bars are the model's bet.
π in the room, it listens toβ¦
π° β¦and bets that the next word is
Press One nudge to see a single training step here.
| word | π± starter | β answer card |
|---|
Chosen by whoever builds it, before training starts. Nothing
here is learned: the numbers above are learned
inside this shape. Change the shape and the baby has to
go back to school. Grown-ups keep this in a tiny file next to
the numbers, usually called config.json.
This is the whole model: the flashcards, the cards of numbers, the room, the betting, the checking and the learning. Most of it is comments.
The page reads this code straight out of itself, so it's exactly the code that runs the Play tab. Everything else on the page only draws pictures of what this code is doing.
Same baby robot as in Word Nursery, same game:
I show you some words, you guess the next one. The new part
is a room. Before it guesses, the word walks into the room, where it can
listen to the word right before it. Here's one guess, step by step:
three potato β ?
Words with a faint dotted underline have a grown-up name: hover over one (or tap it) to see it. The π switch at the top of the page swaps them all for their grown-up names.
Every word that has a next word makes one
flashcard,
and now the
flashcard
remembers the word before it too.
one potato two potato three potato four gives
one potato β two, potato two β potato,
two potato β three, and so on, all the way to
three potato β four. The first word of a line has
nobody before it, so it only has itself.
A starter π±: the word's own numbers, the first draft of its question. And an answer card β: βpick me as the next word!β. Three numbers each, all random at first. The robot knows nothing yet.
potato's starter gets copied out of the phone book, and the copy
walks into the room together with the word before it,
three. The starter in the phone book isn't touched:
the room only ever works on copies.
The room has three recipes. Each is a little 3 Γ 3 grid of numbers, shared by every word, that turns a starter into a new card:
potato makes a looking-for card. Both three and potato make a name tag and a hand-out.
potato scores its looking-for card against each name tag (three's and its own) with a multiply-and-add. Softmax turns the two scores into listening bars that add up to 100%, say βthree 97%, itself 3%β. You can see them on the betting slip.
It mixes the hand-outs by how much it listened: 97% of three's hand-out plus 3% of its own. A card of numbers can't carry a note saying βthree was hereβ, so it carries some of three's numbers instead.
final question = starter + what it heard (the plus is a shortcut: the starter goes round the room and gets added back on). This is what the whole room is for. potato's starter is the same every time, but its final question is different after one, after three and after five. The dots on the map are final questions: one per pair of words.
The final question multiplies-and-adds with every answer card, and softmax turns the scores into bets: βfour 99%β. That part hasn't changed at all.
How wrong
= βlog(bet on the right word), and the
push
= what it should have bet β what it did bet, same as before. Then
the push travels backwards through the room (passing the blame back): the answer cards, all three recipes, potato's starter and
three's starter each learn which way to move, and take a small
step. The final question is thrown away. Next time
three potato comes up, it gets built fresh from the
nudged parts.
Now and then a nudge comes out huge, and the recipes and starters feed on each other until the numbers blow up. So no nudge may be longer than 2: a longer one gets shrunk to fit (the safety net). Real training does the same.
| baby word | grown-up word | what it says | how many | |
|---|---|---|---|---|
| Stored: learned in training, kept in the model | ||||
| π± | starter | input embedding | βhere's my raw stuffβ | one per word |
| β | answer card | output embedding | βpick me as the next word!β | one per word |
| ππ | looking-for recipe | WQ (query weights) | how to make a looking-for card | one per room |
| ππ·οΈ | name-tag recipe | WK (key weights) | how to make a name tag | one per room |
| ππ£οΈ | hand-out recipe | WV (value weights) | how to make a hand-out | one per room |
| Made fresh for every guess, then thrown away | ||||
| π | looking-for card | query | βwho should I listen to?β | one per guess |
| π·οΈ | name tag | key | βhere's how to spot meβ | one per word in the room |
| π£οΈ | hand-out | value | βthree was hereβ | one per word in the room |
| π | listening bars | attention weights | βthree 97%, itself 3%β | one per word in the room |
| β | final question | hidden state | βwhat comes next, now that I've heard the word before me?β | one per guess |
| π° | bets | probabilities (softmax of the logits) | βfour 99%β | one per word |
| Chosen before training: the shape (not learned, but still part of the model) | ||||
| π | dictionary | vocabulary | which ticket number is which word | 9 words (One Potato) |
| π | numbers per card | embedding dimension | how big every card is | 3 |
| πΊ | seats | context window | how far back a word can listen | 2 |
| πͺ | rooms | layers | how many rounds of listening | 1 |
| π | listeners per room | attention heads | how many listeners share a room, each with its own three recipes | 1 |
For One Potato in 3D, that's 9 words Γ 6 numbers + 3 recipes Γ 9 numbers = 81 numbers. That's everything it knows. Word Nursery had 54. The room costs 27 numbers. The shape is what it is: seats and rooms aren't numbers the baby learns, but change them and you get a different baby.
| Word Nursery | The Room | |
|---|---|---|
| memory | one word | two words: the word before, and itself |
| the question | looked up in the phone book | built in the room: starter + what it heard |
| dots on the map | one per word | one per pair of words |
| numbers, One Potato 3D | 54 | 81 |
| numbers, Jack Built 3D | 264 | 291 |
| best possible, Jack Built | 0.92 | 0.08 |
| what one nudge moves | one question card and the answer cards | two starters, the answer cards and all three recipes |
The starter is a sneaky mastermind. It never answers anything itself. Every time its word turns up, it sends a copy into the room, and the copy comes out as a final question: an offspring that asks one question, gets one lesson (the push), and is thrown away. The lesson goes home to the starter, which slowly gets wiser.
Why not keep the offspring instead? Because there isn't one. βone potatoβ and βthree potatoβ build different final questions, and a saved one would be wrong the next time potato turns up next to a different number. Only the parts are the same every time, so the parts are what learn.
And the starter can't learn everything by itself. Its offspring send home βbe more like two!β, βbe more like four!β, βbe more like six!β, and those cancel out. So the starter keeps only what they all agree on (βa number comes after meβ), and the picky part (βafter three, say fourβ) lives with whoever knows it was a three: three's own starter and the recipes. It's not one mastermind, it's a gang.
| On this page | Grown-up name |
|---|---|
| flashcard | training example |
| starter π± | input embedding (token embedding) |
| answer card β | output embedding (unembedding) |
| numbers per card (2D / 3D) | embedding dimension |
| the room | attention layer (one head) |
| recipes | weight matrices WQ, WK, WV |
| looking-for card / name tag / hand-out | query / key / value |
| listening bars | attention weights |
| final question | hidden state (contextual embedding) |
| everything it knows | parameters (weights) |
| multiply-and-add | dot product |
| score | logit |
| betting slip | softmax probabilities |
| how wrong | loss (cross-entropy) |
| push | gradient (with the sign flipped) |
| passing the blame back | backpropagation |
| nudge | training step (stochastic gradient descent) |
| step size | learning rate |
| safety net | gradient clipping |
| one read of the text | epoch |
| best possible | entropy of the next word, given two words |
| squashed ruler | log-scaled radius |
| start number | random seed |
| what it heard | attention output |
| the plus in βstarter + what it heardβ | residual connection |