Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- sentiment-analysis
|
| 4 |
+
- finance
|
| 5 |
+
- roberta
|
| 6 |
+
- text-classification
|
| 7 |
+
datasets:
|
| 8 |
+
- FinancialMarketNewsHeadlines
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
# FinancialNewsSentimentAnalyzer
|
| 13 |
+
|
| 14 |
+
## Overview
|
| 15 |
+
|
| 16 |
+
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.
|
| 17 |
+
|
| 18 |
+
## Model Architecture
|
| 19 |
+
|
| 20 |
+
The core architecture is based on the **RoBERTa-base** pre-trained language model.
|
| 21 |
+
1. **Pre-trained Base:** RoBERTa (Robustly Optimized BERT Pretraining Approach) provides robust feature extraction from the input text.
|
| 22 |
+
2. **Classification Head:** A standard linear classification layer is added on top of the pooled output of the final RoBERTa hidden layer.
|
| 23 |
+
3. **Output:** The model outputs logits corresponding to the three sentiment classes: Negative (0), Neutral (1), and Positive (2).
|
| 24 |
+
|
| 25 |
+
## Intended Use
|
| 26 |
+
|
| 27 |
+
This model is intended for:
|
| 28 |
+
* **Algorithmic Trading Signals:** Providing real-time sentiment input to inform trading strategies.
|
| 29 |
+
* **Market Monitoring:** Automatically categorizing and filtering large streams of financial news.
|
| 30 |
+
* **Research:** Analyzing market reaction to specific events or company announcements.
|
| 31 |
+
|
| 32 |
+
### How to use
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 36 |
+
import torch
|
| 37 |
+
|
| 38 |
+
model_name = "your_username/FinancialNewsSentimentAnalyzer" # Replace with actual hub path
|
| 39 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 40 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
| 41 |
+
|
| 42 |
+
headline = "Tesla Stock Surges 8% Following Unexpectedly Strong Q3 Delivery Numbers"
|
| 43 |
+
inputs = tokenizer(headline, return_tensors="pt")
|
| 44 |
+
|
| 45 |
+
with torch.no_grad():
|
| 46 |
+
logits = model(**inputs).logits
|
| 47 |
+
|
| 48 |
+
predicted_class_id = logits.argmax().item()
|
| 49 |
+
predicted_label = model.config.id2label[predicted_class_id]
|
| 50 |
+
|
| 51 |
+
print(f"Headline: {headline}")
|
| 52 |
+
print(f"Predicted Sentiment: {predicted_label}")
|