You Only Sample (Almost) Once: Linear Cost Self-Attention Via Bernoulli Sampling
Not on the map. Why?
Abstract (arXiv)
Transformer-based models are widely used in natural language processing (NLP). Central to the transformer model is the self-attention mechanism, which captures the interactions of token pairs in the input sequences and depends quadratically on the sequence length. Training such models on longer sequences is expensive. In this paper, we show that a Bernoulli sampling attention mechanism based on Locality Sensitive Hashing (LSH), decreases the quadratic complexity of such models to linear. We bypass the quadratic cost by considering self-attention as a sum of individual tokens associated with Bernoulli random variables that can, in principle, be sampled at once by a single hash (although in practice, this number may be a small constant). This leads to an efficient sampling scheme to estimate self-attention which relies on specific modifications of LSH (to enable deployment on GPU architectures). We evaluate our algorithm on the GLUE benchmark with standard 512 sequence length where we see favorable performance relative to a standard pretrained Transformer. On the Long Range Arena (LRA) benchmark, for evaluating performance on long sequences, our method achieves results consistent with softmax self-attention but with sizable speed-ups and memory savings and often outperforms other efficient self-attention methods. Our code is available at https://github.com/mlpen/YOSO
Key facts. Cited by 17 papers in the map (data through 7 Oct 2026). Builds on 30 of its 46 references that are in the map. First posted on arXiv 18 Nov 2021.
Builds on
30 of 46 references.
References · 30
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2019RoBERTa: A Robustly Optimized BERT Pretraining Approachcited by 13,266
- 2018GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understandingcited by 4,854
- 2016SQuAD: 100,000+ Questions for Machine Comprehension of Textcited by 4,115
- 2020Longformer: The Long-Document Transformercited by 3,362
- 2019XLNet: Generalized Autoregressive Pretraining for Language Understandingcited by 2,801
- 2019ALBERT: A Lite BERT for Self-supervised Learning of Language Representationscited by 2,772
- 2017A Broad-Coverage Challenge Corpus for Sentence Understanding through Inferencecited by 2,665
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
- 2020Big Bird: Transformers for Longer Sequencescited by 1,673
18 more
- 2020Reformer: The Efficient Transformercited by 1,658
- 2020Rethinking Attention with Performerscited by 1,584
- 2019Generating Long Sequences with Sparse Transformerscited by 1,523
- 2020Linformer: Self-Attention with Linear Complexitycited by 1,462
- 2015Aligning Books and Movies: Towards Story-like Visual Explanations by Watching Movies and Reading Bookscited by 1,041
- 2020Long Range Arena: A Benchmark for Efficient Transformerscited by 696
- 2019Defending Against Neural Fake Newscited by 553
- 2021Nystr"omformer: A Nystr"om-Based Algorithm for Approximating Self-Attentioncited by 468
- 2021Random Feature Attentioncited by 350
- 2018A Simple Method for Commonsense Reasoningcited by 223
- 2017Constructing Datasets for Multi-hop Reading Comprehension Across Documentscited by 190
- 2018ListOps: A Diagnostic Dataset for Latent Tree Learningcited by 128
- 2015Practical and Optimal LSH for Angular Distancecited by 105
- 2018Learning long-range spatial dependencies with horizontal gated-recurrent unitscited by 98
- 2020Masked Language Modeling for Proteins via Linearly Scalable Long-Context Transformerscited by 49
- 2018Hashing-Based-Estimators for Kernel Density in High Dimensionscited by 31
- 2014On Symmetric and Asymmetric LSHs for Inner Product Searchcited by 23
- 2017A New Unbiased and Efficient Class of LSH-Based Samplers and Estimators for Partition Function Computation in Log-Linear Modelscited by 15
Built on by
Citing papers per year: 2022: 7; 2023: 4; 2024: 4; 2025: 2.
17 papers.
Sort:
By area:
- 2022Deep Unlearning via Randomized Conditionally Independent Hessianscited by 83
- 2022Flowformer: Linearizing Transformers with Conservation Flowscited by 69
- 2022Attention Mechanism in Neural Networks: Where it Comes and Where it Goescited by 29
- 2023Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representationcited by 28
- 2022Sampling Is All You Need on Modeling Long-Term User Behaviors for CTR Predictioncited by 24
- 2022Multi Resolution Analysis (MRA) for Approximate Self-Attentioncited by 11
- 2023Graph Convolutions Enrich the Self-Attention in Transformers!cited by 11
- 2022CAB: Comprehensive Attention Benchmarking on Long Sequence Modelingcited by 10
- 2024When Linear Attention Meets Autoregressive Decoding: Towards More Effective and Efficient Linearized Large Language Modelscited by 9
- 2024LookupFFN: Making Transformers Compute-lite for CPU inferencecited by 8
- 2023Vcc: Scaling Transformers to 128K Tokens or More by Prioritizing Important Tokenscited by 6
- 2023From Characters to Words: Hierarchical Pre-trained Language Model for Open-vocabulary Language Understandingcited by 4
5 more
- 2024MemoryFormer: Minimize Transformer Computation by Removing Fully-Connected Layerscited by 4
- 2025RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contextscited by 4
- 2022DBA: Efficient Transformer with Dynamic Bilinear Low-Rank Attentioncited by 3
- 2024Computation and Parameter Efficient Multi-Modal Fusion Transformer for Cued Speech Recognitioncited by 3
- 2025Learning Advanced Self-Attention for Linear Transformers in the Singular Value Domaincited by 3
- 2025RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contexts5 Oct 2025
- 2025Learning Advanced Self-Attention for Linear Transformers in the Singular Value Domain13 May 2025
- 2024MemoryFormer: Minimize Transformer Computation by Removing Fully-Connected Layers20 Nov 2024
- 2024When Linear Attention Meets Autoregressive Decoding: Towards More Effective and Efficient Linearized Large Language Models11 Jun 2024
- 2024LookupFFN: Making Transformers Compute-lite for CPU inference12 Mar 2024
- 2024Computation and Parameter Efficient Multi-Modal Fusion Transformer for Cued Speech Recognition31 Jan 2024
- 2023Graph Convolutions Enrich the Self-Attention in Transformers!7 Dec 2023
- 2023Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representation31 May 2023
- 2023From Characters to Words: Hierarchical Pre-trained Language Model for Open-vocabulary Language Understanding23 May 2023
- 2023Vcc: Scaling Transformers to 128K Tokens or More by Prioritizing Important Tokens7 May 2023
- 2022DBA: Efficient Transformer with Dynamic Bilinear Low-Rank Attention24 Nov 2022
- 2022CAB: Comprehensive Attention Benchmarking on Long Sequence Modeling14 Oct 2022
5 more
- 2022Multi Resolution Analysis (MRA) for Approximate Self-Attention21 Jul 2022
- 2022Sampling Is All You Need on Modeling Long-Term User Behaviors for CTR Prediction20 May 2022
- 2022Attention Mechanism in Neural Networks: Where it Comes and Where it Goes27 Apr 2022
- 2022Deep Unlearning via Randomized Conditionally Independent Hessians15 Apr 2022
- 2022Flowformer: Linearizing Transformers with Conservation Flows13 Feb 2022
- 2022Flowformer: Linearizing Transformers with Conservation Flowscited by 69
- 2022Attention Mechanism in Neural Networks: Where it Comes and Where it Goescited by 29
- 2023Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representationcited by 28
- 2022Sampling Is All You Need on Modeling Long-Term User Behaviors for CTR Predictioncited by 24
- 2022Multi Resolution Analysis (MRA) for Approximate Self-Attentioncited by 11
- 2023Graph Convolutions Enrich the Self-Attention in Transformers!cited by 11
- 2022CAB: Comprehensive Attention Benchmarking on Long Sequence Modelingcited by 10
- 2024LookupFFN: Making Transformers Compute-lite for CPU inferencecited by 8
- 2023Vcc: Scaling Transformers to 128K Tokens or More by Prioritizing Important Tokenscited by 6
- 2023From Characters to Words: Hierarchical Pre-trained Language Model for Open-vocabulary Language Understandingcited by 4
- 2024MemoryFormer: Minimize Transformer Computation by Removing Fully-Connected Layerscited by 4
- 2025RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contextscited by 4
12 most cited of 15 All 15 (JSON)
- 2025RACE Attention: A Strictly Linear-Time Attention Layer for Training on Outrageously Large Contexts5 Oct 2025
- 2025Learning Advanced Self-Attention for Linear Transformers in the Singular Value Domain13 May 2025
- 2024MemoryFormer: Minimize Transformer Computation by Removing Fully-Connected Layers20 Nov 2024
- 2024LookupFFN: Making Transformers Compute-lite for CPU inference12 Mar 2024
- 2024Computation and Parameter Efficient Multi-Modal Fusion Transformer for Cued Speech Recognition31 Jan 2024
- 2023Graph Convolutions Enrich the Self-Attention in Transformers!7 Dec 2023
- 2023Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representation31 May 2023
- 2023From Characters to Words: Hierarchical Pre-trained Language Model for Open-vocabulary Language Understanding23 May 2023
- 2023Vcc: Scaling Transformers to 128K Tokens or More by Prioritizing Important Tokens7 May 2023
- 2022DBA: Efficient Transformer with Dynamic Bilinear Low-Rank Attention24 Nov 2022
- 2022CAB: Comprehensive Attention Benchmarking on Long Sequence Modeling14 Oct 2022
- 2022Multi Resolution Analysis (MRA) for Approximate Self-Attention21 Jul 2022
12 newest of 15 All 15 (JSON)