uitnlp/vihsd
Viewer • Updated • 33.4k • 261 • 6
How to use BaoNhan/cafebert-ViHSD with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="BaoNhan/cafebert-ViHSD") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("BaoNhan/cafebert-ViHSD")
model = AutoModelForSequenceClassification.from_pretrained("BaoNhan/cafebert-ViHSD", device_map="auto")This model is uitnlp/CafeBERT fine-tuned for ViHSD hate speech detection on ViHSD.
Metrics are reported as mean ± sample standard deviation over the available completed seeds.
| Metric | Mean ± std |
|---|---|
| Test Macro-F1 | 0.6430 ± 0.0197 |
| Test accuracy | 0.8739 ± 0.0064 |
| Test macro precision | 0.6718 ± 0.0203 |
| Test macro recall | 0.6312 ± 0.0160 |
| Development Macro-F1 | 0.6530 ± 0.0118 |
| seed | dev_macro_f1 | test_macro_f1 | test_accuracy |
|---|---|---|---|
| 22.000000 | 0.666226 | 0.656446 | 0.877246 |
| 42.000000 | 0.649098 | 0.620422 | 0.866467 |
| 202.000000 | 0.643704 | 0.652192 | 0.877994 |
{
"0": "CLEAN",
"1": "OFFENSIVE",
"2": "HATE"
}
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
model_id = "BaoNhan/cafebert-ViHSD"
tokenizer = AutoTokenizer.from_pretrained(model_id, use_fast=False)
model = AutoModelForSequenceClassification.from_pretrained(model_id)
text = "Đây là nội dung tiếng Việt cần phân loại."
inputs = tokenizer(
text,
return_tensors="pt",
truncation=True,
max_length=256,
)
with torch.no_grad():
probabilities = model(**inputs).logits.softmax(dim=-1)[0]
predicted_id = int(probabilities.argmax())
print(model.config.id2label[predicted_id], probabilities.tolist())
ViHSD is class-imbalanced and reflects Vietnamese social-media language from a particular collection period. Performance may not transfer directly to new platforms, dialects, code-switching patterns, irony, or emerging slang. Predictions should not be the sole basis for moderation or punitive decisions.
@InProceedings{10.1007/978-3-030-79457-6_35,
author={Luu, Son T. and Nguyen, Kiet Van and Nguyen, Ngan Luu-Thuy},
title={A Large-Scale Dataset for Hate Speech Detection on Vietnamese Social Media Texts},
booktitle={Advances and Trends in Artificial Intelligence. Artificial Intelligence Practices},
year={2021},
publisher={Springer International Publishing},
pages={415--426},
doi={10.1007/978-3-030-79457-6_35}
}
Base model
uitnlp/CafeBERT