Short-Text Sentiment Classification Model Based on BERT and Dual-Stream Transformer Gated Attention Mechanism
Abstract
1. Introduction
2. Related Work
3. Methodology
3.1. The BERT-Driven Data Augmentation Module
3.2. The Feature Extraction and Integration Module
3.2.1. Principle of Character—Level Text Representation
3.2.2. Principle of Word—Level Text Representation
3.2.3. Integrating Character-Level and Word-Level Features
3.2.4. Feature Fusion with Gated Attention Mechanism
3.3. Sequence Information Processing Module
3.3.1. Principle and Role of BiGRU Layer
3.3.2. Principle and Role of Multi-Head Self-Attention Layer
3.4. Classification Prediction Output Module
3.5. Loss Function and Optimization Strategy Module
4. Experimental Results
4.1. Dataset Acquisition and Preprocessing
4.2. Data Labeling and Classification
4.3. Experimental Parameter Settings
4.4. Baseline Model Comparison Experimental Analysis
4.4.1. Experiments on Three-Classification Sentiment Analysis
4.4.2. Experiments on Binary Sentiment Analysis
4.5. Experimental Analysis and Discussion
4.5.1. Module Validation
4.5.2. Model Performance Visualization
4.5.3. Performance Analysis Under an Uneven Distribution of Categories
5. Conclusions
5.1. Research Summary
5.2. Limitations and Future Prospects
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- An, J.; Zainon, W.M.N.W. Integrating Color Cues to Improve Multimodal Sentiment Analysis in Social Media. Eng. Appl. Artif. Intell. 2023, 126, 106874. [Google Scholar] [CrossRef]
- Jiang, H.; Zhao, C.; Chen, H.; Wang, C. Construction method of domain sentiment lexicon based on improved TF-IDF and BERT. Comput. Sci. 2024, 51, 162–170. [Google Scholar] [CrossRef]
- Wang, H.; Wang, Y.; Marius, G.P. Research on text sentiment analysis based on sentiment dictionary and deep learning. Comput. Digit. Eng. 2024, 52, 451–455. [Google Scholar] [CrossRef]
- Li, Z.; Li, R.; Jin, G.H. Sentiment Analysis of Danmaku Videos Based on Naïve Bayes and Sentiment Dictionary. IEEE Access 2020, 8, 75073–75084. [Google Scholar] [CrossRef]
- Tarımer, İ.; Çoban, A.; Kocaman, A.E. Sentiment Analysis on IMDB Movie Comments and Twitter Data by Machine Learning and Vector Space Techniques. arXiv 2019, arXiv:1903.11983. [Google Scholar] [CrossRef]
- Dervenis, C.; Kanakis, G.; Fitsilis, P. Sentiment Analysis of Student Feedback: A Comparative Study Employing Lexicon and Machine Learning Techniques. Stud. Educ. Eval. 2024, 83, 101406. [Google Scholar] [CrossRef]
- Long, Y.; Li, Q. Sentiment analysis model of Chinese commentary text based on self-attention and TextCNN-BiLSTM. J. Shihezi Univ. Nat. Sci. 2025, 43, 111–121. [Google Scholar] [CrossRef]
- Huang, J.; Xu, X. A short text sentiment analysis model integrating output features of Bi-LSTM and CNN. Comput. Digit. Eng. 2024, 52, 3326–3330. [Google Scholar] [CrossRef]
- Sun, S.; Wei, G.; Wu, S. Sentiment analysis method integrating hypergraph enhance and dual contrastive learning. Comput. Eng. Appl. 2025, 1–12. [Google Scholar] [CrossRef]
- Zhang, B.; Zhou, W. Transformer-Encoder-GRU (T-E-GRU) for Chinese Sentiment Analysis on Chinese Comment Text. Neural Process Lett. 2023, 55, 1847–1867. [Google Scholar] [CrossRef]
- Hu, J.; Yu, Q. Sentiment analysis of Chinese text based on BERT-BGRU-Att model. J. Tianjin Univ. Technol. 2024, 40, 85–90. [Google Scholar] [CrossRef]
- Tembhurne, J.V.; Lakhotia, K.; Agrawal, A. Twitter Sentiment Analysis using Ensemble of Multi-Channel Model Based on Machine Learning and Deep Learning Techniques. Knowl. Inf. Syst. 2025, 67, 1045–1071. [Google Scholar] [CrossRef]
- Li, H.; Ma, Y.; Ma, Z.; Zhu, H. Weibo Text Sentiment Analysis Based on Bert and Deep Learning. Appl. Sci. 2021, 11, 10774. [Google Scholar] [CrossRef]
- Sun, J.; Wei, C. Research on gold futures price forecasting based on text sentiment analysis and LightGBM-LSTM model. J. Nanjing Univ. Inf. Sci. Technol. 2024, 1–16. [Google Scholar] [CrossRef]
- Xu, X.; Tian, K. A novel financial text sentiment analysis-based approach for stock index prediction. J. Quant. Technol. 2021, 38, 124–145. [Google Scholar] [CrossRef]
- Duan, W.; Xue, T. FinBERT-RCNN-ATTACK: Emotional analysis model of financial text. Comput. Tchnology Dev. 2024, 34, 157–162. [Google Scholar] [CrossRef]
- Huang, S.; Raga, R.C. A deep learning model for student sentiment analysis on course reviews. IEEE Access 2024, 12, 136747–136758. [Google Scholar] [CrossRef]
- Liang, Z.; Chen, J. An Al-BERT-Bi-GRU-LDA algorithm for negative sentiment analysis on Bilibili comments. PeerJ Comput. Sci. 2024, 10, e2029. [Google Scholar] [CrossRef]
- Liyih, A.; Anagaw, S.; Yibeyin, M. Sentiment analysis of the Hamas-Israel war on YouTube comments using deep learning. Sci. Rep. 2024, 14, 13647. [Google Scholar] [CrossRef] [PubMed]
- Guo, Y.; Yao, X. Research on user reviews of online health community based on topic mining and sentiment analysis. J. Mod. Inf. 2025, 45, 135–145. [Google Scholar]
- Wen, T.; Xu, G. Research on sentiment-topic recognition on Service quality of mixed anxiety and depression disorder. Inf. Res. 2024, 10–19. [Google Scholar] [CrossRef]
- Zhang, W.; Zhang, J.; Guo, Y. Sentiment analysis of online medical reviews based on BERT and semantics collaboration through dual-channel. J. Med. Inform. 2024, 45, 30–35. [Google Scholar] [CrossRef]
- Mishev, K.; Gjorgjevikj, A.; Vodenska, I.; Chitkushev, L.T.; Trajanov, D. Evaluation of Sentiment Analysis in Finance: From Lexicons to Transformers. IEEE Access 2020, 8, 131662–131682. [Google Scholar] [CrossRef]
- Yan, C.; Liu, J.; Liu, W.; Liu, X. Sentiment Analysis and Topic Mining Using a Novel Deep Attention-Based Parallel Dual-Channel Model for Online Course Reviews. Cogn. Comput. 2023, 15, 304–322. [Google Scholar] [CrossRef]
- Wang, X. Predicting Dropout and Sentiment Analysis of Course Evaluation in MOOCs Based on Deep Learning. Master’s Thesis, Henan University, Zhengzhou, China, 2024. [Google Scholar]
- Gao, H. Sentiment analysis model of online course review based on MacBERT. Electron. Des. Eng. 2023, 31, 39–43. [Google Scholar] [CrossRef]
- Rizinski, M.; Peshov, H.; Mishev, K.; Jovanovik, M.; Trajanov, D. Sentiment Analysis in Finance: From Transformers Back to eXplainable Lexicons (XLex). IEEE Access 2024, 12, 7170–7198. [Google Scholar] [CrossRef]
- Loshchilov, I.; Hutter, F. Decoupled Weight Decay Regularization. ICLR 2019. [Google Scholar] [CrossRef]
- Wang, T.; Yang, W. Review of Text Sentiment Analysis Methods. Comput. Eng. Appl. 2021, 57, 11–24. [Google Scholar] [CrossRef]
- Liang, Y.M.; Fan, J.; Chai, W.Z. Multi-scale feature fusion sentiment classification based on bidirectional cross attention. J. Comput. Appl. 2025, 45, 2773–2782. [Google Scholar]
- Xu, G.X.; Liu, L.Y.; Wang, J.C.; Chen, Z. Text sentiment analysis based on Bert and Hypergraph with dual attention network. Appl. Res. Comput. 2024, 41, 786–793. [Google Scholar]
- Tianchi. 2020. Available online: https://tianchi.aliyun.com/dataset/131940 (accessed on 7 June 2022).
- Ren, C.; Qiu, Q.; Lie, S. Text sentiment analysis fusing TCN and BiLSTM. Comput. Eng. Des. 2024, 45, 2090–2096. [Google Scholar] [CrossRef]
- Ai, S.; Chen, H.; Cui, X.; An, R. Aspect-based sentiment analysis model for short text with interactive dependent multi-head graph attention. J. Harbin Univ. Sci. Technol. 2024, 29, 10–17. [Google Scholar] [CrossRef]
- Ye, H. Research on Sentiment Analysis of Short Text User Comments Based on Deep Learning. Master’s Thesis, Nanchang University, Nanchang, China, 2024. [Google Scholar]
- Li, H.; Wang, Y.; Wang, X. Chinese short text sentiment classification: Research on Transformer-TextCNN model with location-aware enhancement. Comput. Eng. Appl. 2025, 61, 216–226. [Google Scholar] [CrossRef]
- Wu, J.; Jia, Y.; Wang, Z.; Zhang, J.; Yan, W.; Gao, A.; Che, S. Sentiment analysis of Weibo epidemic public opinion text based on deep learning. Comput. Technol. Dev. 2024, 34, 175–183. [Google Scholar] [CrossRef]
- Chen, T.; An, J. Sentiment classification of microblog short text based on feature fusion. Front. Data Comput. 2020, 2, 21–29. [Google Scholar]
- Liu, F.; Yu, W. Text sentiment analysis model based on BERT and Attention. Softw. Guide 2023, 22, 66–71. [Google Scholar] [CrossRef]
- Hsieh, Y.H.; Zeng, X. Sentiment Analysis: An ERNIE-BiLSTM Approach to Bullet Screen Comments. Sensors 2022, 22, 5223. [Google Scholar] [CrossRef] [PubMed]
- Wang, M.; You, H.; Ma, H.; Sun, X.; Wang, Z. Sentiment Analysis of Online New Energy Vehicle Reviews. Appl. Sci. 2023, 13, 8176. [Google Scholar] [CrossRef]
Data Sources | Number of Courses | Number of Reviews |
---|---|---|
MOOC | 27 | 37,886 |
Baidu PaddlePaddle AI Studio | 13 | 4892 |
iFLYTEK AI College | 17 | 15,794 |
Parameter | Value |
---|---|
Maximum sequence length | 256 |
Batch Size | 16 |
BiGRU Hidden Layer Dimension | 256 |
BiGRU Output Dimension | 512 |
Number of Multi-head Attention layers | 4 |
Gated Full Connectivity Layer Output Dimension | 1 |
Output Dimensions in Full connectivity layer | 3 |
Dropout rate | 0.3 |
Learning rate | 2 × 10−5 |
Model | Dataset | Precision | Recall | F1 Score | AUC |
---|---|---|---|---|---|
TCN-BiLSTM | sim_weibo | 0.9266 | 0.9249 | 0.9254 | 0.9714 |
online_10 | 0.8671 | 0.8737 | 0.8750 | 0.9565 | |
dmsc_v2 | 0.9054 | 0.9107 | 0.9082 | 0.9437 | |
cn-taobao | 0.8269 | 0.8341 | 0.8293 | 0.9046 | |
self-built | 0.9129 | 0.9006 | 0.9066 | 0.9513 | |
IDM-GAT | sim_weibo | 0.9068 | 0.8977 | 0.9007 | 0.9585 |
online_10 | 0.7391 | 0.6836 | 0.7009 | 0.8748 | |
dmsc_v2 | 0.8024 | 0.7936 | 0.8017 | 0.8762 | |
cn-taobao | 0.6954 | 0.7029 | 0.6991 | 0.8148 | |
self-built | 0.8976 | 0.8997 | 0.8961 | 0.9332 | |
RoCSAOL | sim_weibo | 0.7273 | 0.7412 | 0.6903 | 0.8260 |
online_10 | 0.6317 | 0.6198 | 0.6046 | 0.7984 | |
dmsc_v2 | 0.7098 | 0.7124 | 0.7103 | 0.8247 | |
cn-taobao | 0.5761 | 0.5809 | 0.5767 | 0.7032 | |
self-built | 0.7140 | 0.7135 | 0.6730 | 0.8297 | |
Transformer-TextCNN | sim_weibo | 0.9257 | 0.9271 | 0.9301 | 0.9724 |
online_10 | 0.8764 | 0.8852 | 0.8819 | 0.9438 | |
dmsc_v2 | 0.9093 | 0.9104 | 0.9081 | 0.9369 | |
cn-taobao | 0.8432 | 0.8327 | 0.8398 | 0.9154 | |
self-built | 0.9185 | 0.8975 | 0.9128 | 0.9653 | |
RoBERTa-BiGRU-Double Att | sim_weibo | 0.8876 | 0.8792 | 0.8803 | 0.9347 |
online_10 | 0.8029 | 0.8257 | 0.8091 | 0.9139 | |
dmsc_v2 | 0.8439 | 0.8491 | 0.8502 | 0.9026 | |
cn-taobao | 0.7892 | 0.7743 | 0.7675 | 0.8321 | |
self-built | 0.8264 | 0.8157 | 0.8259 | 0.9027 | |
Proposed Model | sim_weibo | 0.9370 | 0.9341 | 0.9345 | 0.9737 |
online_10 | 0.8963 | 0.8550 | 0.8568 | 0.9428 | |
dmsc_v2 | 0.9249 | 0.9091 | 0.9124 | 0.9427 | |
cn-taobao | 0.8517 | 0.8496 | 0.8503 | 0.9219 | |
self-built | 0.9317 | 0.9366 | 0.9240 | 0.9643 |
Model | Dataset | Precision | Recall | F1 Score | AUC |
---|---|---|---|---|---|
BERT-CNN-attention | wei-bo-100k | 0.7947 | 0.7986 | 0.8011 | 0.9028 |
waimai_10k | 0.7287 | 0.7194 | 0.7209 | 0.8324 | |
ChnSentiCorp_ | 0.6919 | 0.6787 | 0.6659 | 0.7422 | |
self-built | 0.8149 | 0.8207 | 0.8176 | 0.9124 | |
Bi-LSTM-CNN | wei-bo-100k | 0.6815 | 0.6761 | 0.6808 | 0.7871 |
waimai_10k | 0.6376 | 0.6319 | 0.6401 | 0.7195 | |
ChnSentiCorp_ | 0.6053 | 0.6133 | 0.6110 | 0.6904 | |
self-built | 0.6629 | 0.6497 | 0.6632 | 0.7127 | |
TextCNN-BiLSTM-Att | wei-bo-100k | 0.8231 | 0.8312 | 0.8328 | 0.9282 |
waimai_10k | 0.7854 | 0.7797 | 0.7842 | 0.8567 | |
ChnSentiCorp_ | 0.7344 | 0.7720 | 0.7660 | 0.8701 | |
self-built | 0.8007 | 0.7986 | 0.8018 | 0.9062 | |
BERT-attention-Fasttext | wei-bo-100k | 0.7243 | 0.7189 | 0.7207 | 0.8359 |
waimai_10k | 0.6679 | 0.6703 | 0.6718 | 0.7724 | |
ChnSentiCorp_ | 0.6482 | 0.6531 | 0.6489 | 0.7593 | |
self-built | 0.6971 | 0.7024 | 0.6958 | 0.8124 | |
ERNIE-BiLSTM | wei-bo-100k | 0.8641 | 0.8597 | 0.8624 | 0.9152 |
waimai_10k | 0.6943 | 0.7025 | 0.6932 | 0.7872 | |
ChnSentiCorp_ | 0.6339 | 0.6471 | 0.6409 | 0.7382 | |
self-built | 0.7027 | 0.6984 | 0.7019 | 0.7792 | |
ERNIE-CNN | wei-bo-100k | 0.7864 | 0.7791 | 0.7847 | 0.8356 |
waimai_10k | 0.7325 | 0.7401 | 0.7380 | 0.7139 | |
ChnSentiCorp_ | 0.7069 | 0.7127 | 0.7082 | 0.7947 | |
self-built | 0.7597 | 0.7647 | 0.7609 | 0.7239 | |
Proposed Model | wei-bo-100k | 0.9298 | 0.9295 | 0.9267 | 0.9742 |
waimai_10k | 0.8682 | 0.8707 | 0.8695 | 0.9271 | |
ChnSentiCorp_ | 0.7509 | 0.7685 | 0.7546 | 0.8612 | |
self-built | 0.9158 | 0.9104 | 0.9087 | 0.9698 |
Experiment | Precision | Recall | F1 Score | AUC |
---|---|---|---|---|
Proposed model | 0.9317 | 0.9366 | 0.9240 | 0.9643 |
Fine-tuned RoBERTa | 0.9039 | 0.9011 | 0.8964 | 0.9499 |
Freeze RoBERTa | 0.8287 | 0.7633 | 0.7906 | 0.9215 |
Remove data enhancements | 0.8995 | 0.8967 | 0.8950 | 0.9400 |
Remove BiGRU | 0.8902 | 0.8932 | 0.9010 | 0.9367 |
Remove MHSA | 0.9087 | 0.8905 | 0.9079 | 0.9477 |
Remove gated mechanism | 0.9057 | 0.9089 | 0.9067 | 0.9458 |
Remove gated attention mechanism | 0.8894 | 0.8911 | 0.8853 | 0.9498 |
Remove Transformer | 0.8301 | 0.8292 | 0.8389 | 0.9246 |
Remove character feature extraction | 0.7918 | 0.7932 | 0.7885 | 0.8941 |
Experiment | Precision | Recall | F1 Score | AUC |
---|---|---|---|---|
Proposed Model | 0.932 ± 0.006 | 0.937 ± 0.005 | 0.924 ± 0.007 | 0.964 ± 0.004 |
Fine-tuned RoBERTa | 0.904 ± 0.007 | 0.901 ± 0.008 | 0.896 ± 0.009 | 0.950 ± 0.005 |
Freeze RoBERTa | 0.829 ± 0.012 | 0.763 ± 0.014 | 0.791 ± 0.013 | 0.922 ± 0.006 |
Remove data enhancements | 0.900 ± 0.008 | 0.897 ± 0.009 | 0.895 ± 0.010 | 0.940 ± 0.006 |
Remove BiGRU | 0.890 ± 0.010 | 0.893 ± 0.011 | 0.901 ± 0.009 | 0.937 ± 0.005 |
Remove MHSA | 0.909 ± 0.009 | 0.891 ± 0.010 | 0.908 ± 0.008 | 0.948 ± 0.004 |
Remove Gated mechanism | 0.906 ± 0.008 | 0.909 ± 0.009 | 0.907 ± 0.009 | 0.946 ± 0.005 |
Remove Gated Attention mechanism | 0.889 ± 0.011 | 0.891 ± 0.010 | 0.885 ± 0.009 | 0.950 ± 0.005 |
Remove Transformer | 0.830 ± 0.012 | 0.829 ± 0.013 | 0.839 ± 0.011 | 0.925 ± 0.007 |
Remove Character Feature Extraction | 0.792 ± 0.015 | 0.793 ± 0.014 | 0.789 ± 0.013 | 0.894 ± 0.010 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Yang, S.; Xing, J.; Liu, Z.; Sun, Y. Short-Text Sentiment Classification Model Based on BERT and Dual-Stream Transformer Gated Attention Mechanism. Electronics 2025, 14, 3904. https://doi.org/10.3390/electronics14193904
Yang S, Xing J, Liu Z, Sun Y. Short-Text Sentiment Classification Model Based on BERT and Dual-Stream Transformer Gated Attention Mechanism. Electronics. 2025; 14(19):3904. https://doi.org/10.3390/electronics14193904
Chicago/Turabian StyleYang, Song, Jiayao Xing, Zhaoxia Liu, and Yunhao Sun. 2025. "Short-Text Sentiment Classification Model Based on BERT and Dual-Stream Transformer Gated Attention Mechanism" Electronics 14, no. 19: 3904. https://doi.org/10.3390/electronics14193904
APA StyleYang, S., Xing, J., Liu, Z., & Sun, Y. (2025). Short-Text Sentiment Classification Model Based on BERT and Dual-Stream Transformer Gated Attention Mechanism. Electronics, 14(19), 3904. https://doi.org/10.3390/electronics14193904