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.
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.
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.
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
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.
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.
| Symbol | Meaning | Shape (per head, this paper) |
|---|---|---|
| Q | Query matrix β what each position is "asking for" | n Γ d_k |
| K | Key matrix β what each position "offers to match against" | n Γ d_k |
| V | Value matrix β the actual content retrieved | n Γ d_v |
| QKα΅ | Raw similarity score between every query and every key (dot product) | n Γ n |
| βd_k | Scaling factor that prevents dot products from growing too large | scalar |
| softmax(Β·) | Turns scores into a probability distribution (attention weights) per row | n Γ n |
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.
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.
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
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:
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:
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.
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.
| Model | BLEU ENβDE | BLEU ENβFR | Relative training cost |
|---|---|---|---|
| ByteNet | 23.75 | β | β |
| GNMT + RL | 24.6 | 39.92 | high |
| ConvS2S | 25.16 | 40.46 | high |
| GNMT + RL Ensemble | 26.30 | 41.16 | very high |
| ConvS2S Ensemble | 26.36 | 41.29 | very high |
| Transformer (base) | 27.3 | 38.1 | lowest by far |
| Transformer (big) | 28.4 | 41.8 | low |
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:
- Number of "brains" (heads):Number of heads:Number of heads:Attention head count: too few OR too many hurt the score β 8 was just right, proving that having several smaller "brains" beats one big one.both too few heads (just 1) and too many heads (with correspondingly smaller size each) hurt quality β 8 heads was a sweet spot, confirming multi-head beats single-head attention.both too few heads (h=1) and too many heads (with correspondingly smaller d_k, d_v) hurt quality β 8 heads was a sweet spot in their setup, confirming that single-head attention underperforms multi-head.both h=1 and excessively large h (with proportionally reduced d_k, d_v) degraded quality relative to h=8, empirically supporting the multi-subspace hypothesis.
- Query/Key size:Attention key size (d_k):Attention key size (d_k):Key dimensionality (d_k): making Q/K smaller hurt the score, showing that figuring out "who matters" isn't a trivial job.reducing d_k hurt quality, suggesting matching queries to keys isn't trivial and a smarter matching function might help β though dot-product's speed advantage was worth the trade-off.reducing d_k hurt model quality, suggesting that determining compatibility between Q and K isn't trivial and a smarter compatibility function than a dot product might help β though dot-product's speed advantage was worth the trade-off.reducing d_k degraded quality, suggesting Q-K compatibility estimation benefits from higher-dimensional representations β a nontrivial function that dot-product only crudely approximates at low d_k.
- Bigger robot brain:Model size:Model size:Model scale: bigger versions of the robot generally did better β a hint that "bigger is better" would matter a lot for AI later on.bigger models (more layers, bigger internal sizes) generally performed better, foreshadowing the scaling trends that later defined the LLM era.bigger models (more layers, larger d_model, larger d_ff) generally performed better, foreshadowing the scaling trends that later defined the LLM era.monotonic improvement with increased layers/d_model/d_ff, an early informal data point relative to later rigorous scaling-law studies.
- Forgetting on purpose (dropout):Dropout:Dropout:Dropout: removing it made the robot worse at translating new sentences it hadn't seen.removing dropout hurt performance, confirming it meaningfully helps the model generalize to new sentences.removing dropout hurt performance, confirming it meaningfully helps generalization.ablating dropout reduced held-out quality, confirming its regularizing effect.
- Position tags:Positional encoding:Positional encoding:Positional encoding scheme: the wave-pattern version and a "just memorize it" (learned) version worked about the same.learned positional embeddings performed nearly identically to the fixed sine/cosine version, backing up the choice to use waves for their extrapolation benefits.learned positional embeddings performed nearly identically to the fixed sinusoidal version (row E), validating the choice to use sinusoids for their extrapolation benefits.learned embeddings β sinusoidal in measured quality (row E); sinusoidal retained for its hypothesized (not directly tested) length-extrapolation property.
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.
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 type | Complexity per layer | Sequential operations | Max path length |
|---|---|---|---|
| Self-Attention | O(nΒ²Β·d) | O(1) | O(1) |
| Recurrent | O(nΒ·dΒ²) | O(n) | O(n) |
| Convolutional | O(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.
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.
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.
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.
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
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)
Quiz Time! Test Yourself Test yourself Self-Assessment
Answer the questions below β feedback appears instantly. This is self-graded and doesn't save anywhere.
Word Bank β A to Z AβZ of Every Important Term AβZ of every important term Terminological Reference (AβZ)
If You Remember Five Things... If You Remember Five Things If you remember five things Five Core Takeaways
- 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.
- 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.
- 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.
- 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.
- 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.
No comments yet. Be the first to share!