You Need Better Attention Priors
Elon Litman, Gabe Guo
TL;DR
The paper reframes self-attention as a KL-regularized transport problem from Entropic Optimal Transport, highlighting that standard attention uses an implicit uniform prior. It introduces GOAT, a trainable-prior attention mechanism that preserves SDPA compatibility by decomposing queries/keys into content and positional subspaces and incorporating a learned log-prior consisting of a spectral relative-position component and an explicit key-only sink. Theoretical results show that priors determine sinks and stability, with finite-trigonometric priors arising under SDPA-compatibility and translation equivariance, and that sinks are optimal transport defaults in low-signal regimes. Empirically, GOAT improves language modeling perplexity and long-context retrieval, reduces memory, and extends zero-shot extrapolation in vision tasks, demonstrating broad applicability across domains including biology and computer vision.
Abstract
We generalize the attention mechanism by viewing it through the lens of Entropic Optimal Transport, revealing that standard attention corresponds to a transport problem regularized by an implicit uniform prior. We introduce Generalized Optimal transport Attention with Trainable priors (GOAT), a new attention mechanism that replaces this naive assumption with a learnable, continuous prior. This prior maintains full compatibility with optimized kernels such as FlashAttention. GOAT also provides an EOT-based explanation of attention sinks and materializes a solution for them, avoiding the representational trade-offs of standard attention. Finally, by absorbing spatial information into the core attention computation, GOAT learns an extrapolatable prior that combines the flexibility of learned positional embeddings with the length generalization of fixed encodings.
