转载:https://mp.weixin.qq.com/s/-EAFB4NTFl2MkRPSKiMQVQ
    推荐github上的一个NLP代码教程:nlp-tutorial,教程中包含常见的NLP模型代码实现(基于TensorFlow和Pytorch),而且教程中的大多数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)- **

    • 论文下载

    A Neural Probabilistic LanguageModel(2003)

    • 代码实现

      NNLM_Tensor.ipynb, NNLM_Torch.ipynb

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

    • 论文下载

    Distributed Representations of Wordsand 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-1. TextCNN -
    BinarySentiment Classification**

    • 论文下载

    Convolutional Neural Networks for SentenceClassification(2014)

    • 代码实现

    TextCNN_Tensor.ipynb, TextCNN_Torch.ipynb

    2-2. DCNN(Dynamic Convolutional Neural Network)

    3-1. TextRNN -
    Predict NextStep**

    • 论文下载

    Finding Structure in Time(1990)

    • 代码实现

    TextRNN_Tensor.ipynb, TextRNN_Torch.ipynb

    3-2. TextLSTM - Autocomplete

    • 论文下载

    LONG SHORT-TERM MEMORY(1997)

    • 代码实现

    TextLSTM_Tensor.ipynb, TextLSTM_Torch.ipynb
    3-3. Bi-LSTM - Predict NextWord in Long Sentence

    • 代码实现

    Bi_LSTM_Tensor.ipynb, Bi_LSTM_Torch.ipynb

    4-1. Seq2Seq -
    Change Word**

    • 论文下载

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

    • 代码实现

    Seq2Seq_Tensor.ipynb, Seq2Seq_Torch.ipynb

    4-2. Seq2Seq with Attention - Translate

    • 论文下载

    NeuralMachine Translation by Jointly Learning to Align and Translate(2014)

    • 代码实现

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

    4-3. Bi-LSTM with Attention - BinarySentiment Classification

    • 代码实现

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

    5-1. The Transformer -
    Translate**

    • 论文下载

    Attention Is All You Need(2017)

    • 代码实现

    Transformer_Torch.ipynb, Transformer(Greedy_decoder)_Torch.ipynb

    5-2. BERT - ClassificationNext Sentence & Predict Masked Tokens

    • 论文下载

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

    • 代码实现
      BERT_Torch.ipynb

    部分内容截图
    Github标星5.4k :常见NLP模型的代码实现(基于TensorFlow和PyTorch) - 图1
    Github标星5.4k :常见NLP模型的代码实现(基于TensorFlow和PyTorch) - 图2
    Github标星5.4k :常见NLP模型的代码实现(基于TensorFlow和PyTorch) - 图3
    Github标星5.4k :常见NLP模型的代码实现(基于TensorFlow和PyTorch) - 图4
    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)
    注意:论文下载请“阅读原文”。

    Github标星5.4k :常见NLP模型的代码实现(基于TensorFlow和PyTorch) - 图5