Lune

ICML2021Top-tier venue

You Only Sample (Almost) Once: Linear Cost Self-Attention Via Bernoulli Sampling

Zhanpeng Zeng, Yunyang Xiong, Sathya N. Ravi, Shailesh Acharya, Glenn Moo Fung, Vikas Singh

Abstract

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 .

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.

14 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

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
  • Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention cites Reformer: The Efficient Transformer
  • Long Range Arena : A Benchmark for Efficient Transformers cites Reformer: The Efficient Transformer
  • Graph Convolutions Enrich the Self-Attention in Transformers! cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Graph Convolutions Enrich the Self-Attention in Transformers! cites ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
  • Multi Resolution Analysis (MRA) for Approximate Self-Attention cites Long Range Arena : A Benchmark for Efficient Transformers
  • Multi Resolution Analysis (MRA) for Approximate Self-Attention cites Nyströmformer: A Nyström-based Algorithm for Approximating Self-Attention
  • Multi Resolution Analysis (MRA) for Approximate Self-Attention cites Reformer: The Efficient Transformer
  • Nyströmformer: A Nyström-based Algorithm for Approximating Self-Attention cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Nyströmformer: A Nyström-based Algorithm for Approximating Self-Attention cites Long Range Arena : A Benchmark for Efficient Transformers
  • Nyströmformer: A Nyström-based Algorithm for Approximating Self-Attention cites ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
  • Nyströmformer: A Nyström-based Algorithm for Approximating Self-Attention cites Reformer: The Efficient Transformer
  • Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representation cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representation cites Long Range Arena : A Benchmark for Efficient Transformers
  • Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representation cites Nyströmformer: A Nyström-based Algorithm for Approximating Self-Attention
  • Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representation cites Reformer: The Efficient Transformer
  • Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal Representation cites Flowformer: Linearizing Transformers with Conservation Flows
  • Flowformer: Linearizing Transformers with Conservation Flows cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Flowformer: Linearizing Transformers with Conservation Flows cites Long Range Arena : A Benchmark for Efficient Transformers
  • Flowformer: Linearizing Transformers with Conservation Flows cites Nyströmformer: A Nyström-based Algorithm for Approximating Self-Attention
  • Flowformer: Linearizing Transformers with Conservation Flows cites Reformer: The Efficient Transformer
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers14

  1. Flowformer: Linearizing Transformers with Conservation FlowsHaixu Wu, Jialong Wu, Jiehui Xu, Jianmin Wang et al.ICML 2022 · 130 citations
  2. Deep Unlearning via Randomized Conditionally Independent HessiansRonak Mehta, Sourav Pal, Vikas Singh, Sathya N. RaviCVPR 2022 · 50 citations
  3. Primal-Attention: Self-attention through Asymmetric Kernel SVD in Primal RepresentationYingyi Chen, Qinghua Tao, Francesco Tonin, Johan A. K. SuykensNeurIPS 2023 · 42 citations
  4. Graph Convolutions Enrich the Self-Attention in Transformers!Jeongwhan Choi, Hyowon Wi, Jayoung Kim, Yehjin Shin et al.NeurIPS 2024 · 24 citations
  5. Multi Resolution Analysis (MRA) for Approximate Self-AttentionZhanpeng Zeng, Sourav Pal, Jeffery Kline, Glenn Moo Fung et al.ICML 2022 · 14 citations

Builds on7

  1. 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
  2. Reformer: The Efficient TransformerNikita Kitaev, Lukasz Kaiser, Anselm LevskayaICLR 2020 · 2,878 citations
  3. Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations
  4. Long Range Arena : A Benchmark for Efficient TransformersYi Tay, Mostafa Dehghani, Samira Abnar, Yikang Shen et al.ICLR 2021 · 881 citations
  5. Nyströmformer: A Nyström-based Algorithm for Approximating Self-AttentionYunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan et al.AAAI 2021 · 675 citations

Related papers

  1. Sparse Attention with Learning to HashZhiqing Sun, Yiming Yang, Shinjae YooICLR 2022 · 21 citations
  2. RACE Attention: A Strictly Linear-Time Attention for Long-Sequence TrainingSahil Joshi, Agniva Chowdhury, Amar Kanakamedala, Ekam Singh et al.ICLR 2026 · 2 citations
  3. Linear-Time Self Attention with Codeword Histogram for Efficient RecommendationYongji Wu, Defu Lian, Neil Zhenqiang Gong, Lu Yin et al.WWW 2021 · 18 citations
  4. Fast Attention Over Long Sequences With Dynamic Sparse Flash AttentionMatteo Pagliardini, Daniele Paliotta, Martin Jaggi, François FleuretNeurIPS 2023 · 26 citations
  5. SMYRF - Efficient Attention using Asymmetric ClusteringGiannis Daras, Nikita Kitaev, Augustus Odena, Alexandros G. DimakisNeurIPS 2020 · 54 citations
Dusk over the sea between two cliffs drawn in fine vertical lines