Attention Is All You Need · Abstract

Abstract

One paragraph that says what the paper builds, what it removes, and what it achieved. Every later section backs up one of its claims.

The abstract's claims in one picture
  • Recurrence removed
  • Convolutions removed
  • Attention kept, and all that is needed

Three building blocks of the translation models of 2017: recurrence and convolutions crossed out, attention kept. Below them the three results the abstract reports, each with the section or table that shows it: 28.4 BLEU from English to German, 41.8 BLEU from English to French, and 3.5 days of training on eight GPUs.

What this section says

The abstract makes four claims. The models that translated text best in 2017 read a sentence with recurrent or convolutional networks, with an encoder and a decoder, often joined by attention. The paper keeps the encoder, the decoder and the attention, and throws the rest away. The result, the Transformer, translates better than every earlier model, and trains faster because its work can be spread over many processors at once.

The two scores are BLEU, a number from 0 to 100 that counts how many words and phrases of a machine translation also appear in a human one (section 6.1 and chapter 19). Two points of BLEU was a large step in 2017. The last sentence adds a third task, English constituency parsing, to show the design is not only good at translation (section 6.3).

Daniel meets the result every day: the models behind the APIs he calls are descendants of this design, mostly its decoder half (section 3.1 and chapter 22 to come).

In the paper's words

“We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.”

Abstract In plain words: The paper introduces a new design, the Transformer, built on attention alone, with no recurrent and no convolutional layers.

“Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task, improving over the existing best results, including ensembles, by over 2 BLEU.”

Abstract In plain words: On the standard English-to-German test the model scored 28.4 BLEU, more than 2 points above the best earlier results, even those that combined several models.

Quoted from Vaswani et al., Attention Is All You Need, arXiv:1706.03762v7(opens in a new tab). The figures on this page are redrawn, not copied.

The notation

The symbols of this section, in the paper and in our model
Symbol Meaning In the paper Our miniature
\(\text{BLEU}\) how closely a translation matches a human one, from 0 to 100 28.4 (English to German), 41.8 (English to French) 99.95 on our 805 held-out sentences, an easy task
\(\text{WMT 2014}\) the standard translation test sets of 2014, a public benchmark English–German and English–French our own synthetic English–German sentences
\(\text{GPU}\) a graphics card used for its many parallel processors 8 for 3.5 days (big model) none: one laptop processor, about 4 minutes

Try it

Try the claims on our miniature

Type a short English sentence and the paper's model, in miniature, translates it into German, then shows where each German word looked in the English while it was written.

Examples

English sentence
The model knows 86 English words: see the list below.
The words the model knows

The model's German

Anna hat einen kleinen Hund . Sie mag ihn .

The model writes one German word at a time and keeps the four best beginnings at every step, as the paper's beam search does; the finished translations are ranked by their score.

The beam's finished translations

# Translation Log-probability Score
1 Anna hat einen kleinen Hund . Sie mag ihn .
chosen
−0.8043 −0.4465
2 Anna hat einen öffnen einen kleinen Hund . Sie mag ihn . −7.9367 −4.1055
3 Anna hat einen kleinen Hund . Sie mag ihn . Lampe . −8.3971 −4.3437
4 Anna hat einen kleinen Hund . Sie mag ihn . Auto . −8.4355 −4.3635
5 Anna hat einen kleinen Mann . Sie mag ihn . −7.9613 −4.4198
6 Anna hat einen Eine Hund . Sie mag ihn . −8.0386 −4.4627

The log-probability adds up how sure the model was of each word (0 would be certain). The score divides it by the paper's length penalty, so a longer sentence is not punished just for having more words.

Where each German word looked

Each row is a German word as the decoder wrote it; each column an English word it could look at. The darker the cell, the more of that word went into the decision. This is the encoder–decoder attention of the paper's section 3.2.3.

Decoder layer
Head
Encoder–decoder attention, decoder layer 2, All 4 heads, averaged A heat map with one row for each word of the German translation “Anna hat einen kleinen Hund . Sie mag ihn .” and one column for each English word; each cell shows how much attention the German word paid to the English word.Annahasasmalldog.Shelikesit.</s>Anna100 %hat100 %einen73 %25 %kleinen100 %Hund100 %.49 %51 %Sie13 %75 %12 %mag100 %ihn25 %12 %46 %13 %.48 %51 %</s>24 %26 %50 %

The strongest link of each German word:

The model reads English and writes German, the paper's own task, whatever language this page is in. It is about a quarter of a million weights, trained in minutes on a laptop; the paper's base model had 65 million.

On its own page: Translation playground

The translation playground: the paper's design, built small, translates your English sentence into German with beam search and shows where each German word looked.

How our miniature differs

Our miniature is built exactly as the paper describes, only smaller: 244,800 weights against the paper's 65 million, trained for 239 seconds on a laptop instead of 12 hours on eight GPUs. On our simple sentences it reaches BLEU 99.95, which says the task is easy, not that it beats the paper's 28.4: the two numbers are measured on different test sets and cannot be compared.

Prepared in the Course by

Check yourself

Three questions a reader of this section should now be able to answer. The lab checks your answer against the paper and our models.

What goes

Which building blocks does the Transformer leave out entirely?

The English-to-German score

What BLEU score does the big Transformer reach on WMT 2014 English to German?

Your answer
Within 0.05 of the answer

The main task

On which task does the abstract report its two BLEU scores?

An unhandled error has occurred. Reload 🗙

Reconnecting…

Your connection to the Transformers and Attention Lab dropped, probably a Wi-Fi blip. Hold on while it reconnects.

The connection could not be restored. The page will reload in a few seconds.