YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
Transformer-Based Social Media Sentiment Analysis
IEEE Conference Paper: Comprehensive Evaluation on Real Tweet Data
This repository contains the complete research paper, code, evaluation results, and figures for a social media sentiment analysis study comparing 4 transformer models on real social media data.
π Key Finding: SST-2 Accuracy Does NOT Predict Tweet Performance
| Model | Params | SST-2 Accuracy | TweetEval 3-class Macro-F1 |
|---|---|---|---|
| DistilBERT-SST2 | 66M | 91.06% | 36.53% |
| BERT-base-SST2 | 110M | 92.43% | 38.53% |
| Twitter-RoBERTa | 125M | 86.12% | 72.40% β |
| DeBERTa-v3-base | 184M | 96.44% β | 40.64% |
DeBERTa-v3 achieves 96.44% on movie reviews but only 40.64% on real tweets. Twitter-RoBERTa, pre-trained on 124M tweets, achieves 72.40% β nearly 2x better on social media.
π Paper
π₯ Download IEEE PDF Paper (v2 with figures)
The paper includes:
- 5 figures: confusion matrices, model comparison charts, dataset distributions, per-class F1 analysis
- Evaluation on 12,284 real tweets from TweetEval benchmark
- Honest analysis of the domain gap between formal text and social media
- Comparison of 4 transformer architectures
Also available: LaTeX Source (IEEEtran class)
π Repository Contents
βββ paper/
β βββ Social_Media_Sentiment_Analysis_IEEE_v2.pdf # β
Updated IEEE PDF (6 pages, 5 figures)
β βββ Social_Media_Sentiment_Analysis_IEEE.pdf # Original version
β βββ ieee_sentiment_paper.tex # LaTeX source
βββ figures/
β βββ fig1_confusion_roberta.{png,pdf} # Confusion matrix: Twitter-RoBERTa
β βββ fig2_confusion_deberta.{png,pdf} # Confusion matrix: DeBERTa-v3
β βββ fig3_model_comparison.{png,pdf} # Bar chart: SST-2 vs TweetEval
β βββ fig4_data_distribution.{png,pdf} # Dataset class distributions
β βββ fig5_per_class_f1.{png,pdf} # Per-class F1 comparison
βββ code/
β βββ comprehensive_eval.py # Full evaluation + figure generation
β βββ train_sentiment.py # Training pipeline
β βββ evaluate_models.py # Multi-model evaluation
β βββ eval_deberta.py # DeBERTa-specific evaluation
β βββ generate_pdf_v2.py # PDF generation with figures
βββ results/
β βββ comprehensive_results.json # TweetEval + SST-2 results
β βββ eval_results.json # Initial SST-2 results
βββ README.md
π Datasets Used
| Dataset | Domain | Samples | Classes | Source |
|---|---|---|---|---|
| TweetEval Sentiment | Real tweets | 12,284 test | 3 (neg/neutral/pos) | cardiffnlp/tweet_eval |
| SST-2 | Movie reviews | 872 val | 2 (neg/pos) | stanfordnlp/sst2 |
Both are real data β TweetEval contains actual tweets from Twitter/X, SST-2 contains actual movie review sentences from Rotten Tomatoes.
π¬ What's Needed for IEEE Acceptance
The paper currently addresses most IEEE requirements. For a full conference submission, additionally needed:
- β Figures β 5 figures included (confusion matrices, bar charts, distributions, per-class F1)
- β Real data evaluation β TweetEval benchmark (12,284 real tweets)
- β Multiple baselines β 4 models compared
- β¬ Multi-seed runs β Run 3+ seeds and report mean Β± std
- β¬ Ablation study β Learning rate sweep, layer freezing, sequence length effects
- β¬ Statistical significance β McNemar test between model pairs
- β¬ Two-column layout β LaTeX source uses IEEEtran (compile with pdflatex for proper format)
- β¬ Fine-tune DeBERTa on TweetEval β Would likely close the domain gap significantly
π Quick Start
# Best for social media sentiment:
from transformers import pipeline
classifier = pipeline("sentiment-analysis",
model="cardiffnlp/twitter-roberta-base-sentiment-latest")
result = classifier("Love this new feature! #excited")
print(result) # [{'label': 'positive', 'score': 0.97}]
# Best for formal text sentiment:
classifier_formal = pipeline("text-classification",
model="cliang1453/deberta-v3-base-sst2")
result = classifier_formal("This movie was absolutely brilliant")
print(result) # [{'label': 'positive', 'score': 0.99}]
π Citation
@inproceedings{vivan2026sentiment,
title={Transformer-Based Social Media Sentiment Analysis: A Comprehensive Evaluation on Real Tweet Data},
author={Vivan, Raj},
year={2026},
note={Available at: https://huggingface.co/rajvivan/social-media-sentiment-analysis-paper}
}
License
MIT License