ProsusAI/finBERT

Financial Sentiment Analysis with BERT

FinBERT – Financial Sentiment Analysis with BERT

What it is – FinBERT is a pre‑trained natural‑language‑processing model that classifies the sentiment (positive, neutral, negative) of financial text such as news headlines, earnings calls, or analyst reports. It starts from the general‑purpose BERT model and is further trained on a finance‑specific corpus and the Financial PhraseBank dataset.

Why it matters – Generic sentiment models often misinterpret finance‑jargon (e.g., “bearish”, “bullish”). FinBERT captures those nuances, making it useful for:

  • Quantitative trading signals
  • Risk monitoring
  • Market research dashboards

Main components

  • Model weights – Hosted on Hugging Face under the repo ProsusAI/finbert. The code loads them with AutoModelForSequenceClassification.from_pretrained('ProsusAI/finbert').
  • Training code – A Jupyter notebook (finbert_training.ipynb) that fine‑tunes bert-base-uncased (or another checkpoint) on the Financial PhraseBank. It includes options for discriminate and gradual_unfreeze to mitigate catastrophic forgetting.
  • Data preparation – scripts/datasets.py converts the Sentences_50Agree.txt file from the Financial PhraseBank into train.csv, validation.csv, and test.csv under data/sentiment_data/.
  • Prediction script – scripts/predict.py reads a plain‑text file, runs the model, and writes a CSV with per‑sentence softmax probabilities, the predicted label, and a sentiment score (prob(pos) − prob(neg)).

Getting started

# 1. Create the Conda environment defined in environment.yml
conda env create -f environment.yml
conda activate finbert

# 2. (Optional) Download the pre‑trained weights from Hugging Face
#    The code will fetch them automatically when you run the script.

# 3. Run a quick prediction
python scripts/predict.py --text_path test.txt --output_dir output/

If you want to train your own version, place the three CSV files in data/sentiment_data/ and launch the notebook finbert_training.ipynb. Adjust the Config parameters (epochs, learning rate, batch size, etc.) as needed.

Licensing – The repository’s code is released under Apache‑2.0 (licensed by MIH AI B.V.). The license does not cover the pre‑trained model weights (hosted on Hugging Face) nor the Financial PhraseBank dataset; users must respect the separate terms for those assets.

Contact – For questions, reach out to Dogu Araci (dogu.araci@prosus.com) or Zulkuf Genc (zulkuf.genc@prosus.com).


FinBERT is an intern research project from the Prosus AI team, not an official Prosus product.

Related

  • Project
  • Project
  • Project
  • Project