Exploring Transformer Extrapolation
Zhen Qin, Yiran Zhong, Hui Deng
摘要
Length extrapolation has attracted considerable attention recently since it allows transformers to be tested on longer sequences than those used in training. Previous research has shown that this property can be attained by using carefully designed Relative Positional Encodings (RPEs). While these methods perform well on a variety of corpora, the conditions for length extrapolation have yet to be investigated. This paper attempts to determine what types of RPEs allow for length extrapolation through a thorough mathematical and empirical analysis. We discover that a transformer is certain to possess this property as long as the series that corresponds to the RPE's exponential converges. Two practices are derived from the conditions and examined in language modeling tasks on a variety of corpora. As a bonus from the conditions, we derive a new Theoretical Receptive Field (TRF) to measure the receptive field of RPEs without taking any training steps. Extensive experiments are conducted on the Wikitext-103, Books, Github, and WikiBook datasets to demonstrate the viability of our discovered conditions. We also compare TRF to Empirical Receptive Field (ERF) across different models, showing consistently matched trends on these datasets. Code is released at: https://github.com/OpenNLPLab/Rpe.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 5 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- DAPE: Data-Adaptive Positional Encoding for Length Extrapolation 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- DAPE: Data-Adaptive Positional Encoding for Length Extrapolation 引用了 KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation
- Navigating Scaling Laws: Compute Optimality in Adaptive Model Training 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Hierarchically Gated Recurrent Neural Network for Sequence Modeling 引用了 VATT: Transformers for Multimodal Self-Supervised Learning from Raw Video, Audio and Text
- DAPE V2: Process Attention Score as Feature Map for Length Extrapolation 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- DAPE V2: Process Attention Score as Feature Map for Length Extrapolation 引用了 DAPE: Data-Adaptive Positional Encoding for Length Extrapolation
- DAPE V2: Process Attention Score as Feature Map for Length Extrapolation 引用了 KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation
- Various Lengths, Constant Speed: Efficient Language Modeling with Lightning Attention 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Various Lengths, Constant Speed: Efficient Language Modeling with Lightning Attention 引用了 Hierarchically Gated Recurrent Neural Network for Sequence Modeling
- KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation 引用了 Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
引用它的顶会 Paper5
- Titans: Learning to Memorize at Test TimeAli Behrouz, Peilin Zhong, Vahab MirrokniNeurIPS 2025 · 368 次引用
- DAPE: Data-Adaptive Positional Encoding for Length ExtrapolationChuanyang Zheng, Yihang Gao, Han Shi, Minbin Huang 等NeurIPS 2024 · 42 次引用
- Various Lengths, Constant Speed: Efficient Language Modeling with Lightning AttentionZhen Qin, Weigao Sun, Dong Li, Xuyang Shen 等ICML 2024 · 26 次引用
- DAPE V2: Process Attention Score as Feature Map for Length ExtrapolationChuanyang Zheng, Yihang Gao, Han Shi, Jing Xiong 等ACL 2025 · 12 次引用
- Navigating Scaling Laws: Compute Optimality in Adaptive Model TrainingSotiris Anagnostidis, Gregor Bachmann, Imanol Schlag, Thomas HofmannICML 2024 · 2 次引用
它引用的 Paper7
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 次引用
- VATT: Transformers for Multimodal Self-Supervised Learning from Raw Video, Audio and TextHassan Akbari, Liangzhe Yuan, Rui Qian, Wei-Hong Chuang 等NeurIPS 2021 · 782 次引用
- Hierarchically Gated Recurrent Neural Network for Sequence ModelingZhen Qin, Songlin Yang, Yiran ZhongNeurIPS 2023 · 152 次引用
- KERPLE: Kernelized Relative Positional Embedding for Length ExtrapolationTa-Chung Chi, Ting-Han Fan, Peter J. Ramadge, Alexander RudnickyNeurIPS 2022 · 112 次引用
- Relative Positional Encoding for Transformers with Linear ComplexityAntoine Liutkus, Ondrej Cífka, Shih-Lun Wu, Umut Simsekli 等ICML 2021 · 63 次引用
相关 Paper
- Length Extrapolation of Transformers: A Survey from the Perspective of Positional EncodingLiang Zhao, Xiachong Feng, Xiaocheng Feng, Weihong Zhong 等EMNLP Findings 2024 · 14 次引用
- Dissecting Transformer Length Extrapolation via the Lens of Receptive Field AnalysisTa-Chung Chi, Ting-Han Fan, Alexander Rudnicky, Peter J. RamadgeACL 2023 · 4 次引用
- Functional Interpolation for Relative Positions improves Long Context TransformersShanda Li, Chong You, Guru Guruganesh, Joshua Ainslie 等ICLR 2024 · 66 次引用
- A Length-Extrapolatable TransformerYutao Sun, Li Dong, Barun Patra, Shuming Ma 等ACL 2023 · 45 次引用
- Context-aware Biases for Length ExtrapolationAli Veisi, Hamidreza Amirzadeh, Amir MansourianEMNLP 2025 · 2 次引用
