Efficient Length-Generalizable Attention via Causal Retrieval for Long-Context Language Modeling
Xiang Hu, Zhihao Teng, Jun Zhao, Wei Wu, Kewei Tu
摘要
Despite the success of Transformers, handling longer contexts remains challenging due to the limited length generalization and quadratic complexity of self-attention. Transformers often require post-training with a larger attention window, significantly increasing computational and memory costs. In this paper, we propose a novel attention mechanism based on dynamic context, Grouped Cross Attention (GCA), which can generalize to 1000 × the pre-training context length while maintaining the ability to access distant information with a constant attention window size. For a given input sequence, we split it into chunks and use each chunk to retrieve top-k relevant past chunks for subsequent text generation. Specifically, unlike most previous works that use an offthe-shelf retriever, our key innovation allows the retriever to learn how to retrieve past chunks that better minimize the auto-regressive loss of subsequent tokens in an end-to-end manner. Such a mechanism accommodates retrieved chunks with a fixed-size attention window to achieve longrange information access, significantly reducing computational and memory costs during training and inference. Experiments show that GCA-based models achieve near-perfect accuracy in passkey retrieval for 16M context lengths, which is 1000× the training length.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 4 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Efficient Streaming Language Models with Attention Sinks 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- Efficient Streaming Language Models with Attention Sinks 引用了 Language Models are Few-Shot Learners
- Improving Language Models by Retrieving from Trillions of Tokens 引用了 Language Models are Few-Shot Learners
- Improving Language Models by Retrieving from Trillions of Tokens 引用了 Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
- Understanding and Improving Length Generalization in Hierarchical Sparse Attention Models 引用了 Efficient Streaming Language Models with Attention Sinks
- Understanding and Improving Length Generalization in Hierarchical Sparse Attention Models 引用了 Hardware-aligned Hierarchical Sparse Attention for Efficient Long-term Memory Access
- Understanding and Improving Length Generalization in Hierarchical Sparse Attention Models 引用了 Language Models are Few-Shot Learners
- Understanding and Improving Length Generalization in Hierarchical Sparse Attention Models 引用了 Every Token Counts: Generalizing 16M Ultra-Long Context in Large Language Models
- Every Token Counts: Generalizing 16M Ultra-Long Context in Large Language Models 引用了 Understanding and Improving Length Generalization in Hierarchical Sparse Attention Models
- Hardware-aligned Hierarchical Sparse Attention for Efficient Long-term Memory Access 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
- Hardware-aligned Hierarchical Sparse Attention for Efficient Long-term Memory Access 引用了 Language Models are Few-Shot Learners
- Language Models are Few-Shot Learners 引用了 Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks
- Every Token Counts: Generalizing 16M Ultra-Long Context in Large Language Models 引用了 Hardware-aligned Hierarchical Sparse Attention for Efficient Long-term Memory Access
- Every Token Counts: Generalizing 16M Ultra-Long Context in Large Language Models 引用了 Language Models are Few-Shot Learners
- Long-Context Generalization with Sparse Attention 引用了 Efficient Streaming Language Models with Attention Sinks
- Long-Context Generalization with Sparse Attention 引用了 FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning
引用它的顶会 Paper4
- Long-Context Generalization with Sparse AttentionPavlo Vasylenko, Hugo Pitorro, Andre F. T. Martins, Marcos V. TrevisoICLR 2026 · 19 次引用
- Hardware-aligned Hierarchical Sparse Attention for Efficient Long-term Memory AccessXiang Hu, Jiaqi Leng, Jun Zhao, Kewei Tu 等NeurIPS 2025 · 7 次引用
- Understanding and Improving Length Generalization in Hierarchical Sparse Attention ModelsJiaqi Leng, Xiang Hu, Junxiong Wang, Jianguo Li 等ICLR 2026 · 6 次引用
- Every Token Counts: Generalizing 16M Ultra-Long Context in Large Language ModelsXiang Hu, Zhanchao Zhou, Ruiqi Liang, Zehuan Li 等ACL 2026 · 2 次引用
它引用的 Paper22
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah 等NeurIPS 2020 · 64,255 次引用
- Retrieval-Augmented Generation for Knowledge-Intensive NLP TasksPatrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni 等NeurIPS 2020 · 19,162 次引用
- FlashAttention-2: Faster Attention with Better Parallelism and Work PartitioningTri DaoICLR 2024 · 2,600 次引用
- Efficient Streaming Language Models with Attention SinksGuangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han 等ICLR 2024 · 1,714 次引用
- Improving Language Models by Retrieving from Trillions of TokensSebastian Borgeaud, Arthur Mensch, Jordan Hoffmann, Trevor Cai 等ICML 2022 · 1,629 次引用
相关 Paper
- LongHeads: Multi-Head Attention is Secretly a Long Context ProcessorYi Lu, Xin Zhou, Wei He, Jun Zhao 等EMNLP Findings 2024 · 12 次引用
- Reducing Transformer Key-Value Cache Size with Cross-Layer AttentionWilliam Brandon, Mayank Mishra, Aniruddha Nrusimha, Rameswar Panda 等NeurIPS 2024 · 150 次引用
- Random-Access Infinite Context Length for TransformersAmirkeivan Mohtashami, Martin JaggiNeurIPS 2023 · 207 次引用
- Core Context Aware Transformers for Long Context Language ModelingYaofo Chen, Zeng You, Shuhai Zhang, Haokun Li 等ICML 2025
- Training-Free Long-Context Scaling of Large Language ModelsChenxin An, Fei Huang, Jun Zhang, Shansan Gong 等ICML 2024 · 68 次引用
