This model card documents the fine-tuned PhoBERT model trained with Easy Data Augmentation (EDA) for Vietnamese Hate Speech Detection (HSD) on social media content. It forms part of an empirical study investigating the effect of rule-based lexical perturbations on transformer-based classifiers under severe class imbalance.
vi)vinai/phobert-baseeda, split: eda_segmented)The model classifies Vietnamese social comments and posts into three categorical toxicity levels:
0 - CLEAN: Benign, constructive, or neutral expressions.1 - OFFENSIVE: Vulgar, abrasive, or impolite statements without systemic discriminatory intent.2 - HATE: Hostile, derogatory, or discriminatory statements targeted against protected social, ethnic, religious, or gender identities.Automated social media moderation, content triage systems, and empirical evaluation of lexical perturbation robustness in low-resource Vietnamese NLP.
Predictions near decision boundaries should undergo confidence scoring and human-in-the-loop review.
Input text must be word-segmented (compound words joined with _) prior to tokenization.
from transformers import pipeline
import pyvi
classifier = pipeline(
"text-classification",
model="AnoraLee/vietnamese-hsd-phobert-eda",
tokenizer="AnoraLee/vietnamese-hsd-phobert-eda"
)
raw_text = "Thời tiết hôm nay thật đẹp!"
segmented_text = pyvi.ViTokenizer.tokenize(raw_text)
result = classifier(segmented_text)
print(result)
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import pyvi
MODEL_ID = "AnoraLee/vietnamese-hsd-phobert-eda"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSequenceClassification.from_pretrained(MODEL_ID)
text = "Đồ vô dụng, biến đi cho khuất mắt tao."
text_segmented = pyvi.ViTokenizer.tokenize(text)
inputs = tokenizer(text_segmented, return_tensors="pt", max_length=128, truncation=True)
with torch.no_grad():
logits = model(**inputs).logits
predicted_class_id = torch.argmax(logits, dim=-1).item()
print("Predicted Label:", model.config.id2label[predicted_class_id])
The model was trained on the augmented training partition generated via Easy Data Augmentation (EDA), derived from BonTori/ViHatePhoBERT-TDTU:
eda (split: eda_segmented, 125,124 samples).protected_keys) to guarantee zero test leakage.The training corpus was expanded through four discrete operations applied to the minority classes (OFFENSIVE and HATE):
Text was segmented at compound word boundaries using VnCoreNLP.
vinai/phobert-baseweight_decay=0.01)macro_f1BonTori/ViHatePhoBERT-TDTU.The model was evaluated against the frozen test set to measure the exact impact of EDA compared to the unaugmented baseline:
| Metric | Baseline Score | EDA Augmented Score |
|---|---|---|
| Accuracy | 91.74% | (Điền kết quả test sau khi train hoàn tất) |
| Macro F1 | 67.74% | (Điền kết quả test sau khi train hoàn tất) |
| Weighted F1 | 91.24% | (Điền kết quả test sau khi train hoàn tất) |
| Hate F1 (Class 2) | 62.23% | (Điền kết quả test sau khi train hoàn tất) |
| Test Loss | 0.3204 | (Điền kết quả test sau khi train hoàn tất) |
(Lưu ý: Khi đợt huấn luyện trên Colab hoàn tất, bạn chỉ cần thay các chỉ số trong cột EDA Augmented Score bằng giá trị trong file metrics_eda.json xuất ra).
Sequence classification head stacked upon vinai/phobert-base, trained using categorical cross-entropy loss over 3 discrete classes.