allennlp.commands

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 allennlp.run is such a script:

Run AllenNLP

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

Commands:
    train     Train a model
    evaluate  Evaluate the specified model + dataset
    predict   Use a trained model to make predictions.
    serve     Run the web service and demo.
    make-vocab
              Create a vocabulary
    elmo      Use a trained model to make predictions.

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().

allennlp.commands.main(prog: str = None, subcommand_overrides: typing.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.