Found in the Middle: How Language Models Use Long Contexts Better via Plug-and-Play Positional Encoding
Zhenyu Zhang, Runjin Chen, Shiwei Liu, Zhewei Yao, Olatunji Ruwase, Beidi Chen, Xiaoxia Wu, Zhangyang Wang
Abstract
This paper aims to overcome the"lost-in-the-middle"challenge of large language models (LLMs). While recent advancements have successfully enabled LLMs to perform stable language modeling with up to 4 million tokens, the persistent difficulty faced by most LLMs in identifying relevant information situated in the middle of the context has not been adequately tackled. To address this problem, this paper introduces Multi-scale Positional Encoding (Ms-PoE) which is a simple yet effective plug-and-play approach to enhance the capacity of LLMs to handle the relevant information located in the middle of the context, without fine-tuning or introducing any additional overhead. Ms-PoE leverages the position indice rescaling to relieve the long-term decay effect introduced by RoPE, while meticulously assigning distinct scaling ratios to different attention heads to preserve essential knowledge learned during the pre-training step, forming a multi-scale context fusion from short to long distance. Extensive experiments with a wide range of LLMs demonstrate the efficacy of our approach. Notably, Ms-PoE achieves an average accuracy gain of up to 3.8 on the Zero-SCROLLS benchmark over the original LLMs. Code are available at https://github.com/VITA-Group/Ms-PoE.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
26 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Efficient Streaming Language Models with Attention Sinks cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Efficient Streaming Language Models with Attention Sinks cites H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models
- H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Models cites Efficient Streaming Language Models with Attention Sinks
- Efficient Streaming Language Models with Attention Sinks cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- POSITION BIAS MITIGATES POSITION BIAS: Mitigate Position Bias Through Inter-Position Knowledge Distillation cites Efficient Streaming Language Models with Attention Sinks
- POSITION BIAS MITIGATES POSITION BIAS: Mitigate Position Bias Through Inter-Position Knowledge Distillation cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- DAPE: Data-Adaptive Positional Encoding for Length Extrapolation cites Efficient Streaming Language Models with Attention Sinks
- DAPE: Data-Adaptive Positional Encoding for Length Extrapolation cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Graph-KV: Breaking Sequence via Injecting Structural Biases into Large Language Models cites Efficient Streaming Language Models with Attention Sinks
- Graph-KV: Breaking Sequence via Injecting Structural Biases into Large Language Models cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Graph-KV: Breaking Sequence via Injecting Structural Biases into Large Language Models cites FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- DAPE V2: Process Attention Score as Feature Map for Length Extrapolation cites Efficient Streaming Language Models with Attention Sinks
- DAPE V2: Process Attention Score as Feature Map for Length Extrapolation cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- DAPE V2: Process Attention Score as Feature Map for Length Extrapolation cites DAPE: Data-Adaptive Positional Encoding for Length Extrapolation
Cited by top-tier papers26
- DAPE: Data-Adaptive Positional Encoding for Length ExtrapolationChuanyang Zheng, Yihang Gao, Han Shi, Minbin Huang et al.NeurIPS 2024 · 42 citations
- POSITION BIAS MITIGATES POSITION BIAS: Mitigate Position Bias Through Inter-Position Knowledge DistillationYifei Wang, Feng Xiong, Yong Wang, Linjing Li et al.EMNLP 2025 · 16 citations
- DAPE V2: Process Attention Score as Feature Map for Length ExtrapolationChuanyang Zheng, Yihang Gao, Han Shi, Jing Xiong et al.ACL 2025 · 12 citations
- SARA: Selective and Adaptive Retrieval-augmented Generation with Context CompressionYiqiao Jin, Kartik Sharma, Vineeth Rakesh, Yingtong Dou et al.ACL 2026 · 7 citations
- Graph-KV: Breaking Sequence via Injecting Structural Biases into Large Language ModelsHaoyu Wang, Peihao Wang, Mufei Li, Shikun Liu et al.NeurIPS 2025 · 6 citations
Builds on16
- ALBERT: A Lite BERT for Self-supervised Learning of Language RepresentationsZhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel et al.ICLR 2020 · 7,418 citations
- FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 citations
- Efficient Streaming Language Models with Attention SinksGuangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han et al.ICLR 2024 · 1,714 citations
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 citations
- H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language ModelsZhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen et al.NeurIPS 2023 · 1,003 citations
Related papers
- LaMPE: Length-aware Multi-grained Positional Encoding for Adaptive Long-context Scaling Without TrainingSikui Zhang, Guangze Gao, Ziyun Gan, Chunfeng Yuan et al.ACL Findings 2026
- Mitigating Position Bias in Transformers via Layer-Specific Positional Embedding ScalingZhenghua Wang, Yiran Ding, Changze Lv, Yixin Wu et al.ACL Findings 2026
- Extending LLM Context Window with Adaptive Grouped Positional Encoding: A Training-Free MethodXinhao Xu, Jiaxin Li, Hui Chen, Zijia Lin et al.ACL 2025 · 1 citation
- Never Lost in the Middle: Mastering Long-Context Question Answering with Position-Agnostic Decompositional TrainingJunqing He, Kunhao Pan, Xiaoqun Dong, Zhuoyang Song et al.ACL 2024 · 3 citations
- 3D-RPE: Enhancing Long-Context Modeling Through 3D Rotary Position EncodingXindian Ma, Wenyuan Liu, Peng Zhang, Nan XuAAAI 2025 · 14 citations
