core.params

Provide an argument parser and default command line options for using ParlAI.

parlai.core.params.print_git_commit()

Print the current git commit of ParlAI and parlai_internal.

parlai.core.params.print_announcements(opt)

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)

Get the model name from either –model or –model-file.

parlai.core.params.str2bool(value)

Convert ‘yes’, ‘false’, ‘1’, etc. into a boolean.

parlai.core.params.str2floats(s)

Look for single float or comma-separated floats.

parlai.core.params.str2class(value)

From import path string, returns the class specified.

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

parlai.core.params.class2str(value)

Inverse of params.str2class().

parlai.core.params.fix_underscores(args)

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)

Bases: argparse.ArgumentDefaultsHelpFormatter

Produce a custom-formatted –help option.

See https://goo.gl/DKtHb5 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

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

For 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='ParlAI parser')

Initialize the ParlAI argparser.

add_parlai_data_path(argument_group=None)

Add –datapath CLI arg.

add_mturk_args()

Add standard mechanical turk arguments.

add_chatservice_args()

Arguments for all chat services

add_websockets_args()

Add websocket arguments.

add_messenger_args()

Add Facebook Messenger arguments.

add_parlai_args(args=None)

Add common ParlAI args across all scripts.

add_distributed_training_args()

Add CLI args for distributed training.

add_pytorch_datateacher_args()

Add CLI args for PytorchDataTeacher.

add_model_args()

Add arguments related to models such as model files.

add_model_subargs(model)

Add arguments specific to a particular model.

add_task_args(task)

Add arguments specific to the specified task.

add_pyt_dataset_args(opt)

Add arguments specific to specified pytorch dataset.

add_image_args(image_mode)

Add additional arguments for handling images.

add_extra_args(args=None)

Add more args depending on how known args are set.

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

Parse known args to ignore help flag.

parse_and_process_known_args(args=None)

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, print_args=True)

Parse 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_args()

Print out all the arguments in this parser.

set_params(**kwargs)

Set overridable kwargs.

property show_advanced_args

Check if we should show arguments marked as hidden.

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)

Override to print custom error message.