Twitter Sentiment Analysis (DistilBERT, fine-tuned on Sentiment140)

Binary sentiment classifier (negative / positive) for short English social-media text. Fine-tuned from distilbert-base-uncased on the Sentiment140 dataset (1.6 million labelled tweets).

Built by Alexander Gehbrezgi as part of his Master's thesis at Goethe University Frankfurt, Chair of Information Systems and Information Management (2023): "Impact of Russia's 2022 Invasion of Ukraine on Global Financial Markets: A Machine Learning-Based Sentiment Analysis of News and Social Media" (grade 1.3).

Use in the thesis

The model scored the sentiment of 210,000+ Facebook posts and 149,000+ articles from 20 news outlets in Africa, Asia, Europe and the US (January–July 2023). Together with RoBERTa-based emotion and topic classifiers, the scores were used to explain daily market movements across sector and regional indices with logistic regression.

Training

Setting Value
Base model distilbert-base-uncased
Data Sentiment140 (1.6M tweets, labels 0 = negative, 4 = positive)
Validation Hold-out, shuffled, ~60:40 train/test split
Learning rate 2e-5 (linear decay)
Batch size 16 (train and eval)
Epochs 3
Weight decay 0.01
Hardware NVIDIA A100 GPU (Google Colab)

Evaluation (test split)

Loss Accuracy F1 Precision Recall
0.3724 0.8660 0.8652 0.8712 0.8593

How to use

from transformers import pipeline

classifier = pipeline("text-classification", model="alexgeh196/twitter-sentiment-analysis")
classifier("Ukrainian forces report very good results on the front line.")

Limitations

  • Binary only (negative / positive); no neutral class.
  • Trained on tweets from 2009; language and topics differ from today's news and from long-form text.
  • Long articles must be split into sentences and the scores averaged, as done in the thesis.
  • English only. Labels from Sentiment140 were created by distant supervision (emoticons) and contain noise.
Downloads last month
3
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for alexgeh196/twitter-sentiment-analysis

Finetuned
(12,924)
this model

Dataset used to train alexgeh196/twitter-sentiment-analysis

Evaluation results