Skip to main content
QUICK REVIEW

[論文レビュー] Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformer

Yuandong Tian, Yiping Wang|arXiv (Cornell University)|May 25, 2023
Neural Networks and Applications被引用数 6
ひとこと要約

本論文は、次トークン予測のための1層TransformerにおけるSGDトレーニングダイナミクスを数学的に厳密に分析し、自己注意機構が判別的スキャンメカニズムとして機能することを明らかにした。具体的には、共起頻度が高い異なるトークンに段階的に注目を向ける一方で、一般的なトークンへの注目を減少させる。主な発見は、トレーニングダイナミクスにおけるフェーズ遷移であり、これはウィナー・トゥー・アール(winner-takes-all)への崩壊を防ぎ、学習率比によって制御可能な安定的かつスパースな注目パターンを生じさせる。

ABSTRACT

Transformer architecture has shown impressive performance in multiple research domains and has become the backbone of many neural network models. However, there is limited understanding on how it works. In particular, with a simple predictive loss, how the representation emerges from the gradient \emph{training dynamics} remains a mystery. In this paper, for 1-layer transformer with one self-attention layer plus one decoder layer, we analyze its SGD training dynamics for the task of next token prediction in a mathematically rigorous manner. We open the black box of the dynamic process of how the self-attention layer combines input tokens, and reveal the nature of underlying inductive bias. More specifically, with the assumption (a) no positional encoding, (b) long input sequence, and (c) the decoder layer learns faster than the self-attention layer, we prove that self-attention acts as a \emph{discriminative scanning algorithm}: starting from uniform attention, it gradually attends more to distinct key tokens for a specific next token to be predicted, and pays less attention to common key tokens that occur across different next tokens. Among distinct tokens, it progressively drops attention weights, following the order of low to high co-occurrence between the key and the query token in the training set. Interestingly, this procedure does not lead to winner-takes-all, but decelerates due to a \emph{phase transition} that is controllable by the learning rates of the two layers, leaving (almost) fixed token combination. We verify this extbf{\emph{scan and snap}} dynamics on synthetic and real-world data (WikiText).

研究の動機と目的

  • SGDによる学習におけるTransformerの自己注意機構の暗黙的な誘導バイアスを理解すること。
  • 位置エンコーディングの欠如下での、SGD下における注目重みの動的変化を形式化すること。
  • 自己注意機構が注目スパarsityが増加するにもかかわらず、なぜウィナー・トゥー・アールに崩壊しないのかを説明すること。
  • デコーダー層と自己注意層間の学習率比がフェーズ遷移の発生時期と注目パターンの密度にどのように影響するかを特定すること。
  • 合成データおよび実世界のデータ(WikiText)上で理論的予測を検証すること。

提案手法

  • SGD最適化下で、自己注意機構に続くデコーダー層を備えた1層Transformerを用いた次トークン予測を分析する。
  • パラメータの進化をモデル化するため、非線形ODEを用いたSGDダイナミクスの連続時間近似を導入する。
  • 自己注意とデコーダーのダイナミクスを分離するために、行列$Y$および$Z$による注目重みの再パrameter化を採用する。
  • 長時間系列および低速注目仮定の下で、注目ログィットおよびソフトマックス出力の解析的解を導出する。
  • 長時間系列におけるトークン共起頻度の推定値を束縛するために、Hoeffdingの不等式を用いる。
  • 合成データおよびWikiText上の実験を通じて、注目エントロピーとリコールしきい値曲線を測定することで、主張を検証する。
Figure 1: Overall of our setting. (a) A sequence with contextual tokens $\{x_{1},\ldots,x_{T-1}\}$ and query token $x_{T}$ is fed into 1-layer transformer (self-attention, normalization and decoding) to predict the next token $x_{T+1}$ . (b) The definition of sequence classes (Sec. 3.2 ). A sequence
Figure 1: Overall of our setting. (a) A sequence with contextual tokens $\{x_{1},\ldots,x_{T-1}\}$ and query token $x_{T}$ is fed into 1-layer transformer (self-attention, normalization and decoding) to predict the next token $x_{T+1}$ . (b) The definition of sequence classes (Sec. 3.2 ). A sequence

実験結果

リサーチクエスチョン

  • RQ1位置エンコーディングのない1層Transformerにおいて、自己注意機構はトレーニング中にどのように動的に進化するか?
  • RQ2自己注意機構はどのような誘導バイアスを学習するのか?また、それはトークンの共起頻度と特徴の明確さとどのように関係するか?
  • RQ3注目がスパース化する中で、なぜ自己注意機構はウィナー・トゥー・アールのパターンに崩壊しないのか?
  • RQ4デコーダー層と自己注意層間の学習率比は、注目パターンのスパarsityと安定性にどのように影響するか?
  • RQ5『スキャンして固定(scan and snap)』の理論的ダイナミクスは、実世界の系列データ上で実証的に検証可能か?

主な発見

  • 自己注意機構は判別的スキャン行動を示す。具体的には、クエリトークンと頻繁に共起する特徴的なトークンに段階的に注目を向ける。
  • 注目機構には周波数バイアスが存在し、トレーニングデータにおけるクエリとの共起頻度が高いトークンを好む。
  • 注目がスパース化する中でも、勾配の大きさが対数的に減少するフェーズ遷移のおかげで、注目は1ホットに崩壊しない。
  • デコーダー層の学習率が高いほどフェーズ遷移が加速し、注目パターンがより密度になる。一方、自己注意層の学習率が高いと、注目パターンはよりスパースになる。
  • WikiTextにおける実験結果から、高い学習率は注目マップのエントロピーを低下させ、リコールしきい値の低下を遅らせることが確認され、注目がよりスパースであることを示している。
  • 注目スパarsityと共起依存性に関する理論的予測は、さまざまな学習率比におけるリコールしきい値曲線を通じて実証的に検証された。
Figure 2: Overview of the training dynamics of self-attention map. Here $\tilde{c}_{l|m,n}:=\mathbb{P}(l|m,n)\exp(z_{ml})$ is the un-normalized attention score (Eqn. 5 ). (a) Initialization stage. $z_{ml}(0)=0$ and $\tilde{c}_{l|m,n}=\mathbb{P}(l|m,n)$ . Distinct tokens (Sec. 3.2 ) shown in blue, co
Figure 2: Overview of the training dynamics of self-attention map. Here $\tilde{c}_{l|m,n}:=\mathbb{P}(l|m,n)\exp(z_{ml})$ is the un-normalized attention score (Eqn. 5 ). (a) Initialization stage. $z_{ml}(0)=0$ and $\tilde{c}_{l|m,n}=\mathbb{P}(l|m,n)$ . Distinct tokens (Sec. 3.2 ) shown in blue, co

より良い研究を、今すぐ始めましょう

論文の読解から最終レビューまで、研究時間を劇的に削減しましょう。

クレジットカード登録不要

このレビューはAIが作成し、人間の編集者が確認しました。