arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2306.13596cs.LGcs.AIcs.CLmath.OC
收藏

注意力机制中的最大间隔 token 选择

Max-Margin Token Selection in Attention Mechanism

University of Pennsylvania(宾夕法尼亚大学);University of California, Riverside(加州大学河滨分校);University of Michigan(密歇根大学);UC Riverside(加州大学河滨分校)

Davoud Ataee Tarzanagh, Yingcong Li, Xuechen Zhang, Samet Oymak

AI总结:

本文分析 softmax-attention 的非凸优化动力学,证明梯度下降在方向上收敛到最大间隔 token 选择解,并通过正则化路径与 SVM 联系及实验验证其结论。

摘要:

注意力机制是 transformer 架构的核心组成部分,而 transformer 架构促成了大型语言模型的惊人成功。然而,人们对注意力机制背后的理论原理仍知之甚少,尤其是其非凸优化动力学。在本工作中,我们研究具有奠基意义的 softmax-attention 模型 $f(\boldsymbol{X})=\langle \boldsymbol{Xv}, \texttt{softmax}(\boldsymbol{XWp})\rangle$,其中 $\boldsymbol{X}$ 是 token 序列,$(\boldsymbol{v},\boldsymbol{W},\boldsymbol{p})$ 是可训练参数。我们证明,对 $\boldsymbol{p}$(或等价地对 $\boldsymbol{W}$)运行梯度下降,会在方向上收敛到一个最大间隔解,该解将局部最优 token 与非最优 token 分离开来。这清楚地将注意力形式化为一种最优 token 选择机制。值得注意的是,我们的结果适用于一般数据,并依据 value embeddings $\boldsymbol{Xv}$ 和问题几何结构精确刻画了 token 的最优性。我们还提供了更广泛的正则化路径分析,证明即使对于非线性预测头,注意力也具有最大化间隔的性质。当使用 logistic 损失同时优化 $\boldsymbol{v}$ 和 $\boldsymbol{p}$ 时,我们确定了正则化路径在方向上收敛到各自硬间隔 SVM 解的条件,其中 $\boldsymbol{v}$ 根据标签分离输入特征。有趣的是,$\boldsymbol{p}$ 的 SVM 形式会受到 $\boldsymbol{v}$ 的支持向量几何结构影响。最后,我们通过数值实验验证了理论发现并给出了洞见。

英文摘要:

Attention mechanism is a central component of the transformer architecture which led to the phenomenal success of large language models. However, the theoretical principles underlying the attention mechanism are poorly understood, especially its nonconvex optimization dynamics. In this work, we explore the seminal softmax-attention model $f(\boldsymbol{X})=\langle \boldsymbol{Xv}, \texttt{softmax}(\boldsymbol{XWp})\rangle$, where $\boldsymbol{X}$ is the token sequence and $(\boldsymbol{v},\boldsymbol{W},\boldsymbol{p})$ are trainable parameters. We prove that running gradient descent on $\boldsymbol{p}$, or equivalently $\boldsymbol{W}$, converges in direction to a max-margin solution that separates $\textit{locally-optimal}$ tokens from non-optimal ones. This clearly formalizes attention as an optimal token selection mechanism. Remarkably, our results are applicable to general data and precisely characterize $\textit{optimality}$ of tokens in terms of the value embeddings $\boldsymbol{Xv}$ and problem geometry. We also provide a broader regularization path analysis that establishes the margin maximizing nature of attention even for nonlinear prediction heads. When optimizing $\boldsymbol{v}$ and $\boldsymbol{p}$ simultaneously with logistic loss, we identify conditions under which the regularization paths directionally converge to their respective hard-margin SVM solutions where $\boldsymbol{v}$ separates the input features based on their labels. Interestingly, the SVM formulation of $\boldsymbol{p}$ is influenced by the support vector geometry of $\boldsymbol{v}$. Finally, we verify our theoretical findings via numerical experiments and provide insights.

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

↑