Distillation / AI foundations · 2 min read
Reading all words at once beat word-by-word translators in English-German, far more cheaply.
The design under the chatbots you use today began as a faster way to train translation software.
Vaswani et al. · Google · NIPS 2017 (now NeurIPS) · Dec 2017 · peer reviewed
A curious soul · 1 min
Why should you care?
For context, not from the paper: today's chatbots grew out of this design. It began as a faster way to train translation software.
What did they do?
Back then, leading translation software mostly read one word at a time, each step waiting for the last. In 2017, a team at a big tech company built the Transformer, which looks at every word at once.
What did they find?
They found that a smaller version, trained for 12 hours on one machine, beat every earlier English-to-German system in the paper, even teams of systems, on a fraction of their computing.
12 hours
of training on one machine, enough for the smaller Transformer to beat every earlier English-to-German system in the paper.
Training time of the base Transformer, in hours. Redrawn from Section 5.2 of the paper
What explains it?
The authors point to attention: each word weighs which others matter to it. In training, no word waits, so a sentence's work runs at once.
What's the catch?
- Scope: two language pairs, one test, single scores with no ranges, and no person judged the output.
- The quick win was English to German only; on French, only a bigger version led, and only among single systems.
- Each layer's work grows with the square of sentence length, so very long inputs get costly.
So what?
Our read: here, smarter design beat rivals that used more computing.
Test yourself: one question
What did the smaller Transformer need to beat every earlier English-to-German system in the paper?
Options: A month on hundreds of machines / About half a day on a single machine / A year of hand-made grammar rules
Answer: About half a day on a single machine. It trained for 12 hours on one machine, using a fraction of the computing of earlier systems.
That one smart friend · 2 min
Why should you care?
For context, not from the paper: this design later became the basis of today's chatbots. Here its job was translating better and training faster.
What did they do?
Until 2017, leading translation software mostly read a sentence one word at a time. Each step waited for the last, so the work inside a sentence could not run at once.
A team at Google Brain and Google Research built the Transformer, which relies only on attention: each word looks at every other word and weighs which ones matter to it. Earlier systems used attention mostly as a helper to word-by-word reading.
They trained it on about 4.5 million English-German sentence pairs, plus a much larger English-French set, on one machine with 8 graphics chips, and compared it with earlier published systems.
What did they find?
They found that the smaller version, trained for 12 hours, scored higher on the English-to-German test than every earlier published system, even teams of models, at a fraction of their computing. A bigger version, trained for 3.5 days, beat the best earlier result by more than 2 points on the standard translation score.
12 hours
of training on one machine, enough for the smaller Transformer to beat every earlier English-to-German system in the paper.
Training time of the base Transformer, in hours. Redrawn from Section 5.2 of the paper
What explains it?
The authors think two things matter. In training, every word is handled at the same time, so the work inside a sentence runs in parallel instead of waiting in a queue. And any two words are one step apart, which they argue helps it learn links between distant words.
In variations, splitting attention into several parallel views beat a single one.
What's the catch?
- Scope: two language pairs from one public benchmark, one score per model with no repeats or ranges, and only an automatic overlap score, with no human judges.
- The fast win was English to German only. On English to French, only the bigger version led, and only among single models; earlier teams of models scored higher.
- Rivals' scores come from their own papers, and all costs are the paper's estimates. Each attention layer's work also grows with the square of sentence length.
So what?
Our read: a design that uses the hardware better can beat a bigger computing budget.
Test yourself: one question
According to the authors, why could the Transformer train so much faster?
Options: It looked at every word at once, so the work could run in parallel / It learnt from a far bigger set of sentences than its rivals / It ran on a new kind of chip built just for it
Answer: It looked at every word at once, so the work could run in parallel. With word-by-word reading, each step waits for the last. Looking at all the words at once lets the work inside a sentence run in parallel.
The Final Boss · 4 min
Why should you care?
This NIPS 2017 paper introduced the Transformer, and for context, not from the paper, that design later became the basis of today's large language models. The paper itself is about machine translation: it claims attention alone can beat recurrent and convolutional designs on quality and training cost.
What did they do?
Vaswani and seven co-authors at Google Brain and Google Research started from a bottleneck. Recurrent networks, which read a sequence one position at a time and pass a running state forward, led machine translation, but that step-by-step design stops the work inside a sentence from running in parallel (Section 1). Convolutional models such as ConvS2S and ByteNet already worked in parallel, but the steps needed to link two words grew with the distance between them (Section 2).
The Transformer keeps the usual encoder-decoder layout: the encoder turns the input sentence into numbers, and the decoder writes the output one word at a time from them. Both are built only from attention and small feed-forward layers: 6 layers each, words held as 512 numbers, and 8 attention heads, about 65 million parameters for the base model (Section 3.1, Table 3). Attention here is a weighted average: each word scores every other word for relevance and blends in their information accordingly. A head is one such scoring, so several heads give several views at once. Nothing tracks word order, so fixed wave patterns are added to mark each position.
Training used WMT 2014: about 4.5 million English-German sentence pairs and 36 million English-French sentences (Section 5.1), on one machine with 8 NVIDIA P100 GPUs. Scores are BLEU, which measures how closely a machine translation overlaps with human ones; higher is better. Rivals' BLEU scores were taken from their own papers. Training cost, for every model, is the paper's own estimate: training time, times the number of GPUs, times an assumed speed per GPU, 9.5 TFLOPS for a P100 and lower figures for older K80, K40 and M40 chips (footnote 5).
What did they find?
They found that the base model, after 12 hours of training (100,000 steps of about 0.4 seconds, Section 5.2), scored 27.3 BLEU on English to German, and the big model, after 300,000 steps over 3.5 days, scored 28.4 (Table 2). The best earlier results were 26.36 for the ConvS2S ensemble and 26.30 for the GNMT + RL ensemble, where an ensemble is several models voting.
In billion billion operations, the base model's English-German training cost 3.3, against 77 for the ConvS2S ensemble and 180 for the GNMT + RL ensemble. The big model's 23 matches the GNMT + RL single model and sits near MoE's 20, so its gain over those models did not come cheaper.
On English to French, the big model scored 41.0, a new best for a single model, at less than a quarter of the estimated cost of the previous best single model (Section 6.1).
Table 3 tries variations on the base model, each row changing the settings it lists, scored on a separate development set where the base model scored 25.8. One attention head instead of several, with total computation kept the same, scored 24.9; no dropout, a trick that randomly switches off parts of the network in training, 24.6; learnt position markers instead of waves, 25.7, nearly the same. The big model, which changes several settings at once, reached 26.4.
Training cost for English to German, in billion billion floating-point operations, the paper's own estimate. Redrawn from Table 2 of the paper | Training cost, in billion billion operations |
|---|
| Earlier ensemble (GNMT + RL) | 180 |
|---|
| Earlier ensemble (ConvS2S) | 77 |
|---|
| Earlier single model (MoE) | 20 |
|---|
| Transformer, big | 23 |
|---|
| Transformer, base | 3.3 |
|---|
What explains it?
The authors' case is in Section 4 and Table 1: a self-attention layer links any two positions in a fixed number of steps, where a recurrent layer needs as many steps as the sentence is long. That means more work in parallel and shorter paths between distant words, which they argue are easier to learn. The price is that each layer's work grows with the square of sentence length. They argue it is still faster than a recurrent layer while sentences are shorter than each word's list of numbers, the usual case in translation. They add that a single head blurs detail by averaging, which several heads counter.
What's the catch?
- Scope: two language pairs from one benchmark year. Each model is reported as one score, the Transformer's from averaging saved snapshots near the end of training (Section 6.1), with no repeats, ranges or significance tests, so gaps of a few tenths might not hold.
- The base model's win is English-German only: on English-French it scored 38.1, below every earlier system in Table 2, and the big model's best single-model score still trails the ConvS2S and GNMT + RL ensembles.
- Quality is measured only by BLEU, with no human judges; rivals' scores come from their own papers, not reruns, and every cost, the Transformer's included, is an estimate built on assumed chip speeds.
So what?
Our read: on English-German, a new design scored higher than rivals that spent far more computing, so a bigger budget did not guarantee the best result.
Test yourself: one question
How sure can we be that the 27.3 against 26.36 lead was not luck?
Options: Very sure: every comparison has a significance test / Not at all: the paper was not peer reviewed / We can't tell: one score per model, no repeats or ranges
Answer: We can't tell: one score per model, no repeats or ranges. Each model is reported as one score, with no repeats or ranges, and rivals' scores were not rerun side by side.
Go deeper
| Number | Value | Where in the paper |
|---|
| Who and where | 8 authors, equal contributors listed in random order; work done at Google Brain and Google Research (one author listed at the University of Toronto). NIPS 2017, Long Beach. | Title page |
| Base design | 6 encoder and 6 decoder layers, words held as 512 numbers, 8 attention heads, 65 million parameters (big model: 213 million) | Sections 3.1 and 3.2.2, Table 3 |
| Training data | WMT 2014: about 4.5 million English-German sentence pairs; 36 million English-French sentences | Section 5.1 |
| Hardware | One machine with 8 NVIDIA P100 GPUs | Section 5.2 |
| Training time, base model | 12 hours: 100,000 steps of about 0.4 seconds | Section 5.2, Introduction |
| Training time, big model | 3.5 days: 300,000 steps of 1.0 second | Section 5.2 |
| English-German BLEU | Transformer base 27.3, big 28.4. Best earlier: ConvS2S ensemble 26.36, GNMT + RL ensemble 26.30, MoE 26.03 | Table 2 |
| Margin over the earlier best | More than 2.0 BLEU for the big model on English-German, ensembles included | Abstract, Section 6.1 |
| English-French BLEU | Transformer big 41.0, base 38.1 (below every earlier system listed). Best earlier single model MoE 40.56. Earlier ensembles ConvS2S 41.29 and GNMT + RL 41.16, both higher than 41.0 | Abstract, Table 2, Section 6.1 |
| Training cost, English-German (FLOPs, the paper's estimate) | Transformer base 3.3 × 10¹⁸, big 2.3 × 10¹⁹. ConvS2S 9.6 × 10¹⁸, MoE 2.0 × 10¹⁹, GNMT + RL 2.3 × 10¹⁹. ConvS2S ensemble 7.7 × 10¹⁹, GNMT + RL ensemble 1.8 × 10²⁰ | Table 2 |
| Training cost, English-French | Big model at less than a quarter of the previous best single model's cost: 2.3 × 10¹⁹ against MoE's 1.2 × 10²⁰ | Section 6.1, Table 2 |
| How cost was estimated | Training time × number of GPUs × an assumed sustained speed per GPU (P100 9.5, M40 6.0, K40 3.7, K80 2.8, in TFLOPS), used for every model in Table 2 | Section 6.1, footnote 5 |
| Variations (development set, newstest2013) | Variations on the base model, each row changing the settings it lists. Base 25.8 BLEU. One attention head, total computation kept the same, 24.9 (0.9 worse than the best setting). No dropout 24.6. Learnt positions 25.7. Big model, several settings changed at once, 26.4 | Table 3, Section 6.2 |
| What the authors planned next | Images, audio and video; restricted attention for long inputs; less step-by-step generation | Section 7 |
Inside this NIPS 2017 version: the Table 2 caption and the Conclusion (Section 7) claim a new best on both English-German and English-French, but Table 2's own English-French column has two earlier ensembles above the big model's 41.0 (ConvS2S ensemble 41.29, GNMT + RL ensemble 41.16). The Abstract and Section 6.1 claim only the best single model on English-French.
Later arXiv revision (v7, 2023), not this NIPS 2017 version: it gives the English-French score as 41.8 in its Abstract and Table 2 while keeping 41.0 in Section 6.1, and it adds an English grammar-parsing test (Section 6.3, Table 4).
Say this at dinner
In one paper from 2017, translation software that read every word at once trained for 12 hours on one machine and beat every English-to-German system it was compared with.
All papers