Skip to content

Instantly share code, notes, and snippets.

@sanjibnarzary
Last active September 8, 2023 16:28
Show Gist options
  • Save sanjibnarzary/7df30e458777f9c83c602e7e50000393 to your computer and use it in GitHub Desktop.
Save sanjibnarzary/7df30e458777f9c83c602e7e50000393 to your computer and use it in GitHub Desktop.
Testing a fairseq Translation Model
#!/usr/bin/env bash
#
# Adapted from https://github.com/facebookresearch/MIXER/blob/master/prepareData.sh
usage() {
echo "usage: <command> options:<e|p|b|a>"
echo "-e exp1 -p eng-brx -b 5000 -a transformer"
}
no_args="true"
while getopts e:l:b:a: flag; do
case "${flag}" in
e) experiment=${OPTARG} ;;
l) lang_pair=${OPTARG} ;;
b) bpe_token=${OPTARG} ;;
a) architecture=${OPTARG} ;;
*)
usage
exit
;;
esac
no_args="false"
done
[[ "$no_args" == "true" ]] && {
usage
exit 1
}
export exp=$experiment
export bpe_count=$bpe_token
langs=(${lang_pair//-/ })
export src=${langs[0]}
export tgt=${langs[1]}
export arch=${architecture:-"transformer"}
python test.py ${exp}/checkpoints/${arch}.${src}-${tgt}.${bpe_count} ${exp}/data-bin/${arch}.${src}-${tgt}.${bpe_count} data/bpe_data/bpe_data_${bpe_count}/bpe_data_${bpe_count}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment