Shifting Mechanisms: How Positional Encoding Choice Shapes In-Context Retrieval
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. 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.
Create a lesson
Metadata
- Categories
- cs.CL, cs.LG
Related papers
Rules Amortize, Pairings Don't: Linguistic Structure Determines What Latent Task Representations Can Replace In-Context Learning
Shared title terminologycs.CLGunmay Jhingran
How Local Mixing Encodes Relative Position in Global NoPE Attention
Shared title terminologycs.CLCutter Dawes, Nick Alonso, Tom Figliolia et al.
BaLEEN: Biasing with Latent Encoded Entities for Context-Aware ASR
Shared title terminologycs.CLChihiro Taguchi, Yotaro Kubo, Rujikorn Charakorn
Fine-Tuning Without Gradients? Closed-Form, LLM-Written Classifiers on a Frozen Encoder
Shared title terminologycs.CLMd Nasir Uddin, Musa Tur Farazi, Soumik Bhattacharjee et al.
NORMCRAFT: Cultural Norm Generation for Context-Aware Language Model Alignment
Shared title terminologycs.CLTangyuan Zhang, Zhuang Li, Fatemeh Shiri et al.
Worth the Wait? How Response Time and Streaming Shape Judgments of Generative AI Answers and Chatbot Engagement
Shared title terminologycs.CLZihan Chen, Di Zhu, Lei Nico Zheng