Stable, Fast and Accurate: Kernelized Attention with Relative Positional Encoding
Not on the map. Why?
Abstract (arXiv)
The attention module, which is a crucial component in Transformer, cannot scale efficiently to long sequences due to its quadratic complexity. Many works focus on approximating the dot-then-exponentiate softmax function in the original attention, leading to sub-quadratic or even linear-complexity Transformer architectures. However, we show that these methods cannot be applied to more powerful attention modules that go beyond the dot-then-exponentiate style, e.g., Transformers with relative positional encoding (RPE). Since in many state-of-the-art models, relative positional encoding is used as default, designing efficient Transformers that can incorporate RPE is appealing. In this paper, we propose a novel way to accelerate attention calculation for Transformers with RPE on top of the kernelized attention. Based upon the observation that relative positional encoding forms a Toeplitz matrix, we mathematically show that kernelized attention with RPE can be calculated efficiently using Fast Fourier Transform (FFT). With FFT, our method achieves O(nlog n) time complexity. Interestingly, we further demonstrate that properly using relative positional encoding can mitigate the training instability problem of vanilla kernelized attention. On a wide range of tasks, we empirically show that our models can be trained from scratch without any optimization issues. The learned model performs better than many efficient Transformer variants and is faster than standard Transformer in the long-sequence regime.
Key facts. Cited by 51 papers in the map (data through 14 Oct 2026). Builds on 43 of its 53 references that are in the map. First posted on arXiv 23 Jun 2021.
Builds on
43 of 53 references.
References · 43
- 2017Attention Is All You Needcited by 60,361
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,399
- 2014Adam: A Method for Stochastic Optimizationcited by 37,240
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,305
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,599
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,372
- 2021Swin Transformer: Hierarchical Vision Transformer using Shifted Windowscited by 12,139
- 2020End-to-End Object Detection with Transformerscited by 7,414
- 2015Rethinking the Inception Architecture for Computer Visioncited by 5,475
- 2018GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understandingcited by 4,899
- 2020Training data-efficient image transformers & distillation through attentioncited by 4,586
- 2015Neural Machine Translation of Rare Words with Subword Unitscited by 2,918
31 more
- 2019XLNet: Generalized Autoregressive Pretraining for Language Understandingcited by 2,811
- 2020DeBERTa: Decoding-enhanced BERT with Disentangled Attentioncited by 2,181
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 2,022
- 2018SentencePiece: A simple and language independent subword tokenizer and detokenizer for Neural Text Processingcited by 1,989
- 2020Conformer: Convolution-augmented Transformer for Speech Recognitioncited by 1,863
- 2017Decoupled Weight Decay Regularizationcited by 1,831
- 2020Reformer: The Efficient Transformercited by 1,668
- 2020Rethinking Attention with Performerscited by 1,601
- 2019Generating Long Sequences with Sparse Transformerscited by 1,546
- 2019fairseq: A Fast, Extensible Toolkit for Sequence Modelingcited by 1,488
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,474
- 2018Self-Attention with Relative Position Representationscited by 1,120
- 2015Aligning Books and Movies: Towards Story-like Visual Explanations by Watching Movies and Reading Bookscited by 1,043
- 2019What Does BERT Look At? An Analysis of BERT's Attentioncited by 1,003
- 2020Efficient Transformers: A Surveycited by 790
- 2018Image Transformercited by 772
- 2021Maximum Likelihood Training of Score-Based Diffusion Modelscited by 672
- 2021Nystr"omformer: A Nystr"om-Based Algorithm for Approximating Self-Attentioncited by 471
- 2017A Downsampled Variant of ImageNet as an Alternative to the CIFAR datasetscited by 377
- 2019Axial Attention in Multidimensional Transformerscited by 358
- 2021Random Feature Attentioncited by 354
- 2018A Simple Method for Commonsense Reasoningcited by 223
- 2019Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernelcited by 213
- 2020UniLMv2: Pseudo-Masked Language Models for Unified Language Model Pre-Trainingcited by 204
- 2020Rethinking Positional Encoding in Language Pre-trainingcited by 197
- 2019Blockwise Self-Attention for Long Document Understandingcited by 159
- 2020Fast Transformers with Clustered Attentioncited by 123
- 2021Finetuning Pretrained Transformers into RNNscited by 96
- 2021Do Transformer Modifications Transfer Across Implementations and Applications?cited by 87
- 2021Densely connected normalizing flowscited by 49
- 2020SMYRF: Efficient Attention using Asymmetric Clusteringcited by 43
Built on by
Citing papers per year: 2021: 5; 2022: 12; 2023: 10; 2024: 10; 2025: 6; 2026: 8.
51 papers.
Sort:
By area:
- 2022Hungry Hungry Hippos: Towards Language Modeling with State Space Modelscited by 499
- 2022What Makes Convolutional Models Great on Long Sequence Modeling?cited by 87
- 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 86
- 2022Flowformer: Linearizing Transformers with Conservation Flowscited by 69
- 2024RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrievalcited by 64
- 2022Your Transformer May Not be as Powerful as You Expectcited by 55
- 2021From block-Toeplitz matrices to differential equations on graphs: towards a general theory for scalable masked Transformerscited by 38
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolationcited by 31
- 2022Attention Mechanism in Neural Networks: Where it Comes and Where it Goescited by 29
- 2021Hybrid Random Featurescited by 25
- 2023Efficient Attention via Control Variatescited by 23
- 2023ESSAformer: Efficient Transformer for Hyperspectral Image Super-resolutioncited by 23
38 more
- 2024Do Efficient Transformers Really Save Computation?cited by 20
- 2025Learning the RoPEs: Better 2D and 3D Position Encodings with STRINGcited by 19
- 2021Can Vision Transformers Perform Convolution?cited by 18
- 2021On Learning the Transformer Kernelcited by 15
- 2024Locality-Sensitive Hashing-Based Efficient Point Transformer with Applications in High-Energy Physicscited by 12
- 2022A Quality Index Metric and Method for Online Self-Assessment of Autonomous Vehicles Sensory Perceptioncited by 10
- 2023Learning a Fourier Transform for Linear Relative Positional Encodings in Transformerscited by 10
- 2024Let the Code LLM Edit Itself When You Edit the Codecited by 10
- 2024DAPE V2: Process Attention Score as Feature Map for Length Extrapolationcited by 10
- 2023Simplex Random Featurescited by 9
- 2023Mnemosyne: Learning to Train Transformers with Transformerscited by 9
- 2023Monotonic Location Attention for Length Generalizationcited by 9
- 2023Single Cells Are Spatial Tokens: Transformers for Spatial Transcriptomic Data Imputationcited by 7
- 2024Linear Transformer Topological Masking with Graph Random Featurescited by 7
- 2025Statistical Advantage of Softmax Attention: Insights from Single-Location Regressioncited by 7
- 2022Improving Sample Efficiency of Value Based Models Using Attention and Vision Transformerscited by 4
- 2022Self-explaining Hierarchical Model for Intraoperative Time Seriescited by 4
- 2022DBA: Efficient Transformer with Dynamic Bilinear Low-Rank Attentioncited by 4
- 2023MEGA: Multimodal Alignment Aggregation and Distillation For Cinematic Video Segmentationcited by 4
- 2025Linear Attention for Efficient Bidirectional Sequence Modelingcited by 4
- 2025LOTFormer: Doubly-Stochastic Linear Attention via Low-Rank Optimal Transportcited by 4
- 2024Fast Tree-Field Integrators: From Low Displacement Rank to Topological Transformerscited by 3
- 2021Ripple Attention for Visual Perception with Sub-quadratic Complexitycited by 2
- 2024Building on Efficient Foundations: Effectively Training LLMs with Structured Feedforward Layerscited by 2
- 2025Degrees of Freedom for Linear Attention: Distilling Softmax Attention with Optimal Feature Efficiencycited by 2
- 2026NeuroGame Transformer: Gibbs-Inspired Attention Driven by Game Theory and Statistical Physicscited by 2
- 2022FastRPB: a Scalable Relative Positional Encoding for Long Sequence Taskscited by 1
- 2022Lightweight Structure-Aware Attention for Visual Understandingcited by 1
- 2024In-context Learning for Mixture of Linear Regressions: Existence, Generalization and Training Dynamicscited by 1
- 2025From Small to Large: Generalization Bounds for Transformers on Variable-Size Inputscited by 1
- 2026RelFlexformer: Efficient Attention 3D-Transformers for Integrable Relative Positional Encodingscited by 1
- 2026SMat-Attention: Structured Long-Context Sequence Modelingcited by 1
- 2023TAP: The Attention Patch for Cross-Modal Knowledge Transfer from Unlabeled Modalitycited by 0
- 2023SKI to go Faster: Accelerating Toeplitz Neural Networks via Asymmetric Kernelscited by 0
- 2026Chimera: Neuro-Symbolic Attention Primitives for Trustworthy Dataplane Intelligencecited by 0
- 2026Projection-Free Transformers via Gaussian Kernel Attentioncited by 0
- 2026Improving Adversarial Robustness of Attribution via Implicit Regularizationcited by 0
- 2026A Coulomb Particle Model for Learning Kernel Attention in Transformerscited by 0
50 most cited of 51 All 51 (JSON)
- 2026SMat-Attention: Structured Long-Context Sequence Modeling28 Sep 2026
- 2026ClockRoPE: Random Fourier Rotations for Temporal Routine Modeling29 Jul 2026
- 2026A Coulomb Particle Model for Learning Kernel Attention in Transformers26 Jul 2026
- 2026Improving Adversarial Robustness of Attribution via Implicit Regularization28 May 2026
- 2026RelFlexformer: Efficient Attention 3D-Transformers for Integrable Relative Positional Encodings11 May 2026
- 2026Projection-Free Transformers via Gaussian Kernel Attention4 May 2026
- 2026NeuroGame Transformer: Gibbs-Inspired Attention Driven by Game Theory and Statistical Physics19 Mar 2026
- 2026Chimera: Neuro-Symbolic Attention Primitives for Trustworthy Dataplane Intelligence13 Feb 2026
- 2025From Small to Large: Generalization Bounds for Transformers on Variable-Size Inputs14 Dec 2025
- 2025LOTFormer: Doubly-Stochastic Linear Attention via Low-Rank Optimal Transport27 Sep 2025
- 2025Statistical Advantage of Softmax Attention: Insights from Single-Location Regression26 Sep 2025
- 2025Degrees of Freedom for Linear Attention: Distilling Softmax Attention with Optimal Feature Efficiency4 Jul 2025
38 more
- 2025Linear Attention for Efficient Bidirectional Sequence Modeling22 Feb 2025
- 2025Learning the RoPEs: Better 2D and 3D Position Encodings with STRING4 Feb 2025
- 2024In-context Learning for Mixture of Linear Regressions: Existence, Generalization and Training Dynamics18 Oct 2024
- 2024DAPE V2: Process Attention Score as Feature Map for Length Extrapolation7 Oct 2024
- 2024Linear Transformer Topological Masking with Graph Random Features4 Oct 2024
- 2024Let the Code LLM Edit Itself When You Edit the Code3 Jul 2024
- 2024Building on Efficient Foundations: Effectively Training LLMs with Structured Feedforward Layers24 Jun 2024
- 2024Fast Tree-Field Integrators: From Low Displacement Rank to Topological Transformers22 Jun 2024
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolation23 May 2024
- 2024RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrieval28 Feb 2024
- 2024Do Efficient Transformers Really Save Computation?21 Feb 2024
- 2024Locality-Sensitive Hashing-Based Efficient Point Transformer with Applications in High-Energy Physics19 Feb 2024
- 2023MEGA: Multimodal Alignment Aggregation and Distillation For Cinematic Video Segmentation22 Aug 2023
- 2023ESSAformer: Efficient Transformer for Hyperspectral Image Super-resolution26 Jul 2023
- 2023Monotonic Location Attention for Length Generalization31 May 2023
- 2023SKI to go Faster: Accelerating Toeplitz Neural Networks via Asymmetric Kernels15 May 2023
- 2023Efficient Attention via Control Variates9 Feb 2023
- 2023Single Cells Are Spatial Tokens: Transformers for Spatial Transcriptomic Data Imputation6 Feb 2023
- 2023TAP: The Attention Patch for Cross-Modal Knowledge Transfer from Unlabeled Modality4 Feb 2023
- 2023Learning a Fourier Transform for Linear Relative Positional Encodings in Transformers3 Feb 2023
- 2023Mnemosyne: Learning to Train Transformers with Transformers2 Feb 2023
- 2023Simplex Random Features31 Jan 2023
- 2022Hungry Hungry Hippos: Towards Language Modeling with State Space Models28 Dec 2022
- 2022Lightweight Structure-Aware Attention for Visual Understanding29 Nov 2022
- 2022DBA: Efficient Transformer with Dynamic Bilinear Low-Rank Attention24 Nov 2022
- 2022What Makes Convolutional Models Great on Long Sequence Modeling?17 Oct 2022
- 2022Self-explaining Hierarchical Model for Intraoperative Time Series10 Oct 2022
- 2022Your Transformer May Not be as Powerful as You Expect26 May 2022
- 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolation20 May 2022
- 2022Attention Mechanism in Neural Networks: Where it Comes and Where it Goes27 Apr 2022
- 2022A Quality Index Metric and Method for Online Self-Assessment of Autonomous Vehicles Sensory Perception4 Mar 2022
- 2022FastRPB: a Scalable Relative Positional Encoding for Long Sequence Tasks23 Feb 2022
- 2022Flowformer: Linearizing Transformers with Conservation Flows13 Feb 2022
- 2022Improving Sample Efficiency of Value Based Models Using Attention and Vision Transformers1 Feb 2022
- 2021Can Vision Transformers Perform Convolution?2 Nov 2021
- 2021On Learning the Transformer Kernel15 Oct 2021
- 2021Hybrid Random Features8 Oct 2021
- 2021Ripple Attention for Visual Perception with Sub-quadratic Complexity6 Oct 2021
50 newest of 51 All 51 (JSON)
- 2024Let the Code LLM Edit Itself When You Edit the Codecited by 10
- 2024Let the Code LLM Edit Itself When You Edit the Code3 Jul 2024
- 2022Hungry Hungry Hippos: Towards Language Modeling with State Space Modelscited by 499
- 2022What Makes Convolutional Models Great on Long Sequence Modeling?cited by 87
- 2022KERPLE: Kernelized Relative Positional Embedding for Length Extrapolationcited by 86
- 2022Flowformer: Linearizing Transformers with Conservation Flowscited by 69
- 2024RNNs are not Transformers (Yet): The Key Bottleneck on In-context Retrievalcited by 64
- 2022Your Transformer May Not be as Powerful as You Expectcited by 55
- 2021From block-Toeplitz matrices to differential equations on graphs: towards a general theory for scalable masked Transformerscited by 38
- 2024DAPE: Data-Adaptive Positional Encoding for Length Extrapolationcited by 31
- 2022Attention Mechanism in Neural Networks: Where it Comes and Where it Goescited by 29
- 2021Hybrid Random Featurescited by 25
- 2023Efficient Attention via Control Variatescited by 23
- 2023ESSAformer: Efficient Transformer for Hyperspectral Image Super-resolutioncited by 23
12 most cited of 50 All 50 (JSON)
- 2026SMat-Attention: Structured Long-Context Sequence Modeling28 Sep 2026
- 2026ClockRoPE: Random Fourier Rotations for Temporal Routine Modeling29 Jul 2026
- 2026A Coulomb Particle Model for Learning Kernel Attention in Transformers26 Jul 2026
- 2026Improving Adversarial Robustness of Attribution via Implicit Regularization28 May 2026
- 2026RelFlexformer: Efficient Attention 3D-Transformers for Integrable Relative Positional Encodings11 May 2026
- 2026Projection-Free Transformers via Gaussian Kernel Attention4 May 2026
- 2026NeuroGame Transformer: Gibbs-Inspired Attention Driven by Game Theory and Statistical Physics19 Mar 2026
- 2026Chimera: Neuro-Symbolic Attention Primitives for Trustworthy Dataplane Intelligence13 Feb 2026
- 2025From Small to Large: Generalization Bounds for Transformers on Variable-Size Inputs14 Dec 2025
- 2025LOTFormer: Doubly-Stochastic Linear Attention via Low-Rank Optimal Transport27 Sep 2025
- 2025Statistical Advantage of Softmax Attention: Insights from Single-Location Regression26 Sep 2025
- 2025Degrees of Freedom for Linear Attention: Distilling Softmax Attention with Optimal Feature Efficiency4 Jul 2025
12 newest of 50 All 50 (JSON)