ReAttention: Training-Free Infinite Context with Finite Attention Scope
Xiaoran Liu, Ruixiao Li, Zhigeng Liu, Qipeng Guo, Yuerong Song, Kai Lv, Hang Yan, Linlin Li, Qun Liu, Xipeng Qiu
摘要
The long-context capability of the Large Language Models (LLM) has made significant breakthroughs, but the maximum supported context length in length extrapolation remains a critical bottleneck limiting their practical applications. The constraint of context length in LLMs arises from the self-attention mechanism, which cannot effectively and efficiently capture the semantic relationships within infinitely long contexts via the limited pre-trained positional information and attention scope. In this work, we propose ReAttention, a training-free approach enabling LLM based on the self-attention mechanism to support an infinite context with a finite attention scope under sufficient memory resources. ReAttention performs the position-agnostic top-k attention before the ordinary position-aware self-attention, freeing LLMs from the length extrapolation issue. We validate the performance of ReAttention on the LongBench, L-Eval, and InfiniteBench and demonstrate that it is on par with traditional methods. Furthermore, we also apply ReAttention on mainstream LLMs, including LLaMA3.1-8B and Mistral-v0.3-7B, enabling them to support context lengths of at least 1M and even expanding the context length of LLaMA3.2-3B-chat by 128× to 4M without any further training in Needle-In-A-Haystack tests. We also improve the efficiency of ReAttention with Triton and achieve an efficient extrapolation without additional overhead. The code is available at https://github.com/OpenMOSS/ReAttention .
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 6 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Mixture of Weight-shared Heterogeneous Group Attention Experts for Dynamic Token-wise KV Optimization 引用了 SnapKV: LLM Knows What You are Looking for Before Generation
- FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- SnapKV: LLM Knows What You are Looking for Before Generation 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- SnapKV: LLM Knows What You are Looking for Before Generation 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- SnapKV: LLM Knows What You are Looking for Before Generation 引用了 Scissorhands: Exploiting the Persistence of Importance Hypothesis for LLM KV Cache Compression at Test Time
- Scale-invariant attention 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMs 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMs 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- LongLLaDA: Unlocking Long Context Capabilities in Diffusion LLMs 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- LongLLaDA: Unlocking Long Context Capabilities in Diffusion LLMs 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- Compress, Gather, and Recompute: REFORMing Long-Context Processing in Transformers 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- Compress, Gather, and Recompute: REFORMing Long-Context Processing in Transformers 引用了 SnapKV: LLM Knows What You are Looking for Before Generation
- Scissorhands: Exploiting the Persistence of Importance Hypothesis for LLM KV Cache Compression at Test Time 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
引用它的顶会 Paper6
- LongLLaDA: Unlocking Long Context Capabilities in Diffusion LLMsXiaoran Liu, Yuerong Song, Zhigeng Liu, Zengfeng Huang 等AAAI 2026 · 30 次引用
- Scale-invariant attentionBen Anson, Xi Wang, Laurence AitchisonNeurIPS 2025 · 6 次引用
- Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMsXiaoran Liu, Yuerong Song, Zhigeng Liu, Zengfeng Huang 等ICLR 2026 · 2 次引用
- Compress, Gather, and Recompute: REFORMing Long-Context Processing in TransformersWoomin Song, Sai Muralidhar Jayanthi, Srikanth Ronanki, Kanthashree Mysore Sathyendra 等NeurIPS 2025 · 1 次引用
- Mixture of Weight-shared Heterogeneous Group Attention Experts for Dynamic Token-wise KV OptimizationGuanghui Song, Dongping Liao, Yiren Zhao, Kejiang Ye 等EMNLP 2025
它引用的 Paper24
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra 等NeurIPS 2022 · 5,493 次引用
- FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 次引用
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 次引用
- SnapKV: LLM Knows What You are Looking for Before GenerationYuhong Li, Yingbing Huang, Bowen Yang, Bharat Venkitesh 等NeurIPS 2024 · 1,019 次引用
- Scissorhands: Exploiting the Persistence of Importance Hypothesis for LLM KV Cache Compression at Test TimeZichang Liu, Aditya Desai, Fangshuo Liao, Weitao Wang 等NeurIPS 2023 · 557 次引用
相关 Paper
- Training-Free Long-Context Scaling of Large Language ModelsChenxin An, Fei Huang, Jun Zhang, Shansan Gong 等ICML 2024 · 68 次引用
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context MemoryChaojun Xiao, Pengle Zhang, Xu Han, Guangxuan Xiao 等NeurIPS 2024 · 223 次引用
- LongHeads: Multi-Head Attention is Secretly a Long Context ProcessorYi Lu, Xin Zhou, Wei He, Jun Zhao 等EMNLP Findings 2024 · 12 次引用
- PoSE: Efficient Context Window Extension of LLMs via Positional Skip-wise TrainingDawei Zhu, Nan Yang, Liang Wang, Yifan Song 等ICLR 2024 · 110 次引用
- LLM Maybe LongLM: SelfExtend LLM Context Window Without TuningHongye Jin, Xiaotian Han, Jingfeng Yang, Zhimeng Jiang 等ICML 2024 · 167 次引用
