When using `run_eval.py`, the following features can be useful:
* if you running the script multiple times and want to make it easier to track what arguments produced that output, use `--dump-args`. Along with the results it will also dump any custom params that were passed to the script. For example if you used: `--num_beams 8 --early_stopping true`, the output will be:
`--info` is an additional argument available for the same purpose of tracking the conditions of the experiment. It's useful to pass things that weren't in the argument list, e.g. a language pair `--info "lang:en-ru"`. But also if you pass `--info` without a value it will fallback to the current date/time string, e.g. `2020-09-13 18:44:43`.
If using `--dump-args --info`, the output will be:
* if you need to perform a parametric search in order to find the best ones that lead to the highest BLEU score, let `run_eval_search.py` to do the searching for you.
The script accepts the exact same arguments as `run_eval.py`, plus an additional argument `--search`. The value of `--search` is parsed, reformatted and fed to ``run_eval.py`` as additional args.
The format for the `--search` value is a simple string with hparams and colon separated values to try, e.g.:
which will generate `12``(2*3*2)` searches for a product of each hparam. For example the example that was just used will invoke `run_eval.py` repeatedly with:
If you pass `--info "some experiment-specific info"` it will get printed before the results table - this is useful for scripting and multiple runs, so one can tell the different sets of results from each other.
"--n_obs",type=int,default=-1,required=False,help="How many observations. Defaults to all."
"--n_obs",type=int,default=-1,required=False,help="How many observations. Defaults to all."
)
)
parser.add_argument("--fp16",action="store_true")
parser.add_argument("--fp16",action="store_true")
parser.add_argument("--dump-args",action="store_true",help="print the custom hparams with the results")
parser.add_argument(
"--info",
nargs="?",
type=str,
const=datetime_now(),
help="use in conjunction w/ --dump-args to print with the results whatever other info you'd like, e.g. lang=en-ru. If no value is passed, the current datetime string will be used.",
)
# Unspecified args like --num_beams=2 --decoder_start_token_id=4 are passed to model.generate
# Unspecified args like --num_beams=2 --decoder_start_token_id=4 are passed to model.generate
args,rest=parser.parse_known_args()
args,rest=parser.parse_known_args()
parsed=parse_numeric_cl_kwargs(rest)
parsed_args=parse_numeric_n_bool_cl_kwargs(rest)
ifparsed:
ifparsed_argsandverbose:
print(f"parsed the following generate kwargs: {parsed}")
print(f"parsed the following generate kwargs: {parsed_args}")
Run parametric search over the desired hparam space with help of ``run_eval.py``.
All the arguments except ``--search`` are passed to ``run_eval.py`` as is. The values inside of "--search" are parsed, reformatted and fed to ``run_eval.py`` as additional args.
The format for the ``--search`` value is a simple string with hparams and colon separated values to try, e.g.:
which will generate ``12`` ``(2*3*2)`` searches for a product of each hparam. For example the example that was just used will invoke ``run_eval.py`` repeatedly with:
On completion, this function prints a markdown table of the results sorted by the best BLEU score and the winning arguments.
"""
prog=sys.argv[0]
parser=argparse.ArgumentParser(
usage="\n\nImportant: this script accepts all arguments `run_eval.py` accepts and then a few extra, therefore refer to `run_eval.py -h` for the complete list."
)
parser.add_argument(
"--search",
type=str,
required=False,
help='param space to search, e.g. "num_beams=5:10 length_penalty=0.8:1.0:1.2"',
)
parser.add_argument(
"--bs",type=int,default=8,required=False,help="initial batch size (may get reduced if it's too big)"
)
parser.add_argument(
"--task",type=str,help="used for task_specific_params + metrics",choices=task_score_names.keys()
)
parser.add_argument(
"--info",
nargs="?",
type=str,
const=datetime_now(),
help="add custom notes to be printed before the results table. If no value is passed, the current datetime string will be used.",
)
args,args_main=parser.parse_known_args()
# we share some of the args
args_main.extend(["--task",args.task])
args_normal=[prog]+args_main
matrix,col_names=parse_search_arg(args.search)
col_names[0:0]=task_score_names[args.task]# score cols first