Query-Guided RoPE Modulation for Lost-in-the-Middle Mitigation in Long-Context LLMs
Peiyu Zhang, Heng Ping, Shinibali Bhattacharyya, Anwesan Pal, Nikos Kanakaris, Kevin Cheang, Shixuan Li, Wei Yang, Paul Bogdan
Abstract
Long-context language models often neglect information in the middle of the input, a phenomenon known as "lost-in-the-middle". Part of this gap may stem from the long-range decay of rotary position embedding (RoPE), which weakens the positional signal between distant tokens. Existing input compression deletes low-importance tokens, and attention reweighting acts only after RoPE has weakened this signal. RoPE-level methods modify positions directly but apply the same remapping to every query. To address these limitations, we propose QGPM (Query-Guided Positional Modulation), a training-free method that reshapes RoPE positions using query relevance from the model's own attention heads. QGPM builds a broad relevance map for lower layers and a sharp one for upper layers. Low-relevance tokens advance by less than one position on fast-rotating planes, pulling relevant evidence toward the query. Slow-rotating planes keep the original layout, with every token in place. Experiments on NoLiMa and RULER with multiple context lengths show that QGPM improves over base models and strong baselines, with the largest gains on retrieval tasks, and generalizes across multiple backbones. Our code is available at https://github.com/iZHpy/QGPM.
Create a lesson
Metadata
- Categories
- cs.CL, cs.AI, cs.LG
- Comments
- 13 pages, 3 figures, 7 tables. Code: https://github.com/iZHpy/QGPM
Related papers
LongCapHarness: Capability-Guided Auto-Harnessing for Long-Context Reasoning
Shared title terminologycs.CLTao Zhang, Yuhang He
Make Position Uninformative: Exchangeable Self-Distillation Flattens the Lost-in-the-Middle Curve
Shared title terminologycs.CLQingsen Ma, Dianyun Wang, Jiahong Liu et al.
ASCENT: Scale-Complementary External State for Frozen Long-Context Language Models
Shared title terminologycs.CLXingjian Zhang
MERIT: Experience-Guided Memory for Long-Horizon Persona-Specific Persuasive Dialogue
Shared title terminologycs.CLRohan Kirti, Akash Ghosh, Pratik Amrit et al.
Can Speech LLMs Recognize When Audio Evidence Is Insufficient? A Diagnostic Study and a Pre-Generation Probing Mitigation
Shared title terminologycs.CLVladislav Nesterenko, Polina Doronicheva, Olga Golubeva et al.
ContextFact: Remembering Facts in Context for Long-Term Conversational Agents
Shared title terminologycs.CLJiayu Huang, Yichao Cai, Xinyu Li et al.