phrase-base statistical machine translation
DESCRIPTION
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 - PowerPoint PPT PresentationTRANSCRIPT
Phrase-baseStatistical 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
• 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
今日話すこと
1. Trainingi. 対象化単語アライメントii. フレーズ抽出iii. フレーズ翻訳確率などの計算 (Log-linear
Model)
2. MERT (Minimum Error Rate Training)3. Decoding
i. Decoding Processii. Multistack Beam-search
実習
• Phrase-based SMT のツールキット、 mosesを実際に動かしてみる(英日翻訳実験)1. 言語モデルの構築2. 翻訳モデルの構築3. チューニング( MERT )4. 翻訳5. 翻訳結果の評価
注意
• orchid で動かしてください– 64bit マシン以外では動かない設定になってい
ます• 混んでいるノードで動かすのはやめましょ
う– できれば全員別々のノードで
• orchid[[01-40]] を使いましょう– orchid に負荷をかけるのはやめましょう
実習
1. 言語モデルの構築– 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
統計翻訳の気持ち( 1/2 )• ある原言語文 f が与えられたとき、
を最大とするような目的言語文 eが f の翻訳
• ここで Bayes Rule を適用すると、
)|( feP
)|(maxargˆ fePee
^
)(
)|()()|(
fP
efPePfeP
)|()(maxargˆ efPePee
言語モデル 翻訳モデル
※ Noisy Channel Model と呼ばれる
統計翻訳の気持ち( 2/2 )
• を使って翻訳する場合、かなり良いモデルを作る必要がある
• Bayes Rule を使っていくつかのモデルに分けることにより、各モデルがある程度良いものであれば、それらが相補的に働く
• 言語モデルと翻訳モデルをより良いものにしていき、精度を向上させよう!
)|( feP
実習
2. 翻訳モデルの構築– 双方向での 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 ‘|||’
今日話すこと
1. Trainingi. 対象化単語アライメントii. フレーズ抽出iii. フレーズ翻訳確率などの計算 (Log-linear
Model)
2. MERT (Minimum Error Rate Training)3. Decoding
i. Decoding Processii. Multistack Beam-search
Training
1. 対称化単語アライメントを生成– GIZA++ を双方向に実行し、ヒューリスティッ
クスにより統合
2. 単語アライメントに無矛盾な phrase ペアを抽出
– 全ての無矛盾な単語列ペアを phrase とする
3. フレーズ翻訳確率、 lexicalized-reordering モデルなどを計算・生成
– 抽出された phrase から計算
対称化単語アライメント
• Moses は GIZA++ による単語アライメント結果を利用
• GIZA++ には方向性があり、 1 対多のアライメントしか生成できない(多対多が生成不可能)
• GIZA++ を双方向に実行し、 2 つの 1 対多アライメント結果を統合(対称化)して、多対多のアライメント結果とする
対称化単語アライメント
UnionIntersection
Precision
Recall Low
LowHigh
High
対称化ヒューリスティックス
• 基本 4 種– intersection– union– grow– grow-diag
• 最終処理 3 種(未対応の単語に関する処理)– なし– final– final-and
両方向ともにある対応点のみ各方向の対応点すべてintersection からスタートして拡張grow= 縦・横 grow-diag= 縦・
横・対角
少なくとも片方の言語で対応がない
両言語ともに対応がない
intersection
grow-diag-final
abstract code
diag
Phrase ペアの抽出
• 対称化単語アライメント結果を元に、矛盾しない phrase ペアを全て抽出
• ここで言う phrase とは単純に連続する単語列を意味し、統語的な意味は一切ない
• 「矛盾しない」とは・・・
Phrase ペアの抽出
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)
)|(maxargˆ fepee
M
mmm
efeh
1
),(maxarg
phrase translation table
• 5 parameters– phrase translation probability– lexical weighting– phrase translation probability– lexical weighting– phrase penalty
)|( efp
),|( afepw
718.2)1exp(
fefC
efCefp
),(
),()|(
)|( fep
),|( aefpw
lexical weighting
• phrase ペアの質を評価するための重み
aji
ji
n
iw efw
ajijaefp
),(1
)|(),(|
1),|(
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.
reordering model
• 7 parameters (msd-bidirectional-fe)– – – – – – – simple distance-base model
),|( efmonotonepprevious),|( efswappprevious
),|( efousdiscontinupprevious),|( efmonotonep following
),|( efswapp following
),|( efousdiscontinup following
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
M
mmm
efeh
1
),(maxarg
今日話すこと
1. Trainingi. 対象化単語アライメントii. フレーズ抽出iii. フレーズ翻訳確率などの計算 (Log-linear
Model)
2. MERT (Minimum Error Rate Training)3. Decoding
i. Decoding Processii. Multistack Beam-search
実習
3. チューニング( MERT )– development set を用いて 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
Minimum Error Rate Training
• がよくなるように を調整– Development セットを利用して、評価関数を最大
にするような翻訳結果が選択されるように調整– Development セットは 1000 文程度– 評価関数は BLEU を用いるのが一般的– 各文について n-best の翻訳候補を出力し、正解と
比較してよりよい候補が上位に来るように調整– 10 ~ 20 回程度繰り返して重みを徐々に変化– データサイズにもよるが、終わるまで数日かかる
ことも・・・
e m[Och, 2003]
Param Default 1 2 3 6 9 12 13
BLEU --- --- 14.0 14.4 17.5 21.5 22.1 22.1
LM 0.5 1 0.039 0.038 0.104 0.047 0.052 0.051
TM1 0.2 0.3 0.011 0.010 0.042 0.012 0.042 0.042
TM2 0.2 0.2 0.020 0.020 0.031 0.038 0.031 0.031
TM3 0.2 0.3 0.051 0.049 0.030 0.008 0.034 0.034
TM4 0.2 0.2 0.016 0.068 0.011 0.018 0.016 0.016
TM5 0.2 0 0.003 0.003 0.034 -0.055 0.115 0.114
D1 0.3 1 -0.001 -0.001 0.017 -0.004 0.005 0.005
D2 0.3 1 -0.065 -0.061 0.034 0.087 0.045 0.044
D3 0.3 1 -0.191 -0.186 0.058 -0.032 0.109 0.108
D4 0.3 1 0.055 0.008 0.133 0.383 0.215 0.215
D5 0.3 1 -0.004 -0.010 0.133 0.025 0.123 0.123
D6 0.3 1 0.045 0.045 0.062 0.122 -0.007 -0.009
D7 0.3 1 0.062 0.072 0.130 0.085 0.134 0.133
W -1 0 -0.438 -0.428 -0.181 -0.084 -0.074 -0.074
今日話すこと
1. Trainingi. 対象化単語アライメントii. フレーズ抽出iii. フレーズ翻訳確率などの計算 (Log-linear
Model)
2. MERT (Minimum Error Rate Training)3. Decoding
i. Decoding Processii. Multistack Beam-search
実習
4. 翻訳– 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
Decoding
• 翻訳文は左側(先頭)から順に生成• Multistack Beam-search で最適な翻訳を探
索– 翻訳が完了している単語数ごとに stack を用
意し、それぞれの stack で上位 n 個のみを保持
Decoding
Maria no dio una bofetada a la bruja verde
Input sentence:
Output sentence:
Mary did not slap the green witch
Translation Options
• 翻訳する phrase の順番や、その phrase の翻訳候補はたくさんある
• 全てを探索することは不可能
Multistack Beam-search
• 翻訳が完了している単語数ごとに stack を用意し、それぞれの stack で確率上位 n 個の「仮説」のみを保持
• 確率は、その時点までの翻訳確率と、未翻訳部の推定翻訳確率とから求める
Future Cost
• 全ての translation option について、 phrase翻訳確率と phrase 内言語モデル確率を掛け算
• reordering (訳す順序)は考慮しない– ほんとは正しい翻訳仮説が n-best から外れる
可能性がある• あらかじめ全ての部分について future cost
を計算しておけるので、 decode 時はfuture cost table を引くだけでよい
実習
5. 翻訳結果の評価– 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 のときにバグがあるという噂・
・・