Skip to content

Commit

Permalink
added sample scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
duyvuleo committed Apr 19, 2016
1 parent 7ecbf20 commit 5c15ad8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
7 changes: 6 additions & 1 deletion scripts/compute-perp.sh
@@ -1,3 +1,8 @@
# get the scores from n-best list
# assume that the n-best list should follow the format:
# line in source language ||| line in target language
# and all sentence pairs are wrapped up with <s>, </s>, <unk> markers
./attentional -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -T ../sample-data/50best.de-en.unk.cap -i ./work/exp/params.de-en.AM.l_2_h_512_a_256_lstm_bidirectional --lstm --bidirectional -l 2 -h 512 -a 256 --rescore &>./work/res/scores.50best.de-en.AM.l_2_h_512_a_256_lstm_bidirectional &

---
# note that if using advanced models (with alignment features), please follow the usage of extra params in train.sh

9 changes: 8 additions & 1 deletion scripts/decode.sh
@@ -1,3 +1,10 @@
# Beam Search decoding
./attentional --beam 5 -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -T ../sample-data/test.de-en.unk.cap -i ./work/exp/params.de-en.AM.l_2_h_512_a_256_lstm_bidirectional --lstm --bidirectional -l 2 -h 512 -a 256 &>./work/res/translation.beam.de-en.AM.l_2_h_512_a_256_lstm_bidirectional & #with beam_width=5

# Greedy Viterbi decoding
./attentional -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -T ../sample-data/test.de-en.unk.cap -i ./work/exp/params.de-en.AM.l_2_h_512_a_256_lstm_bidirectional --lstm --bidirectional -l 2 -h 512 -a 256 &>./work/res/translation.greedy.de-en.AM.l_2_h_512_a_256_lstm_bidirectional &

# Sampling decoding


---

36 changes: 35 additions & 1 deletion scripts/train.sh
@@ -1,3 +1,37 @@
## train vanilla attentional models

# print help (no params)
./attentional

# forward model
./attentional -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -p ./work/exp/params.de-en.AM.l_2_h_512_a_256_lstm_bidirectional --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.de-en.AM.train.l_2_h_512_a_256_lstm_bidirectional &

# backward model (simply add '--swap' param)
./attentional --swap -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -p /work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.en-de.AM.train.l_2_h_512_a_256_lstm_bidirectional &

## train attentional model with alignment features (including positional bias, Markov conditioning, and global/local fertilities)

# with positional bias (simple add '--gz-position' param)
./attentional --gz-position -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -p /work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional_giza-position --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.en-de.AM.train.l_2_h_512_a_256_lstm_bidirectional_giza-position &

# with Markov condition (simple add '--gz-condition' param)
./attentional --gz-markov -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -p /work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional_giza-markov --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.en-de.AM.train.l_2_h_512_a_256_lstm_bidirectional_giza-markov &

# with local fertility (simple add '--gz-fertility' param)
./attentional --gz-fertility -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -p /work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional_giza-fertility --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.en-de.AM.train.l_2_h_512_a_256_lstm_bidirectional_giza-fertility &

# with all the above features (simple add '--giza' param)
./attentional --giza -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -p /work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional_giza-all --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.en-de.AM.train.l_2_h_512_a_256_lstm_bidirectional_giza-all &

## train attentional model with global fertility
# First, we need a pre-trained model with (better) or without alignment features using the commands mentioned earlier
# Next, let's train the model with global fertility (simple add '--fertility' param)
./attentional --giza --fertility -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -i /work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional_giza-all --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.en-de.AM.train.l_2_h_512_a_256_lstm_bidirectional_giza-all_continued_fertility &

# train bi-attentional model
# First, we need pre-trained models with both directions (forward and backward)
# e.g. forward model: ./work/exp/params.de-en.AM.l_2_h_512_a_256_lstm_bidirectional
# and backward model: ./work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional
./biattentional -t ../sample-data/train.de-en.unk.cap -d ../sample-data/dev.de-en.unk.cap -i ./work/exp/params.de-en.AM.l_2_h_512_a_256_lstm_bidirectional -i /work/exp/params.en-de.AM.l_2_h_512_a_256_lstm_bidirectional -p /work/exp/params.de-en_en-de.AM.l_2_h_512_a_256_lstm_bidirectional_symmetry --lstm --bidirectional -l 2 -h 512 -a 256 -v &>/work/exp/log.de-en_en-de.AM.train.l_2_h_512_a_256_lstm_bidirectional_symmetry &

---

0 comments on commit 5c15ad8

Please sign in to comment.