These submodules contain the command line tools for things like training and evaluating models. You probably don’t want to call most of them directly. Instead, just create a script that calls allennlp.commands.main() and it will automatically inherit all of the subcommands in this module.

The included module is such a script:

Run AllenNLP

optional arguments:
  -h, --help  show this help message and exit

    train       Train a model
    configure   Generate a stub configuration
    evaluate    Evaluate the specified model + dataset
    predict     Use a trained model to make predictions.
    make-vocab  Create a vocabulary
    elmo        Create word vectors using a pretrained ELMo model.
    fine-tune   Continue training a model on a new dataset
    dry-run     Create a vocabulary, compute dataset statistics and other
                training utilities.
    find-lr     Find a learning rate range where loss decreases quickly
                for the specified model and dataset.
                Run the unit tests.
                Print results from allennlp serialization directories to the

However, it only knows about the models and classes that are included with AllenNLP. Once you start creating custom models, you’ll need to make your own script which imports them and then calls main().

class allennlp.commands.ArgumentParserWithDefaults(prog=None, usage=None, description=None, epilog=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True, allow_abbrev=True)[source]

Bases: argparse.ArgumentParser

Custom argument parser that will display the default value for an argument in the help message.

add_argument(dest, ..., name=value, ...) add_argument(option_string, option_string, ..., name=value, ...)[source]
allennlp.commands.main(prog: str = None, subcommand_overrides: Dict[str, allennlp.commands.subcommand.Subcommand] = {}) → None[source]

The run command only knows about the registered classes in the allennlp codebase. In particular, once you start creating your own Model s and so forth, it won’t work for them, unless you use the --include-package flag.