ModernFinBERT: Financial Sentiment Analysis
ModernFinBERT is a financial sentiment analysis model based on the ModernBERT architecture, fine-tuned specifically for financial text classification.
Model Details
- Base Model: answerdotai/ModernBERT-base
- Task: 3-class sentiment classification (Negative, Neutral, Positive)
- Training Data: Vanilla sentiment tasks from multiple sources (including FinancialPhraseBank)
- Parameters: 149,607,171
Performance
Overall Accuracy
| Split | Accuracy |
|---|---|
| Validation | 85.3% |
| Test | 83.1% |
Test Accuracy by Source
| Source | Accuracy | Correct/Total |
|---|---|---|
| 4.0 | 89.5% | 77/86 |
| 9.0 | 88.0% | 205/233 |
| 5.0 | 84.4% | 205/243 |
| 3.0 | 80.0% | 20/25 |
| 8.0 | 69.1% | 94/136 |
Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("neoyipeng/ModernFinBERT-base")
model = AutoModelForSequenceClassification.from_pretrained("neoyipeng/ModernFinBERT-base")
text = "The company's quarterly results exceeded analyst expectations."
inputs = tokenizer(text, return_tensors="pt")
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
labels = ["NEGATIVE", "NEUTRAL", "POSITIVE"]
predicted_class = labels[predictions.argmax().item()]
confidence = predictions.max().item()
print(f"Sentiment: {predicted_class} ({confidence:.2f})")
Training Details
- Epochs: 3
- Batch Size: 32
- Learning Rate: 5e-05
- Optimizer: AdamW
- Scheduler: Cosine
- Framework: Unsloth + Transformers
Citation
If you use this model, please cite:
@misc{modernfinbert2025,
title={ModernFinBERT: A Modern Approach to Financial Sentiment Analysis},
author={Neo Yi Peng},
year={2025},
howpublished={HuggingFace Model Hub},
url={https://huggingface.co/neoyipeng/ModernFinBERT-base}
}
- Downloads last month
- 101
Inference Providers
NEW
This model isn't deployed by any Inference Provider.
🙋
1
Ask for provider support