SlideShare une entreprise Scribd logo
1  sur  57
Télécharger pour lire hors ligne
2020.10.10
出張!DeNAデータサイエンス輪講
田口 直弥
kaggle tweet コンペの話
2
田口 直弥 (@ihcgT_Ykchi)
# DeNA 18 新卒
# DeNA → MoT 出向中
# DRIVE CHART
# kaggle master (🥇*2 🥈*5)
自己紹介
3
今日の話は...
4
● データが与えられ、Leader Board 上での予測スコアを競うゲーム
○ train data, test data が存在
■ train data:
正解ラベルがあり、基本的にはこのデータを使って
学習・検証を行う。
■ test data:
正解ラベルがなく、train data 等を使って学習したモデルで
正解ラベルを予測。順位評価につかわれる。
この発表を理解する上で必要な kaggle のルール
train test
正解ラベルあり
正解ラベルなし学習・検証
このデータの
予測精度を競う
5
● データが与えられ、Leader Board 上での予測スコアを競うゲーム
○ public / private leader board が存在
■ public leader board:
コンペ期間中も見ることのできる順位表。public test set のみで
順位評価されており、最終順位には関係ないが参考値として
見ることができる。
■ private leader board:
コンペ終了直後に開示される順位表。private test set のみで
順位評価され、ここの順位が最終順位となる。
参加者は提出したファイルから、2つだけ private leader board におい
て順位反映されるものを選べる。
この発表を理解する上で必要な kaggle のルール
6
今日お話するコンペ https://www.kaggle.com/c/tweet-sentiment-extraction/overview
7
今日お話するコンペ
tweet のネガポジの根拠となるフレーズの抽出をしたい
https://www.kaggle.com/c/tweet-sentiment-extraction/overview
8
● 具体例
● どう役立つ?
○ ネガポジ分析をより詳細にできる?
○ kaggle 主催コンペなので...
tweet のネガポジの根拠となるフレーズの抽出
sentiment : positive
label : it was yummy
tweet : just finished dinner - it was yummy
PREDICT
GIVEN
9
● データの説明
○ textID: ID。
○ text: 予測をかける tweet。
○ sentiment: tweet の感情に関する情報。
○ selected_text: text の内 sentiment の根拠になるもの。
データ概要
10
● データ量
○ train (3.3 MB): 27,481 行
○ public test (307 KB): 3,534 行
○ private test (?): public の約 7/3 倍
データ概要
11
● sentiment が結構重要
○ neutral, positive, negative が存在
○ 予測精度に大きく寄与
○ sentiment == neutral の場合、text == selected_text になりがち
データ概要
12
● word-level Jaccard Score
○ ex1) pred/GT = I have a pen. / I have a pen. → 1.0
○ ex2) pred/GT = have / I have a pen. → ¼ = 0.25
評価指標
pred GT
pred GT
Jaccard =
https://www.kaggle.com/c/tweet-sentiment-extraction/overview/evaluation
13
チームのスコア遷移
※ 表示チームは private で金圏だったチーム、表示順は public score 順
14
参加前

15
チームのスコア遷移
※ 表示チームは private で金圏だったチーム、表示順は public score 順
16
● metric の実装ミスによる leader board update
○ evaluation page の python code と leader board back end の C# 実装が
異なっていたらしい...
○ Ahmet が python 版では変わらないはずの処理を sub して調べたらしい
(よく見つけたな...)
いくつか問題があったらしい https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/140942
https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/142073
17
● ラベルズレによる配布データ update
○ HTML codes 起因でラベルにズレが発生
いくつか問題があったらしい https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/142291
https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/140847
18
● ラベルズレによる配布データ update
○ index によるラベル付けと HTML code の表示の違い
● ラベルズレの例
○ & → & の違いで 8 文字分ズレている
いくつか問題があったらしい
kaggle annotator
tweet をラベル付けして欲しい ...!
ラベルは i 文字目 ~ j 文字目ダヨ
&, <, ...
&amp;, &lt;, ...
19
序 盤

20
チームのスコア遷移
※ 表示チームは private で金圏だったチーム、表示順は public score 順
21
● ほぼ 0 sub merge みたいな形
○ w/ @fuz_qwa, @Kenmatsu4, @yiemon773
いきなりチームマージ
22
● 基本的にはよくある NLP の学習パイプライン
○ ラベルと head は問題の解き方による
基礎パイプラインの構築
sentiment: positive
text: haha that’s way cool! Good morning
selected_text: haha that’s way cool!
add sentiment & BPE tokenize
training label
make label
text’: <s> positive </s> </s> haha that ‘ s way ….
embedding
...
...
...
...
... RoBERTa
Head
pred
calc loss & optimize weight
23
● この問題の解き方
○ ① : start/end 方式 (こちらがメジャー)
○ ② : segmentation 方式
基礎パイプラインの構築
※ これ以外にも例えば sentiment を予測対象とした場合の attention を使って解くとか色々と
やり方はある (https://www.kaggle.com/cdeotte/unsupervised-text-selection)
text’ : <s> positive </s> </s> haha that ‘ s way cool ! Good morning
start label : 0 0 0 0 1 0 00 0 0 0 0 0
selected_text: haha that‘s way cool!
end label : 0 0 0 0 0 0 00 0 0 1 0 0
text’ : <s> positive </s> </s> haha that ‘ s way cool ! Good morning
label : 0 0 0 0 1 1 11 1 1 1 0 0
selected_text: haha that‘s way cool!
24
● 予測には start/end 方式を使うが、学習時に segmentation 方式の
学習も同時に行う
○ それぞれの loss の比率をうまく調整すると結構スコアが向上
マルチタスク学習
RoBERTa
start
head
end
head
segmentation
head
start
label
end
label
segmentation
label
CE loss Lovasz-hinge loss
予測はこっちのみ
25
● cumax 関数 [Shen et al., 2018] の利用
○ softmax 後の確率分布を累積値にし、segmentation に使用
■ 予測に使う start/end head の出力に segmentation loss もかけることができる
○ (これベースでの思いつきではないが) 類似 discussion も存在
■ https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/153747
マルチタスク学習 https://openreview.net/pdf?id=B1l6qiR5F7
※ 正確にはこのときはスコアの伸びはなかったが、PP と合わせて最終的にスコアの伸びに寄与
26
● スコア寄与あり
○ LR scheduling
○ Larger batch
■ sentiment の違いによる精度ブレを吸収
○ EMA
■ batch/epoch 毎にモデルの重みを更新前後で重み付き平均。安定化に寄与。
○ 文頭、文末の . や , の数を調整
■ tokenizer の区切りと正解ラベルの整合性が取れない場合が多かった
その他やっていたこと
27
● スコア寄与なし
○ head の改良
○ soft labels, start/end distance loss 等
■ start/end フレームワークだと index のズレを考慮しきれない
ex. pred1, pred2 の違いを考慮しきれない
○ start end 反転対策
■ start, end の関係性に明示的な制約のないモデリングになっている
○ different models and tokenizers, manual pre-train
○ pseudo labeling (CV+, LB-)
■ soft, hard, leak free, for valid … 等色々試して CV は上がるが LB 悪化
その他やっていたこと
text : I really want to see UP! haha. Tooo cute! (:
label : Tooo cute!
GT start: 0 0 0 0 0 0 0 0 1 0 0 0
pred1 : 0 1 0 0 0 0 0 0 0 0 0 0
pred2 : 0 0 0 0 0 0 0 0 0 1 0 0
28
● スコア寄与なし
○ head の改良
○ soft labels, start/end distance loss 等
■ start/end フレームワークだと index のズレを考慮しきれない
ex. pred1, pred2 の違いを考慮しきれない
○ start end 反転対策
■ start, end の関係性に明示的な制約のないモデリングになっている
○ different models and tokenizers, manual pre-train
○ pseudo labeling (CV+, LB-)
■ soft, hard, leak free, for valid … 等色々試して CV は上がるが LB 悪化
その他やっていたこと
text : I really want to see UP! haha. Tooo cute! (:
label : Tooo cute!
GT start: 0 0 0 0 0 0 0 0 1 0 0 0
pred1 : 0 1 0 0 0 0 0 0 0 0 0 0
pred2 : 0 0 0 0 0 0 0 0 0 1 0 0
全くスコアが伸びない...😭
29
● どうやら magic で 0.716 から 0.724 まで上がるらしい
○ 当時の『銅 ~ 銀圏 → 金圏』の大ジャンプ
○ 気付いている人もいたけどうちのチームはたどり着けていなかった...
Magic スレの出現 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/154415
30
● 順位の上がり方から tkm-san は magic を見つけているっぽかった
○ 若干の申し訳無さもありつつ、マージして頂くことに...!
tkm san からのマージ依頼
31
中 盤

32
チームのスコア遷移
※ 表示チームは private で金圏だったチーム、表示順は public score 順
33
● (恐らく) kaggle の依頼時とデータ作成時のスペースの扱いズレ
● 明らかにおかしい例を解析したら見えてくる
Magic の概要
kaggle annotator
ラベルは 0 文字目 ~ 8 文字目ダヨ
Thank you, I have …
→ Thank you だな
tweet をラベル付けして欲しい ...!
(連続スペース数は 1 つに正規化)
Thank you, I have …
→ Thank you, I have ...
Thank you, I … の 0-8 か
→ 『Thank y』だな!
34
● magic の利用
1. スペース数などに基づく pre-process で selected_text のズレを解消
2. ズレを解消した selected_text を使って学習
3. 予測時にスペース数などに基づいて予測した selected_text をずらす
● ☆ 共通指標で post-process を評価できる kaggle notebook を作成
○ pre-process して作った正解ラベルに post-process をかける
■ 要は model が 100% 予測できた仮定をおいた post-process の開発
○ pre-process 前の selected_text vs post-process 後の予測 text の
Jaccard Score を測り改善したら sub
pre-post processing の開発 https://www.kaggle.com/tkm2261/pre-postprosessing-guc
35
● magic 改良 + 手動重み付けアンサンブルで金圏上位まで JUMP!
スコアの大幅改善
36
終 盤

37
チームのスコア遷移
※ 表示チームは private で金圏だったチーム、表示順は public score 順
38
● 特にアンサンブルは CV が改善するのに LB が悪くなる...
手詰まり...
39
● 他チームがどんどん追い上げてくる...
○ 特に日本人 kaggler 達の勢いが twitter から伝わってきてきつかった...
手詰まり...
best fitting にも
抜き返される...
40
● 最終日をギリギリのラインで迎える...
手詰まり...
41
● もうほぼ手はなくて、まだやりきれてなかったアンサンブルモデルの追加を
やっていた
努力の成果が...!
42
結果

43
● 見事 shake up して 5 位に!
○ kaggle master++
Private での順位
44
● 1st (Dark of the Moon)
○ char-based modeling
■ これにより、スペースズレもモデリングできる
■ E2E ではなく stacking により実現
上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159477
char-based modeling パイプライン (solution より引用)
45
● 1st (Dark of the Moon)
○ Custom loss (Jaccard-based Soft Labels)
■ ラベルをなまらし、KL divergence を optimize することで外す位置にも loss を
定義できる
■ 2 乗の項は smoothing のためにいれているらしい (?)
上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159477
ラベル生成の式 (solution より引用)
生成されるラベル例 (solution より引用)
46
● 1st (Dark of the Moon)
○ Multi-Sample Dropout
■ appendix 参照
○ Sequence Bucketing
■ 系列長の同程度のサンプルをできるだけまとめて batch を作る方法。
高速化に寄与。
○ QUEST 1st の pseudo labeling (https://www.kaggle.com/c/google-quest-challenge/discussion/129840)
■ fold 毎に pseudo labeling して validation set について leak を避けるやり方
■ いろいろ試したがうちのチームでは pseudo labeling が全く上手くいかなかった...
■ appendix 参照
○ Bertweet [Nguyen et al., 2020]
上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159477
47
● 2nd (Y.O. & m.y. & hiromu)
○ pre-post processing
○ QUEST 1st の解法にある学習可能な weight を使った中間表現抽出
■ appendix 参照
○ Multi-Sample Dropout
○ Sequence Bucketing
○ Sentiment Sampler
■ sentiment 毎の精度の違いに着目して sampler を作成
上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159310
Sentiment Sampler のイメージ (solution より引用)
48
● 2nd (Y.O. & m.y. & hiromu)
○ Reranking-model training
■ start/end 型の推論において、一度 index を予測した後に top-n の index から
それぞれ最良のものを選ぶモデルを再作成
1. top-n を予測し、それぞれについてselected_text との jaccard を計算
2. 1 の予測結果を元に 1 で計算した jaccard を回帰で求めるモデルを作成
3. 2 の jaccard を指標に最良の組み合わせを選ぶ
上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159310
49
● 3rd (Muggles united)
○ Reranking
○ E2E の char-level model
上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159910
E2E char-based modeling 概要 (solution より引用)
50
● 4th (Podpall)
○ 4 種類のマルチタスク学習
■ 開始・終了 index のラベルを 0.9、両隣を 0.05 として KL-divergence loss で学習
■ segmentation
■ sentiment によって意味付けした semantic segmentation (label 外は neutral)
■ sentiment を当てる (?)
上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159499
51
ブログ書いたのでより詳細な話はこちらで
● https://guchio3.hatenablog.com/entry/2020/06/20/115616
52
Youtube live もアーカイブあります
● https://www.youtube.com/watch?v=gdhqdDwLuU0&feature=youtu.be
53
● tweet コンペの背景・解法・チームでやったことをまとめました
● 結果は 5 th でした
● 良かったらブログ & YouTube Live 見てみて下さい :)
まとめ
54
APPENDIX

55
● network を分けて多様性をもたせた後 AVG する手法
○ 今回だと head 部分に使うイメージ
○ 最近 NLP コンペでよく見る
Multi-Sample Dropout [Inoue, 2019]
https://arxiv.org/abs/1905.09788
56
● hidden 0 ~ 11 全ての重み付き平均を head への入力とする
○ 重みも同時に学習する
○ 従来は hidden 11 だけ、や hidden 8 ~ 11 の単純平均など
Quest 1st の学習可能重み付き中間層平均
Bert Layer 0
hidden 0
Bert Layer 11
hidden 11
...
Bert Layer 1
hidden 1
embedded input text
+
w0
w1
w11
head
trainable
https://medium.com/kaggle-blog/the-3-ingredients-to-our-success-winners-dish-on-their-solution-to-googles-quest-q-a-labeling-c1a63014b88
57
● Cross Validation の fold model 毎に pseudo label を作成
○ fold i の pseudo label が fold i の validation set を学習に使ったモデル
から生成されるのを嫌うやり方
Quest 1st の pseudo labeling
https://medium.com/kaggle-blog/the-3-ingredients-to-our-success-winners-dish-on-their-solution-to-googles-quest-q-a-labeling-c1a63014b88

Contenu connexe

En vedette

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

En vedette (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

20201010 kaggle tweet コンペの話

  • 2. 2 田口 直弥 (@ihcgT_Ykchi) # DeNA 18 新卒 # DeNA → MoT 出向中 # DRIVE CHART # kaggle master (🥇*2 🥈*5) 自己紹介
  • 4. 4 ● データが与えられ、Leader Board 上での予測スコアを競うゲーム ○ train data, test data が存在 ■ train data: 正解ラベルがあり、基本的にはこのデータを使って 学習・検証を行う。 ■ test data: 正解ラベルがなく、train data 等を使って学習したモデルで 正解ラベルを予測。順位評価につかわれる。 この発表を理解する上で必要な kaggle のルール train test 正解ラベルあり 正解ラベルなし学習・検証 このデータの 予測精度を競う
  • 5. 5 ● データが与えられ、Leader Board 上での予測スコアを競うゲーム ○ public / private leader board が存在 ■ public leader board: コンペ期間中も見ることのできる順位表。public test set のみで 順位評価されており、最終順位には関係ないが参考値として 見ることができる。 ■ private leader board: コンペ終了直後に開示される順位表。private test set のみで 順位評価され、ここの順位が最終順位となる。 参加者は提出したファイルから、2つだけ private leader board におい て順位反映されるものを選べる。 この発表を理解する上で必要な kaggle のルール
  • 8. 8 ● 具体例 ● どう役立つ? ○ ネガポジ分析をより詳細にできる? ○ kaggle 主催コンペなので... tweet のネガポジの根拠となるフレーズの抽出 sentiment : positive label : it was yummy tweet : just finished dinner - it was yummy PREDICT GIVEN
  • 9. 9 ● データの説明 ○ textID: ID。 ○ text: 予測をかける tweet。 ○ sentiment: tweet の感情に関する情報。 ○ selected_text: text の内 sentiment の根拠になるもの。 データ概要
  • 10. 10 ● データ量 ○ train (3.3 MB): 27,481 行 ○ public test (307 KB): 3,534 行 ○ private test (?): public の約 7/3 倍 データ概要
  • 11. 11 ● sentiment が結構重要 ○ neutral, positive, negative が存在 ○ 予測精度に大きく寄与 ○ sentiment == neutral の場合、text == selected_text になりがち データ概要
  • 12. 12 ● word-level Jaccard Score ○ ex1) pred/GT = I have a pen. / I have a pen. → 1.0 ○ ex2) pred/GT = have / I have a pen. → ¼ = 0.25 評価指標 pred GT pred GT Jaccard = https://www.kaggle.com/c/tweet-sentiment-extraction/overview/evaluation
  • 13. 13 チームのスコア遷移 ※ 表示チームは private で金圏だったチーム、表示順は public score 順
  • 15. 15 チームのスコア遷移 ※ 表示チームは private で金圏だったチーム、表示順は public score 順
  • 16. 16 ● metric の実装ミスによる leader board update ○ evaluation page の python code と leader board back end の C# 実装が 異なっていたらしい... ○ Ahmet が python 版では変わらないはずの処理を sub して調べたらしい (よく見つけたな...) いくつか問題があったらしい https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/140942 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/142073
  • 17. 17 ● ラベルズレによる配布データ update ○ HTML codes 起因でラベルにズレが発生 いくつか問題があったらしい https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/142291 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/140847
  • 18. 18 ● ラベルズレによる配布データ update ○ index によるラベル付けと HTML code の表示の違い ● ラベルズレの例 ○ & → &amp; の違いで 8 文字分ズレている いくつか問題があったらしい kaggle annotator tweet をラベル付けして欲しい ...! ラベルは i 文字目 ~ j 文字目ダヨ &, <, ... &amp;, &lt;, ...
  • 20. 20 チームのスコア遷移 ※ 表示チームは private で金圏だったチーム、表示順は public score 順
  • 21. 21 ● ほぼ 0 sub merge みたいな形 ○ w/ @fuz_qwa, @Kenmatsu4, @yiemon773 いきなりチームマージ
  • 22. 22 ● 基本的にはよくある NLP の学習パイプライン ○ ラベルと head は問題の解き方による 基礎パイプラインの構築 sentiment: positive text: haha that’s way cool! Good morning selected_text: haha that’s way cool! add sentiment & BPE tokenize training label make label text’: <s> positive </s> </s> haha that ‘ s way …. embedding ... ... ... ... ... RoBERTa Head pred calc loss & optimize weight
  • 23. 23 ● この問題の解き方 ○ ① : start/end 方式 (こちらがメジャー) ○ ② : segmentation 方式 基礎パイプラインの構築 ※ これ以外にも例えば sentiment を予測対象とした場合の attention を使って解くとか色々と やり方はある (https://www.kaggle.com/cdeotte/unsupervised-text-selection) text’ : <s> positive </s> </s> haha that ‘ s way cool ! Good morning start label : 0 0 0 0 1 0 00 0 0 0 0 0 selected_text: haha that‘s way cool! end label : 0 0 0 0 0 0 00 0 0 1 0 0 text’ : <s> positive </s> </s> haha that ‘ s way cool ! Good morning label : 0 0 0 0 1 1 11 1 1 1 0 0 selected_text: haha that‘s way cool!
  • 24. 24 ● 予測には start/end 方式を使うが、学習時に segmentation 方式の 学習も同時に行う ○ それぞれの loss の比率をうまく調整すると結構スコアが向上 マルチタスク学習 RoBERTa start head end head segmentation head start label end label segmentation label CE loss Lovasz-hinge loss 予測はこっちのみ
  • 25. 25 ● cumax 関数 [Shen et al., 2018] の利用 ○ softmax 後の確率分布を累積値にし、segmentation に使用 ■ 予測に使う start/end head の出力に segmentation loss もかけることができる ○ (これベースでの思いつきではないが) 類似 discussion も存在 ■ https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/153747 マルチタスク学習 https://openreview.net/pdf?id=B1l6qiR5F7 ※ 正確にはこのときはスコアの伸びはなかったが、PP と合わせて最終的にスコアの伸びに寄与
  • 26. 26 ● スコア寄与あり ○ LR scheduling ○ Larger batch ■ sentiment の違いによる精度ブレを吸収 ○ EMA ■ batch/epoch 毎にモデルの重みを更新前後で重み付き平均。安定化に寄与。 ○ 文頭、文末の . や , の数を調整 ■ tokenizer の区切りと正解ラベルの整合性が取れない場合が多かった その他やっていたこと
  • 27. 27 ● スコア寄与なし ○ head の改良 ○ soft labels, start/end distance loss 等 ■ start/end フレームワークだと index のズレを考慮しきれない ex. pred1, pred2 の違いを考慮しきれない ○ start end 反転対策 ■ start, end の関係性に明示的な制約のないモデリングになっている ○ different models and tokenizers, manual pre-train ○ pseudo labeling (CV+, LB-) ■ soft, hard, leak free, for valid … 等色々試して CV は上がるが LB 悪化 その他やっていたこと text : I really want to see UP! haha. Tooo cute! (: label : Tooo cute! GT start: 0 0 0 0 0 0 0 0 1 0 0 0 pred1 : 0 1 0 0 0 0 0 0 0 0 0 0 pred2 : 0 0 0 0 0 0 0 0 0 1 0 0
  • 28. 28 ● スコア寄与なし ○ head の改良 ○ soft labels, start/end distance loss 等 ■ start/end フレームワークだと index のズレを考慮しきれない ex. pred1, pred2 の違いを考慮しきれない ○ start end 反転対策 ■ start, end の関係性に明示的な制約のないモデリングになっている ○ different models and tokenizers, manual pre-train ○ pseudo labeling (CV+, LB-) ■ soft, hard, leak free, for valid … 等色々試して CV は上がるが LB 悪化 その他やっていたこと text : I really want to see UP! haha. Tooo cute! (: label : Tooo cute! GT start: 0 0 0 0 0 0 0 0 1 0 0 0 pred1 : 0 1 0 0 0 0 0 0 0 0 0 0 pred2 : 0 0 0 0 0 0 0 0 0 1 0 0 全くスコアが伸びない...😭
  • 29. 29 ● どうやら magic で 0.716 から 0.724 まで上がるらしい ○ 当時の『銅 ~ 銀圏 → 金圏』の大ジャンプ ○ 気付いている人もいたけどうちのチームはたどり着けていなかった... Magic スレの出現 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/154415
  • 30. 30 ● 順位の上がり方から tkm-san は magic を見つけているっぽかった ○ 若干の申し訳無さもありつつ、マージして頂くことに...! tkm san からのマージ依頼
  • 32. 32 チームのスコア遷移 ※ 表示チームは private で金圏だったチーム、表示順は public score 順
  • 33. 33 ● (恐らく) kaggle の依頼時とデータ作成時のスペースの扱いズレ ● 明らかにおかしい例を解析したら見えてくる Magic の概要 kaggle annotator ラベルは 0 文字目 ~ 8 文字目ダヨ Thank you, I have … → Thank you だな tweet をラベル付けして欲しい ...! (連続スペース数は 1 つに正規化) Thank you, I have … → Thank you, I have ... Thank you, I … の 0-8 か → 『Thank y』だな!
  • 34. 34 ● magic の利用 1. スペース数などに基づく pre-process で selected_text のズレを解消 2. ズレを解消した selected_text を使って学習 3. 予測時にスペース数などに基づいて予測した selected_text をずらす ● ☆ 共通指標で post-process を評価できる kaggle notebook を作成 ○ pre-process して作った正解ラベルに post-process をかける ■ 要は model が 100% 予測できた仮定をおいた post-process の開発 ○ pre-process 前の selected_text vs post-process 後の予測 text の Jaccard Score を測り改善したら sub pre-post processing の開発 https://www.kaggle.com/tkm2261/pre-postprosessing-guc
  • 35. 35 ● magic 改良 + 手動重み付けアンサンブルで金圏上位まで JUMP! スコアの大幅改善
  • 37. 37 チームのスコア遷移 ※ 表示チームは private で金圏だったチーム、表示順は public score 順
  • 38. 38 ● 特にアンサンブルは CV が改善するのに LB が悪くなる... 手詰まり...
  • 39. 39 ● 他チームがどんどん追い上げてくる... ○ 特に日本人 kaggler 達の勢いが twitter から伝わってきてきつかった... 手詰まり... best fitting にも 抜き返される...
  • 43. 43 ● 見事 shake up して 5 位に! ○ kaggle master++ Private での順位
  • 44. 44 ● 1st (Dark of the Moon) ○ char-based modeling ■ これにより、スペースズレもモデリングできる ■ E2E ではなく stacking により実現 上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159477 char-based modeling パイプライン (solution より引用)
  • 45. 45 ● 1st (Dark of the Moon) ○ Custom loss (Jaccard-based Soft Labels) ■ ラベルをなまらし、KL divergence を optimize することで外す位置にも loss を 定義できる ■ 2 乗の項は smoothing のためにいれているらしい (?) 上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159477 ラベル生成の式 (solution より引用) 生成されるラベル例 (solution より引用)
  • 46. 46 ● 1st (Dark of the Moon) ○ Multi-Sample Dropout ■ appendix 参照 ○ Sequence Bucketing ■ 系列長の同程度のサンプルをできるだけまとめて batch を作る方法。 高速化に寄与。 ○ QUEST 1st の pseudo labeling (https://www.kaggle.com/c/google-quest-challenge/discussion/129840) ■ fold 毎に pseudo labeling して validation set について leak を避けるやり方 ■ いろいろ試したがうちのチームでは pseudo labeling が全く上手くいかなかった... ■ appendix 参照 ○ Bertweet [Nguyen et al., 2020] 上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159477
  • 47. 47 ● 2nd (Y.O. & m.y. & hiromu) ○ pre-post processing ○ QUEST 1st の解法にある学習可能な weight を使った中間表現抽出 ■ appendix 参照 ○ Multi-Sample Dropout ○ Sequence Bucketing ○ Sentiment Sampler ■ sentiment 毎の精度の違いに着目して sampler を作成 上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159310 Sentiment Sampler のイメージ (solution より引用)
  • 48. 48 ● 2nd (Y.O. & m.y. & hiromu) ○ Reranking-model training ■ start/end 型の推論において、一度 index を予測した後に top-n の index から それぞれ最良のものを選ぶモデルを再作成 1. top-n を予測し、それぞれについてselected_text との jaccard を計算 2. 1 の予測結果を元に 1 で計算した jaccard を回帰で求めるモデルを作成 3. 2 の jaccard を指標に最良の組み合わせを選ぶ 上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159310
  • 49. 49 ● 3rd (Muggles united) ○ Reranking ○ E2E の char-level model 上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159910 E2E char-based modeling 概要 (solution より引用)
  • 50. 50 ● 4th (Podpall) ○ 4 種類のマルチタスク学習 ■ 開始・終了 index のラベルを 0.9、両隣を 0.05 として KL-divergence loss で学習 ■ segmentation ■ sentiment によって意味付けした semantic segmentation (label 外は neutral) ■ sentiment を当てる (?) 上位解法 https://www.kaggle.com/c/tweet-sentiment-extraction/discussion/159499
  • 52. 52 Youtube live もアーカイブあります ● https://www.youtube.com/watch?v=gdhqdDwLuU0&feature=youtu.be
  • 53. 53 ● tweet コンペの背景・解法・チームでやったことをまとめました ● 結果は 5 th でした ● 良かったらブログ & YouTube Live 見てみて下さい :) まとめ
  • 55. 55 ● network を分けて多様性をもたせた後 AVG する手法 ○ 今回だと head 部分に使うイメージ ○ 最近 NLP コンペでよく見る Multi-Sample Dropout [Inoue, 2019] https://arxiv.org/abs/1905.09788
  • 56. 56 ● hidden 0 ~ 11 全ての重み付き平均を head への入力とする ○ 重みも同時に学習する ○ 従来は hidden 11 だけ、や hidden 8 ~ 11 の単純平均など Quest 1st の学習可能重み付き中間層平均 Bert Layer 0 hidden 0 Bert Layer 11 hidden 11 ... Bert Layer 1 hidden 1 embedded input text + w0 w1 w11 head trainable https://medium.com/kaggle-blog/the-3-ingredients-to-our-success-winners-dish-on-their-solution-to-googles-quest-q-a-labeling-c1a63014b88
  • 57. 57 ● Cross Validation の fold model 毎に pseudo label を作成 ○ fold i の pseudo label が fold i の validation set を学習に使ったモデル から生成されるのを嫌うやり方 Quest 1st の pseudo labeling https://medium.com/kaggle-blog/the-3-ingredients-to-our-success-winners-dish-on-their-solution-to-googles-quest-q-a-labeling-c1a63014b88