train.lua

train.lua options:

  • -h [] (default: false)
    This help.
  • -md [] (default: false)
    Dump help in Markdown format.
  • -config (default: '')
    Load options from this file.
  • -save_config (default: '')
    Save options to this file.

Data options

  • -data (default: '')
    Path to the data package *-train.t7 generated by the preprocessing step.

Sampled dataset options

  • -sample (default: 0)
    Number of instances to sample from train data in each epoch.
  • -sample_type (accepted: uniform, perplexity, partition; default: uniform)
    Define the partition type. uniform draws randomly the sample, perplexity uses perplexity as a probability distribution when sampling (with -sample_perplexity_init and -sample_perplexity_max options), partition draws different subsets at each epoch.
  • -sample_perplexity_init (default: 15)
    Start perplexity-based sampling when average train perplexity per batch falls below this value.
  • -sample_perplexity_max (default: -1.5)
    When greater than 0, instances with perplexity above this value will be considered as noise and ignored; when less than 0, mode + -sample_perplexity_max * stdev will be used as threshold.

Data options

  • -train_dir (default: '')
    Path to training files directory.
  • -train_src (default: '')
    Path to the training source data.
  • -train_tgt (default: '')
    Path to the training target data.
  • -valid_src (default: '')
    Path to the validation source data.
  • -valid_tgt (default: '')
    Path to the validation target data.
  • -src_vocab (default: '')
    Path to an existing source vocabulary.
  • -src_suffix (default: .src)
    Suffix for source files in train/valid directories.
  • -src_vocab_size (default: 50000)
    List of source vocabularies size: word[ feat1[ feat2[ ...] ] ]. If = 0, vocabularies are not pruned.
  • -src_words_min_frequency
  • (default: 0)
    List of source words min frequency: word[ feat1[ feat2[ ...] ] ]. If = 0, vocabularies are pruned by size.
  • -tgt_vocab (default: '')
    Path to an existing target vocabulary.
  • -tgt_suffix (default: .tgt)
    Suffix for target files in train/valid directories.
  • -tgt_vocab_size
  • (default: 50000)
    List of target vocabularies size: word[ feat1[ feat2[ ...] ] ]. If = 0, vocabularies are not pruned.
  • -tgt_words_min_frequency
  • (default: 0)
    List of target words min frequency: word[ feat1[ feat2[ ...] ] ]. If = 0, vocabularies are pruned by size.
  • -src_seq_length (default: 50)
    Maximum source sequence length.
  • -tgt_seq_length (default: 50)
    Maximum target sequence length.
  • -check_plength [] (default: false)
    Check source and target have same length (for seq tagging).
  • -features_vocabs_prefix (default: '')
    Path prefix to existing features vocabularies.
  • -time_shift_feature [] (default: true)
    Time shift features on the decoder side.
  • -keep_frequency [] (default: false)
    Keep frequency of words in dictionary.
  • -gsample (default: 0)
    If not zero, extract a new sample from the corpus. In training mode, file sampling is done at each epoch. Values between 0 and 1 indicate ratio, values higher than 1 indicate data size
  • -gsample_dist (default: '')
    Configuration file with data class distribution to use for sampling training corpus. If not set, sampling is uniform.
  • -sort [] (default: true)
    If set, sort the sequences by size to build batches without source padding.
  • -shuffle [] (default: true)
    If set, shuffle the data (prior sorting).
  • -idx_files [] (default: false)
    If set, source and target files are 'key value' with key match between source and target.
  • -report_progress_every (default: 100000)
    Report status every this many sentences.
  • -preprocess_pthreads (default: 4)
    Number of parallel threads for preprocessing.
  • Tokenizer options

    • -tok_src_mode (accepted: conservative, aggressive, space; default: space)
      Define how aggressive should the tokenization be. space is space-tokenization.
    • -tok_tgt_mode (accepted: conservative, aggressive, space; default: space)
      Define how aggressive should the tokenization be. space is space-tokenization.
    • -tok_src_joiner_annotate [] (default: false)
      Include joiner annotation using -joiner character.
    • -tok_tgt_joiner_annotate [] (default: false)
      Include joiner annotation using -joiner character.
    • -tok_src_joiner (default: )
      Character used to annotate joiners.
    • -tok_tgt_joiner (default: )
      Character used to annotate joiners.
    • -tok_src_joiner_new [] (default: false)
      In -joiner_annotate mode, -joiner is an independent token.
    • -tok_tgt_joiner_new [] (default: false)
      In -joiner_annotate mode, -joiner is an independent token.
    • -tok_src_case_feature [] (default: false)
      Generate case feature.
    • -tok_tgt_case_feature [] (default: false)
      Generate case feature.
    • -tok_src_segment_case [] (default: false)
      Segment case feature, splits AbC to Ab C to be able to restore case
    • -tok_tgt_segment_case [] (default: false)
      Segment case feature, splits AbC to Ab C to be able to restore case
    • -tok_src_segment_alphabet
    (accepted: Tagalog, Hanunoo, Limbu, Yi, Hebrew, Latin, Devanagari, Thaana, Lao, Sinhala, Georgian, Kannada, Cherokee, Kanbun, Buhid, Malayalam, Han, Thai, Katakana, Telugu, Greek, Myanmar, Armenian, Hangul, Cyrillic, Ethiopic, Tagbanwa, Gurmukhi, Ogham, Khmer, Arabic, Oriya, Hiragana, Mongolian, Kangxi, Syriac, Gujarati, Braille, Bengali, Tamil, Bopomofo, Tibetan)
    Segment all letters from indicated alphabet.
  • -tok_tgt_segment_alphabet
  • (accepted: Tagalog, Hanunoo, Limbu, Yi, Hebrew, Latin, Devanagari, Thaana, Lao, Sinhala, Georgian, Kannada, Cherokee, Kanbun, Buhid, Malayalam, Han, Thai, Katakana, Telugu, Greek, Myanmar, Armenian, Hangul, Cyrillic, Ethiopic, Tagbanwa, Gurmukhi, Ogham, Khmer, Arabic, Oriya, Hiragana, Mongolian, Kangxi, Syriac, Gujarati, Braille, Bengali, Tamil, Bopomofo, Tibetan)
    Segment all letters from indicated alphabet.
  • -tok_src_segment_numbers [] (default: false)
    Segment numbers into single digits.
  • -tok_tgt_segment_numbers [] (default: false)
    Segment numbers into single digits.
  • -tok_src_segment_alphabet_change [] (default: false)
    Segment if alphabet change between 2 letters.
  • -tok_tgt_segment_alphabet_change [] (default: false)
    Segment if alphabet change between 2 letters.
  • -tok_src_bpe_model (default: '')
    Apply Byte Pair Encoding if the BPE model path is given. If the option is used, BPE related options will be overridden/set automatically if the BPE model specified by -bpe_model is learnt using learn_bpe.lua.
  • -tok_tgt_bpe_model (default: '')
    Apply Byte Pair Encoding if the BPE model path is given. If the option is used, BPE related options will be overridden/set automatically if the BPE model specified by -bpe_model is learnt using learn_bpe.lua.
  • -tok_src_bpe_EOT_marker (default: )
    Marker used to mark the End of Token while applying BPE in mode 'prefix' or 'both'.
  • -tok_tgt_bpe_EOT_marker (default: )
    Marker used to mark the End of Token while applying BPE in mode 'prefix' or 'both'.
  • -tok_src_bpe_BOT_marker (default: )
    Marker used to mark the Beginning of Token while applying BPE in mode 'suffix' or 'both'.
  • -tok_tgt_bpe_BOT_marker (default: )
    Marker used to mark the Beginning of Token while applying BPE in mode 'suffix' or 'both'.
  • -tok_src_bpe_case_insensitive [] (default: false)
    Apply BPE internally in lowercase, but still output the truecase units. This option will be overridden/set automatically if the BPE model specified by -bpe_model is learnt using learn_bpe.lua.
  • -tok_tgt_bpe_case_insensitive [] (default: false)
    Apply BPE internally in lowercase, but still output the truecase units. This option will be overridden/set automatically if the BPE model specified by -bpe_model is learnt using learn_bpe.lua.
  • -tok_src_bpe_mode (accepted: suffix, prefix, both, none; default: suffix)
    Define the BPE mode. This option will be overridden/set automatically if the BPE model specified by -bpe_model is learnt using learn_bpe.lua. prefix: append -bpe_BOT_marker to the begining of each word to learn prefix-oriented pair statistics; suffix: append -bpe_EOT_marker to the end of each word to learn suffix-oriented pair statistics, as in the original Python script; both: suffix and prefix; none: no suffix nor prefix.
  • -tok_tgt_bpe_mode (accepted: suffix, prefix, both, none; default: suffix)
    Define the BPE mode. This option will be overridden/set automatically if the BPE model specified by -bpe_model is learnt using learn_bpe.lua. prefix: append -bpe_BOT_marker to the begining of each word to learn prefix-oriented pair statistics; suffix: append -bpe_EOT_marker to the end of each word to learn suffix-oriented pair statistics, as in the original Python script; both: suffix and prefix; none: no suffix nor prefix.
  • -tok_src_normalize_cmd (default: '')
    Command for on-the-fly corpus normalization. It should work in 'pipeline' mode.
  • -tok_tgt_normalize_cmd (default: '')
    Command for on-the-fly corpus normalization. It should work in 'pipeline' mode.
  • Sampled Vocabulary options

    • -sample_vocab [] (default: false)
      Use importance sampling as an approximation of the full output vocabulary softmax.

    Model options

    • -model_type (accepted: lm, seq2seq, seqtagger; default: seq2seq)
      Type of model to train. This option impacts all options choices.
    • -param_init (default: 0.1)
      Parameters are initialized over uniform distribution with support (-param_init, param_init). Set to 0 to rely on each module default initialization.

    Sequence to Sequence with Attention options

    • -enc_layers (default: 0)
      If > 0, number of layers of the encoder. This overrides the global -layers option.
    • -dec_layers (default: 0)
      If > 0, number of layers of the decoder. This overrides the global -layers option.
    • -word_vec_size (default: 0)
      Shared word embedding size. If set, this overrides -src_word_vec_size and -tgt_word_vec_size.
    • -src_word_vec_size
    (default: 500)
    List of source embedding sizes: word[ feat1[ feat2[ ...] ] ].
  • -tgt_word_vec_size
  • (default: 500)
    List of target embedding sizes: word[ feat1[ feat2[ ...] ] ].
  • -pre_word_vecs_enc (default: '')
    Path to pretrained word embeddings on the encoder side serialized as a Torch tensor.
  • -pre_word_vecs_dec (default: '')
    Path to pretrained word embeddings on the decoder side serialized as a Torch tensor.
  • -fix_word_vecs_enc [/] (accepted: false, true, pretrained; default: false)
    Fix word embeddings on the encoder side.
  • -fix_word_vecs_dec [/] (accepted: false, true, pretrained; default: false)
    Fix word embeddings on the decoder side.
  • -feat_merge (accepted: concat, sum; default: concat)
    Merge action for the features embeddings.
  • -feat_vec_exponent (default: 0.7)
    When features embedding sizes are not set and using -feat_merge concat, their dimension will be set to N^feat_vec_exponent where N is the number of values the feature takes.
  • -feat_vec_size (default: 20)
    When features embedding sizes are not set and using -feat_merge sum, this is the common embedding size of the features
  • -layers (default: 2)
    Number of recurrent layers of the encoder and decoder. See also -enc_layers, -dec_layers and -bridge to assign different layers to the encoder and decoder.
  • -rnn_size (default: 500)
    Hidden size of the recurrent unit.
  • -rnn_type (accepted: LSTM, GRU; default: LSTM)
    Type of recurrent cell.
  • -dropout (default: 0.3)
    Dropout probability applied between recurrent layers.
  • -dropout_input [] (default: false)
    Dropout probability applied to the input of the recurrent module.
  • -dropout_words (default: 0)
    Dropout probability applied to the source sequence.
  • -dropout_type (accepted: naive, variational; default: naive)
    Dropout type.
  • -residual [] (default: false)
    Add residual connections between recurrent layers.
  • -bridge (accepted: copy, dense, dense_nonlinear, none; default: copy)
    Define how to pass encoder states to the decoder. With copy, the encoder and decoder must have the same number of layers.
  • -input_feed [] (default: true)
    在各个时间步长中,把上下文向量作为附加输入 (通过与字嵌入的链接) 输进编码器。
  • -scheduled_sampling (default: 1)
    Probability of feeding true (vs. generated) previous token to decoder.
  • -scheduled_sampling_scope (accepted: token, sentence; default: token)
    Apply scheduled sampling at token or sentence level.
  • -scheduled_sampling_decay_type (accepted: linear, invsigmoid; default: linear)
    Scheduled Sampling decay type.
  • -scheduled_sampling_decay_rate (default: 0)
    Scheduled Sampling decay rate.
  • -encoder_type (accepted: rnn, brnn, dbrnn, pdbrnn, gnmt, cnn; default: rnn)
    Encoder type.
  • -attention (accepted: none, global; default: global)
    Attention model.
  • -brnn_merge (accepted: concat, sum; default: sum)
    Merge action for the bidirectional states.
  • -pdbrnn_reduction (default: 2)
    Time-reduction factor at each layer.
  • -pdbrnn_merge (accepted: concat, sum; default: concat)
    Merge action when reducing time.
  • -cnn_layers (default: 2)
    Number of convolutional layers in the encoder.
  • -cnn_kernel (default: 3)
    Kernel size for convolutions. Same in each layer.
  • -cnn_size (default: 500)
    Number of output units per convolutional layer. Same in each layer.
  • -use_pos_emb [] (default: true)
    Add positional embeddings to word embeddings.
  • -max_pos (default: 50)
    Maximum value for positional indexes.
  • Global Attention Model options

    • -global_attention (accepted: general, dot, concat; default: general)
      Global attention model type.

    Trainer options

    • -save_every (default: 5000)
      Save intermediate models every this many iterations within an epoch. If = 0, will not save intermediate models.
    • -save_every_epochs (default: 1)
      Save a model every this many epochs. If = 0, will not save a model at each epoch.
    • -report_every (default: 50)
      Report progress every this many iterations within an epoch.
    • -async_parallel [] (default: false)
      When training on multiple GPUs, update parameters asynchronously.
    • -async_parallel_minbatch (default: 1000)
      In asynchronous training, minimal number of sequential batches before being parallel.
    • -start_iteration (default: 1)
      If loading from a checkpoint, the iteration from which to start.
    • -start_epoch (default: 1)
      If loading from a checkpoint, the epoch from which to start.
    • -end_epoch (default: 13)
      The final epoch of the training. If = 0, train forever unless another stopping condition is met (e.g. -min_learning_rate is reached).
    • -curriculum (default: 0)
      For this many epochs, order the minibatches based on source length (from smaller to longer). Sometimes setting this to 1 will increase convergence speed.
    • -validation_metric (accepted: perplexity, loss, bleu, ter, dlratio; default: perplexity)
      Metric to use for validation.
    • -save_validation_translation_every (default: 0)
      When using translation-based validation metrics (e.g. BLEU, TER, etc.), also save the translation every this many epochs to the file _epochN_validation_translation.txt. If = 0, will not save validation translation.
    • -update_vocab (accepted: none, replace, merge; default: none)
      When training on a new train-set with a different vocabulary, update the vocabulary and save the common words' information (embedding, generator ...).

    Optimization options

    • -max_batch_size (default: 64)
      Maximum batch size.
    • -uneven_batches [] (default: false)
      If set, batches are filled up to -max_batch_size even if the source lengths are different. Slower but needed for some tasks.
    • -optim (accepted: sgd, adagrad, adadelta, adam; default: sgd)
      优化方法。
    • -learning_rate (default: 1)
      Initial learning rate. If adagrad or adam is used, then this is the global learning rate. 建议使用的设定为: sgd = 1, adagrad = 0.1, adam = 0.0002.
    • -min_learning_rate (default: 0)
      Do not continue the training past this learning rate value.
    • -max_grad_norm (default: 5)
      Clip the gradients L2-norm to this value. Set to 0 to disable.
    • -learning_rate_decay (default: 0.7)
      Learning rate decay factor: learning_rate = learning_rate * learning_rate_decay.
    • -start_decay_at (default: 9)
      In "default" decay mode, start decay after this epoch.
    • -start_decay_score_delta (default: 0)
      Start decay when validation score improvement is lower than this value.
    • -decay (accepted: default, epoch_only, score_only; default: default)
      When to apply learning rate decay. default: decay after each epoch past -start_decay_at or as soon as the validation score is not improving more than -start_decay_score_delta, epoch_only: only decay after each epoch past -start_decay_at, score_only: only decay when validation score is not improving more than -start_decay_score_delta.
    • -decay_method (accepted: default, restart; default: default)
      If restart is set, the optimizer states (if any) will be reset when the decay condition is met.

    Saver options

    • -save_model (required)
      Model filename (the model will be saved as _epochN_PPL.t7 where PPL is the validation perplexity.
    • -train_from (default: '')
      Path to a checkpoint.
    • -continue [] (default: false)
      If set, continue the training where it left off.

    Translator options

    • -model (default: '')
      Path to the serialized model file.
    • -lm_model (default: '')
      Path to serialized language model file.
    • -lm_weight (default: 0.1)
      Relative weight of language model.
    • -beam_size (default: 5)
      Beam size.
    • -max_sent_length (default: 250)
      输出句子的最大长度。
    • -replace_unk [] (default: false)
      Replace the generated tokens with the source token that has the highest attention weight. If -phrase_table is provided, it will lookup the identified source token and give the corresponding target token. If it is not provided (or the identified source token does not exist in the table) then it will copy the source token
    • -replace_unk_tagged [] (default: false)
      The same as -replace_unk, but wrap the replaced token in ⦅unk:xxxxx⦆ if it is not found in the phrase table.
    • -lexical_constraints [] (default: false)
      Force the beam search to apply the translations from the phrase table.
    • -limit_lexical_constraints [] (default: false)
      Prevents producing each lexical constraint more than required.
    • -phrase_table (default: '')
      Path to source-target dictionary to replace tokens.
    • -n_best (default: 1)
      If > 1, it will also output an n-best list of decoded sentences.
    • -max_num_unks (default: inf)
      All sequences with more s than this will be ignored during beam search.
    • -target_subdict (default: '')
      Path to target words dictionary corresponding to the source.
    • -pre_filter_factor (default: 1)
      Optional, set this only if filter is being used. Before applying filters, hypotheses with top beam_size * pre_filter_factor scores will be considered. If the returned hypotheses voilate filters, then set this to a larger value to consider more.
    • -length_norm (default: 0)
      Length normalization coefficient (alpha). If set to 0, no length normalization.
    • -coverage_norm (default: 0)
      Coverage normalization coefficient (beta). An extra coverage term multiplied by beta is added to hypotheses scores. If is set to 0, no coverage normalization.
    • -eos_norm (default: 0)
      End of sentence normalization coefficient (gamma). If set to 0, no EOS normalization.
    • -dump_input_encoding [] (default: false)
      Instead of generating target tokens conditional on the source tokens, we print the representation (encoding/embedding) of the input.
    • -save_beam_to (default: '')
      Path to a file where the beam search exploration will be saved in a JSON format. Requires the dkjson package.

    Crayon options

    • -exp_host (default: 127.0.0.1)
      Crayon server IP.
    • -exp_port (default: 8889)
      Crayon server port.
    • -exp (default: '')
      Crayon experiment name.

    Cuda options

    • -gpuid
    (default: 0)
    List of GPU identifiers (1-indexed). CPU is used when set to 0.
  • -fallback_to_cpu [] (default: false)
    If GPU can't be used, rollback on the CPU.
  • -fp16 [] (default: false)
    Use half-precision float on GPU.
  • -no_nccl [] (default: false)
    在并行模式下使得 nccl 不能运用。
  • Logger options

    • -log_file (default: '')
      Output logs to a file under this path instead of stdout - if file name ending with json, output structure json.
    • -disable_logs [] (default: false)
      If set, output nothing.
    • -log_level (accepted: DEBUG, INFO, WARNING, ERROR, NOERROR; default: INFO)
      Output logs at this level and above.

    Other options

    • -disable_mem_optimization [] (default: false)
      Disable sharing of internal buffers between clones for visualization or development.
    • -profiler [] (default: false)
      Generate profiling logs.
    • -seed (default: 3435)
      Random seed.