atlas

Research map / Architectures and efficiency / Attention and transformers

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

ICLR 2024 · Architectures and efficiency › Attention and transformers · approach: Linear attention approximations · 3 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Proposes Hedgehog, a learnable linear attention whose per-head single-layer exponential MLP feature maps are trained via cross-entropy distillation to mimic softmax attention weights, recovering most softmax quality across training-from-scratch, finetuned-conversion, and pretrained-conversion settings.

Problem

Linear attentions usually underperform softmax attention in quality; the paper asks which properties (low-entropy spikiness and dot-product monotonicity) are missing and how to get them while keeping linear complexity.

Approach

Replace fixed linear-attention feature maps with trainable single-layer MLPs followed by element-wise exp (with a negation mapping), trained by cross-entropy against softmax attention weights, so the linear attention mimics softmax spikiness and monotonicity at O(nd^2) cost.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
replace standard attention with Hedgehog linear attention125M decoder-only Transformer · WikiText-103perplexity: 25.6 -> 20.8Helped
replace standard attention with Hedgehog linear attention125M GPT-2 · WikiText-103perplexity: 19.4 -> 16.7Helped
convert Llama-2 7B to Hedgehog attention and finetune with LoRALlama-2 7B · SAMSumROUGE-1: 51.1 -> 47.4; 2.8 -> 47.4Mixed
replace the Hedgehog feature map with the T2R feature map while retaining attention distillation (ablation)BERT-base-uncased conversion · GLUEperformance recovery (%): 99.3 -> 93.5Hurt
replace the Hedgehog feature map with the T2R feature map while retaining attention distillation (ablation)ViT-B/16 conversion · ImageNet-1Ktop-1 accuracy (%): 79.5 -> 77.0Hurt
use the T2R feature map with attention distillation instead of Hedgehog's exponential MLP (ablation)BERT-base-uncased · BERT-FT CoLAMatthew's correlation: 59.2 -> 56.9Hurt
remove training from the Hedgehog feature maps (ablation)BERT-base-uncased attention matching · GLUE attention weightsKL divergence: 0.345 -> 0.851Hurt
replace the Hedgehog feature map with the T2R feature map (ablation)BERT-base-uncased attention matching · GLUE attention weightsKL divergence: 0.345 -> 0.613Hurt
use a degree-2 Taylor exponential feature map instead of Hedgehog (ablation)BERT-FT CoLA · BERT-FT CoLAMatthew's correlation: 59.2 -> 58.4Hurt
use a degree-2 Taylor exponential feature map instead of Hedgehog (ablation)Transformer trained from scratch · Associative Recallaccuracy: 100.0 -> 100.0No clear effect
increase the temperature of the exponential feature map from t = 1 to t = 2 (ablation)linear attention model trained from scratch · Associative RecallaccuracyHelped
use the exponential map with t = 2 rather than prior linear attention maps (ablation)linear attention model trained from scratch · Associative Recallaccuracy: 17.0 -> 100.0Helped

Surprising findings

Limitations

Experimental setup

Datasets: CoLA GLUE WikiText-103 Long Range Arena ImageNet-1K SAMSum associative recall (synthetic)

Benchmarks: Long Range Arena WikiText-103 GLUE ImageNet-1K SAMSum associative recall

Metrics: accuracy perplexity Matthew's correlation ROUGE KL divergence wall-clock time memory

Baselines: 1 + ELU ReLU Performer cosFormer T2R T2R-HH H3 Hyena AFT Reformer Linformer BigBird

Builds on: Transformer-to-RNN (T2R) linear attention kernel feature maps FlashAttention LoRA

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy