EMNLP Findings2024
LongHeads: Multi-Head Attention is Secretly a Long Context Processor
Yi Lu, Xin Zhou, Wei He, Jun Zhao, Tao Ji, Tao Gui, Qi Zhang, Xuanjing Huang
摘要
Large language models (LLMs) have achieved impressive performance in numerous domains but often struggle to process lengthy inputs effectively and efficiently due to limited length generalization and attention's quadratic computational demands. Many sought to mitigate this by restricting the attention window within the pre-trained length. However, these methods introduce new issues such as ignoring the middle context and requiring additional training. To address these problems, we propose LONGHEADS, a training-free framework that enhances LLM's long context ability by unlocking multi-head attention's untapped potential. Instead of allowing each head to attend to the full sentence, which struggles with generalizing to longer sequences, we allow each head to process in-distribution length by selecting and attending to important context chunks. To this end, we propose a chunk selection strategy that relies on the inherent correlation between the query and the key representations, efficiently distributing context chunks to different heads. In this way, each head ensures it can effectively process attended tokens within the trained length, while different heads in different layers can collectively process longer contexts. LONGHEADS works efficiently and fits seamlessly with many LLMs that use relative positional encoding. LONGHEADS achieves 100% accuracy at the 128k length on passkey retrieval task, verifying LONGHEADS's efficacy in extending the usable context window for existing models. We release our code at https://github.com/LuLuLuyi/LongHeads.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 8 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Efficient Streaming Language Models with Attention Sinks 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Efficient Streaming Language Models with Attention Sinks 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- Efficient Streaming Language Models with Attention Sinks 引用了 YaRN: Efficient Context Window Extension of Large Language Models
- Efficient Streaming Language Models with Attention Sinks 引用了 Compressive Transformers for Long-Range Sequence Modelling
- MoBA: Mixture of Block Attention for Long-Context LLMs 引用了 Efficient Streaming Language Models with Attention Sinks
- MoBA: Mixture of Block Attention for Long-Context LLMs 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation 引用了 Compressive Transformers for Long-Range Sequence Modelling
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness 引用了 Compressive Transformers for Long-Range Sequence Modelling
- YaRN: Efficient Context Window Extension of Large Language Models 引用了 Compressive Transformers for Long-Range Sequence Modelling
- LongRAG: A Dual-Perspective Retrieval-Augmented Generation Paradigm for Long-Context Question Answering 引用了 Efficient Streaming Language Models with Attention Sinks
- LongRAG: A Dual-Perspective Retrieval-Augmented Generation Paradigm for Long-Context Question Answering 引用了 FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
- LongRAG: A Dual-Perspective Retrieval-Augmented Generation Paradigm for Long-Context Question Answering 引用了 YaRN: Efficient Context Window Extension of Large Language Models
- 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 引用了 YaRN: Efficient Context Window Extension of Large Language Models
引用它的顶会 Paper8
- MoBA: Mixture of Block Attention for Long-Context LLMsEnzhe Lu, Zhejun Jiang, Jingyuan Liu, Yulun Du 等NeurIPS 2025 · 219 次引用
- LongRAG: A Dual-Perspective Retrieval-Augmented Generation Paradigm for Long-Context Question AnsweringQingfei Zhao, Ruobing Wang, Yukuo Cen, Daren Zha 等EMNLP 2024 · 13 次引用
- Symbolic Working Memory Enhances Language Models for Complex Rule ApplicationSiyuan Wang, Zhongyu Wei, Yejin Choi, Xiang RenEMNLP 2024 · 6 次引用
- FidelityGPT: Correcting Decompilation Distortions with Retrieval Augmented GenerationZhiping Zhou, Xiaohong Li, Ruitao Feng, Yao Zhang 等NDSS 2026 · 5 次引用
- Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMsXiaoran Liu, Yuerong Song, Zhigeng Liu, Zengfeng Huang 等ICLR 2026 · 2 次引用
它引用的 Paper10
- FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra 等NeurIPS 2022 · 5,493 次引用
- Efficient Streaming Language Models with Attention SinksGuangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han 等ICLR 2024 · 1,714 次引用
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 次引用
- Compressive Transformers for Long-Range Sequence ModellingJack W. Rae, Anna Potapenko, Siddhant M. Jayakumar, Chloe Hillier 等ICLR 2020 · 833 次引用
- YaRN: Efficient Context Window Extension of Large Language ModelsBowen Peng, Jeffrey Quesnelle, Honglu Fan, Enrico ShippoleICLR 2024 · 508 次引用
相关 Paper
- Training-Free Long-Context Scaling of Large Language ModelsChenxin An, Fei Huang, Jun Zhang, Shansan Gong 等ICML 2024 · 68 次引用
- ReAttention: Training-Free Infinite Context with Finite Attention ScopeXiaoran Liu, Ruixiao Li, Zhigeng Liu, Qipeng Guo 等ICLR 2025
- PoSE: Efficient Context Window Extension of LLMs via Positional Skip-wise TrainingDawei Zhu, Nan Yang, Liang Wang, Yifan Song 等ICLR 2024 · 110 次引用
- Parallel Context Windows for Large Language ModelsNir Ratner, Yoav Levine, Yonatan Belinkov, Ori Ram 等ACL 2023 · 37 次引用
- InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context MemoryChaojun Xiao, Pengle Zhang, Xu Han, Guangxuan Xiao 等NeurIPS 2024 · 223 次引用
