Provides an argument parser and a set of default command line options for using the ParlAI package.


Outputs any announcements the ParlAI team wishes to make to users.

Also gives the user the option to suppress the output.


Look for single float or comma-separated floats.


From import path string, returns the class specified.

For example, the string ‘parlai.agents.drqa.drqa:SimpleDictionaryAgent’ returns <class ‘parlai.agents.drqa.drqa.SimpleDictionaryAgent’>.


Inverse of params.str2class().


Converts underscores to hyphens in args.

For example, converts ‘–gradient_clip’ to ‘–gradient-clip’.


args – iterable, possibly containing args strings with underscores.

class parlai.core.params.CustomHelpFormatter(*args, **kwargs)

Bases: argparse.ArgumentDefaultsHelpFormatter

Produces a custom-formatted –help option

See for details.

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

class parlai.core.params.ParlaiParser(add_parlai_args=True, add_model_args=False, description='ParlAI parser')

Bases: argparse.ArgumentParser

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 calling add_arg() or add_argument() on it.

For example, see parlai.core.dict.DictionaryAgent.add_cmdline_args.

__init__(add_parlai_args=True, add_model_args=False, description='ParlAI parser')

Initializes the ParlAI argparser.

  • 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.


Add arguments related to models such as model files.


Add arguments specific to a particular model.


Add arguments specific to the specified task.


Add arguments specific to specified pytorch dataset


Add additional arguments for handling images.


Add more args depending on how known args are set.

parse_known_args(args=None, namespace=None, nohelp=False)

Custom parse known args to ignore help flag.

parse_args(args=None, namespace=None, print_args=True)

Parses the provided arguments and returns a dictionary of the args.

We specifically remove items with None as values in order to support the style opt.get(key, default), which would otherwise return None.


Print out all the arguments in this parser.


Set overridable kwargs.

add_argument(*args, **kwargs)

Override to convert underscores to hyphens for consistency.

add_argument_group(*args, **kwargs)

Override to make arg groups also convert underscores to hyphens.

error(message: string)

Prints a usage message incorporating the message to stderr and exits.

If you override this in a subclass, it should not return – it should either exit or raise an exception.