Skip to content
HARBAN AI LABS

Paper breakdown

Attention Is All You Need: the architecture behind modern language models

A technical reading of the 2017 paper that replaced recurrence with self-attention — what the Transformer does, why it trains faster, and what the paper did and did not show.
Author
HARBAN AI LABS
Published
Reading time
3 min read

The paper

Attention Is All You Need

Authors
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin
Year
2017
Checked against source
28 Sept 2026

TL;DR

The paper proposes the Transformer, a sequence-to-sequence model that drops recurrence and convolution entirely and relies only on attention. Because every position can attend to every other position in a single step, the model trains with far more parallelism than a recurrent network. On the two machine-translation benchmarks the authors used, it matched or beat the best published systems at a fraction of the training cost.

The problem

In 2017, the dominant translation systems were encoder–decoder networks built from recurrent layers (LSTMs or GRUs) or from convolutions, usually with an attention mechanism connecting encoder and decoder. In the paper's own comparison (Table 2), the best earlier ensembles came from a convolutional model (ConvS2S), just ahead of Google's recurrent GNMT; the best earlier single model was a mixture-of-experts model (MoE). Both designs have a structural cost. In a recurrent network, computing the hidden state at position tt needs the state at t−1t-1; that sequential dependency limits parallelism within a training example, which matters more as sequences get longer. In a convolutional one, the number of operations needed to relate two positions grows with the distance between them, which the authors argue makes long-range dependencies harder to learn.

The authors asked whether attention — previously an add-on to recurrent models — could do the whole job.

The method

Scaled dot-product attention

Each token is projected into a query, a key and a value. A token's output is a weighted sum of all values, where the weights come from how well its query matches every key:

Attention⁡(Q,K,V)=softmax⁡ ⁣(QK⊤dk)V\operatorname{Attention}(Q, K, V) = \operatorname{softmax}\!\left(\frac{QK^\top}{\sqrt{d_k}}\right)V

The division by dk\sqrt{d_k} keeps dot products from growing with the key dimension, which would otherwise push the softmax into regions with very small gradients.

Multi-head attention

Instead of one attention function, the model runs several in parallel ("heads"), each with its own learned projections, then concatenates the results. Different heads can specialise in different relationships between positions. The base model uses 8 heads.

The rest of the block

Each layer combines attention with a position-wise feed-forward network, residual connections and layer normalisation. The encoder and decoder are each a stack of these layers (6 in the base model). The decoder's self-attention is masked so a position cannot attend to later positions — preserving the left-to-right generation needed for translation.

Positional information

Attention on its own is order-agnostic: shuffling the input would shuffle the output identically. To give the model a sense of order, the authors add positional encodings — fixed sinusoids of different frequencies — to the input embeddings.

What the paper reports

The headline results, as reported by the authors in the abstract:

TaskResult reported
WMT 2014 English→German28.4 BLEU, "improving over the existing best results, including ensembles, by over 2 BLEU"
WMT 2014 English→French41.8 BLEU, a new single-model state of the art, "after training for 3.5 days on eight GPUs"

The authors also applied the architecture to English constituency parsing to show it generalises beyond translation.

These are the authors' own measurements under their own setup. BLEU scores are sensitive to tokenisation and evaluation details, so they are best compared within the same paper rather than across papers.

Why it mattered

The architecture's parallelism made it practical to train much larger models on much more data. Later model families adopted it as their backbone — for example BERT (Devlin et al., 2018 (external site)) used the encoder side, and GPT-3 (Brown et al., 2020 (external site)) used a decoder-only variant.

Limitations and open questions

  • Quadratic cost in sequence length. Every position attends to every other, so compute and memory for attention grow with the square of the sequence length. Much later work focuses on reducing this cost.
  • Narrow evaluation. The paper's evidence is two translation benchmarks plus parsing. The broader claims people make about Transformers come from later work, not from this paper.
  • Positional encoding choices. The paper uses fixed sinusoidal encodings and reports that learned embeddings performed similarly; how best to represent position remained an active research question.

Reading notes for practitioners

If you are building on Transformer-based models today, the ideas from this paper that most often matter in practice are: attention cost grows quadratically with context length; masking determines what a model can "see"; and positional representation limits how well a model handles sequences longer than those it was trained on.

This breakdown summarises and explains the paper in our own words. Numbers quoted from the paper are the authors’ reported results, checked against the source on 28 Sept 2026. For exact claims, read the original.

Corrections

  1. Corrected “The problem”: the strongest pre-Transformer translation systems in the paper’s Table 2 were convolutional (ConvS2S) as well as recurrent (GNMT), not recurrent only.
  2. Clarified “The problem”: in the paper’s Table 2, ConvS2S and GNMT were the strongest earlier ensembles; the strongest earlier single model was a mixture-of-experts model (MoE).

Cite this page

HARBAN AI LABS (2026). “Attention Is All You Need: the architecture behind modern language models”. HARBAN AI LABS. https://harban-ai-labs.vercel.app/research/attention-is-all-you-need

@misc{harban2026attentionisallyouneed,
  author = {HARBAN AI LABS},
  title = {Attention Is All You Need: the architecture behind modern language models},
  year = {2026},
  publisher = {HARBAN AI LABS},
  url = {https://harban-ai-labs.vercel.app/research/attention-is-all-you-need}
}

Report an issue with this page

Spotted a wrong number, a broken source or something out of date in “Attention Is All You Need: the architecture behind modern language models”? Tell us what and, if you can, link the correct source.

Required. At least 10 characters.

Model registry/models
Benchmarks/benchmarks
Paper breakdowns/research
AI tools directory/tools
Work with us/work-with-us