File size: 5,691 Bytes
a4d5b89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66162a0
 
a4d5b89
66162a0
 
 
a4d5b89
 
 
 
 
 
 
 
 
 
 
 
 
 
66162a0
a4d5b89
 
 
66162a0
a4d5b89
66162a0
a4d5b89
 
 
 
 
 
66162a0
a4d5b89
66162a0
 
a4d5b89
66162a0
 
a4d5b89
 
 
 
 
 
 
 
 
 
 
66162a0
 
 
a4d5b89
 
 
 
66162a0
 
a4d5b89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66162a0
 
 
a4d5b89
 
66162a0
 
a4d5b89
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66162a0
a4d5b89
 
 
 
 
66162a0
a4d5b89
66162a0
a4d5b89
 
 
 
66162a0
a4d5b89
66162a0
a4d5b89
 
 
 
66162a0
 
 
 
 
 
a4d5b89
66162a0
 
 
 
 
 
 
 
 
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
---
base_model: llm-semantic-router/mmbert-32k-yarn
license: apache-2.0
language:
- en
- zh
- fr
- es
- multilingual
tags:
- text-classification
- feedback-detection
- user-satisfaction
- transformers
- modernbert
- mmbert
- 32k-context
datasets:
- llm-semantic-router/feedback-detector-dataset
metrics:
- accuracy
- f1
pipeline_tag: text-classification
model-index:
- name: mmbert32k-feedback-detector-merged
  results:
  - task:
      type: text-classification
      name: User Feedback Classification
    dataset:
      name: feedback-detector-dataset
      type: llm-semantic-router/feedback-detector-dataset
    metrics:
    - name: Accuracy
      type: accuracy
      value: 0.9883
    - name: F1 (macro)
      type: f1
      value: 0.9824
---

# mmBERT-32K Feedback Detector (Merged)

A 4-class user feedback classifier based on [mmbert-32k-yarn](https://huggingface.co/llm-semantic-router/mmbert-32k-yarn). This is the **merged** version with LoRA weights integrated - no PEFT library required.

## Model Description

This model classifies user messages into 4 feedback categories to help conversational AI systems understand user satisfaction:

| Label | ID | Description |
|-------|:--:|-------------|
| **SAT** | 0 | User is satisfied with the response |
| **NEED_CLARIFICATION** | 1 | User needs more explanation or details |
| **WRONG_ANSWER** | 2 | User indicates the response was incorrect |
| **WANT_DIFFERENT** | 3 | User wants an alternative approach/answer |

## Performance

**Validation Results (2,985 samples):**

| Metric | Value |
|--------|-------|
| **Accuracy** | **98.83%** |
| **F1 (macro)** | **98.24%** |
| **F1 (weighted)** | **98.83%** |

**Per-Class Performance:**

| Class | Precision | Recall | F1-Score | Support |
|-------|-----------|--------|----------|---------|
| SAT | 1.0000 | 1.0000 | 1.0000 | 1,491 |
| NEED_CLARIFICATION | 0.9980 | 0.9980 | 0.9980 | 498 |
| WRONG_ANSWER | 0.9604 | 0.9739 | 0.9671 | 498 |
| WANT_DIFFERENT | 0.9715 | 0.9578 | 0.9646 | 498 |

## Quick Start

```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch

# Load model and tokenizer
model = AutoModelForSequenceClassification.from_pretrained(
    "llm-semantic-router/mmbert32k-feedback-detector-merged"
)
tokenizer = AutoTokenizer.from_pretrained(
    "llm-semantic-router/mmbert32k-feedback-detector-merged"
)
model.eval()

# Label mapping
labels = ["SAT", "NEED_CLARIFICATION", "WRONG_ANSWER", "WANT_DIFFERENT"]

# Example inference
texts = [
    "Thank you, that's exactly what I needed!",
    "I don't understand, can you explain more?",
    "That's incorrect, the answer should be different.",
    "Can you give me another approach?",
]

for text in texts:
    inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
    with torch.no_grad():
        outputs = model(**inputs)
    
    probs = torch.softmax(outputs.logits, dim=-1)
    pred = outputs.logits.argmax(-1).item()
    conf = probs[0][pred].item()
    
    print(f"{labels[pred]:20} ({conf:.1%}) | {text}")
```

**Output:**
```
SAT                  (81.2%) | Thank you, that's exactly what I needed!
NEED_CLARIFICATION   (100.0%) | I don't understand, can you explain more?
WRONG_ANSWER         (100.0%) | That's incorrect, the answer should be different.
WANT_DIFFERENT       (100.0%) | Can you give me another approach?
```

## Batch Inference

```python
# Efficient batch processing
texts = ["Your text 1", "Your text 2", "Your text 3"]
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True, max_length=512)

with torch.no_grad():
    outputs = model(**inputs)

predictions = outputs.logits.argmax(-1).tolist()
feedback_types = [labels[p] for p in predictions]
```

## Training Details

This model was fine-tuned using LoRA (Low-Rank Adaptation) with the following configuration:

| Parameter | Value |
|-----------|-------|
| Base Model | llm-semantic-router/mmbert-32k-yarn |
| LoRA Rank | 64 |
| LoRA Alpha | 128 |
| Learning Rate | 2e-5 |
| Batch Size | 16 |
| Epochs | 10 (early stopped at ~5.4) |
| Precision | bf16 |

### Training Data

- **Dataset**: [llm-semantic-router/feedback-detector-dataset](https://huggingface.co/datasets/llm-semantic-router/feedback-detector-dataset)
- **Training samples**: 17,896 (balanced)
- **Validation samples**: 2,985

### Hardware

- **GPU**: AMD Instinct MI300X
- **Training Time**: ~10 minutes

## Model Architecture

- **Architecture**: ModernBERT (Sequence Classification)
- **Parameters**: ~321M (base) with merged LoRA weights
- **Max Context**: 32,768 tokens (YaRN-scaled RoPE)
- **Hidden Size**: 768
- **Layers**: 22
- **Attention Heads**: 12

## Multilingual Support

Supports 1800+ languages via Glot500 tokenizer. Best performance on:
- English (primary)
- Chinese
- French  
- Spanish

## Use Cases

- **Conversational AI**: Detect user satisfaction in chatbots
- **Customer Support**: Route conversations based on feedback type
- **Quality Monitoring**: Track user satisfaction trends
- **Dialog Systems**: Trigger clarification or correction flows

## Comparison: LoRA vs Merged

| Version | Size | Requires PEFT | Use Case |
|---------|------|---------------|----------|
| [LoRA](https://huggingface.co/llm-semantic-router/mmbert32k-feedback-detector-lora) | ~54MB | Yes | Fine-tuning, research |
| **Merged** (this) | ~615MB | No | Production, inference |

## Citation

```bibtex
@misc{mmbert32k-feedback-detector,
  title={mmBERT-32K Feedback Detector},
  author={LLM Semantic Router Team},
  year={2026},
  publisher={Hugging Face},
  url={https://huggingface.co/llm-semantic-router/mmbert32k-feedback-detector-merged}
}
```

## License

Apache 2.0