Transformer-Based Deep Learning Framework for Multiclass Social Media Sentiment Analysis: A Comparative Study of BERT, RoBERTa, DistilBERT, and XLNet Architectures

Authors

  • Dr. Thalakola Assistant Professor, Dept. of CSE-DS, KKR & KSR Institute of Technology and Sciences, Guntur, Andra Pradesh, India Author
  • Syamsundara Rao Assistant Professor, Dept. of CSE-DS, KKR & KSR Institute of Technology and Sciences, Guntur, Andra Pradesh, India Author

Keywords:

Machine Learning Evolution, Classical Learning Algorithms, Deep Learning, Intelligent Systems, Artificial Intelligence

Abstract

Sentiment analysis on social media presents unique challenges due to the informal, noisy, and context-dependent nature of user-generated text. This paper proposes a transformer-based deep learning framework designed specifically for multiclass sentiment classification, capable of distinguishing between positive, negative, and neutral emotions in short social media posts. The methodology begins with a dedicated text cleaning module that removes URLs, hashtags, mentions, and special characters while normalizing emoji representations, thereby reducing noise before tokenization. The cleaned text is then processed through a transformer encoder layer that employs multi-head self-attention mechanisms to generate rich contextual embeddings. These embeddings capture global dependencies across the entire sequence, and we extract the special classification token as a compact representation for the whole post. This vector is subsequently passed through a fully connected layer and a softmax classification head to produce probability distributions over the three sentiment classes. We train the model by minimizing categorical cross-entropy loss using the AdamW optimizer. Our primary contribution is a comparative evaluation of four prominent transformer architectures—BERT, RoBERTa, DistilBERT, and XLNet—within this unified pipeline. We assess their performance across multiple social media datasets, examining trade-offs between accuracy, computational efficiency, and robustness to domain-specific linguistic variations. Furthermore, we demonstrate that RoBERTa consistently achieves the highest classification accuracy, while DistilBERT offers a compelling balance between speed and predictive power, making it suitable for real-time applications. The proposed framework yields F1-scores exceeding ninety percent on benchmark datasets, outperforming conventional recurrent and convolutional baselines. These results underscore the effectiveness of transformer-based representations for decoding sentiment in informal online discourse and provide practitioners with actionable guidance for architecture selection in real-world social media analytics systems.

Downloads

Download data is not yet available.

Downloads

Published

2026-06-27

Issue

Section

Articles

How to Cite

Transformer-Based Deep Learning Framework for Multiclass Social Media Sentiment Analysis: A Comparative Study of BERT, RoBERTa, DistilBERT, and XLNet Architectures. (2026). Journal of Machine Learning Innovations and Artificial Intelligence Horizons, 1(1), 110-133. https://jmliaih.notationpublishing.com/1/article/view/9