HuaminChen commited on
Commit
b734d98
·
verified ·
1 Parent(s): d4de07f

Update with 51K dataset - 98.6% accuracy

Browse files
Files changed (4) hide show
  1. README.md +29 -206
  2. adapter_config.json +4 -4
  3. adapter_model.safetensors +2 -2
  4. training_config.json +13 -13
README.md CHANGED
@@ -1,242 +1,65 @@
1
  ---
2
- license: apache-2.0
3
  language:
4
  - en
5
- - es
6
- - fr
7
- - de
8
- - zh
9
  - ja
10
- - ko
11
- - ar
12
- - pt
13
- - ru
14
- - hi
15
  - multilingual
16
- library_name: peft
17
  tags:
18
- - text-classification
19
  - feedback-detection
20
  - user-satisfaction
21
  - mmbert
22
- - modernbert
23
- - multilingual
24
  - lora
25
  - peft
26
- - vllm-semantic-router
27
  datasets:
28
  - llm-semantic-router/feedback-detector-dataset
29
  metrics:
30
  - accuracy
31
  - f1
32
- base_model: jhu-clsp/mmBERT-base
33
- pipeline_tag: text-classification
34
- model-index:
35
- - name: mmbert-feedback-detector-lora
36
- results:
37
- - task:
38
- type: text-classification
39
- name: User Feedback Classification
40
- dataset:
41
- name: feedback-detector-dataset
42
- type: llm-semantic-router/feedback-detector-dataset
43
- metrics:
44
- - type: accuracy
45
- value: 0.9689
46
- name: Accuracy
47
- - type: f1
48
- value: 0.9688
49
- name: F1 Macro
50
  ---
51
 
52
- # mmBERT Feedback Detector (LoRA Adapter)
53
-
54
- A **multilingual** 4-class user feedback classifier built on [jhu-clsp/mmBERT-base](https://huggingface.co/jhu-clsp/mmBERT-base). This is the **LoRA adapter** version for parameter-efficient fine-tuning and inference.
55
 
56
- ## Model Description
57
 
58
- This model uses **LoRA (Low-Rank Adaptation)** for efficient fine-tuning, reducing trainable parameters to just **1.09%** of the full model while maintaining high performance.
59
 
60
- For the merged version (ready for direct inference), see [llm-semantic-router/mmbert-feedback-detector-merged](https://huggingface.co/llm-semantic-router/mmbert-feedback-detector-merged).
61
-
62
- ### Labels
63
-
64
- | Label | ID | Description |
65
- |-------|-----|-------------|
66
- | `SAT` | 0 | User is satisfied with the response |
67
- | `NEED_CLARIFICATION` | 1 | User needs more explanation or clarification |
68
- | `WRONG_ANSWER` | 2 | User indicates the response is incorrect |
69
- | `WANT_DIFFERENT` | 3 | User wants alternative options or different response |
70
-
71
- ## Performance
72
-
73
- | Metric | Score |
74
  |--------|-------|
75
- | **Accuracy** | 96.89% |
76
- | **F1 Macro** | 96.88% |
77
- | **F1 Weighted** | 96.88% |
78
-
79
- ### Per-Class Performance
80
-
81
- | Class | F1 Score |
82
- |-------|----------|
83
- | SAT | 100.0% |
84
- | NEED_CLARIFICATION | 99.7% |
85
- | WRONG_ANSWER | 94.0% |
86
- | WANT_DIFFERENT | 93.8% |
87
 
88
- ## LoRA Configuration
89
 
90
- | Parameter | Value |
91
- |-----------|-------|
92
- | **Rank (r)** | 16 |
93
- | **Alpha** | 32 |
94
- | **Target Modules** | query, key, value, dense |
95
- | **Dropout** | 0.1 |
96
- | **Trainable Params** | 3.38M (1.09%) |
97
- | **Total Params** | 310.9M |
98
 
99
- ## Multilingual Support
100
 
101
- Thanks to mmBERT's multilingual pretraining (256k vocabulary, 100+ languages), this model achieves excellent cross-lingual transfer:
102
-
103
- | Language | Accuracy |
104
- |----------|----------|
105
- | 🇺🇸 English | 100% |
106
- | 🇪🇸 Spanish | 100% |
107
- | 🇫🇷 French | 100% |
108
- | 🇩🇪 German | 100% |
109
- | 🇨🇳 Chinese | 100% |
110
- | 🇯🇵 Japanese | 100% |
111
- | 🇰🇷 Korean | 100% |
112
- | 🇸🇦 Arabic | 100% |
113
 
114
  ## Usage
115
 
116
- ### With PEFT
117
-
118
- ```python
119
- from peft import PeftModel, PeftConfig
120
- from transformers import AutoModelForSequenceClassification, AutoTokenizer
121
- import torch
122
-
123
- # Load base model and LoRA adapter
124
- base_model_name = "jhu-clsp/mmBERT-base"
125
- adapter_name = "llm-semantic-router/mmbert-feedback-detector-lora"
126
-
127
- # Load tokenizer
128
- tokenizer = AutoTokenizer.from_pretrained(adapter_name)
129
-
130
- # Load base model
131
- base_model = AutoModelForSequenceClassification.from_pretrained(
132
- base_model_name,
133
- num_labels=4,
134
- trust_remote_code=True
135
- )
136
-
137
- # Load LoRA adapter
138
- model = PeftModel.from_pretrained(base_model, adapter_name)
139
- model.eval()
140
-
141
- # Classify feedback
142
- text = "Thanks, that's exactly what I needed!"
143
- inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
144
-
145
- with torch.no_grad():
146
- outputs = model(**inputs)
147
- probs = torch.softmax(outputs.logits, dim=-1)
148
- pred = probs.argmax().item()
149
-
150
- labels = ["SAT", "NEED_CLARIFICATION", "WRONG_ANSWER", "WANT_DIFFERENT"]
151
- print(f"Prediction: {labels[pred]} ({probs[0][pred]:.1%})")
152
- ```
153
-
154
- ### Merge and Save
155
-
156
  ```python
 
157
  from peft import PeftModel
158
- from transformers import AutoModelForSequenceClassification, AutoTokenizer
159
 
160
- # Load and merge
161
- base_model = AutoModelForSequenceClassification.from_pretrained(
162
- "jhu-clsp/mmBERT-base",
163
- num_labels=4,
164
- trust_remote_code=True
165
- )
166
  model = PeftModel.from_pretrained(base_model, "llm-semantic-router/mmbert-feedback-detector-lora")
167
- merged_model = model.merge_and_unload()
168
-
169
- # Save merged model
170
- merged_model.save_pretrained("./merged_model")
171
  tokenizer = AutoTokenizer.from_pretrained("llm-semantic-router/mmbert-feedback-detector-lora")
172
- tokenizer.save_pretrained("./merged_model")
173
- ```
174
-
175
- ### Continue Fine-tuning
176
-
177
- ```python
178
- from peft import PeftModel, get_peft_model, LoraConfig
179
- from transformers import AutoModelForSequenceClassification
180
-
181
- # Load existing adapter
182
- base_model = AutoModelForSequenceClassification.from_pretrained(
183
- "jhu-clsp/mmBERT-base",
184
- num_labels=4,
185
- trust_remote_code=True
186
- )
187
- model = PeftModel.from_pretrained(base_model, "llm-semantic-router/mmbert-feedback-detector-lora")
188
 
189
- # Continue training with your data
190
- # model.train()
191
- # ... training code ...
192
  ```
193
-
194
- ## Training Details
195
-
196
- - **Base Model**: [jhu-clsp/mmBERT-base](https://huggingface.co/jhu-clsp/mmBERT-base)
197
- - **Method**: LoRA (Low-Rank Adaptation)
198
- - **LoRA Rank**: 16
199
- - **LoRA Alpha**: 32
200
- - **Learning Rate**: 2e-5
201
- - **Batch Size**: 32
202
- - **Epochs**: 5
203
- - **Max Length**: 512
204
- - **Dataset**: [llm-semantic-router/feedback-detector-dataset](https://huggingface.co/datasets/llm-semantic-router/feedback-detector-dataset)
205
-
206
- ## Use Cases
207
-
208
- - **Conversational AI**: Understand if users are satisfied with chatbot responses
209
- - **Customer Support**: Route dissatisfied users to human agents
210
- - **Quality Monitoring**: Track response quality across languages
211
- - **Feedback Analysis**: Categorize user feedback automatically
212
- - **Continued Fine-tuning**: Adapt to domain-specific feedback patterns
213
-
214
- ## Advantages of LoRA
215
-
216
- - **Storage Efficient**: Only ~13MB adapter vs ~1.2GB full model
217
- - **Fast Training**: Train in minutes on consumer GPUs
218
- - **Composable**: Stack with other adapters
219
- - **Base Model Updates**: Benefit from base model improvements
220
-
221
- ## Related Models
222
-
223
- - [llm-semantic-router/mmbert-feedback-detector-merged](https://huggingface.co/llm-semantic-router/mmbert-feedback-detector-merged) - Merged version
224
- - [llm-semantic-router/mmbert-intent-classifier-lora](https://huggingface.co/llm-semantic-router/mmbert-intent-classifier-lora) - Intent classification
225
- - [llm-semantic-router/mmbert-fact-check-lora](https://huggingface.co/llm-semantic-router/mmbert-fact-check-lora) - Fact checking
226
- - [llm-semantic-router/mmbert-jailbreak-detector-lora](https://huggingface.co/llm-semantic-router/mmbert-jailbreak-detector-lora) - Security
227
-
228
- ## Citation
229
-
230
- ```bibtex
231
- @misc{mmbert-feedback-detector-lora,
232
- title={mmBERT Feedback Detector LoRA Adapter},
233
- author={vLLM Semantic Router Team},
234
- year={2025},
235
- publisher={Hugging Face},
236
- url={https://huggingface.co/llm-semantic-router/mmbert-feedback-detector-lora}
237
- }
238
- ```
239
-
240
- ## License
241
-
242
- Apache 2.0
 
1
  ---
 
2
  language:
3
  - en
 
 
 
 
4
  - ja
5
+ - tr
 
 
 
 
6
  - multilingual
7
+ license: apache-2.0
8
  tags:
 
9
  - feedback-detection
10
  - user-satisfaction
11
  - mmbert
 
 
12
  - lora
13
  - peft
14
+ base_model: jhu-clsp/mmBERT-base
15
  datasets:
16
  - llm-semantic-router/feedback-detector-dataset
17
  metrics:
18
  - accuracy
19
  - f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  ---
21
 
22
+ # mmBERT Feedback Detector (LoRA)
 
 
23
 
24
+ A multilingual 4-class feedback classification model fine-tuned with LoRA on mmBERT-base.
25
 
26
+ ## Model Performance
27
 
28
+ | Metric | Value |
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  |--------|-------|
30
+ | **Accuracy** | 98.63% |
31
+ | **F1 Macro** | 97.94% |
32
+ | F1 SAT | 100.0% |
33
+ | F1 NEED_CLARIFICATION | 99.7% |
34
+ | F1 WRONG_ANSWER | 96.2% |
35
+ | F1 WANT_DIFFERENT | 95.9% |
 
 
 
 
 
 
36
 
37
+ ## Labels
38
 
39
+ - **SAT** (0): User is satisfied
40
+ - **NEED_CLARIFICATION** (1): User needs more information
41
+ - **WRONG_ANSWER** (2): System gave incorrect response
42
+ - **WANT_DIFFERENT** (3): User wants something different
 
 
 
 
43
 
44
+ ## Training
45
 
46
+ - **Base Model**: jhu-clsp/mmBERT-base
47
+ - **Dataset**: 51,694 examples (llm-semantic-router/feedback-detector-dataset)
48
+ - **LoRA**: rank=32, alpha=64
49
+ - **Epochs**: 5
50
+ - **Batch Size**: 64
 
 
 
 
 
 
 
51
 
52
  ## Usage
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  ```python
55
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
56
  from peft import PeftModel
 
57
 
58
+ base_model = AutoModelForSequenceClassification.from_pretrained("jhu-clsp/mmBERT-base", num_labels=4)
 
 
 
 
 
59
  model = PeftModel.from_pretrained(base_model, "llm-semantic-router/mmbert-feedback-detector-lora")
 
 
 
 
60
  tokenizer = AutoTokenizer.from_pretrained("llm-semantic-router/mmbert-feedback-detector-lora")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
+ inputs = tokenizer("Thank you, that was helpful!", return_tensors="pt")
63
+ outputs = model(**inputs)
64
+ label = outputs.logits.argmax(-1).item()
65
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
adapter_config.json CHANGED
@@ -13,7 +13,7 @@
13
  "layers_pattern": null,
14
  "layers_to_transform": null,
15
  "loftq_config": {},
16
- "lora_alpha": 32,
17
  "lora_bias": false,
18
  "lora_dropout": 0.1,
19
  "megatron_config": null,
@@ -24,14 +24,14 @@
24
  ],
25
  "peft_type": "LORA",
26
  "qalora_group_size": 16,
27
- "r": 16,
28
  "rank_pattern": {},
29
  "revision": null,
30
  "target_modules": [
 
31
  "attn.Wo",
32
  "mlp.Wi",
33
- "mlp.Wo",
34
- "attn.Wqkv"
35
  ],
36
  "target_parameters": null,
37
  "task_type": "SEQ_CLS",
 
13
  "layers_pattern": null,
14
  "layers_to_transform": null,
15
  "loftq_config": {},
16
+ "lora_alpha": 64,
17
  "lora_bias": false,
18
  "lora_dropout": 0.1,
19
  "megatron_config": null,
 
24
  ],
25
  "peft_type": "LORA",
26
  "qalora_group_size": 16,
27
+ "r": 32,
28
  "rank_pattern": {},
29
  "revision": null,
30
  "target_modules": [
31
+ "attn.Wqkv",
32
  "attn.Wo",
33
  "mlp.Wi",
34
+ "mlp.Wo"
 
35
  ],
36
  "target_parameters": null,
37
  "task_type": "SEQ_CLS",
adapter_model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:1d96dddc3fd68845012d5c21af03edce7c5d61ec0d9a8553bb2711025e5148de
3
- size 13551024
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1df0ab37e51dd11727ccdcbbdd040a4a05d0f5f4cf66b0296b5cfd54d1e01afd
3
+ size 27067968
training_config.json CHANGED
@@ -21,8 +21,8 @@
21
  "base_model": "jhu-clsp/mmBERT-base",
22
  "max_length": 512,
23
  "use_lora": true,
24
- "lora_rank": 16,
25
- "lora_alpha": 32,
26
  "class_weights": [
27
  1.0,
28
  1.0,
@@ -30,17 +30,17 @@
30
  1.0
31
  ],
32
  "metrics": {
33
- "eval_loss": 0.11521816998720169,
34
- "eval_accuracy": 0.9688755020080321,
35
- "eval_f1_macro": 0.9688249790009527,
36
- "eval_f1_weighted": 0.9688249790009527,
37
- "eval_f1_SAT": 1.0,
38
- "eval_f1_NEED_CLARIFICATION": 0.996996996996997,
39
- "eval_f1_WRONG_ANSWER": 0.9403578528827038,
40
- "eval_f1_WANT_DIFFERENT": 0.9379450661241099,
41
- "eval_runtime": 1.454,
42
- "eval_samples_per_second": 1370.016,
43
- "eval_steps_per_second": 22.008,
44
  "epoch": 5.0
45
  }
46
  }
 
21
  "base_model": "jhu-clsp/mmBERT-base",
22
  "max_length": 512,
23
  "use_lora": true,
24
+ "lora_rank": 32,
25
+ "lora_alpha": 64,
26
  "class_weights": [
27
  1.0,
28
  1.0,
 
30
  1.0
31
  ],
32
  "metrics": {
33
+ "eval_loss": 0.060757871717214584,
34
+ "eval_accuracy": 0.9819095477386934,
35
+ "eval_f1_macro": 0.9729965135266696,
36
+ "eval_f1_weighted": 0.9818680631789307,
37
+ "eval_f1_SAT": 0.999664767013074,
38
+ "eval_f1_NEED_CLARIFICATION": 0.996,
39
+ "eval_f1_WRONG_ANSWER": 0.9474747474747475,
40
+ "eval_f1_WANT_DIFFERENT": 0.9488465396188566,
41
+ "eval_runtime": 1.2344,
42
+ "eval_samples_per_second": 2418.084,
43
+ "eval_steps_per_second": 19.442,
44
  "epoch": 5.0
45
  }
46
  }