in pytorch_translate/options.py [0:0]
def expand_generation_args(group, train=False):
"""Expands the generation related arguments with pytorch_translate
specific arguments"""
group.add_argument(
"--word-reward",
type=float,
default=0.0,
help=(
"Value to add to (log-prob) score for each token except EOS. "
"Value < 0 encourages shorter translations, while > 0 "
"(the usual case) encourages longer translations "
"(similar to --length-penalty)."
),
)
group.add_argument(
"--unk-reward",
type=float,
default=0.0,
help=(
"Value to add to (log-prob) score for UNK tokens. "
"Value < 0 (the usual case) encourages fewer UNKs, while > 0 "
"encourages more UNKs."
),
)
group.add_argument(
"--length-penalty",
type=float,
default=0.0,
help=(
"When >0 scores are normalized according to length (divided by "
"length^length_penalty). Effectively overrides word_reward when"
"in use. NOTE: supersedes --lenpen."
),
)
group.add_argument(
"--model-weights",
default="",
help=(
"Interpolation weights for ensembles. Comma-separated list of "
"floats with length equal to the number of models in the ensemble."
),
)
group.add_argument(
"--report-oracle-bleu",
type=utils.bool_flag,
nargs="?",
const=True,
default=False,
help=(
"During evaluation, determine best among top-k outputs (where k "
"is controlled by --nbest) for each sentence by smoothed "
"sentence-level BLEU and report overall BLEU score for these "
"sentences."
),
)
group.add_argument(
"--output-hypos-binary-path",
default=None,
type=str,
help=(
"Optional filename to save output hypotheses (binary format "
"and EOS-terminated, suitable for use as training targets)"
),
)
group.add_argument(
"--max-examples-to-evaluate",
default=-1,
type=int,
help=(
"If >0 and smaller than size of evaluation data set, randomly "
"sample this many examples to evaluate"
),
)
group.add_argument(
"--max-examples-to-evaluate-seed",
default=-1,
type=int,
help=(
"If not -1, set seed for random sample as the given seed value, "
"so we can replicate result on random sample."
),
)
group.add_argument(
"--output-source-binary-path",
default=None,
type=str,
help=(
"Optional filename to save binarized source after evaluation "
"(primary use case being that this source dataset will be after "
"any filtering due to --max-examples-to-evaluate)"
),
)
group.add_argument(
"--translation-info-export-path",
default=None,
type=str,
help=("Optional path to save translation info output in pickled format"),
)
group.add_argument(
"--diversity-sibling-gamma",
type=float,
default=0.0,
help=("The diversity rate of sibling_rank for generating diverse beams"),
)
group.add_argument(
"--hypotheses-export-path",
default=None,
type=str,
help=("Optional path to save all generated hypotheses to external file"),
)
# These arguments are only used during training
if train:
group.add_argument(
"--multi-model-restore-files",
default=None,
type=str,
nargs="+",
help=(
"If --multi-encoder = --multi-decoder > 1, this option makes "
"it possible to initialize individual model weights from "
"existing checkpoints of separate training runs."
),
)
return group