This model card documents the fine-tuned PhoBERT model trained using Large Language Model (LLM) synthetic data augmentation for Vietnamese Hate Speech Detection (HSD). It forms part of an empirical investigation assessing how targeted generative text expansion addresses class imbalance in toxic social media classification.
vi)vinai/phobert-baseHATE and OFFENSIVE), combined with automated prefix cleaning and leakage filtering.llm)The model classifies Vietnamese social comments and community posts into three mutually exclusive toxicity categories:
0 - CLEAN: Constructive, neutral, or non-toxic statements.1 - OFFENSIVE: Vulgar, abrasive, or impolite statements devoid of targeted discriminatory animus.2 - HATE: Hostile, derogatory, or discriminatory attacks directed against protected demographic groups (e.g., ethnicity, regional identity, religion, sexual orientation).Automated social platform moderation, toxic content filtering pipelines, and comparative benchmarking of generative augmentation strategies for low-resource NLP.
Human moderators should remain involved for high-stakes decision-making. Threshold tuning on prediction probabilities is recommended based on the desired balance between precision and recall.
Input text must be word-segmented (compound words connected via _) prior to tokenization.
from transformers import pipeline
import pyvi
classifier = pipeline(
"text-classification",
model="AnoraLee/vietnamese-hsd-phobert-llm",
tokenizer="AnoraLee/vietnamese-hsd-phobert-llm"
)
raw_text = "Thời tiết hôm nay thật dễ chịu."
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-llm"
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 partition derived from BonTori/ViHatePhoBERT-TDTU:
default split).llm config.Compound word boundaries were segmented using VnCoreNLP. Synthetic prompt prefixes (e.g., prompt instruction artifacts generated during sample synthesis) were systematically sanitized prior to tokenization.
vinai/phobert-base (12 layers, 768 hidden dimensions, 12 attention heads)weight_decay=0.01)macro_f1BonTori/ViHatePhoBERT-TDTU.HATE).Empirical comparison against the unaugmented PhoBERT Baseline on the identical 9,633 test samples:
| Metric | PhoBERT Baseline | PhoBERT + LLM Augmentation | Delta |
|---|---|---|---|
| Test Accuracy | 91.74% | 91.32% | -0.42% |
| Test Macro F1 | 67.74% | 68.87% | +1.13% |
| Test Weighted F1 | 91.24% | 91.11% | -0.13% |
| Test Hate F1 (Class 2) | 62.23% | 63.10% | +0.87% |
| Test Loss | 0.3204 | 0.2630 | -0.0574 |
Training on the combined dataset augmented with 5,349 LLM instances achieved a +1.13% absolute increase in Macro F1 and a +0.87% increase in Hate F1 compared to the baseline. Furthermore, test loss decreased from 0.3204 to 0.2630, demonstrating stronger model confidence and improved generalization on minority toxic instances.
Sequence classification head stacked atop vinai/phobert-base, trained via cross-entropy loss over 3 discrete target classes.