arXiv:2605.00768cs.CL2026-05ACL被引 3

局部注意力提升Transformer表达能力,理论证明其可识别更复杂语言模式。

Characterizing the Expressivity of Local Attention in Transformers

论文配图:Characterizing the Expressivity of Local Attention in Transformers
图 1 · 摘自论文原文
  • 用时序逻辑分析注意力机制,揭示局部注意力引入新时间算子。
  • 局部注意力使可识别语言类严格扩展,优于纯全局注意力。
  • 实验验证混合架构在形式语言与自然语言任务中表现更优。

Transformer是主流语言建模架构,其核心为全局注意力机制,能聚合所有前序词元信息。局部注意力通过限制每个词元仅关注有限窗口内的上下文,将复杂度从二次降低至线性,虽以效率为目标,却也意外提升模型性能,但缺乏理论解释。本文从可识别性角度给出形式化论证:固定精度的全局注意力对应包含单一过去算子的线性时序逻辑片段;加入局部注意力则引入第二个时间算子,严格扩大了可识别正则语言类。此外,全局与局部注意力表达能力互补,二者结合产生最丰富的逻辑片段。在形式语言识别与自然语言建模任务上的实验验证了该理论,表明混合全局-局部Transformer优于纯全局模型。

原文摘要 · Abstract (English)

The transformer is the most popular neural architecture for language modeling. The cornerstone of the transformer is its global attention mechanism, which lets the model aggregate information from all preceding tokens before generating the next token. One common variant of attention is called local attention, which restricts each token to aggregating information from a bounded window of predecessors, reducing the quadratic cost of global attention to linear. Although this restriction is usually motivated by efficiency, it has also been found to improve model quality, a phenomenon that has so far lacked a satisfactory explanation. We provide a formal account of this phenomenon in terms of recognizer expressivity. It has been shown that fixed-precision transformers with global attention correspond to a fragment of linear temporal logic containing a single past operator. We additionally prove that adding local attention introduces a second temporal operator, strictly enlarging the class of recognizable regular languages. Moreover, global and local attention are expressively complementary: neither subsumes the other, and combining them yields the richest fragment. Experiments on formal language recognition and natural language modeling corroborate the theory, showing that hybrid global--local transformers outperform their global-only counterparts.

Transformer注意力机制形式语言表达能力

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