Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
[論文紹介] Attention Is All You Need
Search
shiba4839
October 01, 2024
Research
0
71
[論文紹介] Attention Is All You Need
学部4年生の7月ごろに行った論文発表の資料です。私自身初めての論文紹介でした。
shiba4839
October 01, 2024
Tweet
Share
More Decks by shiba4839
See All by shiba4839
[論文紹介] iTransformer: Inverted Transformers Are Effective for Time Series Forecasting
shiba4839
0
490
[輪講] Foundations of Cryptography 2.4章
shiba4839
0
53
[論文紹介] MoFusion: A Frame for Denoising-Diffusion-based Motion Synthesis
shiba4839
0
73
Other Decks in Research
See All in Research
地域丸ごとデイサービス「Go トレ」の紹介
smartfukushilab1
0
740
Aurora Serverless からAurora Serverless v2への課題と知見を論文から読み解く/Understanding the challenges and insights of moving from Aurora Serverless to Aurora Serverless v2 from a paper
bootjp
6
1.3k
snlp2025_prevent_llm_spikes
takase
0
420
J-RAGBench: 日本語RAGにおける Generator評価ベンチマークの構築
koki_itai
0
1.1k
さまざまなAgent FrameworkとAIエージェントの評価
ymd65536
1
380
財務諸表監査のための逐次検定
masakat0
0
220
CoRL2025速報
rpc
3
3.8k
言語モデルの地図:確率分布と情報幾何による類似性の可視化
shimosan
8
2.4k
Agentic AI Era におけるサプライチェーン最適化
mickey_kubo
0
110
HoliTracer:Holistic Vectorization of Geographic Objects from Large-Size Remote Sensing Imagery
satai
3
440
Tiaccoon: Unified Access Control with Multiple Transports in Container Networks
hiroyaonoe
0
290
Open Gateway 5GC利用への期待と不安
stellarcraft
2
170
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
How GitHub (no longer) Works
holman
316
140k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
160
WENDY [Excerpt]
tessaabrams
9
35k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
410
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
57
Designing Powerful Visuals for Engaging Learning
tmiket
0
190
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
100
Why Our Code Smells
bkeepers
PRO
340
58k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
0
100
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.3k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
89
Transcript
Transformer [1706.03762] Attention Is All You Need (arxiv.org)
Transformer 1.概要 2.導入と背景 3.モデルについて 4.Multi-Head Attention
1.概要 • Attention is all you need(2017) • 再帰や畳み込みなしの系列変換モデル •
並列化で短時間の訓練 • 様々なタスクに使えて,精度も高い. • 応用先;BERT,GPT-n,ViT • 成果:BLEUスコア100点満点中 英語→独 28.4 BLEU(SoTAより2ポイントup!) 英語→仏 41.8 BLEU(学習時の計算コスト1/4!)
2. 導入 RNNとエンコーダデコーダモデルが自然言語処理における中心 RNN:時系列データを扱うRecurrent Neural Networksとは - DeepAge
2. 導入 RNNは短期依存には対応できるものの,1000ステップのよう な⾧期の系列は学習できない → 「ゲート」と呼ばれる情報の 取捨選択機構を持ったLSTM (long-short term memory)が
提唱されたが逐次計算なので時間がかかる. (AttentionはRNNと一緒に使われてはいた) →Attentionのみのモデルtransformerを提唱 わかるLSTM ~ 最近の動向と共 に - Qiita
2. 背景 • 逐次計算をなくす目的のもと,RNNの代わりにCNNも使われた. • 並列処理をある程度可能にはしたが,O(N)またはO(logN)で計 算量が増えてしまい,より⾧文の依存関係は捉えにくく. • →RNNもCNNも使わないAttentionのみを用いた モデルtransformerを提唱する.計算量は文章の⾧さに応じず
O(1)に抑えた.
3.モデル 英文 →エンコーダ→デコーダ→ 独文の次単語予測(確率) ( ) ) エンコーダー:文章を意味にする デコーダー;意味を文章にする
大きく分けて三層 ・Multi-Head Attention ・Add&Norm ・Feed Forward: 他 ・Embedding 入力単語をベクトルに変換 ・Positional
Encoding ベクトルを足して位置情報を付加 3.モデル
4. Multi-Head Attention 4.1 Scaled Dot-Product Attention 4.2 Multi-Head Attention
どの情報に注目すべきか判断 して情報を処理する
4. Multi-Head Attention 全て横ベクトル 4.1 Scaled Dot-Product Attention
4. Multi-Head Attention 4.1 Scaled Dot-Product Attention まず一つのクエリについて 内積が並ぶ →内積は類似度的な性質を表す
二つのベクトルが 同じ向き→内積大 別向き→0 逆向き→内積-大 𝑸𝑻𝑲が何を表しているかを理解するのが大事 与えられたクエリに対してどのキーが似ているか
4. Multi-Head Attention 4.1 Scaled Dot-Product Attention 一つのクエリについて 次元の大きいベクトルは内積が大きくなって 逆伝搬できなくなるので,スケーリング
合計1の重みに変換
4. Multi-Head Attention Attentionではクエリとキーの類似度を計算して,それに応じた 重みでvalueを足している. 4.1 Scaled Dot-Product Attention 一つのクエリについて
一つのクエリについて 一連の流れとしては,内積取って類似度を計算.大きい次元で内積が大きくなる効果を補正. Softmaxとって重みに変換し,その重みに応じてvalueと掛け合わせる.
4. Multi-Head Attention 各qに対して関連のある KeyのValueが取り出さ れるイメージ →キーとバリューの学習 が大事 4.1 Scaled
Dot-Product Attention N個のクエリについて
4. Multi-Head Attention 4.2 Multi-Head Attention まず,head内にて,①行列かけてやる.②Attentionして出力はまた横ベクトルを 得る.③横につなげる.④最後行列かけて変換する. 論文の中ではh=8個用意.
4. Multi-Head Attention 4.2 Multi-Head Attention Xのどの部分を処理するか Xの注目の仕方を決める Xを回して出力を決める この時,横ベクトルの次元を
1/8にしている. つまり,行列をかけて注目の仕 方を変えているイメージ Q:入力のどの部分をみるか K:比較の仕方 V:出力を決定するのが Multi-Head Attention
4. Multi-Head Attention 4.2 Multi-Head Attention MultiHeadの方が単一のものより性能が高い。これは単一 ヘッドで深く潜在表現を処理するよりも、ヘッドが異な れば処理している潜在表現空間も異なる→MultiHeadで複 数の潜在表現空間を処理してまとめる方がより広範に豊
かな情報を取ってきてくれる
実験結果(時間あれば) •ヘッドが1つの時より複数ヘッドの方が良いが、ヘッド数が多すぎて も逆に性能劣化 •KeyとValueの次元小さいと性能劣化 •モデルサイズを大きくすると性能向上 •ドロップアウトやラベルスムージングは有効 •位置エンコードの代わりに位置を考慮したエンベディングを使って も性能は変わらなかった。
補足(説明を省いた所) • Embedding • Positional encoding • BEAMsearch • Masked
multi head attention • デコーダでのAttention • Softmax 縛り強め和=1, • Sigmoid全般に,比較的緩め
補足 • Masked multi head attention 予測すべき単語より後ろにある単語に対応する部分は-∞でうめ る.その後softmaxを使うので,ほぼ0となり情報はなし. ・デコーダでのAttention KeyとValueはエンコーダーの出力を持ってくる.
Qはデコーダーの出力(初回はBOS:begin of sequencというトー クンだけの入力)
参考 • [1706.03762] Attention Is All You Need (arxiv.org) •
https://www.youtube.com/watch?v=50XvMaWhiTY • 深層学習界の大前提Transformerの論文解説! - Qiita • 論文解説 Attention Is All You Need (Transformer) - ディープ ラーニングブログ (hatenablog.com)