ArXiv: 1706.03762
π― Pitch
A new neural architecture called the Transformer achieves state-of-the-art translation while being easier to train than recurrent modelsβbecause it replaces recurrence entirely with the attention mechanism, computing all positions in parallel. It not only sets a new BLEU record of 28.4 on WMT 2014 English-to-German, but does so after just 3.5 days of training across eight GPUs, a fraction of the cost of previous best systems.
1. Executive Summary
This paper introduces the Transformer, a novel sequence transduction model that dispenses entirely with recurrence and convolutions in favor of a pure attention mechanismβspecifically, stacked multi-head self-attention and position-wise feed-forward networks (the encoder processes input sequences in parallel; the decoder generates outputs auto-regressively with masked self-attention and encoder-decoder attention). On the WMT 2014 English-to-German translation task, the Transformer achieves 28.4 BLEU, outperforming all prior models including ensembles by over 2 BLEU, while training for only 3.5 days on eight P100 GPUs; on English-to-French it reaches a new single-model state-of-the-art of 41.8 BLEU at a fraction of the training cost of competitive approaches. The model establishes that a self-attention-only architecture can surpass recurrent and convolutional baselines in translation quality and training efficiency, while also generalizing to English constituency parsing with state-of-the-art results in both limited-data and semi-supervised regimes.
2. Context and Motivation
The Core Problem: Sequential Computation Is a Fundamental Bottleneck
The paper addresses a structural limitation embedded in the dominant neural architectures for sequence transduction as of 2017. Recurrent neural networks (RNNs), including their long short-term memory (LSTM) [13] and gated recurrent unit (GRU) [7] variants, had become the default building block for problems like machine translation and language modeling [35, 2, 5]. But these models share a property that the authors identify as a barrier to scaling: they factor computation sequentially along the symbol positions of the input and output sequences.
To understand why this is a problem, consider what an RNN does internally. At each time step , it computes a hidden state as a function of the previous hidden state and the current input :
This recurrence means that to compute , you must first compute in order. There is no way around it β the computation at position depends on the result at position . The paper frames this as a "fundamental constraint of sequential computation" (Section 1), and it manifests in two concrete ways:
-
Training cannot be parallelized within examples. When you feed a training sentence of length 100 into an RNN, the GPU must process tokens 1 through 100 sequentially. You can batch across different sentences in parallel, but within each sentence the computation is strictly serial. This becomes increasingly painful as sequence lengths grow, since memory constraints limit how many long sequences you can batch together.
-
Learning long-range dependencies is hard. For information to flow from position 1 to position 100, it must traverse 99 intermediate hidden states. Each step is an opportunity for the signal to be diluted, forgotten, or corrupted. While LSTMs and GRUs were explicitly designed to mitigate this (via gating mechanisms that can preserve information across many timesteps), the problem is structural: the path length between distant positions grows linearly with sequence length. This is a well-known difficulty formalized in the literature on gradient flow in recurrent networks [12].
The authors are pointing at something deeper than just "RNNs are slow." They are identifying that the serial computation model itself β the idea that processing a sequence requires stepping through it one token at a time β is what limits both training efficiency and the ability to model long-range context. If you could compute representations for all positions simultaneously, you would solve both problems at once.
Why This Problem Matters
The practical significance in 2017 was enormous and multi-dimensional:
Training time and cost. State-of-the-art machine translation models were trained on massive parallel corpora (the WMT English-French dataset contained 36 million sentence pairs) and took days or weeks on expensive GPU clusters. The ConvS2S model [9], a strong convolutional baseline, consumed approximately FLOPs for English-to-German and FLOPs for English-to-French (Table 2). The GNMT+RL model [38] used and FLOPs respectively. These numbers placed state-of-the-art translation models out of reach for researchers and organizations without substantial GPU resources. Reducing training time by an order of magnitude would democratize access to high-quality translation.
Scaling to longer sequences. The sequential bottleneck becomes proportionally worse as sequence length increases. For tasks involving long documents, multi-turn dialogue, or high-resolution images treated as sequences, a model whose training time scales linearly with sequence length was fundamentally limited. The paper explicitly frames this as a constraint that "becomes critical at longer sequence lengths" (Section 1).
The gap between available parallelism and its exploitation. GPUs and TPUs are designed for highly parallel workloads β they have thousands of cores that can operate simultaneously. An RNN that processes one token at a time on a single GPU leaves most of that parallelism unused (within a training example). The paper identifies a mismatch between hardware capability and algorithmic design: the hardware wants to do everything at once; the algorithm forces it to do one thing after another.
Long-range dependency learning as a core capability. Many sequence transduction tasks require relating information across arbitrary distances. In translation, a word at the beginning of a source sentence may determine the form of a word at the end of the target sentence (e.g., subject-verb agreement in languages with long-distance dependencies). In parsing, a syntactic head may need to be linked to its dependents many words away. A model whose architecture imposes a long path between distant positions is architecturally biased against the very thing it most needs to learn.
Prior Approaches and Where They Fall Short
By 2017, there were two main alternative directions for reducing sequential computation, plus the standard RNN approaches that accepted it as a necessary cost.
Convolutional Sequence Models
The Extended Neural GPU [16], ByteNet [18], and ConvS2S [9] all replaced recurrence with convolution, allowing parallel computation across input positions. This directly addressed the parallelism problem β a convolutional layer processes all positions simultaneously. But it introduced a different limitation, one that the paper carefully characterizes (Section 2, Section 4, Table 1):
"the number of operations required to relate signals from two arbitrary input or output positions grows in the distance between positions, linearly for ConvS2S and logarithmically for ByteNet"
In a convolutional model, information from position and position can only interact if the receptive field of the network spans the gap between them. For a single convolutional layer with kernel width , two positions more than apart cannot directly interact. To connect distant positions, you need to stack layers: each layer expands the receptive field by positions. For standard convolutions, this means you need layers to connect positions apart. For dilated convolutions (as in ByteNet), the receptive field grows exponentially with depth, requiring only layers. But the fundamental tradeoff remains: connecting distant positions requires either many layers, large kernels (which are computationally expensive), or dilation (which reduces resolution at shorter distances).
The maximum path length column in Table 1 is the paper's way of formalizing this. Self-attention has a maximum path length of β every position attends to every other position directly in a single operation. Recurrent networks have β the signal must traverse every intermediate position. Convolutional networks sit somewhere in between: for dilated convolutions, for standard ones.
The authors acknowledge one advantage convolutional models share with self-attention: both have sequential operations per layer (Table 1), meaning they can be parallelized during training. The limitation is specifically in the path length β the number of computational steps required for information to flow between distant positions β which affects the model's ability to learn long-range dependencies, not just its training speed.
Recurrent Models with Attention
Attention mechanisms had already become standard in sequence-to-sequence models by 2017 [2, 19, 38]. The typical architecture was an RNN encoder that produced a sequence of hidden states, an RNN decoder that generated output tokens one at a time, and an attention mechanism that allowed the decoder to dynamically focus on relevant encoder states at each decoding step. This addressed a key weakness of pure RNN encoder-decoders (where the entire source sentence had to be compressed into a single fixed-length context vector), and it substantially improved translation quality on long sentences.
But attention in these architectures was always used in conjunction with recurrence. The RNN still processed the source sentence sequentially (generating the encoder hidden states one position at a time), and the RNN decoder still generated output tokens one at a time (attending to the encoder outputs at each step). Attention improved the modeling of long-range dependencies but did nothing to address the training-time sequential bottleneck.
The paper mentions one exception: the Decomposable Attention model [27] had used attention without recurrence for textual entailment. But this was not a sequence transduction model β it classified a single input pair rather than generating a variable-length output sequence. The Transformer adapts the idea of purely attention-based processing to the encoder-decoder transduction setting, which is substantially more demanding because it requires generating coherent, structured output sequences.
Memory Networks
End-to-end memory networks [34] explored recurrent attention over a memory store, rather than recurrence over sequence positions. This was a step toward attention-based sequence processing, but the architecture still included a form of recurrence (iterative reading from memory), and it had only been demonstrated on relatively simple tasks like synthetic question answering and language modeling. The Transformer eliminates recurrence entirely β not just from the sequence processing, but from the attention mechanism itself (no iterative memory reads).
Summary of Prior Work Limitations
The paper positions the prior landscape as follows:
- RNNs: Serial computation limits training parallelism and makes long-range dependency learning structurally difficult ( path length).
- Convolutional models: Achieve training parallelism ( sequential operations) but still require or operations for distant positions to interact.
- Attention-augmented RNNs: Attention addresses the long-range dependency problem but is bolted onto a recurrent backbone that remains serial.
- Pure attention models (e.g., Decomposable Attention): Exist for classification tasks but have not been demonstrated for sequence transduction (variable-length generation).
The gap the paper identifies is clear: no existing architecture simultaneously achieved sequential operations (training parallelism) and maximum path length (easy long-range dependency learning) for sequence transduction tasks.
How the Transformer Positions Itself
The paper makes its positioning explicit in a single sentence (Section 2):
"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."
This is a claim of architectural novelty and completeness. The Transformer is not just an improvement on existing architectures β it is a fundamentally different approach that eliminates recurrence and convolution entirely. The model computes representations of all input positions in parallel (via self-attention in the encoder) and generates output tokens one at a time (via masked self-attention and encoder-decoder attention in the decoder), but critically, even the decoder's sequential generation does not impose sequential computation across output positions during training β teacher forcing allows all decoder positions to be computed in parallel during training, with a mask preventing information leakage from future positions.
The paper positions the Transformer as resolving the tension between the three desiderata listed in Section 4 (and Table 1):
-
Computational complexity per layer: Self-attention is , which is faster than recurrence () when β a regime typical for sentence-level NLP where and is often shorter. For longer sequences, the paper hints at restricted self-attention (a neighborhood of size ) as a future direction that would bring complexity down to .
-
Parallelizable computation: sequential operations, matching convolutions and vastly outperforming recurrence ().
-
Path length between long-range dependencies: , uniquely better than both recurrence () and convolution ( or ).
The tradeoff the paper acknowledges is that this path length comes "at the cost of reduced effective resolution due to averaging attention-weighted positions" (Section 2). Because attention computes a weighted average of all positions, the model's representation of what is happening at position is a mixture of information from many positions, which could blur local detail. The paper's solution β multi-head attention (Section 3.2.2) β is presented as the mechanism that counteracts this resolution loss. By having multiple attention heads, each operating in a different learned subspace, the model can simultaneously attend to information from different positions with different interpretative lenses. One head might focus on local syntax, another on long-distance semantic relationships, and a third on positional patterns. This is not described as an optional enhancement β it is fundamental to making self-attention work as the sole computational primitive.
The paper also positions the Transformer as a general-purpose sequence transduction architecture, not just a translation model. The inclusion of English constituency parsing results (Section 6.3, Table 4) is deliberate: it demonstrates that the architecture works on a task with very different structural properties (output longer than input, strong syntactic constraints) and in both data-rich (semi-supervised, 17M sentences) and data-scarce (WSJ only, 40K sentences) regimes. This generalization claim is important because it suggests the Transformer is not merely exploiting some quirk of translation data β it is a viable replacement for recurrent architectures across sequence transduction tasks.
Finally, there is an implicit positioning around interpretability. The paper includes an appendix of attention visualizations (Figures 3β5) showing that individual attention heads learn to perform linguistically meaningful operations β resolving anaphora, tracking long-distance syntactic dependencies, identifying phrase structure. This is not presented as a rigorous contribution but as a "side benefit" (Section 4) that distinguishes self-attention from the opaque hidden states of recurrent networks. The ability to inspect which input positions each output position attends to makes the model's decisions more transparent, which matters for debugging, trust, and scientific understanding of what the model learns.
3. Technical Approach
3.1 Reader Orientation
The Transformer is a neural network architecture for converting one sequence into another β such as translating an English sentence into a German sentence β that replaces the traditional recurrent (step-by-step) processing with a mechanism called attention, which allows every element of the input sequence to directly interact with every other element in a single, parallel computational step. The problem it solves is the sequential bottleneck inherent in recurrent neural networks (RNNs), where processing token by token prevents parallelization during training and makes it structurally difficult for the model to learn dependencies between distant positions; the Transformer's solution is to compute representations of all positions simultaneously using self-attention, which compares each position to every other position in constant time, then to generate the output auto-regressively using a decoder that attends both to its own previous outputs and to the encoder's full context.
3.2 Big-Picture Architecture (Diagram in Words)
The Transformer has five major structural components, organized into an encoder stack and a decoder stack as shown in Figure 1:
- Input Embeddings and Positional Encoding β converts input tokens (words or subwords) into vectors of dimension
$d_{model} = 512$, then adds a positional signal (sinusoidal functions of the token index) so the model knows the order of the sequence despite having no recurrence. - Encoder Stack (
$N = 6$identical layers) β each layer has two sub-components: a Multi-Head Self-Attention mechanism (which allows each position to look at all other positions in the input) and a Position-wise Feed-Forward Network (a small fully-connected network applied identically to each position). Residual connections and layer normalization wrap each sub-component. - Decoder Stack (
$N = 6$identical layers) β each layer has three sub-components: a Masked Multi-Head Self-Attention (prevents positions from seeing future tokens, preserving auto-regressivity), a Multi-Head Encoder-Decoder Attention (allows each decoder position to attend to the entire encoder output), and a Position-wise Feed-Forward Network. Residual connections and layer normalization are applied identically to the encoder. - Output Linear Transformation and Softmax β takes the decoder's final output vectors and projects them to vocabulary-size logits, then applies softmax to produce probabilities for the next output token.
- Training Infrastructure β the Adam optimizer with a custom learning rate schedule (warmup then inverse square root decay), label smoothing (
$\epsilon_{ls} = 0.1$), and dropout ($P_{drop} = 0.1$for base model) applied to multiple locations.
Information flow during training (teacher forcing): A source sentence is converted to embeddings, added to positional encodings, and fed through the 6 encoder layers simultaneously. The encoder output (a sequence of vectors, one per input position) is passed to each decoder layer. The target sentence (shifted right by one position) undergoes the same embedding and positional encoding, then passes through the 6 decoder layers β but with a mask preventing each position from attending to later positions. The decoder's final output goes through a linear layer and softmax to predict the next token for every target position in parallel. The loss (cross-entropy with label smoothing) is computed against the known target sequence.
Information flow during inference: The encoder processes the source sentence once (no change from training). The decoder generates one token at a time: it starts with a special start token, attends to the encoder output, produces a distribution over the next token, samples or selects the best token, appends it to the output, and repeats β each step attending to all previously generated tokens but not future ones (guaranteed by the mask).
3.3 Roadmap for the Deep Dive
The explanation of the Technical Approach will proceed in the following order, which builds from the smallest computational unit (scaled dot-product attention) outward to the full training pipeline:
- First, the Scaled Dot-Product Attention mechanism (Section 3.2.1) β the core mathematical operation that the entire architecture is built on. Understanding this single function is prerequisite to everything else, since it defines how the model computes relationships between positions.
- Second, Multi-Head Attention (Section 3.2.2) β how the basic attention mechanism is parallelized across multiple learned projections to allow the model to simultaneously attend to different types of relationships (syntactic, semantic, positional) from different representation subspaces.
- Third, how attention is applied in three distinct ways within the model (Section 3.2.3): encoder self-attention, decoder masked self-attention, and encoder-decoder attention. Each has a different purpose and different constraints.
- Fourth, the encoder and decoder layer structure (Section 3.1) β how attention sub-layers are combined with position-wise feed-forward networks, residual connections, and layer normalization to form the complete building blocks that are stacked 6 times.
- Fifth, the Position-wise Feed-Forward Networks (Section 3.3) β the component that processes each position independently after attention has mixed information across positions, providing the model with non-linear transformation capacity at each position.
- Sixth, Embeddings and Positional Encoding (Sections 3.4 and 3.5) β how input tokens are converted to vectors and how sequence order information is injected into a model that has no recurrence or convolution.
- Seventh, the training regime (Section 5) β optimizer choice, learning rate schedule, regularization techniques (dropout and label smoothing), and hyperparameter configurations that make all the architectural components learn effectively.
This order is chosen because attention is the conceptual core β the rest of the architecture is scaffolding that makes attention work well for sequence transduction.
3.4 Detailed, Sentence-Based Technical Breakdown
This is an architectural design paper whose core idea is that a pure attention mechanism, without any recurrence or convolution, can serve as the sole computational primitive for sequence transduction, achieving both training parallelism (all positions processed simultaneously) and short dependency paths (any two positions interact in $O(1)$ operations) if the attention is split across multiple learned subspaces (heads) and combined with position-wise non-linear transformations.
Scaled Dot-Product Attention
What Attention Computes, Conceptually
Before examining the mathematical form, understand what an attention function does. An attention function receives three inputs: a query vector (representing "what am I looking for?"), a set of key vectors (each representing "what information do I contain?"), and a set of value vectors (each representing "what content do I provide?"). The function compares the query to each key using a compatibility function (in this case, a scaled dot product), producing a set of weights (one per key-value pair) that sum to 1. These weights determine how much each value contributes to the output. The output is a weighted sum of all values, where the weights reflect how relevant each key is to the query.
This is analogous to a soft dictionary lookup: the query is like a search term, the keys are like dictionary entries, and the values are like definitions β but instead of returning only the value for the best-matching key, you get a mixture of all values, weighted by relevance to the query. This is critical because it means the output is differentiable (weights can be learned via gradient descent) and context-dependent (the weights change based on the specific query).
The Matrix Formulation
In practice, queries, keys, and values all come in sets (e.g., one query per output position, one key-value pair per input position). The model packs all queries into a matrix $Q$, all keys into a matrix $K$, and all values into a matrix $V$. The attention function then computes:
where $Q \in \mathbb{R}^{n_q \times d_k}$ is the matrix of $n_q$ query vectors each of dimension $d_k$, $K \in \mathbb{R}^{n_k \times d_k}$ is the matrix of $n_k$ key vectors each of dimension $d_k$, $V \in \mathbb{R}^{n_k \times d_v}$ is the matrix of $n_k$ value vectors each of dimension $d_v$, and $d_k$ is the dimensionality of the query and key vectors (64 in the Transformer base model).
What it computes, step by step. First, the dot product $QK^T$ produces an $n_q \times n_k$ matrix of raw compatibility scores β each entry $(i,j)$ is the dot product between query $i$ and key $j$, measuring their alignment. A large positive dot product means the query and key point in similar directions (high compatibility); a dot product near zero means they are orthogonal (low compatibility). Second, each score is divided by $\sqrt{d_k}$ β the scaling factor β to prevent the dot products from growing too large in magnitude as $d_k$ increases. Third, a softmax function is applied row-wise to convert these scaled scores into a distribution over the keys for each query: each row becomes a set of non-negative weights that sum to 1. Finally, these attention weights multiply the value matrix $V$, producing an $n_q \times d_v$ output matrix where each row is a weighted combination of all value vectors, with the weights determined by the query-key compatibility.
Why scaling by $\sqrt{d_k}$? The paper provides a specific theoretical motivation. Assume the components of the query and key vectors are independent random variables with mean $0$ and variance $1$. Then the dot product $q \cdot k = \sum_{i=1}^{d_k} q_i k_i$ has mean $0$ and variance $d_k$ (the sum of $d_k$ independent products, each with variance $1$). For large $d_k$, the dot products will have magnitudes on the order of $\sqrt{d_k}$, pushing the softmax function into regions where its gradient is extremely small (the softmax becomes nearly one-hot, assigning almost all probability mass to a single key). This effectively makes the attention mechanism non-differentiable β a disaster for gradient-based learning. Dividing by $\sqrt{d_k}$ normalizes the variance of the dot products back to $1$, keeping the softmax in a regime where gradients flow effectively. This is not a heuristic; it is a corrective for a statistical property that emerges from high-dimensional dot products.
Why dot-product attention over additive attention? Additive attention (Bahdanau et al., 2014 [2]) computes compatibility using a feed-forward network with a single hidden layer: $\text{score}(q, k) = v^T \tanh(W_1 q + W_2 k)$. Both approaches have similar theoretical complexity, but dot-product attention is "much faster and more space-efficient in practice, since it can be implemented using highly optimized matrix multiplication code" (Section 3.2.1). Matrix multiplication is the operation that GPUs and TPUs are designed to accelerate β the entire $QK^T$ computation can be executed as one highly optimized BLAS (Basic Linear Algebra Subprograms) call. Additive attention requires computing a non-linear function for each query-key pair, which does not map as naturally to matrix-multiply hardware. However, the paper notes an important nuance: for small values of $d_k$, dot-product and additive attention perform similarly, but for large $d_k$, additive attention outperforms unscaled dot-product attention [3] β which is precisely why the scaling factor is necessary. The scaled dot-product attention is thus a fusion: it retains the computational efficiency of matrix-multiply-based attention while matching the performance of the more expensive additive variant.
Multi-Head Attention
Why multiple heads? A single attention function with $d_{model}$-dimensional queries, keys, and values (where $d_{model} = 512$) averages attention-weighted information across all positions. This averaging can "inhibit" the model's ability to focus on multiple different relationships simultaneously β for example, a single attention function cannot simultaneously attend to local syntactic dependencies (adjacent words) and long-range semantic dependencies (subject-verb agreement across a clause boundary) because the attention weights form a single distribution that must trade off between these competing demands. The solution is to create $h$ independent attention "heads," each operating in a lower-dimensional projected subspace, allowing different heads to specialize in different types of relationships.
The multi-head formulation:
where
The projection matrices are:
$W_i^Q \in \mathbb{R}^{d_{model} \times d_k}$β projects queries from the model dimension (512) to the per-head query/key dimension (64)$W_i^K \in \mathbb{R}^{d_{model} \times d_k}$β projects keys from 512 to 64$W_i^V \in \mathbb{R}^{d_{model} \times d_v}$β projects values from 512 to the per-head value dimension (64)$W^O \in \mathbb{R}^{h d_v \times d_{model}}$β projects the concatenated head outputs (8 Γ 64 = 512) back to the model dimension (512)
For the base model, $h = 8$, $d_k = d_v = d_{model}/h = 64$.
What it computes, operationally. First, each head independently projects the queries, keys, and values into its own 64-dimensional subspace using learned linear transformations ($W_i^Q, W_i^K, W_i^V$). These projections are different for each head and are learned during training β head 1 might learn to project queries and keys into a subspace that captures syntactic relationships, while head 5 might learn a subspace for semantic relationships. Second, each head performs the scaled dot-product attention computation independently, producing a 64-dimensional output for each query position. Third, the outputs from all 8 heads are concatenated (forming a $8 \times 64 = 512$-dimensional vector per position) and projected through $W^O$ to produce the final output.
Why the computational cost is nearly constant. Because each head operates in a reduced dimension ($d_k = d_v = 64$ instead of $d_{model} = 512$), the total number of floating-point operations for multi-head attention is similar to single-head attention with full dimensionality. The per-head dot product $Q_i K_i^T$ involves matrices of dimension $n \times 64$, costing $O(n^2 \cdot 64)$ per head, and with 8 heads the cost is $O(n^2 \cdot 512)$ β the same asymptotic complexity as a single-head attention with $d_k = 512$. The additional cost of the projection matrices ($W_i^Q, W_i^K, W_i^V, W^O$) is $O(n \cdot d_{model}^2)$, which is linear in $n$ and dominated by the $O(n^2 \cdot d_{model})$ attention cost for typical sequence lengths.
The design choice of head count and dimension. The paper uses $h = 8$ and $d_k = d_v = 64 = 512/8$. This is not arbitrary β the constraint $d_k \cdot h = d_{model}$ ensures that concatenation followed by projection preserves the input dimensionality (necessary for residual connections). The ablation in Table 3 row (A) explores varying the number of heads while keeping total computation constant (by adjusting $d_k$ and $d_v$ inversely). Single-head attention ($h = 1$, $d_k = d_v = 512$) achieves 24.9 BLEU β 0.9 BLEU worse than the 8-head setting (25.8 BLEU). However, 16 heads ($d_k = d_v = 32$) achieves only 25.1 BLEU, and 32 heads ($d_k = d_v = 16$) achieves 25.0 BLEU. This inverted-U pattern suggests that too few heads fail to capture diverse relationships (the "averaging inhibits" problem), while too many heads with too-small dimensions may not have enough representational capacity per head to learn meaningful attention patterns.
The Three Applications of Attention in the Transformer
The Transformer uses multi-head attention in three distinct configurations, each serving a different role in the overall computation. Understanding the differences clarifies how the architecture handles both the parallel encoding of the source and the auto-regressive decoding of the target.
Encoder Self-Attention
In every encoder layer, the queries, keys, and values all come from the same source: the output of the previous layer (or, for the first layer, the input embeddings plus positional encodings). This means each position in the input sequence can attend to every position in the input sequence β all positions, without restriction. This is what enables the $O(1)$ maximum path length: information from position $i$ and position $j$ can interact directly in a single attention operation, regardless of how far apart they are.
The mechanism is often described as "each word looks at every other word," but it is more precise to say that for each position, the attention mechanism computes a weighted combination of representations from all positions, where the weights are learned based on the compatibility between the query at that position and the keys at all positions. After the first encoder layer, each position's representation has already incorporated information from the entire sentence (albeit with weights that may emphasize some positions over others). After 6 layers of this β each followed by a position-wise feed-forward transformation β the representation at each position is a complex, contextually-informed embedding of that token in the context of the full sentence.
There is no masking in the encoder self-attention. Every position can see every other position. This is valid because during both training and inference, the entire source sentence is available β there is no future information to leak, because the encoder processes the source (which is fully known) rather than generating it.
Decoder Masked Self-Attention
The decoder also has self-attention layers, but with a critical modification: masking to prevent leftward information flow. The decoder generates output tokens one at a time, left to right, and during training (when using teacher forcing), the model has access to the entire target sequence. If the decoder self-attention were unmasked, the model could cheat by looking at future tokens when predicting the current one β for example, when predicting token 5, it could directly attend to token 5's embedding (which is the correct answer), making the task trivially easy and preventing the model from learning to generate.
The masking is implemented inside the scaled dot-product attention mechanism by setting all values in the input of the softmax that correspond to illegal connections to $-\infty$. Recall that the attention weights are computed as:
Before the softmax is applied, a mask matrix $M$ is added to the scores, where $M_{ij} = 0$ if position $i$ is allowed to attend to position $j$, and $M_{ij} = -\infty$ otherwise. Since $\exp(-\infty) = 0$, the softmax produces zero weight for all masked positions. The mask for decoder self-attention is upper-triangular (all positions $j > i$ are masked), enforcing that position $i$ can only attend to positions $1, 2, \ldots, i$.
This masking is further combined with the fact that the output embeddings are "offset by one position" β meaning the input to the decoder at position $i$ corresponds to the token at position $i-1$ in the target sequence (with a start-of-sequence token at position 0). Together, these two mechanisms ensure that the prediction for position $i$ depends only on the known outputs at positions $< i$, preserving the auto-regressive property that is essential for the model to be able to generate sequences at inference time.
Encoder-Decoder Attention
The third application of attention is in the encoder-decoder attention layers, which appear in every decoder layer (after the masked self-attention sub-layer). Here, the queries come from the previous decoder layer (the output of the masked self-attention sub-layer, after layer normalization), while the keys and values come from the output of the encoder stack (the final encoder layer's output).
This allows every position in the decoder to attend over all positions in the input sequence. It functions similarly to the attention mechanism in traditional sequence-to-sequence models with RNNs [2, 38]: at each decoding step, the model can look back at the source sentence and focus on the parts most relevant to generating the current output token. For example, when generating a German verb at the end of a clause, the decoder can attend back to the corresponding English verb (which may appear much earlier in the source sentence) to determine its correct form.
Crucially, there is no masking in encoder-decoder attention β the decoder can attend to all encoder positions at every step. This is valid because the encoder processes the entire source sentence before decoding begins, so there is no future information to leak. During training, all decoder positions attend to the entire source in parallel; during inference, each decoding step attends to the entire source independently.
Design choice: separate encoder-decoder attention vs. giving decoder direct access. Why have a separate encoder-decoder attention sub-layer rather than simply feeding the encoder output as input to the decoder self-attention? The separation allows the model to learn different attention patterns for self-context (what has been generated so far) and source-context (what needs to be translated). The decoder self-attention captures dependencies within the target language (e.g., ensuring consistent tense, agreement, and word order); the encoder-decoder attention captures cross-lingual alignments (which source words map to which target words). Mixing these in a single attention operation would force a single set of attention weights to serve both purposes, which is less flexible than learning them separately.
Encoder and Decoder Layer Structure
The Encoder Layer (repeated $N = 6$ times)
Each encoder layer consists of exactly two sub-layers, applied sequentially:
- Multi-head self-attention β as described above, with queries, keys, and values all from the previous layer's output.
- Position-wise feed-forward network β described in detail in Section 3.3, but essentially a two-layer fully-connected network with a ReLU activation, applied independently to each position.
Each sub-layer is wrapped in a residual connection followed by layer normalization. Specifically, the output of each sub-layer is:
where $x$ is the input to the sub-layer and $\text{Sublayer}(x)$ is the function implemented by the sub-layer (either multi-head attention or feed-forward network). For these residual connections to work, the input and output dimensions of every sub-layer must be the same β hence the design choice $d_{model} = 512$ for all sub-layer inputs and outputs, and the constraint that the multi-head attention output projection $W^O$ maps from $h \cdot d_v = 8 \cdot 64 = 512$ back to $d_{model} = 512$.
Why residual connections? Residual connections [11] allow gradients to flow directly through the network during backpropagation. In a deep network (the Transformer has 6 encoder layers, each with 2 sub-layers = 12 sub-layers, plus 6 decoder layers with 3 sub-layers each = 18 sub-layers, for a total of 30 sub-layers in the encoder-decoder stack), gradients would otherwise attenuate or explode as they propagate through successive non-linear transformations. The residual connection provides a "gradient highway" β the identity mapping $x$ is added to the sub-layer output, so gradients can flow directly from the output back to the input without passing through the sub-layer's potentially gradient-attenuating transformations. This makes training deep attention-only networks feasible.
Why layer normalization? Layer normalization [1] normalizes the activations across the feature dimension for each training example independently (unlike batch normalization, which normalizes across the batch). For each position in each example, it computes the mean and variance across the $d_{model} = 512$ features, subtracts the mean, and divides by the standard deviation (with learned scale and shift parameters). This stabilizes training by keeping activations in a consistent range, preventing the distribution of activations from drifting as they pass through many layers. The choice of layer normalization over batch normalization is motivated by the sequence transduction setting: batch sizes vary by sequence length, and the statistics of hidden states can vary dramatically across positions, making per-position (layer) normalization more appropriate than per-feature (batch) normalization.
The Decoder Layer (repeated $N = 6$ times)
Each decoder layer inserts a third sub-layer between the masked self-attention and the feed-forward network: the multi-head encoder-decoder attention described above. The sub-layer order is:
- Masked multi-head self-attention (queries, keys, values from decoder's previous layer; mask prevents attending to future positions).
- Multi-head encoder-decoder attention (queries from the output of sub-layer 1, keys and values from the encoder's final output).
- Position-wise feed-forward network.
Each of these three sub-layers uses the same residual connection + layer normalization pattern: $\text{LayerNorm}(x + \text{Sublayer}(x))$.
Why three sub-layers in the decoder vs. two in the encoder? The decoder needs to integrate information from two distinct sources: its own previously generated tokens (to maintain coherence and consistency in the target language) and the source sentence (to ensure faithful translation). The separation into two attention sub-layers allows the model to compute separate attention distributions for these two information sources β the self-attention weights reflect target-side dependencies, while the encoder-decoder attention weights reflect source-target alignments. If these were combined into a single attention mechanism (e.g., by concatenating the decoder states and encoder states and running self-attention over the combined sequence), the model would lose the ability to independently modulate how much it relies on source vs. target context at each position.
The stacking depth: $N = 6$. The number of layers is a design choice explored in the ablation study (Table 3). With $N = 6$, the base model achieves 25.8 BLEU and has 65 million parameters. Reducing to $N = 2$ (row C) drops performance to 23.7 BLEU (36M parameters); increasing to $N = 8$ achieves 25.5 BLEU (80M parameters). The choice of $N = 6$ appears to be near the point of diminishing returns for the base model scale β doubling the layers to 8 does not improve performance, likely because the 65M-parameter model lacks the capacity to benefit from additional depth without additional width (as the big model, with $d_{model} = 1024$ and $N = 6$, achieves 26.4 BLEU with 213M parameters, showing that increasing both depth and width together yields meaningful gains).
Position-wise Feed-Forward Networks
Each encoder and decoder layer contains a fully connected feed-forward network applied to each position separately and identically β meaning the same weights are used for every position, but the computation at each position is independent of other positions. The network is:
where $x \in \mathbb{R}^{d_{model}}$ is the representation at a single position, $W_1 \in \mathbb{R}^{d_{model} \times d_{ff}}$ projects to an inner dimension $d_{ff} = 2048$, $W_2 \in \mathbb{R}^{d_{ff} \times d_{model}}$ projects back to the model dimension, $b_1 \in \mathbb{R}^{d_{ff}}$ and $b_2 \in \mathbb{R}^{d_{model}}$ are biases, and $\max(0, \cdot)$ is the ReLU activation function.
What it computes, operationally. For each position's $d_{model}$-dimensional vector, the network: (1) linearly transforms it to a 2048-dimensional vector ( $x W_1 + b_1$ ), (2) applies the ReLU non-linearity (setting all negative values to zero), and (3) linearly transforms back to a $d_{model}$-dimensional output ( $\max(0, x W_1 + b_1) W_2 + b_2$ ). The result is added to the residual stream at that position.
Why this design? The attention sub-layer mixes information across positions β it computes weighted averages of value vectors from the entire sequence. The feed-forward sub-layer processes each position independently, applying the same transformation to every position. This provides the model with non-linear representational capacity at each position after cross-position information has been aggregated. The alternating pattern β mix across positions (attention), then transform per position (feed-forward) β is repeated 6 times in the encoder and 6 times in the decoder.
Why an expansion ratio of 4? The inner dimension $d_{ff} = 2048$ is exactly 4 times the model dimension $d_{model} = 512$. This expansion-bottleneck structure (project up to a higher dimension, apply non-linearity, project back down) is common in transformer-like architectures. The expansion allows the model to learn more complex functions β with only 512 hidden units and a single non-linear layer, the model might lack the capacity to transform the attention-aggregated representations sufficiently between layers. The paper does not provide a detailed ablation of $d_{ff}$ vs. $d_{model}$ ratios, but row (D) of Table 3 explores different model sizes: increasing $d_{ff}$ from 2048 to 4096 with $d_{model} = 512$ improves perplexity from 4.66 to 4.75 but BLEU from 26.0 to 26.2 (going from 168M to 90M parameters β note this row also adjusts other hyperparameters), while the big model uses $d_{ff} = 4096$ with $d_{model} = 1024$.
Alternative interpretation: two convolutions with kernel size 1. The paper notes that the position-wise feed-forward network can be equivalently described as two 1D convolutions with kernel size 1. A 1D convolution with kernel size 1 operating on a sequence takes each position's feature vector and applies a learned linear transformation independently to it β which is exactly what $x W_1 + b_1$ does (modulo transposition conventions between linear layers and convolutions). This interpretation connects the Transformer to convolutional architectures, but the key distinction is that the Transformer does not use larger kernels to mix information across positions β that mixing is done entirely by the attention mechanism.
Embeddings and Softmax
Input and Output Embeddings
Like other sequence transduction models, the Transformer converts discrete input and output tokens (words or subword units) into continuous vectors using learned embeddings. An embedding matrix $E \in \mathbb{R}^{|\mathcal{V}| \times d_{model}}$ maps each token in the vocabulary $\mathcal{V}$ to a $d_{model}$-dimensional vector. During training, these embeddings are learned jointly with the rest of the model parameters.
Weight sharing. The same weight matrix is shared between the two embedding layers (source and target) and the pre-softmax linear transformation. This means that the matrix that converts token indices to embedding vectors is the transpose of the matrix that converts decoder output vectors to vocabulary logits. This design choice is borrowed from Press and Wolf [30] and has two motivations: (1) it reduces the total number of parameters (saving $2 \cdot |\mathcal{V}| \cdot d_{model}$ parameters), and (2) it encodes the intuition that tokens that are similar in embedding space should also be similarly likely as outputs β the same geometry that determines which tokens are "close" in meaning also determines which tokens are plausible next-token predictions.
Scaling the embeddings. The paper multiplies the embedding weights by $\sqrt{d_{model}}$ β that is, the embedding lookup returns $\sqrt{512} \cdot e_{\text{token}}$ rather than simply $e_{\text{token}}$. The motivation is not extensively discussed in the paper, but this is a common practice: the embeddings are learned with relatively small values (since they are initialized from a distribution with small variance and regularized during training), while the positional encodings (discussed below) have values in $[-1, 1]$. Multiplying embeddings by $\sqrt{d_{model}}$ increases their magnitude to be more comparable to the positional encodings, preventing the positional signal from being drowned out by the semantic signal. Without this scaling, the model might learn to ignore positional information early in training before the embeddings have grown in magnitude.
Output softmax. The decoder's final output (after the last decoder layer's layer normalization) is a $d_{model}$-dimensional vector per position. This vector is multiplied by the transposed embedding matrix (due to weight sharing) to produce logits over the vocabulary, and a softmax function converts these logits to next-token probabilities:
where $h_i \in \mathbb{R}^{d_{model}}$ is the final representation at position $i$, $W_{\text{emb}} \in \mathbb{R}^{|\mathcal{V}| \times d_{model}}$ is the embedding matrix, and the softmax normalizes over all tokens in the vocabulary.
Positional Encoding
The problem: attention is permutation-invariant. The self-attention mechanism computes weighted averages of value vectors based solely on query-key compatibility. It has no inherent notion of token order β if you permute the input sequence, the attention output at each position permutes correspondingly, but the content of the output at each position is unchanged (just assigned to a different position). This is because the attention function is permutation-equivariant: $\text{Attention}(P Q, P K, P V) = P \cdot \text{Attention}(Q, K, V)$ for any permutation matrix $P$. For tasks where order matters β which includes virtually all language tasks β this is a fundamental limitation.
The Transformer addresses this by injecting positional information directly into the input representations, before any attention computation occurs. This is done by adding a "positional encoding" vector to each input embedding. The encoding depends only on the position of the token in the sequence, not on the token's identity.
The sinusoidal positional encoding:
For position $pos$ and dimension $i$ (where $i \in \{0, 1, \ldots, d_{model}-1\}$):
where $pos$ is the position index (starting from 0), $i$ indexes the dimension pair (0 to $d_{model}/2 - 1$), and $10000$ is a base wavelength that determines the scale of the sinusoids.
What this computes. For each position, the encoding is a deterministic vector of $d_{model}$ numbers. The even-indexed dimensions (0, 2, 4, ...) are computed as sines of position-scaled arguments; the odd-indexed dimensions (1, 3, 5, ...) are computed as cosines of the same arguments. The arguments to the sine and cosine are $pos / 10000^{2i/d_{model}}$.
- For
$i = 0$(the first pair of dimensions), the wavelength is$2\pi \cdot 10000^{0/512} = 2\pi$β this is a sinusoid that completes one full cycle every$2\pi \approx 6.28$positions. This is a high-frequency signal that changes rapidly with position, encoding fine-grained local position information. - For
$i = d_{model}/2 - 1 = 255$(the last pair of dimensions), the wavelength is$2\pi \cdot 10000^{510/512} \approx 2\pi \cdot 10000^{0.996} \approx 2\pi \cdot 10000 \approx 62832$β a very low-frequency sinusoid that changes slowly, encoding coarse, global position information.
The wavelengths form a geometric progression from $2\pi$ to $10000 \cdot 2\pi$, meaning each dimension pair encodes positional information at a different scale. This is analogous to how binary numbers represent numbers using bits of different significance β the low-order bits change rapidly, the high-order bits change slowly.
Why sinusoidal rather than learned? The paper experimented with learned positional embeddings (where each position has a $d_{model}$-dimensional vector that is learned during training, as in ConvS2S [9]) and found "nearly identical results" (Table 3, row E: 25.7 BLEU vs. 25.8 BLEU for the base model). However, the sinusoidal version is chosen because:
"it may allow the model to extrapolate to sequence lengths longer than the ones encountered during training"
Learned positional embeddings can only represent positions that were seen during training (positions 0 through $max\_len - 1$). If the model encounters a longer sequence at test time, position $max\_len$ has no learned embedding β it would require either truncation (losing information) or some form of interpolation. The sinusoidal encoding, being a deterministic function that can be evaluated at any $pos$, naturally handles arbitrary sequence lengths. Whether the model actually generalizes well to longer sequences in practice depends on other factors (the model's attention patterns and feed-forward transformations must also generalize), but the encoding itself imposes no architectural barrier.
Why addition rather than concatenation? The positional encoding is added to the input embedding (and similarly at the decoder input), rather than concatenated. Concatenation would increase the dimensionality of the input to $d_{model} + d_{pos}$, requiring larger weight matrices in the first attention layer. Addition preserves the $d_{model}$ dimensionality, keeping the architecture uniform. The tradeoff is that addition forces the model to disentangle semantic information (from the embedding) and positional information (from the positional encoding) from a single $d_{model}$-dimensional sum β the model must learn to route these two types of information differently in its internal representations.
The inductive bias: relative position via linear functions. The paper hypothesizes a specific property that motivates the sinusoidal choice:
"for any fixed offset
$k$,$\text{PE}_{pos+k}$can be represented as a linear function of$\text{PE}_{pos}$"
This is a mathematical property of sinusoids: $\sin(pos + k)$ can be expressed as $\sin(pos)\cos(k) + \cos(pos)\sin(k)$, which is a linear combination of $\sin(pos)$ and $\cos(pos)$. If the model learns to compute linear transformations of the positional encoding (which is exactly what the learned projection matrices $W^Q, W^K$ in the attention mechanism do), it can potentially learn to attend based on relative position ($pos_{query} - pos_{key}$) rather than absolute position. This would make the attention mechanism translation-invariant, which is a useful inductive bias for many language tasks β the relationship between two words often depends more on their distance than their absolute locations in the sentence.
The paper does not empirically verify that the model actually learns to use relative position information (this would require analyzing the learned attention patterns), but the mathematical property provides a plausible mechanism.
Injection point. The positional encoding is added to the input embeddings at the bottom of both the encoder and decoder stacks β before the first self-attention layer. This means every subsequent layer receives position-informed representations as input, and the positional signal propagates through the residual connections to all deeper layers. The paper does not add positional encodings at intermediate layers (the residual connections already carry positional information forward).
Training Regime
This section brings together all the training details that make the architectural design learnable: the optimizer, learning rate schedule, regularization techniques, and hardware configuration.
Optimizer: Adam
The Transformer uses the Adam optimizer [20] with specific hyperparameters: $\beta_1 = 0.9$, $\beta_2 = 0.98$, and $\epsilon = 10^{-9}$. Adam is an adaptive learning rate optimizer that maintains per-parameter learning rates based on estimates of first and second moments of the gradients. The $\beta_1$ parameter controls the exponential decay rate for the first moment estimate (momentum); $\beta_2$ controls the decay rate for the second moment estimate (variance). Setting $\beta_2 = 0.98$ (higher than the default 0.999) makes the optimizer slightly more responsive to recent gradient variance, which may be appropriate for the Transformer's training dynamics. The small $\epsilon = 10^{-9}$ (compared to the default $10^{-8}$) provides numerical stability without significantly affecting update magnitudes.
Learning Rate Schedule
The learning rate is not constant but varies over the course of training according to:
where $d_{model} = 512$ (so $d_{model}^{-0.5} = 512^{-0.5} \approx 0.0442$), $step\_num$ is the training step counter (starting from 1), and $warmup\_steps = 4000$.
What this computes. The function has two phases:
- Warmup phase (
$step\_num < 4000$): The$\min$selects the second argument, so the learning rate is$d_{model}^{-0.5} \cdot step\_num \cdot warmup\_steps^{-1.5} = d_{model}^{-0.5} \cdot step\_num \cdot 4000^{-1.5}$. This increases linearly from 0 at step 0 to$d_{model}^{-0.5} \cdot 4000^{-0.5}$at step 4000 β the learning rate rises linearly during the first 4000 steps. - Decay phase (
$step\_num \ge 4000$): The$\min$selects the first argument, so the learning rate is$d_{model}^{-0.5} \cdot step\_num^{-0.5} = 512^{-0.5} \cdot step\_num^{-0.5}$. This decays proportionally to the inverse square root of the step number.
Why this schedule? The linear warmup prevents the model from diverging in the early stages of training. At initialization, the model's predictions are essentially random (embeddings are small random values, attention weights are near-uniform, the output distribution is nearly flat). Large gradient updates early in training could push the model into a poor region of parameter space from which it cannot recover. The warmup starts learning with small steps, allowing the optimizer to establish reasonable first and second moment estimates before making substantial parameter updates.
The inverse square root decay is motivated by theoretical convergence results for stochastic gradient descent and has been empirically observed to work well for training large neural networks. It decays the learning rate more aggressively than linear decay but less aggressively than exponential decay, striking a balance between making progress early and refining parameters late.
The $d_{model}^{-0.5}$ scaling factor applies a constant multiplier to the entire schedule. Its purpose is to normalize the learning rate across different model sizes β larger models (with larger $d_{model}$) receive smaller learning rates, which compensates for the fact that the scale of gradients changes with model dimensionality.
Regularization: Dropout
Dropout [33] is applied at three locations during training:
- To the output of each sub-layer, before it is added to the sub-layer input and normalized. This means dropout is applied to the attention output (before the residual connection's addition to the input), to the feed-forward output (again before the residual addition), and to the encoder-decoder attention output. This is the standard residual dropout pattern: dropout is applied to the sub-layer's transformed output, not to the residual path itself.
- To the sums of the embeddings and the positional encodings in both the encoder and decoder stacks. This means dropout is applied to the very first input representation, before it enters the first attention layer. The motivation is to prevent the model from over-relying on specific embedding dimensions or positional encoding values.
For the base model, the dropout rate is $P_{drop} = 0.1$ throughout. For the big model (used on English-to-French), a lower rate of $P_{drop} = 0.1$ is used instead of $0.3$ β the paper mentions this in Section 6.1 parenthetically, noting that the English-to-French big model used $P_{drop} = 0.1$. Table 3 row (D) explores dropout rates of $0.0$, $0.1$, and $0.2$, showing that dropout is "very helpful in avoiding over-fitting" β without dropout, performance drops to 24.6 BLEU (from 25.8 with dropout 0.1).
Regularization: Label Smoothing
Label smoothing [36] is applied to the target distribution during training. Instead of training with hard one-hot targets (where the correct token has probability 1 and all others have probability 0), the target distribution is smoothed:
where $\epsilon_{ls} = 0.1$ and $|\mathcal{V}|$ is the vocabulary size. This means the correct token receives probability $1 - \epsilon_{ls} + \epsilon_{ls}/|\mathcal{V}| \approx 0.9 + \text{very small}$, and all incorrect tokens receive probability $\epsilon_{ls} / |\mathcal{V}|$.
The paper notes that label smoothing "hurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score" (Section 5.4). The intuition is that the model becomes less overconfident in its predictions, avoiding assigning probability 0 to plausible alternatives. This is especially important for translation because there are often multiple valid translations β penalizing a model heavily for predicting a synonym of the reference token would be counterproductive. By requiring the model to spread a small amount of probability mass across all tokens, label smoothing regularizes the output distribution and prevents the model from becoming too peaked, which can lead to better generalization.
Training Data and Batching
For English-to-German, training used the standard WMT 2014 dataset of about 4.5 million sentence pairs. Sentences were encoded using byte-pair encoding (BPE) [3] with a shared source-target vocabulary of approximately 37,000 tokens. BPE splits words into frequent subword units, handling rare and out-of-vocabulary words by decomposing them into known subword pieces.
For English-to-French, the dataset was significantly larger: 36 million sentence pairs from WMT 2014, with sentences split into a 32,000 word-piece vocabulary [38]. Word-piece vocabulary is similar to BPE but uses a likelihood-based criterion for merging subword units rather than frequency-based merging.
Sentence pairs were batched together by approximate sequence length β similar-length sentences are grouped into the same batch to minimize the amount of padding needed (since all sentences in a batch must be the same length for efficient matrix operations). Each training batch contained approximately 25,000 source tokens and 25,000 target tokens. This token-count-based batching (as opposed to sentence-count-based batching) ensures a consistent computational load per batch regardless of sentence lengths.
Hardware and Training Duration
Training was conducted on one machine with 8 NVIDIA P100 GPUs. For the base model, each training step took approximately 0.4 seconds, and training ran for 100,000 steps (about 12 hours total). For the big models, each step took 1.0 second, and training ran for 300,000 steps (3.5 days). The base model was trained with the hyperparameters described throughout Section 3 ($N=6$, $d_{model}=512$, $d_{ff}=2048$, $h=8$, $P_{drop}=0.1$, $\epsilon_{ls}=0.1$). The big model configuration is given at the bottom of Table 3: $N=6$, $d_{model}=1024$, $d_{ff}=4096$, $h=16$, $P_{drop}=0.3$, trained for 300K steps.
Training Cost (FLOPs) Estimation
The paper estimates training cost by multiplying the training time, the number of GPUs, and an estimate of each GPU's sustained single-precision floating-point capacity. For P100 GPUs, the estimated sustained performance is 9.5 TFLOPS (trillion floating-point operations per second). For the Transformer base model trained for 12 hours on 8 P100s, this gives approximately:
This is the number reported in Table 2. By comparison, ConvS2S used $9.6 \times 10^{18}$ FLOPs β nearly 3 times more β and GNMT+RL used $2.3 \times 10^{19}$ FLOPs β about 7 times more. The Transformer's training efficiency advantage is thus quantified as a 3Γ to 7Γ reduction in total floating-point operations compared to convolutional and recurrent state-of-the-art models, while achieving better BLEU scores.
Inference
For generating translations during inference, the paper uses beam search with a beam size of 4 and a length penalty $\alpha = 0.6$ [38]. Beam search maintains the $k$ most promising partial hypotheses at each decoding step and expands each of them, rather than greedily selecting the single most likely next token. The length penalty adjusts the scores to prevent the model from favoring overly short translations (since each additional token multiplies the sequence probability by a factor less than 1, the model would otherwise prefer minimum-length outputs). A penalty $\alpha < 1$ (here 0.6) reduces the per-token penalty, effectively rewarding longer sequences. The maximum output length is set to the input length plus 50 tokens, with early termination when possible.
For the reported results, base models used the average of the last 5 checkpoints (saved at 10-minute intervals); big models used the average of the last 20 checkpoints. Checkpoint averaging is a common ensembling technique that reduces variance in the parameter estimates and typically improves generalization by smoothing out the noise in the stochastic optimization trajectory.
4. Key Insights and Innovations
Innovation 1: Self-Attention as a Complete Replacement for Sequence-Aligned Computation, Not Just an Augmentation
The Transformer's most fundamental intellectual move is not the invention of attentionβattention mechanisms were already well-established by 2017 [2, 19]βbut rather the recognition that attention could serve as the sole computational primitive for sequence transduction, completely displacing the recurrent or convolutional backbone that had been considered indispensable.
What makes this a conceptual leap rather than an incremental tweak is the set of assumptions it overturns. Prior to the Transformer, the dominant mental model for sequence processing was that neural architectures needed some mechanismβrecurrence or convolutionβto impose an inductive bias of locality: nearby tokens are processed together, and distant tokens interact only indirectly through many intermediate processing steps. This bias wasn't just a computational convenience; it reflected a widely-held intuition about how sequences workβthat meaning is built compositionally from adjacent elements outward, that processing should respect the linear order of tokens, and that a model without such a bias would be either too unconstrained to learn effectively or too computationally expensive to be practical.
The Transformer's architecture is a direct rejection of this entire premise. By using self-attention as the only mechanism for mixing information across positions, the model makes every token directly accessible to every other token in $O(1)$ computationβno intermediate representations, no sequentially expanding receptive field, no dilation tricks. The intuition this embodies is radical: the model can and should decide for itself which tokens are relevant to which, without any architectural prior about locality. The burden of learning sensible attention patterns falls entirely on the training data and optimization procedure, not on the structure of the computation.
This is fundamentally different from attention-augmented RNNs [2, 38]. In those models, attention was a retrieval mechanismβthe decoder could look back at specific encoder states to supplement its recurrent hidden state, but the primary flow of information through the decoder was still sequential. You couldn't remove the RNN and keep the model; attention was a helpful add-on, not the engine. The Transformer inverts this relationship: recurrence is removed entirely, and attention becomes the engine. The positional encoding (Section 3.5) and the feed-forward networks (Section 3.3) are the add-ons that supply capabilities attention alone lacksβpositional awareness and per-position non-linear transformationβbut they are auxiliary, not primary.
The paper's framing of this choice, articulated most clearly in the three-desiderata comparison of Section 4 and Table 1, recasts the architecture design problem. Rather than starting with recurrence and asking "how can we make this faster?" or starting with convolution and asking "how can we expand the receptive field?", the Transformer starts with a clean slate: what primitive simultaneously minimizes sequential operations, minimizes path length between distant positions, and keeps total computation manageable? Self-attention is the answer that emerges from this reframing. Prior architectures had optimized one or two of these desiderata at the expense of the third; the Transformer is the first to claim all three simultaneously.
Understanding this as a reframing rather than just a new architecture is essential because it explains why the Transformer has proven so generalizable. It's not that self-attention is inherently the best mechanism for every taskβit's that the design philosophy of letting data-driven attention patterns replace hand-designed structural priors proved to be a more scalable and flexible approach as models and datasets grew. The paper's parsing results (Table 4) gesture at this generality by showing the same architecture working on a task with very different structural properties from translation, but the broader validation came in the years following the paper's publication as Transformers came to dominate virtually every NLP domain.
The paper's positioning makes this reframing explicit by listing a series of architectures that used attention only alongside recurrence [2, 19, 38] and architectures that removed recurrence but used convolution instead [9, 18], then claiming that the Transformer is "the first transduction model relying entirely on self-attention" (Section 2). This is more than a claim of noveltyβit's a claim that the category boundary itself is meaningful, that "models using only attention" constitutes a distinct architectural class with distinct properties worth studying and optimizing.
Innovation 2: Multi-Head Attention as a Mechanism for Jointly Modeling Multiple Relationship Types from a Single, Unstructured Input
A subtle but critical contribution is the recognition that a single attention function with full-dimensional keys and queries is structurally insufficientβnot just empirically suboptimalβbecause it forces the model to compress all the different types of inter-token relationships (syntactic dependencies, semantic associations, positional patterns, coreference links) into a single set of attention weights at each position. Multi-head attention (Section 3.2.2) solves this by giving the model $h$ independent attention operations, each operating in a lower-dimensional projected subspace, that can simultaneously compute different types of relationships and then combine their outputs.
The paper describes this as allowing the model to "jointly attend to information from different representation subspaces at different positions" and notes that "with a single attention head, averaging inhibits this" (Section 3.2.2). The word "inhibits" is doing significant work here. It's not that a single-head model couldn't in principle learn multiple relationship typesβa sufficiently high-dimensional attention function could, theoretically, encode different relationship types in different dimensions of its output. The problem is that the attention weights themselves are a single distribution: the model gets one set of weights per query position to allocate across all key positions. If position $i$ needs to attend to position $j$ for syntactic reasons (e.g., $j$ is $i$'s syntactic head) and position $k$ for semantic reasons (e.g., $k$ is semantically related to $i$), a single-head model must compromiseβthe attention weights become a weighted mixture of these competing demands, and the value vectors $j$ and $k$ get averaged together with weights that reflect a compromise rather than cleanly separating the two signals. Multi-head attention avoids this compromise by giving the model $h$ separate attention distributions, each with its own learned projections, so head 1 can focus entirely on the syntactic relationship (projecting queries and keys into a subspace where syntactic head-dependent relationships are salient) while head 2 simultaneously focuses on the semantic relationship (in a different subspace).
This is a conceptual innovation about the representational capacity of attention, not just a straightforward parallelism trick. Prior work with multiple attention heads existed (e.g., structured attention networks [19]), but the Transformer's formulationβlearned linear projections before attention, concatenation after, with the explicit framing of "different representation subspaces"βtreats the multiple heads as a decomposition of the attention computation into independent, learnable relational modules, each free to specialize. The attention visualizations in the appendix (Figures 3β5) provide suggestive evidence that this specialization actually occurs in practice: different heads in the same layer learn to perform qualitatively different linguistic operations (anaphora resolution in one head, syntactic dependency tracking in another).
The ablation in Table 3 row (A) is particularly informative for understanding this as a real innovation rather than an arbitrary hyperparameter choice. The paper varies the number of heads while keeping total computation constant (by adjusting $d_k$ and $d_v$ inversely), finding that a single head ( $h=1$, $d_k = d_v = 512$ ) achieves 24.9 BLEU vs. the best setting of $h=8$ (25.8 BLEU)βand that $h=16$ and $h=32$ are worse than $h=8$. The inverted-U shape suggests a real tradeoff: too few heads and the model suffers from the "averaging inhibits" problem; too many heads and each head's dimension is too small to learn meaningful projections. Finding this sweet spotβand more importantly, framing it as a resolution vs. diversity tradeoffβis a genuine diagnostic contribution. The optimal number of heads is the one that balances the ability to capture many different relationship types against the representational capacity per head.
This innovation is conceptually distinct from the "use only attention" innovation (Innovation 1) because you could imagine a pure-attention architecture without multi-head attentionβscaled dot-product attention applied once per layer with $d_{model}$-dimensional queries and keys. Such a model would still be attention-only, but it would lack the ability to simultaneously model heterogeneous relationships. Multi-head attention is what makes the pure-attention approach work well, as opposed to merely work at all.
Innovation 3: The Sinusoidal Positional Encoding as a Theory-Driven Inductive Bias for Relative Position Learning
The problem of injecting positional information into an attention-only model is not newβconvolutional sequence models [9] had solved it with learned position embeddings, and the Transformer itself shows that learned embeddings work nearly as well (Table 3, row E: 25.7 vs. 25.8 BLEU). What makes the sinusoidal positional encoding (Section 3.5) an innovation rather than just a functional choice is the theoretical motivation behind the design: the hypothesis that the encoding's mathematical structureβspecifically, the property that $\text{PE}_{pos+k}$ can be expressed as a linear function of $\text{PE}_{pos}$βmakes it easy for the model to learn to attend based on relative position rather than absolute position, and that this inductive bias is useful for sequence transduction.
This is an unusual kind of architectural innovation because it's not driven primarily by empirical performance (learned embeddings work similarly well) but by a hypothesis about what property would make the model generalize better. The crucial property is linear relatability: because sinusoids have the mathematical property that $\sin(pos+k) = \sin(pos)\cos(k) + \cos(pos)\sin(k)$, the encoding at position $pos+k$ can be expressed as a linear combination of the encoding at position $pos$ (with coefficients that depend on $k$ but not on $pos$). If the learned linear projections in the attention mechanism ($W^Q$ and $W^K$) can learn to implement this linear transformationβand they are, after all, linear transformationsβthen the dot product $q_{pos} \cdot k_{pos+k}$ can depend on the relative offset $k$ in a way that is independent of the absolute positions. This would make the attention mechanism translation-invariant with respect to position, which is a natural inductive bias for language: the relationship between a verb and its subject typically depends on their relative position (how many words apart they are) more than on their absolute position (whether they are the 5th and 7th words or the 50th and 52nd).
The paper doesn't prove that the model actually learns this propertyβthe attention visualizations in the appendix don't directly test for relative position encoding, and the paper acknowledges that whether the model generalizes to longer sequences "may allow" rather than "demonstrates." But the design philosophy is what makes this an innovation: rather than treating positional encoding as an afterthought ("we need positions, so here's a vector per position"), the paper treats it as an opportunity to embed a specific inductive bias into the architecture through a mathematically principled design. The choice of sinusoids is not arbitrary but derived from a hypothesis about what property (relative position representation) is useful and what mathematical structure (linear combinability of sinusoids) enables it.
The contrast with learned embeddings is instructive. Learned embeddings treat position as just another discrete symbol to be embeddedβ"position 5" is like "the word 'cat'"βwith no built-in notion that position 5 and position 6 are close while position 5 and position 50 are far apart. The model can learn these relationships from data, but it has to discover the concept of distance from scratch. The sinusoidal encoding builds distance directly into the geometry of the encoding space: the dot product between the encodings at positions $pos$ and $pos+k$ varies smoothly with $k$ in a predictable way. This means that even before any training, the model's attention mechanism has access to a smooth, well-behaved representation of relative distance. The inductive bias is built into the representation, not left for the optimizer to discover.
The additional practical advantageβthat the sinusoidal encoding naturally handles sequence lengths not seen during trainingβis a consequence of this same mathematical property (the encoding is a function, not a lookup table), but the deeper innovation is the idea that positional representations should be designed to make relative position computable via the same linear operations the attention mechanism already uses, rather than being arbitrary vectors that the model must learn to interpret.
Innovation 4: A Unified Architectural Template That Reconciles Training Parallelism with Auto-Regressive Generation
A fourth contribution, more architectural than theoretical but no less significant, is the specific way the Transformer reconciles two apparently conflicting requirements: the desire to process all positions in parallel during training (for computational efficiency) and the need to generate output tokens auto-regressively during inference (where each token depends on previously generated tokens). The masked self-attention mechanism in the decoder (Section 3.2.3, Section 3.1) is the key that makes this reconciliation possible, and its elegance as a design choice is easy to underappreciate.
To see why this is non-trivial, consider the alternatives available in 2017. RNN decoders handle the training-inference mismatch naturallyβthey are inherently sequential in both settings, so there is no mismatch (but training is slow). Convolutional decoders could train in parallel (like the encoder) but required careful causal masking to prevent information leakage from future positions, and the masking had to be implemented at the convolutional layer level, often through shifted convolutions or causal padding. The Transformer's solution is simpler and more unified: the exact same scaled dot-product attention mechanism used everywhere else in the model is reused in the decoder, with the only modification being that the pre-softmax scores are additively masked with $-\infty$ for illegal (future-position) connections.
The conceptual elegance is that the mask is the only difference between training and inference for the decoder self-attention. Everything elseβthe learned projections, the softmax, the value aggregation, the residual connections, the layer normalizationβis identical. This means the model does not need separate training and inference pathways, doesn't need to learn causal dependencies through a different mechanism than it uses for other attention, and doesn't require different parameterizations for the two phases. The mask is applied declaratively (as a matrix of $0$ and $-\infty$ entries) rather than procedurally (as a modified computation graph), which makes the implementation clean and the theoretical analysis straightforward.
Furthermore, the use of masking within the same attention function used for unmasked encoder self-attention and encoder-decoder attention creates a unified attention framework where three qualitatively different operationsβencoding (unrestricted self-attention), decoding self-context (masked self-attention), and source-target alignment (encoder-decoder attention)βare all computed by the same $\text{softmax}(QK^T/\sqrt{d_k})V$ operation with the same multi-head structure, differing only in (a) where $Q$, $K$, and $V$ come from, and (b) whether a mask is applied. This unification is intellectually satisfying because it shows that a single computational mechanism, properly parameterized, can express all three information-routing patterns needed for sequence transduction. Prior architectures typically used different mechanisms for these different operationsβan RNN for encoding, a separate RNN for decoding, and an attention mechanism bolted onto the decoding RNN to access encoder states. The Transformer collapses all of these into one operation used three times.
This innovation is incremental relative to prior masking techniques in convolutional models (which also masked future positions), but it is fundamental in the context of the Transformer's overall design because it enables the decoder to be built from the same components as the encoder, with the same parallel training properties, without sacrificing the auto-regressive constraint. It is the linchpin that allows the claim in Section 4's Table 1β$O(1)$ sequential operations and $O(1)$ path lengthβto apply to the decoder as well as the encoder during training, making the entire model (not just the encoder) trainable with high parallelism.
The importance is heightened by the observation, made explicit in the paper's conclusion, that "making generation less sequential" is a future research goal. The masked self-attention solves the training-time parallelism problem but not the inference-time sequential bottleneckβduring inference, tokens must still be generated one at a time because each token's generation depends on attending to all previously generated tokens. The Transformer's architecture, by making the training-inference distinction hinge on a single mask, makes it clear exactly where the remaining sequential bottleneck lies and suggests a clear target for future work: if you could somehow break the dependency of each decoding step on all previous steps, you could make the entire generation process parallel. This clarity about what is and isn't parallelized is itself a contribution of the architectural design.
5. Experimental Analysis
Evaluation Methodology
-
Dataset. The paper evaluates on two standard machine translation benchmarks: the WMT 2014 English-to-German dataset (approximately 4.5 million training sentence pairs, with news-test2014 as the test set and newstest2013 as the development/validation set) and the WMT 2014 English-to-French dataset (approximately 36 million training sentence pairs, again with newstest2014 as the test set). For English constituency parsing, the paper uses the Wall Street Journal (WSJ) portion of the Penn Treebank (approximately 40K training sentences for the WSJ-only setting; for the semi-supervised setting, additional high-confidence and BerkeleyParser corpora with approximately 17M sentences are included), with Section 22 as the development set and Section 23 as the test set. The English-to-German development set results (newstest2013) are used for all ablation studies reported in Table 3.
-
Base model(s). The paper trains two size variants: the base model (
N = 6,d_model = 512,d_ff = 2048,h = 8, approximately 65 million parameters, trained on 8 NVIDIA P100 GPUs for 100,000 steps or about 12 hours) and the big model (N = 6,d_model = 1024,d_ff = 4096,h = 16, approximately 213 million parameters, trained on 8 P100 GPUs for 300,000 steps or about 3.5 days). The base model is the foundation for all ablation experiments; the big model is used to establish the reported state-of-the-art single-model results on both translation tasks. A smaller 4-layer variant (d_model = 1024) is trained for the parsing experiments to evaluate task generalization. -
Metrics. The primary metric for translation is case-sensitive BLEU score (bilingual evaluation understudy) on the test sets (newstest2014). BLEU measures the n-gram overlap between the model's output and one or more reference translations, with a brevity penalty to discourage overly short outputs. For the development set experiments in Table 3, per-wordpiece perplexity is also reported, measuring how well the model predicts the held-out target tokens (lower perplexity means the model assigns higher probability to the correct tokens). For parsing, the metric is F1 score on Section 23 of the WSJ treebank, following standard constituency parsing evaluation.
-
Baselines. The paper compares against an extensive set of prior state-of-the-art models. For English-to-German: ByteNet [18], Deep-Att + PosUnk [39] (single model), GNMT + RL [38] (single model), ConvS2S [9] (single model), MoE [32] (single model), and ensemble variants of Deep-Att + PosUnk [39], GNMT + RL [38], and ConvS2S [9]. For English-to-French: the same model families with their published single-model and ensemble results. For parsing: a wide range of discriminative, semi-supervised, multi-task, and generative parsers including Vinyals & Kaiser et al. [37], Petrov et al. [29], Zhu et al. [40], Dyer et al. [8], Huang & Harper [14], McClosky et al. [26], and Luong et al. [23]. The base model itself serves as a baseline for the ablation experiments (Table 3). At no point is a simpler recurrent or convolutional baseline trained by the authors β all comparisons are to published numbers from the literature.
-
Generation budget / compute accounting. The paper measures training cost in total floating-point operations (FLOPs) , estimated by multiplying the training time (in seconds), the number of GPUs used, and an estimate of each GPU's sustained single-precision floating-point throughput β specifically, 9.5 TFLOPS for the P100 GPUs used in the Transformer experiments, and 2.8, 3.7, 6.0, and 9.5 TFLOPS for K80, K40, M40, and P100 GPUs respectively for the baseline models (Table 2 footnote). This is a rough approximation that does not account for differences in hardware efficiency, framework overhead, or the fact that different architectures may not achieve the same fraction of peak theoretical throughput. For inference, the paper uses beam search with a beam size of 4 and a length penalty
Ξ± = 0.6(both tuned on the development set), and the maximum output length is set to the input length plus 50 tokens. No inference-time FLOP accounting is reported β the FLOP comparisons are purely about training cost. -
Cross-validation / statistical protocol. The paper does not report standard cross-validation or statistical significance testing. Instead, several specific protocols are used: (1) For translation results, hyperparameters (beam size, length penalty) are tuned on the development set (newstest2013) before evaluating on the test set (newstest2014); (2) For the base model, results are computed by averaging the last 5 checkpoints (saved at 10-minute intervals); for the big model, the last 20 checkpoints are averaged, which functions as a form of parameter ensembling that reduces variance; (3) For the ablation experiments in Table 3, only single models are used (no checkpoint averaging), since the purpose is to diagnose component contributions rather than to maximize absolute performance β the authors explicitly state "We used beam search as described in the previous section, but no checkpoint averaging" for these; (4) For parsing, a small number of experiments are performed on the Section 22 development set to select dropout, learning rate, and beam size, with all other parameters held at the English-to-German translation values. No error bars, confidence intervals, or statistical tests comparing the Transformer to baselines are reported.
Main Quantitative Results
Machine Translation: English-to-German
The central empirical claim of the paper appears in Table 2. On the WMT 2014 English-to-German newstest2014 test set, the Transformer (big) model achieves 28.4 BLEU, which the paper states "outperforms the best previously reported models (including ensembles) by more than 2.0 BLEU." The previously best single model, MoE [32], achieved 26.03 BLEU; the previously best ensemble, ConvS2S Ensemble [9], achieved 26.36 BLEU. The gap to the ensemble is therefore 2.04 BLEU; the gap to the best single model is 2.37 BLEU. Even the Transformer (base) model, trained for only 12 hours, achieves 27.3 BLEU, which surpasses all previously published single models and ensembles (except, implicitly, the Transformer big model itself).
Training cost for the Transformer big model is estimated at 2.3 Γ 10^19 FLOPs. The best-performing prior ensemble (ConvS2S Ensemble) cost 7.7 Γ 10^19 FLOPs β approximately 3.3 times more β while achieving a lower BLEU score. The best prior single model (MoE) cost 2.0 Γ 10^19 FLOPs β comparable to the Transformer big β but scored 2.37 BLEU lower. The Transformer base model cost only 3.3 Γ 10^18 FLOPs β less than half of ConvS2S's 9.6 Γ 10^18 FLOPs β while outperforming it by more than 2 BLEU (27.3 vs. 25.16).
On the development set (newstest2013), the base model achieves 25.8 BLEU and a per-wordpiece perplexity of 4.92 (Table 3). The big model on the development set reaches 26.4 BLEU with 4.33 perplexity.
The beam search configuration used for these results β beam size 4 and length penalty Ξ± = 0.6 β was "chosen after experimentation on the development set" (Section 6.1). The maximum output length constraint (input length + 50) and early termination when possible are adopted from prior work [38].
Machine Translation: English-to-French
On the WMT 2014 English-to-French newstest2014 test set, the Transformer (big) model achieves 41.8 BLEU (Table 2 β note: the text in Section 6.1 states 41.0 BLEU, but Table 2 reports 41.8; the more recent arXiv version resolves this to 41.8, which is the figure quoted in the Abstract and throughout). The paper characterizes this as "a new single-model state-of-the-art" and states it was achieved "at less than 1/4 the training cost of the previous state-of-the-art model." The previous best single model, ConvS2S [9], achieved 40.46 BLEU at a training cost of 1.5 Γ 10^20 FLOPs; GNMT+RL Ensemble [38] achieved 41.16 BLEU at 1.1 Γ 10^21 FLOPs β approximately 48 times more training compute than the Transformer big model (2.3 Γ 10^19 FLOPs) β while scoring lower.
The English-to-French big model used a different dropout configuration: P_drop = 0.1 instead of the 0.3 stated in the big model specification row of Table 3. The paper mentions this parenthetically in Section 6.1, but does not explain why this change was necessary or whether other hyperparameters were also adjusted for this language pair. The base model for English-to-French achieves 38.1 BLEU, which is not state-of-the-art (it underperforms ConvS2S at 40.46 and GNMT+RL at 39.92) but serves to demonstrate that the Transformer can also be applied to larger datasets without architectural modification.
A notable detail: the English-to-French results use a different subword tokenization scheme β 32,000 word-piece vocabulary [38] rather than the 37,000-token byte-pair encoding used for English-to-German. This reflects the practical consideration that the larger training corpus may benefit from a different vocabulary size or tokenization strategy, but the paper does not discuss how this choice affects the comparison or whether the byte-pair encoding would have performed similarly.
English Constituency Parsing
On the WSJ test set (Section 23), the Transformer (4 layers, d_model = 1024) achieves 91.3 F1 in the WSJ-only (supervised, 40K training sentences) setting and 92.7 F1 in the semi-supervised setting (Table 4). In the supervised setting, this outperforms the BerkeleyParser [29] (90.4) and the RNN sequence-to-sequence Grammar as a Foreign Language model [37] (88.3), but is slightly below the Recurrent Neural Network Grammar [8] (91.7). In the semi-supervised setting, it achieves the highest F1 among all models trained without multi-task learning or generative modeling β outperforming the previously best semi-supervised result (Vinyals & Kaiser et al. [37] and McClosky et al. [26], both at 92.1) by 0.6 F1. The only higher results come from a multi-task model [23] at 93.0 F1 and a generative model [8] at 93.3 F1, both of which use different training paradigms and additional signals.
The paper emphasizes that the Transformer achieves these results "despite the lack of task-specific tuning" (Section 6.3). All parameters except dropout, learning rate, and beam size were kept at the English-to-German translation values. The only architectural change was reducing the number of layers to 4 and using a wider model (d_model = 1024 instead of 512), which may reflect the different structural properties of parsing (longer output sequences relative to input, the need for wider representations to capture syntactic structure).
A specific contrast the paper draws: the Transformer trained on WSJ-only (40K sentences, a small data regime) achieves 91.3 F1, while the RNN sequence-to-sequence model from Vinyals & Kaiser et al. [37] (which shares the same overall encoder-decoder paradigm but with recurrent components) achieves only 88.3 F1. The Transformer is furthermore reported as outperforming the BerkeleyParser [29] "even when training only on the WSJ training set of 40K sentences" β the BerkeleyParser being a traditional, feature-rich discriminative parser specifically designed for this dataset, which makes the comparison noteworthy.
Training Speed and Computational Efficiency
While not strictly a "result" in the sense of an accuracy metric, the paper makes substantial claims about training speed that are central to its value proposition. Table 2 reports FLOP counts derived from estimated GPU throughput, and the numbers support the claim that the Transformer achieves a given BLEU level at substantially lower computational cost than prior architectures. For English-to-German, the Transformer big model uses approximately 2.3 Γ 10^19 FLOPs to reach 28.4 BLEU; the best prior ensemble (ConvS2S) uses 7.7 Γ 10^19 FLOPs for 26.36 BLEU β a factor of ~3.3Γ more compute for a lower score. For English-to-French, the Transformer big uses 2.3 Γ 10^19 FLOPs for 41.8 BLEU; the prior best ensemble (GNMT+RL) uses 1.1 Γ 10^21 FLOPs β approximately 48 times more compute for a lower score.
The wall-clock training times are also highlighted: 12 hours for the base model on 8 P100 GPUs, and 3.5 days for the big model. These are presented as dramatically faster than prior models, though the paper does not systematically report the wall-clock time of the baseline models β only their estimated FLOPs. The comparison is therefore primarily on FLOPs rather than elapsed time, which is appropriate since wall-clock time is heavily dependent on hardware, framework implementation, and parallelism strategy.
Ablation Studies and Robustness Checks
All ablation experiments in this section are conducted on the English-to-German translation task using the development set (newstest2013), with the base model as the reference point, and without checkpoint averaging (explicitly stated in Section 6.2). The base model reference performance under these conditions is 25.8 BLEU and 4.92 perplexity (Table 3).
Number of attention heads (Table 3, row A): The paper varies the number of heads while keeping total computation constant by adjusting d_k and d_v inversely (since d_k = d_v = d_model / h). Single-head attention (h=1, d_k = d_v = 512) achieves 24.9 BLEU and 5.29 perplexity β a drop of 0.9 BLEU from the 8-head baseline. With h=4 (d_k = d_v = 128), performance reaches 25.5 BLEU. With h=16 (d_k = d_v = 32), BLEU plateaus at 25.1 with h=16 and drops further to 25.0 with h=32 (d_k = d_v = 16). The finding is non-monotonic: too few heads is clearly worse (single-head drops 0.9 BLEU), but too many heads also degrades performance. The authors interpret the single-head degradation as evidence that "averaging inhibits" the ability to capture diverse relationships, while the degradation with very many heads likely reflects the reduced per-head dimensionality limiting representational capacity.
Attention key size d_k (Table 3, row B): Reducing the attention key dimension d_k from 64 to smaller values while keeping the number of heads constant degrades performance. The base configuration uses d_k = 64 with 25.8 BLEU. With d_k = 16, BLEU drops to 25.1; with d_k = 32, BLEU is 25.4. This suggests that a sufficiently large key dimension is necessary for computing meaningful query-key compatibility. The paper interprets this specifically: "This suggests that determining compatibility is not easy and that a more sophisticated compatibility function than dot product may be beneficial" (Section 6.2). This is a notable observation because it acknowledges that scaled dot-product attention β while computationally efficient β may not be the optimal compatibility function, and that the need for a relatively large d_k (64) is a consequence of the simplicity of the dot-product operation.
Model size β depth (Table 3, row C): Reducing the number of layers from N=6 to N=2 drops BLEU from 25.8 to 23.7 (perplexity increases from 4.92 to 6.11). Increasing depth to N=8 yields 25.5 BLEU β slightly worse than N=6 but at significantly higher parameter count (80M vs. 65M). This suggests that for the base model's width (d_model = 512, d_ff = 2048), N=6 is near the point of diminishing returns for depth. The fact that N=8 does not improve over N=6 may indicate that a wider model (more parameters per layer) is needed to benefit from additional depth, consistent with the big model's success at N=6 with d_model = 1024.
Model size β feed-forward dimension (Table 3, row D): Several configurations are tested that increase d_ff while adjusting other parameters. The base model uses d_ff = 2048, achieving 25.8 BLEU with 65M parameters. Increasing d_ff to 4096 with d_model = 512 yields 26.2 BLEU (perplexity 4.75) with 90M parameters β a clear improvement showing the benefit of wider feed-forward layers. However, a larger configuration with d_model = 1024, d_ff = 4096, 128 attention dimensions, and h = 16 achieves only 25.4 BLEU (53M parameters β curiously smaller than the base due to other configuration changes). The big model combines the best of these findings: d_model = 1024, d_ff = 4096, h = 16, achieving 26.4 BLEU with 213M parameters.
Dropout (Table 3, row D): Three dropout rates are compared: 0.0, 0.1, and 0.2. With no dropout (P_drop = 0.0), BLEU drops to 24.6 (perplexity 5.77) β a decline of 1.2 BLEU from the base model, indicating substantial overfitting. With dropout 0.1 (the base setting), BLEU is 25.8 (perplexity 4.92). With dropout 0.2, BLEU is 25.5 (perplexity 5.47) β slightly worse than 0.1. The paper describes dropout as "very helpful in avoiding over-fitting." The results for P_drop = 0.2 used here (Table 3, row D) appear alongside the Ο΅_ls = 0.0 ablation, which makes it slightly ambiguous whether the 25.5 BLEU reflects dropout alone or an interaction, but the progression from 0.0 β 0.1 β 0.2 is clear.
Label smoothing (Table 3, row D): Two values of label smoothing epsilon (Ο΅_ls) are reported: 0.0 and 0.1. With Ο΅_ls = 0.0 (no label smoothing), BLEU is 25.3 and perplexity is 4.67 β notably, perplexity is lower (better) than the base model's 4.92, but BLEU is lower. This is the phenomenon described in Section 5.4: "label smoothing hurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score." The mechanism is that label smoothing prevents the model from becoming overconfident (which would yield lower perplexity on the training distribution but worse generalization). The BLEU difference is 0.5 in favor of using label smoothing (25.8 vs. 25.3).
Positional encoding: sinusoidal vs. learned (Table 3, row E): Replacing the sinusoidal positional encoding with learned positional embeddings [9] yields 25.7 BLEU and 4.92 perplexity β nearly identical to the base model's 25.8 BLEU. This confirms that the choice of positional encoding mechanism does not significantly affect performance at the sequence lengths encountered in training. However, as discussed in Innovation 3 (Section 4), the paper retains the sinusoidal encoding because of the hypothesized generalization advantage to unseen sequence lengths β a property not tested in this ablation.
Critical Assessment
Claim: The Transformer Is "Superior in Quality" to Recurrent and Convolutional Models
The paper's headline claim β that the Transformer is "superior in quality" (from the Abstract) β is supported by the machine translation results with important caveats. On English-to-German, the big Transformer (28.4 BLEU) does outperform all prior models, including ensembles. The improvement over the best ensemble (+2.0 BLEU) is substantial by BLEU standards. On English-to-French, the claim is more precisely about single-model state-of-the-art (41.8 BLEU), since the best ensemble (GNMT+RL at 41.16) is close to but still below the Transformer single model.
However, several factors complicate the "superior in quality" claim:
First, the comparison is exclusively to published results from different research groups using different hardware, software frameworks, and training recipes. The paper does not train a strong recurrent or convolutional baseline under identical conditions (same dataset, same subword vocabulary, same optimizer, same regularization). The FLOP estimates in Table 2 are rough β they multiply wall-clock time by estimated GPU throughput, which conflates algorithmic efficiency with implementation quality. A recurrent model implemented in the same framework with the same engineering effort might close part of the BLEU gap or reduce the FLOP advantage. This is not a fatal weakness β reimplementing every prior architecture is expensive β but it means the claim should be understood as "the Transformer achieves higher BLEU than any previously reported model" rather than "the Transformer is intrinsically better than any recurrent model."
Second, the English-to-French big model uses a different dropout rate (P_drop = 0.1 vs. 0.3 in the big model row of Table 3) without explanation. If the dropout rate was tuned separately for English-to-French, then the model configuration was not "identical" to what is specified in Table 3, and the comparison to English-to-German is not fully controlled. Similarly, the vocabulary sizes differ between the two language pairs (37K for EN-DE, 32K for EN-FR) and tokenization schemes differ (BPE vs. word-piece), both of which affect BLEU scores independently of the architecture.
Third, the BLEU scores for English-to-German are computed on the standard WMT newstest2014 test set with standard tokenization and evaluation scripts, which makes the comparison to prior work valid. But the paper does not discuss the single-reference limitation of BLEU β translation quality is multi-faceted (adequacy, fluency, style), and a single reference translation can only capture one way of translating a given sentence. A model might produce valid translations that BLEU would penalize because they don't match the specific reference wording. This is a limitation of the evaluation protocol more than of the paper, but it means "superior in quality" is narrower than it sounds β it specifically means "higher n-gram overlap with reference translations."
Claim: The Transformer Is "Significantly Faster to Train"
This claim is strongly supported by the FLOP comparison in Table 2, but the measurement methodology warrants scrutiny. The paper multiplies training time Γ number of GPUs Γ estimated sustained TFLOPS per GPU. This has three sources of uncertainty:
-
Sustained TFLOPS estimates are rough. The P100 is rated at 9.5 TFLOPS for single-precision, but actual throughput depends on operation mix, memory bandwidth, kernel launch overhead, and framework efficiency. The Transformer's heavy use of matrix multiplication (for attention:
QK^T; for feed-forward:xW) maps efficiently to GPU tensor cores, potentially achieving a higher fraction of peak throughput than recurrent operations (which involve more sequential, less paralellizable computations). The FLOP comparison therefore favors the Transformer structurally β its operations are more likely to approach peak hardware efficiency. -
Different GPUs for different baselines. The baseline FLOP numbers in Table 2 are computed using different GPU types (K80 at 2.8 TFLOPS, K40 at 3.7 TFLOPS, M40 at 6.0 TFLOPS, P100 at 9.5 TFLOPS). The Transformer used P100 GPUs; ConvS2S used a mix (the paper's estimate uses P100 numbers for ConvS2S, but the original ConvS2S paper may have used different hardware). These cross-GPU FLOP estimates are inherently approximate.
-
The FLOP comparison does not control for hyperparameter tuning cost or development experiments. The reported numbers are for a single final training run. In practice, achieving these results required unknown amounts of development compute (training ablated models, tuning hyperparameters). This is true for both the Transformer and the baselines, but the absolute numbers in Table 2 capture only the final training.
None of these invalidate the core finding β the Transformer is substantially more compute-efficient for reaching a given BLEU β but the precise multiplier (3.3Γ, 7Γ, 48Γ) should be understood as approximate rather than exact ratios.
Claim: The Transformer Generalizes to Other Tasks (Constituency Parsing)
The parsing results in Table 4 are genuinely surprising and well-executed as a demonstration of task generality. The authors kept almost all hyperparameters at their translation values, including the model architecture (except reducing N from 6 to 4), and still achieved competitive or state-of-the-art results. This is a stronger test of generalization than it might appear: parsing has very different structural properties from translation (the output is a tree, not a sequence of natural language tokens; the output is typically longer than the input; strong syntactic constraints apply), and the training data is orders of magnitude smaller (40K sentences vs. 4.5M).
However, the parsing experiments are limited in scope. Only one configuration is tested (4 layers, d_model = 1024), and only a "small number of experiments" were performed to tune dropout, learning rate, and beam size on the development set. The paper does not report perplexity on the parsing development set, ablate parsing-specific design choices (e.g., is d_model = 1024 important for the small data regime?), or compare against a recurrent baseline trained under identical conditions. The comparison to prior work is again to published numbers from different research groups, not to a retrained baseline.
The 92.7 F1 semi-supervised result is genuinely impressive β it matches or exceeds all prior models except the generative RNN Grammar [8] (93.3 F1), which is a fundamentally different class of model that jointly models the string and the parse tree. That the Transformer can approach a generative parser's performance as a discriminative sequence-to-sequence model suggests real representational power. But the contribution is empirical rather than analytical β the paper does not investigate why the Transformer works for parsing, whether its attention patterns resemble syntactic dependencies, or whether specific architectural choices are important for the parsing task.
Claim: Self-Attention Layers Are More Interpretable
The paper presents attention visualizations (Figures 3β5 in the appendix) as a "side benefit" (Section 4), showing that different attention heads appear to learn different linguistic operations. Figure 3 shows attention heads in encoder layer 5 attending to the distant dependency of the verb "making," tracking the phrase "making...more difficult." Figure 4 shows two heads involved in anaphora resolution for the word "its." Figure 5 shows two heads exhibiting "behaviour that seems related to the structure of the sentence."
These visualizations are suggestive but not rigorous. The paper presents them as examples, not as systematic analysis. There is no quantification of what fraction of heads show interpretable patterns, no comparison of different layers, and no verification that the apparent linguistic patterns are consistent across sentences or actually causal for the model's predictions. The claim of interpretability is a qualitative observation, not an experimentally validated finding. This is appropriate for a paper that is primarily about architectural design and translation quality, but the claim should be understood as a direction for future work rather than an established result.
The Ablation Experiments: Design and Coverage
The ablation experiments in Table 3 are valuable for understanding which components of the Transformer matter and how much. But several important ablations are missing:
- No ablation of the number of encoder layers separate from decoder layers. The experiments vary
Nfor both encoder and decoder together. It is possible β even likely β that the optimal depth differs between encoding and decoding, since they perform qualitatively different operations (bidirectional context integration vs. auto-regressive generation). - No ablation of the residual connection structure. The paper uses residual connections around every sub-layer followed by layer normalization. What happens if residual connections are removed, or if layer normalization is applied before the sub-layer rather than after (the "pre-norm" variant that later became common in Transformer implementations)?
- No ablation of the expansion ratio in the feed-forward network. The base model uses a 4Γ expansion (
d_ff = 2048vs.d_model = 512). Row D of Table 3 tests differentd_ffvalues but in combination with other parameter changes, making it difficult to isolate the effect of the expansion ratio. - No ablation of weight sharing between embeddings and pre-softmax linear. The paper mentions weight sharing as a design choice [30] but never tests whether removing it hurts performance. This would require only a small parameter-count increase and would isolate the contribution of this inductive bias.
- No ablation of the scaling factor
1/β(d_k)in attention. The theoretical motivation (preventing softmax saturation for larged_k) is testable: ford_k = 64, does removing the scaling factor degrade performance? The paper doesn't test this directly, relying instead on the cited observation [3] that unscaled dot-product attention underperforms additive attention for larged_k.
The experiments in Table 3 row (D) also combine multiple parameter changes in single rows, making it difficult to attribute performance changes to specific factors. For example, the row with d_model = 512, d_ff = 4096, and h = 16 (128 key/value dimensions) achieves 26.0 BLEU with 168M parameters β but is the improvement from the larger d_ff (4096 vs. 2048), the different attention configuration, or the interaction? Separating these would require a more systematic factorial design.
What Is Not Tested
Several experiments that would significantly strengthen the paper's claims are absent:
-
Learning curve comparisons. The paper reports final BLEU scores and total FLOPs, but does not show how BLEU improves over the course of training for the Transformer vs. baselines. If the Transformer reaches a given BLEU earlier in training (fewer steps), the FLOP advantage would be even larger than reported (since the comparison is based on full training runs).
-
Sequence length scaling experiments. The paper claims that self-attention's
O(1)path length is advantageous for long sequences, but all experiments use standard WMT sentence lengths (typically under 100 tokens). There is no experiment on a long-sequence task (document-level translation, summarization, long-range dependency benchmarks) that would test whether the architectural advantage actually materializes. -
Attention pattern analysis at scale. The paper presents 3 figures of attention visualizations from a single model and a handful of sentences. There is no systematic analysis of whether head specialization is consistent, whether deeper layers show different attention patterns than shallow layers, or whether the patterns correlate with linguistic phenomena.
-
Comparison to a strong RNN trained under identical conditions. This would directly test the claim that self-attention is superior to recurrence, rather than testing whether the Transformer implementation (with its specific optimization and regularization choices) outperforms published recurrent models trained by other groups.
-
Inference cost comparison. The paper focuses entirely on training cost, never reporting inference latency or throughput. During inference, the Transformer decoder still generates tokens sequentially (the masked self-attention cannot parallelize across output positions during auto-regressive generation). An RNN decoder has similar sequential inference cost. The paper's claim of "more parallelizable" applies primarily to training, not to inference, but this distinction is not made explicit.
6. Limitations and Trade-offs
The Computational Cost Limits Application to Long Sequences
The assumption or constraint. The self-attention mechanism at the core of the Transformer has computational complexity per layer, where is the sequence length and is the representation dimensionality (Table 1). The paper acknowledges this explicitly in Section 4:
"To improve computational performance for tasks involving very long sequences, self-attention could be restricted to considering only a neighborhood of size in the input sequence centered around the respective output position."
The paper presents this as a future direction β "We plan to investigate this approach further in future work" β but does not implement or evaluate any form of restricted or sparse attention in the experiments. The quadratic dependence means that doubling the sequence length quadruples the memory and computation required for the attention matrices, which store pre-softmax scores for each attention head in each layer.
The consequence. For tasks with sequence lengths substantially longer than the typical WMT sentence (roughly 20β60 tokens after subword encoding), the Transformer becomes impractical. A document-level translation task with sequences of 500 tokens requires times more attention computation per layer than the average sentence in the paper's experiments. For tasks involving images as sequences (where can be thousands), video (tens of thousands), or long-form text (documents, books), the naive self-attention is infeasible on commodity hardware. This limits the Transformer's immediate applicability to the class of problems β sentence-level NLP tasks β on which it was evaluated, and means the architectural innovation alone does not extend the range of sequence lengths that neural models can handle compared to recurrent or convolutional alternatives.
The paper's own comparison in Table 1 acknowledges that self-attention is faster than recurrence only "when the sequence length is smaller than the representation dimensionality ." For , this means β which holds for the WMT data but excludes many real-world sequence transduction problems. When exceeds , the recurrent complexity may become more favorable than attention, flipping the efficiency advantage the paper emphasizes.
What evidence exists in the paper. The paper provides no experiments testing the Transformer on sequences longer than those occurring in the WMT datasets. The longest sequences in WMT typically fall under 100 tokens β well within the regime where . There is no characterization of memory usage, wall-clock time, or convergence behavior as sequence length increases. The parsing experiments (Section 6.3) involve output sequences that are "significantly longer than the input" (the paper states this explicitly), but no quantitative analysis of how the Transformer's training time or memory scales with parsing sequence lengths is provided. The attention visualizations (Figures 3β5) examine individual sentences of standard length, providing no evidence about attention pattern quality or interpretability on longer sequences.
Mitigation status. The paper acknowledges the limitation (Section 4) and proposes restricted self-attention β where each position attends only to a neighborhood of size β as a solution, reducing complexity from to . But this constitutes approximately two sentences of forward-looking speculation, with no experimental validation. Setting would involve a tradeoff between computational efficiency (small means faster training) and path length (restricted attention increases the maximum path length from to , partially sacrificing the architectural advantage over convolution). The paper does not explore what values of are practical, whether restricted attention degrades translation quality for standard-length sequences, or how the three desiderata (computational complexity, parallelizability, path length) compare under restricted attention to recurrent and convolutional alternatives.
Inference Remains Inherently Sequential Despite Training Parallelism
The assumption or constraint. The Transformer decouples training parallelism from inference parallelism. During training, the masked self-attention allows all output positions to be computed simultaneously β the teacher-forced target sequence is available, and the mask simply prevents information flow from future positions. But during inference, this parallelism is lost: the model generates tokens one at a time, auto-regressively, because each token depends on all previously generated tokens. Each decoding step requires recomputing the attention over all previously generated positions.
The paper acknowledges this tension in the conclusion: "Making generation less sequential is another research goal of ours" (Section 7). But the architectural design β particularly the fact that the decoder self-attention operates over the entire growing output sequence at each step β means that inference time scales quadratically with output sequence length. Specifically, generating an output sequence of length requires sequential passes through the decoder (one per token), and pass involves computing self-attention over the generated tokens, costing . The total inference cost is therefore in the naive implementation.
The consequence. Latency-sensitive applications cannot benefit from the Transformer's training parallelism. An RNN decoder has identical sequential inference steps but costs per step β linear in rather than quadratic because the RNN state summarizes the history in a fixed-size vector. A Transformer decoder costs total for self-attention across all steps (plus encoder-decoder attention), making it potentially slower than an RNN decoder for long outputs despite being dramatically faster during training.
This matters for interactive applications: machine translation in a chat interface, real-time speech recognition, or any setting where users wait for model output. The paper's headline training speed numbers (12 hours, 3.5 days) characterize only one phase of the model lifecycle. For a deployed translation service that processes millions of queries per day, inference cost β not training cost β dominates the total computational budget. The paper reports no inference latency measurements, no throughput numbers (sentences per second), and no comparison of inference cost to prior architectures.
Furthermore, during inference, the decoder must attend to the growing output sequence. Storing the key and value vectors for all previously generated tokens requires memory proportional to the output length. For long outputs, this can exceed GPU memory, requiring either truncation of the context window (losing long-range dependencies that the architecture was designed to capture) or sophisticated caching and swapping strategies.
What evidence exists in the paper. The paper provides no inference-time measurements whatsoever. The beam search details (beam size 4, length penalty , maximum output length of input length + 50) are reported without associated latency or throughput numbers. The FLOP comparison in Table 2 covers only training cost, not inference cost. The paper's claim that the Transformer is "more parallelizable" (Abstract) is true for training but potentially misleading for deployment, where parallelism is constrained by the auto-regressive decoding loop. This distinction between training and inference parallelism is never made explicit.
Mitigation status. The paper does not address inference cost or propose mechanisms for reducing it. The conclusion's mention of "making generation less sequential" as a research goal acknowledges the limitation without taking steps toward a solution. Subsequent work (not part of this paper) developed techniques like non-auto-regressive generation, cached decoder states for incremental decoding, and speculative decoding β but the Transformer architecture as presented here inherits the full sequential inference burden of auto-regressive models without any of these mitigations.
The Evaluation Is Confined to a Single Model Family on Two NLP Tasks
The assumption or constraint. All experiments are conducted with a single base architecture trained from scratch for each task. There is no evaluation of the Transformer's performance when pre-trained (a paradigm that would later become dominant), no transfer learning experiments (e.g., fine-tuning a translation-trained model on parsing), and most critically, no testing on tasks outside of machine translation and constituency parsing. The paper claims that the Transformer "generalizes well to other tasks" (Abstract), but the evidence for this claim rests entirely on one additional task β English constituency parsing β which, while structurally different from translation, is still a sequence transduction task with well-defined input-output pairs and symbolic target representations.
The paper does not test the Transformer on: language modeling (where the decoder-only variant would later become dominant), text classification, natural language inference, question answering, summarization, or any task requiring reasoning beyond sequence-to-sequence mapping. The model used is also specific β a particular parameter count, depth, and width, trained with a particular optimizer and learning rate schedule. There is no evidence about how these hyperparameters transfer to other domains, or whether the architecture is robust to different training data sizes (the translation datasets are both large β 4.5M and 36M sentence pairs respectively β while the parsing experiments test only one small-data setting of 40K sentences).
The consequence. A practitioner reading this paper cannot determine whether the Transformer would be effective for their specific task, dataset size, or computational budget. The paper's results establish that self-attention-only architectures can work for machine translation and constituency parsing, but provides no guidance on: (1) whether the architecture succeeds on tasks where the relationship between input and output is classification rather than generation; (2) how model size should scale with dataset size (the base model has 65M parameters for 4.5M sentence pairs; the big model has 213M parameters for 36M sentence pairs β does this ratio generalize?); (3) whether the specific hyperparameter choices (, , ) are near-optimal for these tasks or would need substantial retuning for other domains.
The parsing experiments partially address the task generalization concern but also reveal an important gap: the paper ran only "a small number of experiments to select the dropout, both attention and residual (section 5.4), learning rates and beam size on the Section 22 development set, all other parameters remained unchanged from the English-to-German base translation model" (Section 6.3). This means the parsing model inherits hyperparameters (optimizer settings, learning rate schedule, warmup steps, label smoothing, depth-to-width ratio) that were tuned for a 4.5M-sentence translation task and applied without modification to a 40K-sentence parsing task. The fact that this works is impressive, but it also means the paper provides no evidence about what the optimal Transformer configuration for parsing would be, or whether the translation-tuned hyperparameters were suboptimal.
What evidence exists in the paper. The paper's evidence for task generalization consists of Table 4 (parsing results) and the attention visualizations in Figures 3β5 (which are qualitative and from a translation model). The parsing results include only one configuration (4 layers, ) with minimal hyperparameter tuning. There is no ablation of architectural choices for parsing (e.g., does depth matter more or less than for translation? Is multi-head attention as important?). There is no experiment varying the amount of training data to characterize sample efficiency, and no experiment on a non-sequence-transduction task.
Mitigation status. The paper does not acknowledge the narrowness of its evaluation as a limitation. The claim of task generalization is presented as established rather than preliminary. The paper's title β "Attention Is All You Need" β makes a universal architectural claim, but the experimental support covers two tasks, both in the NLP domain, both using the encoder-decoder configuration. The gap between the claim's scope and the evidence's coverage is not discussed. Subsequent work (by other groups, years after this paper) validated the Transformer on a much wider range of tasks, but the paper itself provides no such evidence and no principled argument for why the architecture should generalize beyond the tested domains.
The FLOP Comparison to Baselines Is Approximate and Potentially Biased
The assumption or constraint. The paper quantifies the Transformer's training efficiency advantage through estimated floating-point operations (FLOPs), computed as (training time in seconds) Γ (number of GPUs) Γ (estimated sustained TFLOPS per GPU). The estimates of sustained TFLOPS are given in a footnote to Table 2: 2.8, 3.7, 6.0, and 9.5 TFLOPS for K80, K40, M40, and P100 GPUs respectively. The Transformer was trained on P100 GPUs (9.5 TFLOPS); the baseline models were trained on various hardware generations.
The paper does not measure actual FLOPs (e.g., via operation counting in the computation graph). It does not account for idle time (GPUs waiting for data loading, communication, or CPU-bound operations). It does not verify that the sustained throughput assumption is accurate for each architecture (recurrent models may achieve a lower fraction of peak throughput than matrix-multiply-heavy models). And it does not control for differences in implementation quality, framework efficiency, or hyperparameter optimization effort.
The consequence. The precise efficiency multipliers reported in the paper β such as the Transformer big model requiring "less than 1/4 the training cost" for English-to-French, or the 3.3Γ advantage over ConvS2S for English-to-German β may not reflect actual compute savings if the baseline models were suboptimally implemented or if the FLOP estimation method systematically favors the Transformer's operation mix. The Transformer's computation is dominated by large matrix multiplications (for attention scores, value aggregation, and feed-forward transformations), which are the operations that GPUs execute most efficiently. Recurrent models involve more sequential, element-wise operations that underutilize GPU parallelism. The sustained TFLOPS estimate (9.5 for P100) is a single number applied uniformly to all models regardless of their operation mix, which effectively assumes all architectures achieve the same hardware efficiency β an assumption that is almost certainly false.
Furthermore, the FLOP comparison ignores hyperparameter tuning cost. The Transformer's architecture, optimizer, learning rate schedule, dropout rates, and label smoothing were tuned through an unknown number of development experiments. The paper does not count the FLOPs consumed during this tuning process toward the training cost, even though a practitioner seeking to reproduce the results would need to incur similar tuning costs. This is standard practice in the field, but it means the reported 12-hour training time for the base model understates the total compute required to arrive at that configuration.
What evidence exists in the paper. Table 2 reports the FLOP estimates used for comparison, but the paper provides no sensitivity analysis (e.g., how does the ranking change if sustained TFLOPS estimates are off by Β±20%?). The footnote with hardware TFLOPS numbers is the only documentation of the estimation method. There is no direct measurement of FLOPs via profiling tools, no reporting of GPU utilization rates during training, and no discussion of whether the Transformer achieves a higher or lower fraction of peak TFLOPS than the baseline architectures.
Mitigation status. The paper does not acknowledge the approximation involved in the FLOP comparison or discuss its potential bias. The efficiency claims in the Abstract and Section 6.1 are presented as precise facts ("3.5 days on eight GPUs, a small fraction of the training costs of the best models"), with no qualification about estimation methodology. The FLOP numbers are treated as directly comparable across different hardware generations, GPU models, and framework implementations β an assumption that a practitioner making resource allocation decisions would need to verify independently.
The Architecture Introduces Multiple Hyperparameters With No Systematic Tuning Guidance
The assumption or constraint. The Transformer introduces a large number of interacting hyperparameters with no systematic sensitivity analysis or tuning protocol. The key architectural hyperparameters include: number of encoder/decoder layers (), model dimensionality (), feed-forward inner dimensionality (), number of attention heads (), per-head dimensionality (), dropout rate ( for base, for big), and label smoothing (). The training hyperparameters include: optimizer choice (Adam), Adam betas (, ), Adam epsilon (), warmup steps (4000), learning rate schedule shape (inverse square root decay with linear warmup), and the scaling factor in the learning rate formula.
The ablations in Table 3 provide partial sensitivity analysis: number of heads (row A), key size (row B), depth (row C), model size interactions (row D), and positional encoding type (row E). But many hyperparameters are tested only in confounded combinations: row D simultaneously varies , , , , and across different rows, making it impossible to attribute performance changes to individual hyperparameters. Critical hyperparameters receive no ablation: the Adam value (why not the default 0.999?), the warmup steps of 4000 (what happens with 1000 or 10000?), the learning rate schedule shape (why inverse square root rather than linear or cosine?), the scaling factor in the learning rate, and the choice of versus other encoder-decoder depth combinations.
The consequence. A practitioner seeking to apply the Transformer to a new task, dataset size, or compute budget faces an underdetermined configuration problem. The paper provides a single recipe β the base model hyperparameters β validated on two translation tasks of specific sizes (4.5M and 36M sentence pairs). It provides no guidance on how these hyperparameters should be adjusted for: smaller datasets (where overfitting risks differ), larger datasets (where the 65M-parameter base model might be capacity-limited), different sequence lengths, different vocabulary sizes, or different target modalities. The fact that the English-to-French big model used instead of the specified in Table 3 β without explanation or exploration β suggests the hyperparameters were adjusted post-hoc without systematic study.
The interaction between hyperparameters is particularly problematic. The paper's key finding β that increasing model size improves performance (Table 3, row D) β is demonstrated by comparing configurations that differ in multiple dimensions simultaneously. The "big" model uses , , , , and (Table 3) β a 3.3Γ parameter increase over the base model. It is unclear whether the improvement from 25.8 to 26.4 BLEU on the development set is primarily due to the wider model, the larger feed-forward layers, the increased number of heads, or the different dropout rate. Each of these changes could be individually important or largely redundant, and the paper provides no ablation to disambiguate.
What evidence exists in the paper. Table 3 provides the only systematic hyperparameter evaluation. The rows are sparse β many combinations are not tested, and many hyperparameters receive no ablation at all. The paper does not report the number of development experiments conducted to arrive at the base configuration, making it impossible to estimate how much hyperparameter tuning contributed to the final performance. The standard practice of reporting "hyperparameters were chosen after experimentation on the development set" (Section 6.1, regarding beam size and length penalty) is applied to inference hyperparameters but not to the substantially larger set of training and architectural hyperparameters.
Mitigation status. The paper does not acknowledge the hyperparameter sensitivity as a limitation or provide a tuning methodology. The base model configuration is presented as a fixed reference point rather than as one point in a space that practitioners would need to explore. The paper's contribution is architectural β establishing that a self-attention-only model can work β not methodological guidance for configuring such models. For a practitioner seeking to reproduce or adapt the Transformer, this is a significant practical gap. The paper provides no heuristics for scaling the model with available compute (e.g., "if you have 4Γ more GPUs, should you increase , , , or all three?"), no guidance on minimum dataset sizes for stable training, and no characterization of training instability modes (divergence, slow convergence, poor generalization) that might arise from suboptimal hyperparameter choices.
7. Implications and Future Directions
How This Work Changes the Landscape
The Transformer did not merely improve the state of the art on machine translationβit redefined what a neural sequence model is allowed to be. Prior to 2017, the dominant mental model for sequence processing was that architectures needed some mechanismβrecurrence or convolutionβto impose a structural prior about locality and sequential order. The Transformer demonstrated that this prior was not necessary, and more importantly, that discarding it could yield dramatic improvements in both training efficiency and model quality. This is a paradigm shift, not an incremental refinement: the entire research program of designing recurrent architectures with better gating, more sophisticated memory, or faster sequential computation was rendered orthogonal to the question of how to build the best sequence transduction models. The question shifted from "how do we make recurrence faster?" to "given that attention works, how do we scale it, regularize it, and adapt it to every domain?"
The paper's reframing of the architecture design problem through the three desiderata in Table 1βcomputational complexity per layer, minimum sequential operations, and maximum path lengthβfundamentally changed how researchers evaluate architectural choices. Prior work had optimized individual metrics (e.g., ByteNet and ConvS2S minimized sequential operations while accepting longer path lengths; recurrent models accepted sequential bottlenecks to get linear complexity). The Transformer claimed all three simultaneously, with the explicit tradeoff that the path length comes at the cost of memory. The field internalized this tradeoff as the central architectural tension for the next several yearsβthe question became how to approximate the Transformer's attention pattern with sub-quadratic complexity, not whether attention-based models were viable.
The work also resolved a latent contradiction that had been growing in the sequence modeling literature. On one side, attention-augmented RNNs [2, 38] had shown that attention mechanisms dramatically improved translation quality, particularly for long sentences where the fixed-size RNN bottleneck state was insufficient. On the other side, purely convolutional architectures [9, 18] had shown that removing recurrence entirely could accelerate training without catastrophic quality loss, but at the cost of requiring many layers or dilated convolutions to connect distant positions. These two lines of evidence pointed in the same directionβrecurrence was the bottleneck, attention was the solutionβbut no one had taken the logical next step: remove recurrence entirely and use attention for everything. The Transformer made this move explicitly, and the result (~2 BLEU improvement over the best ensemble systems, achieved at a fraction of the training cost) validated the hypothesis that recurrence was not just inefficient but actually harmful to model quality in the regime of available compute.
The paper also redirected research investment in concrete ways. Before the Transformer, substantial effort was devoted to improving recurrent cells (LSTMs, GRUs, phrasal LSTMs, multiplicative LSTMs), developing better attention mechanisms over RNN hidden states, and engineering conditional computation for recurrent models (e.g., the MoE model [32] that the Transformer outperformed). After the Transformer, these research directions became niche at best and obsolete at worst. The community's attention (and compute) shifted toward: transformer variants for different modalities; scaling laws for transformer training; efficient attention approximations for long sequences; pre-training objectives that leverage the transformer architecture; and interpretability studies of attention patterns. This reallocation of scientific effort is a hallmark of a genuine paradigm shiftβthe old questions didn't get answered; they stopped being asked.
The paper's impact was amplified by a secondary contribution that is easy to overlook: the architectural simplicity of the Transformer made it easy to reimplement, modify, and scale. The entire model is built from a small set of standard operationsβmatrix multiplication, softmax, ReLU, layer normalization, residual connectionsβall of which had highly optimized implementations in deep learning frameworks. There were no custom recurrent cells requiring careful initialization, no complex attention mechanisms with separate alignment models, and no architectural components that required specialized gradient computation. This meant that within months of publication, the Transformer had been reimplemented in every major framework and adapted to dozens of tasks by groups with no connection to the original authors. This reproducibility through simplicity is not an accidentβit is a design property of the architecture, and it accelerated the paper's impact far beyond what the translation numbers alone would suggest.
The parsing results (Table 4), while limited in scope, gestured at a broader claim that the community was quick to investigate: that the Transformer works not just for translation but for any task where relationships between elements of a sequence or set matter. The fact that the same architecture, with minimal tuning, could approach state-of-the-art on a structurally very different task (parsing) with 1/100th the training data of the translation experiments suggested that self-attention captures something fundamental about linguistic structure that transcends specific tasks. This was not proved in the paper, but it was the hypothesis that launched a thousand follow-up papers.
Follow-Up Research This Work Enables
Scaling the Transformer to longer sequences through efficient attention approximations. The paper explicitly identifies the complexity of self-attention as the primary limitation for long sequences (Section 4), and proposes restricted self-attentionβwhere each position attends only to a neighborhood of size βas a solution. The natural follow-up is to implement and evaluate this on a long-sequence task. A strong experiment would train a Transformer with restricted self-attention on a document-level machine translation benchmark (e.g., WMT document-level tasks, or summarization datasets like CNN/DailyMail where input documents average ~800 tokens) and compare against both the unrestricted Transformer (for sequence lengths where it fits in memory) and strong recurrent/convolutional baselines. The key measurements would be: (1) BLEU/ROUGE as a function of the neighborhood size , to characterize the tradeoff between efficiency and path length (the paper's vs. theoretical bound); (2) memory usage and training throughput at scale, since the theoretical complexity is only beneficial if ; and (3) which attention heads learn to attend within vs. beyond their restricted neighborhoods, to determine whether the structural prior imposed by restricted attention is compatible with the linguistic phenomena (anaphora, long-distance dependencies) the model needs to capture. A negative resultβthat restricted attention performs well for translation (where most relevant context is local) but poorly for tasks requiring genuine long-range reasoningβwould be highly informative, because it would establish what the path length is actually buying.
Systematic comparison of positional encoding schemes and their effect on length generalization. The paper presents sinusoidal positional encodings with a specific theoretical motivationβ"for any fixed offset , can be represented as a linear function of " (Section 3.5)βand shows that learned embeddings perform nearly identically on in-distribution sequence lengths (Table 3, row E: 25.7 vs. 25.8 BLEU). The claimed advantage of sinusoidal encodings is extrapolation to sequence lengths not seen during training, but this claim is never tested. A direct follow-up would train Transformers with sinusoidal and learned positional encodings on sequences up to length (say, 64 tokens), then evaluate on sequences of length (say, 128, 256, 512 tokens). If the sinusoidal model maintains performance while the learned embedding model degrades sharply, it validates the extrapolation hypothesis and the design principle of encoding position as a continuous function rather than a lookup table. If both degrade similarly, it suggests that the bottleneck for length generalization is not the positional encoding but something else (attention pattern distribution, feed-forward network saturation). A more ambitious variant would test whether the model actually learns to compute relative position through the sinusoidal encodingβby analyzing whether the attention weight between positions and depends primarily on and is invariant to (the translation-invariance property the encoding was designed to enable). This would connect the architectural design choice to an observable learned behavior.
Pre-training a Transformer encoder on large text corpora and fine-tuning on downstream tasks. The paper evaluates the Transformer only in the "train from scratch on a specific task" paradigm. The architecture's ability to process variable-length sequences, capture long-range dependencies, and produce context-aware representations at every position makes it a natural candidate for pre-trainingβwhere a model is first trained on a large unlabeled text corpus (e.g., language modeling or masked token prediction) and then fine-tuned on downstream tasks with limited labeled data. This direction was not explored in the paper but was the most impactful follow-up in the years after publication. A concrete experiment would: (1) pre-train the Transformer encoder (or a decoder-only variant) on a large corpus like BooksCorpus or English Wikipedia using a self-supervised objective (e.g., the masked language modeling objective that would later define BERT); (2) fine-tune on the tasks the paper already evaluated (translation, parsing) plus additional NLP benchmarks (GLUE, question answering, NLI); and (3) measure how much the pre-training improves performance in data-scarce regimes relative to training from scratch. The parsing results already suggest the Transformer works with only 40K training examples (Table 4)βpre-training could push this much further, potentially matching supervised models with orders of magnitude less labeled data.
Investigating the role of depth vs. width through a controlled scaling study. The paper's big model combines increased width ( from 512 to 1024), increased feed-forward dimension ( from 2048 to 4096), increased heads ( from 8 to 16), and a different dropout rate (0.3 vs. 0.1), achieving 26.4 BLEU vs. 25.8 for the base model (Table 3). But the ablation does not separate these changesβit's unclear whether the improvement comes from width, from depth in parameter count, or from the interaction. A controlled scaling study would fix a computational budget (e.g., total FLOPs or GPU hours) and systematically vary the allocation between depth () and width (, , ) while holding total parameters approximately constant. This would answer: for a fixed parameter budget, is it better to have fewer wide layers or many narrow layers? The base model experiments in Table 3 (row C) hint at the answer for the base width: outperforms and , suggesting an optimal depth. But this is only tested at one width. A full scaling study across multiple compute budgets would reveal whether the optimal depth-to-width ratio changes with scaleβanalogous to the depth-vs-width tradeoffs later studied in the vision transformer literature.
Stress-testing the Transformer on tasks that require precise positional reasoning. The paper's motivation for self-attention emphasizes the path length for long-range dependencies, but the same architecture that makes distant positions equally accessible also makes adjacent positions indistinguishable without the positional encoding. The Transformer has no built-in notion that position 5 and position 6 are neighborsβit learns this entirely from the positional encoding and the training data. A stress-test would evaluate the Transformer on tasks where precise token order matters in ways that go beyond syntax: arithmetic (where the digit sequence 123 encodes a different number than 321), code generation (where character-level order is syntactically constrained), or reversal tasks (where the output must reproduce the input in reverse order). If the Transformer struggles on these tasks relative to recurrent or convolutional modelsβwhich have stronger structural priors about local orderβit would reveal that the "positional encoding addition" approach, while sufficient for translation, is a genuine architectural weakness for tasks with fine-grained sequential structure. The sinusoidal encoding's linear-relatability property (PE at is a linear function of PE at ) may be insufficient for these tasks, motivating the learned relative positional encodings that later work would develop.
Explaining the Transformer's parsing performance through systematic attention analysis. The paper reports that the Transformer achieves 91.3 F1 on WSJ parsing with only 40K training sentences (Table 4), but provides no analysis of why it worksβwhether the attention patterns correspond to syntactic dependencies, whether specific heads learn constituency structure, or whether the model's internal representations encode parse trees. A follow-up would analyze the parsing model's attention patterns on the development set: for each attention head in each layer, compute the overlap between high-attention token pairs and the gold-standard parse tree dependencies (e.g., do attention weights correlate with parent-child relationships in the tree?). If the Transformer's attention heads naturally recover syntactic structure without being explicitly trained to do so, it suggests that self-attention is a good inductive bias for syntaxβand explains why the Transformer generalizes from 40K sentences when RNN sequence-to-sequence models [37] do not. If the attention patterns are not syntactic (e.g., they track positional offsets or shallow lexical associations), the strong parsing performance would be attributable to the feed-forward layers or the depth of the architecture rather than to attention specificallyβwhich would be equally interesting.
Practical Applications and Downstream Use Cases
Machine translation deployment with substantially reduced training compute budgets. The paper's most directly actionable result for practitioners is the combination of state-of-the-art translation quality with dramatically reduced training cost. The Transformer big model achieves 28.4 BLEU on English-to-German at a training cost of FLOPs (Table 2), while the best prior single model (ConvS2S) used FLOPs for only 25.16 BLEU, and the best ensemble used FLOPs for 26.36 BLEU. For an organization building a translation system, this means that training a state-of-the-art model no longer requires the massive GPU clusters needed by prior approachesβeight P100 GPUs for 3.5 days is within the budget of a medium-sized research lab or a small company. The base model, at 27.3 BLEU (already state-of-the-art over all prior single models) trained in only 12 hours on eight P100s, makes rapid iteration feasible: changing hyperparameters, adding training data, or adapting to a new language pair becomes a matter of hours rather than days or weeks.
Adaptation to new sequence transduction tasks without architectural redesign. The parsing results (Table 4) demonstrate that the Transformer can be applied to a structurally different task (output longer than input, strong syntactic constraints, small training set) with minimal architectural changesβonly the number of layers was adjusted, while , the attention mechanism, the feed-forward structure, and the training procedure were kept at their translation values. For practitioners building sequence-to-sequence systems for tasks like text summarization, code generation, dialogue response generation, or structured prediction (e.g., semantic parsing, AMR parsing), this implies that the Transformer provides a off-the-shelf architecture that requires task-specific hyperparameter tuning (dropout, learning rate, beam size) but not task-specific architectural innovation. The paper's finding that the sinusoidal positional encoding matches learned embeddings (Table 3, row E) further simplifies adaptationβthere is no need to decide on a maximum sequence length at architecture design time.
Model interpretability through direct inspection of attention patterns. The attention visualizations in Figures 3β5, while qualitative, demonstrate that the Transformer's self-attention mechanism produces human-interpretable patterns that correspond to linguistically meaningful phenomena (anaphora resolution in Figure 4, syntactic dependency tracking in Figure 3, phrase structure in Figure 5). For applications where model transparency mattersβlegal document processing, medical text analysis, educational tools that explain their reasoningβthe ability to inspect why the model made a particular prediction by examining which input tokens it attended to is a practical advantage over recurrent models, where the hidden state at each position is an opaque vector with no directly interpretable structure. A deployed translation or analysis system could surface attention visualizations to end-users as a form of explanation (e.g., "the model translated 'its' as 'son' because it attended strongly to 'The Law', matching the feminine gender of French 'loi'"βFigure 4).
Foundation for multi-modal and cross-modal sequence models. The Transformer's architecture treats all positions uniformlyβthere is no built-in distinction between "source" and "target" other than which attention mechanism is used (encoder self-attention, decoder self-attention, encoder-decoder attention). This uniformity makes it straightforward to extend the architecture to tasks where input and output come from different modalities: the encoder processes an image (as a sequence of patches), the decoder generates a caption; the encoder processes a video, the decoder generates a transcript; the encoder processes an English sentence, the decoder generates a French sentenceβall using identical components with different embeddings and positional encodings. The paper explicitly calls this out as a future direction (Section 7), and the architectural simplicity that makes it possible is a direct consequence of the design: there are no modality-specific recurrent cells, no modality-specific convolutional kernels, just attention operations that mix across positions and feed-forward operations that transform per-position. For practitioners building multi-modal systems, the Transformer provides a unified architecture where cross-modal interactions are handled by the same encoder-decoder attention mechanism that handles cross-lingual alignments.