AI State of the Art
Ecosystem/Annotated Foundational Papers/13 min
Section 296

"Attention Is All You Need" (2017)

Listen as a podcast →

The Paper That Changed Everything

June 2017. Google Brain. Eight researchers publish a paper with a catchy title: "Attention Is All You Need." The idea is bold: completely abandon recurrent networks (RNNs/LSTMs) that had dominated language processing for years, and replace them with a single mechanism, attention.

The result: the Transformer. The architecture from which all modern AI models descend. GPT, Claude, Gemini, LLaMA, DALL-E, Stable Diffusion, Sora, AlphaFold. All of them are Transformers or variants.

With over 130,000 citations, it's probably the most influential paper of the decade in computer science, and possibly in the history of artificial intelligence.

Why it's revolutionary

Before the Transformer, recurrent networks (RNNs/LSTMs) processed words one at a time, sequentially. Word 1, then word 2, then word 3. It was slow and long-range dependencies (understanding that a word at the beginning of a sentence relates to a word at the end) degraded. The Transformer processes all words in parallel. Every word directly "sees" all others. Training became 10 to 100x faster, and understanding of long-range relationships improved dramatically.

The Context: Why RNNs Were No Longer Enough

In 2017, NLP (Natural Language Processing) relied on recurrent networks: RNNs, LSTMs, GRUs. These architectures had two fundamental problems:

Sequential processing prevents parallelization. An LSTM processes word 5 only after processing words 1, 2, 3, and 4. On a GPU with thousands of compute cores, most sit idle. It's a massive waste of power.

Long-range dependencies degrade. Despite LSTMs' forget gates (designed precisely for this problem), information degrades when it has to travel through dozens or hundreds of time steps. In a 100-word sentence, the model struggles to connect word 3 to word 97.

The Transformer solves both problems at once.

Key Contributions of the Paper

1. Encoder-Decoder Architecture Without Recurrence

The Transformer eliminates all recurrence. It processes all tokens in parallel via the attention mechanism. The original architecture divides into two parts: an encoder that encodes the input sequence into internal representations, and a decoder that generates the output sequence autoregressively (token by token).

The analogy: imagine a human translator. The encoder reads and understands the entire source sentence at once. The decoder produces the translation word by word, consulting its understanding of the source sentence.

2. Scaled Dot-Product Attention

The heart of the Transformer. The attention formula:

Attention(Q,K,V)=softmax(QKTdk)V\text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right) V

In intuitive terms: each token (via its Query) "asks" other tokens (via their Keys) "how relevant are you to me?" The answers are weighted, and useful information (the Values) is aggregated accordingly.

The scaling factor dk\sqrt{d_k} is crucial: without it, dot products become very large for high dimensions, making the softmax too "sharp" (one token dominates the others) and destabilizing gradients.

3. Multi-Head Attention

Instead of a single attention mechanism, the model uses h heads in parallel (8 in the original paper), each with its own linear projections for Q, K, and V.

Why? Because a word can relate to other words in different ways. "The cat sleeps on the mat": one head can capture the subject-verb relationship (cat-sleeps), another the spatial relationship (sleeps-on-mat), a third the grammatical relationships. Each head specializes in a different type of relationship.

Figure 4 of the Attention Is All You Need paper. On top, the sentence The Law will never be perfect, but its application should be just, this is what we are missing, in my opinion, with its words connected by a dense bundle of purple lines representing all the attention weights of head 5 in layer 5. Below, the same sentence showing only the links leaving the word its: two sharp lines point to Law and to application.
The authors looked at what individual heads were doing. Here two heads in layer 5 appear to resolve anaphora: the word its points very sharply at Law, the antecedent it refers to. This is a concrete illustration of the head specialization described above.Source : Attention Is All You Need paper (figure 4, Vaswani et al., 2017)

4. Positional Encoding

Without recurrence, the model has no notion of order. The words "the cat eats the mouse" and "the mouse eats the cat" would produce the same representations. To solve this, sinusoidal positional encodings are added to each token's embeddings, encoding its position in the sequence.

The sine and cosine functions at different frequencies allow the model to distinguish absolute positions and learn relative distance relationships between tokens.

Heatmap of sinusoidal position encodings. The vertical axis is the token position from 0 to about 95, the horizontal axis is the dimension from 0 to 63, and values run from minus 1 in blue to plus 1 in red. On the left, low-dimension columns alternate very quickly between blue and red; towards the right the bands grow wider until they become uniform columns.
Each row is the signature of one position, each column a different frequency. The left-hand dimensions oscillate fast and separate neighbouring positions, the right-hand ones oscillate slowly and give position at a coarse scale. That mix of frequencies is what makes every position unique and distances comparable.Source : Michael Brenndoerfer, Sinusoidal Position Encoding

5. Feed-Forward Networks and Residual Connections

Each Transformer layer contains, in addition to attention, a feed-forward network (FFN): two linear layers with a ReLU activation in between. This FFN is applied independently to each position and is where the model stores much of its "knowledge."

Residual connections (the input is added to the output of each sub-layer) and Layer Normalization surround each sub-layer. These mechanisms are essential for training stability, especially when stacking many layers.

The magic recipe for scaling

The combination of attention + residual connections + layer normalization + FFN is the recipe that enabled scaling to billions of parameters. Each component is simple individually. But their combination creates an architecture that's remarkably scalable and stable to train. This is what distinguishes the Transformer from previous architectures that became unstable beyond a few dozen layers.

Results of the Original Paper

The original Transformer was evaluated on machine translation (it was a translation model, not a chatbot):

  • WMT 2014 English-German (WMT = Workshop on Machine Translation, the reference translation competition): 28.4 BLEU (BLEU = Bilingual Evaluation Understudy, a metric that compares n-grams of the translation to those of the reference), best score, +2.0 BLEU over the state of the art
  • WMT 2014 English-French: 41.8 BLEU (best score with reduced training cost)
  • Training on 8 P100 GPUs for 3.5 days for the base model

By today's standards (thousands of GPUs for months), that's tiny. But the results were the best ever achieved on those tasks.

The Legacy: Three Architectural Families

The Transformer spawned three families of models, each using a different part of the architecture:

  • Encoder-only (BERT, RoBERTa): for text understanding. Classification, entity extraction, sentiment analysis. Uses bidirectional attention.
  • Decoder-only (GPT, Claude, LLaMA): for text generation. This is the dominant family today. Uses causal (masked) attention.
  • Encoder-decoder (T5, BART, the original Transformer): for transformation tasks (translation, summarization). Less used today.

The decoder-only victory wasn't obvious in 2017. It was scaling (GPT-2, GPT-3) that showed autoregressive generation was the most promising paradigm.

Beyond NLP: The Transformer Conquers Everything

The most remarkable aspect of the Transformer is its universality. The architecture has extended to nearly every domain of AI:

  • Vision: ViT (Vision Transformer), DINO, SAM (Segment Anything). Images are cut into "patches" treated as tokens.
  • Audio: Whisper (speech recognition), MusicGen. Sound is tokenized and processed like text.
  • Video: Sora (OpenAI), VideoGPT. Spatiotemporal patches replace text tokens.
  • Biology: AlphaFold (Evoformer). Protein sequences are tokens, and attention captures 3D structural relationships.
  • Robotics: RT-2, VLA models. Robotic actions become tokens in an action vocabulary.

The Transformer has become the "universal" architecture of AI, a sort of internal combustion engine of artificial intelligence.

The 8 authors: remarkable trajectories

The 8 authors of the paper have become major figures in AI. Several founded companies: Noam Shazeer co-founded Character.AI (then returned to Google for a record amount), Aidan Gomez co-founded Cohere (specializing in enterprise AI), Illia Polosukhin co-founded NEAR Protocol (blockchain). The others remained in research at Google or joined other leading labs.

What the paper doesn't predict

The original paper focuses on machine translation. It mentions neither the Transformer's potential for large-scale text generation, nor multimodality, nor reasoning, nor emergent capabilities. The explosion of capabilities with scaling (GPT-3 and beyond) was not anticipated by the authors themselves. The Transformer was designed as a better translation model. It became the foundation of all modern AI.