pmatorras commited on
Commit
316ca5f
·
verified ·
1 Parent(s): cb90f16

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +89 -0
README.md ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: mit
5
+ library_name: transformers
6
+ tags:
7
+ - finance
8
+ - sentiment
9
+ - finbert
10
+ - multi-task-learning
11
+ datasets:
12
+ - financial_phrasebank
13
+ - zeroshot/twitter-financial-news-sentiment
14
+ - TheFinAI/fiqa-sentiment-classification
15
+ metrics:
16
+ - accuracy
17
+ - f1
18
+ base_model: ProsusAI/finbert
19
+ widget:
20
+ - text: "The company reported a record 20% increase in revenue this quarter."
21
+ example_title: "Strong Earnings"
22
+ - text: "Analysts are worried about the looming debt crisis."
23
+ example_title: "Negative Outlook"
24
+ ---
25
+
26
+ # Financial-Sentiment-LLM (Multi-Task FinBERT)
27
+
28
+ A production-ready financial sentiment classifier fine-tuned on **FinBERT**. This model utilizes a **Multi-Task Architecture** (Classification + Regression) to achieve state-of-the-art performance across diverse financial text sources, including professional news, social media, and forum discussions.
29
+
30
+ - **🚀 Live Demo:** [Hugging Face Space](https://huggingface.co/spaces/pmatorras/financial-sentiment-demo)
31
+ - **💻 Source Code:** [GitHub Repository](https://github.com/pmatorras/financial-sentiment-llm)
32
+ - **👨‍💻 Author:** [Pablo Matorras-Cuevas](https://pablo.matorras.com/)
33
+
34
+ ## Model Performance
35
+
36
+ This Multi-Task model achieves **85.4% overall accuracy**, significantly outperforming standard baselines, particularly on noisy social media data.
37
+
38
+ | Metric / Dataset | **FinBERT (Multi-Task)** | FinBERT (LoRA) |
39
+ | :--- | :--- | :--- |
40
+ | **Overall Accuracy** | **85.4%** | 83.2% |
41
+ | **Macro F1-Score** | **0.83** | 0.80 |
42
+ | **Financial PhraseBank** (News) | 95.9% | **97.1%** |
43
+ | **Twitter Financial News** | **83.3%** | 80.5% |
44
+ | **FiQA** (Forums) | **81.5%** | 72.6% |
45
+
46
+ > **Note:** For edge deployment or low-memory environments, check out the [LoRA version](https://huggingface.co/pmatorras/finbert-lora-financial-sentiment) which reduces storage by 99% (5MB vs 420MB).
47
+
48
+ ## Architecture
49
+
50
+ Unlike standard sentiment classifiers, this model shares a `bert-base` backbone with two task-specific heads:
51
+ 1. **Classification Head:** Predicts `Negative`/`Neutral`/`Positive` (Optimized for News & Twitter).
52
+ 2. **Regression Head:** Predicts a continuous sentiment score (Optimized for FiQA forum discussions).
53
+
54
+ This approach yielded a **+6.1% accuracy boost** on Twitter data compared to single-task training, proving that learning continuous sentiment intensity helps the model understand noisy social text better.
55
+
56
+ ## Usage
57
+
58
+ You can use this model directly with the Hugging Face `pipeline` or `AutoModel`:
59
+
60
+ ```python
61
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
62
+ import torch
63
+
64
+ # Load the model and tokenizer
65
+ model_name = "pmatorras/financial-sentiment-multi-task"
66
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
67
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
68
+
69
+ # Inference
70
+ text = "The stock market rally is driven by strong tech earnings."
71
+ inputs = tokenizer(text, return_tensors="pt")
72
+
73
+ with torch.no_grad():
74
+ outputs = model(**inputs)
75
+ probabilities = torch.nn.functional.softmax(outputs.logits, dim=-1)
76
+
77
+ print(probabilities)
78
+ ```
79
+ ## Training Details
80
+ - **Base Model**: ProsusAI/finbert
81
+ - **Optimizer**: AdamW
82
+ - **Loss Function**: Weighted sum of Cross-Entropy (Classification) and MSE (Regression).
83
+ - **Compute**: Trained on NVIDIA RTX 4050.
84
+
85
+
86
+ ### Key Features of this Card:
87
+ - **YAML Header:** Enables the "Hosted Inference API" widget on the right side of the page so people can test it instantly.
88
+ - **Cross-Linking:** It links to your GitHub, your Website, and the LoRA version.
89
+ - **Usage Snippet:** Essential for developers to copy-paste and run.