SlideShare une entreprise Scribd logo
1  sur  18
Télécharger pour lire hors ligne
A Convolutional Encoder
Model for Neural Machine
Translation
Gehring et al., ACL 2017
小町研 B4 勝又智
概要
● 通常、MTのencodeは双方向LSTMだが、今回、畳み込みを用いたencoderを
提案する。
○ 双方向LSTMは逐次的に計算を行うが、CNNなら入力文を平行にencodeできる。
● 既存のLSTMと同程度の精度を実現。
○ WMT’16 English-Romanian、WMT’15 En-Ge、WMT’14 En-Fr
● generateについて、精度はそのままでLSTMと比べて2倍以上速い。
○ IWSLT’14 En-Ge、Ge-En
2
CNN Encoder のうま味(RNNと比べて)
● 入力文に対して平行に計算を行う。
● RNNと比べて入力文内の単語の関係性がより短いパス(計算数の話ではない)で取れる。
○ RNN: sequence length n が必要
○ CNN: max(1, [(n-1) / (k-1)]) が必要(k: kernel width)
● CNNは入力文の各単語に対して均等に処理を行っていく。
一方でRNNは最初の単語と最後の単語で処理された数が異なる。
CNN RNN
例: 下図 n=4、k=2のとき
RNNはそのまま4
CNNは左のように3
3(実際のモデルではストライド1)
Model : Decoder とか attention まわり
Decoder (隠れ層si+1を求める)
● si+1の計算として、
1つ前の隠れ層siと1つ前の出力embedding gi、attentionで計算したciを用いる
○ 具体的にciはgiとconcateしてLSTMに入れてsi+1を求める (siの中にcell vecとhidden vec (hi))
Attention (ciを求める)
● diの計算として、hiを線形変換したものと1つ前の出力giを足す。
このdiとencoder output zj のdot product を計算する。
最終的な出力→
4
Model: Baseline (LSTM encoder, pooling encoder)
bi-directional LSTM encoder (BiLSTM)
● 入力文をembeddingしたものを順方向と逆方向のRNNに入れてconcateし、
線形変換を行いencode output zを返す。
pooling encoder
● こちらは非再帰的なencoderのbaselineで、k個の連続した単語のembedding
の平均をとったモデル。(Ranzato et al., 2015)
● 今回は単語のembedding wjに対して、その単語の入力文における絶対位置を
足した。(ℓj: position embedding)
attentionについて
aijの計算は先ほどと同じだが
ciの計算でzjでなくejを使って
いる 5
Model : Convolutional Encoder
● pooling encoderのようにposition embeddingを行い、畳み込みを行っていく。
○ pooling layerは持ってない。
● 畳み込み層を重ねていく。→最終的な出力は複数の文脈を見ているはず。
○ 畳み込みの入出力はresidual connection (He et al., 2015)を用いている。
● attention計算のために2つの畳み込み計算を行ってencodeを行う。
○ CNN_a: aを計算するためのやつ
○ CNN_c: cを計算するためのやつ
6
CNN_a CNN_c
(diは2つ前のスライドと同じ)
他のCNN Encoder と比べて何が嬉しいのか
● これまでのCNN encoderでは既存のRNN encoderより性能が低かった。
→ 今回、既存のRNN encoderに匹敵する性能が出た!
● (Kalchbrenner and Blunsom, 2013) → 文に対して畳み込みencodeを用いた。
○ sentenceやn-gramに対してCNN encodeを行い、decoderへの入力トークンを生成する。
○ SMT出力のn-best rescoring で使われた。
● (Cho et al., 2014) → 固定長の表現が得られるまで繰り返しCNNを用いた。
○ recurrent encoder の方が高い精度を達成した。
● (Kalchbrenner et al., 2016) → 畳み込みで翻訳を行うモデル (ByteNet) を提案。
○ このモデルはattention機構が無く、SOTAに届かなかった。
● (Lamb and Xie, 2016) → encodeに多層のCNNを用いた。
○ 量的評価がされていなかった。
● (Meng et al., 2015) → PBSMTのphrase対のスコア計算に用いた。
● (Tu et al., 2015) → Dependency-basedSMTのphrase対のスコア計算に用いた。
7
実験: Dataset
● IWSLT’14 German-English (異なるencoderの評価)
○ train: TEDとTEDxの字幕データ、頻度3回以下の単語を<unk>化 (En: 24158 words, Ge: 35882 words)
○ (特に記載無ければ)入力文長制限: 175words ← position embeddingの適切な学習を保証している。
○ trainの文数: 167K, test: 6948 sents (tst2010, tst2011, tst2012, tst2013, dev2010)
● WMT’16 English-Romanian
○ (Sennrich et al., 2016)と同じデータを用いている。→ 学習は2.8M sents用いた。
(En: 200K words, Ro: 80K words)
○ test: newstest2016
○ BPEは使っておらず、word baseで行っている。
● WMT’15 English-German
○ train: Europarl v7, Common Crawl, News Commentary v10を用いて、3.9M sentsを使用した。
(En: 200K words, Ge: 80K words)
○ test: newstest2015
● WMT’14 English-French
○ train: 一般的に用いられる(Schwenk 2014)12M setnsに対して文長制限150wordsを行い、
10.7M sents用いた。(En: 200K, Fr: 30K)
○ test: ntst14
8
validation setについて
IWSLT’14: trainの5%
WMT: trainの1%
実験: パラメータなど
● 共通するパラメータ
○ embedding: 256 dim
○ 重みの初期化: [-0.05, 0.05]の一様分布
○ mini-bach: IWSLT’14 32 sents、WMT 64 sents
○ dropout: IWSLT’14 0.2、WMT 0.1 (embeddingとdecoder output hiに対して行う)
● Recurrent Model
○ hidden unit: 512 (encoder, decoderどちらも)
○ optim: Adam (step幅: 3.125*10^(-4))
○ validのpplに基づいてearly stopingを行ってる。
● CNN Model
○ hidden unit: CNN_a 512 units、CNN_c 256 units、decoder 512 units
○ 窓幅: 3
○ paddingはencoder output zが入力xと同じ (|x|=|z|) になるように。(fig1を参照)
○ optim: SGD and annealing(最初lr=0.1にして、validのpplが改善しなくなったらlrを減らしていく)
今回はlrの桁を減らしていって、lrが10^(-4)になるまで行う。 9
今回の実験の評価について
● IWSLT’14については5つ、WMTについては3つ、seedを変化させて学習したモデルの中から最も
良いvalid pplを出したものを最終的なBLEU評価に用いた。
● beam searchについて
○ IWSLT’14 はbeam幅10、WMTはbeam幅も別のデータセットを使って調整した。
● 未知語を出力した後の処理
○ <unk>を出力した場合、attention scoreが最も高い入力単語を見て、事前に用意した辞書から
対応した単語で<unk>を置き換える。
○ 辞書になかったら、入力単語をそのまま置き換える。
○ この辞書はアライメントをとった学習データからとってくる。
(アライメントはfast_align (Dyer et al., 2013) を用いて張る)
10
Results: IWSLT’14 (Recurrent or 非Recurrent)
● 畳み込み層
○ CNN_a とCNN_cを1層から10層まで変化させて
valid ppl が一番いいものを持ってくる (6層、3層)
● position embedding
○ pos がある→position embeddingを用いている。
11
Results: WMT Corpora
12
Analysis: CNN Encoder について(IWSLT’14)
● CNN_aとCNN_cを分ける話
○ CNN_cが3層のときがいい感じ、このときCNN_aは6層がいい感じ
→ CNN_aはCNN_cの2,3倍の層の数にしておくといい。
○ CNN_aとCNN_cを分けなかったとき 22.9 BLEU(層の数を増やしてもダメでした)
○ CNN_a: 広い範囲の文脈を見て情報を統合してそう
CNN_c: 入力単語により近い感じの浅いところを見てそう
13
Analysis: attention score
14
WMT’14
En-Fr
ntst14
Analysis: 入力文長に対しての性能
15WMT’15 En-Ge newstest2015の出力を文長で15分割した
Analysis: 学習時間と出力時間について
● 学習時間(IWSLT’14)
○ Tesla M40 GPUを使用
○ single layer BiLSTM: 4,300 target words/second
○ 6/3 convolution encoder: 6,400 target words/second
○ Adamの方がSGDより収束が速いため、全体の学習時間はBiLSTMが速かった。
● 出力時間
○ Intel Haswell CPU clocked at 2.50GHzをシングルスレッドで使用した。
○ IWSLT’14: 1.35倍速いしBLEUも上がった。(hidden layerやembedding sizeも同じ)
○ WMT’15: Conv. 8/4はBiLSTMより2.1倍速い。(encoderのembedding sizeが違う(BiLSTM > conv.))
○ そもそも1回でLSTMは2つ行列乗算が必要なのに対し、convは行列乗算が1つで良いのが効いてる
16
まとめ
● 畳み込みネットワークを用いたNMTのencoderを提案した。
○ recurrentにやるよりも並列化でき、入力文の長距離依存性を短いパスで掴める。
○ 入力文のposition embeddingを入れたり、attention計算用にCNNを2つ用いた。
● recurrent encoder と比較して同じくらいの性能が得られた。
○ baselineとしたBiLSTMとは同じくらいかそれ以上の性能が得られた。
○ 他の手法と比べてもそれほど悪くはなかった。
● 出力時間についてもよくなった。
○ 双方向のrecurrent encoderと比べて2倍速くなった。
● Future work
○ conv. encoderを用いて収束の速い学習を行いたい。
○ 文字単位のencoderにも使えそう。
○ 他のseq2seqのtaskにも適応したい。(summarization, constituency parsing, dialog modeling)
● 個人的感想
○ 比較について: モデルが既存のものと大きく異なるのにこんな感じ(setting, 評価にBLEUのみ)でいいの...?
先行研究と設定を一緒にしたりしなかったりどういうこと...?
○ CNN encoder: わざわざ使う1番のメリットは時間...?(性能とかパスが云々とかではない感じがした...)
○ 一番興味深かったのはattention用に2つEncoderを用意するところ
17
参考サイト、論文
● facebookの実装 (lua, torch)
○ https://github.com/facebookresearch/fairseq
● Recurrent Continuous Translation Models. Kalchbrenner and Blunsom, EMNLP 2013
● On the Properties of Neural Machine Translation: Encoder–Decoder Approaches . Cho et al., SSST 2014
● Neural Machine Translation in Linear Time. Kalchbrenner et al., arXiv 2016
● Convolutional Encoders for Neural Machine Translation. Lamb and Xie, 2016
○ (https://cs224d.stanford.edu/ reports/LambAndrew.pdf)
● Encoding Source Language with Convolutional Neural Network for Machine Translation. Meng et al., ACL 2015
● Context-dependent Translation selection using Convolutional Neural Network. Tu et al., ACL-IJCNLP 2015
● Edinburgh neural machine translation systems for wmt 16. Sennrich et al., WMT16 2016
● Schwenk 2014
○ (http://www-lium. univ-lemans.fr/ ̃schwen /cslm_joint_ paper/)
● A Simple, Fast, and Effective Reparameterization of IBM Model 2. Dyer et al., ACL 2013
18

Contenu connexe

Tendances

[DL輪読会]Learning to Skim Text
 [DL輪読会]Learning to Skim Text [DL輪読会]Learning to Skim Text
[DL輪読会]Learning to Skim TextDeep Learning JP
 
Javascriptで無限ループを実現する5つの方法
Javascriptで無限ループを実現する5つの方法Javascriptで無限ループを実現する5つの方法
Javascriptで無限ループを実現する5つの方法yhara
 
Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)
Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)
Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)洋史 東平
 
20130215 fluentd esper_2
20130215 fluentd esper_220130215 fluentd esper_2
20130215 fluentd esper_2Ogibayashi
 
自然言語処理のためのDeep Learning
自然言語処理のためのDeep Learning自然言語処理のためのDeep Learning
自然言語処理のためのDeep LearningYuta Kikuchi
 

Tendances (7)

NanoStrand
NanoStrandNanoStrand
NanoStrand
 
Nltk for biginer
Nltk for biginerNltk for biginer
Nltk for biginer
 
[DL輪読会]Learning to Skim Text
 [DL輪読会]Learning to Skim Text [DL輪読会]Learning to Skim Text
[DL輪読会]Learning to Skim Text
 
Javascriptで無限ループを実現する5つの方法
Javascriptで無限ループを実現する5つの方法Javascriptで無限ループを実現する5つの方法
Javascriptで無限ループを実現する5つの方法
 
Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)
Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)
Rubyの御先祖CLU(くるう)のお話(OSC2013 Hamamatsu 発表資料)
 
20130215 fluentd esper_2
20130215 fluentd esper_220130215 fluentd esper_2
20130215 fluentd esper_2
 
自然言語処理のためのDeep Learning
自然言語処理のためのDeep Learning自然言語処理のためのDeep Learning
自然言語処理のためのDeep Learning
 

Similaire à A convolutional encoder model for neural machine translation

解説 - Factorized Neural Transducer for Efficient Language Model Adaptation
解説 - Factorized Neural Transducer for Efficient Language Model Adaptation解説 - Factorized Neural Transducer for Efficient Language Model Adaptation
解説 - Factorized Neural Transducer for Efficient Language Model AdaptationHayato Futami
 
[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...
[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...
[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...Deep Learning JP
 
2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...
2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...
2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...広樹 本間
 
文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at ScaleToru Tamaki
 
[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...
[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...
[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...Deep Learning JP
 
Volta は、Chainer で使えるの?
Volta は、Chainer で使えるの?Volta は、Chainer で使えるの?
Volta は、Chainer で使えるの?NVIDIA Japan
 
PostgreSQL 9.5 CPU Read Scalability
PostgreSQL 9.5 CPU Read ScalabilityPostgreSQL 9.5 CPU Read Scalability
PostgreSQL 9.5 CPU Read ScalabilityOhyama Masanori
 
【学習メモ#4th】12ステップで作る組込みOS自作入門
【学習メモ#4th】12ステップで作る組込みOS自作入門【学習メモ#4th】12ステップで作る組込みOS自作入門
【学習メモ#4th】12ステップで作る組込みOS自作入門sandai
 
サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価
サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価
サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価Shinnosuke Takamichi
 
Recurrent Neural Networks
Recurrent Neural NetworksRecurrent Neural Networks
Recurrent Neural NetworksSeiya Tokui
 

Similaire à A convolutional encoder model for neural machine translation (12)

解説 - Factorized Neural Transducer for Efficient Language Model Adaptation
解説 - Factorized Neural Transducer for Efficient Language Model Adaptation解説 - Factorized Neural Transducer for Efficient Language Model Adaptation
解説 - Factorized Neural Transducer for Efficient Language Model Adaptation
 
[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...
[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...
[DL輪読会]Pervasive Attention: 2D Convolutional Neural Networks for Sequence-to-...
 
音声認識と深層学習
音声認識と深層学習音声認識と深層学習
音声認識と深層学習
 
2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...
2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...
2020 acl learning_to_recover_from_multi-modality_errors_for_non-autoregressiv...
 
文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
文献紹介:An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale
 
[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...
[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...
[DLHacks]Fast and Accurate Entity Recognition with Iterated Dilated Convoluti...
 
Volta は、Chainer で使えるの?
Volta は、Chainer で使えるの?Volta は、Chainer で使えるの?
Volta は、Chainer で使えるの?
 
PostgreSQL 9.5 CPU Read Scalability
PostgreSQL 9.5 CPU Read ScalabilityPostgreSQL 9.5 CPU Read Scalability
PostgreSQL 9.5 CPU Read Scalability
 
Paper: seq2seq 20190320
Paper: seq2seq 20190320Paper: seq2seq 20190320
Paper: seq2seq 20190320
 
【学習メモ#4th】12ステップで作る組込みOS自作入門
【学習メモ#4th】12ステップで作る組込みOS自作入門【学習メモ#4th】12ステップで作る組込みOS自作入門
【学習メモ#4th】12ステップで作る組込みOS自作入門
 
サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価
サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価
サブバンドフィルタリングに基づくリアルタイム広帯域DNN声質変換の実装と評価
 
Recurrent Neural Networks
Recurrent Neural NetworksRecurrent Neural Networks
Recurrent Neural Networks
 

Plus de Satoru Katsumata

Exploiting Monolingual Data at Scale for Neural Machine Translation
Exploiting Monolingual Data at Scale for Neural Machine TranslationExploiting Monolingual Data at Scale for Neural Machine Translation
Exploiting Monolingual Data at Scale for Neural Machine TranslationSatoru Katsumata
 
Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...
Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...
Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...Satoru Katsumata
 
How Contextual are Contextualized Word Representations?
How Contextual are Contextualized Word Representations?How Contextual are Contextualized Word Representations?
How Contextual are Contextualized Word Representations?Satoru Katsumata
 
Corpora Generation for Grammatical Error Correction
Corpora Generation for Grammatical Error CorrectionCorpora Generation for Grammatical Error Correction
Corpora Generation for Grammatical Error CorrectionSatoru Katsumata
 
Understanding Back-Translation at Scale
Understanding Back-Translation at ScaleUnderstanding Back-Translation at Scale
Understanding Back-Translation at ScaleSatoru Katsumata
 
2018年度レトリバインターン参加報告
2018年度レトリバインターン参加報告2018年度レトリバインターン参加報告
2018年度レトリバインターン参加報告Satoru Katsumata
 
On the Limitations of Unsupervised Bilingual Dictionary Induction
On the Limitations of Unsupervised Bilingual Dictionary InductionOn the Limitations of Unsupervised Bilingual Dictionary Induction
On the Limitations of Unsupervised Bilingual Dictionary InductionSatoru Katsumata
 
Guiding neural machine translation with retrieved translation pieces
Guiding neural machine translation with retrieved translation piecesGuiding neural machine translation with retrieved translation pieces
Guiding neural machine translation with retrieved translation piecesSatoru Katsumata
 
Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...
Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...
Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...Satoru Katsumata
 
Memory-augmented Neural Machine Translation
Memory-augmented Neural Machine TranslationMemory-augmented Neural Machine Translation
Memory-augmented Neural Machine TranslationSatoru Katsumata
 
Lexically constrained decoding for sequence generation using grid beam search
Lexically constrained decoding for sequence generation using grid beam searchLexically constrained decoding for sequence generation using grid beam search
Lexically constrained decoding for sequence generation using grid beam searchSatoru Katsumata
 
Deep Neural Machine Translation with Linear Associative Unit
Deep Neural Machine Translation with Linear Associative UnitDeep Neural Machine Translation with Linear Associative Unit
Deep Neural Machine Translation with Linear Associative UnitSatoru Katsumata
 

Plus de Satoru Katsumata (13)

Exploiting Monolingual Data at Scale for Neural Machine Translation
Exploiting Monolingual Data at Scale for Neural Machine TranslationExploiting Monolingual Data at Scale for Neural Machine Translation
Exploiting Monolingual Data at Scale for Neural Machine Translation
 
Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...
Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...
Incorporating Syntactic and Semantic Information in Word Embeddings using Gra...
 
How Contextual are Contextualized Word Representations?
How Contextual are Contextualized Word Representations?How Contextual are Contextualized Word Representations?
How Contextual are Contextualized Word Representations?
 
Word-node2vec
Word-node2vecWord-node2vec
Word-node2vec
 
Corpora Generation for Grammatical Error Correction
Corpora Generation for Grammatical Error CorrectionCorpora Generation for Grammatical Error Correction
Corpora Generation for Grammatical Error Correction
 
Understanding Back-Translation at Scale
Understanding Back-Translation at ScaleUnderstanding Back-Translation at Scale
Understanding Back-Translation at Scale
 
2018年度レトリバインターン参加報告
2018年度レトリバインターン参加報告2018年度レトリバインターン参加報告
2018年度レトリバインターン参加報告
 
On the Limitations of Unsupervised Bilingual Dictionary Induction
On the Limitations of Unsupervised Bilingual Dictionary InductionOn the Limitations of Unsupervised Bilingual Dictionary Induction
On the Limitations of Unsupervised Bilingual Dictionary Induction
 
Guiding neural machine translation with retrieved translation pieces
Guiding neural machine translation with retrieved translation piecesGuiding neural machine translation with retrieved translation pieces
Guiding neural machine translation with retrieved translation pieces
 
Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...
Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...
Bi-Directional Block Self-Attention for Fast and Memory-Efficient Sequence Mo...
 
Memory-augmented Neural Machine Translation
Memory-augmented Neural Machine TranslationMemory-augmented Neural Machine Translation
Memory-augmented Neural Machine Translation
 
Lexically constrained decoding for sequence generation using grid beam search
Lexically constrained decoding for sequence generation using grid beam searchLexically constrained decoding for sequence generation using grid beam search
Lexically constrained decoding for sequence generation using grid beam search
 
Deep Neural Machine Translation with Linear Associative Unit
Deep Neural Machine Translation with Linear Associative UnitDeep Neural Machine Translation with Linear Associative Unit
Deep Neural Machine Translation with Linear Associative Unit
 

A convolutional encoder model for neural machine translation

  • 1. A Convolutional Encoder Model for Neural Machine Translation Gehring et al., ACL 2017 小町研 B4 勝又智
  • 2. 概要 ● 通常、MTのencodeは双方向LSTMだが、今回、畳み込みを用いたencoderを 提案する。 ○ 双方向LSTMは逐次的に計算を行うが、CNNなら入力文を平行にencodeできる。 ● 既存のLSTMと同程度の精度を実現。 ○ WMT’16 English-Romanian、WMT’15 En-Ge、WMT’14 En-Fr ● generateについて、精度はそのままでLSTMと比べて2倍以上速い。 ○ IWSLT’14 En-Ge、Ge-En 2
  • 3. CNN Encoder のうま味(RNNと比べて) ● 入力文に対して平行に計算を行う。 ● RNNと比べて入力文内の単語の関係性がより短いパス(計算数の話ではない)で取れる。 ○ RNN: sequence length n が必要 ○ CNN: max(1, [(n-1) / (k-1)]) が必要(k: kernel width) ● CNNは入力文の各単語に対して均等に処理を行っていく。 一方でRNNは最初の単語と最後の単語で処理された数が異なる。 CNN RNN 例: 下図 n=4、k=2のとき RNNはそのまま4 CNNは左のように3 3(実際のモデルではストライド1)
  • 4. Model : Decoder とか attention まわり Decoder (隠れ層si+1を求める) ● si+1の計算として、 1つ前の隠れ層siと1つ前の出力embedding gi、attentionで計算したciを用いる ○ 具体的にciはgiとconcateしてLSTMに入れてsi+1を求める (siの中にcell vecとhidden vec (hi)) Attention (ciを求める) ● diの計算として、hiを線形変換したものと1つ前の出力giを足す。 このdiとencoder output zj のdot product を計算する。 最終的な出力→ 4
  • 5. Model: Baseline (LSTM encoder, pooling encoder) bi-directional LSTM encoder (BiLSTM) ● 入力文をembeddingしたものを順方向と逆方向のRNNに入れてconcateし、 線形変換を行いencode output zを返す。 pooling encoder ● こちらは非再帰的なencoderのbaselineで、k個の連続した単語のembedding の平均をとったモデル。(Ranzato et al., 2015) ● 今回は単語のembedding wjに対して、その単語の入力文における絶対位置を 足した。(ℓj: position embedding) attentionについて aijの計算は先ほどと同じだが ciの計算でzjでなくejを使って いる 5
  • 6. Model : Convolutional Encoder ● pooling encoderのようにposition embeddingを行い、畳み込みを行っていく。 ○ pooling layerは持ってない。 ● 畳み込み層を重ねていく。→最終的な出力は複数の文脈を見ているはず。 ○ 畳み込みの入出力はresidual connection (He et al., 2015)を用いている。 ● attention計算のために2つの畳み込み計算を行ってencodeを行う。 ○ CNN_a: aを計算するためのやつ ○ CNN_c: cを計算するためのやつ 6 CNN_a CNN_c (diは2つ前のスライドと同じ)
  • 7. 他のCNN Encoder と比べて何が嬉しいのか ● これまでのCNN encoderでは既存のRNN encoderより性能が低かった。 → 今回、既存のRNN encoderに匹敵する性能が出た! ● (Kalchbrenner and Blunsom, 2013) → 文に対して畳み込みencodeを用いた。 ○ sentenceやn-gramに対してCNN encodeを行い、decoderへの入力トークンを生成する。 ○ SMT出力のn-best rescoring で使われた。 ● (Cho et al., 2014) → 固定長の表現が得られるまで繰り返しCNNを用いた。 ○ recurrent encoder の方が高い精度を達成した。 ● (Kalchbrenner et al., 2016) → 畳み込みで翻訳を行うモデル (ByteNet) を提案。 ○ このモデルはattention機構が無く、SOTAに届かなかった。 ● (Lamb and Xie, 2016) → encodeに多層のCNNを用いた。 ○ 量的評価がされていなかった。 ● (Meng et al., 2015) → PBSMTのphrase対のスコア計算に用いた。 ● (Tu et al., 2015) → Dependency-basedSMTのphrase対のスコア計算に用いた。 7
  • 8. 実験: Dataset ● IWSLT’14 German-English (異なるencoderの評価) ○ train: TEDとTEDxの字幕データ、頻度3回以下の単語を<unk>化 (En: 24158 words, Ge: 35882 words) ○ (特に記載無ければ)入力文長制限: 175words ← position embeddingの適切な学習を保証している。 ○ trainの文数: 167K, test: 6948 sents (tst2010, tst2011, tst2012, tst2013, dev2010) ● WMT’16 English-Romanian ○ (Sennrich et al., 2016)と同じデータを用いている。→ 学習は2.8M sents用いた。 (En: 200K words, Ro: 80K words) ○ test: newstest2016 ○ BPEは使っておらず、word baseで行っている。 ● WMT’15 English-German ○ train: Europarl v7, Common Crawl, News Commentary v10を用いて、3.9M sentsを使用した。 (En: 200K words, Ge: 80K words) ○ test: newstest2015 ● WMT’14 English-French ○ train: 一般的に用いられる(Schwenk 2014)12M setnsに対して文長制限150wordsを行い、 10.7M sents用いた。(En: 200K, Fr: 30K) ○ test: ntst14 8 validation setについて IWSLT’14: trainの5% WMT: trainの1%
  • 9. 実験: パラメータなど ● 共通するパラメータ ○ embedding: 256 dim ○ 重みの初期化: [-0.05, 0.05]の一様分布 ○ mini-bach: IWSLT’14 32 sents、WMT 64 sents ○ dropout: IWSLT’14 0.2、WMT 0.1 (embeddingとdecoder output hiに対して行う) ● Recurrent Model ○ hidden unit: 512 (encoder, decoderどちらも) ○ optim: Adam (step幅: 3.125*10^(-4)) ○ validのpplに基づいてearly stopingを行ってる。 ● CNN Model ○ hidden unit: CNN_a 512 units、CNN_c 256 units、decoder 512 units ○ 窓幅: 3 ○ paddingはencoder output zが入力xと同じ (|x|=|z|) になるように。(fig1を参照) ○ optim: SGD and annealing(最初lr=0.1にして、validのpplが改善しなくなったらlrを減らしていく) 今回はlrの桁を減らしていって、lrが10^(-4)になるまで行う。 9
  • 10. 今回の実験の評価について ● IWSLT’14については5つ、WMTについては3つ、seedを変化させて学習したモデルの中から最も 良いvalid pplを出したものを最終的なBLEU評価に用いた。 ● beam searchについて ○ IWSLT’14 はbeam幅10、WMTはbeam幅も別のデータセットを使って調整した。 ● 未知語を出力した後の処理 ○ <unk>を出力した場合、attention scoreが最も高い入力単語を見て、事前に用意した辞書から 対応した単語で<unk>を置き換える。 ○ 辞書になかったら、入力単語をそのまま置き換える。 ○ この辞書はアライメントをとった学習データからとってくる。 (アライメントはfast_align (Dyer et al., 2013) を用いて張る) 10
  • 11. Results: IWSLT’14 (Recurrent or 非Recurrent) ● 畳み込み層 ○ CNN_a とCNN_cを1層から10層まで変化させて valid ppl が一番いいものを持ってくる (6層、3層) ● position embedding ○ pos がある→position embeddingを用いている。 11
  • 13. Analysis: CNN Encoder について(IWSLT’14) ● CNN_aとCNN_cを分ける話 ○ CNN_cが3層のときがいい感じ、このときCNN_aは6層がいい感じ → CNN_aはCNN_cの2,3倍の層の数にしておくといい。 ○ CNN_aとCNN_cを分けなかったとき 22.9 BLEU(層の数を増やしてもダメでした) ○ CNN_a: 広い範囲の文脈を見て情報を統合してそう CNN_c: 入力単語により近い感じの浅いところを見てそう 13
  • 15. Analysis: 入力文長に対しての性能 15WMT’15 En-Ge newstest2015の出力を文長で15分割した
  • 16. Analysis: 学習時間と出力時間について ● 学習時間(IWSLT’14) ○ Tesla M40 GPUを使用 ○ single layer BiLSTM: 4,300 target words/second ○ 6/3 convolution encoder: 6,400 target words/second ○ Adamの方がSGDより収束が速いため、全体の学習時間はBiLSTMが速かった。 ● 出力時間 ○ Intel Haswell CPU clocked at 2.50GHzをシングルスレッドで使用した。 ○ IWSLT’14: 1.35倍速いしBLEUも上がった。(hidden layerやembedding sizeも同じ) ○ WMT’15: Conv. 8/4はBiLSTMより2.1倍速い。(encoderのembedding sizeが違う(BiLSTM > conv.)) ○ そもそも1回でLSTMは2つ行列乗算が必要なのに対し、convは行列乗算が1つで良いのが効いてる 16
  • 17. まとめ ● 畳み込みネットワークを用いたNMTのencoderを提案した。 ○ recurrentにやるよりも並列化でき、入力文の長距離依存性を短いパスで掴める。 ○ 入力文のposition embeddingを入れたり、attention計算用にCNNを2つ用いた。 ● recurrent encoder と比較して同じくらいの性能が得られた。 ○ baselineとしたBiLSTMとは同じくらいかそれ以上の性能が得られた。 ○ 他の手法と比べてもそれほど悪くはなかった。 ● 出力時間についてもよくなった。 ○ 双方向のrecurrent encoderと比べて2倍速くなった。 ● Future work ○ conv. encoderを用いて収束の速い学習を行いたい。 ○ 文字単位のencoderにも使えそう。 ○ 他のseq2seqのtaskにも適応したい。(summarization, constituency parsing, dialog modeling) ● 個人的感想 ○ 比較について: モデルが既存のものと大きく異なるのにこんな感じ(setting, 評価にBLEUのみ)でいいの...? 先行研究と設定を一緒にしたりしなかったりどういうこと...? ○ CNN encoder: わざわざ使う1番のメリットは時間...?(性能とかパスが云々とかではない感じがした...) ○ 一番興味深かったのはattention用に2つEncoderを用意するところ 17
  • 18. 参考サイト、論文 ● facebookの実装 (lua, torch) ○ https://github.com/facebookresearch/fairseq ● Recurrent Continuous Translation Models. Kalchbrenner and Blunsom, EMNLP 2013 ● On the Properties of Neural Machine Translation: Encoder–Decoder Approaches . Cho et al., SSST 2014 ● Neural Machine Translation in Linear Time. Kalchbrenner et al., arXiv 2016 ● Convolutional Encoders for Neural Machine Translation. Lamb and Xie, 2016 ○ (https://cs224d.stanford.edu/ reports/LambAndrew.pdf) ● Encoding Source Language with Convolutional Neural Network for Machine Translation. Meng et al., ACL 2015 ● Context-dependent Translation selection using Convolutional Neural Network. Tu et al., ACL-IJCNLP 2015 ● Edinburgh neural machine translation systems for wmt 16. Sennrich et al., WMT16 2016 ● Schwenk 2014 ○ (http://www-lium. univ-lemans.fr/ ̃schwen /cslm_joint_ paper/) ● A Simple, Fast, and Effective Reparameterization of IBM Model 2. Dyer et al., ACL 2013 18

Notes de l'éditeur

  1. 論文中には先行研究のgeneration timeも記載あり 2つの行列乗算はrec方向の重みとinputに対しての重みだと思う