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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
- ja
|
| 7 |
+
- de
|
| 8 |
+
- fr
|
| 9 |
+
- es
|
| 10 |
+
tags:
|
| 11 |
+
- finance
|
| 12 |
+
- sentiment-analysis
|
| 13 |
+
- multilingual
|
| 14 |
+
- xlm-roberta
|
| 15 |
+
- finbert
|
| 16 |
+
datasets:
|
| 17 |
+
- Kenpache/multilingual-financial-sentiment
|
| 18 |
+
metrics:
|
| 19 |
+
- accuracy
|
| 20 |
+
- f1
|
| 21 |
+
pipeline_tag: text-classification
|
| 22 |
+
model-index:
|
| 23 |
+
- name: FinBERT-Multilingual
|
| 24 |
+
results:
|
| 25 |
+
- task:
|
| 26 |
+
type: text-classification
|
| 27 |
+
name: Financial Sentiment Analysis
|
| 28 |
+
metrics:
|
| 29 |
+
- name: Accuracy
|
| 30 |
+
type: accuracy
|
| 31 |
+
value: 0.8103
|
| 32 |
+
- name: F1 (weighted)
|
| 33 |
+
type: f1
|
| 34 |
+
value: 0.8102
|
| 35 |
+
---
|
| 36 |
+
|
| 37 |
+
# FinBERT-Multilingual
|
| 38 |
+
|
| 39 |
+
A multilingual extension of the FinBERT paradigm: domain-adapted transformer for financial sentiment classification across six languages (EN, ZH, JA, DE, FR, ES).
|
| 40 |
+
|
| 41 |
+
While the original [FinBERT](https://arxiv.org/abs/1908.10063) demonstrated the effectiveness of domain-specific pre-training for English financial NLP, this model extends that approach to a multilingual setting using XLM-RoBERTa-base as the backbone, enabling cross-lingual financial sentiment analysis without language-specific models.
|
| 42 |
+
|
| 43 |
+
## Model Architecture
|
| 44 |
+
|
| 45 |
+
- **Base model:** `xlm-roberta-base` (278M parameters)
|
| 46 |
+
- **Task:** 3-class sequence classification (Negative / Neutral / Positive)
|
| 47 |
+
- **Domain adaptation:** Task-Adaptive Pre-Training (TAPT) via Masked Language Modeling on 35K+ financial texts
|
| 48 |
+
- **Languages:** English, Chinese, Japanese, German, French, Spanish
|
| 49 |
+
|
| 50 |
+
## Training Pipeline
|
| 51 |
+
|
| 52 |
+
### Stage 1: Task-Adaptive Pre-Training (TAPT)
|
| 53 |
+
|
| 54 |
+
Following [Gururangan et al. (2020)](https://arxiv.org/abs/2004.10964), we perform continued MLM pre-training on the unlabeled financial corpus to adapt the model's representations to the financial domain. This stage exposes the model to domain-specific vocabulary and discourse patterns across all six target languages using approximately 35,000 financial text samples.
|
| 55 |
+
|
| 56 |
+
### Stage 2: Supervised Fine-Tuning
|
| 57 |
+
|
| 58 |
+
The domain-adapted model is then fine-tuned on the labeled sentiment classification task.
|
| 59 |
+
|
| 60 |
+
**Hyperparameters:**
|
| 61 |
+
|
| 62 |
+
| Parameter | Value |
|
| 63 |
+
|---|---|
|
| 64 |
+
| Learning rate | 2e-5 |
|
| 65 |
+
| LR scheduler | Cosine annealing |
|
| 66 |
+
| Label smoothing | 0.1 |
|
| 67 |
+
| Checkpoint selection | SWA (top-3 checkpoints) |
|
| 68 |
+
| Base model | xlm-roberta-base |
|
| 69 |
+
|
| 70 |
+
**Stochastic Weight Averaging (SWA):** Rather than selecting a single best checkpoint, we average the weights of the top-3 performing checkpoints. This produces a flatter loss minimum and more robust generalization, particularly beneficial for multilingual settings where overfitting to dominant languages is a risk.
|
| 71 |
+
|
| 72 |
+
**Label smoothing (0.1):** Prevents overconfident predictions and improves calibration, which is important for financial applications where prediction confidence informs downstream decisions.
|
| 73 |
+
|
| 74 |
+
## Evaluation Results
|
| 75 |
+
|
| 76 |
+
### Overall Metrics
|
| 77 |
+
|
| 78 |
+
| Metric | Score |
|
| 79 |
+
|---|---|
|
| 80 |
+
| Accuracy | 0.8103 |
|
| 81 |
+
| F1 (weighted) | 0.8102 |
|
| 82 |
+
| Precision (weighted) | 0.8111 |
|
| 83 |
+
| Recall (weighted) | 0.8103 |
|
| 84 |
+
|
| 85 |
+
### Per-Class Performance
|
| 86 |
+
|
| 87 |
+
| Class | Precision | Recall | F1-Score |
|
| 88 |
+
|---|---|---|---|
|
| 89 |
+
| Negative | 0.78 | 0.83 | 0.81 |
|
| 90 |
+
| Neutral | 0.83 | 0.79 | 0.81 |
|
| 91 |
+
| Positive | 0.80 | 0.82 | 0.81 |
|
| 92 |
+
|
| 93 |
+
The balanced per-class performance (all F1 scores at 0.81) indicates that the model does not exhibit significant class bias, despite the imbalanced training distribution (Neutral: 45.5%, Positive: 30.8%, Negative: 23.7%).
|
| 94 |
+
|
| 95 |
+
## Usage
|
| 96 |
+
|
| 97 |
+
```python
|
| 98 |
+
from transformers import pipeline
|
| 99 |
+
|
| 100 |
+
classifier = pipeline("text-classification", model="Kenpache/finbert-multilingual")
|
| 101 |
+
|
| 102 |
+
# English
|
| 103 |
+
classifier("The company reported record quarterly earnings, driven by strong demand.")
|
| 104 |
+
# [{'label': 'positive', 'score': 0.95}]
|
| 105 |
+
|
| 106 |
+
# German
|
| 107 |
+
classifier("Die Aktie verlor nach der Gewinnwarnung deutlich an Wert.")
|
| 108 |
+
# [{'label': 'negative', 'score': 0.92}]
|
| 109 |
+
|
| 110 |
+
# Japanese
|
| 111 |
+
classifier("同社の売上高は前年同期比で横ばいとなった。")
|
| 112 |
+
# [{'label': 'neutral', 'score': 0.88}]
|
| 113 |
+
|
| 114 |
+
# Chinese
|
| 115 |
+
classifier("该公司宣布大规模裁员计划,股价应声下跌。")
|
| 116 |
+
# [{'label': 'negative', 'score': 0.91}]
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
### Direct Model Loading
|
| 120 |
+
|
| 121 |
+
```python
|
| 122 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
| 123 |
+
import torch
|
| 124 |
+
|
| 125 |
+
tokenizer = AutoTokenizer.from_pretrained("Kenpache/finbert-multilingual")
|
| 126 |
+
model = AutoModelForSequenceClassification.from_pretrained("Kenpache/finbert-multilingual")
|
| 127 |
+
|
| 128 |
+
text = "Les bénéfices du groupe ont augmenté de 15% au premier trimestre."
|
| 129 |
+
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
|
| 130 |
+
|
| 131 |
+
with torch.no_grad():
|
| 132 |
+
outputs = model(**inputs)
|
| 133 |
+
probs = torch.softmax(outputs.logits, dim=-1)
|
| 134 |
+
pred = torch.argmax(probs, dim=-1).item()
|
| 135 |
+
|
| 136 |
+
labels = {0: "negative", 1: "neutral", 2: "positive"}
|
| 137 |
+
print(f"Prediction: {labels[pred]} ({probs[0][pred]:.4f})")
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
## Training Data
|
| 141 |
+
|
| 142 |
+
The model was trained on [Kenpache/multilingual-financial-sentiment](https://huggingface.co/datasets/Kenpache/multilingual-financial-sentiment), a curated dataset of ~39K financial news sentences from 80+ sources across six languages.
|
| 143 |
+
|
| 144 |
+
| Language | Samples | Sources |
|
| 145 |
+
|---|---|---|
|
| 146 |
+
| Japanese | 8,287 | Nikkei, Nikkan Kogyo, Reuters JP, Minkabu, etc. |
|
| 147 |
+
| Chinese | 7,930 | Sina Finance, EastMoney, 10jqka, etc. |
|
| 148 |
+
| Spanish | 7,125 | Expansión, Cinco Días, Bloomberg Línea, etc. |
|
| 149 |
+
| English | 6,887 | CNBC, Yahoo Finance, Fortune, Benzinga, etc. |
|
| 150 |
+
| German | 5,023 | Börse.de, FAZ, NTV Börse, Handelsblatt, etc. |
|
| 151 |
+
| French | 3,935 | Boursorama, Tradingsat, BFM Business, etc. |
|
| 152 |
+
|
| 153 |
+
## Comparison with FinBERT
|
| 154 |
+
|
| 155 |
+
| Feature | FinBERT | FinBERT-Multilingual |
|
| 156 |
+
|---|---|---|
|
| 157 |
+
| Base model | BERT-base | XLM-RoBERTa-base |
|
| 158 |
+
| Languages | English only | 6 languages |
|
| 159 |
+
| Domain adaptation | Financial corpus pre-training | TAPT on multilingual financial texts |
|
| 160 |
+
| Classes | 3 (Pos/Neg/Neu) | 3 (Pos/Neg/Neu) |
|
| 161 |
+
| Checkpoint selection | Single best | SWA (top-3) |
|
| 162 |
+
|
| 163 |
+
## Citation
|
| 164 |
+
|
| 165 |
+
If you use this model in your research, please cite:
|
| 166 |
+
|
| 167 |
+
```bibtex
|
| 168 |
+
@misc{finbert-multilingual-2025,
|
| 169 |
+
title={FinBERT-Multilingual: Cross-Lingual Financial Sentiment Analysis with Domain-Adapted XLM-RoBERTa},
|
| 170 |
+
author={Kenpache},
|
| 171 |
+
year={2025},
|
| 172 |
+
url={https://huggingface.co/Kenpache/finbert-multilingual}
|
| 173 |
+
}
|
| 174 |
+
```
|
| 175 |
+
|
| 176 |
+
## License
|
| 177 |
+
|
| 178 |
+
Apache 2.0
|