【Github】nlp-tutorial:TensorFlow 和 PyTorch 实现各种NLP模型

2019 年 9 月 4 日 AINLP

推荐一个Github项目:/nlp-tutorial


Natural Language Processing Tutorial for Deep Learning Researchers 


这个tutorial面向自然语言处理学习者提供基于TensorFlow和PyTorch的相关NLP模型实现,绝大多数实现不超过100行,可以参考:


nlp-tutorial is a tutorial for who is studying NLP(Natural Language Processing) using TensorFlow and Pytorch. Most of the models in NLP were implemented with less than 100 lines of code.(except comments or blank lines)


推荐Star,项目链接,点击阅读原文可以直达:


https://github.com/graykode/nlp-tutorial


以下来在该项目主页描述。



Curriculum - (Example Purpose)

1. Basic Embedding Model

  • 1-1. NNLM(Neural Network Language Model) - Predict Next Word

    • Paper - A Neural Probabilistic Language Model(2003)

    • Colab - NNLM_Tensor.ipynb, NNLM_Torch.ipynb

  • 1-2. Word2Vec(Skip-gram) - Embedding Words and Show Graph

    • Paper - Distributed Representations of Words and Phrases and their Compositionality(2013)

    • Colab - Word2Vec_Tensor(NCE_loss).ipynb, Word2Vec_Tensor(Softmax).ipynb, Word2Vec_Torch(Softmax).ipynb

  • 1-3. FastText(Application Level) - Sentence Classification

    • Paper - Bag of Tricks for Efficient Text Classification(2016)

    • Colab - FastText.ipynb

2. CNN(Convolutional Neural Network)

  • 2-1. TextCNN - Binary Sentiment Classification

    • Paper - Convolutional Neural Networks for Sentence Classification(2014)

    • Colab - TextCNN_Tensor.ipynb, TextCNN_Torch.ipynb

  • 2-2. DCNN(Dynamic Convolutional Neural Network)

3. RNN(Recurrent Neural Network)

  • 3-1. TextRNN - Predict Next Step

    • Paper - Finding Structure in Time(1990)

    • Colab - TextRNN_Tensor.ipynb, TextRNN_Torch.ipynb

  • 3-2. TextLSTM - Autocomplete

    • Paper - LONG SHORT-TERM MEMORY(1997)

    • Colab - TextLSTM_Tensor.ipynb, TextLSTM_Torch.ipynb

  • 3-3. Bi-LSTM - Predict Next Word in Long Sentence

    • Colab - Bi_LSTM_Tensor.ipynb, Bi_LSTM_Torch.ipynb

4. Attention Mechanism

  • 4-1. Seq2Seq - Change Word

    • Paper - Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation(2014)

    • Colab - Seq2Seq_Tensor.ipynb, Seq2Seq_Torch.ipynb

  • 4-2. Seq2Seq with Attention - Translate

    • Paper - Neural Machine Translation by Jointly Learning to Align and Translate(2014)

    • Colab - Seq2Seq(Attention)_Tensor.ipynb, Seq2Seq(Attention)_Torch.ipynb

  • 4-3. Bi-LSTM with Attention - Binary Sentiment Classification

    • Colab - Bi_LSTM(Attention)_Tensor.ipynb, Bi_LSTM(Attention)_Torch.ipynb

5. Model based on Transformer

  • 5-1. The Transformer - Translate

    • Paper - Attention Is All You Need(2017)

    • Colab - Transformer_Torch.ipynb, Transformer(Greedy_decoder)_Torch.ipynb

  • 5-2. BERT - Classification Next Sentence & Predict Masked Tokens

    • Paper - BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding(2018)

    • Colab - BERT_Torch.ipynb

Model Example Framework Lines(torch/tensor)
NNLM Predict Next Word Torch, Tensor 67/83
Word2Vec(Softmax) Embedding Words and Show Graph Torch, Tensor 77/94
TextCNN Sentence Classification Torch, Tensor 94/99
TextRNN Predict Next Step Torch, Tensor 70/88
TextLSTM Autocomplete Torch, Tensor 73/78
Bi-LSTM Predict Next Word in Long Sentence Torch, Tensor 73/78
Seq2Seq Change Word Torch, Tensor 93/111
Seq2Seq with Attention Translate Torch, Tensor 108/118
Bi-LSTM with Attention Binary Sentiment Classification Torch, Tensor 92/104
Transformer Translate Torch 222/0
Greedy Decoder Transformer Translate Torch 246/0
BERT how to train Torch 242/0

Dependencies

  • Python 3.5+

  • Tensorflow 1.12.0+

  • Pytorch 0.4.1+

  • Plan to add Keras Version

Author

  • Tae Hwan Jung(Jeff Jung) @graykode

  • Author Email : nlkey2022@gmail.com

  • Acknowledgements to mojitok as NLP Research Internship.


登录查看更多
14

相关内容

Google Colaboratory是谷歌开放的一款研究工具,主要用于机器学习的开发和研究。这款工具现在可以免费使用,但是不是永久免费暂时还不确定。Google Colab最大的好处是给广大的AI开发者提供了免费的GPU使用。
深度学习自然语言处理概述,216页ppt,Jindřich Helcl
专知会员服务
209+阅读 · 2020年4月26日
Transformer文本分类代码
专知会员服务
116+阅读 · 2020年2月3日
一网打尽!100+深度学习模型TensorFlow与Pytorch代码实现集合
开源书:PyTorch深度学习起步
专知会员服务
49+阅读 · 2019年10月11日
2019年机器学习框架回顾
专知会员服务
35+阅读 · 2019年10月11日
TensorFlow 2.0 学习资源汇总
专知会员服务
66+阅读 · 2019年10月9日
Github 项目推荐 | PyTorch 实现的 GAN 文本生成框架
AI研习社
33+阅读 · 2019年6月10日
基于PyTorch/TorchText的自然语言处理库
专知
27+阅读 · 2019年4月22日
Facebook PyText 在 Github 上开源了
AINLP
7+阅读 · 2018年12月14日
机器学习的Pytorch实现资源集合
专知
11+阅读 · 2018年9月1日
GitHub获赞过千:PyTorch 自然语言处理项目Top 5
新智元
12+阅读 · 2018年7月10日
Github 上 Star 过千的 PyTorch NLP 相关项目
专知
3+阅读 · 2018年7月5日
资源 | Github项目:斯坦福大学CS-224n课程中深度NLP模型的PyTorch实现
黑龙江大学自然语言处理实验室
10+阅读 · 2017年11月13日
Arxiv
4+阅读 · 2019年12月2日
Tutorial on NLP-Inspired Network Embedding
Arxiv
7+阅读 · 2019年10月16日
Arxiv
31+阅读 · 2018年11月13日
Bidirectional Attention for SQL Generation
Arxiv
4+阅读 · 2018年6月21日
VIP会员
相关VIP内容
深度学习自然语言处理概述,216页ppt,Jindřich Helcl
专知会员服务
209+阅读 · 2020年4月26日
Transformer文本分类代码
专知会员服务
116+阅读 · 2020年2月3日
一网打尽!100+深度学习模型TensorFlow与Pytorch代码实现集合
开源书:PyTorch深度学习起步
专知会员服务
49+阅读 · 2019年10月11日
2019年机器学习框架回顾
专知会员服务
35+阅读 · 2019年10月11日
TensorFlow 2.0 学习资源汇总
专知会员服务
66+阅读 · 2019年10月9日
相关资讯
Github 项目推荐 | PyTorch 实现的 GAN 文本生成框架
AI研习社
33+阅读 · 2019年6月10日
基于PyTorch/TorchText的自然语言处理库
专知
27+阅读 · 2019年4月22日
Facebook PyText 在 Github 上开源了
AINLP
7+阅读 · 2018年12月14日
机器学习的Pytorch实现资源集合
专知
11+阅读 · 2018年9月1日
GitHub获赞过千:PyTorch 自然语言处理项目Top 5
新智元
12+阅读 · 2018年7月10日
Github 上 Star 过千的 PyTorch NLP 相关项目
专知
3+阅读 · 2018年7月5日
资源 | Github项目:斯坦福大学CS-224n课程中深度NLP模型的PyTorch实现
黑龙江大学自然语言处理实验室
10+阅读 · 2017年11月13日
Top
微信扫码咨询专知VIP会员