JA EN
Close reading › GPU & Hardware

⬢ CLOSE READING

Attention Is All You Need

Attention Is All You Need

Level★★ Est.40 min PaperarXiv:1706.03762 PDF 2017-06-12
What you getThe architecture nearly every current language, image and audio model is built on, in the authors' own words rather than through a decade of secondhand explanation. You come away with the design reasons that every implementation and every efficiency argument silently assumes — why the scores are divided by √d_k, why the heads are split, why everything is 512-dimensional — and with the paper's own account of what it did not solve.
0 min · 0paragraphs · 0lookups

Abstract

The dominant sequence transduction models are based on complex recurrent or convolutional neural networks that include an encoder and a decoder. The best performing models also connect the encoder and decoder through an attention mechanism.

The opening move of almost every abstract: state the incumbent, neutrally, before laying a finger on it. Nothing is criticised yet — the only loaded word is “complex”, planted so that “simple” in the next sentence has something to push against. The second sentence sets the trap: even the strongest systems bolt attention onto a recurrent or convolutional backbone. Read this as the setup for a deletion, not for an improvement.

sequence transduction

Mapping one sequence to another, with no requirement that the two be the same length. Translation is the canonical case.

dominant

Reports what the field currently uses, without endorsing it. In a first sentence this is a factual baseline; the objection is deferred.

We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely.

The thesis. Note the unusual shape of the claim: the contribution is a subtraction. “Simple”, “solely” and “entirely” all insist that no recurrence survives anywhere in the model, and they are load-bearing rather than decorative — if any recurrent path remained, the title's “all you need” would be false. A reader in 2017 would assume attention was a component; what is asserted here is that it suffices as the whole thing.

dispense with

Stronger than “remove”: it claims the component was never needed. Used when discarding prior machinery rather than improving it.

solely

Marks an exclusivity claim the rest of the paper has to defend. A single counterexample inside the model would break it.

Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train.

Three results are listed as equals: quality, parallelism, training time. Giving the last two the same billing as accuracy is the tell that this is as much a systems paper as a modelling one. Ask what “more parallelizable” is measured against — Section 4 answers by defining the quantity (the minimum number of sequential operations), which is what turns a hardware intuition into something arguable.

parallelizable

Work that can be issued at once rather than in a chain — what decides whether a GPU stays busy. Section 4 makes this countable.

Our model achieves 28.4 BLEU on the WMT 2014 English-to-German translation task, improving over the existing best results, including ensembles, by over 2 BLEU.

“Including ensembles” carries the sentence. A single model beating an ensemble is a far stronger result than beating single models, because ensembling is a nearly free way to buy back a point. Note also what is absent: no variance, no seeds, one number on one test set — the accepted currency at the time, and worth remembering before treating the margin as precise.

ensemble

Averaging several trained models to buy accuracy at a multiple of the inference cost. Normally an unfair advantage over any single model.

Background — What BLEU is, and how big a 2-point gap really is

BLEU scores a translation from 0 to 100 by n-gram overlap with human reference translations. The absolute value carries little meaning on its own — it moves with the test set, the tokenisation and the number of references — so the only sound reading is a comparison between systems on the identical test set. On WMT 2014 newstest2014, the set used throughout this paper, gains were being reported in fractions of a point, which is why “over 2 BLEU” is a jump rather than an increment. Every figure quoted in the results section shares this test set and can be lined up directly. The ablation numbers in Table 3 cannot: those are on the newstest2013 development set.

On the WMT 2014 English-to-French translation task, our model establishes a new single-model state-of-the-art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training costs of the best models from the literature.

A cost claim smuggled inside a quality claim, and the cost claim is the more consequential one: eight GPUs for 3.5 days was a budget a university lab could meet. “Single-model” is a deliberate self-limitation — no ensemble comparison is being made here. Worth cross-checking as a reading exercise: Section 6.1 reports 41.0 for this same setting while the abstract and Table 2 say 41.8. The inconsistency is in the original.

state-of-the-art

A claim indexed to a moment, and usually qualified (single-model vs. ensemble). The qualifier decides what was actually beaten.

a small fraction of

An appositive restating the preceding cost as a ratio rather than an absolute. Unquantified here; Table 2 supplies the FLOP estimates.

We show that the Transformer generalizes well to other tasks by applying it successfully to English constituency parsing both with large and limited training data.

One extra task is thin evidence for “generalizes well”, and the authors treat it accordingly — last position, one sentence. The choice of task is the interesting part: constituency parsing emits an output longer than its input and highly structured, so it stresses the decoder differently from translation. “Both with large and limited training data” pre-empts the standard objection that a high-capacity model without recurrence needs a great deal of data to work at all.

constituency parsing

Recovering a sentence's nested phrase structure as a tree. The output is longer and more constrained than the input, unlike translation.

1 Introduction / 2 Background

Background — What an RNN is, and where its sequential bottleneck comes from

An RNN reads a sequence one token at a time, updating a hidden state that carries everything it has seen so far. Because the state at step t is a function of the state at t-1, step t cannot begin until step t-1 has finished — the dependency is in the definition, not in the implementation, which is why no amount of engineering removes it. LSTMs and GRUs redesign that update to keep gradients alive over longer spans, but they inherit the same serial chain, and in 2017 they were the default for sequence modelling. Wherever the text below says “sequential nature” it means exactly this chain, and the paper's argument is that the chain is what caps hardware utilisation.

Recurrent models typically factor computation along the symbol positions of the input and output sequences. Aligning the positions to steps in computation time, they generate a sequence of hidden states h_t, as a function of the previous hidden state h_{t-1} and the input for position t.

Reads as a neutral restatement of the incumbent, but “aligning the positions to steps in computation time” is where the argument is quietly planted. Position in the sentence and step in the computation are two different things that recurrence conflates; once you refuse the conflation, nothing forces token 5 to be processed after token 4. Presenting a contestable assumption as though it were only a description is a standard way to make a later rejection feel inevitable.

hidden state

The running summary an RNN carries between steps — the only channel through which early tokens reach later ones.

This inherently sequential nature precludes parallelization within training examples, which becomes critical at longer sequence lengths, as memory constraints limit batching across examples.

The load-bearing paragraph of the introduction, and it closes an escape route. You cannot parallelise inside one example; the obvious workaround — run many examples at once — is capped by memory, and that cap tightens exactly when sequences get long. “Inherently” claims the limit belongs to the model class rather than to any implementation, which is what justifies a new architecture instead of a faster kernel. Every training-time claim later in the paper descends from here.

preclude

Rules out in principle rather than in practice — a limit engineering effort cannot lift. Note how much weight the word is carrying here.

batching

Running several examples together to fill the hardware. Memory-bound, which is why it cannot compensate for within-example serialisation.

Attention mechanisms have become an integral part of compelling sequence modeling and transduction models in various tasks, allowing modeling of dependencies without regard to their distance in the input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms are used in conjunction with a recurrent network.

Concede, then locate the gap. Attention gets full credit for solving the distance problem — the paper is not claiming to have invented it — and the gap is narrowed to one thing: nobody has removed the recurrent host it is attached to. Framing a contribution as a deletion makes it defensible, because whether prior work kept the RNN is checkable, whereas who first thought of attention is not. The exception is cited rather than ignored, which is the honest form.

in conjunction with

Used alongside, not instead of. The exact phrase that isolates what this paper is about to do differently.

all but a few

All except a handful. Concedes that exceptions exist while still claiming the field's general practice.

In this work we propose the Transformer, a model architecture eschewing recurrence and instead relying entirely on an attention mechanism to draw global dependencies between input and output. The Transformer allows for significantly more parallelization and can reach a new state of the art in translation quality after being trained for as little as twelve hours on eight P100 GPUs.

The contribution sentence. In most papers it sits at the end of the introduction and states the thesis in one line, so it is the sentence to find first when triaging. Two things are claimed at once, an architecture and a cost, and leading with wall-clock (twelve hours, eight P100s) was unusual enough to be a deliberate signal about what the authors think is new. “Draw global dependencies between input and output” stakes out what attention now has to do with no help.

eschew

Going without, by choice. Signals a design decision rather than a limitation — recurrence could have been kept and was not.

global dependencies

Relations between arbitrarily distant positions, as opposed to what a fixed window or a decaying state can carry.

Self-attention, sometimes called intra-attention is an attention mechanism relating different positions of a single sequence in order to compute a representation of the sequence.

The definition to hold onto for the rest of the paper: the same sequence on both sides. Classical encoder-decoder attention relates two sequences, source and target; self-attention relates a sequence to itself, which is precisely what lets it replace a recurrent layer rather than sit on top of one. The alternative name is given in passing because the cited literature uses both, not because anything turns on it.

self-attention

Attention where queries, keys and values all come from one sequence, so it can serve as a layer instead of a bridge between two stacks.

representation

The vector a model computes for a position. “Computing a representation” means deciding what that position carries forward.

To the best of our knowledge, however, the Transformer is the first transduction model relying entirely on self-attention to compute representations of its input and output without using sequence-aligned RNNs or convolution.

A priority claim, hedged. The hedge is not politeness — it keeps the claim honest against an overlooked prior work, and reviewers expect it. Read the qualifiers as a fence: “entirely” and “without sequence-aligned RNNs or convolution” together define exactly what would count as a counterexample. A claim bounded this precisely is easy to check, which is part of why it held up.

to the best of our knowledge

The standard hedge on a novelty claim. It costs nothing and buys protection; its absence from a first-ever claim is a small red flag.

§

Members-only from here

The rest of the close reading and the glossary are for members. $4.99/mo, cancel anytime.

Comments

Sign in to comment

All close readings