parlai.core.opt¶
Opt is the system for passing around options throughout ParlAI.
parlai.core.params¶
Provide an argument parser and default command line options for using ParlAI.
- parlai.core.params.print_git_commit()[source]¶
Print the current git commit of ParlAI and parlai_internal.
- parlai.core.params.print_announcements(opt)[source]¶
Output any announcements the ParlAI team wishes to make to users.
Also gives the user the option to suppress the output.
- parlai.core.params.get_model_name(opt)[source]¶
Get the model name from either –model or –model-file.
- parlai.core.params.str2none(value: str)[source]¶
If the value is a variant of none, return None.
Otherwise, return the original value.
- parlai.core.params.str2class(value)[source]¶
From import path string, returns the class specified.
For example, the string ‘parlai.agents.hugging_face.dict:Gpt2DictionaryAgent’ returns <class ‘parlai.agents.hugging_face.dict.Gpt2DictionaryAgent’>.
- parlai.core.params.fix_underscores(args)[source]¶
Convert underscores to hyphens in args.
For example, converts ‘–gradient_clip’ to ‘–gradient-clip’.
- Parameters
args – iterable, possibly containing args strings with underscores.
- class parlai.core.params.CustomHelpFormatter(*args, **kwargs)[source]¶
Bases:
HelpFormatter
Produce a custom-formatted –help option.
See https://goo.gl/DKtHb5 for details.
- class parlai.core.params.ParlaiParser(add_parlai_args=True, add_model_args=False, description=None, **kwargs)[source]¶
Bases:
ArgumentParser
Provide an opt-producer and CLI argument parser.
Pseudo-extension of
argparse
which sets a number of parameters for the ParlAI framework. More options can be added specific to other modules by passing this object and callingadd_arg()
oradd_argument()
on it.For an example, see
parlai.core.dict.DictionaryAgent.add_cmdline_args
.- Parameters
add_parlai_args – (default True) initializes the default arguments for ParlAI package, including the data download paths and task arguments.
add_model_args – (default False) initializes the default arguments for loading models, including initializing arguments from that model.
- __init__(add_parlai_args=True, add_model_args=False, description=None, **kwargs)[source]¶
Initialize the ParlAI parser.
- add_world_args(task: str, interactive_task: Optional[str], selfchat_task: Optional[str], partial: Opt)[source]¶
Add arguments specific to the world.
- parse_known_args(args=None, namespace=None, nohelp=False)[source]¶
Parse known args to ignore help flag.
- parse_and_process_known_args(args=None)[source]¶
Parse provided arguments and return parlai opts and unknown arg list.
Runs the same arg->opt parsing that parse_args does, but doesn’t throw an error if the args being parsed include additional command line arguments that parlai doesn’t know what to do with.
- parse_args(args=None, namespace=None, **kwargs)[source]¶
Parse the provided arguments and returns a dictionary of the
args
.We specifically remove items with
None
as values in order to support the styleopt.get(key, default)
, which would otherwise returnNone
.