arXiv:2501.11765cs.CLcs.AI2025-01

发现Transformer自注意力可直接完成逻辑分析,不依赖全连接层。

Is logical analysis performed by transformers taking place in self-attention or in the fully connected part?

  • 设计单层编码器,让自注意力独立完成逻辑推理任务。
  • 实验表明模型在可选情况下优先使用自注意力进行逻辑判断。
  • 为理解自注意力的深层能力提供新视角,适合关注模型机制的研究者。

Transformer架构通过向量表示的标记先经自注意力处理,再经过全连接层。传统观点认为自注意力仅用于信息聚合,逻辑运算由全连接层完成。本文反其道而行之,构建一个手工设计的单层编码器,使自注意力部分独立完成逻辑分析。进一步研究单层Transformer在梯度下降下的自学习过程,考察模型在有选择时是否利用全连接层或自注意力进行逻辑判断。考虑到梯度下降可能陷入无效零点,我们显式计算并规避这些陷阱。所有实验均以预测文本中相邻词的语法类别对为目标。结果表明,自注意力具备执行逻辑分析的能力,这一发现对理解自注意力的潜在逻辑功能具有广泛意义。

原文摘要 · Abstract (English)

Transformers architecture apply self-attention to tokens represented as vectors, before a fully connected (neuronal network) layer. These two parts can be layered many times. Traditionally, self-attention is seen as a mechanism for aggregating information before logical operations are performed by the fully connected layer. In this paper, we show, that quite counter-intuitively, the logical analysis can also be performed within the self-attention. For this we implement a handcrafted single-level encoder layer which performs the logical analysis within self-attention. We then study the scenario in which a one-level transformer model undergoes self-learning using gradient descent. We investigate whether the model utilizes fully connected layers or self-attention mechanisms for logical analysis when it has the choice. Given that gradient descent can become stuck at undesired zeros, we explicitly calculate these unwanted zeros and find ways to avoid them. We do all this in the context of predicting grammatical category pairs of adjacent tokens in a text. We believe that our findings have broader implications for understanding the potential logical operations performed by self-attention.

Transformer自注意力逻辑推理

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