| Literature DB >> 35721405 |
Xuchu Jiang1, Chao Song1, Yucheng Xu1, Ying Li1, Yili Peng2.
Abstract
Sentiment analysis of netizens' comments can accurately grasp the psychology of netizens and reduce the risks brought by online public opinion. However, there is currently no effective method to solve the problems of short text, open word range, and sometimes reversed word order in comments. To better solve the above problems, this article proposes a hybrid model of sentiment classification, which is based on bidirectional encoder representations from transformers (BERT), bidirectional long short-term memory (BiLSTM) and a text convolution neural network (TextCNN) (BERT-BiLSTM-TextCNN). The experimental results show that (1) the hybrid model proposed in this article can better combine the advantages of BiLSTM and TextCNN; it not only captures local correlation while retaining context information but also has high accuracy and stability. (2) The BERT-BiLSTM-TextCNN model can extract important emotional information more flexibly in text and achieve multiclass classification tasks of emotions more accurately. The innovations of this study are as follows: (1) the use of BERT to generate word vectors has the advantages of more prior information and a full combination of contextual semantics; (2) the BiLSTM model, as a bidirectional context mechanism model, can obtain contextual information well; and (3) the TextCNN model can obtain important features well in the problem of text classification, and the combined effect of the three modules can significantly improve the accuracy of emotional multilabel classification.Entities:
Keywords: BERT; BiLSTM; Sentiment classification; TextCNN
Year: 2022 PMID: 35721405 PMCID: PMC9202631 DOI: 10.7717/peerj-cs.1005
Source DB: PubMed Journal: PeerJ Comput Sci ISSN: 2376-5992
Figure 1Research framework.
Figure 2BERT-BiLSTM-TextCNN model.
Hyperparameter tuning.
| BiLSTM layer | TextCNN layer | ||
|---|---|---|---|
| Parameters | Values | Parameters | Values |
| Hidden node problem | 300 | Convolution kernels number | 300 |
| Learning rate | 0.001 | Convolution kernels size | 3, 4, 5 |
| Epochs | 15 | Activation function | ReLU |
| Batch_size | 300 | Pooling strategy | 1-max pooling |
| Optimization function | Adam | Dropout | 0.5 |
| Loss function | Cross entropy | L2 regularization | Three |
| Input word vector | BERT | ||
Figure 3Comparison (A) before and (B) after tuning.
Model evaluation.
| Model | Category | Precision | Recall | F1 | Micro-F1 | Macro-F1 |
|---|---|---|---|---|---|---|
| BERT-BiLSTM-TextCNN | 0 | 0.9235 | 0.9085 | 0.9159 | 0.9052 | 0.9143 |
| 1 | 0.9146 | 0.9047 | 0.9096 | |||
| 2 | 0.9184 | 0.9130 | 0.9157 | |||
| 3 | 0.9296 | 0.9022 | 0.9157 | |||
| BERT-BiGRU-TextCNN | 0 | 0.9105 | 0.9029 | 0.9067 | 0.8793 | 0.8885 |
| 1 | 0.9062 | 0.8953 | 0.9007 | |||
| 2 | 0.8883 | 0.8784 | 0.8833 | |||
| 3 | 0.8542 | 0.8721 | 0.8631 | |||
| BERT-LSTM-TextCNN | 0 | 0.8724 | 0.8951 | 0.8836 | 0.8629 | 0.8785 |
| 1 | 0.8843 | 0.8765 | 0.8804 | |||
| 2 | 0.9023 | 0.8701 | 0.8859 | |||
| 3 | 0.8528 | 0.8742 | 0.8634 | |||
| BERT-TextCNN | 0 | 0.8749 | 0.8412 | 0.8577 | 0.8598 | 0.8757 |
| 1 | 0.8852 | 0.8685 | 0.8768 | |||
| 2 | 0.8537 | 0.8821 | 0.8677 | |||
| 3 | 0.9043 | 0.8957 | 0.9000 | |||
| Word2Vec-BiLSTM-TextCNN | 0 | 0.7103 | 0.7348 | 0.7223 | 0.6300 | 0.6723 |
| 1 | 0.6892 | 0.6438 | 0.6657 | |||
| 2 | 0.6719 | 0.7087 | 0.6898 | |||
| 3 | 0.6155 | 0.6043 | 0.6098 | |||
| Word2Vec-BiGRU-TextCNN | 0 | 0.6361 | 0.6207 | 0.6283 | 0.6075 | 0.6265 |
| 1 | 0.6345 | 0.6531 | 0.6437 | |||
| 2 | 0.6394 | 0.6112 | 0.6250 | |||
| 3 | 0.6145 | 0.6026 | 0.6085 | |||
| Word2Vec-LSTM-TextCNN | 0 | 0.6581 | 0.6323 | 0.6449 | 0.6189 | 0.6231 |
| 1 | 0.6361 | 0.6129 | 0.6243 | |||
| 2 | 0.6138 | 0.6199 | 0.6168 | |||
| 3 | 0.6037 | 0.6084 | 0.6060 | |||
| Word2Vec-TextCNN | 0 | 0.6326 | 0.6109 | 0.6216 | 0.6010 | 0.6145 |
| 1 | 0.6370 | 0.6211 | 0.6289 | |||
| 2 | 0.6024 | 0.6029 | 0.6026 | |||
| 3 | 0.6018 | 0.6075 | 0.6046 |
Figure 4Comparison of F1 values of each category (based on BERT).
Figure 5Comparison of F1 values of each category (based on Word2Vec).
Figure 6Overall evaluation of the model (based on BERT).
Figure 7Overall evaluation of the model (based on Word2Vec).
Results analysis.
| Comments | Label | Pre1 | Pre2 |
|---|---|---|---|
| You look very patriotic, very dedicated and very backbone, you never speak ill of others in the back and never frame others, forgive me for my just saying against my heart. | 2 | 2 | 0 |
| How could they call you a pig? This is outrageous! We can’t just call people what they look like! | 2 | 2 | 1 |
| He was so good at it that he broke another plate while doing the dishes. What a talented man! | 1 | 1 | 1 |
| You think you’re the sun, and everyone else must be around you. You know, there is only one earth in the universe, and it is probably burned by the arrogance of you. | 1 | 2 | 2 |
| If you ever learn to be sincere, I think the people around you will no longer vomit after you turn around. | 2 | 2 | 2 |
Evaluation results based on comment corpora.
| Model | Micro F1 | Macro F1 |
|---|---|---|
| BERT-BiLSTM-TextCNN | 0.9457 | 0.9503 |
| BERT-BiGRU-TextCNN | 0.9182 | 0.9071 |
| BERT-LSTM-TextCNN | 0.8836 | 0.8865 |
| BERT-TextCNN | 0.8471 | 0.8524 |
| Word2Vec-BiLSTM-TextCNN | 0.6836 | 0.6709 |
| Word2Vec-BiGRU-TextCNN | 0.6593 | 0.6684 |
| Word2Vec-LSTM-TextCNN | 0.6519 | 0.6476 |
| Word2Vec-TextCNN | 0.6411 | 0.6539 |
Figure 8Model evaluation on the comment corpora (based on BERT).
Figure 9Model evaluation on the comment corpora (based on Word2Vec).