快速多极注意力:一种适用于文本与图像的可扩展多级注意力机制
Fast Multipole Attention: A Scalable Multilevel Attention Mechanism for Text and Images
AI总结:
本文受快速多极方法启发提出快速多极注意力FMA,通过多级可学习层次将自注意力复杂度降至O(n log n)或O(n),在语言和视觉任务上以更低内存达到或超越基线性能。
摘要:
尽管Transformer网络受益于全局感受野,但其相对于序列长度的二次代价限制了它们在长序列和高分辨率输入上的应用。我们提出快速多极注意力(Fast Multipole Attention,FMA),这是一种受n体物理中快速多极方法启发的分而治之自注意力机制。FMA将自注意力的时间和内存复杂度从$\mathcal{O}\left(n^2\right)$降低到$\mathcal{O}(n \log n)$和$\mathcal{O}(n)$,同时保留全上下文交互。FMA包含一个具有$\mathcal{O}(\log n)$个分辨率级别的可学习层次结构。在该层次结构中,邻近token以全分辨率交互,而远距离token通过逐步变粗的可学习基函数进行交互。我们分别为语言和视觉任务开发了FMA的1D和2D实现。在自回归和双向语言建模基准上,1D变体以显著更低的内存使用匹配或优于领先的高效注意力基线。凭借线性复杂度,2D变体在分类和语义分割任务中展现出优于强视觉Transformer基线的性能。我们的结果证实,FMA实现的多级注意力使基于Transformer的模型能够扩展到更长的序列和更高分辨率的输入而不损失精度。这为开发适用于语言、视觉和多模态任务的可扩展神经网络提供了一种有原则的、受物理学启发的方法。我们的代码将在https://github.com/epoch98/FMA提供。
英文摘要:
While Transformer networks benefit from a global receptive field, their quadratic cost relative to sequence length restricts their application to long sequences and high-resolution inputs. We introduce Fast Multipole Attention (FMA), a divide-and-conquer mechanism for self-attention inspired by the Fast Multipole Method from n-body physics. FMA reduces the time and memory complexity of self-attention from $\mathcal{O}\left(n^2\right)$ to $\mathcal{O}(n \log n)$ and $\mathcal{O}(n)$ while preserving full-context interactions. FMA contains a learned hierarchy with $\mathcal{O}(\log n)$ levels of resolution. In this hierarchy, nearby tokens interact at full resolution, while distant tokens engage through progressively coarser, learned basis functions. We have developed both 1D and 2D implementations of FMA for language and vision tasks, respectively. On autoregressive and bidirectional language modeling benchmarks, the 1D variant either matches or outperforms leading efficient attention baselines with substantially lower memory use. With linear complexity, the 2D variant demonstrates superior performance over strong vision transformer baselines in classification and semantic segmentation tasks. Our results confirm that the multilevel attention implemented by FMA allows Transformer-based models to scale to much longer sequences and higher-resolution inputs without loss in accuracy. This provides a principled, physics-inspired approach for developing scalable neural networks suitable for language, vision, and multimodal tasks. Our code will be available at https://github.com/epoch98/FMA.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。