Text in.
A probability out.
A transformer is not a mind, a database, or a search engine. It is one enormous function that takes a sequence of text and returns a probability for every possible next token — and then gets run again on its own output. Everything else, including the part that feels like thinking, is that step repeated. This is a walk through the step, one stage at a time.
01 / THE PREMISE
The whole model does
exactly one thing.
Predict what comes next. Not the sentence, not the paragraph — the next token. The surprising part is not the mechanism; it is that repeating it is enough.
The name says it. GPT is Generative Pre-trained Transformer: it generates, it was trained in advance on a very large amount of text, and transformer is the specific architecture doing the work — invented at Google in 2017, originally to translate between languages.
Feed it some text and it does not return a sentence. It returns a probability for every token in its vocabulary — for GPT-3, that is 50,257 numbers that sum to one. A chatbot is that function wrapped in a loop: sample one token from the distribution, append it to the text, run the whole thing again. The model has no memory of having run before. Each pass re-reads everything from the start.
ONE PASS
PASS 1Thecatsatonthe
PASS 2Thecatsatonthemat
PASS 3Thecatsatonthemat.
This is the entire product surface of a raw model. Everything a chat interface adds — turns, roles, system prompts, tool calls — is text arranged so that the most probable continuation happens to be the behaviour you wanted.
02 / TOKENS
The model never
sees a word.
Before anything else, the text is chopped into tokens: fragments from a fixed vocabulary. Common words are one token. Rarer ones are assembled from pieces.
This is the first place intuition breaks. A token is not a word and not a character — it is whatever the tokenizer decided was a useful unit while compressing the training corpus. Spaces usually belong to the token that follows them, punctuation is its own token, and an unusual word arrives as two or three fragments.
"The tokenizer doesn't see words." — ILLUSTRATIVE SPLIT
8 TOKENS · 6 WORDS ␣ = THE SPACE BELONGS TO THE TOKEN EXACT SPLITS VARY BY TOKENIZER
Each token is then replaced by its ID — an index into the vocabulary. From here on the network is working with numbers, and the letters are gone for good.
03 / EMBEDDINGS
Every token becomes
a direction in space.
The first weight matrix in the model is a lookup table: one column per vocabulary entry. GPT-3's has 50,257 columns of 12,288 numbers each.
Twelve thousand dimensions is impossible to picture, so use the smallest honest intuition instead: each token becomes an arrow, and arrows that point in similar directions mean similar things. What makes this more than a filing system is that directions themselves carry meaning, independently of any particular word.
The classic demonstration is arithmetic. Take the vector for woman, subtract
man, and you get an arrow that is roughly "the gender step". Add that same
arrow to king and you land very close to queen. The model was
never told about gender; the direction fell out of the training objective, because that
geometry makes next-token prediction easier.
VECTOR ARITHMETIC IN EMBEDDING SPACE
The same subtraction between two related pairs produces nearly the same arrow. That shared arrow is the concept, and it can be added to words it was never demonstrated on.
The dot product of two vectors is large when they point the same way, near zero when they are perpendicular, and negative when they oppose. That single operation is how the network asks "how much of this is present in that" — and it is the core of attention, three sections from here.
One important limit: at this stage, a token's vector depends only on the token. Every occurrence of "model" starts identical, whether the sentence is about machine learning or fashion. Context has not entered the picture yet.
04 / THE STACK
A grid of vectors,
refined ninety-six times.
The tokens are laid out side by side and pushed through the same two operations, over and over. Nothing is added to the array; the vectors in it just keep getting rewritten.
The array has a fixed width — the context window, 2,048 tokens for GPT-3. That is the model's entire world during one pass. Anything outside it does not exist, which is why "just give it more context" is a hardware bill and not a setting.
Then the array flows through the stack: an attention block, then a multilayer perceptron block, then attention again, then an MLP, for 96 layers. Same two shapes throughout — only the weights differ. If you want a one-line summary of the architecture: vectors talk to each other, then think alone, repeatedly.
GPT-3 · 2,048 POSITIONS × 12,288 DIMENSIONS × 96 LAYERS
Note what the read-out implies. The final vector at the last position has, by then, absorbed information from every earlier position — so the prediction is made in one place, from an accumulation of everything before it. During training every position predicts its own next token at once, which is what makes training efficient; at inference, only the last one matters.
05 / ATTENTION
Where a word finds out
what it means here.
Attention is the step where vectors are allowed to look at each other and update themselves. It is the reason the same word can mean different things in different sentences.
Every position emits a query — loosely, "what am I looking for?" — and a key — "what do I offer?". Dot products between queries and keys score how relevant each position is to each other position, those scores are normalised into weights, and each vector then pulls in a weighted mix of value vectors from the positions that scored highly.
The effect is concrete. The word model arrives generic, and leaves the block
carrying "machine learning" with it. A single head does this once; GPT-3 runs
96 heads per layer in parallel, each free to specialise in a different
kind of relationship — grammatical agreement, coreference, topic — and their results are
combined.
UPDATING THE VECTOR AT "MODEL" — WEIGHTS ARE ILLUSTRATIVE
a machine learning model
— the vector moves toward statistics, training, parameters.
a fashion model on the runway
— the identical starting vector moves somewhere else entirely.
This is also the step that makes context expensive: every position is scored against every other, so the work grows with the square of the sequence length. A context window is not a bigger buffer — it is a quadratically bigger computation.
06 / THE MLP
Where the vectors
think alone.
The other half of every block. No communication between positions here — each vector is pushed through the same small pipeline independently, and in parallel.
The pipeline is short: project the 12,288-dimensional vector up into a much wider space (49,152 — four times bigger), apply a nonlinearity that zeroes out most of it, then project back down to 12,288 and add the result to the original vector.
A useful reading of that shape: the up-projection asks tens of thousands of yes/no questions of the vector at once, the nonlinearity keeps only the ones that fired, and the down-projection writes the consequences back. This is widely believed to be where a lot of the model's factual knowledge is stored — and, as the parameter table below shows, it is where two thirds of the weights are.
THE MLP BLOCK
+ DOWN-PROJECT
The lanes are the point. Attention is the sociable half of the block; the MLP is the solitary half, and because the positions never interact here, this stage parallelises perfectly — which matters enormously for how these models are trained and served.
07 / THE LAST STEP
From one vector
to 50,257 numbers.
After the last layer, one final matrix turns the last vector into a score for every token in the vocabulary. Softmax turns those scores into probabilities.
The matrix is the unembedding — the mirror image of the embedding table, 50,257 rows of 12,288 numbers. Multiplying gives 50,257 raw scores called logits: unbounded, possibly negative, not yet meaningful as probabilities.
Softmax fixes that in two moves: exponentiate every logit, so everything becomes positive and larger gaps get amplified, then divide by the total so the whole thing sums to one. Temperature is a single extra division applied before exponentiating. Divide by a small number and the gaps widen — the top token dominates. Divide by a larger one and the distribution flattens.
RAW LOGITS AFTER "THE CAT SAT ON THE"
mat · floor · roof · moon
mat · floor · roof · moon
mat · floor · roof · moon
mat · floor · roof · moon
The logits are invented, but the four distributions are the actual softmax of those logits at each temperature. Read across and the important thing becomes obvious: the model's opinion never changed. Temperature only changes how much you let the lower-ranked opinions win the draw.
08 / THE BUDGET
Where 175 billion
parameters actually live.
"Parameter" means one number inside one matrix, tuned during training. GPT-3 has 175,181,291,520 of them spread across 27,938 matrices — and they are not distributed the way most people assume.
| Matrix | Dimensions | Parameters | Share | Relative size |
|---|---|---|---|---|
| Embedding | 12,288 × 50,257 | 617,558,016 | 0.4% | |
| Key | 128 × 12,288 × 96 × 96 | 14,495,514,624 | 8.3% | |
| Query | 128 × 12,288 × 96 × 96 | 14,495,514,624 | 8.3% | |
| Value | 128 × 12,288 × 96 × 96 | 14,495,514,624 | 8.3% | |
| Output | 128 × 12,288 × 96 × 96 | 14,495,514,624 | 8.3% | |
| Up-projection | 49,152 × 12,288 × 96 | 57,982,058,496 | 33.1% | |
| Down-projection | 12,288 × 49,152 × 96 | 57,982,058,496 | 33.1% | |
| Unembedding | 50,257 × 12,288 | 617,558,016 | 0.4% | |
| Total | 175,181,291,520 | 100% |
Two readings worth carrying away. First, the MLPs hold about two thirds of the weights — attention gets the attention, but the majority of the model is the part that processes each position alone. Second, the embedding and unembedding tables together are under 1%: almost nothing in this model is a lookup table, and almost everything is transformation.
It is also worth naming what "parameter" is not. These numbers are frozen after training. Your prompt does not modify them, your conversation does not modify them, and nothing the model says gets written back. Every apparent act of learning inside a session is text in the context window, not a change to the network — which is exactly why the harness around the model is where the engineering happens.
09 / IN PRACTICE
What the architecture
predicts about the behaviour.
The value of holding this picture is that a lot of model behaviour stops being mysterious and starts being derivable.
- 01
The model does not look anything up.
There is no table of facts being consulted. Whatever the network "knows" is baked into fixed weight matrices, and the answer is produced by multiplying your text through them. This is why a model can be fluent and confidently wrong at once: fluency and factuality come out of the same operation, and nothing in that operation distinguishes them.
- 02
Tokenization explains the stupid failures.
A model that reasons well about distributed systems can fail to count the letters in a word, because it never saw letters — it saw token IDs. The same mechanism explains why arithmetic on long numbers is shaky and why the exact same prompt in another language can behave differently: it is a different sequence of tokens entirely.
- 03
Context is a hard, quadratic budget.
Attention compares every position against every other, so doubling the context roughly quadruples that work. Long context windows are not free storage — they are the most expensive thing in the forward pass, which is why deciding what to put in the window is a real engineering discipline rather than a formatting choice.
- 04
Only the last position writes the answer.
The prediction is read off the final vector in the sequence, after it has absorbed everything before it. That is the mechanical reason instructions placed after the material often land differently from the same instructions placed before it: the position where the answer is computed sees a different accumulation.
- 05
Temperature is a knob on the same distribution.
The model does not become more creative at a higher temperature. It produces exactly the same scores and then flattens them before sampling, so lower-ranked tokens get picked more often. Anything you want to be reproducible should be run near zero, and anything you want varied should be varied deliberately, not hoped for.
- 06
The stack is the reason scaling worked.
Attention and the MLP alternate for dozens of layers, and every one of them is the same two operations with different weights. That uniformity is what made it worth pouring capital into: there is no clever architecture to redesign per problem, only a bigger version of the same block, which is precisely the property the last few years have been exploiting.
10 / VOCABULARY
Four terms the rest
of this module assumes.
Everything that follows in the harness track is built on these.
- Token
- The unit the model actually sees. Not a word and not a character — a fragment produced by a tokenizer, which is why letter-level questions confuse models that reason fluently about paragraphs.
- Embedding
- The vector a token becomes. Its direction, not its identity, is what carries meaning, so relationships between words show up as directions shared across the space.
- Context window
- The fixed number of vectors the network processes at once. Everything the model can consider in one pass lives here; nothing else exists to it.
- Logits
- The raw, unnormalised scores the last layer produces — one per vocabulary entry. Softmax turns them into probabilities; temperature decides how sharply.