DL0168 NoPE: Causal Positional Bias Without Encodings

What is NoPE (No Positional Embeddings), and how does a causal mask alone induce implicit positional bias in decoder-only Transformers without explicit position encodings?

Answer

NoPE is a decoder-only Transformer trained with no position information injected anywhere: no learned or sinusoidal absolute embedding added to the token embeddings, no RoPE rotation inside attention, and no ALiBi distance bias on the logits. The only order-dependent structure left in the network is the causal mask, and that turns out to be enough. A bidirectional self-attention layer without positional encodings is permutation equivariant, so it can only represent a bag of tokens, but causal masking destroys that symmetry because query i attends over exactly i+1 keys. The size of each token’s receptive field is therefore itself a strictly monotone function of absolute position, and any head with near-uniform logits converts that count into a readable 1/(i+1) signal in the residual stream. Haviv et al. showed that absolute position can be linearly probed out of NoPE hidden states with high accuracy while perplexity stays close to models with explicit encodings, and Kazemnejad et al. proved constructively that a NoPE decoder can represent both absolute and relative position, and that it length-generalizes at least as well as RoPE or ALiBi on small-scale algorithmic tasks.

(1) Definition: NoPE removes every explicit position term and keeps only the lower-triangular attention mask, so position is an emergent property rather than an injected feature.
(2) Broken Permutation Equivariance: without a mask, f(PX) = P f(X) for any permutation P, but the causal mask satisfies P^\top M P \neq M, which is exactly the asymmetry the model exploits.
(3) Counting Is The Mechanism: uniform attention over an (i+1)-token window puts 1/(i+1) mass on each visible key, so the output norm encodes absolute position.
(4) Absolute First, Relative Later: layer 1 materializes an absolute code, usually anchored on a dominant BOS sink, and deeper layers subtract two codes to obtain the relative offset i-j.
(5) Resolution Decays Quadratically: the gap between adjacent positions is O(i^{-2}), so the counting code loses discriminative power long before the context window ends.
(6) Implicit Recency Bias: trained NoPE heads develop distance-decaying attention that resembles a learned relative encoding, but with no principled extrapolation knob, which is why long-context NoPE needs attention-temperature scaling or hybrid layers.

The mechanism is easiest to read as counting. Row i of the causal attention matrix has exactly i+1 unmasked entries, so a head whose logits are roughly constant across its window spreads 1/(i+1) of the probability mass onto each visible key. If the value vectors are dominated by one distinguished token, in practice the BOS token that every position can see, then the output norm at position i is proportional to 1/(i+1): a strictly decreasing, invertible function of absolute position that the next layer can consume as a positional feature. Kazemnejad et al. turn this observation into a theorem, and once an absolute code sits in the residual stream a later layer’s q_i^\top k_j term can compute i-j, recovering relative position too. Real NoPE models show the fingerprints of this construction: very heavy mass on the first token, first-layer heads with near-flat windows, and probes that decode absolute position from early activations.

Three panels: a ten by ten causal attention mask heatmap whose row i has i+1 shaded cells with the visible-key count printed beside each row, the same size bidirectional mask where every row sees all ten keys, and a line chart showing that uniform causal attention yields an output norm of one over i plus one that decreases strictly with position while bidirectional uniform attention yields a flat one over n line carrying no positional information

Figure 1: The causal mask is the position signal. Counting unmasked entries per row gives 1{,}2{,}\ldots{,}n under causal masking but a constant n under bidirectional attention, so the same uniform head produces a strictly decreasing code in one case and a flat, uninformative constant in the other.

Mathematical Formulation:
\alpha_{ij} = \frac{\exp(q_i^\top k_j)}{\sum_{m=0}^{i} \exp(q_i^\top k_m)}
\alpha_{ij} = 0 \ \text{for}\ j > i
q_i^\top k_j = c \Rightarrow \alpha_{ij} = \tfrac{1}{i+1}
o_i = \sum_{j=0}^{i} \alpha_{ij} v_j = \frac{v_0}{i+1}
i = \|o_i\|^{-1} - 1
f_{\mathrm{bi}}(PX) = P f_{\mathrm{bi}}(X)
P^\top M P \neq M

Where:

  • o_i \in \mathbb{R}^{d} is the attention output at query position i, and \alpha_{ij} the attention weight it places on key position j.
  • q_i, k_j, v_j are the query, key, and value vectors, containing no positional term at all under NoPE.
  • j, m \in \{0,\ldots,i\} index only the unmasked keys; the second line is the causal mask, which is the sole source of order sensitivity.
  • c is a constant logit, the degenerate case that makes attention uniform over the window; the third and fourth lines assume v_j = 0 for j \geq 1 and a nonzero anchor value v_0 at BOS.
  • The fifth line inverts the code with \|v_0\| = 1, showing that absolute position is exactly recoverable from a single layer’s output norm.
  • P is a permutation matrix, X the input sequence, f_{\mathrm{bi}} an unmasked layer, and M the lower-triangular mask; the last two lines state why encoders need explicit position encodings and causal decoders do not.

The same construction explains why NoPE is fragile at long context. Adjacent positions are separated by \Delta_i = 1/((i+1)(i+2)), a relative spacing of only 1/(i+2), so the code that cleanly distinguishes position i from position i+1 must resolve relative differences near 8\times10^{-3} around token 126 and near 10^{-3} around token 1022. Under bf16 activations those differences sit at the edge of machine epsilon, and the second pressure is entropic: uniform attention over a growing window has entropy H_i \leq \ln(i+1), so a head calibrated to be discriminative at 2K tokens is comparatively diffuse at 32K. Real models do not use the naive counting head alone, but both effects push in the same direction, which is why raw NoPE degrades past its training length while RoPE offers explicit rescaling recipes such as NTK interpolation and YaRN.

Two panels: a log-log plot of the relative gap one over i plus two between adjacent positional codes falling below bf16 machine epsilon around position 126 and below fp16 machine epsilon around position 1022, and a semi-log plot of the maximum attention entropy log of i plus one growing from about 7.6 nats at 2048 tokens to about 10.4 nats at 32768 tokens

Figure 2: Two length pressures on an implicit code. The relative spacing between neighbouring positions shrinks like 1/(i+2), crossing bf16 machine epsilon in the low hundreds of tokens, while the entropy ceiling grows like \ln(i+1), so the same attention temperature that is sharp at 2K is diffuse at 32K.

PropertyNoPERoPEALiBi
Source of positionCausal mask only; window size acts as an implicit counterRotation of queries and keys by angle proportional to indexFixed per-head linear penalty on the distance i minus j
Works without a maskNo; a bidirectional layer becomes permutation equivariantYes; encoders use it directlyYes, with a symmetric distance bias
Extension knobAttention temperature or entropy scaling; no standard recipeBase frequency rescaling, NTK interpolation, YaRNSlope schedule; extrapolates but truncates effective range
Extra costNone; consumes capacity and layer-1 heads insteadTwo elementwise ops per head; cached keys are pre-rotatedOne additive bias term per attention score
Dominant failure modeCode resolution and softmax sharpness collapse past training lengthUnseen rotation phases out of distribution beyond training lengthStrong recency bias suppresses genuine long-range retrieval

Login to view more content


Log in to track your progress

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *