arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2412.18288cs.LGcs.AIcs.CVstat.ML
收藏

深入理解深度学习中注意力机制的工作原理

Towards understanding how attention mechanism works in deep learning

Tianyu Ruan, Shihua Zhang

AI总结:

本研究将自注意力机制分解为可学习伪度量与信息传播过程,证明其收敛于漂移-扩散过程,并提出改进的 metric-attention 机制,在训练效率、准确性和鲁棒性上优于自注意力。

摘要:

注意力机制已被广泛集成到主流神经网络架构中,例如 Transformers 和图注意力网络。然而,其底层工作原理仍然有些难以捉摸。它的本质是什么?它与传统机器学习算法之间是否存在联系?在本研究中,我们考察了在流形学习、聚类和监督学习中使用经典度量和向量空间性质计算相似度的过程。我们识别了这些方法中相似度计算和信息传播的关键特征,并证明了深度学习中的自注意力机制遵循相同的原理,但运行得更加灵活和自适应。我们将自注意力机制分解为一个可学习的伪度量函数和一个基于相似度计算的信息传播过程。我们证明,如果伪度量是某个度量的变换并且某些合理的假设成立,则通过连续建模,自注意力机制收敛于一个漂移-扩散过程。该方程在新度量下可转化为热传导方程。此外,我们对具有一般伪度量函数的注意力机制进行了一阶分析。本研究有助于通过物理直觉理解注意力机制的效果和原理。最后,我们利用度量学习的概念,提出了一种称为 metric-attention 的改进型注意力机制,以促进更有效地学习所需度量的能力。实验结果表明,它在训练效率、准确性和鲁棒性方面优于自注意力。

英文摘要:

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.

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

↑