• This repository has been archived on 16/Dec/2022
  • Stars
    star
    11,691
  • Rank 2,674 (Top 0.06 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An open-source NLP research library, built on PyTorch.

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.


CI PyPI License Codecov Optuna

⚠️ 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:

  • If you like the trainer, the configuration language, or are simply looking for a better way to manage your experiments, check out AI2 Tango.
  • If you like AllenNLP's modules and nn packages, check out delmaksym/allennlp-light. It's even compatible with AI2 Tango!
  • If you like the framework aspect of AllenNLP, check out flair. It has multiple state-of-art NLP models and allows you to easily use pretrained embeddings such as those from transformers.
  • If you like the AllenNLP metrics package, check out torchmetrics. It has the same API as AllenNLP, so it should be a quick learning curve to make the switch.
  • If you want to vectorize text, try the transformers library.
  • If you want to maintain the AllenNLP Fairness or Interpret components, please get in touch. There is no alternative to it, so we are looking for a dedicated maintainer.
  • If you are concerned about other AllenNLP functionality, please create an issue. Maybe we can find another way to continue supporting your use case.

Quick Links

In this README

Getting Started Using the Library

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:

  • If you want to use allennlp train and config files to specify experiments, use this template. We recommend this approach.
  • If you'd prefer to use python code to configure your experiments and run your training loop, use this template. There are a few things that are currently a little harder in this setup (loading a saved model, and using distributed training), but otherwise it's functionality equivalent to the config files setup.

In addition, there are external tutorials:

And others on the AI2 AllenNLP blog.

Plugins

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.

Package Overview

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

Installation

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.

Installing via conda-forge

The simplest way to install AllenNLP is using conda (you can choose a different python version):

conda install -c conda-forge python=3.8 allennlp

To install optional packages, such as checklist, use

conda install -c conda-forge allennlp-checklist

or 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-optuna

Installing via pip

It'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 dataclasses installed after running the above command, as this could cause issues on certain platforms. You can quickly check this by running pip freeze | grep dataclasses. If you see something like dataclasses=0.6 in the output, then just run pip 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.

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 environment you want to use, you can skip to the 'installing via pip' section.

  1. Download and install Conda.

  2. Create a Conda environment with Python 3.8 (3.7 or 3.9 would work as well):

    conda create -n allennlp_env python=3.8
    
  3. 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_env
    

Installing the library and dependencies

Installing the library and dependencies is simple using pip.

pip install allennlp

To 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 NLP constructs to train and run our officially supported models, many of which are hosted at https://demo.allennlp.org.

pip install allennlp-models

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.

AllenNLP provides official Docker images with the library and all of its dependencies installed.

Once you have installed Docker, you should also install the NVIDIA Container Toolkit if you have GPUs available.

Then run the following command to get an environment that will run on GPU:

mkdir -p $HOME/.allennlp/
docker run --rm --gpus all -v $HOME/.allennlp:/root/.allennlp allennlp/allennlp:latest

You can test the Docker environment with

docker run --rm --gpus all -v $HOME/.allennlp:/root/.allennlp allennlp/allennlp:latest test-install 

If you don't have GPUs available, just omit the --gpus all flag.

Building your own Docker image

For various reasons you may need to create your own AllenNLP Docker image, such as if you need a different version of PyTorch. To do so, just run make docker-image from the root of your local clone of AllenNLP.

By default this builds an image with the tag allennlp/allennlp, but you can change this to anything you want by setting the DOCKER_IMAGE_NAME flag when you call make. For example, make docker-image DOCKER_IMAGE_NAME=my-allennlp.

If you want to use a different version of Python or PyTorch, set the flags DOCKER_PYTHON_VERSION and DOCKER_TORCH_VERSION to something like 3.9 and 1.9.0-cuda10.2, respectively. These flags together determine the base image that is used. You can see the list of valid combinations in this GitHub Container Registry: github.com/allenai/docker-images/pkgs/container/pytorch.

After building the image you should be able to see it listed by running docker images allennlp.

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
allennlp/allennlp   latest              b66aee6cb593        5 minutes ago       2.38GB

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 or 3.8 virtual environment, and install AllenNLP in editable mode by running:

pip install -U pip setuptools wheel
pip install --editable .[dev,all]

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. See https://github.com/allenai/allennlp-models for instructions on installing allennlp-models from source.

Running AllenNLP

Once you've installed AllenNLP, you can run the command-line interface with the allennlp command (whether you installed from pip or from source). allennlp has various subcommands such as train, evaluate, and predict. To see the full usage information, run allennlp --help.

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. To keep things tidy we will often close issues we think are answered, but don't hesitate to follow up if further discussion is needed.

Contributions

The AllenNLP team at AI2 (@allenai) welcomes contributions from the community. If you're a first time contributor, we recommend you start by reading our CONTRIBUTING.md guide. Then have a look at our issues with the tag Good First Issue.

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

More Repositories

1

OLMo

Modeling, training, eval, and inference code for OLMo
Python
3,949
star
2

RL4LMs

A modular RL library to fine-tune language models to human preferences
Python
2,020
star
3

longformer

Longformer: The Long-Document Transformer
Python
1,955
star
4

bilm-tf

Tensorflow implementation of contextualized word representations from bi-directional language models
Python
1,621
star
5

scispacy

A full spaCy pipeline and models for scientific/biomedical documents.
Python
1,566
star
6

bi-att-flow

Bi-directional Attention Flow (BiDAF) network is a multi-stage hierarchical process that represents context at different levels of granularity and uses a bi-directional attention flow mechanism to achieve a query-aware context representation without early summarization.
Python
1,524
star
7

scibert

A BERT model for scientific text.
Python
1,415
star
8

ai2thor

An open-source platform for Visual AI.
C#
1,010
star
9

open-instruct

Python
932
star
10

XNOR-Net

ImageNet classification using binary Convolutional Neural Networks
Lua
839
star
11

mmc4

MultimodalC4 is a multimodal extension of c4 that interleaves millions of images with text.
Python
793
star
12

scitldr

Python
734
star
13

s2orc

S2ORC: The Semantic Scholar Open Research Corpus: https://www.aclweb.org/anthology/2020.acl-main.447/
Python
710
star
14

natural-instructions

Expanding natural instructions
Python
690
star
15

dolma

Data and tools for generating and inspecting OLMo pre-training data.
Python
678
star
16

visprog

Official code for VisProg (CVPR 2023 Best Paper!)
Python
642
star
17

papermage

library supporting NLP and CV research on scientific papers
Python
585
star
18

science-parse

Science Parse parses scientific papers (in PDF form) and returns them in structured form.
Java
566
star
19

writing-code-for-nlp-research-emnlp2018

A companion repository for the "Writing code for NLP Research" Tutorial at EMNLP 2018
Python
558
star
20

pdffigures2

Given a scholarly PDF, extract figures, tables, captions, and section titles.
Scala
514
star
21

allennlp-models

Officially supported AllenNLP models
Python
512
star
22

tango

Organize your experiments into discrete steps that can be cached and reused throughout the lifetime of your research project.
Python
507
star
23

objaverse-xl

🪐 Objaverse-XL is a Universe of 10M+ 3D Objects. Contains API Scripts for Downloading and Processing!
Python
490
star
24

dont-stop-pretraining

Code associated with the Don't Stop Pretraining ACL 2020 paper
Python
488
star
25

specter

SPECTER: Document-level Representation Learning using Citation-informed Transformers
Python
485
star
26

unified-io-2

Python
471
star
27

macaw

Multi-angle c(q)uestion answering
Python
451
star
28

document-qa

Python
420
star
29

scholarphi

An interactive PDF reader.
Python
410
star
30

deep_qa

A deep NLP library, based on Keras / tf, focused on question answering (but useful for other NLP too)
Python
405
star
31

acl2018-semantic-parsing-tutorial

Materials from the ACL 2018 tutorial on neural semantic parsing
402
star
32

unifiedqa

UnifiedQA: Crossing Format Boundaries With a Single QA System
Python
384
star
33

kb

KnowBert -- Knowledge Enhanced Contextual Word Representations
Python
359
star
34

pawls

Software that makes labeling PDFs easy.
Python
356
star
35

PeerRead

Data and code for Kang et al., NAACL 2018's paper titled "A Dataset of Peer Reviews (PeerRead): Collection, Insights and NLP Applications"
Python
354
star
36

naacl2021-longdoc-tutorial

Python
343
star
37

openie-standalone

Quality information extraction at web scale. Edit
Scala
329
star
38

python-package-template

A template repo for Python packages
Python
318
star
39

acl2022-zerofewshot-tutorial

293
star
40

allenact

An open source framework for research in Embodied-AI from AI2.
Python
293
star
41

ir_datasets

Provides a common interface to many IR ranking datasets.
Python
291
star
42

s2orc-doc2json

Parsers for scientific papers (PDF2JSON, TEX2JSON, JATS2JSON)
Python
290
star
43

beaker-cli

A collaborative platform for rapid and reproducible research.
Go
230
star
44

Holodeck

CVPR 2024: Language Guided Generation of 3D Embodied AI Environments.
Python
220
star
45

procthor

🏘️ Scaling Embodied AI by Procedurally Generating Interactive 3D Houses
Python
214
star
46

comet-atomic-2020

Python
212
star
47

FineGrainedRLHF

Python
209
star
48

fm-cheatsheet

Website for hosting the Open Foundation Models Cheat Sheet.
Python
207
star
49

spv2

Science-parse version 2
Python
206
star
50

scifact

Data and models for the SciFact verification task.
Python
206
star
51

OLMo-Eval

Evaluation suite for LLMs
Python
200
star
52

unified-io-inference

Jupyter Notebook
196
star
53

allennlp-demo

Code for the AllenNLP demo.
TypeScript
191
star
54

lumos

Code and data for "Lumos: Learning Agents with Unified Data, Modular Design, and Open-Source LLMs"
Python
190
star
55

citeomatic

A citation recommendation system that allows users to find relevant citations for their paper drafts. The tool is backed by Semantic Scholar's OpenCorpus dataset.
Jupyter Notebook
182
star
56

cartography

Dataset Cartography: Mapping and Diagnosing Datasets with Training Dynamics
Jupyter Notebook
180
star
57

savn

Learning to Learn how to Learn: Self-Adaptive Visual Navigation using Meta-Learning (https://arxiv.org/abs/1812.00971)
Python
175
star
58

vampire

Variational Methods for Pretraining in Resource-limited Environments
Python
173
star
59

objaverse-rendering

📷 Scripts for rendering Objaverse
Python
169
star
60

hidden-networks

Python
164
star
61

ScienceWorld

ScienceWorld is a text-based virtual environment centered around accomplishing tasks from the standardized elementary science curriculum.
Scala
156
star
62

mmda

multimodal document analysis
Jupyter Notebook
154
star
63

vila

Incorporating VIsual LAyout Structures for Scientific Text Classification
Python
148
star
64

PRIMER

The official code for PRIMERA: Pyramid-based Masked Sentence Pre-training for Multi-document Summarization
Python
145
star
65

cord19

Get started with CORD-19
142
star
66

dnw

Discovering Neural Wirings (https://arxiv.org/abs/1906.00586)
Python
139
star
67

tpu_pretrain

LM Pretraining with PyTorch/TPU
Python
129
star
68

deepfigures-open

Companion code to the paper "Extracting Scientific Figures with Distantly Supervised Neural Networks" 🤖
Python
129
star
69

catwalk

This project studies the performance and robustness of language models and task-adaptation methods.
Python
129
star
70

allentune

Hyperparameter Search for AllenNLP
Python
128
star
71

lm-explorer

interactive explorer for language models
Python
127
star
72

pdffigures

Command line tool to extract figures, tables, and captions from scholarly documents in PDF form.
C++
125
star
73

SciREX

Data/Code Repository for https://api.semanticscholar.org/CorpusID:218470122
Python
125
star
74

s2-folks

Public space for the user community of Semantic Scholar APIs to share scripts, report issues, and make suggestions.
125
star
75

scidocs

Dataset accompanying the SPECTER model
Python
124
star
76

gooaq

Question-answers, collected from Google
Python
116
star
77

OpenBookQA

Code for experiments on OpenBookQA from the EMNLP 2018 paper "Can a Suit of Armor Conduct Electricity? A New Dataset for Open Book Question Answering"
Python
113
star
78

allennlp-as-a-library-example

A simple example for how to build your own model using AllenNLP as a dependency.
Python
113
star
79

alexafsm

With alexafsm, developers can model dialog agents with first-class concepts such as states, attributes, transition, and actions. alexafsm also provides visualization and other tools to help understand, test, debug, and maintain complex FSM conversations.
Python
108
star
80

allennlp-semparse

A framework for building semantic parsers (including neural module networks) with AllenNLP, built by the authors of AllenNLP
Python
107
star
81

scicite

Repository for NAACL 2019 paper on Citation Intent prediction
Python
106
star
82

peS2o

Pretraining Efficiently on S2ORC!
105
star
83

multimodalqa

Python
102
star
84

commonsense-kg-completion

Python
102
star
85

real-toxicity-prompts

Jupyter Notebook
101
star
86

ai2thor-rearrangement

🔀 Visual Room Rearrangement
Python
97
star
87

embodied-clip

Official codebase for EmbCLIP
Python
97
star
88

aristo-mini

Aristo mini is a light-weight question answering system that can quickly evaluate Aristo science questions with an evaluation web server and the provided baseline solvers.
Python
96
star
89

s2search

The Semantic Scholar Search Reranker
Python
93
star
90

elastic

Python
91
star
91

reward-bench

RewardBench: the first evaluation tool for reward models.
Python
90
star
92

flex

Few-shot NLP benchmark for unified, rigorous eval
Python
89
star
93

gpv-1

A task-agnostic vision-language architecture as a step towards General Purpose Vision
Jupyter Notebook
89
star
94

manipulathor

ManipulaTHOR, a framework that facilitates visual manipulation of objects using a robotic arm
Jupyter Notebook
86
star
95

medicat

Dataset of medical images, captions, subfigure-subcaption annotations, and inline textual references
Python
85
star
96

propara

ProPara (Process Paragraph Comprehension) dataset and models
Python
82
star
97

allennlp-guide

Code and material for the AllenNLP Guide
Python
81
star
98

hierplane

A tool for visualizing trees, tailored specifically to the analysis of parse trees.
JavaScript
81
star
99

S2AND

Semantic Scholar's Author Disambiguation Algorithm & Evaluation Suite
Python
78
star
100

ARC-Solvers

ARC Question Solvers
Python
78
star