SlideShare una empresa de Scribd logo
1 de 48
Kaggle参加報告:
Quora Insincere Questions Classification
(4th place solution)
藤川 和樹
AIシステム部 AI研究開発第三グループ
株式会社 ディー・エヌ・エー
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Top 3 solutions
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Top 3 solutions
コンペティション概要(問題設定)
• Quoraに投稿された質問文で、不適切な質問かどうかを識別するタスク(2値分類)
• 猥褻的な表現を含む質問(Bag-of-wordsでもある程度識別できそう)
• Which races have the smallest penis?
• Would you date a girl who had sex with a horse or a bull?
• 差別的、攻撃的な質問(単語レベルでは判断が難しそう)
• Do all women tell lies?
• Why do Indians not gives a shit on Pakistan?
• 事実に基づかない質問(単語レベルでは判断が難しそう)
• Why did an 0bama fan kill ovr 50 people in Las Vegas?
• Why is the US so good at brainwashing?
• 正例が少ない不均衡なクラス分類問題
• 負例 : 正例 ≒ 15 : 1
• 評価指標 : F1 score
コンペティション概要(制約条件)
• Kernel only competition
• データロード、学習、予測といった処理全てを2hで実行可能な1枚のKernelを提出
• 2nd stage制で、締切後に差し替えられたtest setで再計算してリスコアリングされる
• インターネットアクセス禁止
• 外部のデータソースをDLして事前学習する、学習済みモデルを利用する等はNG
• ホワイトリストとして、4種の学習済みword embeddingのみ利用可能
コンペティションでのポイント
• 精度と計算コストのバランスが取れたモデルの選択
• 少数の大きなモデルで単体の性能勝負 vs 多数の小さなモデルでアンサンブル勝負
• 計算コスト削減方法
• 前処理・訓練時に行う処理をいかに効率化できるか
• 提供された学習済みword embeddingの活用法、含まれない単語の処理方法
• 表記揺れレベルの差異、ドメインの差分をどう埋めるか
• Public LBのスコアだけに頼らないsubmission戦略
• public test set は private test set と比較してデータが少なく、スコアが信用できない
(public: 5.6万件 vs private: 37.6万件)
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Top 3 solutions
主要カーネル解説 (Pytorch starter by Heng Zheng)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
Classification model
average
Word features
(300d)
BiLSTM → BiGRU
(2 * 60d)
1 Layer MLP
(480d)
concat
Raw texts
以下をconcat (4 * 2 * 60d)
• 1st layer weighted sum
with attention
• 2nd layer weighted sum
with attention
• 2nd layer avg pooling
• 2nd layer max pooling
Prediction
(1d)
BCE Loss
concat
主要カーネル解説 (Pytorch starter by Heng Zheng)
Normalize
&
Tokenize
Raw texts
① テキストのNormalize, Tokenize
• Normalize
• 小文字化(ex. Trump → trump)
• 句読点前後にスペース追加(ex. pen. → pen .)
• 数字を特殊文字に変換(ex. 2019 → ####)
• ルールベースによる表記揺れ解消(ex. isn’t → is not)
• Keras Tokenizerによる特殊文字除去(ex. ####th → th)
• Tokenize
• spaceでsplit
主要カーネル解説 (Pytorch starter by Heng Zheng)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
averageRaw texts
② 下記方針によるWord embeddingの構築
高頻度 低頻度
有
Glove, Paragramの
平均ベクトル
単語自体を消去
無
単語毎に作成した
乱数ベクトル
単語自体を消去
Quoraデータセット中の単語の出現頻度
Glove,Paragram
(Pretrainedvectors)
での出現有無
主要カーネル解説 (Pytorch starter by Heng Zheng)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
Classification model
average
Word features
(300d)
BiLSTM → BiGRU
(2 * 60d)
1 Layer MLP
(480d)
concat
Raw texts
以下をconcat (4 * 2 * 60d)
• 1st layer weighted sum
with attention
• 2nd layer weighted sum
with attention
• 2nd layer avg pooling
• 2nd layer max pooling
Prediction
(1d)
concat
③ 構築されたWord featuresを入力に、Classification modelを構築
主要カーネル解説 (Pytorch starter by Heng Zheng)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
Classification model
average
Word features
(300d)
BiLSTM → BiGRU
(2 * 60d)
1 Layer MLP
(480d)
concat
Raw texts
以下をconcat (4 * 2 * 60d)
• 1st layer weighted sum
with attention
• 2nd layer weighted sum
with attention
• 2nd layer avg pooling
• 2nd layer max pooling
Prediction
(1d)
BCE Loss
concat
④ Binary Cross Entropy Loss を最小化するように
ネットワーク全体を学習
(ただし、Word featuresは固定)
主要カーネル解説 (Pytorch starter by Heng Zheng)
⑤ 5-Fold CVで行って5つのモデルを構築し、
最終予測値は5つのモデルの予測値の平均を使う
dataset fold: 1
dataset fold: 2
dataset fold: 3
dataset fold: 4
dataset fold: 5
dataset
model: 1 prediction: 1
model: 2 prediction: 2
model: 3 prediction: 3
model: 4 prediction: 4
model: 5 prediction: 5
prediction ∈ ℝ
主要カーネル解説 (Pytorch starter by Heng Zheng)
dataset fold: 1
dataset fold: 2
dataset fold: 3
dataset fold: 4
dataset fold: 5
dataset
model: 1 prediction: 1
model: 2 prediction: 2
model: 3 prediction: 3
model: 4 prediction: 4
model: 5 prediction: 5
prediction ∈ ℝ
prediction ∈ {0, 1}
閾値による
binning
⑥ 訓練データで最適な閾値探索を行い、binningする
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Top 3 solutions
My Solution 概要
ソースも公開しているので興味があればご覧下さい!
https://github.com/k-fujikawa/Kaggle-Quora-
Insincere-Questions-Classification
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Pytorch starter 微修正(LB: 0.691 → 0.705)
• Word embedding fine-tuning(LB: 0.705 → 0.708)
• 単語・文単位の統計的特徴量(LB: 0.708 → 0.708)
• Word embedding sampling(LB: 0.708 → 0.710)
• モデルの評価
• Top 3 solutions
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Pytorch starter 微修正(LB: 0.691 → 0.705)
• Word embedding fine-tuning(LB: 0.705 → 0.708)
• 単語・文単位の統計的特徴量(LB: 0.708 → 0.708)
• Word embedding sampling(LB: 0.708 → 0.710)
• モデルの評価
• Top 3 solutions
Pytorch starter の微修正(LB: 0.691 → 0.705)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
Classification model
average
Word features
(300d)
BiLSTM → BiGRU
(2 * 60d)
1 Layer MLP
(480d)
concat
Raw texts
以下をconcat (4 * 2 * 60d)
• 1st layer weighted sum
with attention
• 2nd layer weighted sum
with attention
• 2nd layer avg pooling
• 2nd layer max pooling
Prediction
(1d)
BCE Loss
concat
Pytorch starter の微修正(LB: 0.691 → 0.705)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
Classification model
average
Word features
(300d)
BiLSTM → BiGRU
(2 * 60d)
1 Layer MLP
(480d)
concat
Raw texts
以下をconcat (4 * 2 * 60d)
• 1st layer weighted sum
with attention
• 2nd layer weighted sum
with attention
• 2nd layer avg pooling
• 2nd layer max pooling
Prediction
(1d)
BCE Loss
concat
① 前処理の小さな修正
• ルールベースの微修正
• before: I‘d’ve → I would’ve
• after: I‘d’ve → I would have
• 句読点スペースとルールベースの順序
を反転
• before: isn’t → isn ‘ t
• after: isn’t → is not
• 数字の特殊文字の前後にスペース追加
• before: 1990th → ####th
• after: 1990th → #### th
• Keras Tokenizerのfilters処理を除外
• before: #### th → th
• after: #### th → #### th
Pytorch starter の微修正(LB: 0.691 → 0.705)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
averageRaw texts
Classification model
Extra Features
(6d)
2 Layer MLP with BN
(480d)
Prediction
(1d)
BCE Loss
2nd layer max pooling
(2 * 128d)
Word features
(300d)
2 Layer BiLSTM
(2 * 128d)
② モデルの入れ替え
BiLSTM + BiGRU (2 * 60d) → 2 Layer BiLSTM (2 * 128d)
4種のPooling → Max pooling → 2 Layer MLP with BN
Pytorch starter の微修正(LB: 0.691 → 0.705)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
averageRaw texts
③ Word embeddingの構築方法を変更
高頻度 低頻度
有
Glove, Paragramの
平均ベクトル
単語自体を消去
無
単語毎に作成した
乱数ベクトル
単語自体を消去
Quoraデータセット中の単語の出現頻度
Glove,Paragram
(Pretrainedvectors)
での出現有無
高頻度 低頻度
有
Glove, Paragramの
平均ベクトル
Glove, Paragramの
平均ベクトル
無
単語毎に作成した
乱数ベクトル
(CV毎に生成)
0ベクトル
Pytorch starter の微修正(LB: 0.691 → 0.705)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
averageRaw texts
Classification model
2 Layer MLP w/ BN
(480d)
Prediction
(1d)
BCE Loss
2nd layer max pooling
(2 * 128d)
Word features
(300d)
2 Layer BiLSTM
(2 * 128d)
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Pytorch starter 微修正(LB: 0.691 → 0.705)
• Word embedding fine-tuning(LB: 0.705 → 0.708)
• 単語・文単位の統計的特徴量(LB: 0.708 → 0.708)
• Word embedding sampling(LB: 0.708 → 0.710)
• モデルの評価
• Top 3 solutions
データセット中の単語例
高頻度 低頻度
含まれる
• the, what
(一般語)
• obama, trump
(Wikipediaに出現する単語)
• compresses
(一般語の変形)
• 0bama, germnay
(typo)
• 2sinxcosx, cython
(一部の専門用語)
含まれない
• coinbase, gdpr, brexit
(新語)
• tensorflow, kubernetes
(専門用語)
• germeny, fathar, f*ck
(typo)
• 5gfwdhf4rz
(ハッシュ値)
• ॡ
(外国語)
Quoraデータセット中の単語の出現頻度
Glove,Paragram
(Pretrainedvectors)
データセット中の単語例
高頻度 低頻度
含まれる
• the, what
(一般語)
• obama, trump
(Wikipediaに出現する単語)
• compresses
(一般語の変形)
• 0bama, germnay
(typo)
• 2sinxcosx, cython
(一部の専門用語)
含まれない
• coinbase, gdpr, brexit
(新語)
• tensorflow, kubernetes
(専門用語)
• germeny, fathar, f*ck
(typo)
• 5gfwdhf4rz
(ハッシュ値)
• ॡ
(外国語)
Quoraデータセット中の単語の出現頻度
Glove,Paragram
(Pretrainedvectors)
Pretrained Vectorが持つ情報
を活用したい
データセット中の単語例
高頻度 低頻度
含まれる
• the, what
(一般語)
• obama, trump
(Wikipediaに出現する単語)
• compresses
(一般語の変形)
• 0bama, germnay
(typo)
• 2sinxcosx, cython
(一部の専門用語)
含まれない
• coinbase, gdpr, brexit
(新語)
• tensorflow, kubernetes
(専門用語)
• germeny, fathar, f*ck
(typo)
• 5gfwdhf4rz
(ハッシュ値)
• ॡ
(外国語)
Quoraデータセット中の単語の出現頻度
Glove,Paragram
(Pretrainedvectors)
Quoraデータセットだけでも
ある程度学習できるはず
Word embeddingの更新戦略例
計算コスト 単語表現学習
(Train)
単語表現学習
(Test)
モデル例
Embeddingのみ
教師なし学習
◎ ○ ○ Word2Vec,
FastText
(unsupervised)
Embeddingのみ
半教師あり学習
○ ◎ ○ Doc2Vec,
FastText
Embeddingのみ
教師あり学習
◎ ○? ☓ Doc2Vec,
FastText
(supervised)
NN全体を
半教師あり学習
☓ ◎ ○ Masked LM +
教師あり学習
NN全体を
教師あり学習
☓(all epochs)
○(last epoch)
○? ☓ Embedding
unfreeze
Word embeddingの更新戦略例
計算コスト 単語表現学習
(Train)
単語表現学習
(Test)
モデル例
Embeddingのみ
教師なし学習
◎ ○ ○ Word2Vec,
FastText
(unsupervised)
Embeddingのみ
半教師あり学習
○ ◎ ○ Doc2Vec,
FastText
Embeddingのみ
教師あり学習
◎ ○? ☓ Doc2Vec,
FastText
(supervised)
NN全体を
半教師あり学習
☓ ◎ ○ Masked LM +
教師あり学習
NN全体を
教師あり学習
☓(all epochs)
○(last epoch)
○? ☓ Embedding
unfreeze
計算コスト重視でEmbeddingのみ
教師なし学習する戦略を選択
Word embeddingの更新戦略例
計算コスト 単語表現学習
(Train)
単語表現学習
(Test)
モデル例
Embeddingのみ
教師なし学習
◎ ○ ○ Word2Vec,
FastText
(unsupervised)
Embeddingのみ
半教師あり学習
○ ◎ ○ Doc2Vec,
FastText
Embeddingのみ
教師あり学習
◎ ○? ☓ Doc2Vec,
FastText
(supervised)
NN全体を
半教師あり学習
☓ ◎ ○ Masked LM +
教師あり学習
NN全体を
教師あり学習
☓(all epochs)
○(last epoch)
○? ☓ Embedding
unfreeze
FastText supervisedのみ、というのも
試したが簡単には上手くいかなかった
Word embeddingの更新戦略例
計算コスト 単語表現学習
(Train)
単語表現学習
(Test)
モデル例
Embeddingのみ
教師なし学習
◎ ○ ○ Word2Vec,
FastText
(unsupervised)
Embeddingのみ
半教師あり学習
○ ◎ ○ Doc2Vec,
FastText
Embeddingのみ
教師あり学習
◎ ○? ☓ Doc2Vec,
FastText
(supervised)
NN全体を
半教師あり学習
☓ ◎ ○ Masked LM +
教師あり学習
NN全体を
教師あり学習
☓(all epochs)
○(last epoch)
○? ☓ Embedding
unfreeze
モデルも計算コスト重視でWord2Vec
(CBOW)を選択
(Char N-gramは利用しない)
予備実験: Word embedding fine-tuning
• 以下3モデルを構築し、各モデルでベンチマーク単語と類似しているとされる
Top10件の単語を確認する
• Glove only
• 提供された事前学習モデル(Glove)をそのまま利用
• Word2Vec Scratch
• 事前学習モデルを使わずスクラッチでCBOWを 5 epoch 学習する
• Word2Vec Fine-tuning
• 事前学習モデル(Glove)を初期値にCBOWを 5 epoch 学習する
予備実験結果: Word embedding fine-tuning
• Quora 高頻度語 & Glove 既知語
• Glove: ○、Scratch: ○、Finetune: ○
obama(DF: 2838) cosx(DF: 98)
Glove, Scratch, Finetune どれでも良さそう
予備実験結果: Word embedding fine-tuning
• Quora 高頻度語 & Glove 未知語
• Glove: ☓、Scratch: ○、Finetune: ○
coinbase(DF: 169) kubernetes(DF: 30)
Gloveではヒットしない単語ベクトルが
Scratch, Finetune で上手く学習できてそう
予備実験結果: Word embedding fine-tuning
• Quora 低頻度語 & Glove 既知語
• Glove: ○、Scratch: ☓、Finetune: ○
0bama(DF: 5) compresses(DF: 2)
Scratchでは学習が困難だが、
Glove では上手く表現できており、
Finetuneしても悪影響は無さそう
予備実験結果: Word embedding fine-tuning
• Quora 低頻度語 & Glove 未知語
• Glove: ☓、Scratch: △~☓、Finetune: △~☓
xgboost(DF: 8) germeny(DF: 2)
Glove(0ベクトル)よりはマシな場合も
あるが、悪影響が無視できなさそう
Word embedding fine-tuning (LB: 0.705 → 0.708)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
averageRaw texts Glove & Paragram
(300d)
Finetuned
(300d)
Word2Vec
fine-tuning
average
Glove & Paragram
with Finetuned
(300d)
Word embeddingの構築方法を変更
高頻度 低頻度
有
Glove, Paragramの
平均ベクトル
Glove, Paragramの
平均ベクトル
無
単語毎に作成した
乱数ベクトル
0ベクトル
Quoraデータセット中の単語の出現頻度
Glove,Paragram
(PretrainedVectors)
での出現有無
高頻度 低頻度
有
下記ベクトルを平均
• Glove, Paragramの
平均ベクトル
• Word2Vec Finetune
下記ベクトルを平均
• Glove, Paragramの
平均ベクトル
• Word2Vec Finetune
無
下記ベクトルを平均
• 単語毎に作成した
乱数ベクトル
• Word2Vec Finetune
0ベクトル
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Pytorch starter 微修正(LB: 0.691 → 0.705)
• Word embedding fine-tuning(LB: 0.705 → 0.708)
• 単語・文単位の統計的特徴量(LB: 0.708 → 0.708)
• Word embedding sampling(LB: 0.708 → 0.710)
• モデルの評価
• Top 3 solutions
単語・文単位の統計的特徴量(LB: 0.708 → 0.708)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
averageRaw texts
Classification model
Extra Features
(6d)
2 Layer MLP w/ BN
(480d)
Prediction
(1d)
BCE Loss
concat2nd layer max pooling
(2 * 128d)
Word features
(302d)
2 Layer BiLSTM
(2 * 128d)
Glove & Paragram
(300d)
Finetuned
(300d)
Word2Vec
fine-tuning
average
Glove & Paragram
with Finetuned
(300d)
Extra Features
(6d)
Extra Features
[is_unk, IDF] (2d)
単語・文単位の統計的特徴量を追加
• 以下の特徴量を算出し、単語・文の特徴ベクトルに連結した
• 単語特徴量: Glove未知語か否か、IDF
• 文特徴量: 文字数、単語数等のKernelで議論されていた特徴量
• Localでは軽微な改善があったものの、Public LBでは変化がなかった
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Pytorch starter 微修正(LB: 0.691 → 0.705)
• Word embedding fine-tuning(LB: 0.705 → 0.708)
• 単語・文単位の統計的特徴量(LB: 0.708 → 0.708)
• Word embedding sampling(LB: 0.708 → 0.710)
• モデルの評価
• Top 3 solutions
Word Embedding sampling(LB: 0.708 → 0.710)
Glove
(300d)
Paragram
(300d)
Words
Normalize
&
Tokenize
Build word features
Glove & Paragram
(300d)
averageRaw texts
Classification model
Extra Features
(6d)
1 Layer MLP
(480d)
Prediction
(1d)
BCE Loss
concat2nd layer max pooling
(2 * 128d)
Word features
(302d)
2 Layer BiLSTM
(2 * 128d)
Glove & Paragram
(300d)
Finetuned
(300d)
Word2Vec
fine-tuning
concat
Glove & Paragram
with Finetuned
(600d)
Extra Features
(6d)
Extra Features
[is_unk, IDF] (2d)
Glove & Paragram
with Finetuned
(400d)
sampling
per CV
Word embeddingの構築方法を変更
• Fine-tuning前後のベクトル平均は若干怪しさが残っていた
• 特にQuora高頻度 & Pretrained Vector非搭載の単語
• 一方Fine-tuning後のベクトルのみ利用するよりも、平均したベクトルを
利用した方が実験的に良いスコアを示していた
• Fine-tuning前後のWord Embeddingを連結した600次元のベクトルから
400次元をCV毎にサンプリングして扱うように変更
• 600次元を扱うのは計算時間的に厳しかった
• モデル間の多用性を上げてアンサンブル後の性能を改善することが狙い
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Pytorch starter 微修正(LB: 0.691 → 0.705)
• Word embedding fine-tuning(LB: 0.705 → 0.708)
• 単語・文単位の統計的特徴量(LB: 0.708 → 0.708)
• Word embedding sampling(LB: 0.708 → 0.710)
• モデルの評価
• Top 3 solutions
モデルの評価方法(背景)
• アンサンブル後のスコアはLocal CVでは測れないため、CV外のデータで評価する必要があった
• Embedding sampling は Local CV は低くてもアンサンブル後にスコアが高くなる
可能性があるのではないかと考えていた
• Public LBのスコアは件数が少なく、乱数シードを変えただけで大きく変動してしまうため、
別の指標が必要だった
モデルの評価方法
• Holdout & CV を乱数シードを変えて複数回実施し、平均と標準偏差で評価
• 上記のスコア平均が高かった実験設定を選択し、同じ実験設定でCVのみ行って提出
Train 0 (CVに利用) Test 0
Seed: 0 でシャッフル
Train 1 (CVに利用) Test 1
Seed: 1 でシャッフル
Train 2 (CVに利用) Test 2
Seed: 2 でシャッフル
Train 3 (CVに利用) Test 3
Seed: 3 でシャッフル
Train 4 (CVに利用) Test 4
Seed: 4 でシャッフル
Test 0 ~ 4 の平均・標準偏差
Train set(ラベル付き)
Agenda
• コンペティション概要
• 主要Kernel解説 (Pytorch starter by Heng Zheng)
• My solution
• Top 3 solutions
1st Place Solution (The Zoo)
• Model
• Embedding (300) → BiLSTM (128) → 1DCNN (64) → MLP (128)
• Embeddings
• 0.7 * Glove + 0.3 * Paragram(重みをCVで選択)
• アンサンブル・閾値選択
• 10-fold CV, Rank Average
• Fold毎に閾値と対応するF1を計測し、
最小値が最大になる値を閾値として選択
2nd Place Solution (takapt)
• Model
• Embedding (668) → BiGRU (128) → MLP (64)
• Embeddings
• Glove (300), WikiNews (300), FastText scratch (64) 単語Feature (4) のconcat (668)
• 単語Feature: [all upper chars?, first char upper?, only first char upper?, OOV?]
• Statical Features
• 単語数、ユニーク単語数、文字数、大文字数、Bag of characters
• アンサンブル・閾値選択
• 6-fold CV, Local CVで閾値をFix(0.36)
3rd Place Solution (Guanshuo Xu)
• Model
• Embedding (600) → BiGRU (256) → BiGRU (128) → Linear (64)
• Embeddings
• Model1: Glove (300), FastText (300) のconcat
• Model2: Glove (300), Paragram (300) のconcat
• WordVectorの対応付けに、stemming, lemmatizing, spell correction等を適用
• アンサンブル・閾値選択
• 2モデルのsnapshot ensemble: 2 * (0.15 * 3rd epoch + 0.35 * 4th epoch)
• Validation setは取らない
• 閾値はLocal CVで決定(0.35)

Más contenido relacionado

La actualidad más candente

MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎Naruhiko Ogasawara
 
Quora Insincere Questions 10th Place Solution & 昔話
Quora Insincere Questions 10th Place Solution & 昔話Quora Insincere Questions 10th Place Solution & 昔話
Quora Insincere Questions 10th Place Solution & 昔話ssuser4a5291
 
MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法Tetsutaro Watanabe
 
リーンなコードを書こう:実践的なオブジェクト指向設計
リーンなコードを書こう:実践的なオブジェクト指向設計リーンなコードを書こう:実践的なオブジェクト指向設計
リーンなコードを書こう:実践的なオブジェクト指向設計増田 亨
 
このスライドには間違いが含まれています。修正版をご覧ください
このスライドには間違いが含まれています。修正版をご覧くださいこのスライドには間違いが含まれています。修正版をご覧ください
このスライドには間違いが含まれています。修正版をご覧くださいssuser4a5291
 
Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介Hiroshi Tokumaru
 
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJPYahoo!デベロッパーネットワーク
 
知って得するWebで便利なpostgre sqlの3つの機能
知って得するWebで便利なpostgre sqlの3つの機能知って得するWebで便利なpostgre sqlの3つの機能
知って得するWebで便利なpostgre sqlの3つの機能Soudai Sone
 
ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装infinite_loop
 
AutoEncoderで特徴抽出
AutoEncoderで特徴抽出AutoEncoderで特徴抽出
AutoEncoderで特徴抽出Kai Sasaki
 
SQL Server Performance Tuning Essentials
SQL Server Performance Tuning EssentialsSQL Server Performance Tuning Essentials
SQL Server Performance Tuning EssentialsMasaki Hirose
 
ソーシャルゲームのためのデータベース設計
ソーシャルゲームのためのデータベース設計ソーシャルゲームのためのデータベース設計
ソーシャルゲームのためのデータベース設計Yoshinori Matsunobu
 
第45回elasticsearch勉強会 BERTモデルを利用した文書分類
第45回elasticsearch勉強会 BERTモデルを利用した文書分類第45回elasticsearch勉強会 BERTモデルを利用した文書分類
第45回elasticsearch勉強会 BERTモデルを利用した文書分類shinhiguchi
 
RL4J で始める深層強化学習
RL4J で始める深層強化学習RL4J で始める深層強化学習
RL4J で始める深層強化学習Yuki Tagami
 
Start Deep Reinforcement Learning with RL4J
Start Deep Reinforcement Learning with RL4JStart Deep Reinforcement Learning with RL4J
Start Deep Reinforcement Learning with RL4JYuki Tagami
 

La actualidad más candente (18)

MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎MongoDB very basic (Japanese) / MongoDB基礎の基礎
MongoDB very basic (Japanese) / MongoDB基礎の基礎
 
Quora Insincere Questions 10th Place Solution & 昔話
Quora Insincere Questions 10th Place Solution & 昔話Quora Insincere Questions 10th Place Solution & 昔話
Quora Insincere Questions 10th Place Solution & 昔話
 
MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法MongoDBが遅いときの切り分け方法
MongoDBが遅いときの切り分け方法
 
リーンなコードを書こう:実践的なオブジェクト指向設計
リーンなコードを書こう:実践的なオブジェクト指向設計リーンなコードを書こう:実践的なオブジェクト指向設計
リーンなコードを書こう:実践的なオブジェクト指向設計
 
MongoDB3.2の紹介
MongoDB3.2の紹介MongoDB3.2の紹介
MongoDB3.2の紹介
 
このスライドには間違いが含まれています。修正版をご覧ください
このスライドには間違いが含まれています。修正版をご覧くださいこのスライドには間違いが含まれています。修正版をご覧ください
このスライドには間違いが含まれています。修正版をご覧ください
 
Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介Rails SQL Injection Examplesの紹介
Rails SQL Injection Examplesの紹介
 
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
第16回Lucene/Solr勉強会 – ランキングチューニングと定量評価 #SolrJP
 
知って得するWebで便利なpostgre sqlの3つの機能
知って得するWebで便利なpostgre sqlの3つの機能知って得するWebで便利なpostgre sqlの3つの機能
知って得するWebで便利なpostgre sqlの3つの機能
 
ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装
 
AutoEncoderで特徴抽出
AutoEncoderで特徴抽出AutoEncoderで特徴抽出
AutoEncoderで特徴抽出
 
SQL Server Performance Tuning Essentials
SQL Server Performance Tuning EssentialsSQL Server Performance Tuning Essentials
SQL Server Performance Tuning Essentials
 
HCL Nomad と OCR
HCL Nomad と OCRHCL Nomad と OCR
HCL Nomad と OCR
 
ソーシャルゲームのためのデータベース設計
ソーシャルゲームのためのデータベース設計ソーシャルゲームのためのデータベース設計
ソーシャルゲームのためのデータベース設計
 
第45回elasticsearch勉強会 BERTモデルを利用した文書分類
第45回elasticsearch勉強会 BERTモデルを利用した文書分類第45回elasticsearch勉強会 BERTモデルを利用した文書分類
第45回elasticsearch勉強会 BERTモデルを利用した文書分類
 
良いコードとは
良いコードとは良いコードとは
良いコードとは
 
RL4J で始める深層強化学習
RL4J で始める深層強化学習RL4J で始める深層強化学習
RL4J で始める深層強化学習
 
Start Deep Reinforcement Learning with RL4J
Start Deep Reinforcement Learning with RL4JStart Deep Reinforcement Learning with RL4J
Start Deep Reinforcement Learning with RL4J
 

Similar a Kaggle参加報告: Quora Insincere Questions Classification

Azure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etc
Azure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etcAzure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etc
Azure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etcYoichi Kawasaki
 
[第2版]Python機械学習プログラミング 第8章
[第2版]Python機械学習プログラミング 第8章[第2版]Python機械学習プログラミング 第8章
[第2版]Python機械学習プログラミング 第8章Haruki Eguchi
 
Abstractive Text Summarization @Retrieva seminar
Abstractive Text Summarization @Retrieva seminarAbstractive Text Summarization @Retrieva seminar
Abstractive Text Summarization @Retrieva seminarKodaira Tomonori
 
Getting test world
Getting test worldGetting test world
Getting test worldhayabusa333
 
WordNetで作ろう! 言語横断検索サービス
WordNetで作ろう! 言語横断検索サービスWordNetで作ろう! 言語横断検索サービス
WordNetで作ろう! 言語横断検索サービスShintaro Takemura
 
10分で分かるr言語入門ver2.14 15 0905
10分で分かるr言語入門ver2.14 15 090510分で分かるr言語入門ver2.14 15 0905
10分で分かるr言語入門ver2.14 15 0905Nobuaki Oshiro
 
Jubatusでマルウェア分類
Jubatusでマルウェア分類Jubatusでマルウェア分類
Jubatusでマルウェア分類Shuzo Kashihara
 
Stan勉強会資料(前編)
Stan勉強会資料(前編) Stan勉強会資料(前編)
Stan勉強会資料(前編) daiki hojo
 
10分で分かるr言語入門ver2.15 15 1010
10分で分かるr言語入門ver2.15 15 101010分で分かるr言語入門ver2.15 15 1010
10分で分かるr言語入門ver2.15 15 1010Nobuaki Oshiro
 
全文検索In着うた配信サービス
全文検索In着うた配信サービス全文検索In着うた配信サービス
全文検索In着うた配信サービスtechtalkdwango
 
脱コピペ!デザイナーにもわかるPHPとWP_Query
脱コピペ!デザイナーにもわかるPHPとWP_Query脱コピペ!デザイナーにもわかるPHPとWP_Query
脱コピペ!デザイナーにもわかるPHPとWP_QueryHidekazu Ishikawa
 
JavaLearning_1.pptx
JavaLearning_1.pptxJavaLearning_1.pptx
JavaLearning_1.pptxRyuuGaku
 
10分で分かるr言語入門ver2.8 14 0712
10分で分かるr言語入門ver2.8 14 0712 10分で分かるr言語入門ver2.8 14 0712
10分で分かるr言語入門ver2.8 14 0712 Nobuaki Oshiro
 
Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編
Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編
Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編Toshi Harada
 
クラスタリングとレコメンデーション資料
クラスタリングとレコメンデーション資料クラスタリングとレコメンデーション資料
クラスタリングとレコメンデーション資料洋資 堅田
 
Optimisation 2013-07-02
Optimisation 2013-07-02Optimisation 2013-07-02
Optimisation 2013-07-02kmiyako
 

Similar a Kaggle参加報告: Quora Insincere Questions Classification (20)

Azure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etc
Azure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etcAzure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etc
Azure Search 言語処理関連機能 〜 アナライザー、検索クエリー、辞書、& ランキング, etc
 
[第2版]Python機械学習プログラミング 第8章
[第2版]Python機械学習プログラミング 第8章[第2版]Python機械学習プログラミング 第8章
[第2版]Python機械学習プログラミング 第8章
 
Abstractive Text Summarization @Retrieva seminar
Abstractive Text Summarization @Retrieva seminarAbstractive Text Summarization @Retrieva seminar
Abstractive Text Summarization @Retrieva seminar
 
Getting test world
Getting test worldGetting test world
Getting test world
 
WordNetで作ろう! 言語横断検索サービス
WordNetで作ろう! 言語横断検索サービスWordNetで作ろう! 言語横断検索サービス
WordNetで作ろう! 言語横断検索サービス
 
10分で分かるr言語入門ver2.14 15 0905
10分で分かるr言語入門ver2.14 15 090510分で分かるr言語入門ver2.14 15 0905
10分で分かるr言語入門ver2.14 15 0905
 
Jubatusでマルウェア分類
Jubatusでマルウェア分類Jubatusでマルウェア分類
Jubatusでマルウェア分類
 
第28回Tokyo.R
第28回Tokyo.R第28回Tokyo.R
第28回Tokyo.R
 
Wtm
WtmWtm
Wtm
 
Stan勉強会資料(前編)
Stan勉強会資料(前編) Stan勉強会資料(前編)
Stan勉強会資料(前編)
 
10分で分かるr言語入門ver2.15 15 1010
10分で分かるr言語入門ver2.15 15 101010分で分かるr言語入門ver2.15 15 1010
10分で分かるr言語入門ver2.15 15 1010
 
Tesseract ocr
Tesseract ocrTesseract ocr
Tesseract ocr
 
全文検索In着うた配信サービス
全文検索In着うた配信サービス全文検索In着うた配信サービス
全文検索In着うた配信サービス
 
日本語形態素解析
日本語形態素解析日本語形態素解析
日本語形態素解析
 
脱コピペ!デザイナーにもわかるPHPとWP_Query
脱コピペ!デザイナーにもわかるPHPとWP_Query脱コピペ!デザイナーにもわかるPHPとWP_Query
脱コピペ!デザイナーにもわかるPHPとWP_Query
 
JavaLearning_1.pptx
JavaLearning_1.pptxJavaLearning_1.pptx
JavaLearning_1.pptx
 
10分で分かるr言語入門ver2.8 14 0712
10分で分かるr言語入門ver2.8 14 0712 10分で分かるr言語入門ver2.8 14 0712
10分で分かるr言語入門ver2.8 14 0712
 
Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編
Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編
Pgunconf ゆるいテキスト検索ふたたび - n-gram応用編
 
クラスタリングとレコメンデーション資料
クラスタリングとレコメンデーション資料クラスタリングとレコメンデーション資料
クラスタリングとレコメンデーション資料
 
Optimisation 2013-07-02
Optimisation 2013-07-02Optimisation 2013-07-02
Optimisation 2013-07-02
 

Más de Kazuki Fujikawa

Stanford Covid Vaccine 2nd place solution
Stanford Covid Vaccine 2nd place solutionStanford Covid Vaccine 2nd place solution
Stanford Covid Vaccine 2nd place solutionKazuki Fujikawa
 
BMS Molecular Translation 3rd place solution
BMS Molecular Translation 3rd place solutionBMS Molecular Translation 3rd place solution
BMS Molecular Translation 3rd place solutionKazuki Fujikawa
 
Kaggle参加報告: Champs Predicting Molecular Properties
Kaggle参加報告: Champs Predicting Molecular PropertiesKaggle参加報告: Champs Predicting Molecular Properties
Kaggle参加報告: Champs Predicting Molecular PropertiesKazuki Fujikawa
 
Ordered neurons integrating tree structures into recurrent neural networks
Ordered neurons integrating tree structures into recurrent neural networksOrdered neurons integrating tree structures into recurrent neural networks
Ordered neurons integrating tree structures into recurrent neural networksKazuki Fujikawa
 
A closer look at few shot classification
A closer look at few shot classificationA closer look at few shot classification
A closer look at few shot classificationKazuki Fujikawa
 
Graph convolutional policy network for goal directed molecular graph generation
Graph convolutional policy network for goal directed molecular graph generationGraph convolutional policy network for goal directed molecular graph generation
Graph convolutional policy network for goal directed molecular graph generationKazuki Fujikawa
 
Conditional neural processes
Conditional neural processesConditional neural processes
Conditional neural processesKazuki Fujikawa
 
NIPS2017 Few-shot Learning and Graph Convolution
NIPS2017 Few-shot Learning and Graph ConvolutionNIPS2017 Few-shot Learning and Graph Convolution
NIPS2017 Few-shot Learning and Graph ConvolutionKazuki Fujikawa
 
Matrix capsules with em routing
Matrix capsules with em routingMatrix capsules with em routing
Matrix capsules with em routingKazuki Fujikawa
 
Predicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman networkPredicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman networkKazuki Fujikawa
 
SchNet: A continuous-filter convolutional neural network for modeling quantum...
SchNet: A continuous-filter convolutional neural network for modeling quantum...SchNet: A continuous-filter convolutional neural network for modeling quantum...
SchNet: A continuous-filter convolutional neural network for modeling quantum...Kazuki Fujikawa
 
Matching networks for one shot learning
Matching networks for one shot learningMatching networks for one shot learning
Matching networks for one shot learningKazuki Fujikawa
 
DeNAにおける機械学習・深層学習活用
DeNAにおける機械学習・深層学習活用DeNAにおける機械学習・深層学習活用
DeNAにおける機械学習・深層学習活用Kazuki Fujikawa
 

Más de Kazuki Fujikawa (15)

Stanford Covid Vaccine 2nd place solution
Stanford Covid Vaccine 2nd place solutionStanford Covid Vaccine 2nd place solution
Stanford Covid Vaccine 2nd place solution
 
BMS Molecular Translation 3rd place solution
BMS Molecular Translation 3rd place solutionBMS Molecular Translation 3rd place solution
BMS Molecular Translation 3rd place solution
 
ACL2020 best papers
ACL2020 best papersACL2020 best papers
ACL2020 best papers
 
Kaggle参加報告: Champs Predicting Molecular Properties
Kaggle参加報告: Champs Predicting Molecular PropertiesKaggle参加報告: Champs Predicting Molecular Properties
Kaggle参加報告: Champs Predicting Molecular Properties
 
NLP@ICLR2019
NLP@ICLR2019NLP@ICLR2019
NLP@ICLR2019
 
Ordered neurons integrating tree structures into recurrent neural networks
Ordered neurons integrating tree structures into recurrent neural networksOrdered neurons integrating tree structures into recurrent neural networks
Ordered neurons integrating tree structures into recurrent neural networks
 
A closer look at few shot classification
A closer look at few shot classificationA closer look at few shot classification
A closer look at few shot classification
 
Graph convolutional policy network for goal directed molecular graph generation
Graph convolutional policy network for goal directed molecular graph generationGraph convolutional policy network for goal directed molecular graph generation
Graph convolutional policy network for goal directed molecular graph generation
 
Conditional neural processes
Conditional neural processesConditional neural processes
Conditional neural processes
 
NIPS2017 Few-shot Learning and Graph Convolution
NIPS2017 Few-shot Learning and Graph ConvolutionNIPS2017 Few-shot Learning and Graph Convolution
NIPS2017 Few-shot Learning and Graph Convolution
 
Matrix capsules with em routing
Matrix capsules with em routingMatrix capsules with em routing
Matrix capsules with em routing
 
Predicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman networkPredicting organic reaction outcomes with weisfeiler lehman network
Predicting organic reaction outcomes with weisfeiler lehman network
 
SchNet: A continuous-filter convolutional neural network for modeling quantum...
SchNet: A continuous-filter convolutional neural network for modeling quantum...SchNet: A continuous-filter convolutional neural network for modeling quantum...
SchNet: A continuous-filter convolutional neural network for modeling quantum...
 
Matching networks for one shot learning
Matching networks for one shot learningMatching networks for one shot learning
Matching networks for one shot learning
 
DeNAにおける機械学習・深層学習活用
DeNAにおける機械学習・深層学習活用DeNAにおける機械学習・深層学習活用
DeNAにおける機械学習・深層学習活用
 

Kaggle参加報告: Quora Insincere Questions Classification

  • 1. Kaggle参加報告: Quora Insincere Questions Classification (4th place solution) 藤川 和樹 AIシステム部 AI研究開発第三グループ 株式会社 ディー・エヌ・エー
  • 2. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Top 3 solutions
  • 3. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Top 3 solutions
  • 4. コンペティション概要(問題設定) • Quoraに投稿された質問文で、不適切な質問かどうかを識別するタスク(2値分類) • 猥褻的な表現を含む質問(Bag-of-wordsでもある程度識別できそう) • Which races have the smallest penis? • Would you date a girl who had sex with a horse or a bull? • 差別的、攻撃的な質問(単語レベルでは判断が難しそう) • Do all women tell lies? • Why do Indians not gives a shit on Pakistan? • 事実に基づかない質問(単語レベルでは判断が難しそう) • Why did an 0bama fan kill ovr 50 people in Las Vegas? • Why is the US so good at brainwashing? • 正例が少ない不均衡なクラス分類問題 • 負例 : 正例 ≒ 15 : 1 • 評価指標 : F1 score
  • 5. コンペティション概要(制約条件) • Kernel only competition • データロード、学習、予測といった処理全てを2hで実行可能な1枚のKernelを提出 • 2nd stage制で、締切後に差し替えられたtest setで再計算してリスコアリングされる • インターネットアクセス禁止 • 外部のデータソースをDLして事前学習する、学習済みモデルを利用する等はNG • ホワイトリストとして、4種の学習済みword embeddingのみ利用可能
  • 6. コンペティションでのポイント • 精度と計算コストのバランスが取れたモデルの選択 • 少数の大きなモデルで単体の性能勝負 vs 多数の小さなモデルでアンサンブル勝負 • 計算コスト削減方法 • 前処理・訓練時に行う処理をいかに効率化できるか • 提供された学習済みword embeddingの活用法、含まれない単語の処理方法 • 表記揺れレベルの差異、ドメインの差分をどう埋めるか • Public LBのスコアだけに頼らないsubmission戦略 • public test set は private test set と比較してデータが少なく、スコアが信用できない (public: 5.6万件 vs private: 37.6万件)
  • 7. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Top 3 solutions
  • 8. 主要カーネル解説 (Pytorch starter by Heng Zheng) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) Classification model average Word features (300d) BiLSTM → BiGRU (2 * 60d) 1 Layer MLP (480d) concat Raw texts 以下をconcat (4 * 2 * 60d) • 1st layer weighted sum with attention • 2nd layer weighted sum with attention • 2nd layer avg pooling • 2nd layer max pooling Prediction (1d) BCE Loss concat
  • 9. 主要カーネル解説 (Pytorch starter by Heng Zheng) Normalize & Tokenize Raw texts ① テキストのNormalize, Tokenize • Normalize • 小文字化(ex. Trump → trump) • 句読点前後にスペース追加(ex. pen. → pen .) • 数字を特殊文字に変換(ex. 2019 → ####) • ルールベースによる表記揺れ解消(ex. isn’t → is not) • Keras Tokenizerによる特殊文字除去(ex. ####th → th) • Tokenize • spaceでsplit
  • 10. 主要カーネル解説 (Pytorch starter by Heng Zheng) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) averageRaw texts ② 下記方針によるWord embeddingの構築 高頻度 低頻度 有 Glove, Paragramの 平均ベクトル 単語自体を消去 無 単語毎に作成した 乱数ベクトル 単語自体を消去 Quoraデータセット中の単語の出現頻度 Glove,Paragram (Pretrainedvectors) での出現有無
  • 11. 主要カーネル解説 (Pytorch starter by Heng Zheng) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) Classification model average Word features (300d) BiLSTM → BiGRU (2 * 60d) 1 Layer MLP (480d) concat Raw texts 以下をconcat (4 * 2 * 60d) • 1st layer weighted sum with attention • 2nd layer weighted sum with attention • 2nd layer avg pooling • 2nd layer max pooling Prediction (1d) concat ③ 構築されたWord featuresを入力に、Classification modelを構築
  • 12. 主要カーネル解説 (Pytorch starter by Heng Zheng) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) Classification model average Word features (300d) BiLSTM → BiGRU (2 * 60d) 1 Layer MLP (480d) concat Raw texts 以下をconcat (4 * 2 * 60d) • 1st layer weighted sum with attention • 2nd layer weighted sum with attention • 2nd layer avg pooling • 2nd layer max pooling Prediction (1d) BCE Loss concat ④ Binary Cross Entropy Loss を最小化するように ネットワーク全体を学習 (ただし、Word featuresは固定)
  • 13. 主要カーネル解説 (Pytorch starter by Heng Zheng) ⑤ 5-Fold CVで行って5つのモデルを構築し、 最終予測値は5つのモデルの予測値の平均を使う dataset fold: 1 dataset fold: 2 dataset fold: 3 dataset fold: 4 dataset fold: 5 dataset model: 1 prediction: 1 model: 2 prediction: 2 model: 3 prediction: 3 model: 4 prediction: 4 model: 5 prediction: 5 prediction ∈ ℝ
  • 14. 主要カーネル解説 (Pytorch starter by Heng Zheng) dataset fold: 1 dataset fold: 2 dataset fold: 3 dataset fold: 4 dataset fold: 5 dataset model: 1 prediction: 1 model: 2 prediction: 2 model: 3 prediction: 3 model: 4 prediction: 4 model: 5 prediction: 5 prediction ∈ ℝ prediction ∈ {0, 1} 閾値による binning ⑥ 訓練データで最適な閾値探索を行い、binningする
  • 15. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Top 3 solutions
  • 17. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Pytorch starter 微修正(LB: 0.691 → 0.705) • Word embedding fine-tuning(LB: 0.705 → 0.708) • 単語・文単位の統計的特徴量(LB: 0.708 → 0.708) • Word embedding sampling(LB: 0.708 → 0.710) • モデルの評価 • Top 3 solutions
  • 18. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Pytorch starter 微修正(LB: 0.691 → 0.705) • Word embedding fine-tuning(LB: 0.705 → 0.708) • 単語・文単位の統計的特徴量(LB: 0.708 → 0.708) • Word embedding sampling(LB: 0.708 → 0.710) • モデルの評価 • Top 3 solutions
  • 19. Pytorch starter の微修正(LB: 0.691 → 0.705) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) Classification model average Word features (300d) BiLSTM → BiGRU (2 * 60d) 1 Layer MLP (480d) concat Raw texts 以下をconcat (4 * 2 * 60d) • 1st layer weighted sum with attention • 2nd layer weighted sum with attention • 2nd layer avg pooling • 2nd layer max pooling Prediction (1d) BCE Loss concat
  • 20. Pytorch starter の微修正(LB: 0.691 → 0.705) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) Classification model average Word features (300d) BiLSTM → BiGRU (2 * 60d) 1 Layer MLP (480d) concat Raw texts 以下をconcat (4 * 2 * 60d) • 1st layer weighted sum with attention • 2nd layer weighted sum with attention • 2nd layer avg pooling • 2nd layer max pooling Prediction (1d) BCE Loss concat ① 前処理の小さな修正 • ルールベースの微修正 • before: I‘d’ve → I would’ve • after: I‘d’ve → I would have • 句読点スペースとルールベースの順序 を反転 • before: isn’t → isn ‘ t • after: isn’t → is not • 数字の特殊文字の前後にスペース追加 • before: 1990th → ####th • after: 1990th → #### th • Keras Tokenizerのfilters処理を除外 • before: #### th → th • after: #### th → #### th
  • 21. Pytorch starter の微修正(LB: 0.691 → 0.705) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) averageRaw texts Classification model Extra Features (6d) 2 Layer MLP with BN (480d) Prediction (1d) BCE Loss 2nd layer max pooling (2 * 128d) Word features (300d) 2 Layer BiLSTM (2 * 128d) ② モデルの入れ替え BiLSTM + BiGRU (2 * 60d) → 2 Layer BiLSTM (2 * 128d) 4種のPooling → Max pooling → 2 Layer MLP with BN
  • 22. Pytorch starter の微修正(LB: 0.691 → 0.705) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) averageRaw texts ③ Word embeddingの構築方法を変更 高頻度 低頻度 有 Glove, Paragramの 平均ベクトル 単語自体を消去 無 単語毎に作成した 乱数ベクトル 単語自体を消去 Quoraデータセット中の単語の出現頻度 Glove,Paragram (Pretrainedvectors) での出現有無 高頻度 低頻度 有 Glove, Paragramの 平均ベクトル Glove, Paragramの 平均ベクトル 無 単語毎に作成した 乱数ベクトル (CV毎に生成) 0ベクトル
  • 23. Pytorch starter の微修正(LB: 0.691 → 0.705) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) averageRaw texts Classification model 2 Layer MLP w/ BN (480d) Prediction (1d) BCE Loss 2nd layer max pooling (2 * 128d) Word features (300d) 2 Layer BiLSTM (2 * 128d)
  • 24. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Pytorch starter 微修正(LB: 0.691 → 0.705) • Word embedding fine-tuning(LB: 0.705 → 0.708) • 単語・文単位の統計的特徴量(LB: 0.708 → 0.708) • Word embedding sampling(LB: 0.708 → 0.710) • モデルの評価 • Top 3 solutions
  • 25. データセット中の単語例 高頻度 低頻度 含まれる • the, what (一般語) • obama, trump (Wikipediaに出現する単語) • compresses (一般語の変形) • 0bama, germnay (typo) • 2sinxcosx, cython (一部の専門用語) 含まれない • coinbase, gdpr, brexit (新語) • tensorflow, kubernetes (専門用語) • germeny, fathar, f*ck (typo) • 5gfwdhf4rz (ハッシュ値) • ॡ (外国語) Quoraデータセット中の単語の出現頻度 Glove,Paragram (Pretrainedvectors)
  • 26. データセット中の単語例 高頻度 低頻度 含まれる • the, what (一般語) • obama, trump (Wikipediaに出現する単語) • compresses (一般語の変形) • 0bama, germnay (typo) • 2sinxcosx, cython (一部の専門用語) 含まれない • coinbase, gdpr, brexit (新語) • tensorflow, kubernetes (専門用語) • germeny, fathar, f*ck (typo) • 5gfwdhf4rz (ハッシュ値) • ॡ (外国語) Quoraデータセット中の単語の出現頻度 Glove,Paragram (Pretrainedvectors) Pretrained Vectorが持つ情報 を活用したい
  • 27. データセット中の単語例 高頻度 低頻度 含まれる • the, what (一般語) • obama, trump (Wikipediaに出現する単語) • compresses (一般語の変形) • 0bama, germnay (typo) • 2sinxcosx, cython (一部の専門用語) 含まれない • coinbase, gdpr, brexit (新語) • tensorflow, kubernetes (専門用語) • germeny, fathar, f*ck (typo) • 5gfwdhf4rz (ハッシュ値) • ॡ (外国語) Quoraデータセット中の単語の出現頻度 Glove,Paragram (Pretrainedvectors) Quoraデータセットだけでも ある程度学習できるはず
  • 28. Word embeddingの更新戦略例 計算コスト 単語表現学習 (Train) 単語表現学習 (Test) モデル例 Embeddingのみ 教師なし学習 ◎ ○ ○ Word2Vec, FastText (unsupervised) Embeddingのみ 半教師あり学習 ○ ◎ ○ Doc2Vec, FastText Embeddingのみ 教師あり学習 ◎ ○? ☓ Doc2Vec, FastText (supervised) NN全体を 半教師あり学習 ☓ ◎ ○ Masked LM + 教師あり学習 NN全体を 教師あり学習 ☓(all epochs) ○(last epoch) ○? ☓ Embedding unfreeze
  • 29. Word embeddingの更新戦略例 計算コスト 単語表現学習 (Train) 単語表現学習 (Test) モデル例 Embeddingのみ 教師なし学習 ◎ ○ ○ Word2Vec, FastText (unsupervised) Embeddingのみ 半教師あり学習 ○ ◎ ○ Doc2Vec, FastText Embeddingのみ 教師あり学習 ◎ ○? ☓ Doc2Vec, FastText (supervised) NN全体を 半教師あり学習 ☓ ◎ ○ Masked LM + 教師あり学習 NN全体を 教師あり学習 ☓(all epochs) ○(last epoch) ○? ☓ Embedding unfreeze 計算コスト重視でEmbeddingのみ 教師なし学習する戦略を選択
  • 30. Word embeddingの更新戦略例 計算コスト 単語表現学習 (Train) 単語表現学習 (Test) モデル例 Embeddingのみ 教師なし学習 ◎ ○ ○ Word2Vec, FastText (unsupervised) Embeddingのみ 半教師あり学習 ○ ◎ ○ Doc2Vec, FastText Embeddingのみ 教師あり学習 ◎ ○? ☓ Doc2Vec, FastText (supervised) NN全体を 半教師あり学習 ☓ ◎ ○ Masked LM + 教師あり学習 NN全体を 教師あり学習 ☓(all epochs) ○(last epoch) ○? ☓ Embedding unfreeze FastText supervisedのみ、というのも 試したが簡単には上手くいかなかった
  • 31. Word embeddingの更新戦略例 計算コスト 単語表現学習 (Train) 単語表現学習 (Test) モデル例 Embeddingのみ 教師なし学習 ◎ ○ ○ Word2Vec, FastText (unsupervised) Embeddingのみ 半教師あり学習 ○ ◎ ○ Doc2Vec, FastText Embeddingのみ 教師あり学習 ◎ ○? ☓ Doc2Vec, FastText (supervised) NN全体を 半教師あり学習 ☓ ◎ ○ Masked LM + 教師あり学習 NN全体を 教師あり学習 ☓(all epochs) ○(last epoch) ○? ☓ Embedding unfreeze モデルも計算コスト重視でWord2Vec (CBOW)を選択 (Char N-gramは利用しない)
  • 32. 予備実験: Word embedding fine-tuning • 以下3モデルを構築し、各モデルでベンチマーク単語と類似しているとされる Top10件の単語を確認する • Glove only • 提供された事前学習モデル(Glove)をそのまま利用 • Word2Vec Scratch • 事前学習モデルを使わずスクラッチでCBOWを 5 epoch 学習する • Word2Vec Fine-tuning • 事前学習モデル(Glove)を初期値にCBOWを 5 epoch 学習する
  • 33. 予備実験結果: Word embedding fine-tuning • Quora 高頻度語 & Glove 既知語 • Glove: ○、Scratch: ○、Finetune: ○ obama(DF: 2838) cosx(DF: 98) Glove, Scratch, Finetune どれでも良さそう
  • 34. 予備実験結果: Word embedding fine-tuning • Quora 高頻度語 & Glove 未知語 • Glove: ☓、Scratch: ○、Finetune: ○ coinbase(DF: 169) kubernetes(DF: 30) Gloveではヒットしない単語ベクトルが Scratch, Finetune で上手く学習できてそう
  • 35. 予備実験結果: Word embedding fine-tuning • Quora 低頻度語 & Glove 既知語 • Glove: ○、Scratch: ☓、Finetune: ○ 0bama(DF: 5) compresses(DF: 2) Scratchでは学習が困難だが、 Glove では上手く表現できており、 Finetuneしても悪影響は無さそう
  • 36. 予備実験結果: Word embedding fine-tuning • Quora 低頻度語 & Glove 未知語 • Glove: ☓、Scratch: △~☓、Finetune: △~☓ xgboost(DF: 8) germeny(DF: 2) Glove(0ベクトル)よりはマシな場合も あるが、悪影響が無視できなさそう
  • 37. Word embedding fine-tuning (LB: 0.705 → 0.708) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) averageRaw texts Glove & Paragram (300d) Finetuned (300d) Word2Vec fine-tuning average Glove & Paragram with Finetuned (300d) Word embeddingの構築方法を変更 高頻度 低頻度 有 Glove, Paragramの 平均ベクトル Glove, Paragramの 平均ベクトル 無 単語毎に作成した 乱数ベクトル 0ベクトル Quoraデータセット中の単語の出現頻度 Glove,Paragram (PretrainedVectors) での出現有無 高頻度 低頻度 有 下記ベクトルを平均 • Glove, Paragramの 平均ベクトル • Word2Vec Finetune 下記ベクトルを平均 • Glove, Paragramの 平均ベクトル • Word2Vec Finetune 無 下記ベクトルを平均 • 単語毎に作成した 乱数ベクトル • Word2Vec Finetune 0ベクトル
  • 38. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Pytorch starter 微修正(LB: 0.691 → 0.705) • Word embedding fine-tuning(LB: 0.705 → 0.708) • 単語・文単位の統計的特徴量(LB: 0.708 → 0.708) • Word embedding sampling(LB: 0.708 → 0.710) • モデルの評価 • Top 3 solutions
  • 39. 単語・文単位の統計的特徴量(LB: 0.708 → 0.708) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) averageRaw texts Classification model Extra Features (6d) 2 Layer MLP w/ BN (480d) Prediction (1d) BCE Loss concat2nd layer max pooling (2 * 128d) Word features (302d) 2 Layer BiLSTM (2 * 128d) Glove & Paragram (300d) Finetuned (300d) Word2Vec fine-tuning average Glove & Paragram with Finetuned (300d) Extra Features (6d) Extra Features [is_unk, IDF] (2d) 単語・文単位の統計的特徴量を追加 • 以下の特徴量を算出し、単語・文の特徴ベクトルに連結した • 単語特徴量: Glove未知語か否か、IDF • 文特徴量: 文字数、単語数等のKernelで議論されていた特徴量 • Localでは軽微な改善があったものの、Public LBでは変化がなかった
  • 40. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Pytorch starter 微修正(LB: 0.691 → 0.705) • Word embedding fine-tuning(LB: 0.705 → 0.708) • 単語・文単位の統計的特徴量(LB: 0.708 → 0.708) • Word embedding sampling(LB: 0.708 → 0.710) • モデルの評価 • Top 3 solutions
  • 41. Word Embedding sampling(LB: 0.708 → 0.710) Glove (300d) Paragram (300d) Words Normalize & Tokenize Build word features Glove & Paragram (300d) averageRaw texts Classification model Extra Features (6d) 1 Layer MLP (480d) Prediction (1d) BCE Loss concat2nd layer max pooling (2 * 128d) Word features (302d) 2 Layer BiLSTM (2 * 128d) Glove & Paragram (300d) Finetuned (300d) Word2Vec fine-tuning concat Glove & Paragram with Finetuned (600d) Extra Features (6d) Extra Features [is_unk, IDF] (2d) Glove & Paragram with Finetuned (400d) sampling per CV Word embeddingの構築方法を変更 • Fine-tuning前後のベクトル平均は若干怪しさが残っていた • 特にQuora高頻度 & Pretrained Vector非搭載の単語 • 一方Fine-tuning後のベクトルのみ利用するよりも、平均したベクトルを 利用した方が実験的に良いスコアを示していた • Fine-tuning前後のWord Embeddingを連結した600次元のベクトルから 400次元をCV毎にサンプリングして扱うように変更 • 600次元を扱うのは計算時間的に厳しかった • モデル間の多用性を上げてアンサンブル後の性能を改善することが狙い
  • 42. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Pytorch starter 微修正(LB: 0.691 → 0.705) • Word embedding fine-tuning(LB: 0.705 → 0.708) • 単語・文単位の統計的特徴量(LB: 0.708 → 0.708) • Word embedding sampling(LB: 0.708 → 0.710) • モデルの評価 • Top 3 solutions
  • 43. モデルの評価方法(背景) • アンサンブル後のスコアはLocal CVでは測れないため、CV外のデータで評価する必要があった • Embedding sampling は Local CV は低くてもアンサンブル後にスコアが高くなる 可能性があるのではないかと考えていた • Public LBのスコアは件数が少なく、乱数シードを変えただけで大きく変動してしまうため、 別の指標が必要だった
  • 44. モデルの評価方法 • Holdout & CV を乱数シードを変えて複数回実施し、平均と標準偏差で評価 • 上記のスコア平均が高かった実験設定を選択し、同じ実験設定でCVのみ行って提出 Train 0 (CVに利用) Test 0 Seed: 0 でシャッフル Train 1 (CVに利用) Test 1 Seed: 1 でシャッフル Train 2 (CVに利用) Test 2 Seed: 2 でシャッフル Train 3 (CVに利用) Test 3 Seed: 3 でシャッフル Train 4 (CVに利用) Test 4 Seed: 4 でシャッフル Test 0 ~ 4 の平均・標準偏差 Train set(ラベル付き)
  • 45. Agenda • コンペティション概要 • 主要Kernel解説 (Pytorch starter by Heng Zheng) • My solution • Top 3 solutions
  • 46. 1st Place Solution (The Zoo) • Model • Embedding (300) → BiLSTM (128) → 1DCNN (64) → MLP (128) • Embeddings • 0.7 * Glove + 0.3 * Paragram(重みをCVで選択) • アンサンブル・閾値選択 • 10-fold CV, Rank Average • Fold毎に閾値と対応するF1を計測し、 最小値が最大になる値を閾値として選択
  • 47. 2nd Place Solution (takapt) • Model • Embedding (668) → BiGRU (128) → MLP (64) • Embeddings • Glove (300), WikiNews (300), FastText scratch (64) 単語Feature (4) のconcat (668) • 単語Feature: [all upper chars?, first char upper?, only first char upper?, OOV?] • Statical Features • 単語数、ユニーク単語数、文字数、大文字数、Bag of characters • アンサンブル・閾値選択 • 6-fold CV, Local CVで閾値をFix(0.36)
  • 48. 3rd Place Solution (Guanshuo Xu) • Model • Embedding (600) → BiGRU (256) → BiGRU (128) → Linear (64) • Embeddings • Model1: Glove (300), FastText (300) のconcat • Model2: Glove (300), Paragram (300) のconcat • WordVectorの対応付けに、stemming, lemmatizing, spell correction等を適用 • アンサンブル・閾値選択 • 2モデルのsnapshot ensemble: 2 * (0.15 * 3rd epoch + 0.35 * 4th epoch) • Validation setは取らない • 閾値はLocal CVで決定(0.35)