Tasfiya025's picture
Create README.md
7892414 verified
---
tags:
- sentiment-analysis
- finance
- roberta
- text-classification
datasets:
- FinancialMarketNewsHeadlines
license: apache-2.0
---
# FinancialNewsSentimentAnalyzer
## Overview
This model is a RoBERTa-base sequence classification fine-tuned for analyzing the sentiment of financial market news headlines. It classifies headlines into one of three categories: **Positive**, **Negative**, or **Neutral**. The model is specifically optimized for short, impactful text snippets common in financial reporting.
## Model Architecture
The core architecture is based on the **RoBERTa-base** pre-trained language model.
1. **Pre-trained Base:** RoBERTa (Robustly Optimized BERT Pretraining Approach) provides robust feature extraction from the input text.
2. **Classification Head:** A standard linear classification layer is added on top of the pooled output of the final RoBERTa hidden layer.
3. **Output:** The model outputs logits corresponding to the three sentiment classes: Negative (0), Neutral (1), and Positive (2).
## Intended Use
This model is intended for:
* **Algorithmic Trading Signals:** Providing real-time sentiment input to inform trading strategies.
* **Market Monitoring:** Automatically categorizing and filtering large streams of financial news.
* **Research:** Analyzing market reaction to specific events or company announcements.
### How to use
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "your_username/FinancialNewsSentimentAnalyzer" # Replace with actual hub path
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
headline = "Tesla Stock Surges 8% Following Unexpectedly Strong Q3 Delivery Numbers"
inputs = tokenizer(headline, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
predicted_class_id = logits.argmax().item()
predicted_label = model.config.id2label[predicted_class_id]
print(f"Headline: {headline}")
print(f"Predicted Sentiment: {predicted_label}")