Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Transformer論文紹介

Avatar for Masa Kazama Masa Kazama
May 08, 2025
310

 Transformer論文紹介

Avatar for Masa Kazama

Masa Kazama

May 08, 2025
Tweet

Transcript

  1. 概要 論文: "Attention Is All You Need" (Vaswani et al.,

    2017) 課題: 従来の系列変換モデル (RNN, LSTM, GRU, CNNベース) は、逐次計算による並列 化の制約や、長い系列での依存関係学習の困難さがあった。 提案: Recurrence (再帰) や Convolution (畳み込み) を完全に排除し、Attentionメカニ ズムのみに基づいた新しいモデルアーキテクチャ "Transformer" を提案。 貢献: 高い並列化可能性による訓練時間の短縮。 機械翻訳タスクで当時の最高性能 (State-of-the-Art) を達成。 他のタスクへの汎用性も示した。 Attention Is All You Need 論文解説 2
  2. 提案手法:Transformer 基本構造: Encoder-Decoder モデル 特徴: RNNやCNNを使用しない。 Self-Attention を用いて入力系列内、出 力系列内の依存関係を学習。 Encoder-Decoder間の関連性は

    Encoder-Decoder Attention で学習。 位置情報を与えるために Positional Encoding を導入。 Figure 1: Transformerのモデルアーキテクチャ Attention Is All You Need 論文解説 4
  3. Transformerの構成要素 (1/3): Multi- Head Attention Attentionは、Query (Q) と Key-Value (K-V)

    ペ アから出力を計算する機構。 Scaled Dot-Product Attention: : Keyの次元数。次元数でスケールす ることで勾配消失を防ぐ。 Multi-Head Attention: Attention層を 個並列に実行 (異なる重 みで線形射影)。 異なる表現部分空間からの情報を同時 に捉えることが可能。 Attention Is All You Need 論文解説 5
  4. Transformerの構成要素 (2/3): Attentionの種類 Transformerでは3種類のMulti-Head Attentionを使用: 1. Encoder Self-Attention: Encoder内で、各位置が他の全ての位置を参照 (Q,

    K, Vが同じ Encoder層の出力)。 2. Decoder Self-Attention (Masked): Decoder内で、各位置が自身を含むそれ以前の位 置のみを参照 (未来の情報を参照しないようにMasking)。 3. Encoder-Decoder Attention: DecoderがEncoderの最終出力を参照 (QはDecoder層、K, VはEncoder出力)。 Attention Is All You Need 論文解説 6
  5. Transformerの構成要素 (3/3): その他 Position-wise Feed-Forward Networks (FFN): Attention層の後、各位置に対して独立に適用される全結合FFN。 活性化関数はReLU。 Positional

    Encoding: 系列内のトークンの相対的/絶対的な位置情報を与える。 sin関数とcos関数を用いた固定的な値を、入力Embeddingに加算。 Residual Connection & Layer Normalization: 各サブレイヤー (Attention, FFN) の後に追加。勾配伝播を助け、学習を安定化。 Attention Is All You Need 論文解説 7
  6. なぜ Self-Attention か? Layer Type Complexity per Layer Sequential Operations

    Maximum Path Length Self-Attention Recurrent (RNN) Convolutional (k=kernel size) or Self-Attention (restricted r) 計算量: 系列長 が次元数 より小さい場合、RNNより高速。 並列化: の逐次計算で済むため、並列化が容易。 長期依存: 系列内の任意の位置間のパス長が であり、長期依存関係の学習が容 Attention Is All You Need 論文解説 8
  7. 実験結果:機械翻訳 WMT 2014 英独翻訳: BLEUスコア 28.4 を達成。 既存の最高性能モデル (アンサンブル含む) を

    2.0 BLEU以上 改善。 WMT 2014 英仏翻訳: BLEUスコア 41.8 を達成 (Bigモデル)。 単一モデルとして当時の最高性能 (SOTA) を達成。 訓練時間: ベースモデル: 8 P100 GPUs で 12時間 (10万ステップ)。 Bigモデル: 8 P100 GPUs で 3.5日 (30万ステップ)。 従来のSOTAモデルと比較して大幅に短い訓練時間。 Attention Is All You Need 論文解説 9
  8. 実験結果:モデルのバリエーション Attention Head数 (h): 1 head (h=1) では性能低下。多すぎる場合 (h=16, 32)

    も若干低下。h=8が良好。 Attention Key次元 (dk): 次元数を減らすと性能低下。単純なDot-Product以外の類似度関数が有効な可能 性を示唆。 モデルサイズ: モデルを大きくする (d_model, d_ff) と性能向上。 Positional Encoding: 学習可能なPositional Embeddingでも、sin/cos関数版とほぼ同等の性能。 Regularization: Dropout, Label Smoothing が過学習抑制に有効。 Attention Is All You Need 論文解説 10
  9. 実験結果:英語構文解析 Transformerを英語構文解析タスク (WSJ) に適用。 課題: 出力は構造的な制約が強く、入力よりかなり長い。RNNベースのモデルは苦戦 していた。 結果: タスク特化のチューニングなしでも、当時の多くのモデルより優れた性能 (F1ス

    コア)。 特に、少量の訓練データ (WSJ only) でも BerkeleyParser を上回った。 Transformerが他の系列変換タスクにも汎用的に適用可能であることを示した。 Attention Is All You Need 論文解説 11
  10. 参考文献 Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion

    Jones, Aidan N. Gomez, Łukasz Kaiser, Illia Polosukhin. (2017). Attention Is All You Need. Advances in Neural Information Processing Systems 30 (NIPS 2017). (https://arxiv.org/abs/1706.03762) Attention Is All You Need 論文解説 14