推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)

推荐github上的一个NLP代码实现的教程:nlp-tutorial,一个使用TensorFlow和Pytorch学习NLP(自然语言处理)的教程,教程中的大多数NLP模型都使用少于100行代码实现。

教程说明

这是使用TensorFlow和Pytorch学习NLP(自然语言处理)的教程,把常用NLP模型用不到100行的代码实现了,教程里附论文下载,并且包含py和ipynb文件,经过测试全部通过。

仓库地址:

https://github.com/graykode/nlp-tutorial
里面有使用说明和样例(py和ipynb格式)。

教程目录

1. Basic Embedding Model(基础嵌入模型)

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

  • 论文下载

A Neural Probabilistic Language Model(2003)

  • 代码实现

NNLM_Tensor.ipynb, NNLM_Torch.ipynb

1-2. Word2Vec(Skip-gram)EmbeddingWords and Show Graph

  • 论文下载

Distributed Representations of Words and Phrases and their Compositionality(2013)

  • 代码实现

Word2Vec_Tensor(NCE_loss).ipynb, Word2Vec_Tensor(Softmax).ipynb, Word2Vec_Torch(Softmax).ipynb

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

  • 论文下载

Bag of Tricks for Efficient Text Classification(2016)

  • 代码实现

FastText.ipynb

2. CNN(卷积神经网络)

2-1. TextCNNBinarySentiment Classification

  • 论文下载

Convolutional Neural Networks for Sentence Classification(2014)

  • 代码实现

TextCNN_Tensor.ipynb, TextCNN_Torch.ipynb

2-2. DCNN(Dynamic Convolutional Neural Network)

3. RNN(循环神经网络)

3-1. TextRNNPredict NextStep

  • 论文下载

Finding Structure in Time(1990)

  • 代码实现

TextRNN_Tensor.ipynb, TextRNN_Torch.ipynb

3-2. TextLSTMAutocomplete

  • 论文下载

LONG SHORT-TERM MEMORY(1997)

  • 代码实现

TextLSTM_Tensor.ipynb, TextLSTM_Torch.ipynb

3-3. Bi-LSTMPredict NextWord in Long Sentence

  • 代码实现

Bi_LSTM_Tensor.ipynb, Bi_LSTM_Torch.ipynb

4. Attention Mechanism(注意力机制)

4-1. Seq2SeqChange Word

  • 论文下载

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

  • 代码实现

Seq2Seq_Tensor.ipynb, Seq2Seq_Torch.ipynb

4-2. Seq2Seq with AttentionTranslate

  • 论文下载

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

  • 代码实现

Seq2Seq(Attention)_Tensor.ipynb, Seq2Seq(Attention)_Torch.ipynb

4-3. Bi-LSTM with AttentionBinarySentiment Classification

  • 代码实现

Bi_LSTM(Attention)_Tensor.ipynb, Bi_LSTM(Attention)_Torch.ipynb

5. Model based on Transformer(Transformer模型)

5-1. The TransformerTranslate

  • 论文下载

Attention Is All You Need(2017)

  • 代码实现

Transformer_Torch.ipynb, Transformer(Greedy_decoder)_Torch.ipynb

5-2. BERTClassificationNext Sentence & Predict Masked Tokens

  • 论文下载

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

部分内容截图

《推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)》

《推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)》
《推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)》
《推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)》
《推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)》
《推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)》
《推荐:常见NLP模型的代码实现(使用TensorFlow和PyTorch)》 TextCNN的两种实现方式(使用TensorFlow和Pytorch)

总结

推荐github上的一个NLP代码教程:nlp-tutorial,一个使用TensorFlow和Pytorch学习NLP(自然语言处理)的教程,教程中的大多数NLP模型都使用少于100行代码实现。

仓库地址:
https://github.com/graykode/nlp-tutorial
里面有使用说明和样例(py和ipynb格式)。

仓库作者:Tae Hwan Jung(Jeff Jung)

    原文作者:黄海广
    原文地址: https://zhuanlan.zhihu.com/p/71503733
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞