File size: 7,470 Bytes
cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 1adb5db cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 cd3f868 ef7c7b6 |
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
---
library_name: transformers
license: apache-2.0
base_model: FacebookAI/xlm-roberta-base
tags:
- sentiment
- text-classification
- multilingual
- modernbert
- sentiment-analysis
- product-reviews
- place-reviews
metrics:
- f1
- precision
- recall
model-index:
- name: clapAI/roberta-large-multilingual-sentiment
results: []
datasets:
- clapAI/MultiLingualSentiment
language:
- en
- zh
- vi
- ko
- ja
- ar
- de
- es
- fr
- hi
- id
- it
- ms
- pt
- ru
- tr
pipeline_tag: text-classification
---
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
should probably proofread and complete it, then remove this comment. -->
# clapAI/modernBERT-large-multilingual-sentiment
## Introduction
**roberta-large-multilingual-sentiment** is a multilingual sentiment classification model, part of
the [Multilingual-Sentiment](https://huggingface.co./collections/clapAI/multilingual-sentiment-677416a6b23e03f52cb6cc3f)
collection.
The model is fine-tuned from [FacebookAI/xlm-roberta-base](https://huggingface.co./FacebookAI/xlm-roberta-base) using the
multilingual sentiment
dataset [clapAI/MultiLingualSentiment](https://huggingface.co./datasets/clapAI/MultiLingualSentiment).
Model supports multilingual sentiment classification across 16+ languages, including English, Vietnamese, Chinese,
French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Arabic, and more.
## Evaluation & Performance
After fine-tuning, the best model is loaded and evaluated on the `test` dataset
from [clapAI/MultiLingualSentiment](https://huggingface.co./datasets/clapAI/MultiLingualSentiment)
| Model | Pretrained Model | Parameters | F1-score |
|:----------------------------------------------------------------------------------------------------------------:|:-----------------:|:----------:|:--------:|
| [modernBERT-base-multilingual-sentiment](https://huggingface.co./clapAI/modernBERT-base-multilingual-sentiment) | ModernBERT-base | 150M | 80.16 |
| [modernBERT-large-multilingual-sentiment](https://huggingface.co./clapAI/modernBERT-large-multilingual-sentiment) | ModernBERT-large | 396M | 81.4 |
| [roberta-base-multilingual-sentiment](https://huggingface.co./clapAI/roberta-base-multilingual-sentiment) | XLM-roberta-base | 278M | 81.8 |
| [roberta-large-multilingual-sentiment](https://huggingface.co./clapAI/roberta-large-multilingual-sentiment) | XLM-roberta-large | 560M | 82.6 |
## How to use
### Requirements
Since **transformers** only supports the **ModernBERT** architecture from version `4.48.0.dev0`, use the following
command to get the required version:
```bash
pip install "git+https://github.com/huggingface/transformers.git@6e0515e99c39444caae39472ee1b2fd76ece32f1" --upgrade
```
Install **FlashAttention** to accelerate inference performance
```bash
pip install flash-attn==2.7.2.post1
```
### Quick start
```python
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
model_id = "clapAI/roberta-large-multilingual-sentiment"
# Load the tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id, torch_dtype=torch.float16)
model.to(device)
model.eval()
# Retrieve labels from the model's configuration
id2label = model.config.id2label
texts = [
# English
{
"text": "I absolutely love the new design of this app!",
"label": "positive"
},
{
"text": "The customer service was disappointing.",
"label": "negative"
},
# Arabic
{
"text": "هذا المنتج رائع للغاية!",
"label": "positive"
},
{
"text": "الخدمة كانت سيئة للغاية.",
"label": "negative"
},
# German
{
"text": "Ich bin sehr zufrieden mit dem Kauf.",
"label": "positive"
},
{
"text": "Die Lieferung war eine Katastrophe.",
"label": "negative"
},
# Spanish
{
"text": "Este es el mejor libro que he leído.",
"label": "positive"
},
{
"text": "El producto llegó roto y no funciona.",
"label": "negative"
},
# French
{
"text": "J'adore ce restaurant, la nourriture est délicieuse!",
"label": "positive"
},
{
"text": "Le service était très lent et désagréable.",
"label": "negative"
},
# Indonesian
{
"text": "Saya sangat senang dengan pelayanan ini.",
"label": "positive"
},
{
"text": "Makanannya benar-benar tidak enak.",
"label": "negative"
},
# Japanese
{
"text": "この製品は本当に素晴らしいです!",
"label": "positive"
},
{
"text": "サービスがひどかったです。",
"label": "negative"
},
# Korean
{
"text": "이 제품을 정말 좋아해요!",
"label": "positive"
},
{
"text": "고객 서비스가 정말 실망스러웠어요.",
"label": "negative"
},
# Russian
{
"text": "Этот фильм просто потрясающий!",
"label": "positive"
},
{
"text": "Качество было ужасным.",
"label": "negative"
},
# Vietnamese
{
"text": "Tôi thực sự yêu thích sản phẩm này!",
"label": "positive"
},
{
"text": "Dịch vụ khách hàng thật tệ.",
"label": "negative"
},
# Chinese
{
"text": "我非常喜欢这款产品!",
"label": "positive"
},
{
"text": "质量真的很差。",
"label": "negative"
}
]
for item in texts:
text = item["text"]
label = item["label"]
inputs = tokenizer(text, return_tensors="pt").to(device)
# Perform inference in inference mode
with torch.inference_mode():
outputs = model(**inputs)
predictions = outputs.logits.argmax(dim=-1)
print(f"Text: {text} | Label: {label} | Prediction: {id2label[predictions.item()]}")
```
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:
```yaml
learning_rate: 5e-05
train_batch_size: 512
eval_batch_size: 512
seed: 42
distributed_type: multi-GPU
num_devices: 2
gradient_accumulation_steps: 2
total_train_batch_size: 2048
total_eval_batch_size: 1024
optimizer:
type: adamw_torch_fused
betas: [ 0.9, 0.999 ]
epsilon: 1e-08
optimizer_args: "No additional optimizer arguments"
lr_scheduler:
type: cosine
warmup_ratio: 0.01
num_epochs: 5.0
mixed_precision_training: Native AMP
```
### Framework versions
```plaintex
transformers==4.48.0.dev0
torch==2.4.0+cu121
datasets==3.2.0
tokenizers==0.21.0
flash-attn==2.7.2.post1
```
## Citation
If you find our project helpful, please star our repo and cite our work. Thanks!
```bibtex
@misc{roberta-large-multilingual-sentiment,
title=roberta-large-multilingual-sentiment: A Multilingual Sentiment Classification Model},
author={clapAI},
howpublished={\url{https://huggingface.co./clapAI/roberta-large-multilingual-sentiment}},
year={2025},
} |