An open-source NLP research library, built on PyTorch.
An open-source NLP research library, built on PyTorch.
⚠️ NOTICE: The AllenNLP library is now in maintenance mode. That means we are no longer adding new features or upgrading dependencies. We will still respond to questions and address bugs as they arise up until December 16th, 2022. If you have any concerns or are interested in maintaining AllenNLP going forward, please open an issue on this repository.
AllenNLP has been a big success, but as the field is advancing quickly it's time to focus on new initiatives. We're working hard to make AI2 Tango the best way to organize research codebases. If you are an active user of AllenNLP, here are some suggested alternatives:
modules and nn packages, check out delmaksym/allennlp-light. It's even compatible with AI2 Tango!If you're interested in using AllenNLP for model development, we recommend you check out the AllenNLP Guide for a thorough introduction to the library, followed by our more advanced guides on GitHub Discussions.
When you're ready to start your project, we've created a couple of template repositories that you can use as a starting place:
allennlp train and config files to specify experiments, use this
template. We recommend this approach.In addition, there are external tutorials:
And others on the AI2 AllenNLP blog.
AllenNLP supports loading "plugins" dynamically. A plugin is just a Python package that
provides custom registered classes or additional allennlp subcommands.
There is ecosystem of open source plugins, some of which are maintained by the AllenNLP team here at AI2, and some of which are maintained by the broader community.
| Plugin | Maintainer | CLI | Description |
| allennlp-models | AI2 | No | A collection of state-of-the-art models |
| allennlp-semparse | AI2 | No | A framework for building semantic parsers |
| allennlp-server | AI2 | Yes | A simple demo server for serving models |
| allennlp-optuna | Makoto Hiramatsu | Yes | Optuna integration for hyperparameter optimization |
AllenNLP will automatically find any official AI2-maintained plugins that you have installed,
but for AllenNLP to find personal or third-party plugins you've installed,
you also have to create either a local plugins file named .allennlp_plugins
in the directory where you run the allennlp command, or a global plugins file at ~/.allennlp/plugins.
The file should list the plugin modules that you want to be loaded, one per line.
To test that your plugins can be found and imported by AllenNLP, you can run the allennlp test-install command.
Each discovered plugin will be logged to the terminal.
For more information about plugins, see the plugins API docs. And for information on how to create a custom subcommand to distribute as a plugin, see the subcommand API docs.
| allennlp | An open-source NLP research library, built on PyTorch |
| allennlp.commands | Functionality for the CLI |
| allennlp.common | Utility modules that are used across the library |
| allennlp.data | A data processing module for loading datasets and encoding strings as integers for representation in matrices |
| allennlp.fairness | A module for bias mitigation and fairness algorithms and metrics |
| allennlp.modules | A collection of PyTorch modules for use with text |
| allennlp.nn | Tensor utility functions, such as initializers and activation functions |
| allennlp.training | Functionality for training models |
AllenNLP requires Python 3.6.1 or later and PyTorch.
We support AllenNLP on Mac and Linux environments. We presently do not support Windows but are open to contributions.
The simplest way to install AllenNLP is using conda (you can choose a different python version):
conda install -c conda-forge python=3.8 allennlpTo install optional packages, such as checklist, use
conda install -c conda-forge allennlp-checklistor simply install allennlp-all directly. The plugins mentioned above are similarly installable, e.g.
conda install -c conda-forge allennlp-models allennlp-semparse allennlp-server allennlp-optunaIt's recommended that you install the PyTorch ecosystem before installing AllenNLP by following the instructions on pytorch.org.
After that, just run pip install allennlp.
⚠️ If you're using Python 3.7 or greater, you should ensure that you don't have the PyPI version of
dataclassesinstalled after running the above command, as this could cause issues on certain platforms. You can quickly check this by runningpip freeze | grep dataclasses. If you see something likedataclasses=0.6in the output, then just runpip uninstall -y dataclasses.
If you need pointers on setting up an appropriate Python environment or would like to install AllenNLP using a different method, see below.
Conda can be used set up a virtual environment with the version of Python required for AllenNLP. If you already have a Python 3 environment you want to use, you can skip to the 'installing via pip' section.
Create a Conda environment with Python 3.8 (3.7 or 3.9 would work as well):
conda create -n allennlp_env python=3.8Activate the Conda environment. You will need to activate the Conda environment in each terminal in which you want to use AllenNLP:
conda activate allennlp_envInstalling the library and dependencies is simple using pip.
pip install allennlpTo install the optional dependencies, such as checklist, run
pip install allennlp[checklist]Or you can just install all optional dependencies with pip install allennlp[all].
Looking for bleeding edge features? You can install nightly releases directly from pypi
AllenNLP installs a script when you install the python package, so you can run allennlp commands just by typing allennlp into a terminal. For example, you can now test your installation with allennlp test-install.
You may also want to install allennlp-models, which contains the
Computing rouge is significantly slow
Build Fairness Library
AllenNLP biased towards BERT
structured-prediction-constituency-parser adds extra spaces
Accept compressed files as input to `predict` when using a `Predictor`
save git status when run commands
how to turn off INFO messages when run in command-line mode
Windows
Add instructions for getting AllenNLP to run on Windows
RoBERTa on SuperGLUE's 'Multi-Sentence Reading Comprehension' task