ArXiv: 1803.02155
🎯 Pitch
Simply injecting relative position information into Transformer self-attention boosts BLEU scores by up to 1.3 points on English-German translation—entirely replacing the need for absolute position encodings. This approach, which learns a distance-aware bias for each attention head, shows that combining both absolute and relative positions offers no extra gain, and that high precision beyond a clipped distance of 2 is largely unnecessary.
1. Executive Summary
This paper introduces relation-aware self-attention, an extension to the Transformer's self-attention mechanism that efficiently incorporates representations of relative position—the distances between sequence elements—directly into the attention computation rather than relying on absolute position encodings added to inputs. Evaluated on the WMT 2014 English-to-German and English-to-French translation tasks using the Transformer model, the method improves performance by 1.3 BLEU and 0.3 BLEU over absolute position representations for the big configuration, respectively, with the base configuration yielding gains of 0.3 and 0.5 BLEU. The approach uses learned edge representations to modify both the compatibility function that determines attention weights (via a key-relative term, a^K_ij) and the weighted sum that produces output elements (via a value-relative term, a^V_ij), establishing that relative position information can fully replace absolute position encodings—the authors observe that combining both yields no further improvement—and that the key-relative term alone may be sufficient for machine translation, while precise relative position beyond a clipping distance of k ≥ 2 provides negligible additional benefit.
2. Context and Motivation
The Core Problem: Transformers Have No Built-In Notion of Sequence Order
The fundamental problem this paper addresses flows directly from a defining characteristic of the Transformer architecture (Vaswani et al., 2017): self-attention is entirely permutation-invariant with respect to its inputs. This means that if you shuffle the input sequence arbitrarily, the self-attention mechanism—as originally formulated—produces exactly the same output for each position, just shuffled correspondingly. The model has no way to distinguish whether the word "dog" appeared before or after the word "bit" in a sentence, because the attention computation treats all pairwise interactions purely as a function of content, not position.
This stands in stark contrast to the two other dominant neural sequence architectures. Recurrent neural networks (RNNs) process tokens one at a time, with each hidden state computed as a function of the current input and the previous hidden state . This inherently encodes both absolute position (earlier tokens are processed first) and relative position (the distance between any two tokens is reflected in how many recurrent steps separate them). Convolutional neural networks (CNNs) applied to sequences capture relative position within a local window—each convolution kernel sees a fixed-size neighborhood around each token, and the relative offsets within that kernel are implicitly part of the learned computation.
The Transformer deliberately discarded both recurrence and convolution to achieve the parallelizability that makes it so efficient at training time. The cost of this design choice is that position information must be supplied externally. The model has no structural mechanism to learn that tokens next to each other often interact differently than tokens far apart, or that "the dog chased the cat" means something different than "the cat chased the dog" despite containing identical tokens.
Why This Matters: Beyond Toy Sequences to Real Language Tasks
The importance of position modeling in the Transformer is not merely a theoretical curiosity—it is a practical necessity for any task where sequence order carries meaning. Natural language is the canonical example: word order encodes grammatical relations (subject vs. object), semantic roles (agent vs. patient), and discourse structure (topic shifts, anaphora). In machine translation—the task this paper evaluates on—getting position right is essential. Consider:
"The man gave the woman a book." vs. "The woman gave the man a book."
These two sentences contain exactly the same tokens but describe opposite events. A position-oblivious model would see identical input, yet must produce different translations. Even more subtly, in the translation from English to German, the verb position shifts depending on clause type, and relative word order carries information about grammatical case when morphological marking is ambiguous. A model that cannot distinguish "token A before token B" from "token B before token A" will struggle with such fundamental linguistic phenomena.
The problem compounds with sequence length. The Transformer's self-attention computes pairwise interactions between all positions in the input, meaning that for a sequence of length , there are pairwise relationships. Without position information, the model treats every pair identically regardless of distance. This is wasteful: in natural language, very distant tokens rarely have direct syntactic dependencies (though they may have long-range discourse or coreference links), while nearby tokens participate in phrase structure, agreement, and local collocation patterns. A model that knows which tokens are nearby and which are far apart can learn to allocate its attention capacity more effectively.
The paper also touches on an important generalization concern (Section 2.1): absolute position encodings are tied to specific numerical position indices (e.g., position 7 always maps to the same encoding vector). If the model sees longer sequences at test time than it ever saw at training time, those new high-index positions will be out-of-distribution for the learned (or fixed) encoding. Relative position, by contrast, only depends on differences between positions, which can generalize to new sequence lengths provided the relative distances that appear in those longer sequences fall within the range seen during training—or are handled by an explicit clipping mechanism, as this paper proposes.
Prior Approaches and Their Limitations
At the time of this paper's publication (early 2018, building on the Transformer introduced in late 2017), the field had explored several strategies for injecting position information into non-recurrent models, each with notable shortcomings.
Absolute Position Encodings (the Transformer Baseline)
The original Transformer (Vaswani et al., 2017) adds sinusoidal position encodings to the input embeddings before the first encoder and decoder layers. Each position index maps to a vector whose components are sinusoids of varying frequencies:
These vectors are added to the token embeddings, so the model sees input that is the sum of content and position representations: .
The authors of the original Transformer hypothesized that sinusoidal encodings might help the model learn to attend by relative position because the dot product between encodings at positions and can be expressed as a function of alone (for sufficiently high-dimensional encodings, the dot product approximates a basis-dependent function of the offset). However, this property is indirect and emergent—there is no guarantee that the model will actually extract relative position information from the absolute encodings, especially after the additive combination with content embeddings and subsequent nonlinear transformations through feed-forward layers and layer normalization. The relative position information is buried in the absolute representations and must be recovered by the model's learned parameters, which may not happen reliably in practice.
More fundamentally, absolute position encodings suffer from a representational mismatch: they encode where a token is (absolute position), but self-attention intrinsically operates on pairs of tokens. The attention weight represents the relevance of token to token . The natural thing to condition this relevance on is not "where is token ?" and "where is token ?" independently, but rather "how far apart are tokens and ?" or "what is their relative ordering?" Absolute encodings force the model to compute relative information on the fly from two absolute representations, adding unnecessary computational burden and representational noise.
Learned Absolute Position Embeddings
An alternative approach (used, for example, in Gehring et al., 2017's convolutional sequence-to-sequence model) is to treat position indices as vocabulary items and learn a separate embedding vector for each position. During training, the model sees positions up to some maximum sequence length and learns what each absolute position "means" through backpropagation.
This approach faces three problems. First, generalization: positions beyond the training maximum receive untrained embeddings, typically set to zero or extrapolated heuristically. Second, fixed capacity: the number of position embeddings is a hyperparameter that must be chosen before training, and the model cannot dynamically adapt to longer sequences. Third, the same representational mismatch noted above: absolute position learned per token does not directly condition pairwise attention on relative distance.
Distance-Biased Attention Weights
Some prior work on attention-based models (notably Parikh et al., 2016's Decomposable Attention model for natural language inference) had explored biasing attention weights based on distance by adding or multiplying a distance-dependent term to the compatibility scores. These approaches typically use fixed functional forms (e.g., a Gaussian decay, or a learned scalar bias per distance bucket).
While closer in spirit to relative position representations, these approaches have two key limitations. First, they operate only on the attention weights (the in Equation 1)—they do not provide position information to the output of the attention mechanism (the weighted sum ). As this paper demonstrates (Section 4.3, Table 3), providing relative position both in the compatibility function and in the value computation can be beneficial on some tasks. Second, fixed functional forms impose strong assumptions about how distance matters (e.g., monotonic decay), which may not hold for all linguistic phenomena—consider syntactic dependencies that skip over intermediate tokens while paying attention to a distant head.
Recurrent and Convolutional Alternatives (and Why They're Not Solutions for the Transformer)
One might reasonably ask: if RNNs and CNNs handle position naturally, why not just use them? The answer lies in the parallelization and long-range dependency advantages of the Transformer that motivated its original development. RNNs are inherently sequential, making them slow to train because each time step depends on the previous one. CNNs have limited receptive fields (though dilated convolutions can expand this) and struggle with very long-range dependencies that require information to propagate through many layers.
The Transformer's self-attention, by contrast, computes all pairwise interactions in constant path length (each token can directly attend to every other token in a single operation) and is fully parallelizable across sequence positions during training. These are substantial practical advantages that made the Transformer state-of-the-art for machine translation at the time. The challenge, therefore, is not to abandon the Transformer but to augment it with position information in a way that preserves its computational advantages while addressing its permutation-invariance blind spot.
How This Paper Positions Itself
The paper situates its contribution at the intersection of two observations:
-
The Transformer works well but position is handled suboptimally. Absolute position encodings are a workaround—a way to inject position information into a model that structurally ignores it. The encoding is added at the input, but must propagate through layers, potentially being diluted or distorted by layer normalization, residual connections, and the nonlinearities in feed-forward sublayers.
-
Self-attention is naturally pairwise, so position information should be pairwise too. The central computation of self-attention is the compatibility function (Equation 2), which scores how relevant token is to token . If position matters for this relevance—and in language it does—then the most natural place to encode it is directly in this pairwise score. Similarly, the output (Equation 1) is a weighted sum over other tokens' values; if a token's contribution should depend on its position relative to , that positional modulation should appear alongside the value vector.
The paper's proposed architecture, relation-aware self-attention, operationalizes this insight by introducing learned edge representations and that depend on the relative position between tokens. These edge vectors are added directly into the two places where pairwise information matters:
- is added to the key vector in the compatibility computation (Equation 4), so the model can learn that tokens at certain relative positions should receive more or less attention regardless of their content.
- is added to the value vector in the output computation (Equation 3), so the model can learn that what a token contributes to another's output should be modulated by their relative distance.
Crucially, the paper frames this not as a narrow position-encoding trick but as an instance of a more general relation-aware extension to self-attention (Section 3.1): the input is modeled as a labeled, directed, fully-connected graph, where edge labels can encode arbitrary pairwise relationships—relative position being the specific instantiation explored here. This framing connects the work to the emerging graph neural network literature (explicitly citing Veličković et al., 2017's Graph Attention Networks) and opens the door to modeling more structured relationships (syntactic parse edges, coreference links, discourse relations) beyond simple positional distances.
The paper's explicit positioning relative to the original Transformer is clear from the experimental design: they replace sinusoidal position encodings entirely (Section 4.2: "we did not observe any benefit from including sinusoidal position encodings in addition to relative position representations") and directly compare BLEU scores under the same training conditions, model sizes, and hyperparameters—only the position mechanism changes. This isolates the effect of their method and establishes that relative position representations are not merely a complementary addition but a complete substitute for absolute position encodings in the tested setting.
The paper also positions itself against the efficiency concerns that might deter adoption of a method that introduces additional vectors. Section 3.3 explicitly addresses the computational and memory overhead, describing a tensor-reshaping implementation that keeps the wall-clock slowdown to a modest 7% while maintaining the same batch and model sizes—a critical detail for practitioners evaluating whether the BLEU gains justify the engineering cost.
3. Technical Approach
3.1 Reader Orientation
This paper introduces an extension to the Transformer's self-attention mechanism that allows the model to directly consider pairwise relationships—specifically relative position distances—between every pair of tokens in a sequence, rather than relying on absolute position encodings added to token embeddings. The problem this solves is the Transformer's fundamental inability to distinguish sequence order: self-attention is permutation-invariant, so without explicit position information, the model treats "the dog bit the man" identically to "the man bit the dog." The solution takes the shape of learned edge vectors that are injected directly into the two core operations of self-attention—the compatibility computation (which determines how much attention one token pays to another) and the value aggregation (which determines what information each token contributes to the output)—with these edge vectors depending only on the signed distance between token positions.
3.2 Big-Picture Architecture (Diagram in Words)
The system modifies the Transformer's self-attention sublayer by introducing four major components that work together to make attention relation-aware:
-
Relative Position Edge Labels: For any pair of input tokens at positions
iandj, the system computes a single integerj - irepresenting their signed distance, then clips it to a maximum absolute valuek. This produces one of2k + 1discrete edge labels (e.g., -4, -3, -2, -1, 0, 1, 2, 3, 4 ifk = 4). -
Learned Key-Relative Edge Vectors (
w^K): A lookup table of2k + 1vectors (each of dimensiond_a = d_z), one per possible clipped relative position. Given the edge label for the pair(i, j), the system retrieves the corresponding vectora^K_{ij}and adds it to the key representation of tokenjinside the dot-product compatibility computation. This allows the attention weightα_{ij}to depend not just on what tokensiandjare, but on how far apart they are. -
Learned Value-Relative Edge Vectors (
w^V): An identically sized lookup table of2k + 1vectors. Given the same edge label, the system retrievesa^V_{ij}and adds it to the value representation of tokenjwhen computing the weighted sum that produces the outputz_i. This allows the content that tokenjcontributes to tokeni's updated representation to be modulated by their relative distance. -
Efficient Implementation via Tensor Reshaping: To avoid the
O(n^2)memory blowup from storing unique edge vectors per head per layer, the system sharesw^Kandw^Vacross all attention heads within a layer (though they are unique per layer). The computation is split into two additive terms (content-based and position-based) that exploit parallel matrix multiplications without broadcasting edge representations, keeping the wall-clock overhead to a modest 7%.
The flow of information through a single self-attention head proceeds as follows: input tokens x = (x_1, ..., x_n) arrive at the attention sublayer → each token is linearly projected to queries, keys, and values via learned matrices W^Q, W^K, W^V → for each pair (i, j), the edge label clip(j - i, k) is computed → the edge vectors a^K_{ij} and a^V_{ij} are retrieved from the learned tables → the compatibility score e_{ij} is computed as a scaled dot product between the query of token i and the key of token j plus the key-relative edge vector → a softmax over all j converts these scores to attention weights α_{ij} → the output z_i is computed as a weighted sum of the value of token j plus the value-relative edge vector → the outputs from all heads are concatenated and linearly projected to form the sublayer output, which passes through a residual connection and layer normalization before feeding into the next sublayer.
3.3 Roadmap for the Deep Dive
- First, the formal specification of relation-aware self-attention (Equations 3 and 4), which introduces the two edge representations
a^V_{ij}anda^K_{ij}and shows exactly where they are injected into the standard self-attention computation. This is the core architectural modification—everything else is about how these edge vectors are parameterized and computed efficiently. - Second, the parameterization of edge vectors as relative position representations, introducing the clipping function, the
2k + 1discrete labels, and the learned lookup tablesw^Kandw^V. This grounds the general graph framework in the specific case of linear sequences. - Third, the efficient implementation strategy (Equation 5 decomposition and tensor reshaping), which is essential for understanding why this method is practical at scale—without it, the memory and compute costs would be prohibitive.
- Finally, the summary of key design choices and hyperparameters (clipping distance
k, edge sharing across heads, dimensionalityd_a), along with the rationale behind each choice and its empirical consequences as shown in Section 4.3. This connects the theoretical framework to the practical configuration used in the experiments.
3.4 Detailed, Sentence-Based Technical Breakdown
This is primarily an architectural innovation paper whose core idea is that the self-attention mechanism should directly condition on pairwise relationships between input elements, with relative position as the specific instantiation of that idea. The paper modifies two equations from the original Transformer—the compatibility function and the output aggregation—and shows that this modification is both computationally efficient and empirically superior to absolute position encodings.
Standard Self-Attention (The Starting Point)
Before explaining the modification, it is essential to understand exactly what self-attention computes. This section establishes the baseline that the paper extends.
The input to a self-attention sublayer is a sequence x = (x_1, ..., x_n) of n elements, where each element x_i is a vector of dimension d_x (the model dimension, e.g., 512 for the base Transformer). The sublayer contains h attention heads that operate in parallel. Each attention head produces an output sequence z = (z_1, ..., z_n) of the same length, where each output z_i is a vector of dimension d_z.
Each attention head has three learned parameter matrices:
where W^Q is the query projection matrix that transforms each input element into a query vector representing "what information this token is looking for," W^K is the key projection matrix that transforms each input element into a key vector representing "what information this token contains," and W^V is the value projection matrix that transforms each input element into a value vector representing "what information this token will contribute if attended to."
For each pair of positions (i, j), the compatibility score e_{ij} is computed as a scaled dot product between the query of token i and the key of token j:
where x_i W^Q is the query vector for position i (a row vector of dimension d_z), x_j W^K is the key vector for position j (a row vector of dimension d_z), the product (x_i W^Q)(x_j W^K)^T is their dot product (a scalar), and \sqrt{d_z} is a scaling factor that prevents the dot product from growing too large in magnitude as the dimension increases, which would push the softmax into regions of extremely small gradients.
The attention weights α_{ij} are computed by applying a softmax over all j for a fixed i:
This ensures that for each query position i, the weights α_{i1}, ..., α_{in} are non-negative and sum to 1, forming a valid probability distribution over the n input positions. The attention weight α_{ij} represents the proportion of token i's total attention that is allocated to token j.
Finally, the output z_i for position i is computed as a weighted sum of the value vectors of all input positions:
where x_j W^V is the value vector for position j (a row vector of dimension d_z), and the sum produces a vector z_i of the same dimension d_z.
Critical observation about position blindness: In the three equations above, the indices i and j appear only to select which vector to use—they do not affect the computation in any other way. If you permuted the input sequence arbitrarily (keeping each token paired with its original projections), the compatibility scores e_{ij} would be permuted correspondingly, the softmax would produce the same set of weights (just re-indexed), and the outputs z_i would be the same vectors (just re-indexed). The model has no way to know that position 5 should be treated differently from position 17 based on their positions alone—only their content matters. This is the property that the paper's modification addresses.
Relation-Aware Self-Attention: The Core Modification
The paper proposes to modify the self-attention mechanism so that it explicitly considers the relationship between input elements i and j. The most general framing is that the input is a labeled, directed, fully-connected graph, where each directed edge from node j to node i carries a label that encodes their pairwise relationship. For the specific case of sequences, this label is the relative position j - i.
The key insight is that there are two distinct places where pairwise relationship information is useful, and they correspond to two different edge representations:
Representation 1: a^V_{ij} modulates what information token j contributes to token i's output. This is added to the value vector in the weighted sum that produces z_i:
where a^V_{ij} \in \mathbb{R}^{d_z} is a learned edge vector representing the relationship from element j to element i, and x_j W^V is the usual content-based value vector for token j (a row vector of dimension d_z).
What it computes: For each output position i, the updated representation z_i is a weighted sum over all input positions j, where each position's contribution has two additive components: (1) the content of token j as transformed by W^V, and (2) a learned vector that depends solely on the relationship between i and j. The attention weight α_{ij} gates both components jointly—if token j is irrelevant to token i (small α_{ij}), neither its content nor its positional relationship contributes to the output. The result is a vector z_i of dimension d_z per position.
Why this form: Adding (rather than concatenating or multiplying) the edge vector to the value vector preserves the dimensional structure of the output—z_i remains dimension d_z, which is essential because all subsequent layers expect inputs of that dimension. Concatenation would require projecting back down, adding parameters and complexity. Addition allows the edge information to be a modulation of the value: the content x_j W^V establishes the base meaning, and a^V_{ij} shifts it based on relative position. For example, the model could learn that when token j is immediately before token i (relative position -1), the value contribution should be adjusted in a particular direction—perhaps emphasizing local syntactic dependencies—while when token j is far away, a different adjustment applies. This is analogous to how positional encodings are added to token embeddings in the original Transformer, but crucially, here the positional information is pairwise (depends on both i and j) rather than absolute (depends only on j), and it is applied at every attention layer rather than just once at the input.
The paper notes (Section 3.1) that this modification "is presumably important for tasks where information about the edge types selected by a given attention head is useful to downstream encoder or decoder layers," but acknowledges (Section 4.3, Table 3) that for machine translation, it may not be essential—the key-relative term a^K_{ij} appears sufficient.
Representation 2: a^K_{ij} modulates the compatibility between token i and token j. This is added to the key vector in the dot-product computation of e_{ij}:
where a^K_{ij} \in \mathbb{R}^{d_z} is a learned edge vector representing the relationship from element j to element i, x_i W^Q is the query vector for position i (a row vector of dimension d_z), and x_j W^K + a^K_{ij} is the relation-augmented key—the key vector for token j shifted by the edge representation.
What it computes: The compatibility score e_{ij} is the scaled dot product between the query of token i and the relation-augmented key of token j. Expanding the numerator:
The first term is the standard content-based compatibility: how well does the content of token j match what token i is looking for? The second term is the position-based compatibility: how appropriate is it for token i to attend to a token at relative position j - i, regardless of content? The sum of these two scalars (divided by \sqrt{d_z}) determines the unnormalized attention weight, which is then softmax-normalized across all j.
Why this form: The additive combination in the key space is a crucial design choice. It means that the query x_i W^Q interacts with both the content key x_j W^K and the position key a^K_{ij} through the same dot-product operation. The model does not need separate parameters to integrate content and position information—the query vector naturally captures both aspects in a unified similarity score. An alternative would be to compute two separate compatibility scores (one content-based, one position-based) and combine them with a learned weight, but this would require additional parameters and would break the efficient matrix-multiplication implementation that makes the Transformer fast. The additive form preserves the simple dot-product structure while making the key "position-aware."
The paper's primary motivation for using simple addition in both Equation 3 and Equation 4 is explicitly stated: "to enable an efficient implementation described in 3.3." As we will see, addition allows the computation to be split into two terms that can each be computed with standard matrix multiplications, avoiding the need to materialize a unique key vector for every (i, j) pair explicitly.
A subtle but important consequence of this design: the edge vector a^K_{ij} is independent of the content of token j. It only depends on the relative position j - i. This means that for a fixed query position i and a fixed relative distance d, all tokens at that relative distance contribute the same position-based component to the compatibility score, regardless of what those tokens actually are. The model can learn, for example, that for most queries, tokens at relative position -1 (immediately preceding) should receive a positive position-based compatibility boost, increasing the chance they are attended to, while tokens at relative position +10 should receive a neutral or negative boost. This is a sensible inductive bias: position alone does not determine relevance, but it shifts the prior in a way that the content-based term can override.
Relative Position Representations: From Arbitrary Edges to Sequences
The previous section described edge vectors a^V_{ij} and a^K_{ij} in the abstract—any relationship between elements i and j could be encoded. This section specializes to linear sequences, where the relationship is simply the signed distance between positions.
For a pair of positions (i, j) with i as the query position and j as the key/value position, the relative position is j - i. This is negative when j precedes i (token j is to the left of token i), zero when i = j (self-attention), and positive when j follows i (token j is to the right of token i). For a sequence of length n, the possible relative positions range from -(n-1) to n-1.
The paper makes the key design choice to clip the relative position to a maximum absolute value k:
where the clipping function is:
which means: if x > k, return k; if x < -k, return -k; otherwise return x. For example, with k = 4, relative positions of 4, 5, 10, and 100 all map to the same label 4; relative positions of -4, -5, -10, and -100 all map to -4.
The learnable parameters are two sets of 2k + 1 vectors:
where each w^K_i and w^V_i is a vector in \mathbb{R}^{d_a}, with d_a = d_z (so each edge vector has the same dimension as the key and value vectors).
Why clipping? The paper provides two motivations. First, the hypothesis that "precise relative position information is not useful beyond a certain distance." In natural language, knowing that two words are exactly 47 positions apart versus 48 positions apart is unlikely to affect their syntactic or semantic interaction. What matters is typically whether they are adjacent, within a local window (e.g., a noun phrase), at sentence-internal distances, or very far apart (cross-sentence). Clipping beyond k means the model distinguishes fine-grained distances only within a local window and treats all distant positions as equivalently "far."
Second, and more critically: "Clipping the maximum distance also enables the model to generalize to sequence lengths not seen during training." If the model learned a unique vector for every possible relative distance up to the training sequence length (say, 100), then at test time, a sequence of length 200 would introduce relative distances from 101 to 199 that the model has never seen. With clipping, any distance beyond k maps to one of the two boundary labels (-k or k), which the model has seen during training on shorter sequences. This is the same generalization motivation that the original Transformer authors gave for sinusoidal encodings, but realized through a different mechanism.
The number of edge labels 2k + 1: For k = 16 (used in the base model configuration), there are 33 unique edge labels: 16 for negative relative positions (token j precedes token i by up to 16 positions, and further precedes are clipped to -16), 1 for self-attention (relative position 0), and 16 for positive relative positions (token j follows token i by up to 16 positions, with further follows clipped to 16). For k = 8 (used in the big model configuration), there are 17 unique edge labels.
Asymmetry of relative position: Note that clip(j - i, k) is not symmetric: the edge from i to j can be different from the edge from j to i. For example, if i = 3 and j = 5, then j - i = 2 (positive, meaning j follows i), while for the reverse pair, i - j = -2 (negative, meaning i precedes j). The model learns separate vectors for relative position +2 and relative position -2. This is crucial for natural language, where the direction of a relationship matters: a modifier that follows its head is different from one that precedes it (e.g., "the red car" vs. "la voiture rouge" in French).
Efficient Implementation: How the Method Scales
A naive implementation of Equations 3 and 4 would be extremely expensive. For each pair (i, j) of the n^2 possible pairs, the system would need to retrieve a unique a^K_{ij} and a^V_{ij} vector, add it to the key or value, and compute the dot product. This would require O(n^2 d_z) memory per attention head, and for h heads, O(h n^2 d_z) total. For a typical sequence length of n = 100 and base model configuration (h = 8, d_z = 64), this is 8 * 10000 * 64 = 5,120,000 floating-point numbers per sequence—already large but manageable. For longer sequences (n = 1000), it becomes 512 million floats per sequence, which is prohibitive.
The paper addresses this with two key strategies: sharing edge representations across attention heads and splitting the computation to exploit parallel matrix multiplication.
Edge sharing across heads: The paper states that "we reduce the space complexity of storing relative position representations from O(h n^2 d_a) to O(n^2 d_a) by sharing them across each heads." This means that within a given layer, all h attention heads use the same w^K and w^V tables. The edge vectors do not need to be stored separately per head. The total memory for edge representations per sequence becomes n^2 * d_a, independent of the number of heads. Additionally, "relative position representations can be shared across sequences" within a batch, because the relative position matrix is identical for all sequences of the same length (it only depends on the indices i and j, not on the content). This means the edge vectors a^K_{ij} and a^V_{ij} need to be computed once per unique sequence length in the batch, not once per sequence.
Splitting the compatibility computation (Equation 5): The critical observation is that Equation 4 can be algebraically decomposed:
The first term is exactly the standard content-based compatibility function (Equation 2). The second term is the position-based contribution, which depends on the query x_i W^Q and the edge vector a^K_{ij}, but not on the key x_j W^K (except through the index j selecting which edge vector to use).
The paper's implementation computes these two terms separately, using different matrix multiplication patterns for each:
Term 1 (content-based): This is computed identically to the original Transformer. For a batch of sequences, the query matrix Q (shape batch * heads * n * d_z) and the key matrix K (shape batch * heads * n * d_z) are multiplied using standard batched matrix multiplication: Q @ K^T produces a tensor of shape batch * heads * n * n, where each slice [b, h, i, j] is the content-based dot product (x_i W^Q)(x_j W^K)^T for batch element b, head h, positions i and j. This is highly optimized in deep learning frameworks and runs as a single parallel operation over all batches, heads, and positions.
Term 2 (position-based): This term cannot be computed as a single matrix multiplication over all position pairs because a^K_{ij} varies with both i and j—there is no single key matrix that stores all edge vectors simultaneously for all (i, j) pairs. However, the paper exploits the fact that for a fixed query position i, the computation across all j (all key positions) is a matrix-vector product between the query q_i = x_i W^Q and the matrix of edge vectors A^K_i = [a^K_{i1}; a^K_{i2}; ...; a^K_{in}] (stacked as rows). This can be done in parallel for all heads and batch elements for each i, using n parallel matrix multiplications of shape bh * d_z times d_z * n (where bh is the product of batch size and number of heads). The paper describes this as "tensor reshaping can be used to compute n parallel multiplications of bh × d_z and d_z × n matrices."
Concretely, for each query position i, the system:
- Extracts the query vectors for all batch elements and heads at position
i, forming a matrix of shapebh × d_z. - Constructs the edge matrix for position
i, of shapen × d_z, where rowjisa^K_{ij}(extracted from the shared edge lookup table based onclip(j - i, k)). - Computes the matrix product
(bh × d_z) @ (d_z × n) → (bh × n), yielding the position-based contributionx_i W^Q (a^K_{ij})^Tfor allbhcombinations and allj.
This produces n matrices of shape bh × n, one per query position. By reshaping these into a single tensor of shape bh × n × n and transposing appropriately, the position-based term can be added to the content-based term to produce the full e_{ij} matrix. The division by \sqrt{d_z} and the softmax are then applied as usual.
Efficient computation of the value term (Equation 3): The paper states that "the same approach can be used to efficiently compute eq. (3)." In Equation 3, the term a^V_{ij} is added to the value vector before the weighted sum. This can be decomposed as:
The first sum is the standard content-based output. The second sum is the position-based contribution, which can be computed by multiplying the attention weight matrix A (shape batch * heads * n * n, where A[b, h, i, j] = α_{ij}) with the edge value matrix (shape batch * n * n * d_z, where the edge matrix for the sequence has rows as a^V_{ij} for all j at fixed i). Using tensor reshaping, this can be batched efficiently without materializing per-head copies of the edge vectors.
Resulting computational overhead: The paper reports that "the result was a modest 7% decrease in steps per second, but we were able to maintain the same model and batch sizes on P100 GPUs as Vaswani et al. (2017)." The 7% slowdown is the cost of the additional matrix multiplications for the position-based terms. The fact that model and batch sizes remain unchanged confirms that the memory optimization (edge sharing across heads) is effective—without it, the increased memory footprint would have forced smaller batch sizes, potentially degrading training stability or throughput.
Space complexity summary: The overall self-attention space complexity increases from O(b h n d_z) to O(b h n d_z + n^2 d_a). The first term is the standard per-head query, key, and value matrices. The second term is the shared edge representations, which scales quadratically with sequence length but is independent of batch size and number of heads. The paper notes that "given d_a = d_z, the size of the relative increase depends on n / (b h)"—for large batches and many heads, the relative overhead is small; for very long sequences with small batches, it can become significant. At the time of publication, with typical sequence lengths of 100–200 tokens for machine translation and d_a = 64, the n^2 d_a term was approximately 10000 * 64 = 640,000 floats per sequence, which is modest compared to the total model memory.
Key Design Choices, Hyperparameters, and Their Rationale
Choice: Two distinct edge representations (a^K and a^V). The paper learns separate sets of vectors for use in the key (compatibility) and value (output) equations. The motivation is that these representations serve different purposes and may benefit from different learned values: a^K_{ij} affects which tokens are attended to (by modifying the compatibility score), while a^V_{ij} affects what information attended tokens contribute (by modifying the value). The paper finds experimentally (Section 4.3, Table 3) that a^K alone achieves the same BLEU score as both together (25.8), while a^V alone drops to 25.3, and neither (k=0, equivalent to no relative position) drops to 12.5. This suggests that for machine translation, the key-relative term is the primary mechanism by which relative position information improves performance, and the value-relative term provides at most a marginal benefit.
Choice: Clipping distance k = 16 (base) and k = 8 (big). The base model uses k = 16, meaning it distinguishes 33 relative position categories. The big model uses k = 8, meaning 17 categories. The reduction for the big model may reflect that the larger model has more parameters overall and more attention heads (16 vs. 8), so the positional information can be distributed across more heads even with coarser per-head resolution. The paper's ablation in Table 2 shows that performance is essentially flat for k ≥ 2 on the base model (BLEU values of 25.8–25.9 for k = 2, 4, 16, 64, 256), with only k = 0 (12.5) and k = 1 (25.5) showing significant differences. This is a striking result: distinguishing between relative positions -2, -1, 0, 1, and 2 captures nearly all the benefit, and adding finer resolution beyond that contributes negligibly. The authors hypothesize that "as we use multiple encoder layers, precise relative position information may be able to propagate beyond the clipping distance"—meaning that even if layer 1 only explicitly models relative distances up to 2, the stacking of 6 layers allows information about larger distances to propagate implicitly through the network (token at position i attends to token at i-2, which in turn attends to token at i-4, etc.).
Choice: Unique edge representations per layer (both configurations) and per head (base only). The paper states that for the base model, "we used unique edge representations per layer and head," meaning each of the 6 encoder and 6 decoder layers has its own w^K and w^V tables, and within each layer, each of the 8 attention heads has its own tables. For the big model, "we used unique edge representations per layer," meaning 6 + 6 = 12 sets of tables, but shared across the 16 heads within each layer. The reason for sharing across heads in the big model is not explicitly stated, but likely relates to memory constraints: the big model has d_z = 64, 16 heads, and k = 8 (17 labels), so per-head edge tables would require 16 * 17 * 64 * 2 = 34,816 parameters per layer for the edge vectors alone, while sharing across heads requires only 17 * 64 * 2 = 2,176 parameters per layer. For the base model with 8 heads, the per-head cost is half that, which may have been acceptable.
Choice: Dimensionality d_a = d_z. The edge vectors are set to have the same dimension as the key and value vectors (64 for both base and big configurations). This is a natural choice because the edge vectors are added to these vectors, and addition requires matching dimensions. An alternative would be to project the edge vectors from a smaller dimension up to d_z using a learned linear transformation, but this would add parameters and complexity. The direct equality keeps the design simple and the parameter cost transparent.
Choice: No absolute position encodings. The paper's experiments use relative position representations in place of the sinusoidal position encodings from the original Transformer, not in addition to them. The authors explicitly state: "In our experiments we did not observe any benefit from including sinusoidal position encodings in addition to relative position representations." This is a significant finding: it means that relative position alone provides sufficient position information for the model to perform well, and the absolute position encodings are redundant given the pairwise mechanism.
Choice: Single-layer injection of edge information. The edge vectors are incorporated into the self-attention computation at every layer (both encoder and decoder self-attention). However, they are not added to the input embeddings and do not propagate through the feed-forward sublayers independently—they are consumed within the attention mechanism. This means that after the attention sublayer output is produced, the positional information is embedded in the resulting representations z_i (which mix content and position through the weighted sum), and these representations feed into the next layer's attention mechanism, where they serve as the content input x_i. The positional information thus cascades through the layers implicitly, with each layer's attention mechanism adding fresh positional modulation on top of the mixed representations it receives.
4. Key Insights and Innovations
Innovation 1: Reframing Self-Attention as Operating on a Labeled Graph, Not Just a Set of Vectors
The paper's most conceptually distinctive move is not the specific mechanism of adding edge vectors to keys and values—it is the reframing of what self-attention fundamentally computes. Prior to this work, self-attention (as introduced by Vaswani et al., 2017) was understood as operating on a set of input vectors. Each token was an isolated node; attention weights computed pairwise similarities between these nodes based solely on their content. Position information was injected externally by modifying the node representations themselves (adding sinusoidal encodings to embeddings), a strategy that treats position as an attribute of individual tokens rather than a property of token pairs.
This paper fundamentally shifts that framing: the input to self-attention is not a set of vectors but a labeled, directed, fully-connected graph (Section 3.1). Each input element is a node, and each directed edge carries a label encoding the pairwise relationship between its endpoints. Attention weights become edge-dependent: how much node i attends to node j depends not only on what they contain but on the label of the edge connecting them. The output representation of each node is a weighted sum over neighbor values that are themselves edge-modulated.
This reframing is significant beyond the specific case of relative position because it generalizes the Transformer to arbitrary relational inputs. The paper explicitly states: "We model the input as a labeled, directed, fully-connected graph," and positions relative position as merely "a special case of extending the self-attention mechanism of the Transformer to considering arbitrary relations between any two elements of the input." The architecture as described in Equations 3 and 4 does not assume edges represent position—any pairwise label could be encoded as a^K_{ij} and a^V_{ij}, whether that label is a syntactic dependency type (subject-of, object-of, modifier-of), a coreference link, a discourse relation, or anything else with pairwise structure.
This is a fundamental conceptual shift, not an incremental refinement. The original Transformer's self-attention was relation-agnostic: all pairs were treated identically except for the content-based dot product. By explicitly parameterizing the edge space, this paper opens the door to what we would now call graph-aware Transformers—models that can ingest relational structure natively rather than learning to infer it from content alone. The connection to the graph neural network literature is made explicitly through the citation of Veličković et al. (2017)'s Graph Attention Networks, positioning this work at the intersection of two rapidly developing fields.
The significance of this reframing extends beyond the paper's immediate machine translation results. It provided the intellectual scaffolding for an entire subsequent research direction: Transformers that operate on structured inputs (knowledge graphs, molecular graphs, program ASTs, social networks) by encoding edge relationships directly into attention. The paper didn't explore these extensions—Section 5 explicitly defers them to future work—but the architectural generality was designed in from the start. The fact that the key-relative and value-relative vectors are separate learnable parameters (rather than derived from a fixed distance function) means the framework can absorb arbitrary discrete or continuous edge features through the same mechanism.
Evidence for this reframing's practical impact is embedded in the experimental design: the edge lookup tables w^K and w^V are implemented as general-purpose parameters that happen to be indexed by clip(j - i, k) for the positional case, but the architecture itself places no constraints on how edges are assigned. The efficient implementation described in Section 3.3 is similarly general—it only requires that edge vectors can be arranged into a matrix for efficient multiplication, not that they follow any particular functional form.
Innovation 2: The Diagnostic Decomposition of Position Into Two Orthogonal Functional Roles
A less obvious but equally important contribution is the paper's analytical decomposition of where position information matters in the attention computation. Prior work treated position as a monolithic concept—you either add it to the input embeddings (absolute encodings) or bias attention weights by distance (Parikh et al., 2016). This paper identifies that position serves two functionally distinct roles in self-attention, and that these roles benefit from separate learned representations:
- Attentional guidance (
a^K_{ij}in Equation 4): Position modulates whether tokenjgets attended to by tokeni. This is about selection—a token that is nearby might receive a higher baseline priority regardless of its content. - Content modulation (
a^V_{ij}in Equation 3): Position modulates what tokenjcontributes once attended to. This is about transformation—knowing that tokenjprecedes tokenimight shift how its value is incorporated intoz_i, even if the attention weight is determined primarily by content.
The paper goes further by empirically demonstrating that these two roles are asymmetric in importance for the task studied, and that having separate learned representations for each enables the model to allocate capacity where it matters. The ablation experiment in Table 3 is the critical piece of evidence: including a^K_{ij} alone achieves the same BLEU score (25.8) as including both (25.8), while including a^V_{ij} alone drops substantially (25.3), and omitting both collapses performance to 12.5 (effectively, the model has no position information and cannot translate). This is a diagnostic finding: it tells us that for machine translation, the primary mechanism by which relative position improves performance is through guiding attention weights, not through modulating value contributions. The a^V term provides negligible additional benefit once a^K is present.
This decomposition is conceptually significant because it provides a language for reasoning about position representations that was absent before. When a subsequent paper considers whether to add position information to a Transformer variant, it can now ask: should position affect attention selection, value modulation, or both? The answer may be task-dependent—the authors explicitly hedge that a^V "is presumably important for tasks where information about the edge types selected by a given attention head is useful to downstream encoder or decoder layers. However, as explored in 4.3, this may not be necessary for machine translation." This opens a research question: what properties of a task determine whether value-relative information matters? Tasks with strong structural dependencies (parsing, graph reasoning) might benefit more than tasks where attention gating already provides sufficient structural signal.
This is also a counterexample to the default assumption that more position information is always better. The paper demonstrates that a^V on its own is worse than a^K on its own, and that adding a^V to a^K yields no improvement. This is a negative result with practical implications: if you are implementing relative position for a translation model, you can omit the value-relative term, saving parameters and computation with no accuracy cost. More broadly, it suggests that the different "channels" through which position enters the model are not additive in a simple way—they can be redundant or even interfere, and each deserves independent evaluation.
Innovation 3: The Discovery That Clipping Distance Above a Minimal Threshold Adds No Value—and the Implicit Depth-Based Explanation
The paper's investigation of the clipping distance k (Table 2) reveals a genuinely surprising empirical finding: relative position information beyond k = 2 provides essentially no additional benefit for the base Transformer on the translation task. The BLEU scores for k = 2 (25.8), k = 4 (25.9), k = 16 (25.8), k = 64 (25.9), and k = 256 (25.8) are all essentially identical. The only meaningful jumps occur from k = 0 (12.5—no position information at all) to k = 1 (25.5—distinguishing immediately adjacent from self from immediately following) and from k = 1 to k = 2 (25.8—adding the second-neighbor distinction).
This is a strong finding with significant architectural implications. It means that the model does not benefit from knowing whether two tokens are 10 positions apart versus 50 positions apart—the only distinctions that matter are whether they are adjacent, within a small local window (distance 1 or 2), at the same position, or farther than that. The clipping mechanism, which was introduced primarily to enable length generalization, turns out to be doing almost no work beyond k = 2 for this task and model configuration—all distances beyond 2 are effectively treated as equivalent by the model even when given the capacity to distinguish them.
The paper's explanation for this finding is both elegant and subtle: "as we use multiple encoder layers, precise relative position information may be able to propagate beyond the clipping distance." This is not simply saying that positional information is lost through the layers—it is saying something more interesting: positional information can be recovered implicitly through the compositional structure of multi-layer attention, making explicit encoding of large relative distances redundant. If layer 1 allows token i to attend to token i-1 and token i-1 to attend to token i-3, then by layer 2, token i indirectly has access to information from token i-3 through the intermediate representation of token i-1. The model doesn't need an explicit edge between positions i and i-3 because it can route that information through intermediate nodes across layers.
This insight—that the effective receptive field of relative position extends beyond the explicit clipping distance through depth—is a conceptual contribution that connects position modeling to the broader literature on receptive fields in deep networks. It parallels observations about CNNs where stacking layers expands the effective receptive field beyond the kernel size, but applied to the discrete edge-labeling setting of Transformers. It also explains why reducing k from 16 to 8 for the big model did not hurt performance: the big model has the same number of layers (6) and more attention heads, providing even more paths for positional information to propagate implicitly.
The practical implication is substantial: the number of learned position vectors can be extremely small without sacrificing accuracy, reducing the parameter count of the position mechanism from 2k+1 per layer to perhaps 5 (for k = 2)—a 6.6× reduction in position parameters for the base model's k = 16 setting with negligible impact on BLEU. This is a diagnostic of the effective position resolution needed for translation, and it provides a strong prior for practitioners choosing k in new applications: start small and only increase if there is evidence that long-range relative position adds value beyond what depth provides implicitly.
Innovation 4: Establishing Relative Position as a Complete Replacement—Not a Supplement—to Absolute Encodings
At the time of this paper's publication, the default approach to position in non-recurrent models was to add absolute position representations to input embeddings. The original Transformer used sinusoidal encodings; Gehring et al. (2017) used learned position embeddings; and it was considered natural that the model needed to know where each token was in absolute terms. Relative position was seen, at most, as a complementary signal—a bias on attention weights that could supplement but not replace absolute position.
This paper challenges that assumption directly by removing absolute position encodings entirely and showing that relative position representations alone suffice. The experimental design is explicit about this: "In our experiments we did not observe any benefit from including sinusoidal position encodings in addition to relative position representations." This is not a throwaway finding—it is a refutation of the hypothesis that absolute position information is necessary for the Transformer to understand sequence order, at least for machine translation.
The significance of this finding goes beyond the BLEU improvement. It demonstrates that the Transformer's permutation invariance is not a fundamental limitation requiring absolute position compensation—it is a design choice about where position information enters the model. By shifting position from the input (node-level) to the attention mechanism (edge-level), the model gains access to exactly the positional signal it needs for its core operation (computing pairwise attention weights) without the representational overhead of recovering relative distances from absolute encodings.
This is a fundamental shift rather than an incremental refinement because it changes the architectural contract of the Transformer. In the original design, position is part of the input representation—like word embeddings, it is processed by every subsequent layer. In this paper's design, position is a property of the attention mechanism itself—it is consulted during attention computation and then "consumed," with its effects propagated forward through the mixed content-position representations z_i rather than being carried forward as a separate signal. This means that position information can be different at different layers: a layer can learn that relative position -1 matters a lot for local syntax, while another layer can learn that relative position beyond the clipping distance doesn't matter for its function. With absolute encodings, all layers receive the same positional signal and must extract task-appropriate information from it.
The authors are careful not to overclaim: they observe no benefit from combining absolute and relative position "in our experiments," leaving open the possibility that absolute position might matter for other tasks (e.g., where the absolute position of a token in a document—beginning vs. end—carries semantic weight beyond relative distances). But for the dominant application at the time (machine translation), the finding is clear: relative position is not merely a helpful addition but a complete substitute for absolute position, and one that yields better results (1.3 BLEU improvement for the big EN-DE configuration in Table 1).
This finding had a significant impact on subsequent Transformer design. Many later architectures (Transformer-XL, DeBERTa, T5's relative position bias) built directly on the idea that relative position should be encoded in the attention mechanism rather than added to inputs, often extending the specific a^K and a^V decomposition introduced here. The paper effectively established that the attention mechanism—not the input embedding—is the natural home for position information in the Transformer architecture.
5. Experimental Analysis
Evaluation Methodology
-
Dataset. The paper evaluates on the WMT 2014 machine translation task, using two language pairs: English-to-German (EN-DE) with approximately 4.5M sentence pairs from the WMT 2014 training data, and English-to-French (EN-FR) with approximately 36M sentence pairs. The test set is newstest2014 for both language pairs, and development set experiments use newstest2013 for EN-DE. The data is tokenized using a 32,768 word-piece vocabulary (following Wu et al., 2016).
-
Base model(s). The paper uses the Transformer model (Vaswani et al., 2017) in two configurations: base (6 encoder and decoder layers,
d_x = 512,d_z = 64, 8 attention heads, 1024 feed-forward inner-layer dimensions, dropout 0.1) and big (6 encoder and decoder layers,d_x = 1024,d_z = 64, 16 attention heads, 4096 feed-forward inner-layer dimensions, dropout 0.3 for EN-DE and 0.1 for EN-FR). Both configurations are used with sinusoidal position encodings (the baseline from Vaswani et al., 2017) and with the proposed relative position representations, enabling direct comparison. The base model is trained for 100,000 steps on 8 K40 GPUs without checkpoint averaging; the big model is trained for 300,000 steps on 8 P100 GPUs and averages the last 20 checkpoints saved at 10-minute intervals. -
Metrics. The primary metric is case-sensitive BLEU score (Papineni et al., 2002) on the newstest2014 test set, computed using the standard multi-bleu.perl script. For development set experiments (Section 4.3), BLEU is calculated on newstest2013. BLEU measures n-gram overlap between the model's output and reference translations, with higher scores indicating better translation quality. All reported BLEU scores use beam search decoding with a beam size of 4 and length penalty
α = 0.6. -
Baselines. The paper uses exactly one baseline: the Transformer with sinusoidal absolute position encodings as described by Vaswani et al. (2017), re-implemented in the tensor2tensor library to isolate the impact of relative position representations from any library or configuration differences. The authors explicitly state: "We generated baseline results to isolate the impact of relative position representations from any other changes to the underlying library and experimental configuration." No other position encoding schemes are compared (e.g., learned absolute position embeddings, distance-biased attention from Parikh et al., 2016), nor are there non-Transformer baselines (RNN-based or CNN-based sequence models). The comparison is strictly: Transformer with sinusoidal absolute encodings vs. Transformer with relative position representations, holding all other architectural and training details constant.
-
Generation budget / compute accounting. The paper does not use a "generation budget" framework in the sense of controlled inference-time compute allocation. All comparisons are made at fixed training budgets (100K steps for base, 300K steps for big) and fixed inference settings (beam size 4, length penalty 0.6). The efficiency measurement is wall-clock training throughput: the paper reports a "modest 7% decrease in steps per second" for the relative position implementation compared to the baseline Transformer, measured on P100 GPUs with the same model and batch sizes. This 7% figure is the paper's primary cost metric—it quantifies the computational overhead of the additional position-based matrix multiplications described in Section 3.3. There is no analysis of inference-time latency, memory usage beyond the asymptotic analysis in Section 3.3, or FLOPs counts.
-
Cross-validation / statistical protocol. There is no cross-validation, statistical significance testing, or multiple-run averaging described in the paper. The main results (Table 1) report single-run BLEU scores on the newstest2014 test set. The development set experiments (Tables 2 and 3) use the newstest2013 development set for model selection and hyperparameter tuning, then report on newstest2014 for the final test set. The paper reports exactly one number per configuration—no standard deviations, confidence intervals, or minimum/maximum over multiple seeds are provided. For the big model, checkpoint averaging is applied (last 20 checkpoints saved at 10-minute intervals) which reduces variance from training instability but does not constitute a statistical protocol in the formal sense.
Main Quantitative Results
Overall Translation Quality: Relative vs. Absolute Position Representations
The headline result appears in Table 1, comparing the Transformer with sinusoidal absolute position encodings against the Transformer with relative position representations across both model sizes and language pairs:
| Model Configuration | Position Type | EN-DE BLEU | EN-FR BLEU |
|---|---|---|---|
| Transformer (base) | Absolute (sinusoidal) | 26.5 | 38.2 |
| Transformer (base) | Relative | 26.8 | 38.7 |
| Transformer (big) | Absolute (sinusoidal) | 27.9 | 41.2 |
| Transformer (big) | Relative | 29.2 | 41.5 |
The relative position representations improve over absolute encodings in all four comparisons. The improvements are: +0.3 BLEU on EN-DE base, +0.5 BLEU on EN-FR base, +1.3 BLEU on EN-DE big, and +0.3 BLEU on EN-FR big. The largest gain (+1.3 BLEU on EN-DE big) is notable—it represents a roughly 5% relative improvement over the 27.9 baseline—while the smallest gains (+0.3 BLEU) represent roughly 1% relative improvement. The paper does not discuss whether the variation in improvement magnitude across configurations reflects sample size effects, language pair characteristics, or model capacity interactions.
Critically, the paper states: "In our experiments we did not observe any benefit from including sinusoidal position encodings in addition to relative position representations." This is a negative result with architectural significance: absolute and relative position encodings are not complementary for this task—relative position alone suffices, and adding absolute encodings provides no additional signal.
Effect of Clipping Distance k
Table 2 reports the development set BLEU (newstest2013, EN-DE, base model, no absolute position encodings) as a function of the maximum relative position clipping distance k:
k | EN-DE BLEU |
|---|---|
| 0 | 12.5 |
| 1 | 25.5 |
| 2 | 25.8 |
| 4 | 25.9 |
| 16 | 25.8 |
| 64 | 25.9 |
| 256 | 25.8 |
The progression reveals a sharp threshold at k = 1 and near-saturation by k = 2. With k = 0 (no relative position—all edges receive the same representation since clip(j - i, 0) = 0 for all j - i), BLEU collapses to 12.5, demonstrating that the model without any position information is nearly incapable of translation. Moving to k = 1 (three labels: -1, 0, 1) yields a dramatic jump to 25.5, recapturing essentially all of the benefit of relative position. k = 2 (five labels) reaches 25.8, and all higher values of k oscillate within 0.1 BLEU of this value.
The paper notes: "Notably, for k ≥ 2, there does not appear to be much variation in BLEU scores." The range from k = 2 to k = 256 is 25.8–25.9, with no monotonic trend. This is the key empirical finding underlying the authors' hypothesis that "as we use multiple encoder layers, precise relative position information may be able to propagate beyond the clipping distance"—the model's 6 stacked encoder layers effectively expand the receptive field beyond the explicit clipping window, making fine-grained distance information beyond immediate neighbors redundant.
The base model in the main experiments uses k = 16, while the big model uses k = 8. The ablation in Table 2 suggests that both of these values are in the saturated regime and that the reduction from 16 to 8 for the big model should have negligible accuracy impact (consistent with the observed results, though no direct k sweep is reported for the big model).
Ablation of Edge Representation Types: Key-Relative vs. Value-Relative
Table 3 isolates the contribution of the two edge representations a^V_{ij} (value-relative, Equation 3) and a^K_{ij} (key-relative, Equation 4) on newstest2013 for EN-DE base:
a^V_{ij} (value-relative) | a^K_{ij} (key-relative) | EN-DE BLEU |
|---|---|---|
| Yes | Yes | 25.8 |
| No | Yes | 25.8 |
| Yes | No | 25.3 |
| No | No | 12.5 |
The first two rows are identical: including both edge representations (25.8) yields exactly the same BLEU as including only the key-relative term (25.8). This establishes that the value-relative term a^V provides no measurable benefit once the key-relative term a^K is present for this task and model configuration.
The third row shows a substantial drop when only the value-relative term is used (25.3 vs. 25.8), indicating that a^V on its own provides less position information than a^K on its own—the model loses 0.5 BLEU by relying solely on position-modulated values rather than position-modulated attention weights. Both single-term configurations dramatically outperform no position information (12.5, fourth row).
The paper characterizes this cautiously: "Including relative position representations solely when determining compatibility between elements may be sufficient, but further work is needed to determine whether this is true for other tasks." The asymmetry between a^K and a^V is the central diagnostic that the attentional guidance role of position dominates its content-modulation role in translation.
Summary of Result Patterns Across Model Scales
While not presented in a single table, cross-referencing Tables 1–3 reveals an important consistency: the relative position mechanism produces consistent improvements across both model sizes, but the magnitude varies substantially by language pair and model scale. The improvements are larger for EN-DE than EN-FR in the big configuration (+1.3 vs. +0.3) but reversed in the base configuration (+0.3 vs. +0.5). The paper does not analyze this variation—no discussion is provided about whether it reflects statistical noise (single-run results), inherent differences between the language pairs (German has more flexible word order than French, potentially benefiting more from explicit relative position), or interactions with model capacity (the big model with 16 heads may leverage relative position differently than the base model with 8 heads).
Ablation Studies and Robustness Checks
-
Maximum clipping distance
k(Table 2): Performance saturates atk = 2with no meaningful variation fork ∈ {2, 4, 16, 64, 256}. This is the paper's primary robustness check—showing that the model's performance is insensitive to the specific choice ofkonce a minimal threshold is exceeded, validating that the default choices (k = 16for base,k = 8for big) are in the saturated regime and that results are not sensitive to this hyperparameter. -
Value-relative term
a^Vvs. key-relative terma^K(Table 3): Includinga^Valongsidea^Kprovides exactly zero benefit (both 25.8 BLEU), while including onlya^Vdrops to 25.3. This ablation establishes that the key-relative term alone captures the full benefit of relative position for translation, and that the two-term architecture as described in Section 3.1 could be simplified to a single-term version for this task without accuracy loss. -
Edge sharing across attention heads (Section 3.3, efficiency analysis): The paper reports that sharing
w^Kandw^Vacross all heads within a layer reduces space complexity fromO(h n^2 d_a)toO(n^2 d_a). While not presented as an ablation experiment, the fact that the base model uses per-head edge representations while the big model shares across heads—and both configurations show improvements over absolute encodings—suggests that per-head edge representations are not essential for gains. However, no direct ablation comparing per-head vs. shared edge representations within a single model configuration is provided. -
Unique edge representations per layer (Section 4.1, model configuration details): The paper notes that the base model uses "unique edge representations per layer and head" while the big model uses "unique edge representations per layer" (shared across heads). No ablation is performed comparing per-layer shared vs. per-layer independent edge representations. The experiment design choices appear driven by memory constraints on the big model rather than empirical comparison.
-
Absolute + relative position combination: The paper states that no benefit was observed from combining sinusoidal absolute encodings with relative position representations. This is a negative ablation result mentioned in the text but not presented in any table. The specific BLEU score for the combined configuration is not reported, making it difficult to assess whether the finding is a genuine lack of improvement or a failure to tune the combination properly (e.g., different learning rates, initialization scales, or clipping distances might be needed when both signals are present).
-
Training stability across runs: The paper does not report any results across multiple random seeds or training runs. All reported numbers are from single training runs. The big model uses checkpoint averaging (last 20 checkpoints), which reduces variance within a single run but does not address between-run variability. The base model uses no averaging. The absence of multi-run statistics means it is impossible to determine whether the observed differences (e.g., +0.3 BLEU for EN-DE base) exceed run-to-run variance—a concern given that BLEU scores for a 500-sentence test set like newstest2014 have non-trivial variance depending on initialization and data ordering.
-
Generalization to unseen sequence lengths: The paper does not include any experiment evaluating the model's performance on sequences longer than those seen during training. The theoretical argument that clipping enables length generalization is stated but never empirically tested. An experiment comparing absolute encodings vs. relative position representations on held-out long sequences would directly test this claim but is absent.
-
Ablation of
d_a(edge vector dimension): The paper setsd_a = d_z = 64without ablating this choice. It is possible that smaller edge dimensions (e.g., 32 or 16) would achieve similar performance with fewer parameters, or that larger dimensions would help whenkis small. No such experiment is performed.
Critical Assessment
Claim 1: Relative position representations improve translation quality over absolute encodings.
Assessment: The claim is demonstrated across all four tested configurations (Table 1), with improvements ranging from +0.3 to +1.3 BLEU. However, the strength of this evidence is tempered by several factors. First, all results are from single training runs with no reported confidence intervals or multi-run averages. For the base EN-DE configuration, the improvement is +0.3 BLEU—a small absolute gain that could plausibly arise from run-to-run variation. For the big EN-DE configuration (+1.3 BLEU), the magnitude makes this less likely, but without variance estimates this remains an assumption. Second, the baseline uses the tensor2tensor library's reimplementation of the original Transformer, and the paper acknowledges generating new baseline results rather than using published numbers (Table 1 caption: "We generated baseline results to isolate the impact of relative position representations from any other changes to the underlying library and experimental configuration"). While this is methodologically sound, it means the absolute BLEU numbers differ from previously published results and the comparison is strictly internal.
Third, the claim is supported for exactly one task domain (machine translation) on one dataset (WMT 2014). The paper makes no claim of broader applicability—Section 5 explicitly defers extensions to arbitrary graphs and nonlinear compatibility functions to future work—but the generality of the "relation-aware self-attention" framing invites extrapolation that is not empirically supported.
What was tested: Translation quality on newstest2014 for two language pairs with two model sizes. What was not tested: Any non-translation task, any out-of-distribution evaluation (longer sequences, different domains), any comparison against learned absolute position embeddings (only sinusoidal encodings were tested), or any larger-scale model beyond the big configuration.
Claim 2: Combining relative and absolute position representations yields no further improvement.
Assessment: This claim is mentioned in prose but not documented with any quantitative data. The paper states (Section 4.2): "In our experiments we did not observe any benefit from including sinusoidal position encodings in addition to relative position representations." No BLEU score, configuration detail, or table entry corresponds to this finding. This is a significant omission: a table row showing "Both absolute + relative" with the resulting BLEU would allow the reader to assess whether the lack of improvement means (a) the BLEU is identical (truly no benefit), (b) the BLEU is slightly lower (potential interference between the two signals), or (c) the BLEU is slightly higher but below a significance threshold that the authors judged negligible. The absence of even a parenthetical number makes this claim unverifiable from the paper's reported data.
Moreover, the combination experiment may not have been tuned appropriately. If the same training hyperparameters (learning rate schedule, warmup steps, dropout) were used for absolute-only, relative-only, and combined configurations, it is possible that the combined configuration requires different settings—for example, higher dropout to prevent overfitting from having access to richer position signals. The paper provides no evidence that hyperparameters were searched for the combined configuration.
Claim 3: Precise relative position information beyond k = 2 provides negligible benefit.
Assessment: Table 2 provides strong evidence for this claim on the development set (newstest2013) with the base model, showing flat BLEU scores of 25.8–25.9 for all k ≥ 2. This is the most robust finding in the experimental section, supported by sweeping a range of k values from 0 to 256. However, this result is demonstrated only for the base model on a single language pair (EN-DE) on the development set. No k sweep is reported for the big model, for EN-FR, or on the test set. The big model uses k = 8 (vs. k = 16 for the base model), and the implicit assumption is that k = 8 is also in the saturated regime, but this is not verified—Table 2 shows that k = 16 yields 25.8, but the big model's behavior could differ since it uses more heads (16 vs. 8) and larger model dimension (1024 vs. 512), potentially enabling more effective use of fine-grained relative distance information.
Additionally, the paper's explanation for the flat curve—that depth propagates position information beyond the clipping distance—is a hypothesis, not an empirically verified mechanism. An experiment that would directly test this hypothesis is to vary the number of layers while measuring the sensitivity of performance to k. If the depth-based propagation explanation is correct, we would expect that shallower models show greater sensitivity to k (needing larger k to achieve the same performance) while deeper models saturate earlier. No such experiment exists. An alternative explanation—that the translation task simply does not require distinguishing distances beyond 2, regardless of architectural depth—would also be consistent with the data and is not ruled out.
Claim 4: The key-relative term a^K is sufficient; the value-relative term a^V is not needed for machine translation.
Assessment: Table 3 supports this claim on the development set with the base EN-DE model, showing identical BLEU (25.8) for a^K alone vs. a^K + a^V. The experimental design is clean and the ablation is direct. However, the scope of the claim is limited: it is demonstrated for one model configuration (base), one language pair (EN-DE), and one task (machine translation) on the development set. The paper is appropriately cautious—"further work is needed to determine whether this is true for other tasks"—but the reader should recognize that the claim's generality is untested. For tasks that require more explicit structural awareness (e.g., syntactic parsing, where knowing the edge type between a head and dependent matters for the output representation at the dependent's position), the value-relative term might prove important. The paper's framing of a^V as "presumably important for tasks where information about the edge types selected by a given attention head is useful to downstream encoder or decoder layers" is speculative and receives no empirical support.
Claim 5: The implementation is efficient, with only a 7% decrease in training speed.
Assessment: The 7% figure is reported as a measurement on P100 GPUs but is not accompanied by any breakdown or ablation. The reader is told the final slowdown but not which component of the computation contributes most (the position-based compatibility term vs. the position-based value term), whether the slowdown scales with sequence length (the n^2 term might dominate at longer lengths), or whether the overhead is in computation or memory bandwidth. The space complexity analysis in Section 3.3 is asymptotic and doesn't provide concrete memory usage numbers or peak memory comparisons. Furthermore, the paper "was able to maintain the same model and batch sizes" but does not report maximum feasible batch sizes with and without relative position—the fact that the same batch size was used does not mean the memory ceiling is the same, only that the chosen batch size fits within both ceilings. A more thorough efficiency analysis would report training throughput in tokens/second (not just steps/second, since the two architectures may process different effective amounts of computation per step), peak GPU memory usage, and inference latency for beam search decoding (where the n^2 term affects each attention computation during autoregressive generation).
Missing experiments that would strengthen the evaluation:
-
Multi-run statistics with confidence intervals. Running each configuration 3–5 times with different random seeds would allow assessment of whether the observed BLEU differences exceed run-to-run variance, especially for the smallest gains (+0.3 BLEU).
-
Long sequence evaluation. The paper argues that clipping enables generalization to unseen lengths but never tests this. An experiment training on sequences up to 100 tokens and testing on sequences of 150–200 tokens would directly validate the generalization claim and compare absolute vs. relative position under length shift.
-
Direct comparison against learned absolute position embeddings. The baseline uses only sinusoidal encodings. Learned absolute position embeddings (as used in Gehring et al., 2017) would be a stronger baseline and would test whether the improvement comes from learned vs. fixed representations rather than pairwise vs. absolute representations.
-
Non-translation task evaluation. Testing on a task where word order is even more critical (e.g., syntactic parsing, subject-verb agreement, or a synthetic task with controlled position-content interactions) would better isolate the contribution of relative position and test the generality of the relation-aware framework.
-
Interaction with number of layers. Varying the number of encoder layers while sweeping
kwould test the depth-based position propagation hypothesis and provide guidance for architecture design when using relative position. -
Ablation of edge dimension
d_a. Sweepingd_a ∈ {16, 32, 64, 128}would reveal whether the full key/value dimension is necessary for edge representations or whether a smaller dimension (with or without projection) suffices, directly impacting the parameter and computational efficiency argument.
6. Limitations and Trade-offs
Limitation 1: Generalization Evidence Is Confined to a Single Task, Model Architecture, and Language Pair Family
The assumption or constraint: All positive evidence for relative position representations comes from exactly one task (machine translation), one model architecture (the Transformer base and big variants), one modeling library (tensor2tensor), and two language pairs from the same shared task (WMT 2014 English-German and English-French). The paper never evaluates on a non-translation task, a non-Transformer architecture, or even a translation pair with typologically different word order properties (e.g., English-to-Japanese, where the verb-final structure and case marking might interact differently with position representations). The authors are explicit about the framing: "For future work, we plan to extend this mechanism to consider arbitrary directed, labeled graph inputs to the Transformer" (Section 5), acknowledging that only the positional specialization of the relation-aware framework has been tested. However, the paper's title and abstract describe the contribution as an extension to "self-attention" in general, with machine translation presented as the evaluation rather than the scope boundary.
The consequence: The paper cannot distinguish between claims that are specific to neural machine translation on these language pairs and claims that are general properties of relative position in Transformers. Several findings have plausible task-specific explanations that go unexplored. For example, the result that k = 2 saturates performance (Table 2) could reflect a property of translation—where word reordering rarely exceeds a few positions within a local window and long-range dependencies are mediated by content-based attention to encoder states—rather than a general property of Transformer depth propagating position information. Similarly, the finding that a^V provides no benefit over a^K alone (Table 3) could be specific to translation, where the value modulation might be unnecessary because the decoder's cross-attention to encoder states already captures structural information. For a task like syntactic constituency parsing—where the model must explicitly output tree structures and where edge type matters for the representation at each node—the value-relative term might prove essential. The paper's framing of these findings as general architectural properties (Section 5: "Including relative position representations solely when determining compatibility between elements may be sufficient") is stated as a hypothesis requiring further work but reads as a conclusion in the context of the paper's narrative. A practitioner reading the paper in 2018 could reasonably conclude that k = 2 and a^K-only are sufficient defaults, only to discover on a different task that both choices substantially underperform larger k values and joint a^K + a^V representations.
What evidence exists in the paper: None—this is a limitation by omission. The paper contains only translation results. Table 1 covers two language pairs at two model sizes, all within the same experimental framework. Section 4.3 ablations use only EN-DE on the development set. The paper provides no baseline from a different task domain, no synthetic controlled experiment that isolates position-content interactions, and no evaluation on a typologically dissimilar language pair.
Mitigation status: The paper neither mitigates nor measures this limitation. The authors explicitly defer extensions beyond machine translation to future work (Section 5), and the abstract describes the contribution in terms general enough to apply beyond translation ("extending the self-attention mechanism to efficiently consider representations of the relative positions"). The gap between the claimed generality and the empirical scope is large and unacknowledged as a limitation.
Limitation 2: No Empirical Validation of Length Generalization Despite It Being a Core Claim
The assumption or constraint: The paper asserts that clipping relative position to a maximum absolute value k "enables the model to generalize to sequence lengths not seen during training" (Section 3.2). This is presented alongside the original Transformer's sinusoidal encoding design as a key motivation: "This property is shared by our relative position representations which, in contrast to absolute position representations, are invariant to the total sequence length" (Section 2.1). The invariant property is structurally true—for any sequence, all relative positions beyond ±k map to the same two boundary labels—but whether this structural property translates into actual generalization behavior is an empirical question that the paper never tests.
The consequence: The length generalization claim is purely theoretical. A practitioner deciding between absolute and relative position encodings for a deployment where test sequences will be longer than training sequences has no evidence from this paper to guide that decision. Worse, there are plausible failure modes that receive no investigation. First, while the edge labels ±k are seen during training (they appear whenever sequences have length at least k+1, which covers most practical training sequences), the distribution of edge labels shifts with sequence length. For a training sequence of length 50 with k = 16, the edge label +16 appears for relative distances of 16 through 49—a range of 34 positions all mapped to the same label. For a test sequence of length 150, the edge label +16 now covers distances 16 through 149—133 positions. The model has learned to associate the +16 edge vector with a mixture of relative distances heavily weighted toward the 16–50 range, and it is unclear whether that learned representation transfers to covering distances 50–150 effectively. Second, the attention distribution itself changes with sequence length: longer sequences mean more positions compete for the softmax probability mass, and the model's learned attention patterns (which are tuned to training-length sequences) may not gracefully adapt to a much larger set of candidates, even if relative position representations technically generalize. Neither of these failure modes is explored.
What evidence exists in the paper: None. The generalization claim is stated as motivation but never tested. No experiment compares model performance on training-length sequences vs. longer sequences, either for absolute encodings (where length generalization is a known weakness of learned position embeddings) or for relative representations (where it is claimed as a strength). The paper does not report the training sequence length distribution or the test sequence length distribution, making it impossible to assess even post-hoc whether the training and test sets had similar lengths.
Mitigation status: The paper provides a structural argument (clipping ensures all edge labels are seen during training) but no empirical validation. This is a significant gap because the length-generalization property is one of the two explicit motivations for clipping (alongside the hypothesis that precise position beyond k is unnecessary, which is partially tested via the k sweep in Table 2). The absence of any length-generalization experiment means readers must accept an architectural claim on faith.
Limitation 3: The Computational Overhead Analysis Is Incomplete and Omits Critical Practical Factors
The assumption or constraint: The paper reports that the relative position implementation incurs "a modest 7% decrease in steps per second" while maintaining the same model and batch sizes on P100 GPUs (Section 3.3). This single number serves as the efficiency justification for the method—the implicit claim is that the BLEU improvements come at an acceptable computational cost. However, this measurement captures only training throughput under one specific hardware configuration and batch size, and it omits several factors that a practitioner assessing total cost of ownership would need.
The consequence: The 7% figure, even taken at face value, understates the real cost in several ways. First, it measures only training throughput, not inference latency. Machine translation models are deployed for inference, often under strict latency constraints for interactive applications. The relative position computation adds n parallel matrix multiplications per attention head per layer for the position-compatibility term (Equation 5, second term), plus corresponding computation for the position-value term. During autoregressive decoding with beam search, this overhead is incurred at every decoding step for every beam hypothesis, and the self-attention computation must process the growing target-side sequence. The paper provides no inference latency measurements. Second, the space complexity analysis (Section 3.3) is asymptotic: O(bhnd_z + n^2 d_a). The n^2 d_a term stores the edge lookup matrices. For training on sequences of length ~100 with d_a = 64, this is ~640,000 floats per sequence—modest. But for tasks with longer sequences (document-level translation, summarization, or code generation), this term grows quadratically and can dominate memory usage. The paper acknowledges this implicitly ("the size of the relative increase depends on n / (bh)") but provides no measurements at longer sequence lengths or guidance on when the overhead becomes prohibitive. Third, the 7% figure was measured with bh (batch size × heads) large enough that the n^2 overhead is a small fraction of total memory—at smaller batch sizes or with fewer heads, the relative overhead would be larger. The paper reports only a single measurement point.
What evidence exists in the paper: One sentence of quantitative data: "the result was a modest 7% decrease in steps per second" on P100 GPUs. The space complexity analysis in Section 3.3 is asymptotic and does not report concrete memory usage, peak memory, or memory bandwidth utilization. No inference latency is reported. No scaling curves (throughput vs. sequence length, throughput vs. batch size, memory vs. sequence length) are provided.
Mitigation status: The paper provides the algebraic decomposition (Equation 5) that enables efficient implementation and notes that edge sharing across heads reduces the asymptotic space complexity from O(h n^2 d_a) to O(n^2 d_a). These are genuine efficiency contributions—the method would be significantly more expensive without them. However, the evaluation of efficiency is minimal: a single throughput number at one operating point, with no exploration of how the overhead scales with key variables (sequence length, batch size, model dimension) and no inference-time measurements. The paper does not acknowledge these gaps as limitations.
Limitation 4: The Comparison Is Only Against One Absolute Encoding Scheme, and the Baseline Is Not Tuned for Fairness
The assumption or constraint: The paper compares relative position representations against exactly one baseline: sinusoidal absolute position encodings as described by Vaswani et al. (2017) and re-implemented in tensor2tensor. The authors state this explicitly: "We generated baseline results to isolate the impact of relative position representations from any other changes to the underlying library and experimental configuration" (Table 1 caption). No comparison is made against learned absolute position embeddings (as used in Gehring et al., 2017, which the paper cites), against distance-biased attention with learned scalar biases (Parikh et al., 2016, also cited), or against any other position representation scheme proposed in the literature.
The consequence: The paper demonstrates that relative position representations outperform sinusoidal absolute encodings, but it does not demonstrate that they outperform absolute position representations in general—only this specific fixed-function encoding. This is a critical distinction because sinusoidal encodings have known weaknesses. They are not learned, meaning they cannot adapt to the statistics of the training data or the specific requirements of the task. They use fixed frequencies that may not align well with the positional patterns that matter for the language pair. They are added to token embeddings before the first layer, forcing the model to separate content and position signals from a summed representation—a known difficulty that relative position elegantly avoids by separating the two pathways. A learned absolute position embedding would share some of these weaknesses (additive combination, input-level injection) but not others (it could adapt frequencies and learn task-specific position patterns). The paper provides no evidence about whether the observed BLEU improvements come from the pairwise nature of relative position (the key conceptual innovation), from the learned nature of the representations (relative position vectors are trained, while sinusoids are fixed), or from the architecture-level injection (attention mechanism vs. input embeddings).
This matters for practical deployment decisions. If the primary gain comes from learned vs. fixed representations, a practitioner could achieve most of the benefit by simply replacing sinusoidal encodings with learned absolute position embeddings—a much simpler change that requires no modifications to the attention mechanism and no additional matrix multiplications. If the gain comes from injecting position into the attention mechanism rather than the input, that points toward a more fundamental architectural principle but also requires implementing the more complex relative position machinery. The paper's experimental design cannot distinguish these explanations.
What evidence exists in the paper: Table 1 compares only against sinusoidal absolute encodings. Section 4.3 ablates components of the relative position mechanism but never introduces a learned absolute position baseline. The paper cites Gehring et al. (2017) for the use of learned position embeddings but does not implement or compare against them.
Mitigation status: The paper does not acknowledge this as a limitation. It implicitly treats sinusoidal encodings as synonymous with absolute position representations and does not discuss the choice of baseline or alternative absolute encoding schemes. A reader unfamiliar with the position encoding literature might reasonably conclude from the abstract ("This approach yields improvements... over absolute position representations") that relative position has been compared against absolute position representations generally, when in fact it has been compared only against one specific non-learned scheme.
Limitation 5: All Results Are Single-Run with No Statistical Reliability Assessment
The assumption or constraint: Every BLEU score in the paper—Table 1 (test set), Tables 2 and 3 (development set)—is reported from a single training run. The paper does not report standard deviations, confidence intervals, minimum/maximum over multiple seeds, or any form of statistical testing. The only variance-reduction technique mentioned is checkpoint averaging for the big model (last 20 checkpoints saved at 10-minute intervals), which reduces noise within a single training trajectory but does not address between-run variability arising from random initialization, data ordering, or nondeterministic GPU operations. The test set sizes (newstest2014 for WMT) are approximately 3000 sentences for EN-DE and 3000 sentences for EN-FR, and the development set (newstest2013) is similar in size—large enough that BLEU differences of 0.3 points can be statistically significant under some conditions, but small enough that single-run estimates have non-negligible variance.
The consequence: The smallest reported improvements—+0.3 BLEU for EN-DE base and EN-FR big (Table 1), and the differences of 0.1 BLEU in the k sweep (Table 2)—cannot be reliably distinguished from run-to-run noise. A practitioner seeing "+0.3 BLEU" for the base EN-DE configuration cannot determine whether this represents a genuine improvement or whether retraining the same configuration with a different random seed would produce a BLEU score 0.3 points lower, eliminating the reported gain. The problem is most acute for the ablation results in Tables 2 and 3. In Table 2, the difference between k = 2 (25.8), k = 4 (25.9), and k = 16 (25.8) is ±0.1 BLEU—a range that is almost certainly within the noise floor of single-run development set evaluation. Drawing the conclusion that "for k ≥ 2, there does not appear to be much variation in BLEU scores" is reasonable as a qualitative observation, but the precise ranking of k = 4 as 25.9 vs. k = 2 as 25.8 cannot support the inference that k = 4 is actually better. Similarly, in Table 3, the identity between a^K only (25.8) and a^K + a^V (25.8) could reflect either genuine equivalence or a coincidental single-run match where multi-run averages would reveal a small difference. The paper's claim that the value-relative term provides no benefit rests on two numbers being identical in a single run.
The magnitude of between-run BLEU variance for Transformer models on WMT tasks is not reported in this paper but is known from the broader literature to be non-trivial—differences of 0.2–0.5 BLEU can arise from different random seeds even with identical hyperparameters, due to the sensitivity of training dynamics to initialization and data ordering. The paper provides no evidence about whether its specific training setup (tensor2tensor, the hyperparameters listed in Section 4.1) exhibits more or less variance than this.
What evidence exists in the paper: None. The paper contains no error bars, no multi-run statistics, and no discussion of statistical reliability. The experimental setup (Section 4.1) describes training configurations in detail but does not mention multiple runs or significance testing.
Mitigation status: The paper does not address this limitation. The big model's checkpoint averaging provides some within-run variance reduction but does not substitute for between-run replication. The absence of any statistical assessment is a standard practice in the 2017–2018 neural MT literature (the original Transformer paper also reported single-run results), but it weakens confidence in the smaller-magnitude results and makes the ablation conclusions in Tables 2 and 3 more suggestive than definitive.
Limitation 6: The Relationship Between Clipping Distance and Depth Is Hypothesized but Never Empirically Tested
The assumption or constraint: The paper's explanation for why k = 2 saturates performance (Table 2) invokes model depth: "as we use multiple encoder layers, precise relative position information may be able to propagate beyond the clipping distance" (Section 4.3). The reasoning is that a 6-layer encoder can effectively expand the receptive field of relative position beyond the explicit k-token window because token i in layer L can attend to token j in layer L, and token j's representation already incorporates information from tokens within ±k of j from layer L-1, extending the effective range to ±2k after two layers, ±3k after three layers, and so on. This is an elegant architectural argument that parallels observations about receptive fields in deep CNNs and has significant implications for how practitioners should set k as a function of model depth.
The consequence: The depth-based propagation hypothesis is plausible but untested, and the paper provides no experimental evidence that depth is the mechanism behind the saturation at k = 2. There are at least two alternative explanations for the flat BLEU scores in Table 2. First, the translation task may simply not require distinguishing relative distances beyond 2, regardless of architectural depth. If the linguistic phenomena that drive translation quality—local reordering of adjectives and adverbs, verb positioning relative to auxiliaries, prepositional phrase attachment—operate within a 2-token window, then even a single-layer model might saturate at k = 2, and depth would be irrelevant. Second, the model may lack the capacity to make effective use of fine-grained distance information even when it is provided. The edge vectors w^K and w^V have dimension d_a = 64 and are shared across all attention heads. For k = 256, the model must compress all distance-dependent positional information into 256 vectors of dimension 64 and then combine these with content-based queries and keys through a single dot product. It is possible that the dot-product compatibility function simply cannot effectively distinguish 256 relative distance categories—the positional signal gets lost in the content-based dot product—and that a nonlinear compatibility function (which the paper mentions as future work in Section 5) would be needed to exploit large k values. The depth-based explanation is only one of several possibilities, and none are tested.
The practical consequence is that a practitioner reading this paper might incorrectly conclude that k = 2 is sufficient for their architecture regardless of depth. If the depth hypothesis is correct, a shallower model (e.g., 2 layers) would need larger k to achieve the same effective positional receptive field, and using k = 2 would hurt performance. Conversely, if the task-based or capacity-based explanations are correct, even shallow models would saturate at k = 2, and increasing depth would not reduce the needed k. The paper provides no guidance for distinguishing these scenarios.
What evidence exists in the paper: Table 2 shows the saturation at k = 2 for a 6-layer base model. There is no experiment varying depth while measuring sensitivity to k. There is no experiment that directly probes the effective positional receptive field (e.g., a synthetic task where distance-d dependencies are controlled and the model's ability to resolve them is measured as a function of k and depth). There is no analysis of attention patterns showing that higher layers attend to tokens beyond the clipping distance of lower layers, which would be direct evidence for the propagation mechanism.
Mitigation status: The paper presents the depth-based propagation as a hypothesis ("may be able to propagate") but does not test it empirically or discuss alternative explanations. The hypothesis is offered as a post-hoc interpretation of Table 2 rather than a prediction tested by experimental design. The paper does not flag this as a limitation requiring further investigation, instead treating it as a plausible explanation that closes the discussion of the k sweep results.
7. Implications and Future Directions
How This Work Changes the Landscape
This paper is best understood as an architectural reframing with outsized downstream consequences rather than a paradigm shift in the Kuhnian sense. The core operation it modifies—self-attention—remains fundamentally the same: compute compatibility scores between query-key pairs, softmax-normalize, and aggregate values. What changes is where and how position information enters the computation, and that change, while conceptually modest, carries substantial implications for how the field thinks about position, attention, and the representational capacity of Transformers.
The paper's most durable contribution is not the specific BLEU improvements in Table 1 but the intellectual migration of position information from the input embedding to the attention mechanism itself. Before this work, the default assumption was that position is a property of individual tokens—you add a position vector to each token embedding, and the model figures out how to use it. This paper demonstrates that position is more naturally understood as a property of token pairs, and that encoding it directly into the pairwise attention computation yields both better performance and a cleaner architectural separation of concerns: content determines what to attend to, position modulates how content interacts. This is a reframing of what self-attention is for: it is not just a content-based matching mechanism with position bolted on, but a pairwise interaction module that innately expects relational information.
This reframing resolved a latent tension in the original Transformer design that the paper identifies subtly but never states explicitly. The original Transformer's sinusoidal encodings were hypothesized to enable relative position learning through the dot-product structure of the encoding function—a property that is mathematically elegant but architecturally indirect. The position information must survive being added to content embeddings, passed through layer normalization, transformed by feed-forward layers, and then re-extracted at the attention computation three or more layers later. The paper's architecture eliminates this indirection entirely: if you want the attention weight between tokens i and j to depend on their relative distance, just add a learned vector representing that distance directly into the key that token i's query will dot-product with. This is the architectural equivalent of making an implicit inductive bias explicit—and the BLEU improvements (up to +1.3 on EN-DE big) quantify the benefit of eliminating the indirection.
The paper also reconciles a subtle contradiction in how position had been treated across model families. RNNs encoded position structurally (through sequential computation), CNNs encoded it through local receptive fields, and the Transformer—the first fully-parallel sequence model—encoded it through input augmentation. Each approach treated position as a fundamentally different kind of thing. By showing that relative position can be injected directly into the attention computation in a way that generalizes across sequence lengths (via clipping) and across layers (via learned per-layer edge representations), the paper provided a unified conceptual vocabulary: position is a pairwise relation that can be learned, clipped, and injected at the point of use, regardless of whether the underlying model is recurrent, convolutional, or attentional. This unification is more significant than the specific method because it abstracts position away from model architecture and into a learned, edge-based representation that can in principle be attached to any pairwise interaction mechanism.
A more subtle landscape shift concerns what the paper implies about depth and position. The finding that k = 2 saturates performance (Table 2), combined with the hypothesis that depth propagates positional information beyond the clipping distance, suggests that the effective positional receptive field of a Transformer is not determined by the clipping distance alone but by the product of clipping distance and depth. This is a genuinely new idea that the paper introduces but does not fully develop: it implies that positional encoding design should be co-optimized with model depth, and that deeper models can "afford" smaller clipping distances because the effective positional range grows with each layer. This connects position modeling to the broader literature on effective receptive fields in deep networks (Luo et al., 2016) and suggests that the relationship between position encoding and depth is not merely additive but multiplicative—a hypothesis that subsequent work on Transformer positional architectures would explore extensively.
The paper also redirects research attention away from absolute position encodings and toward attention-native position mechanisms. Before this paper, improving position representations meant designing better absolute encoding functions (learned, sinusoidal, or otherwise). After this paper, the space of possible position mechanisms expanded dramatically to include any pairwise relation that can be encoded as an edge vector and injected into the attention computation. This opened the door for the rich subsequent literature on relative position biases (Raffel et al., 2020's T5), rotary position embeddings (Su et al., 2021's RoPE), and alien position encoding schemes (Press et al., 2021's ALiBi), all of which operate on attention logits or keys directly rather than on input embeddings. The paper did not predict these specific methods, but it established the architectural validity of putting position in the attention mechanism rather than the input, which made those subsequent innovations natural to propose rather than radical to consider.
Finally, the paper's graph-theoretic framing—modeling the input as a labeled, directed, fully-connected graph with edge representations—was ahead of its time. In 2018, the idea that Transformers could natively consume structured relational inputs was speculative (the paper explicitly defers it to future work). By 2020-2022, graph-aware Transformers, structure-aware Transformers for code, and relation-aware attention for knowledge graphs had become active research areas, and this paper's Equation 3 and 4 provided the architectural template that many of those efforts adapted. The paper did not cause this shift single-handedly, but it provided the cleanest early formulation of how to make self-attention edge-aware without sacrificing the efficient matrix-multiplication implementation that made the Transformer practical.
Follow-Up Research This Work Enables
Stress-testing the depth-position propagation hypothesis through controlled synthetic experiments. The paper hypothesizes that the saturation of performance at k = 2 (Table 2) occurs because multi-layer stacking propagates relative position information beyond the explicit clipping window. This hypothesis has never been directly tested in the paper, and it has significant architectural implications: if true, shallow Transformers would require larger k than deep ones to achieve the same effective positional receptive field. A strong follow-up would design a synthetic task where the correct output depends on a token at a controlled distance d from the query position (e.g., copying the token d positions to the left, where d is varied systematically). By training Transformers of varying depths (1, 2, 4, 6, 12 layers) with varying clipping distances k (1, 2, 4, 8, 16) and measuring accuracy as a function of d, one could map out the effective positional receptive field d_effective(k, L) and determine whether it scales as approximately k * L (multiplicative propagation), k + L (additive), or saturates at some maximum regardless of depth. A negative result—finding that d_effective is independent of depth and saturates at k—would refute the paper's hypothesis and suggest instead that the translation task simply does not require long-range relative position. Either outcome would sharpen our understanding of what the clipping distance actually controls.
Quantifying the value-relative term a^V on tasks where edge type matters for output structure. The paper's ablation (Table 3) shows that a^V provides zero benefit over a^K alone for machine translation (25.8 BLEU in both cases). The authors explicitly speculate that a^V "is presumably important for tasks where information about the edge types selected by a given attention head is useful to downstream encoder or decoder layers" but provide no evidence. A targeted follow-up would test this hypothesis on a task where the structural relationship between tokens directly determines the output representation. Candidate tasks include: (a) syntactic constituency parsing, where the model must produce a tree structure and the edge type between a head and its dependent (subject, object, modifier) should influence the dependent's output representation; (b) semantic role labeling, where each token's representation must encode its thematic role relative to a predicate; (c) a synthetic task where the model must output a linear combination of input tokens whose coefficients depend on their relative positions (e.g., output_i = sum_j w(j-i) * input_j for a known weight function w). In each case, the prediction is that a^V will provide measurable benefit over a^K alone, and the magnitude of that benefit will correlate with how strongly the output representation depends on pairwise structural relationships. A null result—a^V providing no benefit even on these structurally-demanding tasks—would suggest that the attention-weight gating mechanism alone is sufficient to encode structural information and that the value modulation path is architecturally redundant.
Training a difficulty predictor or length-aware clipping adapter to dynamically select k. The paper's clipping distance k is a fixed hyperparameter chosen before training. Table 2 shows that performance is insensitive to k for k ≥ 2, but this finding is averaged over the entire development set. A more nuanced hypothesis is that the optimal k varies with sequence position: tokens near the beginning or end of a sentence might benefit from asymmetric positional information (e.g., knowing that they are sentence-initial or sentence-final), which a fixed symmetric clipping window cannot provide. A follow-up could replace the fixed k with a learned, content-dependent clipping function—for example, a lightweight network that takes the query and key representations as input and outputs a position-dependent k value or directly modulates the edge vector lookup. This would blend the paper's discrete edge-label approach with the continuous, content-dependent position biases that later models like Shaw et al. (2018)'s own follow-up work and Dai et al. (2019)'s Transformer-XL explored. The experiment would compare fixed-k relative position against adaptive-k on the WMT tasks and on a length-extrapolation benchmark (training on sequences up to 100 tokens, testing on sequences up to 200), measuring whether dynamic k allocation recovers performance on long sequences that fixed-k clipping loses.
Extending the edge representation to continuous-valued relative distances, not just discrete clipped labels. The paper discretizes relative position into 2k + 1 learned vectors, discarding the actual numerical distance for any pair beyond ±k. This is architecturally simple but throws away potentially useful information: knowing that two tokens are 100 positions apart versus 10 positions apart might matter for some tasks, even if the exact difference between 100 and 101 does not. A natural extension would learn a function f: R -> R^{d_a} that maps the continuous relative distance j - i to an edge vector, parameterized either as a small neural network or as a set of basis functions (e.g., sinusoidal features of varying frequency) whose coefficients are learned. This would allow the model to smoothly interpolate between nearby relative positions while still compressing long-range distances into a low-dimensional representation. A strong experiment would compare discrete clipping (the paper's method) against a continuous learned function on: (a) the WMT translation tasks, to see whether continuous distance information recovers the small BLEU differences that discrete clipping loses; (b) a long-range dependency benchmark like LRA (Tay et al., 2020), where distinguishing distance 50 from distance 500 is critical; and (c) a length-generalization test where the continuous function can naturally handle distances not seen during training without the hard clipping artifact at ±k. The hypothesis is that continuous functions outperform discrete clipping on tasks requiring genuine long-range structural awareness while matching discrete clipping on tasks (like translation) where only local position matters.
Systematic comparison against learned absolute position embeddings with matched parameter budgets. The paper compares relative position representations only against sinusoidal absolute encodings (Table 1), leaving open the possibility that learned absolute position embeddings—with a comparable parameter budget—would close or eliminate the gap. A rigorous follow-up would implement three baselines: (a) sinusoidal absolute encodings (the paper's existing baseline), (b) learned absolute position embeddings with n_max * d_model parameters (where n_max is the maximum sequence length), and (c) learned absolute position embeddings with a parameter budget matched to the relative position method (2 * (2k + 1) * d_z parameters per layer, summing to approximately 12 layers * 2 * 33 * 64 = 50,688 parameters for the base model with k = 16). Each baseline would be evaluated on the WMT tasks at both base and big scales, with multi-run statistics. This experiment would decompose the BLEU improvement in Table 1 into three components: the benefit of learned vs. fixed position representations, the benefit of pairwise vs. absolute position injection, and the benefit of per-layer vs. input-only position injection. If learned absolute embeddings achieve most of the gain, the paper's architectural innovation (edge-based injection) is less important than the simpler "learn your position representations" lesson. If relative position still substantially outperforms parameter-matched absolute embeddings, the pairwise injection mechanism is genuinely responsible for the improvement.
Measuring the effective positional receptive field through attention pattern analysis. The paper's hypothesis that depth propagates relative position information beyond the explicit clipping distance is stated but never empirically visualized. A diagnostic experiment would train the base model with relative position (k = 2) and then analyze the attention patterns at each layer to measure the distribution of attention weights as a function of relative distance. Specifically, for each attention head at each layer, one could compute the average attention weight assigned to tokens at each relative distance (from -n to n), aggregated over all sequences in the test set. If the depth-propagation hypothesis is correct, attention heads in higher layers should show substantial probability mass at relative distances beyond ±2—indicating that the model is attending to tokens outside the explicit clipping window by routing through intermediate representations. If instead attention in higher layers remains concentrated within ±2, it would suggest that the depth-propagation mechanism is not actually used and that the saturation at k = 2 (Table 2) simply reflects the task not requiring longer-range position information. This experiment would provide direct empirical evidence for or against one of the paper's central explanatory claims and would connect the paper's architectural innovation to the interpretability literature on attention head specialization.
Practical Applications and Downstream Use Cases
Neural machine translation systems operating under tight latency and memory constraints. The paper demonstrates that relative position representations with k = 2 achieve essentially the same BLEU as k = 16 (Table 2) while requiring only 5 edge labels per direction instead of 33—a 6.6× reduction in the number of learned position vectors per layer. For production translation systems running on edge devices or under strict latency budgets, this translates directly to reduced parameter count and faster attention computation (fewer edge vectors to retrieve and add). A deployment engineer can configure the relative position mechanism with k = 2 (or even k = 1, which Table 2 shows achieves 25.5 BLEU vs. 25.8 for k = 2—a 0.3 BLEU sacrifice for a further 2.5× reduction in edge labels) and omit the value-relative term a^V entirely (Table 3 shows no loss from its removal), yielding a position mechanism that adds negligible memory overhead while still capturing the ~13 BLEU gain over having no position information at all (12.5 → 25.5+ BLEU). The paper also establishes that relative position representations can fully replace absolute sinusoidal encodings with no accuracy penalty, eliminating the need for the sinusoidal computation and the input-level addition step, which simplifies the embedding layer implementation.
Training data generation and self-improvement pipelines for sequence models. The paper's architecture is an enabling component for systems that need to learn from structured or position-sensitive feedback. In a self-improvement loop where a Transformer generates candidate translations and receives BLEU-based or automatic post-editing feedback, the model's ability to distinguish token order in its own outputs is critical—it must recognize that "the cat sat on the mat" is correct while "the mat sat on the cat" is not. Absolute position encodings provide this signal only indirectly (through input-level augmentation that may be diluted by later layers). Relative position representations, by injecting position directly into every attention computation, make the pairwise ordering signal available at every layer's decision point. This matters most when the model is learning from its own mistakes: a revision that fixes a word order error is more likely to succeed if the model can explicitly attend to "what word came before what" at the architectural level rather than reconstructing order from absolute position embeddings. The paper's finding that a^K alone captures the full benefit (Table 3) means that self-improvement systems can implement this capability with minimal additional parameters—just the key-relative edge vectors—making it feasible even in compute-constrained fine-tuning loops.
Architectures for processing tabular, structured, or semi-structured data with Transformers. The paper's graph-theoretic framing (Section 3.1)—modeling the input as a labeled, directed, fully-connected graph—directly applies to domains where the input is not a linear sequence but a structured object with known pairwise relationships. In a table-to-text generation system, rows and columns have natural relative positions, but there are also relational edges (same-row, same-column, header-cell relationships) that can be encoded as additional edge types beyond simple position differences. The paper's architecture natively supports this: rather than clip(j - i, k) as the edge label function, one would define a composite label that includes relative row position, relative column position, and any structural relationship (e.g., "same row header," "column aggregate"). The efficient implementation in Section 3.3 (splitting the compatibility computation and sharing edge representations across heads) applies regardless of the edge labeling scheme, meaning that even with multiple edge types, the space complexity remains O(n^2 d_a) rather than O(h n^2 d_a). The paper's demonstration that per-head edge representations are not essential (the big model shares across heads and still improves over absolute encodings) further supports scaling to settings where many edge types would make per-head storage prohibitive. The paper does not implement this extension, but the architectural generality is explicitly designed in.
When to Prefer This Method
The paper does not articulate an explicit tradeoff matrix against named alternative position encoding schemes beyond the implicit comparison to sinusoidal absolute encodings. The evidence supports the following decision rule grounded in the paper's own findings:
-
Prefer relative position representations over sinusoidal absolute encodings when: you are training a Transformer for machine translation or a similar sequence-to-sequence task where local word order matters. The paper's evidence shows consistent BLEU improvements across all tested configurations (Table 1: +0.3 to +1.3 BLEU), with the largest gains on the big EN-DE configuration. The method reduces to a minimal configuration (
k = 2,a^Konly, shared across heads) with negligible accuracy loss (Tables 2 and 3), making it practical even under tight memory constraints. The 7% training slowdown (Section 3.3) is the cost to weigh against the BLEU gain, but the paper provides no inference-latency data to inform deployment decisions. -
Prefer sinusoidal absolute encodings over relative position representations when: you need the simplest possible implementation with no modifications to the attention mechanism. Sinusoidal encodings add zero learned parameters, require no per-layer computation beyond the initial embedding addition, and are already implemented in standard Transformer libraries. The paper does not compare against learned absolute position embeddings, so no evidence-based preference can be stated relative to that alternative—a practitioner using learned absolute embeddings must rely on external evidence to choose between them and the paper's relative position method.