tridm/UIT-VSMEC
Viewer • Updated • 6.93k • 517 • 4
How to use aabcv/visobert-vsmec-moderation with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="aabcv/visobert-vsmec-moderation") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("aabcv/visobert-vsmec-moderation")
model = AutoModelForSequenceClassification.from_pretrained("aabcv/visobert-vsmec-moderation", device_map="auto")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:
Enjoyment, Disgust, Sadness, Anger, Fear, Surprise, Other.EnjoymentSadness, Disgust, Anger, FearOther, Surpriseheld) trước khi kịp hiển thị công khai.| 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 |
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...}]
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%})")