Transformer在稀疏依赖任务中样本效率远超传统网络。
When Do Transformers Outperform Feedforward and Recurrent Networks? A Statistical Perspective
- 通过动态稀疏性机制,Transformer能高效定位关键输入
- 单层Transformer只需q个注意力头即可实现近似N无关的样本复杂度
- 适合处理长序列中局部相关性的任务,如语言建模
理论研究通常从表征能力角度比较Transformer与前馈和循环神经网络的优势。本文从统计视角出发,证明即使在无限计算条件下,前馈和循环网络仍可能面临更大的样本复杂度,而Transformer可通过动态稀疏性适应此类任务。我们考虑一个长度为N的序列到序列生成模型,其中每个位置的输出仅依赖于q个相关标记(q≪N),且其位置由输入提示给出。我们证明,单层Transformer仅需至少q个注意力头即可学习该模型,此时样本复杂度几乎与N无关;而循环网络在相同问题下需要N^Ω(1)样本。若简化模型,循环网络可达到近似N无关的复杂度,但前馈网络仍需N样本。因此,我们的稀疏检索模型揭示了这三类架构在样本复杂度上的自然层级关系。
原文摘要 · Abstract (English)
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.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。