Reading as:
● Paper Breakdown · NeurIPS 2017

Attention Is All You Need — The Story of How Robots Learned to Really Listen Attention Is All You Need — The Paper That Rewired How AI Reads Attention Is All You Need
— explained for people who've never seen it before
Attention Is All You Need: Annotated Technical Reference

A long time ago (in computer years — 2017!), translation programs had to read one word at a time, like reading a book through a tiny window that shows only one word at once. A team at Google built a new kind of computer brain that looks at a whole sentence at once and figures out which words matter most to each other. They called this trick "attention," and it changed how nearly every smart computer program works today — including the one talking to you right now. In 2017, a team at Google Brain and Google Research published a translation paper that dropped two techniques everyone assumed you needed — recurrent networks and convolutions — and replaced them with just one mechanism: attention. The result, called the Transformer, translated better than anything before it, trained way faster, and became the direct ancestor of GPT, BERT, and Claude. Vaswani, Shazeer, Parmar, Uszkoreit, Jones, Gomez, Kaiser & Polosukhin (Google Brain / Google Research / U. Toronto) introduced the Transformer: a translation model built entirely out of attention, with no recurrence and no convolution. It is the architecture behind essentially every modern large language model, including the one generating this guide. This guide provides a structured technical walkthrough of Vaswani et al. (2017): the scaled dot-product and multi-head attention formulations, encoder–decoder composition, complexity analysis relative to recurrent/convolutional alternatives, training configuration, and empirical results on WMT14 En-De/En-Fr translation and English constituency parsing.

📄 arXiv:1706.03762 🏆 28.4 BLEU (EN→DE), new SOTA ⚡ Trained in 12 hrs–3.5 days on 8 GPUs 🧩 8 authors, "equal contribution, random order"

Try it — click a word to see what it "attends to"

Tap a word and watch bars pop up for every other word — a taller bar means the robot is paying more attention to that word! Click a word to see a simplified example of "attention weights" — how much each other word in the sentence matters to the one you clicked. This is a simplified, illustrative attention pattern (not the model's real trained weights) to build intuition for Section 3.2. Illustrative, non-trained attention-weight visualization for pedagogical purposes; real trained heads tend to be sparser and more specialized (see Section 8, interpretability discussion).

01 · The Problem

Why Old Robots Were Slow Readers The Problem With Reading One Word at a Time Why did we need a new architecture? Motivating the Elimination of Recurrence and Convolution

Before this paper, computer translators worked like a kid reading a book while covering up every word except one, sliding the cover along one word at a time. They had to finish thinking about word 1 before even starting on word 2. That's called a "recurrent neural network." It worked okay, but it was slow, and by the end of a long sentence it sometimes half-forgot what happened at the beginning — like a game of telephone.

Before 2017, top translation systems used Recurrent Neural Networks (RNNs) — especially LSTMs — often paired with an attention add-on. RNNs process a sentence one word at a time, updating a running "memory" as they go. The catch: word 50 can't be processed until words 1–49 are done, so training can't be parallelized across a sequence. Information from early words also has to survive a long chain of steps to reach later ones, and tends to fade along the way.

Before 2017, the best machine translation systems were built on recurrent neural networks (RNNs) — especially LSTMs and GRUs — often paired with an attention mechanism layered on top. These models read a sentence one word at a time, carrying a "memory" (hidden state) forward from word to word.

Prior state-of-the-art sequence transduction models were dominated by recurrent architectures (LSTM/GRU) with an attached attention mechanism connecting encoder and decoder. Recurrent models factor computation along input/output symbol positions, generating hidden state h_t as a function of h_{t-1} and the input at position t — an inherently sequential dependency.

Problem #1: One Word at a Time Is Slow Bottleneck: Sequential Computation The bottleneck: sequential computation Constraint: strictly sequential hidden-state computation

To figure out word 50, the robot needs word 49's answer first — and that needed word 48's answer, all the way back to word 1. It's stuck in a single-file line and can't work on many words at once.

To compute hidden state h_t, an RNN needs h_{t-1} first, so word 50 can't start until word 49 finishes. This makes RNNs impossible to fully parallelize during training — painful for long sequences and big datasets.

To compute hidden state h_t, an RNN needs h_{t-1} first. Word 50 can't be processed until words 1–49 are done. This makes RNNs impossible to fully parallelize during training, which is brutal for long sequences and large datasets — you're stuck waiting.

This inherently sequential nature precludes parallelization within training examples, which becomes critical at longer sequence lengths, as memory constraints limit batching across examples — a hard architectural ceiling on training throughput regardless of available compute.

Problem #2: Forgetting Things From Far Away Bottleneck: Long-Range Dependencies The bottleneck: long-range dependencies Constraint: degraded long-range dependency propagation

Imagine whispering a message down a line of 50 kids. By the time it reaches the last kid, it's garbled. That's what happens to information from the start of a long sentence by the time an old-style robot reaches the end.

Even with LSTMs' gating tricks, information about word 1 has to travel through 49 sequential steps to influence word 50 — like a message passed down a long line of people, it gets fuzzier with distance.

Even with LSTMs' gating tricks, information about word 1 has to travel through 49 sequential steps to influence word 50. Signal degrades over distance — like a message passed down a long line of people, it gets fuzzier the further it travels.

The length of the forward/backward signal path between arbitrary positions directly affects the ability to learn long-range dependencies; recurrent architectures impose an O(n) path length, which compounds gradient decay/instability over long sequences.

The big idea: instead of reading one word at a time, why not let the robot look at the whole sentence at once and decide for itself which words matter to which? That's the bet this paper makes — and it pays off. The paper's core bet: replace recurrence entirely with an attention mechanism that draws connections between any two words directly, no matter how far apart — allowing much more parallel computation and faster training. The paper's core bet: this work proposes the Transformer, a model architecture eschewing recurrence and instead relying entirely on an attention mechanism to draw global dependencies between input and output, allowing far more parallelization and reaching state-of-the-art translation quality after training for as little as twelve hours on eight P100 GPUs. Core contribution: a model architecture eschewing recurrence and convolution entirely, relying solely on attention to draw global input–output dependencies, enabling significantly more parallelization and reaching SOTA translation quality after only twelve hours of training on eight P100 GPUs.

Why This Matters for You Why This Matters Beyond Translation Why this matters beyond translation Broader Significance

Letting a computer look at everything at once instead of one word at a time meant it could learn from WAY more books and websites, WAY faster. That's a big reason chatbots like Claude got so good, so fast.

Removing the one-word-at-a-time limit didn't just speed up training — it changed what was computationally realistic. Once a whole sequence can be processed in parallel, you can train on far more data with far more compute. That scaling recipe directly led to GPT, BERT, and Claude.

Removing the sequential constraint didn't just make training faster — it changed what was computationally feasible. Once you can process an entire sequence in parallel, you can train on vastly more data with vastly more compute. That scaling recipe is the direct ancestor of GPT, BERT, Claude, and virtually every modern language model.

Eliminating the sequential dependency was the structural precondition for later scaling-law-driven research: parallel training across positions is what made training runs on web-scale corpora with billions to trillions of parameters computationally tractable within realistic wall-clock budgets.

02 · Background Concepts

Words You Need to Know First Some Vocabulary Before We Dive In Everything you need before Section 3 Formal Preliminaries

What does "turning one thing into another sequence" mean? What is "sequence transduction"? What is "sequence transduction"? Sequence transduction, formally

It just means turning one list of things into another list of things — like turning an English sentence into a German sentence, one word list into another word list.

Any task that maps one sequence to another: English sentence → German sentence, audio → text, or sentence → grammar tree. The Transformer is a general sequence-to-sequence tool, mainly demonstrated on translation.

Any task that maps one sequence to another: English sentence → German sentence, audio → text, or a sentence → its grammar tree. The Transformer is a general sequence-to-sequence tool, demonstrated primarily on translation.

The task of mapping an input sequence to an output sequence, generally of differing length and possibly differing modality — translation, ASR transcription, and constituency parsing are all instances.

Two Halves: the Reader and the Writer Encoder–decoder architecture Encoder–decoder architecture Encoder–decoder decomposition

Most translators have two parts: a "reader" (encoder) that reads the whole input sentence, and a "writer" (decoder) that writes the output sentence one word at a time, using what the reader understood.

The encoder reads the full source sentence and turns it into vector representations. The decoder then generates the output sentence one token at a time, looking at both the encoder's output and whatever it has written so far.

The encoder reads the full source sentence (x₁,...,xₙ) and turns it into a sequence of continuous vector representations z = (z₁,...,zₙ). The decoder then generates the output sentence (y₁,...,yₘ) one token at a time, looking at both z and whatever it has generated so far — this is called being auto-regressive.

The encoder maps (x₁,...,xₙ) → z=(z₁,...,zₙ); given z, the decoder generates (y₁,...,yₘ) one element at a time, auto-regressively consuming previously generated symbols as additional input at each step.

What is "attention," really? What is "attention," in general? What is "attention," in general? The general attention function

It's a way for the robot to look at everything and decide, "how much should I care about each thing?" — then blend them together based on how much it cares.

A mechanism that lets the model weigh how relevant different parts of the input are to the part it's currently working on, then produces a blend of that information based on relevance.

An attention function can be described as mapping a query and a set of key-value pairs to an output, where the output is a weighted sum of the values — and the weight on each value is decided by how well its key matches the query. Think of it as a smart, differentiable lookup table: instead of retrieving one exact match, you retrieve a blend of everything, weighted by relevance.

Formally, an attention function maps a query and a set of key–value pairs to an output vector, computed as a weighted sum of values, with weights derived from a compatibility function between the query and each key.

"Self"-Attention — Paying Attention to Your Own Sentence Self-attention vs. "regular" attention Self-attention vs. "regular" attention Self-attention vs. inter-sequence attention

Normally attention connects the output sentence back to the input sentence. "Self"-attention is when a sentence pays attention to its OWN words — like each word checking in with every other word in the same sentence.

In earlier models, attention connected the decoder back to the encoder. Self-attention instead relates positions within the same sequence — every word attends to every other word in its own sentence to build a richer representation.

In earlier seq2seq models, attention connected the decoder to the encoder (looking "across" from output back to input). Self-attention instead relates different positions of the same sequence to each other — every word attends to every other word in its own sentence to build a context-aware representation.

Self-attention (intra-attention) relates positions within a single sequence to compute a representation of that sequence, as opposed to encoder-decoder attention which relates positions across two distinct sequences.

Word Vectors & Why Order Matters Word embeddings & why order needs special handling Word embeddings & why order needs special handling Embeddings and the order-invariance problem

Computers turn words into lists of numbers ("embeddings") to represent their meaning. Old robots got word order for free since they read one word after another. This new model doesn't naturally know word order, so it has to be told directly.

Words are converted into number vectors (embeddings) capturing meaning. RNNs get word order "for free" from reading in sequence. A model built purely from attention has no built-in sense of order — it treats input as an unordered set — so order must be added explicitly.

Words are converted into dense numeric vectors (embeddings) that capture meaning. RNNs get word order "for free" because they process tokens in sequence. A model built purely from attention has no built-in sense of order — attention treats input as an unordered set of vectors — so the Transformer has to inject order information explicitly (see Positional Encoding, Section 3.5).

Self-attention is permutation-invariant by construction; without explicit order information, the model cannot distinguish sequence permutations. This motivates the additive positional encoding scheme detailed in §3.5.

How Do We Know If a Translation Is Good? (BLEU) BLEU score, briefly BLEU score, briefly BLEU as an evaluation metric

BLEU is basically a grade (0–100) for how close a robot's translation is to what a human would write. Higher is better.

BLEU (Bilingual Evaluation Understudy) scores translations by comparing word-chunk overlap with human reference translations, on a 0–100 scale. Higher is better. It's the paper's main quality measure.

BLEU (Bilingual Evaluation Understudy) scores machine translations by comparing n-gram overlap with human reference translations, from 0 to 100. It's the paper's primary quality metric — higher is better. A jump of "+2 BLEU" over prior state-of-the-art is considered a substantial improvement in MT research.

BLEU computes a modified n-gram precision between candidate and reference translations, combined with a brevity penalty. It remains the paper's primary reported metric despite known limitations (insensitivity to fluency/semantics beyond n-gram overlap).

What Other Robots Tried Before This One What came before: ByteNet, ConvS2S, and the CNN alternative What came before: ByteNet, ConvS2S, and the CNN alternative Prior parallelizable alternatives: convolutional approaches

Other scientists tried using a different trick (convolutions, like the ones that help computers recognize pictures) to avoid the one-word-at-a-time problem. It helped, but words far apart still had a hard time "hearing" each other.

Other researchers tried escaping RNN sequentiality with convolutional networks (ByteNet, ConvS2S), which compute in parallel. But the number of operations needed to relate two distant positions still grows with distance — linearly for ConvS2S, logarithmically for ByteNet — so distant relationships remained harder to learn than with the Transformer's constant-time connections.

Other researchers tried to escape RNN sequentiality using convolutional networks (ByteNet, ConvS2S), which do compute in parallel. But the number of operations required to relate signals from two arbitrary input or output positions grows in the distance between positions — linearly for ConvS2S, logarithmically for ByteNet — still making distant relationships harder to learn than the Transformer's constant-time connections.

Extended Neural GPU, ByteNet, and ConvS2S all use convolutions as the parallelizable building block; however, relating distant positions requires O(n) or O(log n) operations depending on architecture, versus O(1) for self-attention — motivating multi-head attention as a mechanism to recover the resolution lost from averaging attention-weighted positions.

03 · Model Architecture

How the Robot Is Built, Like LEGO Blocks Inside the Transformer: The Big Picture How the Transformer is built Architectural Specification: Encoder–Decoder Composition

The Transformer still has a "reader" half and a "writer" half, like older translators — but instead of reading one word at a time, both halves are built from stacked layers of "who should I pay attention to" blocks and simple thinking blocks.

The Transformer keeps the encoder–decoder shape but throws out recurrence entirely, replacing it with stacked layers of self-attention and simple feed-forward networks.

The Transformer keeps the encoder–decoder skeleton but throws out recurrence entirely, replacing it with stacked layers of self-attention and simple feed-forward networks.

The architecture retains the general encoder–decoder structure common to competitive sequence transduction models, but composes each stack entirely from self-attention and point-wise fully connected sub-layers, each wrapped in residual connections and layer normalization.

Input tokens                              Output tokens (shifted right)
     │                                              │
Input Embedding + Positional Encoding      Output Embedding + Positional Encoding
     │                                              │
┌────▼────────────┐                        ┌────────▼─────────┐
│   ENCODER (×N=6) │ ─── encoder output ──▶ │   DECODER (×N=6)  │
│  Multi-Head       │                       │  Masked Multi-Head │
│  Self-Attention    │                       │  Self-Attention    │
│  + Add & Norm       │                       │  + Add & Norm       │
│  Feed-Forward         │                       │  Encoder-Decoder     │
│  + Add & Norm           │                       │  Attention             │
└──────────────────────┘                       │  + Add & Norm             │
                                                │  Feed-Forward               │
                                                │  + Add & Norm                 │
                                                └────────────┬──────────────────┘
                                                              │
                                                    Linear + Softmax
                                                              │
                                                  Output token probabilities
  
Encoder layer
×N = 6 identical layers
Multi-Head Self-Attention
Residual Add + LayerNorm
Position-wise Feed-Forward
Residual Add + LayerNorm
Decoder layer
×N = 6 identical layers
Masked Multi-Head Self-Attention
Residual Add + LayerNorm
Encoder–Decoder Attention
Residual Add + LayerNorm
Position-wise Feed-Forward
Residual Add + LayerNorm

The Reader (Encoder) Encoder Encoder Encoder

Made of 6 identical "reading layers" stacked on top of each other. Each layer first lets every word check in with every other word (self-attention), then does some extra thinking (feed-forward), with little "keep the original info too" shortcuts (residuals) at each step.

A stack of 6 identical layers. Each has two parts: multi-head self-attention, then a feed-forward network. Every part is wrapped in a shortcut connection (residual) plus normalization, keeping outputs at a consistent size of 512 numbers per word (d_model = 512).

A stack of N = 6 identical layers. Each has two sub-layers: multi-head self-attention, then a position-wise feed-forward network. Every sub-layer is wrapped in a residual connection followed by layer normalization: LayerNorm(x + Sublayer(x)). All sub-layers (and the embeddings) output vectors of dimension d_model = 512 so the residual additions line up.

N = 6 identical layers, each with two sub-layers (multi-head self-attention; position-wise FFN), each wrapped as LayerNorm(x + Sublayer(x)). All sub-layers and embedding layers output d_model = 512 to enable the residual additions.

The Writer (Decoder) Decoder Decoder Decoder

Also 6 layers, but each one gets an extra step: peeking at what the Reader understood. It's also not allowed to peek ahead at words it hasn't written yet — that would be cheating!

Also 6 layers, but each layer adds a third part: attention over the encoder's output. The decoder's self-attention is "masked" so it can't look ahead at future words it hasn't generated yet — otherwise it would be cheating during training.

Also N = 6 layers, but each layer gets a third sub-layer: encoder–decoder attention over the encoder's output. The decoder's self-attention is masked so position i cannot look at positions after i — combined with shifting outputs right by one position, this preserves the auto-regressive property: predictions can only depend on already-known outputs.

N = 6 layers, each inserting a third sub-layer performing multi-head attention over encoder output. Decoder self-attention is masked (illegal connections set to −∞ pre-softmax) to prevent leftward information flow, preserving the auto-regressive property given the output-embedding right-shift.

Why the shortcuts (residuals) everywhere? With 6 layers stacked up, information can get lost or distorted along the way. Residuals are like sticky notes that say "don't forget the original version too" — they help the robot learn properly even when it's this deep. Why residual connections + normalization everywhere? They let gradients flow directly through a 6-layer-deep stack during training (avoiding the "vanishing gradient" problem) and keep the numbers at each layer in a stable, consistent range. Why residual connections + LayerNorm everywhere? Residual connections let gradients flow directly through the network (avoiding vanishing gradients in a 6-layer-deep stack), and LayerNorm keeps activations stable across layers — a pattern borrowed from prior deep learning work but essential to making this specific architecture trainable at depth. Design rationale: residual connections mitigate vanishing gradients across a 6-layer-deep stack per side, while LayerNorm stabilizes activation statistics between sub-layers — both standard deep-learning techniques repurposed here as load-bearing components of trainability at this depth.
04 · Attention Mechanism

The "Who Should I Listen To?" Trick How Attention Actually Works Scaled Dot-Product Attention & Multi-Head Attention Formal Treatment: Scaled Dot-Product and Multi-Head Attention

3.2.1 — The Basic "Who Matters?" Math 3.2.1 — Scaled Dot-Product Attention 3.2.1 — Scaled Dot-Product Attention 3.2.1 — Scaled Dot-Product Attention

Every attention step uses three things made from the input: a Question (Query), a Label (Key), and an Answer (Value). It's like: "What am I looking for?" (Query), "What do I have to offer?" (Key), and "Here's my actual info if you want it" (Value).

Every attention computation involves three learned versions of the input: Queries (Q), Keys (K), and Values (V). A Query is "what am I looking for," a Key is "what do I contain," and a Value is "what I actually offer if you find me relevant."

Every attention computation involves three learned projections of the input: Queries (Q), Keys (K), and Values (V). Intuitively: a Query is "what am I looking for," a Key is "what do I contain," and a Value is "what do I actually offer if you find me relevant."

Each attention operation projects the input into three learned representations — Queries, Keys, Values — via distinct linear maps; the output is a convex combination of Values, weighted by a compatibility function between Query and Key.

Attention(Q, K, V) = softmax( QKᵀ / √d_k ) · V
// Q, K, V are matrices packing many queries/keys/values as rows; d_k = dimension of the keys
SymbolMeaningShape (per head, this paper)
QQuery matrix — what each position is "asking for"n × d_k
KKey matrix — what each position "offers to match against"n × d_k
VValue matrix — the actual content retrievedn × d_v
QKᵀRaw similarity score between every query and every key (dot product)n × n
√d_kScaling factor that prevents dot products from growing too largescalar
softmax(·)Turns scores into a probability distribution (attention weights) per rown × n
Why divide by √d_k? If the model uses really big numbers, the "who matters more" step (softmax) can get too extreme and stop learning well — like a microphone turned up so loud it just screeches instead of playing music. Dividing keeps the volume just right. Why divide by √d_k? As the size of Q and K vectors (d_k) grows, their dot products tend to grow too, which pushes softmax toward regions with almost no useful gradient — making learning stall. Scaling by √d_k keeps the numbers in a healthy range. Why divide by √d_k at all? To illustrate why the dot products get large, assume that the components of q and k are independent random variables with mean 0 and variance 1. Then their dot product... has mean 0 and variance d_k. As d_k grows, dot products grow in magnitude and push softmax into regions with tiny gradients, so scaling by √d_k keeps the variance stable at 1 regardless of dimension. Derivation: assuming independent q_i, k_i with mean 0, variance 1, Var(q·k) = Σ Var(q_i k_i) = d_k. Unscaled, dot-product magnitude grows with √d_k in standard deviation, saturating softmax and collapsing gradients; scaling by 1/√d_k normalizes variance to 1 regardless of d_k.

3.2.2 — Eight Brains Instead of One 3.2.2 — Multi-Head Attention 3.2.2 — Multi-Head Attention 3.2.2 — Multi-Head Attention

Instead of doing the "who matters" trick just once, the Transformer does it 8 times at once, each time from a slightly different angle, and then combines all 8 answers. It's like asking 8 different friends what they noticed about the same sentence, then putting all their notes together.

Instead of one attention computation over the full 512-number vectors, the model splits Q, K, V into 8 smaller versions (64 numbers each), runs attention on each in parallel, then combines the 8 results back into 512 numbers.

Instead of one attention computation over the full 512-dimensional vectors, the paper linearly projects Q, K, V into h = 8 different, smaller subspaces (each d_k = d_v = 64), runs scaled dot-product attention in each subspace in parallel, then concatenates and projects the results back to 512 dimensions.

Rather than a single d_model-dimensional attention function, Q, K, V are linearly projected h=8 times into d_k=d_v=64-dimensional subspaces; attention is computed in parallel per subspace, outputs concatenated and re-projected via W^O.

MultiHead(Q, K, V) = Concat(head₁, ..., head_h) · Wᴼ where head_i = Attention(Q·Wᵢᵠ, K·Wᵢᴷ, V·Wᵢⱽ)
// Wᵢᵠ, Wᵢᴷ ∈ ℝ^(d_model×d_k), Wᵢⱽ ∈ ℝ^(d_model×d_v), Wᴼ ∈ ℝ^(h·d_v×d_model)
Why 8 brains instead of 1 big one? One brain averages everything together and can miss details. Eight smaller brains can each notice something different — one might track "who's doing the action," another "which words describe which," and so on. Why multiple heads? A single attention head averages information together, which can wash out useful distinctions. Multiple heads let the model attend to different types of relationships at once — one head might track grammar, another might track meaning. Why multiple heads instead of one big attention? Multi-head attention allows the model to jointly attend to information from different representation subspaces at different positions. With a single attention head, averaging inhibits this. One head might learn to track subject-verb agreement, another might track coreference, another local word order — and because each head works in a lower dimension (64 instead of 512), total compute stays similar to one full-size head. Motivation: a single attention head's weighted averaging inhibits joint attendance to multiple representation subspaces simultaneously; multi-head attention recovers this capacity, at near-equal total compute to one full-dimension head since per-head cost reduction (d_model/h) offsets the head-count increase.

3.2.3 — Three Ways This Trick Gets Used 3.2.3 — Three Uses of Attention in This Model 3.2.3 — Three ways attention is used in this model 3.2.3 — Applications of Attention Within the Model

Reader Self-Check Encoder self-attention Encoder self-attention Encoder self-attention

Every input word gets to look at every other input word — no secrets, full picture.

Q, K, V all come from the previous encoder layer — every input word can attend to every other input word, full context both ways.

Q, K, V all come from the previous encoder layer. Every input word can attend to every other input word — full bidirectional context.

Q, K, V derived from the previous encoder layer's output; every position attends over all positions in that layer, unrestricted (bidirectional).

Writer's No-Peeking Rule Decoder masked self-attention Decoder masked self-attention Decoder masked self-attention

Same idea, but a word can't peek at words that come after it — no cheating by reading ahead!

Same idea, but positions are blocked from attending to future words, preserving the rule that generation only depends on what's already been written.

Same idea, but positions are masked (set to −∞ before softmax) so a word can't attend to future words — preserving auto-regressive generation.

Identical structure with illegal (future) connections masked to −∞ pre-softmax, preserving auto-regressive validity during parallel (teacher-forced) training.

Writer Asking the Reader Questions Encoder–decoder attention Encoder–decoder attention Encoder–decoder attention

The Writer asks Questions, and gets Answers/Labels from the Reader — this is how it decides which input words matter for the word it's writing next.

Queries come from the decoder; Keys and Values come from the encoder's output — every decoder position can look at the entire input sentence, the classic "translation alignment" attention.

Queries come from the decoder; Keys and Values come from the encoder's output. Every decoder position can attend over the entire input sentence — the classic "translation alignment" attention.

Queries sourced from the previous decoder layer; memory Keys/Values sourced from encoder output — mirrors classical seq2seq encoder-decoder attention mechanisms.

05 · Other Building Blocks

The Other LEGO Pieces Feed-Forward Layers, Embeddings & Position Tags Feed-forward, embeddings, and positional encoding Auxiliary Sub-layer Formulations

3.3 — The "Extra Thinking" Step 3.3 — Position-wise Feed-Forward Networks 3.3 — Position-wise Feed-Forward Networks 3.3 — Position-wise Feed-Forward Networks

FFN(x) = max(0, x·W₁ + b₁)·W₂ + b₂

After the "who matters" step, every word gets a private moment of extra thinking — two simple math steps with a "throw away negative numbers" rule (ReLU) in between. Every word gets this exact same treatment, just with its own info plugged in.

Applied identically to every position on its own (think: two small calculations with a ReLU "keep only positives" step in between). Input/output size is 512 numbers; the hidden step in between temporarily expands to 2048 numbers, then shrinks back.

Applied identically and independently to every position (think: two 1×1 convolutions with a ReLU in between). Input/output dimension is d_model = 512; the hidden layer in between expands to d_ff = 2048, then projects back down. Parameters differ from layer to layer even though the same shape is reused at every position within a layer.

Equivalent to two kernel-size-1 convolutions with a ReLU nonlinearity; d_model = 512 in/out, d_ff = 2048 inner dimension; parameters are shared across positions within a layer but distinct across layers.

3.4 — Turning Words Into Numbers 3.4 — Embeddings and Softmax 3.4 — Embeddings and Softmax 3.4 — Embeddings and Softmax

Words get turned into lists of 512 numbers (embeddings) that capture meaning. At the very end, the model uses almost the SAME number-lists in reverse to guess the next word — kind of like using the same dictionary to write a word as to look one up.

Input and output tokens become 512-number vectors via learned embeddings. The model reuses (ties) the same weight table for the input embeddings, output embeddings, and the final prediction layer — and scales embedding values up before adding position info.

Input and output tokens are converted to 512-dimensional vectors via learned embeddings. Notably, the paper ties the input embedding matrix, the output embedding matrix, and the pre-softmax linear layer to share the same weights — and multiplies embedding weights by √d_model before adding positional encodings, to balance their relative scale.

Shared weight matrix across input embeddings, output embeddings, and pre-softmax linear transformation (cf. Press & Wolf-style tying); embedding weights scaled by √d_model prior to summation with positional encodings, balancing relative magnitude.

3.5 — Giving Every Word a Position Tag 3.5 — Positional Encoding 3.5 — Positional Encoding 3.5 — Positional Encoding

Since the model looks at the whole sentence at once, it needs a hint about which word came first, second, third, etc. The paper gives each position its own special "wavy pattern" made from sine and cosine waves, added right onto the word's number-list.

Since attention has no inherent sense of order, position info is injected directly into the embeddings using fixed sine/cosine waves of different frequencies, one unique pattern per position.

Since attention has no inherent sense of order, the model injects position information directly into the embeddings using fixed sine/cosine functions of different frequencies:

Absolute position information is injected additively via fixed sinusoidal functions of varying frequency across the embedding dimension:

PE(pos, 2i) = sin( pos / 10000^(2i/d_model) ) PE(pos, 2i+1) = cos( pos / 10000^(2i/d_model) )
// pos = position in the sequence, i = dimension index
Why sine and cosine waves? Each position gets a unique wave-pattern "fingerprint." The scientists picked waves because there's a neat math trick where the pattern for "5 words later" can always be worked out from the current pattern — which might help the robot understand relative distance, and handle longer sentences than it ever trained on. Why sine and cosine waves? Every dimension is a wave of a different length, so every position gets a unique combined pattern. The authors chose this because a fixed offset between positions can be expressed as a simple transformation of the pattern — possibly helping the model learn relative position and generalize to longer sentences than it trained on. Why sine and cosine waves? The wavelengths form a geometric progression from 2π to 10000·2π. The authors chose this because for any fixed offset k, PE(pos+k) can be expressed as a linear function of PE(pos) — a trigonometric identity — which they hypothesized would help the model learn to attend by relative position, and might allow extrapolation to sequence lengths longer than those seen during training. Rationale: wavelengths form a geometric progression from 2π to 10000·2π; for fixed offset k, PE(pos+k) is a linear function of PE(pos) (trigonometric angle-addition identity), hypothesized to ease learning of relative-position attention. Ablation (row E, Table 3) shows learned positional embeddings perform nearly identically; sinusoidal was retained for its hypothesized — but not empirically verified within the paper — length-extrapolation property.
06 · Training Setup

How They Taught the Robot Training the Model: The Practical Details How the model was actually trained Empirical Training Configuration

The "Textbook" Data & Batching Data & batching Data & batching

The robot practiced on about 4.5 million pairs of matched English/German sentences, plus an even bigger set for English/French — like a giant flashcard deck of translations.

WMT 2014 English-German: ~4.5M sentence pairs, split into word pieces so rare words can still be handled. English-French used an even bigger 36M-sentence set. Sentences of similar length were grouped into batches for efficiency.

WMT 2014 English-German: ~4.5M sentence pairs, byte-pair encoded into a shared ~37,000-token vocabulary. WMT 2014 English-French: a much larger 36M-sentence set with a 32,000 word-piece vocabulary. Sentences were batched by approximate length, ~25,000 source + ~25,000 target tokens per batch.

WMT14 En-De: ~4.5M sentence pairs, BPE-encoded, ~37K shared source-target vocabulary. En-Fr: 36M sentences, 32K word-piece vocabulary. Batching by approximate sequence length, ~25,000 source + 25,000 target tokens/batch.

The "Classroom" Hardware & Schedule Hardware & schedule Hardware & schedule

They used 8 powerful graphics cards on one computer. The smaller version of the robot finished practicing in about 12 hours — the bigger, smarter version took about 3.5 days.

8× NVIDIA P100 GPUs on one machine. Base model: ~12 hours total training time. Big model: ~3.5 days — remarkably cheap next to the ensembles of older models it beat.

8× NVIDIA P100 GPUs on one machine. Base model: ~0.4s/step, 100,000 steps, ~12 hours total. Big model: ~1.0s/step, 300,000 steps, ~3.5 days total — remarkably cheap next to the ensembles it beat.

8× NVIDIA P100. Base: ~0.4s/step × 100,000 steps ≈ 12h. Big: ~1.0s/step × 300,000 steps ≈ 3.5 days — one to two orders of magnitude cheaper in FLOPs than the ensembled prior SOTA it surpassed.

How It Learned From Mistakes Optimizer Optimizer Optimizer

The robot used a smart learning method called Adam. It starts learning slowly, speeds up, then gradually slows back down as it gets better — like warming up before a race, then pacing yourself.

Adam optimizer, with a learning rate that ramps up for the first 4,000 steps, then gradually decreases — avoiding instability early on while still allowing fast initial learning.

Adam with β₁ = 0.9, β₂ = 0.98, ε = 10⁻⁹. Learning rate follows a warm-up-then-decay schedule:

Adam (β₁=0.9, β₂=0.98, ε=10⁻⁹); custom warm-up/inverse-square-root-decay learning rate schedule, warmup_steps=4000:

lrate = d_model^(-0.5) · min(step_num^(-0.5), step_num · warmup_steps^(-1.5))

Rate goes up for the first 4,000 steps, then comes back down. Increases linearly for 4,000 steps, then decays proportional to the inverse square root of the step number. Increases linearly for warmup_steps = 4000 steps, then decays proportionally to the inverse square root of the step number. Linear warm-up over 4,000 steps followed by inverse-square-root decay, chosen to stabilize early high-variance gradient/second-moment estimates under Adam.

Keeping It From Memorizing Too Hard Regularization Regularization Regularization

Two tricks kept the robot from just memorizing answers: randomly "forgetting" some info during practice (dropout), and being taught not to be 100% overconfident about answers (label smoothing).

Dropout (10% rate) randomly turns off some connections during training to prevent overfitting. Label smoothing (10%) discourages the model from being too confident — this actually makes its confidence scores look worse (higher perplexity) but improves real translation quality.

Residual dropout (P_drop = 0.1) applied to each sub-layer's output before it's added back, and to the embedding + positional encoding sums. Label smoothing (ε_ls = 0.1) — this actually hurts perplexity because the model is trained to be less overconfident, but it improves accuracy and BLEU.

Residual dropout P_drop=0.1 applied to each sub-layer output pre-residual-add, and to embedding+PE sums. Label smoothing ε_ls=0.1 increases perplexity (by design, discouraging one-hot overconfidence) while improving BLEU/accuracy.

07 · Experiments & Results

Did It Work? YES — Really Well! The Results: Beating the Old Champions Machine translation results Quantitative Results and Ablation Analysis

On the big English-to-German test, the Transformer scored 28.4 out of 100 on the BLEU "translation grade" — beating every earlier robot, even ones that combined several robots together (called "ensembles"), by more than 2 points. On English-to-French it scored 41.8, also a new record — and it trained way faster and cheaper too!

On WMT14 English-to-German, Transformer (big) scores 28.4 BLEU, beating the best previous models — including combinations of several models (ensembles) — by more than 2 BLEU points. On English-to-French, it sets a new single-model record of 41.8 BLEU. And the base model already reaches 27.3 BLEU while training on a fraction of the compute anyone else used.

On the WMT 2014 English-to-German task, the Transformer (big) model reaches 28.4 BLEU, beating the best previously reported models — including ensembles — by more than 2 BLEU, while the base model already reaches 27.3 BLEU at a fraction of typical training cost. On English-to-French, the big model sets a new single-model state of the art of 41.8 BLEU.

Transformer (big) achieves 28.4 BLEU on WMT14 En-De, exceeding prior SOTA (including ensembles) by >2.0 BLEU; base model reaches 27.3 BLEU at ~1-2 orders of magnitude lower training FLOPs than compared ensembles. On En-Fr, Transformer (big) achieves a new single-model SOTA of 41.8 BLEU.

ModelBLEU EN→DEBLEU EN→FRRelative training cost
ByteNet23.75
GNMT + RL24.639.92high
ConvS2S25.1640.46high
GNMT + RL Ensemble26.3041.16very high
ConvS2S Ensemble26.3641.29very high
Transformer (base)27.338.1lowest by far
Transformer (big)28.441.8low

Training cost is measured in floating-point operations; the Transformer base model uses roughly one to two orders of magnitude fewer FLOPs than the ensembled prior state-of-the-art while matching or beating its BLEU score.

6.2 — Testing What Happens If You Change Things 6.2 — Model Variations (Ablations) 6.2 — Model variations (ablations) 6.2 — Model Variations (Ablation Study)

The scientists tried tweaking one setting at a time to see what mattered. Here's what they found, in simple terms:

The authors changed one hyperparameter at a time from the base setup and re-measured translation quality. Big-picture findings:

The authors varied one hyperparameter at a time from the base configuration and re-measured English-to-German BLEU on the development set. The broad, well-established findings:

Single-factor ablations relative to the base configuration, evaluated on the En-De development set:

6.3 — Can It Do Other Jobs Too? 6.3 — English Constituency Parsing 6.3 — English constituency parsing 6.3 — English Constituency Parsing

To check if this trick only works for translation, they tried using it to figure out the grammar structure of English sentences (like drawing a tree diagram of a sentence). It did really well — even better than special robots built ONLY for that job!

To test whether the architecture generalizes, the authors used the Transformer to parse English sentences into grammar trees. Despite little task-specific tuning, it performed competitively with — and sometimes beat — dedicated parsers built specifically for this task.

To test generalization beyond translation, the authors applied the Transformer to parsing sentences into grammatical tree structures. Despite little task-specific tuning, the Transformer performed competitively with — and in the semi-supervised setting, better than — previously reported dedicated parsers, showing the architecture wasn't a translation-only trick.

Applied to English constituency parsing with minimal task-specific tuning, the Transformer performed competitively with, and in the semi-supervised regime exceeded, prior dedicated parsing architectures — evidence of architectural generality beyond MT.

Big takeaway: a robot built entirely from "who should I listen to" tricks beat every older approach at translation, trained way faster and cheaper, and even did well at a totally different job. That's a strong sign the trick itself is powerful — not just lucky for translation. The headline finding, in one line: a purely attention-based model reached new state-of-the-art translation quality, trained dramatically faster and cheaper, and transferred well to a structurally different task — strong evidence the architecture itself was doing the work. The headline finding, in one line: a purely attention-based model reached new state-of-the-art translation quality, trained dramatically faster and cheaper than recurrent or convolutional alternatives, and transferred well to a structurally different task (parsing) — strong evidence the architecture itself, not translation-specific engineering, was doing the work. Synthesis: the combination of SOTA MT quality, substantially reduced training FLOPs, and positive transfer to a structurally distinct task (parsing) jointly support the claim that the architecture — not task-specific engineering — is the primary driver of the observed gains.
08 · Why Self-Attention

Why This Trick Beats the Old Ways Self-Attention vs. RNNs vs. CNNs: The Showdown The complexity argument, side by side Formal Complexity and Path-Length Comparison

Section 4 of the paper compares this new trick to the old ones on three things: how much work per step, how much of that work can happen at the same time, and how many steps it takes for word 1 to "talk to" word 100.

Section 4 formally compares self-attention to recurrent and convolutional layers on three criteria: compute per layer, how much of that compute can run in parallel, and the longest "distance" between any two positions (shorter is better for learning long-range relationships).

Section 4 formally compares self-attention to recurrent and convolutional layers on three criteria: compute per layer, how much of that compute can run in parallel, and the maximum path length between any two positions (shorter = easier to learn long-range dependencies).

§4 formally compares self-attention, recurrent, and convolutional layers along three desiderata: total computational complexity per layer, minimum sequential operations (parallelizability), and maximum path length between any input/output position pair.

Layer typeComplexity per layerSequential operationsMax path length
Self-AttentionO(n²·d)O(1)O(1)
RecurrentO(n·d²)O(n)O(n)
ConvolutionalO(k·n·d²)O(1)O(log_k(n))
Self-Attention (restricted, neighborhood r)O(r·n·d)O(1)O(n/r)

n = sequence length, d = representation dimension, k = convolution kernel size, r = restricted attention neighborhood size.

Self-attention lets ANY word talk directly to ANY other word in just one step (that's the "O(1)" in the table) — the big reason it's so good at connecting far-apart ideas. Old-style robots (RNNs) needed one step per word in between — slow and forgetful over long distances. Self-attention connects every position to every other position in a single step — the key reason it learns long-range relationships more easily than RNNs, which need one sequential step per word in between. The trade-off is more total compute (O(n²)), which is cheaper than recurrence whenever sentences are shorter than the internal representation size — true for most sentence-level tasks. Self-attention connects every position to every other position in a single step (O(1) path length) — the key structural reason it learns long-range dependencies more easily than RNNs, which need O(n) sequential steps for the same connection. The trade-off is O(n²) compute, which is cheaper than recurrence's O(n·d²) whenever sequence length n is smaller than dimension d — true for most sentence-level tasks with subword tokenization. Self-attention's O(1) path length structurally eliminates the repeated multiplicative gradient decay/growth recurrence imposes across O(n) steps. The O(n²·d) vs O(n·d²) tradeoff favors self-attention precisely when n < d, the typical regime for subword-tokenized sentence-level tasks; this inequality flips for very long sequences, motivating restricted-attention variants.

Bonus: because you can literally look at which words a word is "paying attention to," these robots are easier to peek inside and understand than old ones.

As a side benefit, the authors note self-attention models can be more interpretable — you can inspect which words each attention head focuses on, and some heads appear to specialize in grammar or meaning patterns.

As a side benefit, the authors note self-attention models can be more interpretable: individual heads appear to specialize, with some learning to track syntactic structure and others semantic relationships — visible directly by inspecting attention weight matrices.

A noted side benefit is improved interpretability: individual heads exhibit apparent specialization toward syntactic or semantic structure, inspectable directly via attention weight matrices — though see §11 for caveats on how rigorously this claim is substantiated.

09 · Limitations, Assumptions & Future Work

What It Still Can't Do Where the Model Struggles What the paper doesn't solve Critical Limitations and Open Problems

Gets Slow With REALLY Long Sentences Quadratic cost in sequence length Quadratic cost in sequence length Quadratic complexity in sequence length

Since every word checks in with every other word, doubling the sentence length more than doubles the work. For a whole book instead of a sentence, that adds up fast!

Full self-attention costs grow with the square of sequence length (O(n²)). For very long inputs (long documents, audio, DNA sequences), this becomes the main bottleneck.

Full self-attention is O(n²) in memory and compute. For very long sequences (long documents, high-resolution audio, genomic data), this becomes the dominant bottleneck — a limitation that motivated years of follow-up research into sparse, linear, and restricted attention variants.

O(n²) memory/compute in self-attention is the dominant bottleneck for long-context regimes, motivating subsequent research into sparse (Longformer, BigBird), linear (Performer, Linear Transformer), and restricted-window attention variants.

The "Local Neighborhood" Idea Was Never Actually Tested Restricted attention was left unexplored Restricted attention was left unexplored Restricted attention: proposed but untested

The scientists had an idea to speed things up for long sentences — only pay attention to nearby words — but they admit they didn't actually try it themselves in this paper.

The paper suggests restricting self-attention to a local neighborhood to help with very long sequences, but explicitly says they plan to investigate this in future work — they didn't implement or test it here.

The paper explicitly floats restricting self-attention to a local neighborhood of size r to improve performance on very long sequences, but states we plan to investigate this approach further in future work — they didn't implement or test it themselves.

Restricted (local-window) self-attention is proposed analytically (Table 1 row) but not empirically validated within the paper; explicitly deferred to future work.

The Position Tags Are a Bit of a Guess Positional encoding is a design guess Positional encoding is a design guess Positional encoding: hypothesis-driven, not proven

They picked wave patterns because they THOUGHT it would help, but their own test showed a much simpler "just memorize it" method worked about the same — so the fancy reasoning isn't fully proven.

The sine/cosine scheme was chosen on a hypothesis about helping relative-position learning and length extrapolation, but the paper's own comparison shows it performs about the same as simple learned embeddings.

The sinusoidal scheme was chosen on the hypothesis it would help relative-position learning and length extrapolation, but the paper's own ablation shows it performs about the same as simple learned embeddings — the deeper justification is more intuition than proof.

The sinusoidal encoding's justification rests on an untested extrapolation hypothesis; the sole reported comparison (learned vs. sinusoidal, row E) shows near-parity at trained sequence lengths only, leaving the extrapolation claim unverified within the paper.

Mostly Only Tested on Translation Evaluated mainly on translation (+ one parsing task) Evaluated mainly on translation (+ one parsing task) Narrow empirical evaluation scope

Almost all of the proof this works comes from two translation tests, plus one grammar-tree test. They didn't try it on pictures, sounds, or other totally different jobs in this paper.

The empirical case rests heavily on WMT translation benchmarks, with constituency parsing as the only generalization test. Broader use (later confirmed by the field) wasn't shown in this paper itself.

The empirical case rests heavily on WMT translation benchmarks, with constituency parsing as the sole generalization test. Broader applicability (which the field later confirmed extensively) wasn't demonstrated within the paper itself.

Empirical validation is limited to two MT benchmarks plus one parsing task; claims of broader generality (vision, audio, etc.) are stated as future work, not demonstrated in-paper.

What They Hoped to Try Next Where the Authors Said This Could Go Where the authors said this could go Stated Future Directions

The scientists said they wanted to try this trick on pictures, sounds, and videos too, make it work well on really long inputs, and make the "writing" part less one-word-at-a-time. Guess what — all three of those things came true in the years after!

The conclusion explicitly names three future directions: extending the Transformer beyond text to images, audio, and video; investigating local/restricted attention for very large inputs; and making generation less strictly sequential. All three later became real, major areas of research.

The conclusion explicitly plans to: extend the Transformer to problems beyond text involving images, audio, and video; investigate local, restricted attention mechanisms to handle very large inputs and outputs efficiently; and pursue making generation less sequential. All three predictions came true in the following years — Vision Transformers, audio Transformers, and non-autoregressive/parallel decoding research all trace back to these stated directions.

The conclusion enumerates three research directions: (1) extension to non-textual modalities (images, audio, video); (2) local/restricted attention mechanisms for efficient handling of large inputs/outputs; (3) reduced sequentiality in generation. Subsequent work substantiated all three: Vision Transformers, audio/speech Transformers, and non-autoregressive decoding research, respectively.

10 · Real-World Applications

Where You've Probably Already Used This Real-World Uses Why this paper reshaped the industry Deployment Contexts and Ecosystem Influence

Chatbots Like Claude & ChatGPT Language models Language models Large language models

The chatbot you're talking to right now is built from the "Writer" (decoder) half of this same design, just made much, much bigger! The decoder-only Transformer became the backbone of GPT-style language models; the encoder-only version became the backbone of BERT-style models — both direct descendants of this paper's design. The decoder-only Transformer became the backbone of GPT-style large language models; the encoder-only variant became the backbone of BERT-style representation models — both direct descendants of this architecture. Decoder-only Transformer stacks underpin GPT-family LLMs; encoder-only stacks underpin BERT-family representation models — both direct architectural descendants.

Google Translate & Similar Apps Machine translation products Machine translation products Production machine translation

Translation apps switched from old-style robots to Transformer-style ones within a few years of this paper coming out. Transformer-based systems replaced RNN-based translation in production services industry-wide within a few years of publication. Transformer-based systems replaced RNN-based MT in production translation services industry-wide within a few years of publication. Transformer-based NMT systems supplanted RNN-based production translation pipelines industry-wide within several years of publication.

Understanding Pictures Too Vision & multimodal models Vision & multimodal models Vision & multimodal Transformers

"Vision Transformers" cut pictures into little squares and use this exact same "who matters most" trick on them instead of words! Vision Transformers (ViT) apply the same self-attention mechanism to image patches instead of word tokens — one of the future directions the paper explicitly named. Vision Transformers (ViT) apply the same self-attention mechanism to image patches instead of word tokens — one of the future directions the paper's conclusion explicitly named. Vision Transformer (ViT) architectures apply self-attention over linearly-embedded image patches, directly realizing the paper's stated non-textual-modality extension.

Coding Assistants Code generation & coding assistants Code generation & coding assistants Code-focused Transformer models

Tools that help write and fix computer code (like Claude Code) use this same "attention" trick to understand entire files and projects. Transformer-based models trained on code (like the model powering Claude Code) use this same self-attention core to reason across long files and repositories. Transformer-based models trained on code (like the model powering Claude Code) use this same self-attention core to reason across long files and repositories. Code-trained Transformer variants leverage the same self-attention core for long-context reasoning across files and repositories, as in Claude Code.

Understanding Speech Speech & audio Speech & audio Speech & audio Transformers

Programs that turn speech into text (or text into speech) now often use Transformers too — exactly what the paper's authors hoped for. Transformer variants underpin modern speech recognition and speech synthesis systems, matching the paper's stated ambition to extend beyond text. Transformer variants underpin modern speech recognition and speech synthesis systems, again matching the paper's stated ambition to extend beyond text. Transformer-based architectures underpin modern ASR and TTS systems, realizing the paper's stated audio-modality extension.

Why Businesses Care Business impact Business impact Economic / industry impact

Because training only took hours to days on 8 computers instead of huge server farms, way more companies could afford to build powerful AI. The training-efficiency argument (state-of-the-art quality on 8 GPUs in hours to days) made large-scale sequence modeling affordable for far more organizations, accelerating the shift toward foundation models. The training-efficiency argument (state-of-the-art quality on 8 GPUs in hours to days) made large-scale sequence modeling economically viable for far more organizations, accelerating the entire industry's shift toward foundation models. Demonstrated training efficiency lowered the compute barrier to SOTA sequence modeling, catalyzing industry-wide adoption of foundation-model approaches.

11 · Strengths & Weaknesses

The Good Parts and the Tricky Parts Pros and Cons A balanced assessment Strengths, Weaknesses, and Methodological Caveats

The Good Stuff 👍 Strengths Strengths Strengths

  • Any two words can "talk" in one step — great for long, tricky sentencesConstant path length between any two positions — strong long-range dependency modelingConstant path length between any two positions — strong long-range dependency modelingO(1) inter-position path length — strong long-range dependency modeling
  • Can practice on many words at the same time — way faster to trainFully parallelizable training — dramatic wall-clock and compute savingsFully parallelizable training — dramatic wall-clock and compute savingsFully parallelizable training across sequence positions — substantial wall-clock/FLOP savings
  • Set new best-ever scores on two translation tests at onceState-of-the-art results on two translation benchmarks simultaneouslyState-of-the-art results on two translation benchmarks simultaneouslySOTA results on two independent MT benchmarks concurrently
  • Also did great on a totally different job (grammar trees) without much extra tweakingGeneralized to a structurally different task (parsing) with minimal tuningGeneralized to a structurally different task (parsing) with minimal tuningPositive transfer to a structurally distinct task (parsing) with minimal task-specific tuning
  • Simple building blocks that can be stacked bigger and bigger — this became a HUGE deal laterSimple, uniform building block (attention + FFN) that scales cleanly — foundational for the scaling-law eraSimple, uniform building block (attention + FFN) that scales cleanly — foundational for the scaling-law eraUniform, composable building block (attention + FFN) exhibiting clean scaling behavior — foundational to subsequent scaling-law research
  • You can peek inside and see what it's "thinking about" more easily than old robotsMore interpretable attention patterns compared to opaque recurrent hidden statesMore interpretable attention patterns compared to opaque recurrent hidden statesComparatively more interpretable attention distributions vs. opaque recurrent hidden states

The Tricky Parts 👎 Weaknesses Weaknesses Weaknesses

  • Gets expensive fast with really long inputs (everyone checks in with everyone)O(n²) compute/memory in sequence length — expensive for very long inputsO(n²) compute/memory in sequence length — expensive for very long inputsO(n²) compute/memory scaling — costly for long-context regimes
  • The "wavy pattern" position trick is more of an educated guess than a proven factPositional encoding design is justified more by intuition than rigorous proofPositional encoding design is justified more by intuition than rigorous proofPositional encoding rationale is hypothesis-driven, not rigorously validated in-paper
  • Only really tested on translation and one grammar task in this paperEvaluated on a narrow set of tasks (translation + one parsing benchmark) within the paperEvaluated on a narrow set of tasks (translation + one parsing benchmark) within the paperNarrow in-paper evaluation scope (MT + one parsing benchmark)
  • The "only look at nearby words" speed-up idea was suggested but never actually triedRestricted/local attention proposed but not empirically tested by the authorsRestricted/local attention proposed but not empirically tested by the authorsRestricted/local attention proposed analytically but not empirically validated
  • Even though training is fast, writing the output is still done one word at a timeDecoding remains sequential/auto-regressive at inference time even though training is parallelDecoding remains sequential/auto-regressive at inference time even though training is parallelInference-time decoding remains auto-regressive/sequential despite parallel training
12 · Interview Preparation

Practice Questions — Show What You Learned! 60 Practice Questions, With Answers 60 practice questions, with answers 60 Interview-Style Questions, With Model Answers

Grouped by level. Click a question to reveal the answer.

Beginner (20)

Intermediate (20)

Advanced (20)

13 · Quiz

Quiz Time! Test Yourself Test yourself Self-Assessment

Answer the questions below — feedback appears instantly. This is self-graded and doesn't save anywhere.

Score: 0 / 0
14 · Glossary

Word Bank — A to Z A–Z of Every Important Term A–Z of every important term Terminological Reference (A–Z)

15 · Key Takeaways

If You Remember Five Things... If You Remember Five Things If you remember five things Five Core Takeaways

  1. Paying attention beats reading one word at a time.Attention alone is enough.Attention alone is enough.Attention alone suffices. You can build a super smart translator using nothing but the "who matters to whom" trick — no reading order needed, no old-style tricks required. You can build a state-of-the-art sequence model with no recurrence and no convolution — just attention and feed-forward layers, wrapped in residuals and normalization. You can build a state-of-the-art sequence transduction model with no recurrence and no convolution — just attention and feed-forward layers, wrapped in residuals and normalization. A SOTA sequence transduction model can be constructed entirely from attention and position-wise FFN sub-layers, wrapped in residual connections and layer normalization — no recurrence or convolution required.
  2. Doing things at the same time (not one-by-one) was the real magic trick.Parallelism was the unlock.Parallelism was the unlock.Parallelizability was the critical enabler. Letting the robot work on many words at once made training way faster — which is a big reason today's chatbots got so smart. Removing sequential dependence between positions made training dramatically faster and, ultimately, made today's massive-scale language models economically trainable. Removing sequential dependence between positions is what made training dramatically faster and, ultimately, made today's massive-scale language models economically trainable. Eliminating sequential inter-position dependence was the structural precondition enabling web-scale training runs underlying modern large language models.
  3. Eight little brains beat one big brain.Multi-head attention gives several "angles" at once.Multi-head attention gives the model several "angles" at onceMulti-head attention enables joint attendance across representation subspaces. Splitting attention into 8 smaller versions lets each one notice different kinds of things — one big version would blur everything together. Different heads can specialize in different types of relationships between words, which a single averaged attention head cannot do. — different heads can specialize in different types of relationships between words, which a single averaged attention head cannot do. Different heads specialize toward distinct relational patterns, a capacity a single averaged head structurally lacks.
  4. You have to tell it word order on purpose.Position has to be added back in explicitly.Position has to be added back in explicitlyPositional information must be injected explicitly. Since it reads the whole sentence at once, the model has no idea which word came first unless you tell it — using those wavy sine/cosine patterns. via positional encodings, because attention itself has no notion of sequence order. via positional encodings, because attention itself has no notion of sequence order. via fixed sinusoidal positional encodings, since self-attention is inherently permutation-invariant.
  5. This one paper is basically the ancestor of all the AI you use today.This paper's ideas power almost everything since.This paper's ideas power almost everything since.Foundational influence on subsequent architectures. GPT-style, BERT-style, and even picture-understanding AIs — including the one writing this guide — all come from the ideas in this exact paper. GPT-style, BERT-style, and vision Transformer architectures — including the model that wrote this guide — are direct descendants of the encoder/decoder blocks described here. GPT-style, BERT-style, and vision Transformer architectures — including the model that wrote this guide — are direct descendants of the encoder/decoder blocks described here. GPT-family, BERT-family, and Vision Transformer architectures are direct descendants of the encoder/decoder sub-layer design formalized here.