Downloads · 30 days
18
2% of all-time downloads
suha-memon/finbert-stock-sentiment
finbert-stock-sentiment is a machine learning model from suha-memon. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Fine-tuned FinBERT model for financial sentiment analysis of stock-related news headlines.
Downloads · 30 days
18
2% of all-time downloads
All-time downloads
1.1K
Public
Parameters
109M
438 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors438 MB · 100%
From the Hugging Face model README
Fine-tuned FinBERT model for financial sentiment analysis of stock-related news headlines.
This model is a fine-tuned version of ProsusAI/finbert on financial sentiment data. It classifies financial text into three categories:
| Metric | Score |
|---|---|
| Accuracy | 81.88% |
| F1 Macro | 0.8009 |
| F1 Weighted | 0.8259 |
| Class | F1 Score |
|---|---|
| Negative | 0.6719 |
| Neutral | 0.8203 |
| Positive | 0.9104 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "suha-memon/finbert-stock-sentiment"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Example usage
headline = "Apple announces record-breaking quarterly earnings"
inputs = tokenizer(headline, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
# Get probabilities
negative_prob = predictions[0][0].item()
neutral_prob = predictions[0][1].item()
positive_prob = predictions[0][2].item()
print(f"Negative: {negative_prob:.2%}")
print(f"Neutral: {neutral_prob:.2%}")
print(f"Positive: {positive_prob:.2%}")
This model is designed for:
The model was trained on financial sentiment data from Kaggle, consisting of:
Class distribution was imbalanced with fewer negative examples, addressed using Focal Loss.
If you use this model, please cite:
@misc{finbert-stock-sentiment,
author = {Your Name},
title = {FinBERT Stock Sentiment Analyzer},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/suha-memon/finbert-stock-sentiment}}
}