arXiv:2611.09554cs.CLNov 2026

Manuscript Offprint

arXiv:2611.09554

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

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

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.

1 Introduction

Long-context language models now support context windows of hundreds of thousands of tokens (Achiam et al., 2023; Grattafori et al., 2024; Yang et al., 2024). Whether these models actually use the information in such windows, however, remains an open question. Models often attend to the beginning and end of the input while neglecting the middle, a phenomenon known as “lost-in-the-middle” (Liu et al., 2024). Benchmarks designed to probe context utilization (Modarressi et al., 2025; Hsieh et al., 2024a) show that accuracy drops sharply as context grows, especially when the relevant evidence shares little surface overlap with the query. This paper therefore aims to improve how models use the information already in the context window, rather than to extend the window further.

Part of this utilization gap may stem from rotary position embedding (RoPE) (Su et al., 2024), the position encoding adopted by most modern LLMs. RoPE represents position as rotations in many two-dimensional planes, each with a distinct frequency. Over a long distance, the fast-rotating planes complete many full turns and no longer carry a consistent distance signal. Evidence far from the query is thus matched through fewer planes than nearby text. This long-range decay depends on the positional distance between tokens. Assigning relevant evidence a position closer to the query can therefore mitigate the decay without changing the input text.

Existing methods that target lost-in-the-middle fall short of intervening on RoPE in a query-aware manner. Input compression methods (Jiang et al., 2024; Pan et al., 2024; Li et al., 2023) delete low-importance tokens and thus discard graded relevance information. Attention reweighting methods (Zhang et al., 2024a,b; Guardieiro et al., 2025) strengthen attention to selected tokens, but only after RoPE has weakened the positional signal between distant tokens. RoPE-level methods (Zhang et al., 2024c; Jin et al., 2024; An et al., 2025) modify position encoding directly, yet apply the same remapping regardless of the query. A separate line of work shows that a few attention heads already attend to query-relevant spans in long inputs (Wu et al., 2025; Zhang et al., 2025a). Such attention signals have been used to select KV cache entries (Li et al., 2024), filter input tokens (Shi et al., 2026), or re-rank documents (Zhang et al., 2025a),

∗^{*}Equal contribution.

†^{\dagger}The work does not relate to the author's position at Amazon.

but always by deleting or reordering content. In short, no existing method uses the model's own query relevance to reshape RoPE positions while keeping every token in place.

We propose QGPM (Query-Guided Positional Modulation), a training-free method that fills this gap. QGPM reads the attention from the query to each context sentence in a few such heads. The resulting relevance ranking is shaped into a broad map and a sharp map. Using the two maps, QGPM lets low-relevance tokens advance by less than one position on the fast-rotating planes, so relevant sentences move closer to the query. In contrast, the slow-rotating planes keep the original layout of the document. The broad map is applied to the lower layers and the sharp map to the upper layers. QGPM deletes or reorders no token and updates no model weight.

Our main contributions are as follows:

  • We propose QGPM, which converts query relevance read from the model's own attention heads into token-level and frequency-specific RoPE positions. The same context thus receives different positions under different queries, which makes the evidence needed by each query easier for the model to retrieve.

  • We design a modulation scheme that is aware of both frequency and depth. Low-relevance text is compressed only on fast-rotating planes, and separate relevance maps guide the lower and upper layers.

  • Comprehensive experiments on multiple LLM backbones and long-context benchmarks show that QGPM achieves superior overall performance over strong baselines across a range of context lengths.

References (22)