# FinBERT: Apache-2.0 code, weights and data under other terms, and a 64-token cap on every sentence

> ProsusAI/finBERT is the training and prediction code for a BERT model fine-tuned to classify financial text as positive, negative or neutral. The Apache-2.0 license covers the scripts and notebooks only, not the Hugging Face weights and not the Financial PhraseBank data.

**ProsusAI/finBERT** — Financial Sentiment Analysis with BERT

- Repository: https://github.com/ProsusAI/finBERT
- Stars: 2,277 · Forks: 542
- Language: Jupyter Notebook
- License: Apache-2.0
- Published: 2026-10-16 · Updated: 2026-10-30 · Language: en
- Canonical page: https://hysenlabs.com/projects/prosusai-finbert

## The Apache-2.0 license stops at the code

The README now opens with a licensing notice dated 12 October 2026, and it narrows what the repository's license means. The Apache-2.0 license applies only to the training code, scripts and notebooks in the repository. It does not cover the pre-trained model weights hosted on Hugging Face, and it does not cover the training dataset, Financial PhraseBank.

The code is licensed by MIH AI B.V. under the Apache License, Version 2.0. For the weights, the README tells you to review the model card on Hugging Face for licensing terms and restrictions. For the data, it says Financial PhraseBank has its own licensing terms and that users are solely responsible for ensuring compliance with third-party data licenses.

Two more statements sit beside that. The project is provided as is, without warranty. And it is not an official Prosus product: the Disclaimer section calls it the outcome of an intern research project in the Prosus AI team. A company that wants to put the model in a commercial product has to resolve the weights license and the data license separately, since the repository license settles neither.

## Further pre-training on finance text, then three-label classification

FinBERT is described as a pre-trained NLP model for the sentiment of financial text. It is built by further training the BERT language model in the finance domain, using a large financial corpus, and then fine-tuning it for financial sentiment classification. The paper named for the details is FinBERT: Financial Sentiment Analysis with Pre-trained Language Models.

Two datasets are involved. The further training of the language model uses a subset of Reuters TRC2. The README says that dataset is not public, but researchers can apply for access through the NIST page it links. For the sentiment step, the README names Financial PhraseBank from Malo et al. (2014).

The consequence is that you can reproduce only half of the pipeline from public parts. The sentiment fine-tuning can be repeated if you download Financial PhraseBank. The domain pre-training cannot be repeated without access to TRC2. The training notebook gets around this by starting from bert-base-uncased by default, so a model trained from the repository alone skips the finance pre-training unless you supply your own further pre-trained model.

## Installing means a Conda environment named finbert

The README installs dependencies by creating a Conda environment called finbert from the given environment.yml file and activating it:

```bash
conda env create -f environment.yml
conda activate finbert
```

The repository also has a Dockerfile, which takes a different route. It starts from pytorch/pytorch:latest, runs pip install numpy pandas nltk Flask flask-cors transformers, copies main.py and the finbert folder into /src, exposes port 8080 and starts python3 /src/main.py. That points to a small Flask service in main.py, though the README never mentions it, so the routes it serves are not documented.

The image pins nothing: the base image tag is latest and the pip packages carry no versions, so two builds on different days can produce different environments. The Conda file is the documented path. If you want reproducibility with the Docker route, you have to add the version pins yourself.

## Weights come from Hugging Face by model id

The pre-trained weights are not in the repository. They are hosted at huggingface.co/ProsusAI/finbert, and the README says to review the model card for licensing terms and usage restrictions before downloading or using them. The code loads the model directly by its id:

```python
from transformers import AutoModelForSequenceClassification
model = AutoModelForSequenceClassification.from_pretrained('ProsusAI/finbert')
```

To use a model you trained yourself, pass its local directory instead of 'ProsusAI/finbert'. The first call therefore needs network access to Hugging Face unless the weights are already cached, and the README does not describe caching.

The README opens its main text by saying the sentiment model is now available on the Hugging Face model hub. This tells you where most users are expected to get the model, and the repository itself matters mostly when you want to retrain or run the bundled prediction script. If all you need is the model, the transformers snippet above is the whole integration the README documents.

## Preparing Financial PhraseBank takes three CSV files

To train on the same dataset, download Financial PhraseBank from the link in the README, then create three files under the data/sentiment_data folder: train.csv, validation.csv and test.csv. The steps are to download the dataset, locate Sentences_50Agree.txt inside the FinancialPhraseBank-v1.0 zip, and run the datasets script with that path:

```bash
python scripts/datasets.py --data_path <path to Sentences_50Agree.txt>
```

The file name matters. Sentences_50Agree.txt is the variant the README points to, and the name suggests sentences where annotators agreed at least at the fifty percent level, though the README does not explain it. The README does not state how the script splits the data into the three files either, so the proportions are in scripts/datasets.py.

The download link goes to a ResearchGate address, a third-party host. If that link fails, the README offers no mirror, and the Financial PhraseBank license is the user's responsibility as stated in the notice.

## Four epochs, 64 tokens and two anti-forgetting switches

Training happens in the finbert_training.ipynb notebook. It starts from bert-base-uncased by default, and you can set bm in the notebook to your own further pre-trained language model. The trained model is saved to models/classifier_model/finbert-sentiment. The README prints the configuration:

```python
config = Config(   data_dir=cl_data_path,
                   bert_model=bertmodel,
                   num_train_epochs=4.0,
                   model_dir=cl_path,
                   max_seq_length = 64,
                   train_batch_size = 32,
                   learning_rate = 2e-5,
                   output_mode='classification',
                   warm_up_proportion=0.2,
                   local_rank=-1,
                   discriminate=True,
                   gradual_unfreeze=True )
```

max_seq_length = 64 is the limit that bites. A sentence longer than 64 tokens cannot be seen in full during training, and the README says nothing about how longer inputs are handled at prediction time. For financial news that runs to paragraphs, split the text into sentences first.

The last two parameters, discriminate and gradual_unfreeze, decide whether to apply the corresponding technique against catastrophic forgetting. Both are on in the printed config.

## predict.py turns a text file into probabilities and a score

For quick predictions the README provides scripts/predict.py. Given a .txt file, it produces a .csv file with the sentences, the softmax probabilities for three labels, the actual prediction and a sentiment score. The score is the probability of positive minus the probability of negative. The example uses the bundled test.txt:

```bash
python scripts/predict.py --text_path test.txt --output_dir output/
```

By default this uses the ProsusAI/finbert model from Hugging Face. To use your own trained model, add --model_path models/classifier_model/finbert-sentiment.

The README does not name the three labels, though the score formula refers to positive and negative, which leaves neutral as the third. Because the score subtracts negative from positive, a sentence the model treats as mostly neutral lands near zero, and so does a sentence split evenly between positive and negative. Read the probabilities and not only the score if that distinction matters to you.

The repository is not archived, there are no GitHub releases, and the last push was on 2026-10-12. Questions go to the two authors named by email in the README.

## Conclusion

Use FinBERT if you need three-label sentiment scores for financial sentences and are willing to run a Python script or notebook yourself. Do not treat the Apache-2.0 badge as covering the model: the weights and the Financial PhraseBank data have their own terms, and the README makes you responsible for checking them. Read the Hugging Face model card first, then run scripts/predict.py on the bundled test.txt before pointing it at your own text.

## FAQ

### What is FinBERT used for?

FinBERT is a pre-trained NLP model that analyzes the sentiment of financial text. It is BERT further trained on financial text and fine-tuned for financial sentiment classification.

### How do I install FinBERT?

Create the Conda environment from environment.yml with conda env create -f environment.yml and activate it with conda activate finbert. The model weights load from Hugging Face by the id ProsusAI/finbert.

### What is FinBERT trained on?

The language model was further trained on a subset of Reuters TRC2, which is not public. Sentiment fine-tuning used Financial PhraseBank from Malo et al. (2014).

### What does FinBERT output?

The predict.py script writes a CSV with each sentence, softmax probabilities for three labels, the prediction and a sentiment score equal to the positive probability minus the negative probability.

## Sources

- [Issues](https://github.com/ProsusAI/finBERT/issues)
- [License: Apache-2.0](https://github.com/ProsusAI/finBERT/blob/master/LICENSE)
- [ProsusAI/finBERT on GitHub](https://github.com/ProsusAI/finBERT)
- [README](https://github.com/ProsusAI/finBERT/blob/master/README.md)

---

Hysen Labs editorial analysis, written from the project's own repository and release notes. Cite the canonical page: https://hysenlabs.com/projects/prosusai-finbert
