Fine-tuning distilbert-base-uncased for 3-class sentiment classification (Bearish / Bullish / Neutral) on real-world finance tweets.
This project fine-tunes DistilBERT into a sequence classification head over three sentiment labels. The dataset has significant class imbalance (~65% Neutral), so the notebook tracks weighted F1 and macro F1 alongside accuracy — a model that always predicts "Neutral" would score ~65% accuracy while being useless.
| Label | id |
|---|---|
| Bearish | 0 |
| Bullish | 1 |
| Neutral | 2 |
distilbert_financial_sentiment.ipynb— end-to-end notebook: data loading, tokenization, fine-tuning, evaluation, and inference.config.json— fine-tuned model config (DistilBERT, 6 layers, 12 heads, 3-class classification head).tokenizer_config.json— tokenizer configuration.training_args.bin— saved Hugging FaceTrainingArgumentsfrom the training run.
Designed to run in Google Colab:
- Open the notebook in Colab.
- Go to
Runtime → Change runtime type → T4 GPU. - Run the dependency install cell, then
Runtime → Restart session(avoids atorchvision/datasetsversion conflict). - Run all remaining cells in order, top to bottom.
- Install dependencies
- GPU check
- Load and explore the dataset
- Tokenization
- Load the model
- Training
- Evaluation
- Inference on new sentences
- (Optional) Save the fine-tuned model weights
Base model: distilbert-base-uncased, fine-tuned with a single-label sequence classification head for 3 classes.