Skip to main content
QUICK REVIEW

[论文解读] Transformers as Support Vector Machines

Davoud Ataee Tarzanagh, Yingcong Li|arXiv (Cornell University)|Aug 31, 2023
Topic Modeling被引用 7
一句话总结

本文建立了变换器中自注意力机制优化动态与硬-margin支持向量机(SVM)问题之间的形式等价性,表明在消失正则化下,对单层变换器进行梯度下降时,其参数方向收敛于最小化参数矩阵 $\mathbf{W} = \mathbf{K}\mathbf{Q}^\top$ 的核范数的SVM解。关键贡献在于构建了一个将注意力机制与SVM联系起来的理论框架,揭示了过参数化可确保全局收敛及良性优化景观。

ABSTRACT

Since its inception in "Attention Is All You Need", transformer architecture has led to revolutionary advancements in NLP. The attention layer within the transformer admits a sequence of input tokens $X$ and makes them interact through pairwise similarities computed as softmax$(XQK^ op X^ op)$, where $(K,Q)$ are the trainable key-query parameters. In this work, we establish a formal equivalence between the optimization geometry of self-attention and a hard-margin SVM problem that separates optimal input tokens from non-optimal tokens using linear constraints on the outer-products of token pairs. This formalism allows us to characterize the implicit bias of 1-layer transformers optimized with gradient descent: (1) Optimizing the attention layer with vanishing regularization, parameterized by $(K,Q)$, converges in direction to an SVM solution minimizing the nuclear norm of the combined parameter $W=KQ^ op$. Instead, directly parameterizing by $W$ minimizes a Frobenius norm objective. We characterize this convergence, highlighting that it can occur toward locally-optimal directions rather than global ones. (2) Complementing this, we prove the local/global directional convergence of gradient descent under suitable geometric conditions. Importantly, we show that over-parameterization catalyzes global convergence by ensuring the feasibility of the SVM problem and by guaranteeing a benign optimization landscape devoid of stationary points. (3) While our theory applies primarily to linear prediction heads, we propose a more general SVM equivalence that predicts the implicit bias with nonlinear heads. Our findings are applicable to arbitrary datasets and their validity is verified via experiments. We also introduce several open problems and research directions. We believe these findings inspire the interpretation of transformers as a hierarchy of SVMs that separates and selects optimal tokens.

研究动机与目标

  • 通过将优化几何与SVM联系起来,理解使用梯度下降训练的单层变换器的隐性偏差。
  • 刻画注意力机制如何通过在令牌对外积上施加线性约束来选择最优令牌。
  • 解释为何过参数化可确保注意力优化中的全局收敛,通过确保可行性并消除虚假驻点。
  • 将SVM等价性从线性头扩展至非线性预测头及多令牌组合。
  • 通过在交叉注意力与自注意力机制上针对多种数据设置的数值实验验证理论。

提出的方法

  • 将自注意力机制形式化为一个硬-margin SVM问题(Att-SVM),通过在成对令牌外积上施加约束,实现对最优与非最优输入令牌的分离。
  • 证明通过 $({\mathbf{K}}, {\mathbf{Q}})$ 参数化注意力层时,梯度下降在方向上收敛至最小化 $\mathbf{W} = \mathbf{K}\mathbf{Q}^\top$ 的核范数的SVM解。
  • 证明直接通过 $\mathbf{W}$ 参数化时,SVM目标最小化Frobenius范数,且在几何条件下可保证收敛。
  • 展示过参数化可确保SVM问题的可行性,并消除非全局驻点,从而实现全局收敛。
  • 提出适用于非线性头与多令牌注意力的广义SVM等价性,并通过在不同维度与令牌选择阈值下的数值实验进行验证。
  • 使用经验分析验证梯度下降在方向上收敛至SVM解,测量学习到的 $\mathbf{W}$ 与最优 $\mathbf{W}^{\text{mm}}$ 之间的相关性。
(a) $\bm{W}$ -parameterization
(a) $\bm{W}$ -parameterization

实验结果

研究问题

  • RQ1变换器中自注意力机制的优化几何如何与硬-margin SVM问题相关联?
  • RQ2在 $({\mathbf{K}}, {\mathbf{Q}})$ 参数化下,梯度下降在单层变换器上的隐性偏差是什么?其与直接 $\mathbf{W}$ 参数化的区别何在?
  • RQ3梯度下降在注意力优化景观中于何种条件下实现全局收敛?
  • RQ4过参数化如何影响注意力模型的收敛行为与优化景观?
  • RQ5SVM等价性能否扩展至注意力中的非线性预测头与多令牌组合?

主要发现

  • 在 $({\mathbf{K}}, {\mathbf{Q}})$-参数化注意力中,梯度下降在方向上收敛至最小化 $\mathbf{W} = \mathbf{K}\mathbf{Q}^\top$ 的核范数的SVM解。
  • 对于 $\mathbf{W}$-参数化注意力,梯度下降的收敛性取决于几何条件:全局或局部收敛;过参数化通过消除非全局驻点确保全局收敛。
  • 过参数化确保了SVM问题的可行性,并保证了不包含虚假驻点的良性优化景观。
  • 数值实验表明,当 $d \geq 8$ 或 $\Gamma \leq 10^{-9}$ 时,学习到的注意力权重 $\mathbf{W}$ 与最优SVM解 $\mathbf{W}^{\text{mm}}$ 的相关性超过0.99。
  • 在使用广义SVM等价性时,注意力选择的令牌数量保持在 $\tau$ 的限制范围内,验证了引理6。
  • 性能在不同序列长度 $T$ 下保持一致,但需满足 $m \gtrsim n$ 才能实现对SVM解的准确收敛,证实了关于秩与维度的理论边界。
(b) $({\bm{K}},{\bm{Q}})$ -parameterization
(b) $({\bm{K}},{\bm{Q}})$ -parameterization

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。