TL;DR
How can a Transformer know whether a word is the 5th or the 500th in a sentence when you strip away all its positional embeddings? Previous theories pointed to shrinking activation variance, forgetting that LayerNorm immediately wipes out scale. This paper uncovers the real culprit: a clever, two-layer geometric circuit that uses the "Beginning of Sequence" (BOS) token as a directional compass, encoding exact token positions in vector angles that effortlessly survive normalization.
What Problem Does This Paper Address?
Traditionally, Transformers are treated as "bags of words" unless we explicitly inject positional embeddings (like sinusoidal waves or RoPE) to tell them word order. Yet, strangely, autoregressive Transformers without positional embeddings—dubbed NoPE models—still manage to figure out absolute token positions.
How? The prevailing theory blamed the causal attention mask (which restricts token $i$ to only looking at preceding tokens $0$ through $i$). Because token $i$ averages $i+1$ vectors, the variance of that average shrinks at a predictable rate of $1/(i+1)$. Case closed? Not quite. Real-world Transformers apply LayerNorm throughout the network, which rescales every token vector to unit variance, effectively erasing this scale signal. What, then, actually survives LayerNorm to tell the network where it is?
Methods
Taking a mechanistic interpretability approach (reverse-engineering weights into human-readable circuits), the authors derive a theoretical five-step, two-layer mechanism and verify it empirically on three trained NoPE decoders: two 2-layer models trained explicitly to predict position (1-head 1H and 12-head 12H), and a standard 6-layer language model (NoPE LM) trained purely on next-token prediction.
The circuit unfolds across two Transformer blocks:
- Noisy Anchor Injection (Layer 1 Attention): Because the special
BOStoken sits at position 0, every token attends to it. Layer 1 writes aBOSvector direction into every token's representation, though it gets noisier further down the sequence due to random cross-terms from other words. - Cleaning the Slate (Layer 1 MLP + LayerNorm): The first MLP acts like a gate. Recognizing the massive
BOSsignal at position 0, it leaves it alone, while pushing all later positions ($i \ge 1$) toward a uniform, nearly constant (or zero)BOSshare. Crucially, the enclosing LayerNorm helps squash residual word noise! - Counting in the Denominator (Layer 2 Attention Weights): With
BOSstanding out cleanly at position 0 and every subsequent token contributing an identical constant to the attention denominator, the attention weight $\alpha_{i,0}$ paid toBOSdecays smoothly as $k / (k + i)$ at position $i$. - Exposing the Weight (Layer 2 Value/Output Map): Attention weights are trapped inside the attention head. To expose $\alpha_{i,0}$ to the residual stream, the value-output matrix ($W_{OV}$) maps
BOSand non-BOStokens to two distinct vector directions—creating an output vector that smoothly interpolates between the two levels based on $\alpha_{i,0}$. - Reading Position: Any downstream layer can now take a simple dot product (projection) along the mapped
BOSdirection to read out $\alpha_{i,0}$—and thus, the exact position $i$.
To prove this isn't just a neat math trick, the authors run causal interventions—surgically ablating or replacing specific directional shares during forward passes while running random-direction controls.
Datasets
All models were trained and evaluated on OpenWebText using sequences of length $L = 1024$ with a BOS token prepended at position 0. Probes were fitted on 320 held-out sequences, and all measurements and causal interventions were evaluated on a separate set of 1,600 held-out sequences. No new datasets were introduced.
Key Insights and Ideas
- Directions survive where scales die: LayerNorm destroys vector norms (scales), so NoPE models encode position in direction proportions—mixing a fixed
BOSanchor vector with an orthogonal or opposite background vector. - LayerNorm is an accomplice, not an obstacle: In Step 2, the MLP outputs a high-magnitude vector for positions $\ge 1$ so that when LayerNorm rescales the sum, the noisy Layer-1 token content is effectively washed out.
- Opposite poles maximize resolution: Theoretically, the
BOSand non-BOSvalue vectors only need to be orthogonal. Empirically, trained networks push them to point in opposite directions (cosine similarity $\approx -0.996$ in1Hand $-0.771$ inNoPE LM). Stretching the gap between the two interpolated endpoints makes tiny shifts in attention weights much easier to distinguish at late positions.
Key Results
Both explicit position models and the naturally trained language model converge on this exact five-step circuit:
- Formulaic Precision: The analytical curve $k/(k+i)$ explains the measured Layer-2
BOSattention weights with $R^2 = 0.998$ in1Hand $R^2 = 0.954$ inNoPE LM. - Sharp Position Decoding: Adding a second layer drops position Mean Absolute Error (MAE) tenfold compared to a 1-layer model (from 30.3 tokens down to 2.3 tokens in
1H). InNoPE LM—which was never explicitly taught about position—probing the Layer-2 projections across heads recovers token position (out of 1,024) with $R^2 = 0.993$ and an MAE of 15.8 tokens. - Causal Knockouts: Wiping out the Layer-1
BOSterm craters position $R^2$ from $>0.99$ into negative territory ($-4.64$ in1H, $-15.77$ inNoPE LM) and spikesNoPE LM's next-token perplexity by 41.6x. Collapsing the two value levels in Step 4 similarly ruins position decoding and increases LM perplexity by 7.8x to 34.8x, whereas random-direction control edits change $R^2$ by nothing and loss by at most $0.0008$.
Limitations and Future Work
- Reliance on a
BOSAnchor: Every step counts the prefix relative to a guaranteedBOStoken at index 0. Without a fixed starting token, a model must improvise. Because natural language follows Zipf's law, the authors hypothesize networks might latch onto ultra-frequent words like "the" or "a" as makeshift anchors—an open question for future work. - Architectural Specificity: The exact circuit steps were derived and tested on decoder-only pre-norm Transformers using standard LayerNorm. Variations like RMSNorm could still exploit the directional
BOSanchor, though the exact downstream mechanics require empirical validation.
Summary updated