Shifting Mechanisms: How Positional Encoding Choice Shapes In-Context Retrieval

Eric Enouen, Sainyam Galhotra
9/29/2026
cs.CLcs.LG

No confident code implementation found for this paper.

Abstract

Language models increasingly use architectures that vary attention span and positional encoding across layers, such as applying RoPE with sliding-window attention and NoPE with global attention (SWA NoPE). However, how these choices shape in-context retrieval remains unclear.

Show full abstract

To study this question, we take a mechanistic view, tracing how positional encoding (PE) choice shapes the internal mechanisms models use for in-context retrieval. Across 22 open-weight models spanning eight families, we find that standard RoPE models rely primarily on positional retrieval, while PE hybrids shift toward semantic retrieval. We further show on a controlled pre-training ablation that confining positional encoding to local layers produces this semantic shift, degrading representations of positional information. Finally, we show that the reported long-context gains of PE hybrids mask a retrieval trade-off: SWA NoPE improves over RoPE on multiple-target retrieval and QA, but degrades when distinguishing competing keys. We show that these behavioral differences better track the mechanism shift from positional toward semantic mechanisms than a uniform improvement in long-context retrieval.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{enouen2026shifting,
  title  = {Shifting Mechanisms: How Positional Encoding Choice Shapes In-Context Retrieval},
  author = {Eric Enouen and Sainyam Galhotra},
  year   = {2026},
  eprint = {2609.38530},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2609.38530v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2609.38530.svg)](https://codeofpaper.com/paper/2609.38530)

Discussion