KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation
Ta-Chung Chi, Ting-Han Fan, Peter J. Ramadge, Alexander Rudnicky
Abstract
Relative positional embeddings (RPE) have received considerable attention since RPEs effectively model the relative distance among tokens and enable length extrapolation. We propose KERPLE, a framework that generalizes relative position embedding for extrapolation by kernelizing positional differences. We achieve this goal using conditionally positive definite (CPD) kernels, a class of functions known for generalizing distance metrics. To maintain the inner product interpretation of self-attention, we show that a CPD kernel can be transformed into a PD kernel by adding a constant offset. This offset is implicitly absorbed in the Softmax normalization during self-attention. The diversity of CPD kernels allows us to derive various RPEs that enable length extrapolation in a principled way. Experiments demonstrate that the logarithmic variant achieves excellent extrapolation performance on three large language modeling datasets. Our implementation and pretrained checkpoints are released at https://github.com/chijames/KERPLE.git .
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.
42 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
- Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention cites ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
- Rope to Nope and Back Again: A New Hybrid Attention Strategy cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Deberta: decoding-Enhanced Bert with Disentangled Attention cites ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
- DAPE: Data-Adaptive Positional Encoding for Length Extrapolation cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- DAPE: Data-Adaptive Positional Encoding for Length Extrapolation cites Functional Interpolation for Relative Positions improves Long Context Transformers
- DAPE: Data-Adaptive Positional Encoding for Length Extrapolation cites PEGASUS: Pre-training with Extracted Gap-sentences for Abstractive Summarization
- Functional Interpolation for Relative Positions improves Long Context Transformers cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Functional Interpolation for Relative Positions improves Long Context Transformers cites PEGASUS: Pre-training with Extracted Gap-sentences for Abstractive Summarization
- Transformers Can Do Arithmetic with the Right Embeddings cites ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
- Transformers Can Do Arithmetic with the Right Embeddings cites Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation
- Transformers Can Do Arithmetic with the Right Embeddings cites Functional Interpolation for Relative Positions improves Long Context Transformers
Cited by top-tier papers42
- Transformers Can Do Arithmetic with the Right EmbeddingsSean McLeish, Arpit Bansal, Alex Stein, Neel Jain et al.NeurIPS 2024 · 94 citations
- Functional Interpolation for Relative Positions improves Long Context TransformersShanda Li, Chong You, Guru Guruganesh, Joshua Ainslie et al.ICLR 2024 · 66 citations
- Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In ContextXiang Cheng, Yuxin Chen, Suvrit SraICML 2024 · 64 citations
- Rope to Nope and Back Again: A New Hybrid Attention StrategyBowen Yang, Bharat Venkitesh, Dwaraknath Gnaneshwar, Hangyu Lin et al.NeurIPS 2025 · 51 citations
- DAPE: Data-Adaptive Positional Encoding for Length ExtrapolationChuanyang Zheng, Yihang Gao, Han Shi, Minbin Huang et al.NeurIPS 2024 · 42 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
- Deberta: decoding-Enhanced Bert with Disentangled AttentionPengcheng He, Xiaodong Liu, Jianfeng Gao, Weizhu ChenICLR 2021 · 3,729 citations
- Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations
- PEGASUS: Pre-training with Extracted Gap-sentences for Abstractive SummarizationJingqing Zhang, Yao Zhao, Mohammad Saleh, Peter J. LiuICML 2020 · 2,453 citations
- Train Short, Test Long: Attention with Linear Biases Enables Input Length ExtrapolationOfir Press, Noah A. Smith, Mike LewisICLR 2022 · 1,168 citations
Related papers
- Exploring Transformer ExtrapolationZhen Qin, Yiran Zhong, Hui DengAAAI 2024 · 12 citations
- Context-aware Biases for Length ExtrapolationAli Veisi, Hamidreza Amirzadeh, Amir MansourianEMNLP 2025 · 2 citations
- On the token distance modeling ability of higher RoPE attention dimensionXiangyu Hong, Che Jiang, Biqing Qi, Fandong Meng et al.EMNLP Findings 2024 · 2 citations
- 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
- A Length-Extrapolatable TransformerYutao Sun, Li Dong, Barun Patra, Shuming Ma et al.ACL 2023 · 45 citations
