Home

Awesome

dynmt-py

Neural machine translation implementation using dynet's python bindings.

Example Usage:

python dynmt.py --dynet-autobatch 0 --dynet-devices GPU:1 --dynet-mem 12000 \
--input-dim=500 --hidden-dim=1024 --epochs=100 --lstm-layers=1 --optimization=ADADELTA \
--batch-size=60 --beam-size=5 --vocab 30000 --plot --eval-after=10000  \
train_source.txt train_target.txt dev_source.txt dev_target.txt test_source.txt test_target.txt path/to/model/dir

Options:

NameDescription
-h --helpshows a help message and exits
--dynet-mem MEMallocates MEM bytes for dynet (see dynet's documentation for more details)
--dynet-gpus GPUShow many gpus to use (see dynet's documentation for more details)
--dynet-devices DEVCPU/GPU ids to use (see dynet's documentation for more details)
--dynet-autobatch AUTOswitch auto-batching on (see dynet's documentation for more details)
--input-dim=INPUTinput embeddings dimension [default: 300]
--hidden-dim=HIDDENLSTM hidden layer dimension [default: 100]
--epochs=EPOCHSamount of training epochs [default: 1]
--layers=LAYERSamount of layers in LSTM [default: 1]
--optimization=OPTIMIZATIONchosen optimization method (ADAM/SGD/ADAGRAD/MOMENTUM/ADADELTA) [default: ADADELTA]
--reg=REGULARIZATIONregularization parameter for optimization [default: 0]
--learning=LEARNINGlearning rate parameter for optimization [default: 0.0001]
--batch-size=BATCHbatch size [default: 1]
--beam-size=BEAMbeam size in beam search [default: 5]
--vocab-size=VOCABmax vocabulary size [default: 99999]
--eval-after=EVALAFTERamount of train batches to wait before evaluation [default: 1000]
--max-len=MAXLENmax train sequence length [default: 50]
--max-pred=MAXPREDmax predicted sequence length [default: 50]
--grad-clip=GRADCLIPgradient clipping threshold [default: 5.0]
--max-patience=MAXPATIENCEamount of checkpoints without improvement on dev before early stopping [default: 100]
--plotplot a learning curve while training each model
--overrideoverride existing model with the same name, if exists
--ensemble=ENSEMBLEensemble model paths separated by a comma
--last-stateonly use last encoder state
--evalskip training, do only evaluation

Arguments (must be given in this order):

NameDescription
TRAIN_INPUTS_PATHtrain inputs path
TRAIN_OUTPUTS_PATHtrain outputs path
DEV_INPUTS_PATHdevelopment inputs path
DEV_OUTPUTS_PATHdevelopment outputs path
TEST_INPUTS_PATHtest inputs path
TEST_OUTPUTS_PATHtest outputs path
RESULTS_PATHresults file path