ViSoBERT for Vietnamese Emotion Recognition & Comment Moderation (UIT-VSMEC)
Mô hình ViSoBERT (uitnlp/visobert) được huấn luyện tinh chỉnh (fine-tuned) trên bộ ngữ liệu UIT-VSMEC (Vietnamese Social Media Emotion Corpus), phục vụ 3 mục đích:
- Phân loại 7 sắc thái cảm xúc:
Enjoyment,Disgust,Sadness,Anger,Fear,Surprise,Other. - Quy đổi Sắc thái (Sentiment):
- Tích cực (Positive):
Enjoyment - Tiêu cực (Negative):
Sadness,Disgust,Anger,Fear - Trung tính (Neutral):
Other,Surprise
- Tích cực (Positive):
- Kiểm duyệt tự động bình luận độc hại / vi phạm tiêu chuẩn cộng đồng (HuTube Video Platform):
- Tối ưu hóa ngưỡng xác suất độc hại: $P(\text{Anger}) + P(\text{Disgust}) \ge 0.20$.
- Tự động chuyển các bình luận xúc phạm, thù ghét vào hàng đợi kiểm duyệt (
held) trước khi kịp hiển thị công khai.
📊 Kết quả đánh giá trên tập Test (UIT-VSMEC)
1. Kiểm duyệt bình luận độc hại (Toxic Moderation):
- Accuracy tổng thể: 81.5%
- Độ nhạy bắt độc hại (Recall - Toxic): 75.6%
- Độ tin cậy bình luận an toàn (Precision - Clean): 91.2% (giảm hơn 50% tỉ lệ bắt nhầm bình luận lành mạnh)
2. Phân loại 3 Sắc thái (Sentiment):
| Sắc thái | Precision | Recall | F1-score | Số lượng mẫu |
|---|---|---|---|---|
| Tiêu cực (Negative) | 0.772 | 0.841 | 0.805 | 334 |
| Tích cực (Positive) | 0.668 | 0.679 | 0.674 | 193 |
| Trung tính (Neutral) | 0.669 | 0.536 | 0.595 | 166 |
| Toàn bộ (Accuracy) | 72.3% | 693 |
3. Phân loại chi tiết 7 cảm xúc:
- Macro F1: 0.577
- Weighted F1: 0.596
- Accuracy: 60.2%
🚀 Hướng dẫn sử dụng
Sử dụng qua pipeline (Đơn giản nhất):
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="aabcv/visobert-vsmec-moderation"
)
text = "Video này rất hữu ích, cảm ơn bạn nhiều nhé!"
result = classifier(text)
print(result)
# [{'label': 'Enjoyment', 'score': 0.985...}]
Sử dụng qua PyTorch & AutoModel:
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
MODEL_ID = "aabcv/visobert-vsmec-moderation"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
text = "Video xàm vcl lừa đảo quá, cút đi thằng ad ngu ngốc"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=128)
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1).squeeze().tolist()
labels = ["Enjoyment", "Disgust", "Sadness", "Anger", "Fear", "Surprise", "Other"]
for label, prob in zip(labels, probs):
print(f"{label:10s}: {prob:.4f}")
# Kiểm tra điều kiện độc hại cho hệ thống kiểm duyệt
p_toxic = probs[1] + probs[3] # Disgust + Anger
is_toxic = p_toxic >= 0.20
print(f"Bình luận độc hại: {is_toxic} (Xác suất toxic: {p_toxic:.2%})")