-
Notifications
You must be signed in to change notification settings - Fork 0
/
31-test-mma-il.sh
45 lines (38 loc) · 1.6 KB
/
31-test-mma-il.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
###
### Train an MMA-IL model
###
basedir=`dirname $0`
scriptdir=${basedir}/scripts
FAIRSEQ_ROOT=${basedir}/fairseq-mma-il/fairseq
SIMULEVAL_ROOT=${basedir}/SimulEval
. ${scriptdir}/00-env.sh
parse_options "$@"
shift $?
if test ${verbose} -gt 0 ; then set -x ; fi
model_dir=${model_basedir}/mma-il
devtest_dir=${devtest_basedir}/mma-il
decoder_options=""
if test ${TRG} = "ja" ; then
decoder_options="${decoder_options} --sacrebleu-tokenizer ja-mecab"
decoder_options="${decoder_options} --eval-latency-unit char --no-space"
decoder_options="${decoder_options} --src-splitter-type sentencepiecemodel"
decoder_options="${decoder_options} --src-splitter-path ${sentencepiece_dir}/${SRC}${TRG}.spm.model"
fi
if test ! -s ${model_dir}/checkpoint_best.pt ; then
error_and_die "No model checkpoints are found in ${model_dir}."
elif test ! -e ${model_dir}/.done ; then
warn "The model training has not completed. The best intermediate checkpoint will be used."
fi
for dataset in ${devtestset[@]} ; do
env PYTHONPATH="${FAIRSEQ_ROOT}:${SIMULEVAL_ROOT}" \
${python3} ${SIMULEVAL_ROOT}/bin/simuleval \
--agent ${FAIRSEQ_ROOT}/examples/simultaneous_translation/eval/agents/simul_trans_text_agent.py \
--source ${mustc_data_dir}/${dataset:6}/txt/${dataset:6}.${SRC} \
--target ${mustc_data_dir}/${dataset:6}/txt/${dataset:6}.${TRG} \
--data-bin ${preprocessed_data_dir} \
--model-path ${model_dir}/checkpoint_best.pt \
--output ${devtest_dir}/${dataset} \
--scores ${decoder_options} \
--gpu
done