Lune

ICLR2024Top-tier venue

The Hedgehog & the Porcupine: Expressive Linear Attentions with Softmax Mimicry

Michael Zhang, Kush Bhatia, Hermann Kumbong, Christopher Ré

Abstract

Linear attentions have shown potential for improving Transformer efficiency, reducing attention's quadratic complexity to linear in sequence length. This holds exciting promise for (1) training linear Transformers from scratch, (2) "finetuned-conversion" of task-specific Transformers into linear versions that recover task performance, and (3) "pretrained-conversion" of Transformers such as large language models into linear versions finetunable on downstream tasks. However, linear attentions often underperform standard softmax attention in quality. To close this performance gap, we find prior linear attentions lack key properties of softmax attention tied to good performance: low-entropy (or "spiky") weights and dot-product monotonicity. We further observe surprisingly simple feature maps that retain these properties and match softmax performance, but are inefficient to compute in linear attention. We thus propose Hedgehog, a learnable linear attention that retains the spiky and monotonic properties of softmax attention while maintaining linear complexity. Hedgehog uses simple trainable MLPs to produce attention weights mimicking softmax attention. Experiments show Hedgehog recovers over 99% of standard Transformer quality in train-from-scratch and finetuned-conversion settings, outperforming prior linear attentions up to 6 perplexity points on WikiText-103 with causal GPTs, and up to 8.7 GLUE score points on finetuned bidirectional BERTs. Hedgehog also enables pretrained-conversion. Converting a pretrained GPT-2 into a linear attention variant achieves state-of-the-art 16.7 perplexity on WikiText-103 for 125M subquadratic decoder models. We finally turn a pretrained Llama-2 7B into a viable linear attention Llama. With low-rank adaptation, Hedgehog-Llama2 7B achieves 28.1 higher ROUGE-1 points over the base standard attention model, where prior linear attentions lead to 16.5 point drops.

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.

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

  • Emerging Properties in Self-Supervised Vision Transformers cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness cites Efficiently Modeling Long Sequences with Structured State Spaces
  • FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • Efficiently Modeling Long Sequences with Structured State Spaces cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Efficiently Modeling Long Sequences with Structured State Spaces cites An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
  • The Mamba in the Llama: Distilling and Accelerating Hybrid Models cites Efficiently Modeling Long Sequences with Structured State Spaces
  • The Mamba in the Llama: Distilling and Accelerating Hybrid Models cites Gated Linear Attention Transformers with Hardware-Efficient Training
  • The Mamba in the Llama: Distilling and Accelerating Hybrid Models cites Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
  • The Mamba in the Llama: Distilling and Accelerating Hybrid Models cites Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites The Mamba in the Llama: Distilling and Accelerating Hybrid Models
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites The Mamba in the Llama: Distilling and Accelerating Hybrid Models
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites Gated Linear Attention Transformers with Hardware-Efficient Training
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
  • Gated Slot Attention for Efficient Linear-Time Sequence Modeling cites Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models
  • Gated Linear Attention Transformers with Hardware-Efficient Training cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Gated Linear Attention Transformers with Hardware-Efficient Training cites FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Gated Linear Attention Transformers with Hardware-Efficient Training cites Efficiently Modeling Long Sequences with Structured State Spaces
  • Gated Linear Attention Transformers with Hardware-Efficient Training cites Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
  • Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Gated Linear Attention Transformers with Hardware-Efficient Training
  • Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality cites Efficiently Modeling Long Sequences with Structured State Spaces
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites Transformers are RNNs: Fast Autoregressive Transformers with Linear Attention
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites Efficiently Modeling Long Sequences with Structured State Spaces
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites Gated Linear Attention Transformers with Hardware-Efficient Training
  • Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic Models cites Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space Duality
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers42

  1. Transformers are SSMs: Generalized Models and Efficient Algorithms Through Structured State Space DualityTri Dao, Albert GuICML 2024 · 1,407 citations
  2. Gated Linear Attention Transformers with Hardware-Efficient TrainingSonglin Yang, Bailin Wang, Yikang Shen, Rameswar Panda et al.ICML 2024 · 390 citations
  3. The Mamba in the Llama: Distilling and Accelerating Hybrid ModelsJunxiong Wang, Daniele Paliotta, Avner May, Alexander M. Rush et al.NeurIPS 2024 · 146 citations
  4. Gated Slot Attention for Efficient Linear-Time Sequence ModelingYu Zhang, Songlin Yang, Rui-Jie Zhu, Yue Zhang et al.NeurIPS 2024 · 93 citations
  5. Transformers to SSMs: Distilling Quadratic Knowledge to Subquadratic ModelsAviv Bick, Kevin Y. Li, Eric P. Xing, J. Zico Kolter et al.NeurIPS 2024 · 78 citations

Builds on19

  1. An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleAlexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn et al.ICLR 2021 · 21,477 citations
  2. Emerging Properties in Self-Supervised Vision TransformersMathilde Caron, Hugo Touvron, Ishan Misra, Hervé Jégou et al.ICCV 2021 · 8,921 citations
  3. FlashAttention: Fast and Memory-Efficient Exact Attention with IO-AwarenessTri Dao, Daniel Y. Fu, Stefano Ermon, Atri Rudra et al.NeurIPS 2022 · 5,493 citations
  4. Efficiently Modeling Long Sequences with Structured State SpacesAlbert Gu, Karan Goel, Christopher RéICLR 2022 · 3,482 citations
  5. Transformers are RNNs: Fast Autoregressive Transformers with Linear AttentionAngelos Katharopoulos, Apoorv Vyas, Nikolaos Pappas, François FleuretICML 2020 · 2,665 citations

Related papers

  1. LoLCATs: On Low-Rank Linearizing of Large Language ModelsMichael Zhang, Simran Arora, Rahul Chalamala, Benjamin Frederick Spector et al.ICLR 2025
  2. Lizard: An Efficient Linearization Framework for Large Language ModelsChien Van Nguyen, Huy Huu Nguyen, Ruiyi Zhang, Hanieh Deilamsalehy et al.ACL 2026 · 8 citations
  3. MVA: Linear Attention with High-order Query-Keys Integration and Multi-level Vocabulary DecompositionNing Wang, Zekun Li, Tongxin Bai, Man Yao et al.ICML 2025
  4. LAWCAT: Efficient Distillation from Quadratic to Linear Attention with Convolution across Tokens for Long Context ModelingZeyu Liu, Souvik Kundu, Lianghao Jiang, Anni Li et al.EMNLP Findings 2025
  5. Rectifying Magnitude Neglect in Linear AttentionQihang Fan, Huaibo Huang, Yuang Ai, Ran HeICCV 2025 · 14 citations
Dusk over the sea between two cliffs drawn in fine vertical lines