Skip to content
Python Shell Groovy C++ Perl Makefile Other
Branch: master
Clone or download
kamatsuoka and eric-haibin-lin [DOC] Fix command line examples for text classification (#874)
* Fix command line examples

* Update index.rst
Latest commit d36a1e6 Sep 23, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github [CI] enable timestamp in CI (#925) Sep 18, 2019
ci [CI] enable timestamp in CI (#925) Sep 18, 2019
docs [DOC] Add missing docs for nlp.utils (#936) Sep 22, 2019
env [CI] Fix CI (#875) Aug 14, 2019
scripts [DOC] Fix command line examples for text classification (#874) Sep 23, 2019
src/gluonnlp [Usability] Add version checker to all tutorials (#934) Sep 20, 2019
tests [Usability] Add version checker to all scripts (#930) Sep 17, 2019
tools Scripts for producing the figures that explain the bucketing strategy ( Sep 3, 2019
.coveragerc [CI] CI refactoring to speed up tests (#566) May 3, 2019
.gitignore add license checker (#804) Jul 2, 2019
.gitmodules Add GloVe to documentation and enable tests (#424) Nov 26, 2018
.pylintrc Change scripts test hierarchy (#35) Apr 19, 2018
CODEOWNERS [CI] enable timestamp in CI (#925) Sep 18, 2019 [DOC] community related docs and templates (#745) Jun 5, 2019 [DOC] community related docs and templates (#745) Jun 5, 2019
LICENSE Migrate gluon-nlp-toolkit Apr 12, 2018 Change scripts test hierarchy (#35) Apr 19, 2018
Makefile [DATASET] add atis and snips (#816) Jul 5, 2019
README.rst Update README.rst (#884) Aug 23, 2019
codecov.yml [CI] fix codecov (#693) May 5, 2019 [REFACTOR] Drop unused compatibility helpers and fix doc (#928) Sep 16, 2019
contributor.rst writing fix (#301) Aug 18, 2018
examples make CI more debug-friendly (#312) Aug 23, 2018
pytest.ini [MODEL] �GPT-2 for text generation (#761) Jun 13, 2019 Declare Python version requirement in (#927) Sep 16, 2019


GluonNLP: Your Choice of Deep Learning for NLP

GluonNLP is a toolkit that enables easy text preprocessing, datasets loading and neural models building to help you speed up your Natural Language Processing (NLP) research.



Make sure you have Python 3.6 or newer and a recent version of MXNet (our CI server runs the testsuite with Python 3.6).

You can install MXNet and GluonNLP using pip.

GluonNLP is based on the most recent version of MXNet.

In particular, if you want to install the most recent MXNet release:

pip install --upgrade mxnet>=1.5.0

Else, if you want to install the most recent MXNet nightly build:

pip install --pre --upgrade mxnet

Then, you can install GluonNLP:

pip install gluonnlp

Please check more installation details.

Docs 📖

GluonNLP documentation is available at our website.


GluonNLP is a community that believes in sharing.

For questions, comments, and bug reports, Github issues is the best way to reach us.

We now have a new Slack channel here. (register).

How to Contribute

GluonNLP community welcomes contributions from anyone!

There are lots of opportunities for you to become our contributors:

  • Ask or answer questions on GitHub issues.
  • Propose ideas, or review proposed design ideas on GitHub issues.
  • Improve the documentation.
  • Contribute bug reports GitHub issues.
  • Write new scripts to reproduce state-of-the-art results.
  • Write new examples to explain key ideas in NLP methods and models.
  • Write new public datasets (license permitting).
  • Most importantly, if you have an idea of how to contribute, then do it!

For a list of open starter tasks, check good first issues.

Also see our contributing guide on simple how-tos, contribution guidelines and more.


Check out how to use GluonNLP for your own research or projects.

If you are new to Gluon, please check out our 60-minute crash course.

For getting started quickly, refer to notebook runnable examples at Examples.

For advanced examples, check out our Scripts.

For experienced users, check out our API Notes.

Quick Start Guide

Dataset Loading

Load the Wikitext-2 dataset, for example:

>>> import gluonnlp as nlp
>>> train ='train')
>>> train[0:5]
['=', 'Valkyria', 'Chronicles', 'III', '=']

Vocabulary Construction

Build vocabulary based on the above dataset, for example:

>>> vocab = nlp.Vocab(
>>> vocab
Vocab(size=33280, unk="<unk>", reserved="['<pad>', '<bos>', '<eos>']")

Neural Models Building

From the models package, apply a Standard RNN language model to the above dataset:

>>> model = nlp.model.language_model.StandardRNN('lstm', len(vocab),
...                                              200, 200, 2, 0.5, True)
>>> model
  (embedding): HybridSequential(
    (0): Embedding(33280 -> 200, float32)
    (1): Dropout(p = 0.5, axes=())
  (encoder): LSTM(200 -> 200.0, TNC, num_layers=2, dropout=0.5)
  (decoder): HybridSequential(
    (0): Dense(200 -> 33280, linear)

Word Embeddings Loading

For example, load a GloVe word embedding, one of the state-of-the-art English word embeddings:

>>> glove = nlp.embedding.create('glove', source='glove.6B.50d')
# Obtain vectors for 'baby' in the GloVe word embedding
>>> type(glove['baby'])
<class 'mxnet.ndarray.ndarray.NDArray'>
>>> glove['baby'].shape

Reference Paper

The bibtex entry for the reference paper of GluonNLP is:

  title={GluonCV and GluonNLP: Deep Learning in Computer Vision and Natural Language Processing},
  author={Guo, Jian and He, He and He, Tong and Lausen, Leonard and Li, Mu and Lin, Haibin and Shi, Xingjian and Wang, Chenguang and Xie, Junyuan and Zha, Sheng and Zhang, Aston and Zhang, Hang and Zhang, Zhi and Zhang, Zhongyue and Zheng, Shuai},
  journal={arXiv preprint arXiv:1907.04433},

New to Deep Learning or NLP?

For background knowledge of deep learning or NLP, please refer to the open source book Dive into Deep Learning.

You can’t perform that action at this time.