Downloads · 30 days
18
21% of all-time downloads
archich/hate-speech-detector
hate-speech-detector is a text classification model from archich. Use it when you need a label for a piece of text. The card lists the license as mit.
Multilingual hate speech detection model fine-tuned on HASOC 2019 dataset.
Downloads · 30 days
18
21% of all-time downloads
All-time downloads
85
Public
Parameters
278M
5.6 GB on disk
Likes
0
Public
Click a slice to open those files.
.pth4.5 GB · 80%
From the Hugging Face model README
Multilingual hate speech detection model fine-tuned on HASOC 2019 dataset.
This model detects hate speech in English and Hindi text using XLM-RoBERTa base as the backbone.
Languages: English, Hindi
Task: Binary Text Classification (Hate Speech / Not Hate Speech)
Base Model: xlm-roberta-base
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained("archich/hate-speech-detector")
model = AutoModelForSequenceClassification.from_pretrained("archich/hate-speech-detector")
# Example text
text = "Your text here"
# Tokenize
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=256)
# Predict
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
prediction = torch.argmax(probs, dim=1).item()
labels = ["NOT_HATE_SPEECH", "HATE_SPEECH"]
print(f"Prediction: {labels[prediction]} ({probs[0][prediction].item():.2%} confidence)")
Trained on HASOC 2019 (Hate Speech and Offensive Content Identification) dataset containing:
0: NOT_HATE_SPEECH - Normal, non-offensive content1: HATE_SPEECH - Hateful or offensive content (HOF)⚠️ Important Notice:
Training details and metrics available in model files.
If you use this model, please cite:
@misc{hate-speech-detector,
author = {archich},
title = {Multilingual Hate Speech Detector},
year = {2024},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/archich/hate-speech-detector}}
}