Package: gluonnlp
GluonNLP: Your Choice of Deep Learning for NLPGluonNLP 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.Quick Start GuideResourcesNewsTutorial proposal for GluonNLP is accepted atEMNLP 2019, Hong Kong.GluonNLP was featured in:KDD 2019 Alaska! Check out our tutorial:From Shallow to Deep Language Representations: Pre-training, Fine-tuning, and Beyond.JSALT 2019 in Montreal, 2019-6-14! Checkouthttps://jsalt19.mxnet.io.AWS re:invent 2018 in Las Vegas, 2018-11-28! Checkoutdetails.PyData 2018 NYC, 2018-10-18! Checkout theawesome talkby Sneha Jha.KDD 2018 London, 2018-08-21, Apache MXNet Gluon tutorial! Check outhttps://kdd18.mxnet.io.InstallationMake 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 installMXNetandGluonNLPusing pip.GluonNLPis based on the most recent version ofMXNet.In particular, if you want to install the most recentMXNetrelease:pip install --upgrade mxnet>=1.6.0Else, if you want to install the most recentMXNetnightly build:pip install --pre --upgrade mxnetThen, you can installGluonNLP:pip install gluonnlpPlease check moreinstallation details.Docs 📖GluonNLP documentation is available atour
website.CommunityGluonNLP is a community that believes in sharing.For questions, comments, and bug reports,Github issuesis the best way to reach us.We now have a new Slack channelhere.
(register).How to ContributeGluonNLP community welcomes contributions from anyone!There are lots of opportunities for you to become ourcontributors:Ask or answer questions onGitHub issues.Propose ideas, or review proposed design ideas onGitHub issues.Improve thedocumentation.Contribute bug reportsGitHub issues.Write newscriptsto reproduce
state-of-the-art results.Write newexamplesto explain
key ideas in NLP methods and models.Write newpublic datasets(license permitting).Most importantly, if you have an idea of how to contribute, then do it!For a list of open starter tasks, checkgood first issues.Also see ourcontributing
guideon simple how-tos,
contribution guidelines and more.ResourcesCheck out how to use GluonNLP for your own research or projects.If you are new to Gluon, please check out our60-minute crash course.For getting started quickly, refer to notebook runnable examples atExamples.For advanced examples, check out ourScripts.For experienced users, check out ourAPI Notes.Quick Start GuideDataset LoadingLoad the Wikitext-2 dataset, for example:>>>importgluonnlpasnlp>>>train=nlp.data.WikiText2(segment='train')>>>train[0:5]['=','Valkyria','Chronicles','III','=']Vocabulary ConstructionBuild vocabulary based on the above dataset, for example:>>>vocab=nlp.Vocab(counter=nlp.data.Counter(train))>>>vocabVocab(size=33280,unk="<unk>",reserved="['<pad>', '<bos>', '<eos>']")Neural Models BuildingFrom 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)>>>modelStandardRNN((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 LoadingFor 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 PaperThe bibtex entry for thereference paperof 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 bookDive into Deep Learning.