Hate Speech Detection
Collection
6 items
•
Updated
BARTpho fine-tuned cho bài toán phân loại Hate Speech tiếng Việt.
| Metric | Score |
|---|---|
| Accuracy | 0.8985 |
| F1 Macro | 0.6791 |
| F1 Weighted | 0.8886 |
BARTpho fine-tuned cho bài toán phân loại Hate Speech tiếng Việt. Model này được fine-tune từ vinai/bartpho-syllable-base trên dataset ViHSD (Vietnamese Hate Speech Dataset).
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
model_name = "visolex/hate-speech-bartpho"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
# Classify text
text = "Văn bản tiếng Việt cần phân loại"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_label = torch.argmax(predictions, dim=-1).item()
# Label mapping
label_names = {
0: "CLEAN",
1: "OFFENSIVE",
2: "HATE"
}
print(f"Predicted label: {label_names[predicted_label]}")
print(f"Confidence scores: {predictions[0].tolist()}")
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="visolex/hate-speech-bartpho",
tokenizer="visolex/hate-speech-bartpho"
)
result = classifier("Văn bản tiếng Việt cần phân loại")
print(result)
Model được đánh giá trên test set của ViHSD với các metrics:
This model is distributed under the MIT License.
Base model
vinai/bartpho-syllable-base