ModernFinBERT-base / README.md
neoyipeng's picture
Upload README.md with huggingface_hub
f7d7c0d verified
metadata
language: en
license: apache-2.0
tags:
  - finance
  - sentiment-analysis
  - modernbert
  - financial-nlp
datasets:
  - neoyipeng/financial_reasoning_aggregated
metrics:
  - accuracy
widget:
  - text: >-
      The company reported strong quarterly earnings with revenue beating
      expectations.
    example_title: Positive Example
  - text: >-
      Stock prices fell sharply following disappointing guidance from
      management.
    example_title: Negative Example
  - text: The merger is expected to close in Q3 pending regulatory approval.
    example_title: Neutral Example

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: Financial text from multiple sources (excluding FinancialPhraseBank for evaluation)
  • Parameters: 149,607,171

Performance

  • FinancialPhraseBank Accuracy: 90.47%
  • Target: >94% accuracy on FinancialPhraseBank

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: 10
  • Batch Size: 32
  • Learning Rate: 5e-5
  • 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}
}