Large language models · a five‑minute tour

How ChatGPT and Claude work (approximately)

Every word starts at a position in a big "meaning space". The other words in the text then pull it toward a more specific position: what this word means in this context. The next word is predicted from where it ends up.

None of this structure was designed. The model starts as random numbers and is pushed by a single, dumb objective: predict the next word. The space, the directions, the attention patterns are all what that pressure left behind.

0:00 – 1:00
Words as locations

Every word is a point in a space with thousands of axes. Nearby means similar.

1:00 – 2:00
Directions encode meaning

king − man + woman ≈ queen. The axes were never labelled by anyone; they emerged.

2:00 – 3:30
Attention

Each word asks everything before it a question and blends in the answers. "bank" moves toward "river", on its way to predicting what comes next.

3:30 – 5:00
Stack & emerge

Dozens of rounds of this. Random start, one objective, local rules, no controller: global structure. Sound familiar?

1 · Words as locations

Words as positions in a meaning space

  • A map where similar words sit close together
  • Not two directions, but thousands
  • Each direction is a question: alive? royal? wet?
  • A word's address = its list of answers
  • Nobody wrote the questions; the model found them by reading
  • The map starts as pure noise. Order is not seeded in; it emerges

Picture a map where words that mean similar things are close together. Now give the map not two directions but a few thousand.

You can't picture a thousand directions, and you don't need to. Each direction is just one question you could ask about a word: is it alive? is it royal? is it wet? A word's address is its list of answers. Click a word to see a few of them.

This dictionary location is only the starting point. Everything that follows is about how a word gets moved from here, until its location says where the next word should be. The rest is bookkeeping.

In a real model there are ~12,000 of these questions, and none of them were written by a human. The model found the useful ones by itself, just from reading.

For a complexity crowd: the map begins as pure noise. Every word starts at a random address, not copied from an earlier model or a dictionary. Training only ever nudges the numbers that would have predicted the next word better, and out of that local pressure a global geometry appears: neighbours cluster, and the "add royalty" walk from the next section becomes straight. Nothing in the objective mentions similarity or directions. They are the residue of a selection pressure, the same way a trail network forms from many individual walks.

2 · Directions encode meaning

Adding and subtracting word positions

  • manking is a walk. Take the same walk from woman and land near queen
  • "Add royalty" is a direction, and it works from anywhere
  • A learned concept = a consistent direction in the space
  • It fell out of one dumb objective: predict the next word

Walk from man to king. Now take exactly that same walk starting from woman. You arrive next to queen.

The step "add royalty" is a direction in the space, and it works from anywhere you start. This is what people mean when they say a model has "learned a concept": a consistent direction has appeared in its space.

Nobody put that direction there. It fell out of a single dumb objective: predict the next word.

3 · Quick aside: tokens

The model works on tokens, not words

  • "Word" was a simplification: the model sees pieces from a fixed list of ~100k
  • Common word → one piece. Rare word → a few fragments
  • Every letter and byte is on the list, so nothing is unrecognisable
  • Try it: a made-up word, a long one, a number

One correction before we go on: the model has never seen a word. It has a fixed list of about 100,000 pieces, and every text gets chopped into them.

Common words are one piece. Rare words become a few familiar fragments. And because the list includes every single letter and byte as a last resort, nothing is ever unrecognisable: a word you invented this morning still gets in, just as a string of smaller bits.

Type something. Try a made-up word, a long one, or a number.

The piece list is learned by repeatedly gluing together the most frequent neighbouring fragments in the training text. This box uses the real GPT-4 list (cl100k, 100,256 pieces), bundled with the page. Notice that most pieces carry their leading space (shown as ·), and that a word gets chopped differently at the start of a sentence than after a space.

This is also why models famously struggle to count the r's in "strawberry": the model never sees ten letters, it sees three opaque pieces, and has to remember how each one is spelled.

whole wordsub-word fragmentsingle character fallback
4 · Attention

How the words in a text influence each other

  • On its own, "bank" sits between water and money; everything before it, in the whole text, pulls it
  • Attention: each word asks a question and posts an advert
  • Question matches advert → strong link → blend in some meaning
  • Words only listen backwards, never at the answer ahead
  • Hover a word; switch sentences and watch bank move

A word's address on its own is ambiguous. "bank" sits halfway between water and money. The words before it have to move it, and "before" means everything in the text so far, not just this sentence. The point is not being sharpened for its own sake: it is being dragged toward what the model expects to come next.

That is what attention does. Every word broadcasts a short question ("is anyone here about water or money?") and a short advert ("I'm about water"). Where a question matches an advert, the two words are connected strongly, and the asking word blends in a bit of the answering word's meaning.

Hover a word to see who it listens to. Switch sentences and watch where bank ends up. Notice a word only ever listens backwards: the model reads left to right and must not peek at the answer it is about to predict.

The questions and adverts are the famous "queries" and "keys". The blended-in content is the "values". Weights shown are illustrative.

5 · Depth

How one word's meaning is refined across layers

  • Every word carries a whiteboard; each layer adds a note, never erases
  • Early layers: what the word is, where it sits
  • Middle layers: what it means here
  • Late layers: stop describing, start predicting
  • Bars = reading the prediction off the board early

Each word carries a whiteboard. Every layer reads it, adds a note, and never erases. The board starts as the dictionary meaning and ends as a guess about the next word.

Drag through the layers for bank in "we sat on the bank". Early layers write down what the word is and where it sits. Middle layers add what it means here: a river bank, a place to sit, part of a story told in the past tense. Late layers stop describing and start predicting.

The right-hand bars are the "logit lens": what you get if you read the next-word prediction off the whiteboard early. It is confused in the middle and snaps into focus in the last third. Notes are illustrative; the pattern is real.

6 · Stack it, and something emerges

Stacking many layers gives a language model

  • One round resolves "bank"; the next round builds on that. Stack a hundred
  • Several heads per round, each asking a different kind of question
  • Between rounds each word "thinks" alone
  • Final position points at a region; read off the words living there
  • No controller, no parser, no rules. Local interactions, one global pressure. Structure anyway

One round of attention resolves "bank". The next round can use the resolved "bank" to resolve something else. Stack a hundred rounds.

Each round has several attention heads running in parallel, each asking a different kind of question: one tracks grammar, one tracks who did what to whom, one tracks which entity a pronoun refers to. Between rounds, a small network lets each word "think" alone about what it has gathered.

At the end, the last word's position points at a region of the space, and the model reads off which words live there. That's the prediction.

For a complexity crowd: there is no central controller, no symbolic parser, no rule that says what a sentence is. There are only local interactions between points, repeated, under one global pressure. Structure like grammar, facts, and reasoning-ish behaviour shows up anyway, and shows up suddenly as scale grows.

layer 0 / 6
7 · Chat

A chat is a single document that is re-read every turn

  • The model has no memory. It sees one document and predicts the next token
  • Hidden system prompt sets the character
  • Each message wrapped in role markers, which are just tokens
  • Every turn: whole transcript re-read from the top
  • "Claude" is a character the document is written in
  • Long chats get slower, and eventually hit a limit

The model has no memory and no idea a conversation is happening. It sees a single document and predicts what comes next.

The app builds that document for it. A hidden opening section, the system prompt, describes the character it should write as. Then each message is wrapped in role markers, which are special tokens like any other. When you hit send, the whole transcript so far, plus an open "assistant:" marker, is fed through the stack, and the model produces tokens until it emits a special stop token. The app hides the markers and shows you the middle.

Send the three messages in order. The third only works because the answer is sitting in the document.

"Claude" is a character the document is written in. The model learned to play it during fine-tuning on transcripts written that way. Its memory of this conversation is the transcript itself, re-read from the beginning every turn, which is also why long chats get slower and eventually hit a limit.

what you see

what the model sees

document: 0 tokens
8 · Thinking

Reasoning happens by writing out tokens

  • One pass through the stack = fixed computation. Some questions don't fit
  • Every produced token becomes input for the next. That is the only memory
  • Write out the steps, then attend to them: "chain of thought"
  • Reasoning models are trained to use a long hidden scratchpad well
  • Agents: some tokens are a request. Software runs it, pastes back the result, loop continues
  • The interesting behaviour lives in the loop, not in a single pass

One trip through the stack is a fixed amount of computation. Some questions don't fit. So the model writes, and then reads back what it wrote.

Every token the model produces is appended to the context and becomes input for the next one. That is the only memory it has. A model that writes out its intermediate steps gets to attend to them on the next token. It trades depth it doesn't have for length it can always add. This is "chain of thought".

"Reasoning" models are trained, by reinforcement learning, to produce long scratchpads and use them well: check, backtrack, try another route. The scratchpad is hidden from you but fully visible to the model.

An agent adds one move. Some of the tokens are a request ("run this"). The software around the model runs it, pastes the result into the context, and the model carries on. Calculators, web search, running code: all the same loop.

For a complexity crowd: the interesting behaviour lives in the loop, not in a single pass. Planning and self-correction are properties of the transcript feeding back into itself, the way a conversation can reach conclusions none of the speakers started with.

prompt hidden scratchpad tool result, pasted in answer
0forward passes (tokens produced)
12layers per pass, fixed
0sequential steps of computation
9 · World model

Where the knowledge is stored, and why it is a model of how things work

  • Context is working memory and vanishes. Knowledge lives in the weights
  • Most weights are in the "think alone" blocks: a huge pattern → nudge lookup
  • "fragile thing" + "hard landing" → nudge toward "shatters". Nobody wrote that entry
  • Too few numbers to memorise the text, so it compresses into rules: what things do
  • The vector carries the running state of a scene: full or empty, shut or open, whole or broken
  • Hallucination: a pattern with no entry still gets a plausible nudge
  • Valleys appear because they are the cheap solution. Nothing in a chat changes the weights

The context is working memory and vanishes when the chat ends. Everything the model knows for good is in the weights: hundreds of billions of numbers, fixed since training.

Most of those numbers sit in the "think alone" blocks between attention rounds. Each block works like an enormous lookup of pattern → nudge. One entry responds when the vector says "fragile thing", another when it says "hard landing", and together they push it toward "shatters". Nobody wrote those entries. They formed because "shatters" kept being the right next word after glasses, vases and eggs met floors.

Why rules rather than a pile of quotes? The network has far fewer numbers than the text it read, so it cannot memorise. The cheapest reliable way to predict text about the world is to carry a compressed model of how the world behaves: what falls, what melts, what stays where it was put, who knows what. An entry that fires on "glass" alone or "dropped" alone is reused in millions of sentences; an entry per sentence is not. Next-word prediction is the pressure; the mechanics are what the weights settle into under it.

You can find the state. Read the model a short story and probe the vector after each sentence: a simple linear read-out recovers whether the glass is currently full or empty, whether the door is open, where the glass is now, and it updates as events happen, though the model was never told to keep a ledger. A model trained only on lists of Othello moves builds the board in its activations and updates it move by move. Hallucination is the flip side: a pattern with no entry behind it still receives a plausible-looking nudge.

For a complexity crowd: a landscape shaped by rain has no rule that says "carve valleys", yet valleys appear because they are the cheap solution. Structure here is the residue of pressure. Nothing in a chat changes the weights; learning only happens during training.

probe the vector after each sentence