financial-sentiment-improved
This model is a fine-tuned version of DistilBERT for financial sentiment analysis. It has been trained on financial news and social media data to classify text into three sentiment categories: Bearish (negative), Neutral, and Bullish (positive).
Model Performance
- Accuracy: 0.847
- F1 Score: 0.845
Usage
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("codealchemist01/financial-sentiment-improved")
model = AutoModelForSequenceClassification.from_pretrained("codealchemist01/financial-sentiment-improved")
def predict_sentiment(text):
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
labels = ["Bearish", "Neutral", "Bullish"]
predicted_class = torch.argmax(predictions, dim=-1).item()
confidence = predictions[0][predicted_class].item()
return {
"label": labels[predicted_class],
"confidence": confidence
}
# Example
result = predict_sentiment("The stock market is showing strong growth today")
print(result)
Training Details
This model was trained using advanced techniques including:
- Balanced dataset sampling
- Custom loss functions
- Learning rate scheduling
- Early stopping
Intended Use
This model is designed for financial sentiment analysis tasks, including:
- Social media sentiment monitoring
- News sentiment analysis
- Market sentiment tracking
- Financial document analysis
- Downloads last month
- 14
Dataset used to train codealchemist01/financial-sentiment-improved
Space using codealchemist01/financial-sentiment-improved 1
Evaluation results
- accuracy on Twitter Financial News Sentimentself-reported0.847
- f1 on Twitter Financial News Sentimentself-reported0.845