Files
graykode--nlp-tutorial/README.md
T
2026-07-13 10:44:04 +00:00

91 lines
5.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- WEHUB_ZH_README -->
> [!NOTE]
> 本文档由 WeHub 基于上游 README 翻译整理,属于社区翻译,非官方中文文档。
> [English](./README.en.md) · [原始项目](https://github.com/graykode/nlp-tutorial) · [上游 README](https://github.com/graykode/nlp-tutorial/blob/HEAD/README.md)
> 原作者、版权与许可证归属以原始项目及本仓库 LICENSE 文件为准。
## nlp-tutorial
<p align="center"><img width="100" src="https://upload.wikimedia.org/wikipedia/commons/thumb/1/11/TensorFlowLogo.svg/225px-TensorFlowLogo.svg.png" /> <img width="100" src="https://media-thumbs.golden.com/OLqzmrmwAzY1P7Sl29k2T9WjJdM=/200x200/smart/golden-storage-production.s3.amazonaws.com/topic_images/e08914afa10a4179893eeb07cb5e4713.png" /></p>
`nlp-tutorial` 是一份面向学习 NLP(自然语言处理,Natural Language Processing)者的教程,使用 **Pytorch** 实现。NLP 中的大多数模型均用不到 **100 行**代码实现。(注释和空行除外)
- [08-14-2020] 旧版 TensorFlow v1 代码已归档至 [archive 文件夹](archive)。为便于初学者阅读,仅支持 PyTorch 1.0 及以上版本。
## 课程大纲 -(示例用途)
#### 1. 基础嵌入模型(Embedding Model
- 1-1. [NNLM(神经网络语言模型,Neural Network Language Model](1-1.NNLM) - **预测下一个词(Predict Next Word**
- 论文 - [A Neural Probabilistic Language Model(2003)](http://www.jmlr.org/papers/volume3/bengio03a/bengio03a.pdf)
- Colab - [NNLM.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/1-1.NNLM/NNLM.ipynb)
- 1-2. [Word2VecSkip-gram](1-2.Word2Vec) - **词嵌入与图形展示(Embedding Words and Show Graph**
- 论文 - [Distributed Representations of Words and Phrases
and their Compositionality(2013)](https://papers.nips.cc/paper/5021-distributed-representations-of-words-and-phrases-and-their-compositionality.pdf)
- Colab - [Word2Vec.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/1-2.Word2Vec/Word2Vec_Skipgram(Softmax).ipynb)
- 1-3. [FastText(应用层,Application Level](1-3.FastText) - **句子分类(Sentence Classification**
- 论文 - [Bag of Tricks for Efficient Text Classification(2016)](https://arxiv.org/pdf/1607.01759.pdf)
- Colab - [FastText.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/1-3.FastText/FastText.ipynb)
#### 2. CNN(卷积神经网络,Convolutional Neural Network
- 2-1. [TextCNN](2-1.TextCNN) - **二分类情感分析(Binary Sentiment Classification**
- 论文 - [Convolutional Neural Networks for Sentence Classification(2014)](http://www.aclweb.org/anthology/D14-1181)
- [TextCNN.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/2-1.TextCNN/TextCNN.ipynb)
#### 3. RNN(循环神经网络,Recurrent Neural Network
- 3-1. [TextRNN](3-1.TextRNN) - **预测下一步(Predict Next Step**
- 论文 - [Finding Structure in Time(1990)](http://psych.colorado.edu/~kimlab/Elman1990.pdf)
- Colab - [TextRNN.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/3-1.TextRNN/TextRNN.ipynb)
- 3-2. [TextLSTM](https://github.com/graykode/nlp-tutorial/tree/master/3-2.TextLSTM) - **自动补全(Autocomplete**
- 论文 - [LONG SHORT-TERM MEMORY(1997)](https://www.bioinf.jku.at/publications/older/2604.pdf)
- Colab - [TextLSTM.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/3-2.TextLSTM/TextLSTM.ipynb)
- 3-3. [Bi-LSTM](3-3.Bi-LSTM) - **在长句中预测下一个词(Predict Next Word in Long Sentence**
- Colab - [Bi_LSTM.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/3-3.Bi-LSTM/Bi_LSTM.ipynb)
#### 4. 注意力机制(Attention Mechanism
- 4-1. [Seq2Seq](4-1.Seq2Seq) - **词语替换(Change Word**
- 论文 - [Learning Phrase Representations using RNN EncoderDecoder
for Statistical Machine Translation(2014)](https://arxiv.org/pdf/1406.1078.pdf)
- Colab - [Seq2Seq.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/4-1.Seq2Seq/Seq2Seq.ipynb)
- 4-2. [Seq2Seq with Attention](4-2.Seq2Seq(Attention)) - **机器翻译(Translate**
- 论文 - [Neural Machine Translation by Jointly Learning to Align and Translate(2014)](https://arxiv.org/abs/1409.0473)
- Colab - [Seq2Seq(Attention).ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/4-2.Seq2Seq(Attention)/Seq2Seq(Attention).ipynb)
- 4-3. [Bi-LSTM with Attention](4-3.Bi-LSTM(Attention)) - **二分类情感分析(Binary Sentiment Classification**
- Colab - [Bi_LSTM(Attention).ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/4-3.Bi-LSTM(Attention)/Bi_LSTM(Attention).ipynb)
#### 5. 基于 Transformer 的模型
- 5-1. [The Transformer](5-1.Transformer) - **机器翻译(Translate**
- 论文 - [Attention Is All You Need(2017)](https://arxiv.org/abs/1706.03762)
- Colab - [Transformer.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/5-1.Transformer/Transformer.ipynb), [Transformer(Greedy_decoder).ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/5-1.Transformer/Transformer(Greedy_decoder).ipynb)
- 5-2. [BERT](5-2.BERT) - **下一句分类与掩码词预测(Classification Next Sentence & Predict Masked Tokens**
- 论文 - [BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding(2018)](https://arxiv.org/abs/1810.04805)
- Colab - [BERT.ipynb](https://colab.research.google.com/github/graykode/nlp-tutorial/blob/master/5-2.BERT/BERT.ipynb)
## 依赖项
- Python 3.5+
- Pytorch 1.0.0+
## 作者
- Tae Hwan Jung(Jeff Jung) @graykode
- 作者邮箱:nlkey2022@gmail.com
- 感谢 [mojitok](http://mojitok.com/) 担任 NLP 研究实习生。