Author(s): Jason Phang and Jesse Swanson
Publication date: October 7 2020
Reviewer: Jason Lee
Editor: Kyunghyun Cho
We are excited to release jiant 2.0: a natural language understanding toolkit built to reflect the evolving needs of NLP researchers.
Summary
- jiant is a research library for natural language understanding including multi-task training and transfer learning
- jiant supports a wide range of tasks (including the GLUE, SuperGLUE and XTREME benchmarks), and many of the newest transformers models (BERT, RoBERTa, ALBERT, ELECTRA, XLM-R, etc)
- jiant is designed to be modular and easily adaptable to different experimental or training workflows
- Check out jiant 2.0 here: https://github.com/nyu-mll/jiant
What is jiant?
jiant is a NLP research library written in Python. jiant is built for researching general-purpose text understanding models and transfer learning. jiant 1.x has been used in several published research papers. jiant 2.0 was rebuilt from the ground up to support cutting-edge NLP research.
What’s new in 2.0?
The NLP research landscape has changed dramatically since the initial release of jiant 1.0 two years ago. In that time, we have witnessed the rise of BERT-style fine-tuning, the development of a whole sub-field studying BERTology, and community adoption of libraries such as Hugging Face’s transformers, tokenizers, and datasets (formerly nlp).
To support the changing needs of NLP researchers, jiant has undergone major changes and is now built with transformers models and datasets. jiant has a new training pipeline to facilitate modern experimental workflows. jiant is no longer a framework. jiant is a modular library. At the same time, we expanded task and model support.
Why should I use jiant?
With transformers’ large and expanding library of examples, is there really a need for another wrapper library just to run some experiments?
We think so.
When doing research, you want a unified API for running experiments with different models, tasks, or run configurations rather than making ad-hoc tweaks for different experiments or running experiments with different scripts resulting in duplicated code. jiant is designed to facilitate large-scale, replicable, configuration-driven experiments from a single standardized interface.
To further explain what jiant brings to the table, let’s go over each of the major components of the jiant library.
Tasks
jiant supports more than 50 natural language understanding tasks built in part on Hugging Face’s datasets. These include the GLUE, SuperGLUE, and XTREME benchmark tasks, edge probing tasks, and many more. Each task implementation handles all the preprocessing from the task’s raw data format to transformers model inputs. If you’re using one of the currently supported tasks, you should not need to write any code to start training. If you intend to add a task, that’s easy too.
Models
jiant supports BERT, RoBERTa, XLM-R, ALBERT, BART, mBART, and ELECTRA, based on Hugging Face’s transformers and tokenizers libraries. jiant models comprise of a text encoder (e.g BERT), and task-specific heads corresponding to each task. Multiple heads can share a single encoder, supporting multi-task training. jiant supports a wide variety of task heads including classification, regression, multiple choice, span comparison, span prediction, multi-label span comparison, tagging, question answering and masked language modeling. It is also possible to add support for encoder models beyond those currently supported.
Runner
With task data and models in hand, we need to train and evaluate our models. jiant provides a Runner implementation, which handles the training loop for an experiment (similar to transformers Trainer). jiant’s Runner natively supports multi-task training, and this includes considerations like different task-sampling methods and different batch sizes or gradient accumulation steps per task. All of this is exposed through a single run-script that you can call to start training your model.
How do I start using jiant?
The following is a multitask training example using RoBERTa on the MRPC and RTE task. jiant uses proportional sampling from each task as default (this is configurable).
Python version:
from jiant.proj.simple import runscript as run
import jiant.scripts.download_data.runscript as downloader
# Download the Data
downloader.download_data([“mrpc”, “rte”], “/content/data”)
# Set up the arguments for the Simple API
args = run.RunConfiguration(
run_name=“simple”,
exp_dir=“/content/exp”,
data_dir=“/content/data”,
model_type=“roberta-base”,
tasks=“mrpc,rte”,
train_batch_size=16,
num_train_epochs=3
)
Bash version:
python jiant/scripts/download_data/runscript.py \
download \
--tasks mrpc rte \
--output_path /content/data
python jiant/proj/simple/runscript.py \
run \
--run_name simple \
--exp_dir /content/data \
--data_dir /content/data \
--model_type roberta-base \
--tasks mrpc,rte \
--train_batch_size 16 \
--num_train_epochs 3
As you can see above, this is pretty simple! The simple API abstracts the complete jiant pipeline for quick evaluation on tasks. For more complex experimental workflows, we provide a more in-depth introduction to jiant here.
Beyond multi-task training, we have examples demonstrating training workflows including:
- Sequential transfer (STILTs)
- Zero-shot evaluation on XNLI from a model trained on MNLI
These examples can be found here.
Design Philosophy
A major departure from jiant 1.0 is the change in our design philosophy to build a library, not a framework. In other words, jiant 2.0 is designed to be able to be used piecewise and to support workflows that we haven’t thought of yet. jiant’s task preprocessing can be wrapped and fed into Transformer models. jiant’s models can be used in a different training workflow than the one we provide.
In short, jiant is built to support NLP research across a wide swathe of models and tasks, but flexible enough to support more complex experimental workflows. And if there is some new idea you want to experiment with, and you want to quickly evaluate it against a large variety of tasks or models, jiant is the perfect place to start.
Final thoughts: Building a research library is hard!
In typical software libraries, one aims to draw a clean line between implementation and interface. In a research library like jiant, everything must be exposed and configurable since. researchers require maximum flexibility to implement new methods. Scope creep == research! The trade-off between flexibility and ease-of-use is a difficult line that we try to walk in jiant.
jiant is under active development, and there are many features we are excited to work on in the near future. We want to support use cases the NLP research community is interested in. We are actively seeking feedback and contributions from the community!
Check out jiant here: https://github.com/nyu-mll/jiant
Revision history
- October 7 2020: Initial publication