Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -23,26 +23,19 @@ model-index:
|
|
| 23 |
type: zeroshot/twitter-financial-news-sentiment
|
| 24 |
metrics:
|
| 25 |
- type: accuracy
|
| 26 |
-
value: 0.
|
| 27 |
-
|
|
|
|
| 28 |
---
|
| 29 |
|
| 30 |
# financial-sentiment-improved
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
Improved financial sentiment analysis model with enhanced performance
|
| 35 |
-
|
| 36 |
-
This model is fine-tuned from `distilbert-base-uncased` for financial sentiment analysis, capable of classifying financial text into three categories:
|
| 37 |
-
- **Bearish** (0): Negative financial sentiment
|
| 38 |
-
- **Neutral** (1): Neutral financial sentiment
|
| 39 |
-
- **Bullish** (2): Positive financial sentiment
|
| 40 |
|
| 41 |
## Model Performance
|
| 42 |
|
| 43 |
-
- **Accuracy**: 0.
|
| 44 |
-
- **
|
| 45 |
-
- **Base Model**: distilbert-base-uncased
|
| 46 |
|
| 47 |
## Usage
|
| 48 |
|
|
@@ -50,45 +43,42 @@ This model is fine-tuned from `distilbert-base-uncased` for financial sentiment
|
|
| 50 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 51 |
import torch
|
| 52 |
|
| 53 |
-
# Load model and tokenizer
|
| 54 |
tokenizer = AutoTokenizer.from_pretrained("codealchemist01/financial-sentiment-improved")
|
| 55 |
model = AutoModelForSequenceClassification.from_pretrained("codealchemist01/financial-sentiment-improved")
|
| 56 |
|
| 57 |
-
|
| 58 |
-
text =
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
|
|
|
| 64 |
predicted_class = torch.argmax(predictions, dim=-1).item()
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
```
|
| 70 |
|
| 71 |
## Training Details
|
| 72 |
|
| 73 |
-
|
| 74 |
-
-
|
| 75 |
-
-
|
| 76 |
-
-
|
|
|
|
| 77 |
|
| 78 |
-
##
|
| 79 |
|
| 80 |
-
This model is
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
```bibtex
|
| 87 |
-
@misc{financial-sentiment-improved,
|
| 88 |
-
author = {CodeAlchemist01},
|
| 89 |
-
title = {financial-sentiment-improved},
|
| 90 |
-
year = {2024},
|
| 91 |
-
publisher = {Hugging Face},
|
| 92 |
-
url = {https://huggingface.co/codealchemist01/financial-sentiment-improved}
|
| 93 |
-
}
|
| 94 |
-
```
|
|
|
|
| 23 |
type: zeroshot/twitter-financial-news-sentiment
|
| 24 |
metrics:
|
| 25 |
- type: accuracy
|
| 26 |
+
value: 0.847
|
| 27 |
+
- type: f1
|
| 28 |
+
value: 0.845
|
| 29 |
---
|
| 30 |
|
| 31 |
# financial-sentiment-improved
|
| 32 |
|
| 33 |
+
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).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
## Model Performance
|
| 36 |
|
| 37 |
+
- **Accuracy**: 0.847
|
| 38 |
+
- **F1 Score**: 0.845
|
|
|
|
| 39 |
|
| 40 |
## Usage
|
| 41 |
|
|
|
|
| 43 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 44 |
import torch
|
| 45 |
|
|
|
|
| 46 |
tokenizer = AutoTokenizer.from_pretrained("codealchemist01/financial-sentiment-improved")
|
| 47 |
model = AutoModelForSequenceClassification.from_pretrained("codealchemist01/financial-sentiment-improved")
|
| 48 |
|
| 49 |
+
def predict_sentiment(text):
|
| 50 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True, max_length=512)
|
| 51 |
+
|
| 52 |
+
with torch.no_grad():
|
| 53 |
+
outputs = model(**inputs)
|
| 54 |
+
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
|
| 55 |
+
|
| 56 |
+
labels = ["Bearish", "Neutral", "Bullish"]
|
| 57 |
predicted_class = torch.argmax(predictions, dim=-1).item()
|
| 58 |
+
confidence = predictions[0][predicted_class].item()
|
| 59 |
+
|
| 60 |
+
return {
|
| 61 |
+
"label": labels[predicted_class],
|
| 62 |
+
"confidence": confidence
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
# Example
|
| 66 |
+
result = predict_sentiment("The stock market is showing strong growth today")
|
| 67 |
+
print(result)
|
| 68 |
```
|
| 69 |
|
| 70 |
## Training Details
|
| 71 |
|
| 72 |
+
This model was trained using advanced techniques including:
|
| 73 |
+
- Balanced dataset sampling
|
| 74 |
+
- Custom loss functions
|
| 75 |
+
- Learning rate scheduling
|
| 76 |
+
- Early stopping
|
| 77 |
|
| 78 |
+
## Intended Use
|
| 79 |
|
| 80 |
+
This model is designed for financial sentiment analysis tasks, including:
|
| 81 |
+
- Social media sentiment monitoring
|
| 82 |
+
- News sentiment analysis
|
| 83 |
+
- Market sentiment tracking
|
| 84 |
+
- Financial document analysis
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|