# Enhancing Imbalanced Sentiment Analysis: A GPT-3-Based Sentence-by-Sentence Generation Approach
###### Abstract  
This study addresses the challenge of class imbalance in sentiment analysis by utilizing synthetic data to balance training datasets. We introduce an innovative approach using the GPT-3 model's sentence-by-sentence generation technique to generate synthetic data, specifically targeting underrepresented negative and neutral sentiments. Our method aims to align these minority classes with the predominantly positive sentiment class in a Coursera course review dataset, with the goal of enhancing the performance of sentiment classification. This research demonstrates that our proposed method successfully enhances sentiment classification performance, as evidenced by improved accuracy and F1-score metrics across five deep-learning models. However, when compared to our previous research utilizing fine-tuning techniques, the current method shows a relative shortfall. The fine-tuning approach yields better results in all models tested, indicating the importance of data novelty and diversity in synthetic data generation. In terms of the deep-learning model used for classification, the notable finding is the significant performance improvement of the Recurrent Neural Network (RNN) model compared to other models like CNN, LSTM, BiLSTM, and GRU, highlighting the impact of the model choice and architecture depth. This study emphasizes the critical role of synthetic data quality and strategic deep-learning model implementation in sentiment analysis. The results suggest that the careful consideration of training data and model attributes is vital for optimal sentiment classification. GPT-3; imbalanced sentiment analysis; sentiment analysis; synthetic data generation; text classification; text generation; large language model (LLM) +
Footnote †: journal: _Applied_  
_aciences_  
Sentiment analysis is one of the applications of text classification. A crucial issue that consistently attracts attention in text classification is data imbalance. This is a situation where some classes have more samples, while others have relatively few or very few samples [4]. For instance, in sentiment analysis, it is common to find that the positive sentiment class has more samples, while the negative or neutral sentiments are significantly under-represented. Situations where some classes in the data are underrepresented compared to others lead to the incapability of standard classifiers to properly discriminate the poorly represented classes [5]. This means that the model will be very good at recognizing the majority class but poor at recognizing the minority class. This is one of the indications of the poor classification performance produced by a model. This study focuses on addressing the class imbalance in sentiment analysis by balancing the dataset with synthetic data. The primary goal is to enhance the classification performance after balancing the training data. The approach we propose for balancing involves generating synthetic data using the Generative Pre-trained Transformer 3 (GPT-3) model with a sentence-by-sentence generation technique. Generally, there are two methods to generate synthetic text data using the GPT-3 model: fine-tuning and prompt-based generation. The sentence-by-sentence text generation we propose in this study is a technique within prompt-based text generation. It involves instructing the GPT-3 model through a prompt that includes input text from the original dataset as an example. On the other hand, the fine-tuning technique is carried out by training the model using a training dataset through a fine-tuning process and then asking the fine-tuned model to generate new text using a prompt. The choice of the GPT-3 model for our study is grounded in its recognition as a state-of-the-art large language model, trained on extensive data to generate human-like text [6]. GPT-3's capabilities extend beyond basic text generation; it is known for producing content that rivals human quality in many instances [7].