Everdust StoriesMinds · 6 chapters

Anatomy of a Thought: follow one prompt through a small language model to its answer, Rome

What happens inside a language model between a prompt and its answer? This Story follows one short prompt through a small model, with 1.7 billion parameters, the numbers it learned in training, and shows you each step as a live scene you can stand inside while River, the narrator, explains it. The prompt is a simple pattern, "The Eiffel Tower is in Paris. The Colosseum is in", and the model's answer is Rome.

You watch the words get cut into pieces and turned into lists of numbers, flow down 28 layers where each word gathers information from the words before it, and settle on an answer. A research tool called the logit lens lets you read the model's guess at every layer, and it shows something surprising: partway up, the model leans toward the wrong country before it changes its mind. The numbers you see are measured from the model itself.

At a glance

Chapters
6, each a live simulation
Length
about 6 minutes played straight through
Narrator
River, with subtitles
Free or Plus
Free: chapters I–II. Everdust Plus: chapters III–VI
Where
Everdust on iPhone and iPad, Android, Apple Vision Pro, Mac, Apple TV and Meta Quest 3 and 3S
  1. IWords become numbers
  2. IIDown the layers
  3. IIIThe logit lens
  4. IVThe choice
  5. VThe loop
  6. VIThe whole machine

Chapter by chapter

Inside a map of meaning: the prompt's words split into numbered pieces, with a ring of 2,048 numbers above

Chapter I Words become numbers Free

A tokenizer turns the prompt into numbered pieces, each a list of 2,048 numbers.

A language model never sees letters. It only sees numbers. So first your words are cut into small pieces called tokens; the word Colosseum becomes four of them. Each piece flies to its place on a map of meaning, where similar words land close together, and the ring above you shows one piece the way the model really receives it: a list of 2,048 numbers.

The pieces come from a method called byte-pair encoding, which starts from single characters and keeps merging the pairs that turn up most often in a huge body of text, so that common words stay whole and rare ones split into parts [1]. Each token is then swapped for a learned list of numbers called an embedding. Training arranges these lists so that words used in similar ways get similar lists, which is why related words sit near each other [2]. The map is a three-dimensional picture of that arrangement; the real lists have 2,048 dimensions.

A river of 16 token streams flowing down 28 layers, with arcs of attention, glowing orbs and a disc of neurons

Chapter II Down the layers Free

Sixteen token streams flow down 28 layers of attention and neurons.

You are standing inside a thought. Sixteen streams, one for each token, flow down 28 layers. At each layer the arcs show attention: each word looking back at earlier words and copying in what it needs. The orbs are the layer's attention heads, each looking for something different, and the disc is a block of 6,144 neurons that reworks one word at a time. Each layer adds notes to the stream, and nothing is erased. By the last layer, the stream carries the answer.

This is the transformer, a design introduced in 2017 and built from attention blocks and neuron blocks in turn [3]. Researchers picture each word's stream as a shared channel, the residual stream, that every layer reads from and adds to [4]. Some attention heads have jobs you can name. An induction head spots a pattern seen earlier, A followed by B, and when A appears again it predicts B; such heads may explain much of a model's knack for picking up patterns from its prompt [5]. The neuron blocks act a little like memories, matching patterns in the text and pushing the prediction toward words likely to come next [6].

A cloud of guesses on the map of meaning beside a ladder of 29 rungs, one for each layer

Chapter III The logit lens Plus

Layer by layer the model's guess moves from Germany to Rome.

What if you could ask the model for its answer early? Each rung of the ladder is a layer, and the cloud is the model's guess so far. At first the guess is only noise. Around layer ten it starts guessing a city. By layer nineteen it leans to Germany, which is wrong. Two layers later it changes its mind: Rome. The right answer arrives late, and suddenly. After the last layer it is Rome, at 97 percent.

The trick is called the logit lens. A model's last step turns its stream into a score for every token it knows; the lens applies that same last step after every layer, to see what the model would say if it stopped there. It was first shared in 2020 by a researcher writing as nostalgebraist, and later work found it useful but often brittle and built a trained version, the tuned lens, to read the layers more reliably [7]. In this model the lens shows Germany leading at layer 19 with 69 percent before Rome takes over at layer 21 with 85.5 percent: the Story's own measurements of this model on this prompt.

What is the logit lens? Reading a language model's guesses →

Every one of the model's 151,643 tokens as a star on the map of meaning, bright by its chance of coming next

Chapter IV The choice Plus

The model scores all 151,643 tokens, and Rome gets 97.4 %.

Every star is a word the model could say next, one for each of the 151,643 tokens it knows, and the brighter the star, the more likely the word. As the temperature falls, the sky collapses onto a single word. Rome: 97 percent. The model is almost certain. The final pick is a roll of weighted dice.

After its last layer the model gives every token a score, and a function called softmax turns the scores into probabilities that add up to one. The choice of word happens outside the model. The program running it can always take the top word, known as greedy decoding, or draw at random by each word's odds, sharpened or flattened by a setting called temperature. How it chooses matters a great deal: always taking the likeliest word tends to produce bland, strangely repetitive text, while sampling from the most likely words reads more like a person [8].

The sentence wrapped around you, a pulse re-reading it and a column of gold rungs where each new word settles

Chapter V The loop Plus

Writing is a loop: add the chosen token and run the whole machine again.

How does a model write a whole sentence? One word at a time. It picks a word, adds it to the text, then runs the entire machine again, and each pulse re-reads everything written so far. Here it carries on by itself after Rome, writing "The Great Wall of China is in Beijing." Gold rungs mark the layer where each new word settles. Easy pattern words settle early. Recalled facts settle late.

This loop is called autoregressive generation: each new token is predicted from the ones before it, then fed back in, the way transformers were designed to write [3]. Measured in this model, a word the pattern makes obvious, China after "The Great Wall of", settles by layer 12, while a recalled fact, Beijing, isn't settled until layer 26. Research on how models recall facts finds that it takes several steps: early layers gather what the model knows about the subject, and only then is the fact itself pulled out for the answer [9].

A wall of the model's neurons lit by how strongly they fire, a helix of attention heads and a comet crossing to Rome

Chapter VI The whole machine Plus

28 layers, 448 heads and 1.7 billion parameters, all used for every token.

Here is the whole machine at once: 28 layers, 448 attention heads and a wall of 172,032 neurons, every one of them used for a single word. A comet follows the guess as it climbs the layers and arrives at Rome. Most of it we cannot read yet. A few neurons we can, like one in layer 24 that pushes toward the word Empire.

The model's 1.7 billion parameters all take part in producing every token. Single neurons can sometimes be read because the neuron blocks write their updates in terms of the words the model knows: researchers have shown those updates can be broken into parts that each promote a concept a person can often recognize [10][11]. The neuron in layer 24 that pushes toward Empire, and so helps toward Rome, is one such readable part, found in the Story's own measurements. Most of the machine still can't be put into words.

What’s simulated, and what isn’t

The numbers in the Story are measured from a real language model running this prompt: the token pieces, the attention arcs, the guess at each layer, the final probabilities, the layer where each new word settles and the neuron that pushes toward Empire. What is drawn for you is the space they live in. The map of meaning is a three-dimensional picture of lists that really have 2,048 numbers each, the cloud is a way to show a probability, and the arcs, orbs, rungs and colors are a visual code. The logit lens is a real research tool with real limits: it reads early layers poorly, so noise there means the lens can't read them, not that nothing is happening.

Watch Anatomy of a Thought in Everdust

Anatomy of a Thought is in the Everdust app on iPhone and iPad, Android, Apple Vision Pro, Mac, Apple TV and Meta Quest 3 and 3S. Open Everdust, choose Stories, then Anatomy of a Thought. Free: chapters I–II. Everdust Plus: chapters III–VI.

Everdust on the App Store (iPhone, iPad, Apple Vision Pro, Mac, Apple TV)Everdust on Google Play (Android)Everdust on the Meta Horizon Store (Quest 3 and 3S)

Everdust is free to download, with no ads and no account. Everdust Plus, an optional subscription, opens every chapter of every Story on iPhone, iPad, Android, Apple Vision Pro, Mac and Apple TV (on Meta Quest, which chapters are free can differ).

Questions people ask

What is a token in a language model? A small piece of text, a whole word or part of one, that the model reads as a single unit. Methods such as byte-pair encoding learn which pieces to use from large amounts of text [1]; in this Story the word Colosseum becomes four tokens.

How does a language model choose the next word? It scores every token it knows and turns the scores into probabilities; the program running it then takes the top one or samples at random by those odds, shaped by a temperature setting [8].

What is an attention head? One of many small units inside each layer of a transformer that decide which earlier words each word should draw information from. A model runs many side by side, and each learns its own habit [3][5].

What is the logit lens? A way to read a model's guess partway through, by applying its final step to the state after each layer [7]. Our logit lens page explains it.

Sources

  1. Sennrich, R., Haddow, B. & Birch, A. (2016). Neural machine translation of rare words with subword units. Proceedings of the 54th Annual Meeting of the Association for Computational Linguistics, 1715.
  2. Mikolov, T., Chen, K., Corrado, G. & Dean, J. (2013). Efficient estimation of word representations in vector space. arXiv:1301.3781.
  3. Vaswani, A. et al. (2017). Attention is all you need. Advances in Neural Information Processing Systems 30.
  4. Elhage, N. et al. (2021). A mathematical framework for transformer circuits. Transformer Circuits Thread.
  5. Olsson, C. et al. (2022). In-context learning and induction heads. arXiv:2209.11895.
  6. Geva, M., Schuster, R., Berant, J. & Levy, O. (2021). Transformer feed-forward layers are key-value memories. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, 5484.
  7. Belrose, N. et al. (2023). Eliciting latent predictions from transformers with the tuned lens. arXiv:2303.08112.
  8. Holtzman, A., Buys, J., Du, L., Forbes, M. & Choi, Y. (2020). The curious case of neural text degeneration. International Conference on Learning Representations; arXiv:1904.09751.
  9. Geva, M., Bastings, J., Filippova, K. & Globerson, A. (2023). Dissecting recall of factual associations in auto-regressive language models. Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, 12216.
  10. Geva, M., Caciularu, A., Wang, K. R. & Goldberg, Y. (2022). Transformer feed-forward layers build predictions by promoting concepts in the vocabulary space. Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, 30.
  11. Dar, G., Geva, M., Gupta, A. & Berant, J. (2023). Analyzing transformers in embedding space. Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics, 16124.

Chapter stills: Everdust, from each chapter’s live simulation. The Story’s script was written for Everdust from the sources above; River reads it. This page retells it in its own words.

Read and play next