An open-source NLP research library, built on PyTorch.
Project description
An Apache 2.0 NLP research library, built on PyTorch, for developing state-of-the-art deep learning models on a wide variety of linguistic tasks.
Quick Links
- Website
- Tutorial
- Forum
- Documentation
- Contributing Guidelines
- Pretrained Models
- Continuous Build
- Nightly Releases
Package Overview
allennlp | an open-source NLP research library, built on PyTorch |
allennlp.commands | functionality for a CLI and web service |
allennlp.data | a data processing module for loading datasets and encoding strings as integers for representation in matrices |
allennlp.models | a collection of state-of-the-art models |
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 |
Installation
AllenNLP requires Python 3.6.1 or later. The preferred way to install AllenNLP is via pip
. Just run pip install allennlp
in your Python environment and you're good to go!
If you need pointers on setting up an appropriate Python environment or would like to install AllenNLP using a different method, see below.
Windows is currently not officially supported, although we try to fix issues when they are easily addressed.
Installing via pip
Setting up a virtual environment
Conda can be used set up a virtual environment with the version of Python required for AllenNLP. If you already have a Python 3.6 or 3.7 environment you want to use, you can skip to the 'installing via pip' section.
-
Create a Conda environment with Python 3.7
conda create -n allennlp python=3.7
-
Activate the Conda environment. You will need to activate the Conda environment in each terminal in which you want to use AllenNLP.
conda activate allennlp
Installing the library and dependencies
Installing the library and dependencies is simple using pip
.
pip install allennlp
Looking for bleeding edge features? You can install nightly releases directly from pypi
That's it! You're now ready to build and train AllenNLP models.
AllenNLP installs a script when you install the python package, meaning you can run allennlp commands just by typing allennlp
into a terminal.
You can now test your installation with allennlp test-install
.
Installing using Docker
Docker provides a virtual machine with everything set up to run AllenNLP-- whether you will leverage a GPU or just run on a CPU. Docker provides more isolation and consistency, and also makes it easy to distribute your environment to a compute cluster.
Once you have installed Docker just run the following command to get an environment that will run on either the cpu or gpu.
mkdir -p $HOME/.allennlp/
docker run --rm -v $HOME/.allennlp:/root/.allennlp allennlp/allennlp:v0.9.0
You can test the Docker environment with docker run --rm -v $HOME/.allennlp:/root/.allennlp allennlp/allennlp:v0.9.0 test-install
.
Installing from source
You can also install AllenNLP by cloning our git repository:
git clone https://github.com/allenai/allennlp.git
Create a Python 3.7 virtual environment, and install AllenNLP in editable
mode by running:
pip install --editable .
pip install -r dev-requirements.txt
This will make allennlp
available on your system but it will use the sources from the local clone
you made of the source repository.
You can test your installation with allennlp test-install
.
./scripts/verify.py
will run the full suite of tests used by our continuous build environment.
Running AllenNLP
Once you've installed AllenNLP, you can run the command-line interface either
with the allennlp
command (if you installed via pip
) or allennlp
(if you installed via source).
$ allennlp
Run AllenNLP
optional arguments:
-h, --help show this help message and exit
--version show program's version number and exit
Commands:
elmo Create word vectors using a pretrained ELMo model.
evaluate Evaluate the specified model + dataset.
find-lr Find a learning rate range.
predict Use a trained model to make predictions.
print-results
Print results from allennlp serialization directories to the
console.
test-install
Run the unit tests.
train Train a model.
Docker images
AllenNLP releases Docker images to Docker Hub for each release. For information on how to run these releases, see Installing using Docker.
Building a Docker image
For various reasons you may need to create your own AllenNLP Docker image. The same image can be used either with a CPU or a GPU.
First, you need to install Docker. Then run the following command (it will take some time, as it completely builds the environment needed to run AllenNLP.)
docker build -f Dockerfile.pip --tag allennlp/allennlp:latest .
You should now be able to see this image listed by running docker images allennlp
.
REPOSITORY TAG IMAGE ID CREATED SIZE
allennlp/allennlp latest b66aee6cb593 5 minutes ago 2.38GB
Running the Docker image
You can run the image with docker run --rm -it allennlp/allennlp:latest
. The --rm
flag cleans up the image on exit and the -it
flags make the session interactive so you can use the bash shell the Docker image starts.
You can test your installation by running allennlp test-install
.
Issues
Everyone is welcome to file issues with either feature requests, bug reports, or general questions. As a small team with our own internal goals, we may ask for contributions if a prompt fix doesn't fit into our roadmap. We allow users a two week window to follow up on questions, after which we will close issues. They can be re-opened if there is further discussion.
Contributions
The AllenNLP team at AI2 (@allenai) welcomes contributions from the greater AllenNLP community, and, if you would like to get a change into the library, this is likely the fastest approach. If you would like to contribute a larger feature, we recommend first creating an issue with a proposed design for discussion. This will prevent you from spending significant time on an implementation which has a technical limitation someone could have pointed out early on. Small contributions can be made directly in a pull request.
Pull requests (PRs) must have one approving review and no requested changes before they are merged. As AllenNLP is primarily driven by AI2 (@allenai) we reserve the right to reject or revert contributions that we don't think are good additions.
Citing
If you use AllenNLP in your research, please cite AllenNLP: A Deep Semantic Natural Language Processing Platform.
@inproceedings{Gardner2017AllenNLP,
title={AllenNLP: A Deep Semantic Natural Language Processing Platform},
author={Matt Gardner and Joel Grus and Mark Neumann and Oyvind Tafjord
and Pradeep Dasigi and Nelson F. Liu and Matthew Peters and
Michael Schmitz and Luke S. Zettlemoyer},
year={2017},
Eprint = {arXiv:1803.07640},
}
Team
AllenNLP is an open-source project backed by the Allen Institute for Artificial Intelligence (AI2). AI2 is a non-profit institute with the mission to contribute to humanity through high-impact AI research and engineering. To learn more about who specifically contributed to this codebase, see our contributors page.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file allennlp-0.9.1.dev20200415.tar.gz
.
File metadata
- Download URL: allennlp-0.9.1.dev20200415.tar.gz
- Upload date:
- Size: 1.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2a577522c131b2d372ea1f4029892dbfb0a641b38bf03de898e4548a8f9d8cd |
|
MD5 | dbe1e1929052e14baaaf890bcb7dc18c |
|
BLAKE2b-256 | f7f8b6bb4fa624991af5c7e7f42d4fa308f4d91e8392792e9fcb38fe6034501d |
File details
Details for the file allennlp-0.9.1.dev20200415-py3-none-any.whl
.
File metadata
- Download URL: allennlp-0.9.1.dev20200415-py3-none-any.whl
- Upload date:
- Size: 1.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66a46387b6b0f7e5724f8820254414c1e14702f59a3824d7c15e759d77177c74 |
|
MD5 | 5fc60974b46674c977b078cf5ce89fc9 |
|
BLAKE2b-256 | 25dfe8d975dae4755ef1dc892a31b8293ec052dc47ef3ccc56353bcc483c2349 |