Skip to main content

MXNet Gluon NLP Toolkit

Project description

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.

News

Installation

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

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

Community

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.

Resources

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 = nlp.data.WikiText2(segment='train')
>>> train[0:5]
['=', 'Valkyria', 'Chronicles', 'III', '=']

Vocabulary Construction

Build vocabulary based on the above dataset, for example:

>>> vocab = nlp.Vocab(counter=nlp.data.Counter(train))
>>> 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
StandardRNN(
  (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
(50,)

Reference Paper

The bibtex entry for the reference paper of GluonNLP is:

@article{gluoncvnlp2020,
  author  = {Jian Guo and He He and Tong He and Leonard Lausen and Mu Li and Haibin Lin and Xingjian Shi and Chenguang Wang and Junyuan Xie and Sheng Zha and Aston Zhang and Hang Zhang and Zhi Zhang and Zhongyue Zhang and Shuai Zheng and Yi Zhu},
  title   = {GluonCV and GluonNLP: Deep Learning in Computer Vision and Natural Language Processing},
  journal = {Journal of Machine Learning Research},
  year    = {2020},
  volume  = {21},
  number  = {23},
  pages   = {1-7},
  url     = {http://jmlr.org/papers/v21/19-429.html}
}

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gluonnlp-0.10.0.tar.gz (344.5 kB view details)

Uploaded Source

File details

Details for the file gluonnlp-0.10.0.tar.gz.

File metadata

  • Download URL: gluonnlp-0.10.0.tar.gz
  • Upload date:
  • Size: 344.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.7.8

File hashes

Hashes for gluonnlp-0.10.0.tar.gz
Algorithm Hash digest
SHA256 ae34825031f5228f3fced26339b56550cf8e360b40906aa44fb705439ff426e0
MD5 c1b4b318809fd999bbd2bffc559e2fcd
BLAKE2b-256 9c81a238e47ccba0d7a61dcef4e0b4a7fd4473cb86bed3d84dd4fe28d45a0905

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page