hungnm commited on
Commit
be01169
·
verified ·
1 Parent(s): fbc1ac7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +240 -41
README.md CHANGED
@@ -3,7 +3,13 @@ library_name: transformers
3
  license: apache-2.0
4
  base_model: answerdotai/ModernBERT-base
5
  tags:
6
- - generated_from_trainer
 
 
 
 
 
 
7
  metrics:
8
  - f1
9
  - precision
@@ -11,6 +17,26 @@ metrics:
11
  model-index:
12
  - name: clapAI/modernBERT-base-multilingual-sentiment
13
  results: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ---
15
 
16
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
@@ -18,59 +44,232 @@ should probably proofread and complete it, then remove this comment. -->
18
 
19
  # clapAI/modernBERT-base-multilingual-sentiment
20
 
21
- This model is a fine-tuned version of [answerdotai/ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) on an unknown dataset.
22
- It achieves the following results on the evaluation set:
23
- - Loss: 0.4517
24
- - F1: 0.8012
25
- - Precision: 0.8020
26
- - Recall: 0.8007
27
 
28
- ## Model description
 
 
29
 
30
- More information needed
 
 
31
 
32
- ## Intended uses & limitations
 
33
 
34
- More information needed
35
 
36
- ## Training and evaluation data
 
37
 
38
- More information needed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  ## Training procedure
41
 
42
  ### Training hyperparameters
43
 
44
  The following hyperparameters were used during training:
45
- - learning_rate: 5e-05
46
- - train_batch_size: 512
47
- - eval_batch_size: 512
48
- - seed: 42
49
- - distributed_type: multi-GPU
50
- - num_devices: 2
51
- - gradient_accumulation_steps: 2
52
- - total_train_batch_size: 2048
53
- - total_eval_batch_size: 1024
54
- - optimizer: Use adamw_torch_fused with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
55
- - lr_scheduler_type: cosine
56
- - lr_scheduler_warmup_ratio: 0.01
57
- - num_epochs: 5.0
58
- - mixed_precision_training: Native AMP
59
-
60
- ### Training results
61
-
62
- | Training Loss | Epoch | Step | Validation Loss | F1 | Precision | Recall |
63
- |:-------------:|:-----:|:----:|:---------------:|:------:|:---------:|:------:|
64
- | 0.9287 | 1.0 | 1537 | 0.4626 | 0.7910 | 0.7940 | 0.7897 |
65
- | 0.8356 | 2.0 | 3074 | 0.4441 | 0.8011 | 0.8009 | 0.8015 |
66
- | 0.7488 | 3.0 | 4611 | 0.4517 | 0.8012 | 0.8020 | 0.8007 |
67
- | 0.6177 | 4.0 | 6148 | 0.4915 | 0.7990 | 0.7989 | 0.7991 |
68
- | 0.5174 | 5.0 | 7685 | 0.5464 | 0.7944 | 0.7945 | 0.7944 |
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
71
  ### Framework versions
72
 
73
- - Transformers 4.48.0.dev0
74
- - Pytorch 2.4.0+cu121
75
- - Datasets 3.2.0
76
- - Tokenizers 0.21.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  license: apache-2.0
4
  base_model: answerdotai/ModernBERT-base
5
  tags:
6
+ - sentiment
7
+ - text-classification
8
+ - multilingual
9
+ - modernbert
10
+ - sentiment-analysis
11
+ - product-reviews
12
+ - place-reviews
13
  metrics:
14
  - f1
15
  - precision
 
17
  model-index:
18
  - name: clapAI/modernBERT-base-multilingual-sentiment
19
  results: []
20
+ datasets:
21
+ - clapAI/MultiLingualSentiment
22
+ language:
23
+ - en
24
+ - zh
25
+ - vi
26
+ - ko
27
+ - ja
28
+ - ar
29
+ - de
30
+ - es
31
+ - fr
32
+ - hi
33
+ - id
34
+ - it
35
+ - ms
36
+ - pt
37
+ - ru
38
+ - tr
39
+ pipeline_tag: text-classification
40
  ---
41
 
42
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
 
44
 
45
  # clapAI/modernBERT-base-multilingual-sentiment
46
 
47
+ ## Introduction
 
 
 
 
 
48
 
49
+ **modernBERT-base-multilingual-sentiment** is a multilingual sentiment classification model, part of
50
+ the [Multilingual-Sentiment](https://huggingface.co/collections/clapAI/multilingual-sentiment-677416a6b23e03f52cb6cc3f)
51
+ collection.
52
 
53
+ The model is fine-tuned from [answerdotai/ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) using the
54
+ multilingual sentiment
55
+ dataset [clapAI/MultiLingualSentiment](https://huggingface.co/datasets/clapAI/MultiLingualSentiment).
56
 
57
+ Model supports multilingual sentiment classification across 16+ languages, including English, Vietnamese, Chinese,
58
+ French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Arabic, and more.
59
 
60
+ ## Evaluation & Performance
61
 
62
+ After fine-tuning, the best model is loaded and evaluated on the `test` dataset
63
+ from [clapAI/MultiLingualSentiment](https://huggingface.co/datasets/clapAI/MultiLingualSentiment)
64
 
65
+ | Model | Pretrained Model | Parameters | Latency (ms) | F1 | Precision | Recall |
66
+ |:----------------------------------------------------------------------------------------------------------------:|:-----------------:|:-----------:|:------------:|:--------:|:---------:|:--------:|
67
+ | [modernBERT-base-multilingual-sentiment](https://huggingface.co/clapAI/modernBERT-base-multilingual-sentiment) | ModernBERT-base | 149.607.171 | Updating | 80.16 | 80.26 | 80.09 |
68
+ | [modernBERT-large-multilingual-sentiment](https://huggingface.co/clapAI/modernBERT-large-multilingual-sentiment) | ModernBERT-large | 395.833.346 | Updating | Updating | Updating | Updating |
69
+ | [roberta-base-multilingual-sentiment](https://huggingface.co/clapAI/roberta-base-multilingual-sentiment) | XLM-roberta-base | 278.045.186 | Updating | Updating | Updating | Updating |
70
+ | [roberta-large-multilingual-sentiment](https://huggingface.co/clapAI/roberta-large-multilingual-sentiment) | XLM-roberta-large | 559.892.482 | Updating | Updating | Updating | Updating |
71
+
72
+ ## How to use
73
+
74
+ ### Requirements
75
+
76
+ Since **transformers** only supports the **ModernBERT** architecture from version `4.48.0.dev0`, use the following
77
+ command to get the required version:
78
+
79
+ ```bash
80
+ pip install "git+https://github.com/huggingface/transformers.git@6e0515e99c39444caae39472ee1b2fd76ece32f1" --upgrade
81
+ ```
82
+
83
+ Install **FlashAttention** to accelerate inference performance
84
+
85
+ ```bash
86
+ pip install flash-attn==2.7.2.post1
87
+ ```
88
+
89
+ ### Quick start
90
+
91
+ ```python
92
+ import torch
93
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
94
+
95
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
96
+
97
+ model_id = "clapAI/modernBERT-base-multilingual-sentiment"
98
+ # Load the tokenizer and model
99
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
100
+ model = AutoModelForSequenceClassification.from_pretrained(model_id, torch_dtype=torch.float16)
101
+
102
+ model.to(device)
103
+ model.eval()
104
+
105
+
106
+ # Retrieve labels from the model's configuration
107
+ id2label = model.config.id2label
108
+
109
+ texts = [
110
+ # English
111
+ {
112
+ "text": "I absolutely love the new design of this app!",
113
+ "label": "positive"
114
+ },
115
+ {
116
+ "text": "The customer service was disappointing.",
117
+ "label": "negative"
118
+ },
119
+ # Arabic
120
+ {
121
+ "text": "هذا المنتج رائع للغاية!",
122
+ "label": "positive"
123
+ },
124
+ {
125
+ "text": "الخدمة كانت سيئة للغاية.",
126
+ "label": "negative"
127
+ },
128
+ # German
129
+ {
130
+ "text": "Ich bin sehr zufrieden mit dem Kauf.",
131
+ "label": "positive"
132
+ },
133
+ {
134
+ "text": "Die Lieferung war eine Katastrophe.",
135
+ "label": "negative"
136
+ },
137
+ # Spanish
138
+ {
139
+ "text": "Este es el mejor libro que he leído.",
140
+ "label": "positive"
141
+ },
142
+ {
143
+ "text": "El producto llegó roto y no funciona.",
144
+ "label": "negative"
145
+ },
146
+ # French
147
+ {
148
+ "text": "J'adore ce restaurant, la nourriture est délicieuse!",
149
+ "label": "positive"
150
+ },
151
+ {
152
+ "text": "Le service était très lent et désagréable.",
153
+ "label": "negative"
154
+ },
155
+ # Indonesian
156
+ {
157
+ "text": "Saya sangat senang dengan pelayanan ini.",
158
+ "label": "positive"
159
+ },
160
+ {
161
+ "text": "Makanannya benar-benar tidak enak.",
162
+ "label": "negative"
163
+ },
164
+ # Japanese
165
+ {
166
+ "text": "この製品は本当に素晴らしいです!",
167
+ "label": "positive"
168
+ },
169
+ {
170
+ "text": "サービスがひどかったです。",
171
+ "label": "negative"
172
+ },
173
+ # Korean
174
+ {
175
+ "text": "이 제품을 정말 좋아해요!",
176
+ "label": "positive"
177
+ },
178
+ {
179
+ "text": "고객 서비스가 정말 실망스러웠어요.",
180
+ "label": "negative"
181
+ },
182
+ # Russian
183
+ {
184
+ "text": "Этот фильм просто потрясающий!",
185
+ "label": "positive"
186
+ },
187
+ {
188
+ "text": "Качество было ужасным.",
189
+ "label": "negative"
190
+ },
191
+ # Vietnamese
192
+ {
193
+ "text": "Tôi thực sự yêu thích sản phẩm này!",
194
+ "label": "positive"
195
+ },
196
+ {
197
+ "text": "Dịch vụ khách hàng thật tệ.",
198
+ "label": "negative"
199
+ },
200
+ # Chinese
201
+ {
202
+ "text": "我非常喜欢这款产品!",
203
+ "label": "positive"
204
+ },
205
+ {
206
+ "text": "质量真的很差。",
207
+ "label": "negative"
208
+ }
209
+ ]
210
+
211
+ for item in texts:
212
+ text = item["text"]
213
+ label = item["label"]
214
+
215
+ inputs = tokenizer(text, return_tensors="pt").to(device)
216
+
217
+ # Perform inference in inference mode
218
+ with torch.inference_mode():
219
+ outputs = model(**inputs)
220
+ predictions = outputs.logits.argmax(dim=-1)
221
+ print(f"Text: {text} | Label: {label} | Prediction: {id2label[predictions.item()]}")
222
+
223
+
224
+ ```
225
 
226
  ## Training procedure
227
 
228
  ### Training hyperparameters
229
 
230
  The following hyperparameters were used during training:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
+ ```yaml
233
+ learning_rate: 5e-05
234
+ train_batch_size: 512
235
+ eval_batch_size: 512
236
+ seed: 42
237
+ distributed_type: multi-GPU
238
+ num_devices: 2
239
+ gradient_accumulation_steps: 2
240
+ total_train_batch_size: 2048
241
+ total_eval_batch_size: 1024
242
+ optimizer:
243
+ type: adamw_torch_fused
244
+ betas: [ 0.9, 0.999 ]
245
+ epsilon: 1e-08
246
+ optimizer_args: "No additional optimizer arguments"
247
+ lr_scheduler:
248
+ type: cosine
249
+ warmup_ratio: 0.01
250
+ num_epochs: 5.0
251
+ mixed_precision_training: Native AMP
252
+
253
+ ```
254
 
255
  ### Framework versions
256
 
257
+ ```plaintex
258
+ transformers==4.48.0.dev0
259
+ torch==2.4.0+cu121
260
+ datasets==3.2.0
261
+ tokenizers==0.21.0
262
+ flash-attn==2.7.2.post1
263
+ ```
264
+
265
+ ## Citation
266
+
267
+ If you find our project helpful, please star our repo and cite our work. Thanks!
268
+
269
+ ```bibtex
270
+ @misc{modernBERT-base-multilingual-sentiment,
271
+ title={modernBERT-base-multilingual-sentiment: A Multilingual Sentiment Classification Model},
272
+ author={clapAI},
273
+ howpublished={\url{https://huggingface.co/clapAI/modernBERT-base-multilingual-sentiment}},
274
+ year={2025},
275
+ }