Abstract
Sentiment classification tasks are a large branch of current natural language processing problems. The purpose of this task lies in determining the sentiment that the text is trying to convey given a piece of text or sentence. This technique can be widely referenced in areas such as monitoring market opinion, protecting social security, and developing AI customer service. Currently, the most advanced solutions to the sentiment classification problem are based on Bidirectional Encoder Representations from Transformers (BERT). In order to research a better solution, this study starts from the bottom, first finding the optimal Recurrent Neural Network (RNN) model to pave the way for future improvements. The research method starts from one layer and adjusts parameters or RNN types until the best model is found. Through an experimental study, it was found that the two-layer bidirectional Long Short-Term Memory (LSTM) performed best on the sentiment classification problem with an accuracy of 93.21%. It proves that LSTM is better than Gated Recurrent Unit (GRU) and simple RNN in understanding long text. In the future, more datasets can be collected from other platforms to help the model generalize to other domains.
Introduction
Sentiment classification—the task of determining the emotional tone behind a piece of text—is a cornerstone of modern Natural Language Processing (NLP). While Transformer-based models like BERT currently define the state-of-the-art, they are computationally expensive and complex. This research argues that to truly optimize sentiment analysis, we must first understand the optimal structure of the underlying Recurrent Neural Networks. The challenge lies in the inherent limitations of basic RNNs, such as the "vanishing gradient" problem, which prevents them from understanding the context of long sentences or paragraphs.
Methodology
The researchers employed an iterative, "bottom-up" experimental approach, starting with simple models and progressively increasing complexity based on performance.
Preprocessing and Architecture
The pipeline included standard NLP cleaning (removing URLs, punctuation, and stop words), lemmatization, and one-hot encoding for six target emotions. The study tested five primary architectures: Simple RNN (baseline), LSTM (using gates to handle long-term dependencies), GRU (a streamlined version of LSTM), and Bidirectional variants (Bi-LSTM/Bi-GRU) to capture full context from both directions.
Datasets
The study utilized an open-source Twitter Sentiment Dataset. Because the original dataset had an uneven distribution of emotions, the researchers used downsampling to ensure a balanced training environment across the six distinct emotion categories. A standard 80/20 split was used for training and testing.
Key Results
The quantitative results clearly favor the more complex, bidirectional architectures. Simple RNNs performed poorly, suffering from severe overfitting and an inability to capture long-range dependencies.
As shown in the performance table, the Two-layer Bi-LSTM emerged as the top performer, achieving a 93.21% accuracy rate. Interestingly, at the single-layer level, the GRU (78.67%) outperformed the LSTM (71.10%), likely due to its simpler structure being more efficient on the specific dataset size used.
Optimization and Hyperparameter Sensitivity
The study also investigated the impact of different optimizers and regularization techniques. While L2 regularization and learning rate decay are standard tools for preventing overfitting, they were found to decrease performance in this specific setup, suggesting that model architecture was a more critical factor than these tuning techniques.
As illustrated in the optimization results, the Adam optimizer significantly outperformed SGD for this task, with the Two-layer Bi-GRU reaching 88.33% accuracy with Adam compared to only 35.49% with SGD.
Conclusion
The study concludes that a two-layer Bidirectional LSTM is the most robust architecture for sentiment classification among the RNN variants tested. While this research provides a foundational understanding of RNN structures, future work will focus on applying these insights to improve Transformer-based models like BERT and RoBERTa, as well as expanding the dataset diversity beyond Twitter to include longer-form content like news articles.
Summary updated