arXiv:2412.18288cs.LGcs.AI2024-12被引 9

揭示注意力机制的本质及其与传统机器学习的联系

Towards understanding how attention mechanism works in deep learning

  • 将自注意力分解为可学习的伪度量函数与相似性传播过程
  • 证明自注意力在特定条件下收敛于漂移扩散过程,可转化为热方程
  • 提出基于度量学习的metric-attention,提升训练效率与鲁棒性

注意力机制广泛应用于Transformer和图注意力网络等主流神经网络架构中,但其内在工作原理仍不清晰。本文通过分析流形学习、聚类和监督学习中经典度量与向量空间性质下的相似性计算过程,识别出其中的关键特征,并证明深度学习中的自注意力机制遵循相同原则,但更具灵活性和自适应性。研究将自注意力分解为可学习的伪度量函数与基于相似性的信息传播过程,证明当伪度量为度量的变换且满足合理假设时,自注意力可通过连续建模收敛至漂移扩散过程,该方程可在新度量下转化为热方程。此外,本文对一般伪度量函数的注意力机制进行了一阶分析,借助物理直觉深化理解。最后,提出基于度量学习的metric-attention改进方法,实验表明其在训练效率、准确率和鲁棒性上均优于标准自注意力。

原文摘要 · Abstract (English)

Attention mechanism has been extensively integrated within mainstream neural network architectures, such as Transformers and graph attention networks. Yet, its underlying working principles remain somewhat elusive. What is its essence? Are there any connections between it and traditional machine learning algorithms? In this study, we inspect the process of computing similarity using classic metrics and vector space properties in manifold learning, clustering, and supervised learning. We identify the key characteristics of similarity computation and information propagation in these methods and demonstrate that the self-attention mechanism in deep learning adheres to the same principles but operates more flexibly and adaptively. We decompose the self-attention mechanism into a learnable pseudo-metric function and an information propagation process based on similarity computation. We prove that the self-attention mechanism converges to a drift-diffusion process through continuous modeling provided the pseudo-metric is a transformation of a metric and certain reasonable assumptions hold. This equation could be transformed into a heat equation under a new metric. In addition, we give a first-order analysis of attention mechanism with a general pseudo-metric function. This study aids in understanding the effects and principle of attention mechanism through physical intuition. Finally, we propose a modified attention mechanism called metric-attention by leveraging the concept of metric learning to facilitate the ability to learn desired metrics more effectively. Experimental results demonstrate that it outperforms self-attention regarding training efficiency, accuracy, and robustness.

注意力机制度量学习自注意力模型解释

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