ABSA-PyTorch
Aspect Based Sentiment Analysis, PyTorch Implementations.
基于方面的情感分析,使用PyTorch实现。
Requirement
- pytorch >= 0.4.0
- numpy >= 1.13.3
- sklearn
- python 3.6 / 3.7
- transformers
To install requirements, run pip install -r requirements.txt
.
- For non-BERT-based models, GloVe pre-trained word vectors are required, please refer to data_utils.py for more detail.
Usage
Training
python train.py --model_name bert_spc --dataset restaurant
- All implemented models are listed in models directory.
- See train.py for more training arguments.
- Refer to train_k_fold_cross_val.py for k-fold cross validation support.
Inference
- Refer to infer_example.py for non-BERT-based models.
- Refer to infer_example_bert_models.py for BERT-based models.
Tips
- For non-BERT-based models, training procedure is not very stable.
- BERT-based models are more sensitive to hyperparameters (especially learning rate) on small data sets, see this issue.
- Fine-tuning on the specific task is necessary for releasing the true power of BERT.
Reviews / Surveys
Qiu, Xipeng, et al. "Pre-trained Models for Natural Language Processing: A Survey." arXiv preprint arXiv:2003.08271 (2020). [pdf]
Zhang, Lei, Shuai Wang, and Bing Liu. "Deep Learning for Sentiment Analysis: A Survey." arXiv preprint arXiv:1801.07883 (2018). [pdf]
Young, Tom, et al. "Recent trends in deep learning based natural language processing." arXiv preprint arXiv:1708.02709 (2017). [pdf]
BERT-based models
official)
BERT-ADA (Rietzler, Alexander, et al. "Adapt or get left behind: Domain adaptation through bert language model finetuning for aspect-target sentiment classification." arXiv preprint arXiv:1908.11860 (2019). [pdf]
official)
BERR-PT (Xu, Hu, et al. "Bert post-training for review reading comprehension and aspect-based sentiment analysis." arXiv preprint arXiv:1904.02232 (2019). [pdf]
official)
ABSA-BERT-pair (Sun, Chi, Luyao Huang, and Xipeng Qiu. "Utilizing bert for aspect-based sentiment analysis via constructing auxiliary sentence." arXiv preprint arXiv:1903.09588 (2019). [pdf]
lcf_bert.py) (official)
LCF-BERT (Zeng Biqing, Yang Heng, et al. "LCF: A Local Context Focus Mechanism for Aspect-Based Sentiment Classification." Applied Sciences. 2019, 9, 3389. [pdf]
aen.py)
AEN-BERT (Song, Youwei, et al. "Attentional Encoder Network for Targeted Sentiment Classification." arXiv preprint arXiv:1902.09314 (2019). [pdf]
bert_spc.py)
BERT for Sentence Pair Classification (Devlin, Jacob, et al. "Bert: Pre-training of deep bidirectional transformers for language understanding." arXiv preprint arXiv:1810.04805 (2018). [pdf]
Non-BERT-based models
mgan.py)
MGAN (Fan, Feifan, et al. "Multi-grained Attention Network for Aspect-Level Sentiment Classification." Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing. 2018. [pdf]
aoa.py)
AOA (Huang, Binxuan, et al. "Aspect Level Sentiment Classification with Attention-over-Attention Neural Networks." arXiv preprint arXiv:1804.06536 (2018). [pdf]
tnet_lf.py) (official)
TNet (Li, Xin, et al. "Transformation Networks for Target-Oriented Sentiment Classification." arXiv preprint arXiv:1805.01086 (2018). [pdf]
cabasc.py)
Cabasc (Liu, Qiao, et al. "Content Attention Model for Aspect Based Sentiment Analysis." Proceedings of the 2018 World Wide Web Conference on World Wide Web. International World Wide Web Conferences Steering Committee, 2018.
ram.py)
RAM (Chen, Peng, et al. "Recurrent Attention Network on Memory for Aspect Sentiment Analysis." Proceedings of the 2017 Conference on Empirical Methods in Natural Language Processing. 2017. [pdf]
memnet.py) (official)
MemNet (Tang, Duyu, B. Qin, and T. Liu. "Aspect Level Sentiment Classification with Deep Memory Network." Conference on Empirical Methods in Natural Language Processing 2016:214-224. [pdf]
ian.py)
IAN (Ma, Dehong, et al. "Interactive Attention Networks for Aspect-Level Sentiment Classification." arXiv preprint arXiv:1709.00893 (2017). [pdf]
atae_lstm.py)
ATAE-LSTM (Wang, Yequan, Minlie Huang, and Li Zhao. "Attention-based lstm for aspect-level sentiment classification." Proceedings of the 2016 conference on empirical methods in natural language processing. 2016.
td_lstm.py, tc_lstm.py) (official)
TD-LSTM (Tang, Duyu, et al. "Effective LSTMs for Target-Dependent Sentiment Classification." Proceedings of COLING 2016, the 26th International Conference on Computational Linguistics: Technical Papers. 2016. [pdf]
lstm.py)
LSTM (Hochreiter, Sepp, and Jürgen Schmidhuber. "Long short-term memory." Neural computation 9.8 (1997): 1735-1780. [pdf]
Contributors
Thanks goes to these wonderful people:
Alberto Paz 💻 |
jiangtao 💻 |
WhereIsMyHead 💻 |
songyouwei 💻 |
YangHeng 💻 |
rmarcacini 💻 |
Yikai Zhang 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!
Licence
MIT