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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: en
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- federated-learning
|
| 6 |
+
- finance
|
| 7 |
+
- sentiment-analysis
|
| 8 |
+
- bert
|
| 9 |
+
- finbert
|
| 10 |
+
- fedavg
|
| 11 |
+
library_name: transformers
|
| 12 |
+
pipeline_tag: text-classification
|
| 13 |
+
authors:
|
| 14 |
+
- Harsh Prasad
|
| 15 |
+
- Sai Dhole
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
## FinBERTโFedAvg: Federated Averaging for Financial Sentiment Analysis
|
| 19 |
+
|
| 20 |
+
---
|
| 21 |
+
|
| 22 |
+
### ๐ Model Summary
|
| 23 |
+
|
| 24 |
+
This model is a **federated version of FinBERT** fine-tuned for
|
| 25 |
+
**financial sentiment classification (Positive / Negative / Neutral)**.
|
| 26 |
+
|
| 27 |
+
Training is performed across **three clients**:
|
| 28 |
+
|
| 29 |
+
* Financial Twitter posts
|
| 30 |
+
* Financial news headlines
|
| 31 |
+
* Financial reports & statements
|
| 32 |
+
|
| 33 |
+
This model is trained using the **Federated Averaging (FedAvg)** algorithm,
|
| 34 |
+
where each client trains locally on its own data and only **model weights** are shared.
|
| 35 |
+
No raw data is exchanged, supporting privacy-preserving learning.
|
| 36 |
+
|
| 37 |
+
This model is part of a research project comparing:
|
| 38 |
+
|
| 39 |
+
* FedAvg
|
| 40 |
+
* FedProx
|
| 41 |
+
* Adaptive Aggregation
|
| 42 |
+
|
| 43 |
+
for federated financial NLP.
|
| 44 |
+
|
| 45 |
+
---
|
| 46 |
+
|
| 47 |
+
### ๐ง Intended Use
|
| 48 |
+
|
| 49 |
+
Designed for:
|
| 50 |
+
|
| 51 |
+
* Financial sentiment research
|
| 52 |
+
* Risk & market analytics
|
| 53 |
+
* Academic exploration of federated learning
|
| 54 |
+
|
| 55 |
+
Not intended for automated trading without expert oversight.
|
| 56 |
+
|
| 57 |
+
---
|
| 58 |
+
|
| 59 |
+
### ๐ Model Architecture
|
| 60 |
+
|
| 61 |
+
Base Model:
|
| 62 |
+
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
ProsusAI/finbert
|
| 66 |
+
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Task:
|
| 70 |
+
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
Sequence classification โ 3 classes
|
| 74 |
+
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
Training Setup:
|
| 78 |
+
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
3 federation clients
|
| 82 |
+
10 global rounds
|
| 83 |
+
3 local epochs
|
| 84 |
+
FedAvg aggregation
|
| 85 |
+
|
| 86 |
+
````
|
| 87 |
+
|
| 88 |
+
---
|
| 89 |
+
|
| 90 |
+
### ๐ Client Data Sources
|
| 91 |
+
|
| 92 |
+
| Client | Data Type |
|
| 93 |
+
| -------- | ----------------- |
|
| 94 |
+
| Client-1 | Financial Twitter |
|
| 95 |
+
| Client-2 | Financial News |
|
| 96 |
+
| Client-3 | Financial Reports |
|
| 97 |
+
|
| 98 |
+
No raw data is shared between clients.
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
### ๐ Privacy Advantage
|
| 103 |
+
|
| 104 |
+
Only model updates are exchanged โ not text data.
|
| 105 |
+
This supports data governance and privacy-aware ML.
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
### ๐ Performance (Validation)
|
| 110 |
+
|
| 111 |
+
| Method | Final Avg F1-Score |
|
| 112 |
+
| ------ | ------------------ |
|
| 113 |
+
| FedAvg | **0.846** |
|
| 114 |
+
|
| 115 |
+
FedAvg provided **strong and stable global performance**
|
| 116 |
+
across heterogeneous financial text sources.
|
| 117 |
+
|
| 118 |
+
---
|
| 119 |
+
|
| 120 |
+
### ๐ Example Usage
|
| 121 |
+
|
| 122 |
+
```python
|
| 123 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 124 |
+
import torch
|
| 125 |
+
|
| 126 |
+
model = AutoModelForSequenceClassification.from_pretrained(
|
| 127 |
+
"harshprasad03/FinBERT-FedAvg"
|
| 128 |
+
)
|
| 129 |
+
tokenizer = AutoTokenizer.from_pretrained(
|
| 130 |
+
"harshprasad03/FinBERT-FedAvg"
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
text = "Tech stocks fell after negative earnings guidance."
|
| 134 |
+
|
| 135 |
+
inputs = tokenizer(text, return_tensors="pt")
|
| 136 |
+
outputs = model(**inputs)
|
| 137 |
+
|
| 138 |
+
prob = torch.softmax(outputs.logits, dim=1)
|
| 139 |
+
print(prob)
|
| 140 |
+
````
|
| 141 |
+
|
| 142 |
+
---
|
| 143 |
+
|
| 144 |
+
### โ ๏ธ Limitations
|
| 145 |
+
|
| 146 |
+
* Trained only on finance-domain text
|
| 147 |
+
* Sentiment โ market prediction
|
| 148 |
+
* Model may inherit dataset biases
|
| 149 |
+
* Designed for research use
|
| 150 |
+
|
| 151 |
+
---
|
| 152 |
+
|
| 153 |
+
### ๐ Citation
|
| 154 |
+
|
| 155 |
+
```
|
| 156 |
+
Harsh Prasad, Sai Dhole (2025).
|
| 157 |
+
FedAvg-based Federated FinBERT for Financial Sentiment Analysis.
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
---
|
| 161 |
+
|
| 162 |
+
### ๐จโ๐ป Authors
|
| 163 |
+
|
| 164 |
+
**Harsh Prasad**
|
| 165 |
+
AI and ML Research
|
| 166 |
+
|
| 167 |
+
**Sai Dhole**
|
| 168 |
+
AI and ML Research
|
| 169 |
+
|
| 170 |
+
---
|