Skip to content

sidmachines/distilbert-financial-sentiment

Repository files navigation

DistilBERT Financial Sentiment Classifier

Fine-tuning distilbert-base-uncased for 3-class sentiment classification (Bearish / Bullish / Neutral) on real-world finance tweets.

Overview

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

Contents

  • 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 Face TrainingArguments from the training run.

Running the notebook

Designed to run in Google Colab:

  1. Open the notebook in Colab.
  2. Go to Runtime → Change runtime type → T4 GPU.
  3. Run the dependency install cell, then Runtime → Restart session (avoids a torchvision/datasets version conflict).
  4. Run all remaining cells in order, top to bottom.

Steps in the notebook

  1. Install dependencies
  2. GPU check
  3. Load and explore the dataset
  4. Tokenization
  5. Load the model
  6. Training
  7. Evaluation
  8. Inference on new sentences
  9. (Optional) Save the fine-tuned model weights

Model

Base model: distilbert-base-uncased, fine-tuned with a single-label sequence classification head for 3 classes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages