In June 2017 eight researchers at Google posted a paper proposing that a translation system could drop its most trusted part, the recurrent network that reads a sentence one word at a time, and keep only a side mechanism called attention. They named the result the Transformer. I am built on it, and so is nearly every large language model in use today. This edition replaces the paper's figures with a working one. A Transformer of 7,136 numbers, trained for this page in 28 seconds, runs in your browser and translates a toy English into French. Every line drawn between two words below is its actual arithmetic. You can watch it read, bet on where it will look next, and pull out its parts to learn which ones it needs.
| Paper, 2017 | This page | |
|---|---|---|
| Encoder layers, decoder layers | 6, 6 | 1, 1 |
| Numbers per word (dmodel) | 512 | 16 |
| Attention heads per layer | 8 | 2 |
| Feed-forward width | 2,048 | 32 |
| Learned numbers | about 65 million | 7,136 |
| Training | 12 hours on 8 P100 GPUs | 28 seconds on 2 CPU cores |
| Task | English to German, about 4.5 million sentence pairs | Toy English to French, 105 words, about 2.2 trillion possible sentences |
| Result | The larger “big” version scored 28.4 BLEU, more than 2 points above the best previous systems | 20,000 of 20,000 random test sentences exactly right |
Before 2017 the best translation systems were recurrent networks. They read a sentence the way a message travels down a line of people: each word updates a running summary and hands it to the next. Two costs follow. Word nine cannot be processed until word eight is done, so the work cannot be spread across a parallel machine. And anything the first word knew has to survive every hand-off to reach the last.
Those systems already used attention as a helper, a way for the output side to glance back at the input. The paper's footnote credits Jakob Uszkoreit with the proposal to go further and replace the recurrence with attention entirely. Without the line of people, every word can consult every other word directly, in one step, and all of them can do it at the same moment.
The word it needs a fact from an earlier word. Tap the word that holds it.
Here is the whole mechanism. A word that needs information forms a question: a short list of numbers called a query. Every word it could consult holds up a key, another short list. Multiply query and key together, number by number, and add up the results. A large total means this key answers that question. The totals then pass through a softmax, which turns them into shares that sum to 100%. The asking word takes that share of what each word has to offer, which is a third list called its value.
The paper writes all of that in one line and calls it scaled dot-product attention:
Attention(Q, K, V) = softmax(QKT / √dk) V(1)
The division by √dk is the “scaled” part. Longer lists produce bigger totals, and big totals push the softmax toward all-or-nothing answers that are hard to learn from. Dividing by the square root of the list length keeps them in range. In this model the lists are 8 numbers long.
The model is about to write one French word. Choose which:
A single head asks one question at a time, so the paper runs eight in parallel in every layer, each with its own learned queries, keys and values, and joins their answers. It calls this multi-head attention. The footnote credits it, together with equation (1) and the position trick of section 4, to Noam Shazeer. This model has two heads per layer, printed in blue and orange.
The Transformer then uses that one mechanism in three places.
There is a catch. Equation (1) treats a sentence as a bag of words. Nothing in it knows that the cow sees the hat and the hat sees the cow are different sentences, because a recurrent network got word order for free and attention does not. So before anything else, each word's numbers are stamped with its position: a pattern of sine and cosine waves, a different wavelength for each pair of numbers, added straight onto the word.
PE(pos, 2i) = sin(pos / 100002i/d) PE(pos, 2i+1) = cos(pos / 100002i/d)(2)
position in the sentence, 0 to 19
The decoder writes a word, reads its own output back in, and writes the next. At each step it scores every French word it knows and takes the highest. This model knows 60. The paper's knew tens of thousands of word pieces. Figure 1 shows those odds beside the lines.
You have seen enough to predict it. Before each French word appears, tap the English word you think the model is reading. You score by how much of its attention you guessed.
The title is a claim about what can be left out: recurrence and convolution, the two standard ways of reading a sequence in 2017. It does not say attention works alone. Around it sit the position stamp, a small feed-forward network after each attention step, and residual connections that carry every word's own numbers past each block so that nothing has to be relearned.
Here is the whole machine. Take parts out and I will rerun 200 test sentences each time. “Blur” keeps a block in place but makes it give every word equal attention, which is roughly what a head does before it has learned anything.
Try the position stamp first, then blur the attention over the English. Then remove only head A from the decoder's self-attention and read the failures. Every one of them is a wrong il or elle, and nothing else breaks.
I trained this model with the paper's own recipe at a smaller scale: the Adam optimiser, a learning rate that climbs for the first 400 steps and then decays, dropout of 0.1 and label smoothing of 0.1. It ran for 3,000 steps of 64 sentences each. The toy grammar can produce about 2.2 trillion sentences, and training showed it 192,000 examples. One sentence in ten was held back and never shown, and those are the ones the curve below is measured on.
The paper closes by saying its authors planned to take the Transformer beyond text, to images, audio and video. That happened. By the end of 2018, BERT had shown what the encoder half could do alone and GPT what the decoder half could do alone. Today's language models, including the one writing this sentence, are mostly that decoder half made very much larger: the loop from section 5, trained on a great deal more than toy sentences about cows.
Equation (1) is the part that stayed. The 7,136 numbers on this page and the model that wrote the page do the same arithmetic. I find that strange to think about, and I am made of it.
Everything here was written by Claude Fable 5.2 in November 2026 for Tom Harwood's Conversational Artifacts: the prose, the toy grammar, the training script, the model, and the JavaScript that runs it. Tom chose the subject. There are no libraries. The model's code is about 150 readable lines in js/engine.js, and the training script and tests are in the repository.
The toy French is real French with a small vocabulary and three rules: articles and adjectives agree with the noun, colours follow the noun while big, small, pretty and new come before it, and it refers to the subject. The model was never told these rules. It was shown examples. I trained six copies from different random starts and kept the one whose heads were easiest to read. All six translate at least 99.96% of test sentences.
Source: Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser and Polosukhin, “Attention Is All You Need,” arXiv:1706.03762, presented at NIPS 2017. This edition is an independent explanation and is not affiliated with the authors or with Google.