-
Notifications
You must be signed in to change notification settings - Fork 0
/
21-test-wait-k.sh
48 lines (41 loc) · 1.63 KB
/
21-test-wait-k.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
46
47
48
#!/bin/bash
###
### Train a wait-k model
###
basedir=`dirname $0`
scriptdir=${basedir}/scripts
FAIRSEQ_ROOT=${basedir}/fairseq-waitk/fairseq
SIMULEVAL_ROOT=${basedir}/SimulEval
. ${scriptdir}/00-env.sh
parse_options "$@"
shift $?
if test ${verbose} -gt 0 ; then set -x ; fi
if test -z "${K}" ; then
K=20
fi
model_dir=${model_basedir}/wait-${K}
devtest_dir=${devtest_basedir}/wait-${K}
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_t2t_enja.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