arXiv:2410.01686cs.LGcs.AI2024-10被引 9

研究注意力如何让Transformer执行算法,发现仅用位置信息就能高效完成计算任务。

Positional Attention: Expressivity and Learnability of Algorithmic Computation

  • 用位置编码决定注意力权重,实现无需内容的算法计算。
  • 理论证明其表达能力等同于并行计算模型,深度仅随输入长度对数增长。
  • 适合研究算法推理与位置敏感任务的模型设计,如排序、统计计算。

神经网络执行算法任务(如算术、统计、排序)的能力日益受到关注。本文旨在深入理解注意力机制在Transformer中对算法执行的作用。已有研究从理论和实验角度表明,注意力对算法执行至关重要,尤其许多并行算法仅通过位置信息进行处理器间通信。受此启发,本文研究仅依赖位置编码生成注意力权重的「位置注意力」机制。我们证明,采用位置注意力的Transformer(即位置Transformer)具有与并行计算模型相同的表达能力,且其深度相对于输入长度仅呈对数级增长。进一步分析其分布内可学习性,并探讨参数范数对样本复杂度的影响。结果表明,位置Transformer在参数范数方面有更优的理论表现,但某些任务可能需要更多层,从而增加样本需求。最后,通过实证考察其分布外性能,发现当任务的算法解依赖位置信息时,位置Transformer表现良好。

原文摘要 · Abstract (English)

There is a growing interest in the ability of neural networks to execute algorithmic tasks (e.g., arithmetic, summary statistics, and sorting). The goal of this work is to better understand the role of attention in Transformers for algorithmic execution. Its importance for algorithmic execution has been studied theoretically and empirically using parallel computational models. Notably, many parallel algorithms communicate between processors solely using positional information. Inspired by this observation, we investigate how Transformers can execute algorithms using positional attention, where attention weights depend exclusively on positional encodings. We prove that Transformers with positional attention (positional Transformers) maintain the same expressivity of parallel computational models, incurring a logarithmic depth cost relative to the input length. We analyze their in-distribution learnability and explore how parameter norms in positional attention affect sample complexity. Our results show that positional Transformers introduce a learning trade-off: while they exhibit better theoretical dependence on parameter norms, certain tasks may require more layers, which can, in turn, increase sample complexity. Finally, we empirically explore the out-of-distribution performance of positional Transformers and find that they perform well in tasks where their underlying algorithmic solution relies on positional information.

Transformer算法计算位置注意力表达能力

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。