Based on the repository TextClassifiers by datnnt1997. Textclassifiers: Collection of Text Classification/Document Classification/Sentence Classification/Sentiment Analysis models for PyTorch
Install dependencies:
pip3 install -r requirements.txt
python3 run.py --mode train --config configs/fasttext_config.yaml
- FastText released with the paper Bag of tricks for efficient text classification by Joulin, Armand, et al.
- TextRNN
- TextCNN released with the paper Convolutional neural networks for sentence classification by Kim, Yoon.
- RCNN released with the paper Recurrent convolutional neural networks for text classification by Lai, Siwei, et al.
- LSTM + Attention released with the paper Text classification research with attention-based recurrent neural networks by Du, Changshun, and Lei Huang.
- Transformer released with the paper Attention is all you need by Vaswani, Ashish, et al.
S. No. | Model | Training | Test | ||||
---|---|---|---|---|---|---|---|
Loss | F1 | Loss | Precision | Recall | F1 | ||
1 | TextRNN | 0.097278 | 0.4952 | 0.098633 | 0.28 | 0.01 | 0.01 |
2 | TextCNN | 0.082481 | 0.5407 | 0.092145 | 0.32 | 0.06 | 0.1 |
3 | LSTM Attention | 0.084443 | 0.498 | 0.088827 | 0.31 | 0.02 | 0.04 |
4 | RCNN | 0.071199 | 0.5568 | 0.086385 | 0.43 | 0.02 | 0.04 |
5 | FastText | 0.096211 | 0.4972 | 0.099686 | 0.33 | 0.01 | 0.02 |
6 | Transformer | 0.09527 | 0.501 | 0.097861 | 0.33 | 0.01 | 0.03 |
S. No. | Model | Training | Test | ||||
---|---|---|---|---|---|---|---|
Loss | F1 | Loss | Precision | Recall | F1 | ||
1 | TextRNN | 0.536789 | 0.7388 | 0.572004 | 0.71 | 0.71 | 0.71 |
2 | TextCNN | 0.176651 | 0.9328 | 0.86567 | 0.64 | 0.78 | 0.71 |
3 | LSTM Attention | 0.537625 | 0.7379 | 0.590331 | 0.7 | 0.7 | 0.7 |
4 | RCNN | 0.442955 | 0.7994 | 0.560319 | 0.75 | 0.67 | 0.71 |
5 | FastText | 0.659113 | 0.6 | 0.647117 | 0.67 | 0.6 | 0.63 |
6 | Transformer | 0.479358 | 0.773 | 0.612778 | 0.71 | 0.68 | 0.7 |
S. No. | Model | Training | Test | ||||
---|---|---|---|---|---|---|---|
Loss | F1 | Loss | Precision | Recall | F1 | ||
1 | TextRNN | 0.519968 | 0.7486 | 0.600619 | 0.7 | 0.68 | 0.69 |
2 | TextCNN | 0.375668 | 0.8312 | 0.887177 | 0.79 | 0.46 | 0.58 |
3 | LSTM Attention | 0.574681 | 0.7066 | 0.594618 | 0.71 | 0.65 | 0.68 |
4 | RCNN | 0.536011 | 0.734 | 0.559934 | 0.74 | 0.68 | 0.71 |
5 | FastText | 0.73637 | 0.5292 | 0.683402 | 0.65 | 0.43 | 0.52 |
6 | Transformer | 0.530028 | 0.7354 | 0.60349 | 0.71 | 0.69 | 0.7 |
[1] Joulin, Armand, Edouard Grave, and Piotr Bojanowski Tomas Mikolov. "Bag of Tricks for Efficient Text Classification." EACL 2017 (2017): 427.
[2] Kim, Yoon. "Convolutional Neural Networks for Sentence Classification." Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP). 2014.
[3] Lai, Siwei, et al. "Recurrent convolutional neural networks for text classification." In Proc. Conference of the Association for the Advancement of Artificial Intelligence (AAAI). 2015.
[4] Du, Changshun, and Lei Huang. "Text classification research with attention-based recurrent neural networks." International Journal of Computers Communications & Control 13.1 (2018): 50-61.
[5] Vaswani, Ashish, et al. "Attention is all you need." Proceedings of the 31st International Conference on Neural Information Processing Systems. Curran Associates Inc., 2017.