The 2017 paper that taught machines to pay attention
Get Bloomer Friday and the free Starter Pack
Free: 13 AI breakthroughs already making life better, plus a 2-minute good news email every Friday.
13 picks, instant access. Unsubscribe any time.2026 breakthroughs PDFSample issue
On June 12, 2017, a paper with a memorable title appeared on arXiv: “Attention Is All You Need.” Its eight authors, listed in random order because they made equal contributions, were Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser and Illia Polosukhin, at Google Brain, Google Research and the University of Toronto. Later that year the work was published at the 31st Conference on Neural Information Processing Systems (NIPS 2017) in Long Beach, California.
The bottleneck they wanted to remove
At the time, the leading way to teach a computer about a sentence was to read it in order, one word after another, using a recurrent neural network. The paper explained the catch plainly. Recurrent models generate each hidden state from the previous one, and “this inherently sequential nature precludes parallelization within training examples.” Attention mechanisms were already helping models look across a sentence, but almost always together with a recurrent network.
The authors proposed something simpler. “We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.”
Looking at every word at once
Instead of stepping through a sentence, the Transformer lets every position look at every other position in a constant number of steps. In a Google Research post published on August 31, 2017, Jakob Uszkoreit offered a clear example. In the sentence “I arrived at the bank after crossing the river,” the model can learn to attend immediately to “river” when it is figuring out what “bank” means.
Under the hood, both the encoder and the decoder are stacks of six identical layers. Each encoder layer has multi-head self-attention and a small feed-forward network. The decoder adds a third sub-layer so it can attend over the encoder’s output, and it masks future words so it cannot peek ahead. The authors used eight attention heads running in parallel, which they found let the model “jointly attend to information from different representation subspaces at different positions.”
Because the model has no recurrence and no convolution, word order has to be added another way. They attached positional encodings, built from sine and cosine functions of different frequencies, to the input embeddings.
Faster, and better at translation
The results were hard to ignore. On the WMT 2014 English-to-German translation task, their big model reached a BLEU score of 28.4, improving on the best previous results (including ensembles) by more than 2 BLEU. They trained that model for 3.5 days on eight NVIDIA P100 GPUs. A smaller base model, trained for 12 hours or 100,000 steps on one machine with the same eight GPUs, already surpassed all previously published models and ensembles. On English-to-French, the big model set a new single-model state of the art after the same 3.5 days of training.
They also tried English constituency parsing, a structured language task, with little extra tuning. A four-layer Transformer did better than all previously reported models except one specialized parser, the Recurrent Neural Network Grammar.
In the Google Research post, Uszkoreit wrote that besides higher translation quality, the Transformer “requires less computation to train and is a much better fit for modern machine learning hardware, speeding up training by up to an order of magnitude.”
An invitation to keep going
The authors called the Transformer “the first sequence transduction model based entirely on attention.” They were already thinking beyond translation, and planned to extend it to “input and output modalities other than text” and to large inputs such as images, audio and video. The Google post said they had already started applying it to images and video, sped along by the Tensor2Tensor library they had open sourced so others could train their own Transformer networks.
“We are excited about the future of attention-based models and plan to apply them to other tasks,” they wrote. The simple idea (let every word look at every other word) showed that a clearer design could make language systems both stronger and faster to train. Then they handed the tools to anyone who wanted to try.