File size: 2,075 Bytes
7892414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
---
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}")