arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.11272stat.MLcs.LG
收藏

Transformer 何时优于前馈网络和循环网络?统计学视角

When Do Transformers Outperform Feedforward and Recurrent Networks? A Statistical Perspective

University of Toronto(多伦多大学);Vector Institute(矢量研究院);Google Research(谷歌研究院);New York University(纽约大学);Flatiron Institute(弗拉蒂伦研究院)

Alireza Mousavi-Hosseini, Clayton Sanford, Denny Wu, Murat A. Erdogdu

AI总结:

论文提出动态稀疏检索的序列到序列模型,从样本复杂度角度证明单层 Transformer 在注意力头数不少于 $q$ 时可几乎不受序列长度 $N$ 影响,并揭示其相对循环与前馈网络的层级优势。

摘要:

为证明 Transformer 相比前馈神经网络和循环神经网络等经典架构的优势,已有理论研究大多聚焦于表示能力。在本工作中,我们采用另一种视角,并证明:即使拥有无限算力,前馈网络和循环网络仍可能面临比 Transformer 更高的样本复杂度,因为后者能够适应一种动态稀疏性。具体而言,我们考虑一个长度为 $N$ 的序列上的序列到序列数据生成模型,其中每个位置的输出仅依赖于 $q$ 个相关 token,且 $q \ll N$,这些 token 的位置在输入提示中给出。我们证明,单层 Transformer 能够学习该模型,当且仅当其注意力头数量至少为 $q$;在这种情况下,它实现几乎与 $N$ 无关的样本复杂度,而循环网络在同一问题上需要 $N^{\Omega(1)}$ 个样本。如果简化该模型,循环网络可以实现几乎与 $N$ 无关的复杂度,而前馈网络仍需要 $N$ 个样本。因此,我们提出的稀疏检索模型说明了这些架构之间在样本复杂度上的一种自然层级。

英文摘要:

Theoretical efforts to prove advantages of Transformers in comparison with classical architectures such as feedforward and recurrent neural networks have mostly focused on representational power. In this work, we take an alternative perspective and prove that even with infinite compute, feedforward and recurrent networks may suffer from larger sample complexity compared to Transformers, as the latter can adapt to a form of dynamic sparsity. Specifically, we consider a sequence-to-sequence data generating model on sequences of length $N$, in which the output at each position depends only on $q$ relevant tokens with $q \ll N$, and the positions of these tokens are described in the input prompt. We prove that a single-layer Transformer can learn this model if and only if its number of attention heads is at least $q$, in which case it achieves a sample complexity almost independent of $N$, while recurrent networks require $N^{Ω(1)}$ samples on the same problem. If we simplify this model, recurrent networks may achieve a complexity almost independent of $N$, while feedforward networks still require $N$ samples. Consequently, our proposed sparse retrieval model illustrates a natural hierarchy in sample complexity across these architectures.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑