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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
shiba4839
October 01, 2024
Research
140
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
[論文紹介] Attention Is All You Need
学部4年生の7月ごろに行った論文発表の資料です。私自身初めての論文紹介でした。
shiba4839
October 01, 2024
More Decks by shiba4839
See All by shiba4839
[論文紹介] Extrovert or Introvert? GAN-Based Humanoid Upper-Body Gesture Generation for Different Impressions
shiba4839
0
21
[論文紹介] iTransformer: Inverted Transformers Are Effective for Time Series Forecasting
shiba4839
0
680
[輪講] Foundations of Cryptography 2.4章
shiba4839
0
76
[論文紹介] MoFusion: A Frame for Denoising-Diffusion-based Motion Synthesis
shiba4839
0
100
Other Decks in Research
See All in Research
IA for theory
gpeyre
0
270
重要だけど測れていないもの:高齢者ケアの見えない課題
theoriatec2024
0
410
データサイエンティストの就労意識~2015 → 2026 一般(個人)会員アンケートより
datascientistsociety
PRO
0
240
Unified Audio Source Separation (Defense Slides)
kohei_1979
1
630
LLM Compute Infrastructure Overview
karakurist
2
1.5k
LLM の Attention 機構まとめ — 数式・計算量・メモリ
puwaer
8
2.3k
typst の使い方:言語学を研究する学生のために
gitomochang
0
520
某助成金プロジェクト採択に向けて企業研究所のアウトリーチ専任者がやったこと
afroscript
0
110
言語モデルから言語について語る際に押さえておきたいこと
eumesy
PRO
6
2.5k
The Landscape of Agentic Reinforcement Learning for LLMs: A Survey
shunk031
4
1.1k
「行ける・行けない表」による地域公共交通の性能評価
bansousha
0
170
Sleuthcon Keynote - How Cybercriminals (ab)use AI
fr0gger
0
260
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Code Reviewing Like a Champion
maltzj
528
40k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
Chasing Engaging Ingredients in Design
codingconduct
0
240
The Mindset for Success: Future Career Progression
greggifford
PRO
0
420
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
220
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Optimizing for Happiness
mojombo
378
71k
Mind Mapping
helmedeiros
PRO
1
280
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
350
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)