visualizing and understanding neural machine translation

30
Visualizing and Understanding Neural Machine Translation Yanzhuo Ding, Yang Liu, Huanbo Luan, Maosong Sun ACL 2017 (outstanding paper) スライド中の図表は論文から引用されたもの 小町守 <[email protected]> 9 回最先端 NLP 勉強会 @ リクルート MTL カフェ 2017/09/15

Upload: mamoru-komachi

Post on 21-Jan-2018

614 views

Category:

Technology


8 download

TRANSCRIPT

Page 1: Visualizing and Understanding Neural Machine Translation

Visualizing and Understanding Neural Machine Translation

Yanzhuo Ding, Yang Liu, Huanbo Luan, Maosong Sun

ACL 2017 (outstanding paper)

※スライド中の図表は論文から引用されたもの

小町守

<[email protected]>

第9回最先端NLP勉強会@リクルートMTLカフェ

2017/09/15

Page 2: Visualizing and Understanding Neural Machine Translation

深層学習により機械翻訳の質が近年著しく向上しています

2https://research.googleblog.com/2016/09/a-neural-

network-for-machine.html

Page 3: Visualizing and Understanding Neural Machine Translation

ニューラル翻訳特有の問題がいくつかあります

未知語の扱い→the largest UNK in the world

Under-translation, over-translation

→in the history of the history of the history of the …

全然関係のない単語を出力

3Sato et al., Japanese-English Machine Translation

of Recipe Texts. WAT 2016.

Page 4: Visualizing and Understanding Neural Machine Translation

NMT 特有の誤りのエラー分析は簡単ではありません

原文小型甲殻類では , アミ類のアカイソアミ , ワレカラ類のニッポンワレカラとツカルワレカラは茨城県で初めて確認された。

N

M

T

in small crustaceans , <unk> and <unk> of <unk> and

<unk> were con- firmed for the first time in Ibaraki

Prefecture .

参照訳

among the small-type Crustacea , Paracanthomysis

hispida of Mysidae , and Caprella japonica and C.

tsugarensis of Caprellidae were confirmed for the first

time in Ibaraki Prefecture .

4Matsumura and Komachi. Tokyo Metropolitan University Neural

Machine Translation System for WAT 2017. WAT 2017.

Page 5: Visualizing and Understanding Neural Machine Translation

アテンションは役に立つがNMT のデバッグには不十分

5Matsumura et al., English-Japanese Neural Machine Translation

with Encoder-Decoder-Reconstructor. arXiv 2017.

Page 6: Visualizing and Understanding Neural Machine Translation

本研究の3行まとめ

層ごとの適合性伝播 LRP: layer-wise relevance

propagation (Bach et al., 2015) を用いて NMT

の可視化と解釈をする手法を提案

アテンションに基づくエンコーダ・デコーダフレームワーク (Bahdanau et al., 2015) に LRP を適応

中英翻訳でケーススタディを行い、NMT の翻訳誤りを分析(→アテンションだけを用いるのと比べて、解釈・デバッグしやすい)

6

Page 7: Visualizing and Understanding Neural Machine Translation

2017年現在ふつうの NMT

𝑃 𝒚 𝒙; 𝜽 =

𝑗=1

𝐽

𝑃(𝑦𝑗|𝒙, 𝒚<𝑗; 𝜽)

𝑃(𝑦𝑗|𝑥, 𝑦<𝑗; 𝜃) = 𝜌(𝑦𝑗−1, 𝑠𝑗 , 𝑐𝑗)

𝑠𝑗 = 𝑔(𝑠𝑗−1, 𝑦𝑗 , 𝑐𝑗)

𝑐𝑗 = 𝑖=1𝐼+1𝛼𝑗,𝑖ℎ𝑖

ℎ𝑖 = [ℎ𝑖; ℎ𝑖]

ℎ𝑖 = 𝑓(ℎ𝑖−1, 𝑥𝑖)

ℎ𝑖 = 𝑓(ℎ𝑖+1, 𝑥𝑖)

7

x: 入力(I単語)y: 出力(J単語)f, g, ρ: 非線形関数

Page 8: Visualizing and Understanding Neural Machine Translation

ニューラルネットワークの可視化・解釈の問題設定最終出力層に入力層のユニットがどれくらい貢献するか計算 (Bach et al.,

2015; Li et al.,

2016)

アテンションに基づくエンコーダ・デコーダで知りたいのは、原言語と目的言語の単語が右の状態にどれくらい貢献するか

1. ℎ𝑖 = 𝑓(ℎ𝑖−1, 𝑥𝑖): 原言語の前向き隠れ状態

2. ℎ𝑖 = 𝑓(ℎ𝑖+1, 𝑥𝑖): 原言語の後ろ向き隠れ状態

3. ℎ𝑖 = [ℎ𝑖; ℎ𝑖]: 原言語の隠れ状態

4. 𝑐𝑗 = 𝑖=1𝐼+1𝛼𝑗,𝑖ℎ𝑖: 原言語の文脈ベクトル

5. 𝑠𝑗 = 𝑔 𝑠𝑗−1, 𝑦𝑗 , 𝑐𝑗 : 目的言語の隠れ状態

6. 𝑦𝑗: 目的言語の単語埋め込み

8

Page 9: Visualizing and Understanding Neural Machine Translation

“New York” のベクトルに対する入力と出力ベクトルの関連度

“York” を出すとき、入力と出力の両方に関係している(黒くなっている)

隠れ状態と文脈ベクトルをどのように計算・可視化すればいいか?

9

Page 10: Visualizing and Understanding Neural Machine Translation

ニューロンレベルの関連度からベクトルの関連度を計算する

10

W の計算は Eq. (15)-(17)

Page 11: Visualizing and Understanding Neural Machine Translation

単純なフィードフォワードネットワークで関連度を計算

Wの計算は演算内容(行列の積、要素ごとの積、最大値等)によって変える (Bach et al., 2015)

O(|G|×|V|×Omax) で計算可能

Omaxはネットワーク中のニューロンの最大次数

ネットワーク全体のニューロンの計算をするのでアテンションの計算より重いが、並列計算やキャッシュによって高速化できる

11

Page 12: Visualizing and Understanding Neural Machine Translation

中英翻訳で可視化実験

データ

訓練: 125万文のパラレルコーパス

開発: NIST 2003(モデル選択)

テスト: NIST 2004(可視化)

ツール

GroundHog (Bahdanau et al., 2015)

→開発データでの BLEU スコアは 32.73

12

Page 13: Visualizing and Understanding Neural Machine Translation

原言語ベクトルの可視化:両方向の文脈を考慮

13

Page 14: Visualizing and Understanding Neural Machine Translation

目的言語ベクトルの可視化:アテンションとの違いもある

14

Page 15: Visualizing and Understanding Neural Machine Translation

未知語ベクトルの可視化:周辺文脈を見ているのがわかる

15

Page 16: Visualizing and Understanding Neural Machine Translation

ここからニューラル翻訳特有の問題のエラー分析(再掲) 未知語の扱い

→the largest UNK in the world

Under-translation, over-translation

→in the history of the history of the history of the …

全然関係のない単語を出力

16Sato et al., Japanese-English Machine Translation

of Recipe Texts. WAT 2016.

Page 17: Visualizing and Understanding Neural Machine Translation

未翻訳の誤り分析:文末記号を出すのが早すぎた

17

Page 18: Visualizing and Understanding Neural Machine Translation

繰り返しの誤り分析:目的言語の文脈の影響が大きい

18

Page 19: Visualizing and Understanding Neural Machine Translation

置換誤りの誤り分析:入出力の他の単語を見ている

19

Page 20: Visualizing and Understanding Neural Machine Translation

否定の反転の誤り分析:目的言語の文脈の影響が強い

20

Page 21: Visualizing and Understanding Neural Machine Translation

余分な単語の誤り分析:文末記号を(なぜか)見ている

21

Page 22: Visualizing and Understanding Neural Machine Translation

NMTのデコーディングとエラー分析のまとめ

アテンションは原言語と目的言語の関連の分析には役に立つが、アテンションだけでは目的言語の単語生成の理解には不十分

文脈中の単語の関連度は隠れ層ごとにかなり異なる(アテンションとも異なる)

単語生成には目的言語の文脈がとても重要

文末記号がいろんな問題(未翻訳、関係ない単語の生成、等)の原因である可能性

22

Page 23: Visualizing and Understanding Neural Machine Translation

深層学習の可視化の研究は始まったばかり

画像認識では出力層にどれくらい入力層の情報が関係するのか計算する研究が盛んにある(Bach et al., 2015; Li et al., 2016; …)

Bach et al. (2015) との違いは、NMT の入力は1

ピクセルではなく単語ベクトルであること→ベクトルレベルの適合性と重みを計算する

Li et al. (2016) との違いは、偏微分ではなく適合性を用いていること→活性化関数が微分可能でも滑らかでなくてもいい

アテンションはソースとターゲットの単語の関係しか見られないが、適合性は任意の隠れ層の間の関係の度合いを計算するために使える

23

Page 24: Visualizing and Understanding Neural Machine Translation

まとめと今後の課題: NMTの可視化と解釈

Layer-wise relevance propagation を用いることで NMT の可視化と解釈を行う手法を提案

任意の隠れ層と文脈の間の関連度を計算可能

アテンションメカニズムより深い分析が可能

今後の課題

他の NMT モデル、他の言語対での有効性

翻訳の関連度を明示的に考慮するようなモデル

24

Page 25: Visualizing and Understanding Neural Machine Translation

所感

アテンションを見るくらいしか簡単にNMTの分析ができないと思っていたので、有効そう。

NMT 特有の誤りの原因の検討がつくのは大きい

計算自体は結構重たそう(キャッシュすればいいとか書いてあるが、1層のシンプルな NMT だからこれで動いているのでは?)

目的言語の文脈は明らかに重要だが、文末記号は本当に翻訳誤りの原因なのか?→他の問題が文末記号に現れているのではないか?

25

Page 26: Visualizing and Understanding Neural Machine Translation

質疑応答①

Q: 可視化ができるのは分かったが、実際にNMT のデバッグができるような方法は提案されているのか?

A: デバッグ方法までは提案されておらず、Tu et

al. (2017) のような context gate を考慮する重要性について指摘されていた。将来的にはここで誤りの原因の検討をつけて改善していきたい。

26

Page 27: Visualizing and Understanding Neural Machine Translation

質疑応答②

Q: このような分析ができる例があるのは分かったが、実際にこのような分析ができるのは定量的にはどれくらいあるのか?

A: NMT と PBSMT のエラーの分布については例えば Sato et al. (2016) で調べたが、それぞれの中でどれくらいが今回の手法できれいに可視化できるのかは分からない。今後実装して調べてみたい。

27

Page 28: Visualizing and Understanding Neural Machine Translation

質疑応答③

Q: 目的言語の文脈が重要だというのは分かったが、それ以外の情報は本当に重要なのか?

A: それは疑問。実際、文末記号に関する議論はかなり怪しいと考えている。他の原因で翻訳誤りが起きているのが、文末記号へのアテンションまたは文末記号への関連度の集中という形で出てきているのかなと思っている。

28

Page 29: Visualizing and Understanding Neural Machine Translation

参考文献

Ding et al. Visualizing and Understanding Neural

Machine Translation. ACL 2017.

Bach et al. On pixel-wise explanations for non-

linear classifier decisions by layer-wise

relevance propagation. PLoS ONE 2015.

Li et al. Visualizing and understanding neural

models in NLP. NAACL 2016.

Tu et al. Context gates for neural machine

translations. ACL 2017.

29

Page 30: Visualizing and Understanding Neural Machine Translation

(首都大のNMT)関連文献

Matsumura et al. English-Japanese Neural

Machine Translation with Encoder-Decoder-

Reconstructor. arXiv 2017.

Sato et al. Japanese-English Machine

Translation of Recipe Texts. WAT 2016.

Yamagishi et al. Improving Japanese-to-English

Neural Machine Translation by Voice Prediction.

IJCNLP 2017.

Matsumura and Komachi. Tokyo Metropolitan

University Neural Machine Translation System

for WAT 2017. WAT 2017. 30