1 / 38

Phrase-base Statistical Machine Translation

Phrase-base Statistical Machine Translation. 2008 年 8 月 29 日 勉強会 D2  中澤 敏明. 参考文献. “Statistical Phrase-Based Translation”, Koehn et al., HLT/NAACL 2003 http://www.iccs.inf.ed.ac.uk/~pkoehn/publications/phrase2003.pdf

deidra
Download Presentation

Phrase-base Statistical Machine Translation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Phrase-baseStatistical Machine Translation 2008年8月29日 勉強会 D2 中澤 敏明

  2. 参考文献 • “Statistical Phrase-Based Translation”, Koehn et al., HLT/NAACL 2003 • http://www.iccs.inf.ed.ac.uk/~pkoehn/publications/phrase2003.pdf • Statistical Machine Translation: the basic, the novel, and the speculative, Philipp Koehn, Tutorial at EACL 2006 • http://www.iccs.inf.ed.ac.uk/~pkoehn/publications/tutorial2006.pdf • SMT講習会の資料 by 山本幹雄先生 • http://if-lab.slis.tsukuba.ac.jp/fujii/ntc7patmt/SMT_tutorial2007/myama.pdf

  3. 今日話すこと • Training • 対象化単語アライメント • フレーズ抽出 • フレーズ翻訳確率などの計算(Log-linear Model) • MERT (Minimum Error Rate Training) • Decoding • Decoding Process • Multistack Beam-search

  4. 実習 • Phrase-based SMTのツールキット、mosesを実際に動かしてみる(英日翻訳実験) • 言語モデルの構築 • 翻訳モデルの構築 • チューニング(MERT) • 翻訳 • 翻訳結果の評価

  5. 注意 • orchidで動かしてください • 64bitマシン以外では動かない設定になっています • 混んでいるノードで動かすのはやめましょう • できれば全員別々のノードで • orchid[[01-40]]を使いましょう • orchidに負荷をかけるのはやめましょう

  6. 実習 • 言語モデルの構築 • srilmというツールを利用 • http://www.speech.sri.com/projects/srilm/ • ngram-count -order 5 -interpolate -kndiscount -text /avocado3/moses/data/train_lm.ja -lm 1M.ja.lm

  7. 統計翻訳の気持ち(1/2) • ある原言語文fが与えられたとき、     を最大とするような目的言語文eがfの翻訳 • ここでBayes Ruleを適用すると、 ^ 言語モデル 翻訳モデル ※ Noisy Channel Model と呼ばれる

  8. 統計翻訳の気持ち(2/2) •      を使って翻訳する場合、かなり良いモデルを作る必要がある • Bayes Ruleを使っていくつかのモデルに分けることにより、各モデルがある程度良いものであれば、それらが相補的に働く • 言語モデルと翻訳モデルをより良いものにしていき、精度を向上させよう!

  9. 実習 • 翻訳モデルの構築 • 双方向でのGIZA++から翻訳モデルの構築まで • train-factored-phrase-model.perl -scripts-root-dir /avocado3/moses/scripts -corpus ../data/train -f en -e ja -alignment grow-diag-final-and -reordering msd-bidirectional-fe -lm 0:5:/avocado3/moses/lm/1M.ja.lm:0 -factor-delimiter ‘|||’

  10. 今日話すこと • Training • 対象化単語アライメント • フレーズ抽出 • フレーズ翻訳確率などの計算(Log-linear Model) • MERT (Minimum Error Rate Training) • Decoding • Decoding Process • Multistack Beam-search

  11. Training • 対称化単語アライメントを生成 • GIZA++を双方向に実行し、ヒューリスティックスにより統合 • 単語アライメントに無矛盾なphraseペアを抽出 • 全ての無矛盾な単語列ペアをphraseとする • フレーズ翻訳確率、lexicalized-reorderingモデルなどを計算・生成 • 抽出されたphraseから計算

  12. 対称化単語アライメント • MosesはGIZA++による単語アライメント結果を利用 • GIZA++には方向性があり、1対多のアライメントしか生成できない(多対多が生成不可能) • GIZA++を双方向に実行し、2つの1対多アライメント結果を統合(対称化)して、多対多のアライメント結果とする

  13. 対称化単語アライメント Intersection Union Precision High Low High Recall Low

  14. 対称化ヒューリスティックス • 基本4種 • intersection • union • grow • grow-diag • 最終処理3種(未対応の単語に関する処理) • なし • final • final-and • 両方向ともにある対応点のみ • 各方向の対応点すべて • intersectionからスタートして拡張 • grow=縦・横 grow-diag=縦・横・対角 • 少なくとも片方の言語で対応がない • 両言語ともに対応がない

  15. intersection

  16. grow-diag-final

  17. abstract code diag

  18. Phraseペアの抽出 • 対称化単語アライメント結果を元に、矛盾しないphraseペアを全て抽出 • ここで言うphraseとは単純に連続する単語列を意味し、統語的な意味は一切ない • 「矛盾しない」とは・・・

  19. Phraseペアの抽出

  20. Log-linear Model • Feature functions(moses default: 14 params) • language model (1 param) • phrase translation table (5 params) • reordering model (7 params) • word penalty (1 param)

  21. phrase translation table • 5 parameters • phrase translation probability • lexical weighting • phrase translation probability • lexical weighting • phrase penalty

  22. lexical weighting • phraseペアの質を評価するための重み

  23. lexicalized reordering • MSD vs monotonicity • monotone, swap, discontinuous • monotone, non-monotone • f vs fe • model is conditioned on f vs both f and e • unidirectional vs bidirectional • For each phrase, the ordering of itself in respect to the previous is considered. For bidirectional models, also the ordering of the next phrase in respect to the currect phrase is modeled.

  24. reordering model • 7 parameters (msd-bidirectional-fe) • simple distance-base model

  25. Log-linear Model • Feature functions • language model (1 param) 0.5 • phrase translation table (5 params) 0.2 • reordering model (7 params) 0.3 • word penalty (1 param) -1

  26. 今日話すこと • Training • 対象化単語アライメント • フレーズ抽出 • フレーズ翻訳確率などの計算(Log-linear Model) • MERT (Minimum Error Rate Training) • Decoding • Decoding Process • Multistack Beam-search

  27. 実習 • チューニング(MERT) • developmentsetを用いてlog-linear modelのλをBLEUが向上するように調整 • mert-moses.pl --rootdir /avocado3/moses/scripts --working-dir . ../data/dev.en ../data/dev.ja /share/usr-x86_64/bin/moses ../tm/model/moses.ini

  28. Minimum Error Rate Training [Och, 2003] •  がよくなるように  を調整 • Developmentセットを利用して、評価関数を最大にするような翻訳結果が選択されるように調整 • Developmentセットは1000文程度 • 評価関数はBLEUを用いるのが一般的 • 各文についてn-bestの翻訳候補を出力し、正解と比較してよりよい候補が上位に来るように調整 • 10~20回程度繰り返して重みを徐々に変化 • データサイズにもよるが、終わるまで数日かかることも・・・

  29. 今日話すこと • Training • 対象化単語アライメント • フレーズ抽出 • フレーズ翻訳確率などの計算(Log-linear Model) • MERT (Minimum Error Rate Training) • Decoding • Decoding Process • Multistack Beam-search

  30. 実習 • 翻訳 • MERTによって調整されたλを用いて翻訳 • phrase table全てを読み込むとメモリが足らなくなるので、翻訳する文に必要なphrase tableのみをあらかじめfiltering • filter-model-given-input.pl filterd ../tune/moses.ini ../data/test.ja • filteringされたphrase tableを用いて翻訳 • moses -f filterd/moses.ini < ../data/test.en

  31. Decoding • 翻訳文は左側(先頭)から順に生成 • Multistack Beam-searchで最適な翻訳を探索 • 翻訳が完了している単語数ごとにstackを用意し、それぞれのstackで上位n個のみを保持

  32. Decoding Input sentence: Mary did not slap the green witch Output sentence:

  33. Translation Options • 翻訳するphraseの順番や、そのphraseの翻訳候補はたくさんある • 全てを探索することは不可能

  34. Multistack Beam-search • 翻訳が完了している単語数ごとにstackを用意し、それぞれのstackで確率上位n個の「仮説」のみを保持 • 確率は、その時点までの翻訳確率と、未翻訳部の推定翻訳確率とから求める

  35. Future Cost • 全てのtranslation optionについて、phrase翻訳確率とphrase内言語モデル確率を掛け算 • reordering(訳す順序)は考慮しない • ほんとは正しい翻訳仮説がn-bestから外れる可能性がある • あらかじめ全ての部分についてfuture costを計算しておけるので、decode時はfuture cost tableを引くだけでよい

  36. 実習 • 翻訳結果の評価 • mtevalというツールを使ってBLEU(NIST)を計算 • http://www.nist.gov/speech/tests/mt/2008/scoring.html • mteval.pl -s src.sgm -r ref.sgm -t tst.sgm • BLEUのみ、NISTのみ計算するオプションや、文ごとのBLEUを出すオプションなどがある • multi referenceのときにバグがあるという噂・・・

More Related