Attention Is All You Need — Detailed Summary

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, Illia Polosukhin | Google Brain / Google Research / University of Toronto | 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA | arXiv:1706.03762

Per-section summary organized by paper headings. Each section includes paragraph-level bullet points and exact quantitative results where the paper provides them.


Abstract


1. Introduction

Background and the dominance of recurrence:

The sequential-computation bottleneck:

Mitigations that fall short:

Rising importance of attention:

The Transformer proposal:


2. Background

Reducing sequential computation via convolutions:

The Transformer's constant-distance attention:

Self-attention in prior literature:

End-to-end memory networks:

Novelty claim:


3. Model Architecture

Encoder-decoder framing:

Transformer's instantiation:

3.1 Encoder and Decoder Stacks

Encoder:

Decoder:

3.2 Attention

Definition:

3.2.1 Scaled Dot-Product Attention

3.2.2 Multi-Head Attention

3.2.3 Applications of Attention in our Model

3.3 Position-wise Feed-Forward Networks

3.4 Embeddings and Softmax

3.5 Positional Encoding


4. Why Self-Attention

Desiderata for the comparison:

Per-layer complexity:

Path length and long-range dependencies:

Restricted self-attention for very long sequences:

Convolutions:

Interpretability:

Table 1 (paraphrased): Layer-type comparison

Layer Type Complexity per Layer Sequential Ops Max Path Length
Self-Attention \(O(n^2 \cdot d)\) \(O(1)\) \(O(1)\)
Recurrent \(O(n \cdot d^2)\) \(O(n)\) \(O(n)\)
Convolutional \(O(k \cdot n \cdot d^2)\) \(O(1)\) \(O(\log_k n)\)
Restricted Self-Attention \(O(r \cdot n \cdot d)\) \(O(1)\) \(O(n/r)\)

5. Training

5.1 Training Data and Batching

5.2 Hardware and Schedule

5.3 Optimizer

5.4 Regularization


6. Results

6.1 Machine Translation

Table 2 (paraphrased): BLEU comparison with selected baselines

Model EN-DE (BLEU) EN-FR (BLEU)
GNMT + RL 24.6 39.92
ConvS2S 25.16 40.46
MoE 26.03 40.56
Transformer (base) 27.3 38.1
Transformer (big) 28.4 41.0

Training cost (FLOPs):

Inference:

6.2 Model Variations

6.3 English Constituency Parsing


7. Conclusion


Figures


Hyperparameter Summary

Hyperparameter Base Big
Stack depth \(N\) 6 6
Model dim \(d_{model}\) 512 1024
Feed-forward dim \(d_{ff}\) 2048 4096
Heads \(h\) 8 16
Key/Value dim \(d_k = d_v\) 64 64
Dropout \(P_{drop}\) 0.1 0.3 (0.1 for En-Fr)
Label smoothing \(\epsilon_{ls}\) 0.1 0.1
Training steps 100k 300k
Wall-clock training ~12 h ~3.5 days
Hardware 8x P100 8x P100

Limitations and Future Work


Focal References

Reference Contribution Relevance to this paper
Bahdanau et al. 2014 Additive attention in encoder-decoder NMT Original attention; baseline for compatibility-function comparison
Hochreiter & Schmidhuber 1997 (LSTM) Long short-term memory Recurrent backbone the Transformer displaces
Hochreiter et al. 2001 Vanishing gradients in RNNs Motivates short path length argument
Gehring et al. 2017 (ConvS2S) Convolutional seq2seq Direct convolutional baseline in Table 2
Wu et al. 2016 (GNMT) Deep LSTM NMT with RL Recurrent baseline in Table 2
Shazeer et al. 2017 (MoE) Sparsely gated mixture of experts Recurrent baseline in Table 2
Kaiser & Bengio (Extended Neural GPU); ByteNet CNN-based sequence models Convolutional reduction of sequential computation

Cross-Cutting Take-Aways

Take-away Derived from
Recurrence is unnecessary for sequence transduction quality Sec. 1, Sec. 6 BLEU results
Constant-length attention paths help long-range dependency learning Sec. 4, Table 1
Multi-Head Attention recovers what averaging in single-head loses Sec. 3.2.2, Table 3 row A
The \(1/\sqrt{d_k}\) scale matters at large \(d_k\) to keep softmax in well-conditioned region Sec. 3.2.1
Sinusoidal vs learned positional encodings perform nearly identically Sec. 3.5, Table 3 row E
Big > Base; dropout is decisive for the big model Sec. 6.2, Table 3 rows C-D
Transformer generalizes beyond MT (constituency parsing) Sec. 6.3
Training cost is significantly lower than competing recurrent/convolutional SOTA at equal-or-better BLEU Sec. 6.1