hungnm commited on
Commit
fddfffd
·
verified ·
1 Parent(s): 143e205

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +147 -70
README.md CHANGED
@@ -1,75 +1,152 @@
1
- ---
2
- library_name: transformers
3
- license: mit
4
- base_model: jhu-clsp/mmBERT-small
5
- tags:
6
- - generated_from_trainer
7
- metrics:
8
- - f1
9
- - precision
10
- - recall
11
- model-index:
12
- - name: mmBERT-small-multilingual-sentiment
13
- results: []
14
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
17
  should probably proofread and complete it, then remove this comment. -->
18
 
19
- # mmBERT-small-multilingual-sentiment
20
 
21
- This model is a fine-tuned version of [jhu-clsp/mmBERT-small](https://huggingface.co/jhu-clsp/mmBERT-small) on an unknown dataset.
22
- It achieves the following results on the evaluation set:
23
- - Loss: 0.4605
24
- - F1: 81.8318
25
- - Precision: 81.8361
26
- - Recall: 81.8321
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: 0
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 OptimizerNames.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
58
-
59
- ### Training results
60
-
61
- | Training Loss | Epoch | Step | Validation Loss | F1 | Precision | Recall |
62
- |:-------------:|:-----:|:----:|:---------------:|:-------:|:---------:|:-------:|
63
- | 1.8064 | 1.0 | 1537 | 0.4447 | 80.9603 | 80.9710 | 81.0960 |
64
- | 1.6408 | 2.0 | 3074 | 0.4309 | 81.7277 | 81.8109 | 81.6765 |
65
- | 1.4703 | 3.0 | 4611 | 0.4252 | 82.1472 | 82.1151 | 82.1871 |
66
- | 1.3121 | 4.0 | 6148 | 0.4393 | 82.0532 | 82.0873 | 82.0275 |
67
- | 1.1733 | 5.0 | 7685 | 0.4605 | 81.8318 | 81.8361 | 81.8321 |
68
-
69
-
70
- ### Framework versions
71
-
72
- - Transformers 4.55.0
73
- - Pytorch 2.8.0+cu128
74
- - Datasets 3.6.0
75
- - Tokenizers 0.21.4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ license: mit
4
+ base_model: jhu-clsp/mmBERT-small
5
+ tags:
6
+ - sentiment
7
+ - text-classification
8
+ - multilingual
9
+ - modernbert
10
+ - sentiment-analysis
11
+ - product-reviews
12
+ - place-reviews
13
+ - mmbert
14
+ metrics:
15
+ - f1
16
+ - precision
17
+ - recall
18
+ model-index:
19
+ - name: mmBERT-small-multilingual-sentiment
20
+ results: []
21
+ datasets:
22
+ - clapAI/MultiLingualSentiment
23
+ language:
24
+ - en
25
+ - zh
26
+ - vi
27
+ - ko
28
+ - ja
29
+ - ar
30
+ - de
31
+ - es
32
+ - fr
33
+ - hi
34
+ - id
35
+ - it
36
+ - ms
37
+ - pt
38
+ - ru
39
+ - tr
40
+ pipeline_tag: text-classification
41
+ ---
42
 
43
  <!-- This model card has been generated automatically according to the information the Trainer had access to. You
44
  should probably proofread and complete it, then remove this comment. -->
45
 
46
+ # clapAI/mmBERT-small-multilingual-sentiment
47
 
48
+ ## Introduction
49
+
50
+ **mmBERT-small-multilingual-sentiment** is a multilingual sentiment classification model, part of
51
+ the [Multilingual-Sentiment](https://huggingface.co/collections/clapAI/multilingual-sentiment-677416a6b23e03f52cb6cc3f)
52
+ collection.
53
+
54
+ The model is fine-tuned from [jhu-clsp/mmBERT-small](https://huggingface.co/jhu-clsp/mmBERT-small) using the
55
+ multilingual sentiment
56
+ dataset [clapAI/MultiLingualSentiment](https://huggingface.co/datasets/clapAI/MultiLingualSentiment).
57
+
58
+ Model supports multilingual sentiment classification across 16+ languages, including English, Vietnamese, Chinese,
59
+ French, Spanish, Portuguese, German, Italian, Russian, Japanese, Korean, Arabic, and more.
60
+
61
+ ## Key Highlights
62
+ > 📈 **Improved accuracy**: Achieves **F1 = 82.2**.
63
+ > 📜 **Long context support**: Handles sequences up to **8192 tokens**.
64
+ > 🪶 **Efficient size**: Only **140M parameters**, smaller than RoBERTa-base (278M) with better performance.
65
+ > **FlashAttention-2 support**: Enables much faster inference on modern GPUs.
66
+
67
+ ## Evaluation & Performance
68
+
69
+ Results on the test split
70
+ of [clapAI/MultiLingualSentiment](https://huggingface.co/datasets/clapAI/MultiLingualSentiment)
71
+
72
+ | Model | Pretrained Model | Parameters | Context-length | F1-score |
73
+ |:---------------------------------------------------------------------------------------------------------------:|:----------------------------------------------------------------------:|:----------:|----------------|:--------:|
74
+ | [clapAI/mmBERT-small-multilingual-sentiment](https://huggingface.co/clapAI/mmBERT-small-multilingual-sentiment) | [jhu-clsp/mmBERT-small](https://huggingface.co/jhu-clsp/mmBERT-small) | 140M | 8192 | **82.2** |
75
+ | [modernBERT-base-multilingual-sentiment](https://huggingface.co/clapAI/modernBERT-base-multilingual-sentiment) | [ModernBERT-base](https://huggingface.co/answerdotai/ModernBERT-base) | 150M | 8192 | 80.16 |
76
+ | [roberta-base-multilingual-sentiment](https://huggingface.co/clapAI/roberta-base-multilingual-sentiment) | [XLM-roberta-base](https://huggingface.co/FacebookAI/xlm-roberta-base) | 278M | 512 | 81.8 |
77
+
78
+ ## How to use
79
+
80
+ ### Installation
81
+
82
+ ```bash
83
+ pip install torch==2.8
84
+ pip install transformers==4.55.0
85
+ ```
86
+
87
+ `Optional: accelerate inference with FlashAttention-2 (if supported by your GPU):`
88
+
89
+ ```bash
90
+ pip install packaging
91
+ pip install ninja
92
+ MAX_JOBS=4 pip install flash-attn --no-build-isolation
93
+ ```
94
+
95
+ ### Example Usage
96
+
97
+ ```python
98
+ import torch
99
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
100
+
101
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
102
+
103
+ model_id = "clapAI/mmBERT-small-multilingual-sentiment"
104
+ # Load the tokenizer and model
105
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
106
+ dtype = torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16
107
+ model = AutoModelForSequenceClassification.from_pretrained(
108
+ model_id,
109
+ torch_dtype=dtype,
110
+ # Uncomment if device supports FA2
111
+ # attn_implementation="flash_attention_2"
112
+ )
113
+
114
+ model.to(device)
115
+ model.eval()
116
+
117
+ # Retrieve labels from the model's configuration
118
+ id2label = model.config.id2label
119
+
120
+ texts = [
121
+ "I absolutely love the new design of this app!", # English
122
+ "الخدمة كانت سيئة للغاية.",
123
+ "Ich bin sehr zufrieden mit dem Kauf.", # German
124
+ "El producto llegó roto y no funciona.", # Spanish
125
+ "J'adore ce restaurant, la nourriture est délicieuse!", # French
126
+ "Makanannya benar-benar tidak enak.", # Indonesian
127
+ "この製品は本当に素晴らしいです!", # Japanese
128
+ "고객 서비스가 정말 실망스러웠어요.", # Korean
129
+ "Этот фильм просто потрясающий!", # Russian
130
+ "Tôi thực sự yêu thích sản phẩm này!", # Vietnamese
131
+ "质量真的很差。" # Chinese
132
+ ]
133
+
134
+ for text in texts:
135
+ inputs = tokenizer(text, return_tensors="pt").to(device)
136
+ with torch.inference_mode():
137
+ outputs = model(**inputs)
138
+ prediction = id2label[outputs.logits.argmax(dim=-1).item()]
139
+ print(f"Text: {text} | Prediction: {prediction}")
140
+ ```
141
+
142
+ ## Citation
143
+
144
+ If you use this model, please consider citing:
145
+
146
+ ```bibtex
147
+ @misc{clapAI_mmbert_small_multilingual_sentiment,
148
+ title={mmBERT-small-multilingual-sentiment: A Multilingual Sentiment Classification Model},
149
+ author={clapAI},
150
+ howpublished={\url{https://huggingface.co/clapAI/mmBERT-small-multilingual-sentiment}},
151
+ year={2025},
152
+ }