File size: 2,313 Bytes
345d0ac
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f564899
 
 
345d0ac
 
 
 
f564899
345d0ac
 
 
f564899
 
345d0ac
 
 
 
 
 
 
 
 
 
f564899
 
 
 
 
 
 
 
345d0ac
f564899
 
 
 
 
 
 
 
 
 
345d0ac
 
 
 
f564899
 
 
 
 
345d0ac
f564899
345d0ac
f564899
 
 
 
 
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---

language: en
license: apache-2.0
tags:
- financial-sentiment
- sentiment-analysis
- finance
- nlp
- transformers
datasets:
- zeroshot/twitter-financial-news-sentiment
metrics:
- accuracy
- f1
model-index:
- name: financial-sentiment-improved
  results:
  - task:
      type: text-classification
      name: Financial Sentiment Analysis
    dataset:
      name: Twitter Financial News Sentiment
      type: zeroshot/twitter-financial-news-sentiment
    metrics:
    - type: accuracy
      value: 0.847
    - type: f1
      value: 0.845
---


# 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

```python

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