LUNA: Linear Universal Neural Attention with Generalization Guarantees
Department of Computer Science, Vanderbilt University(维斯尼尔大学计算机科学系);Department of Electrical & Computer Engineering, Vanderbilt University(维斯尼尔大学电气与计算机工程系);Department of Computer Science, Duke University(杜克大学计算机科学系);Department of Biostatistics & Bioinformatics, Duke University(杜克大学生物统计与生物信息学系)
在扩展注意力机制时面临一个关键瓶颈:softmax注意力的$\mathcal{O}(n^2)$二次计算成本,这限制了其在长序列领域中的应用。虽然线性注意力机制将此成本降低到$\mathcal{O}(n)$,但它们通常依赖于固定的随机特征图,如随机傅里叶特征或手工设计的函数。这种对静态、数据无关内核的依赖造成了一个根本性的权衡,迫使实践者在计算效率和模型精度之间做出牺牲。我们引入了\textsc{LUNA},一种基于内核的线性注意力机制,消除了这种权衡,保留了线性成本的同时,匹配并超越了二次注意力的精度。\textsc{LUNA}基于一个关键见解:内核特征图本身应该被学习而非事先固定。通过参数化内核,\textsc{LUNA}学习了一个针对特定数据和任务定制的特征基,克服了固定特征方法的表达限制。\textsc{Luna}通过一个可学习的特征图实现这一点,该特征图诱导出正定内核并允许流式形式,从而在序列长度上实现线性时间与内存扩展。经验评估验证了我们的方法在多样化的设置中。在Long Range Arena (LRA)上,\textsc{Luna}在计算条件相同的情况下,使用相同参数数量、训练步骤和近似FLOPs,实现了高效Transformer中的最先进平均精度。此外,\textsc{Luna}在事后转换方面也表现出色:在微调后的BERT和ViT-B/16检查点中替换softmax并短暂微调,恢复了大部分原始性能,显著优于固定线性化方法。
英文摘要:
Scaling attention faces a critical bottleneck: the $\mathcal{O}(n^2)$ quadratic computational cost of softmax attention, which limits its application in long-sequence domains. While linear attention mechanisms reduce this cost to $\mathcal{O}(n)$, they typically rely on fixed random feature maps, such as random Fourier features or hand-crafted functions. This reliance on static, data-agnostic kernels creates a fundamental trade-off, forcing practitioners to sacrifice significant model accuracy for computational efficiency. We introduce \textsc{LUNA}, a kernelized linear attention mechanism that eliminates this trade-off, retaining linear cost while matching and surpassing the accuracy of quadratic attention. \textsc{LUNA} is built on the key insight that the kernel feature map itself should be learned rather than fixed a priori. By parameterizing the kernel, \textsc{LUNA} learns a feature basis tailored to the specific data and task, overcoming the expressive limitations of fixed-feature methods. \textsc{Luna} implements this with a learnable feature map that induces a positive-definite kernel and admits a streaming form, yielding linear time and memory scaling in the sequence length. Empirical evaluations validate our approach across diverse settings. On the Long Range Arena (LRA), \textsc{Luna} achieves state-of-the-art average accuracy among efficient Transformers under compute parity, using the same parameter count, training steps, and approximate FLOPs. \textsc{Luna} also excels at post-hoc conversion: replacing softmax in fine-tuned BERT and ViT-B/16 checkpoints and briefly fine-tuning recovers most of the original performance, substantially outperforming fixed linearizations.
Universality of Linear Recurrences Followed by Non-linear Projections: Finite-Width Guarantees and Benefits of Complex Eigenvalues
ELLIS Institute Tübingen(ELLIS研究所蒂宾根分部);Max Planck Institute for Intelligent Systems(马克斯·普朗克智能系统研究所);Tübingen AI Center(蒂宾根人工智能中心);Google Deepmind(谷歌DeepMind);EPFL(洛桑联邦理工学院)
Single Image Inpainting and Super-Resolution with Simultaneous Uncertainty Guarantees by Universal Reproducing Kernels
Institute for Computer Science and Control (SZTAKI)(计算机科学与控制研究所);Institute of Mathematics, Budapest University of Technology and Economics (BME)(布达佩斯技术大学数学研究所)