papers / transformer2017
Next task →
Research Papers/Transformer and LLM pretraining/Attention Is All You Need
Transformer and LLM pretraining · #1 · seminal

Attention Is All You Need

Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones et al. · 2017 · NeurIPS
reproduction difficulty: mediumTransformersNLPArchitecture

1. Research problem

Sequence transduction relied on recurrent or convolutional layers, which serialize computation and make long-range dependencies hard to parallelize.

2. Motivation

The authors wanted a model based entirely on attention so that all positions can be processed in parallel and dependencies can be connected in a constant number of steps.

3. Previous approaches

Bahdanau and Luong attention improved RNN encoder-decoders but kept recurrent computation; convolutional seq2seq models needed many layers for global receptive fields.

4. Core contribution

Introduced the Transformer: stacked multi-head self-attention, position-wise feedforward layers, residual connections, layer normalization, and positional encoding, with no recurrence or convolution.

5. Mathematical formulation

Attention(Q,K,V) = softmax(QK^T / sqrt(d_k))V; multiple heads attend in parallel subspaces, and encoder-decoder attention connects the two stacks.

6. Methodology

Define the architecture, train with Adam and a warmup learning-rate schedule, apply dropout and label smoothing, and evaluate on translation.

7. Architecture

Six-layer encoder and decoder stacks, 8 attention heads, 512 model dimension, 2048 feedforward dimension, sinusoidal positional encodings.

8. Experimental setup

WMT 2014 English-German and English-French translation plus English constituency parsing.

9. Datasets

WMT 2014 translation corpora, Penn Treebank for parsing.

10. Results

28.4 BLEU on English-German with a fraction of prior training cost, plus strong parsing results, establishing the dominant architecture for modern NLP.

11. Limitations

Self-attention is quadratic in sequence length; positional encodings and lack of recurrence can limit extrapolation to longer sequences.

12. Critical analysis

Its real novelty is the removal of sequence-order bottlenecks, enabling the scale that produced large language models; many details were borrowed and refined from prior attention work.

13. Implementation tasks

  • 1.Implement scaled dot-product and multi-head attention from scratch and compare with a framework implementation.
  • 2.Train a tiny Transformer on a synthetic sequence task and verify permutation handling via positional encodings.
  • 3.Profile attention memory as sequence length grows and implement a simple causal mask.

14. Follow-up work

  • 1.BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding (Devlin et al., 2018)
  • 2.Language Models are Few-Shot Learners (Brown et al., 2020)

15. Open research questions

  • 1.What role do individual attention heads actually play?
  • 2.How can full attention be approximated for very long contexts?
16. Reproduce it. Record the hypothesis, configuration, dataset, metrics and discrepancies in the Experiment Tracker. A reproduction is not complete until you have run the experiments, performed at least one ablation and documented the differences from the reported numbers.