arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.00768cs.CL
收藏

对变换器中局部注意力的表达力进行表征

Characterizing the Expressivity of Local Attention in Transformers

Jiaoda Li, Ryan Cotterell

AI总结:

本文研究了变换器中局部注意力的表达力,通过形式语言理论分析了局部注意力如何扩展可识别的正则语言,并证明了全局和局部注意力在表达力上的互补性,实验表明混合型变换器在形式语言识别和自然语言建模中表现更优。

摘要:

变换器是语言建模中最流行的神经架构。变换器的核心是其全局注意力机制,该机制允许模型在生成下一个标记前聚合所有前序标记的信息。局部注意力是一种常见的注意力变体,它限制每个标记只能聚合来自有限窗口前序标记的信息,从而将全局注意力的二次成本降低到线性。尽管这种限制通常由效率驱动,但发现它也提高了模型质量,这一现象至今缺乏令人满意的解释。本文从识别器表达力的角度提供了这一现象的正式说明。已证明具有固定精度的变换器与包含单一过去操作符的线性时序逻辑片段相对应。此外,证明添加局部注意力引入了第二个时间操作符,严格扩大了可识别的正则语言类别。此外,全局和局部注意力在表达力上是互补的:彼此不包含,结合它们会产生最丰富的片段。在形式语言识别和自然语言建模上的实验验证了理论,显示混合型全局-局部变换器在性能上优于仅使用全局注意力的变换器。

英文摘要:

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.

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

↑