/transformer-normalizer-and-stressor-lt

Transformer problem for normalizing and stressing text in lithuanian

Primary LanguagePython

Docker Env

Instructions

Run trainer & evaluate

Train

PROBLEM=num_to_text128
HPARAMS_SET=transformer_base
MODEL=transformer
WORKER_GPU=2
HPARAMS="eval_drop_long_sequences=True"

USR_DIR=.
DATA_DIR=$HOME/t2t_data
TMP_DIR=/tmp/t2t_datagen
TRAIN_DIR=$HOME/t2t_train/$PROBLEM/$MODEL-$HPARAMS_SET

mkdir -p $DATA_DIR $TMP_DIR

tensorboard --logdir $TRAIN_DIR &

t2t-trainer \
 --generate_data \
 --problem=$PROBLEM \
 --global_step=0 \
 --data_dir=$DATA_DIR \
 --tmp_dir=$TMP_DIR \
 --output_dir=$TRAIN_DIR \
 --t2t_usr_dir=$USR_DIR \
 --hparams_set=$HPARAMS_SET \
 --hparams=$HPARAMS \
 --model=$MODEL \
 --worker_gpu=$WORKER_GPU

Evaluate

PROBLEM=encoder_character_stressor
HPARAMS=transformer_base
MODEL=transformer_encoder

USR_DIR=.
DATA_DIR=$HOME/t2t_data
TMP_DIR=/tmp/t2t_datagen
TRAIN_DIR=$HOME/t2t_train/$PROBLEM/$MODEL-$HPARAMS

DECODE_FILE=$DATA_DIR/decode_this.txt
DECODE_TO_FILE=$DATA_DIR/decode_result.txt
echo "Laba diena drauai!" > $DECODE_FILE
echo "Viskas bus gerai." >> $DECODE_FILE

BEAM_SIZE=4
ALPHA=0.6

t2t-decoder \
  --data_dir=$DATA_DIR \
  --problem=$PROBLEM \
  --model=$MODEL \
  --hparams_set=$HPARAMS \
  --output_dir=$TRAIN_DIR \
  --t2t_usr_dir=$USR_DIR \
  --decode_hparams="beam_size=$BEAM_SIZE,alpha=$ALPHA" \
  --decode_from_file=$DECODE_FILE \
  --decode_to_file=$DECODE_TO_FILE

References