Skip to content

Commit

Permalink
fix bug in pt/translation example (intel#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
xin3he authored Aug 5, 2022
1 parent 2234981 commit 8e3c3c0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ function init_params {

# run_benchmark
function run_benchmark {
extra_cmd=''

extra_cmd='None'
if [[ ${mode} == "accuracy" ]]; then
mode_cmd=" --accuracy_only"
elif [[ ${mode} == "benchmark" ]]; then
Expand All @@ -65,10 +64,9 @@ function run_benchmark {

if [ "${topology}" = "t5_WMT_en_ro" ];then
model_name_or_path='t5-small'
extra_cmd="--source_lang en --target_lang ro --dataset_name wmt16 --dataset_config_name ro-en"
extra_cmd='translate English to Romanian: '
elif [ "${topology}" = "marianmt_WMT_en_ro" ]; then
model_name_or_path='Helsinki-NLP/opus-mt-en-ro'
extra_cmd="--source_lang en --target_lang ro --dataset_name wmt16 --dataset_config_name ro-en"
fi

if [[ ${int8} == "true" ]]; then
Expand All @@ -82,9 +80,12 @@ function run_benchmark {
--predict_with_generate \
--per_device_eval_batch_size ${batch_size} \
--output_dir ${tuned_checkpoint} \
--source_prefix "translate English to Romanian: " \
--source_lang en \
--target_lang ro \
--dataset_name wmt16 \
--dataset_config_name ro-en\
${mode_cmd} \
${extra_cmd}
--source_prefix "$extra_cmd"
}

main "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,17 @@ function init_params {

# run_tuning
function run_tuning {
extra_cmd=''
extra_cmd='None'
batch_size=16
model_type='bert'

if [ "${topology}" = "t5_WMT_en_ro" ];then
model_name_or_path='t5-small'
model_type='t5'
extra_cmd="--source_lang en --target_lang ro --dataset_name wmt16 --dataset_config_name ro-en"
extra_cmd='translate English to Romanian: '
elif [ "${topology}" = "marianmt_WMT_en_ro" ]; then
model_name_or_path='Helsinki-NLP/opus-mt-en-ro'
model_type='marianmt'
extra_cmd="--source_lang en --target_lang ro --dataset_name wmt16 --dataset_config_name ro-en"
fi

sed -i "/: bert/s|name:.*|name: $model_type|g" conf.yaml
Expand All @@ -61,10 +60,13 @@ function run_tuning {
--predict_with_generate \
--per_device_eval_batch_size ${batch_size} \
--output_dir ${tuned_checkpoint} \
--source_prefix "translate English to Romanian: " \
--source_lang en \
--target_lang ro \
--dataset_name wmt16 \
--dataset_config_name ro-en\
--tune \
--overwrite_output_dir \
$extra_cmd
--source_prefix "$extra_cmd"
}

main "$@"

0 comments on commit 8e3c3c0

Please sign in to comment.