The 2017 paper that built a translation model from attention alone, letting every word read every other word at once. It became the base of modern language models.

Before 2017, the best programs for translating languages read a sentence one word at a time. That was slow, because each step had to wait for the step before it. It also made it hard to link words that sit far apart. This paper showed a model that looks at all the words at once, using only a tool called attention. Almost every large language model today is built on it.
| Title | Attention Is All You Need |
| Authors | Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, Illia Polosukhin |
| Year | 2017 |
| Venue | NIPS 2017 (31st Conference on Neural Information Processing Systems) |
| Link | arxiv.org/abs/1706.03762 |
Build a translation model out of attention only, with no recurrence and no convolution, and call it the Transformer.
Attention lets each word in a sentence look at every other word and take in the information it needs. Because all words are handled together, the work can run in parallel on a GPU (a chip made for many small calculations at once).
A vector is a list of numbers. For each word, the model makes three vectors from that word's own vector, using learned weights (numbers the model adjusts during training).
The model compares one word's query with every word's key. A good match means "pay attention to that word". Then it takes a weighted mix of the values.
The paper's formula (equation 1) is:
Read it from the inside out.
One query looks at three words with keys , , and values , , . Here .
Dot products: . Divide by : . Softmax gives weights , which add up to 1.
Output .
Compare the query with every key
The word is called self-attention when the queries, keys and values all come from the same sentence.
One attention step produces one set of weights, so it can follow only one kind of link at a time. The paper runs attention steps side by side, called heads. Each head first projects the queries, keys and values with its own learned weights into smaller vectors ( when the model width is ). The outputs of all heads are joined and projected once more. Because each head is smaller, the total cost is similar to one full-size head.

In the paper's tests, one head was 0.9 BLEU worse than the best setting, and too many heads also hurt.
Attention treats a sentence as a set of words. It has no sense of order, so "dog bites man" and "man bites dog" would look alike. The paper adds a positional encoding to each word's vector: a vector of the same length, built from sine and cosine waves of different wavelengths.
For position 0 the first four values are . For position 1 they are . For position 2 they are . Each position gets its own pattern. The first pair changes fast from position to position, and the second pair changes slowly.
The authors chose waves because they expected the model could learn to look at relative positions. They also tried learned position vectors and got nearly identical results.
The model has two stacks, each with identical layers.
Around every sub-layer there is a residual connection (the input is added back to the output) and layer normalization (rescaling the numbers to a steady range).
The mask sets scores for later positions to . Softmax turns those into weight 0, so a word cannot look at words that come after it.
All results are on translation, scored with BLEU, a number that measures how much a machine translation overlaps with human translations (higher is better). The test sets are WMT 2014.
| Model | English to German | English to French | Training cost (FLOPs, German) |
|---|---|---|---|
| ConvS2S | 25.16 | 40.46 | 9.6e18 |
| MoE | 26.03 | 40.56 | 2.0e19 |
| GNMT + RL | 24.6 | 39.92 | 2.3e19 |
| ConvS2S ensemble | 26.36 | 41.29 | 7.7e19 |
| Transformer (base) | 27.3 | 38.1 | 3.3e18 |
| Transformer (big) | 28.4 | 41.8 | 2.3e19 |
These numbers show that attention alone can match or beat the strongest 2017 models on these translation tasks, for less training cost. They do not show it is best for every task or every length of text.