2022-02-25 18:52:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
. ./tests/lib.sh
|
|
|
|
|
|
|
|
# test e2e dialogue tasks
|
|
|
|
|
|
|
|
hparams=(
|
2022-03-03 00:23:42 +00:00
|
|
|
"--pretrained_model Helsinki-NLP/opus-mt-en-de"
|
2022-02-25 18:52:48 +00:00
|
|
|
"--pretrained_model sshleifer/bart-tiny-random"
|
2022-06-29 21:00:50 +00:00
|
|
|
"--pretrained_model Helsinki-NLP/opus-mt-en-de"
|
2022-02-25 18:52:48 +00:00
|
|
|
)
|
|
|
|
tasks=(
|
|
|
|
bitod
|
|
|
|
bitod_dst
|
2022-06-29 21:00:50 +00:00
|
|
|
risawoz
|
2022-02-25 18:52:48 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
for i in ${!hparams[*]};
|
|
|
|
do
|
2022-08-25 04:04:08 +00:00
|
|
|
# train
|
|
|
|
genienlp train \
|
|
|
|
--train_tasks ${tasks[i]} \
|
|
|
|
--train_batch_tokens 100 \
|
|
|
|
--val_batch_size 300 \
|
|
|
|
--train_iterations 4 \
|
|
|
|
--min_output_length 2 \
|
|
|
|
--preserve_case \
|
|
|
|
--save_every 2 \
|
|
|
|
--log_every 2 \
|
|
|
|
--val_every 2 \
|
|
|
|
--save $workdir/model_$i \
|
|
|
|
--data $SRCDIR/dataset/bitod \
|
|
|
|
--exist_ok \
|
|
|
|
--embeddings $EMBEDDING_DIR \
|
|
|
|
--no_commit ${hparams[i]}
|
2022-02-25 18:52:48 +00:00
|
|
|
|
2022-08-25 04:04:08 +00:00
|
|
|
# greedy prediction
|
|
|
|
genienlp predict \
|
|
|
|
--tasks ${tasks[i]} \
|
|
|
|
--evaluate test \
|
|
|
|
--path $workdir/model_$i \
|
|
|
|
--overwrite \
|
|
|
|
--eval_dir $workdir/model_$i/eval_results/ \
|
|
|
|
--data $SRCDIR/dataset/bitod \
|
|
|
|
--embeddings $EMBEDDING_DIR \
|
|
|
|
--extra_metrics e2e_dialogue_score
|
2022-02-25 18:52:48 +00:00
|
|
|
|
2022-08-25 04:04:08 +00:00
|
|
|
# e2e prediction
|
|
|
|
genienlp predict \
|
|
|
|
--tasks ${tasks[i]} \
|
|
|
|
--evaluate test \
|
|
|
|
--path $workdir/model_$i \
|
|
|
|
--overwrite \
|
|
|
|
--eval_dir $workdir/model_$i/e2e_eval_results/ \
|
|
|
|
--data $SRCDIR/dataset/bitod \
|
|
|
|
--embeddings $EMBEDDING_DIR \
|
|
|
|
--extra_metrics e2e_dialogue_score \
|
|
|
|
--e2e_dialogue_evaluation
|
2022-03-02 22:57:25 +00:00
|
|
|
|
2022-08-25 04:04:08 +00:00
|
|
|
# check if result file exists
|
|
|
|
if ! [[ -f $workdir/model_$i/eval_results/test/${tasks[i]}.tsv || -f $workdir/model_$i/e2e_eval_results/test/e2e_dialogue_preds.json ]] ; then
|
|
|
|
echo "File not found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-03-02 22:57:25 +00:00
|
|
|
|
2022-08-25 04:04:08 +00:00
|
|
|
# check export and server mode
|
|
|
|
if [ $i == 0 ] ; then
|
|
|
|
echo "Testing export"
|
|
|
|
genienlp export --path $workdir/model_$i --output $workdir/model_"$i"_exported
|
2022-02-25 18:52:48 +00:00
|
|
|
|
2022-08-25 04:04:08 +00:00
|
|
|
echo "Testing the server mode"
|
|
|
|
echo '{"id": "dummy_example_1", "context": "show me .", "question": "translate to thingtalk", "answer": "now => () => notify"}' | genienlp server --path $workdir/model_$i --stdin
|
|
|
|
fi
|
2022-02-25 18:52:48 +00:00
|
|
|
|
2022-08-25 04:04:08 +00:00
|
|
|
if [ $i == 0 ] ; then
|
|
|
|
# check if predictions matches expected_results
|
|
|
|
diff -u $SRCDIR/expected_results/bitod/bitod.tsv $workdir/model_$i/eval_results/test/bitod.tsv
|
|
|
|
diff -u $SRCDIR/expected_results/bitod/e2e_dialogue_preds.json $workdir/model_$i/e2e_eval_results/test/e2e_dialogue_preds.json
|
|
|
|
fi
|
2022-02-25 18:52:48 +00:00
|
|
|
|
2022-08-25 04:04:08 +00:00
|
|
|
rm -rf $workdir/model_$i $workdir/model_"$i"_exported
|
2022-02-25 18:52:48 +00:00
|
|
|
|
|
|
|
done
|