GluonNLP: NLP made easy

Get Started: A Quick Example

Here is a quick example that downloads and creates a word embedding model and then computes the cosine similarity between two words.

(You can click the play button below to run this example.)

Examples

Benchmarking the Performance of NLP Backbonesmodel_zoo/benchmarks/index.html

Benchmarking the performance of NLP models. We released the benchmarking script that compares different NLP packages.

Conversion Scriptsmodel_zoo/conversion_toolkits/index.html

Converting NLP models from other frameworks to GluonNLP.

Datasetsmodel_zoo/datasets/index.html

Example about the datasets supported by nlp_data

Generationmodel_zoo/generation/index.html

Example about how to generate from a pretrained GPT-2 model with GluonNLP. We provided the generation script and tried to compare different sampling methods.

Machine Translationmodel_zoo/machine_translation/index.html

Train machine translation model with GluonNLP.

Data Preprocessing Toolkit in GluonNLPmodel_zoo/processing/index.html

Example about the data processing toolkit (nlp_process) offered in GluonNLP.

Pretraining Modelmodel_zoo/pretraining/index.html

Examples about pretraining your own backbones.

Question Answering Examplesmodel_zoo/question_answering/index.html

Run SQuAD 1.1 and 2.0 finetuning with GluonNLP. You will know how to run the models with mixed-precision training (AMP) and Horovod.

And more in tutorials.

Installation

Select your preferences and run the install command.

OS: Linux macOS

Version: Stable Nightly Source

Stable Release.
Nightly build with latest features.
Install GluonNLP from source.

Backend: CPU-Only CUDA

Build-in backend for CPU.
Required to run on Nvidia GPUs.

Prerequisites:

  • Nightly build provides latest features for enthusiasts.

Command:

# Install Apache MXNet (incubating) (Disclaimer: This is an unreleased nightly build and is used for the purpose of development).
python3 -m pip install -U --pre "mxnet>=2.0.0" -f https://dist.mxnet.io/python

# Install GluonNLP
git clone https://github.com/dmlc/gluon-nlp.git
cd gluon-nlp
python3 -m pip install -U -e ."[extras]"
# Install Apache MXNet (incubating) (Disclaimer: This is an unreleased nightly build and is used for the purpose of development).
# Here we assume CUDA 10.2 is installed. You can change the number
# according to your own CUDA version, e.g., cu101, cu110
python3 -m pip install -U --pre "mxnet-cu102>=2.0.0" -f https://dist.mxnet.io/python

# Install GluonNLP
git clone https://github.com/dmlc/gluon-nlp.git
cd gluon-nlp
python3 -m pip install -U -e ."[extras]"
# Install Apache MXNet (incubating) (Disclaimer: This is an unreleased nightly build and is used for the purpose of development).
python3 -m pip install -U --pre "mxnet>=2.0.0" -f https://dist.mxnet.io/python

# Install GluonNLP
git clone https://github.com/dmlc/gluon-nlp.git
cd gluon-nlp
python3 -m pip install -U -e ."[extras]"
# Install Apache MXNet (incubating) (Disclaimer: This is an unreleased nightly build and is used for the purpose of development).
# Here we assume CUDA 10.2 is installed. You can change the number
# according to your own CUDA version, e.g., cu100, cu101
python3 -m pip install -U --pre "mxnet-cu102>=2.0.0" -f https://dist.mxnet.io/python

# Install GluonNLP
git clone https://github.com/dmlc/gluon-nlp.git
cd gluon-nlp
python3 -m pip install -U -e ."[extras]"

Check Installation for more installation instructions and options.

About GluonNLP

Hint

You can find out the doc for our master development branch here.

GluonNLP provides implementations of the state-of-the-art (SOTA) deep learning models in NLP, and build blocks for text data pipelines and models. It is designed for engineers, researchers, and students to fast prototype research ideas and products based on these models. This toolkit offers five main features:

  1. Carefully designed APIs that greatly reduce the implementation complexity.

  2. Pre-trained models for common NLP tasks.

  3. Tutorials to help get started on new NLP tasks.

  4. Community support.

This toolkit assumes that users have basic knowledge about deep learning and NLP. Otherwise, please refer to an introductory course such as Dive into Deep Learning or Stanford CS224n. If you are not familiar with Gluon, check out the Gluon documentation. You may find the 60-min Gluon crash course linked from there especially helpful.