Downloads · 30 days
71
4% of all-time downloads
sadjava/multilingual-hate-speech-xlm-roberta
multilingual-hate-speech-xlm-roberta is a text classification model from sadjava. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as mit.
This is a fine-tuned XLM-RoBERTa model for multilingual hate speech detection, specifically trained on English and Serbian text. The model classifies text into 8 categories:
Downloads · 30 days
71
4% of all-time downloads
All-time downloads
1.8K
Public
Parameters
278M
1.1 GB on disk
Likes
3
Public
Click a slice to open those files.
.safetensors1.1 GB · 98%
From the Hugging Face model README
This is a fine-tuned XLM-RoBERTa model for multilingual hate speech detection, specifically trained on English and Serbian text. The model classifies text into 8 categories:
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("sadjava/multilingual-hate-speech-xlm-roberta")
model = AutoModelForSequenceClassification.from_pretrained("sadjava/multilingual-hate-speech-xlm-roberta")
# Example prediction
text = "Your text here"
inputs = tokenizer(text, return_tensors="pt", truncation=True, padding=True)
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
# Categories
categories = ["Race", "Sexual Orientation", "Gender", "Physical Appearance",
"Religion", "Class", "Disability", "Appropriate"]
# Get predicted category
predicted_class = torch.argmax(predictions, dim=-1).item()
predicted_category = categories[predicted_class]
confidence = float(predictions[0][predicted_class])
print(f"Category: {predicted_category}")
print(f"Confidence: {confidence:.2%}")
The model was fine-tuned on multilingual hate speech datasets including:
This model is designed for research and educational purposes. Results should be interpreted carefully and human judgment should always be applied for critical decisions. The system is designed to assist, not replace, human moderation.
If you use this model, please cite:
@misc{multilingual-hate-speech-xlm-roberta,
author = {sadjava},
title = {Multilingual Hate Speech Detector},
year = {2024},
publisher = {Hugging Face},
url = {https://huggingface.co/sadjava/multilingual-hate-speech-xlm-roberta}
}
Try the interactive demo: Multilingual Hate Speech Detector Space