Downloads · 30 days
1
7% of all-time downloads
Anchar21/Hate-Speech-Detector-XLM-RoBERTa
Hate-Speech-Detector-XLM-RoBERTa is a text classification model from Anchar21. Use it when you need a label for a piece of text. The card lists the license as mit.
Multilingual toxic comment classification model fine-tuned on English and Russian datasets.
Downloads · 30 days
1
7% of all-time downloads
All-time downloads
14
Public
Repo size
3.3 GB
Likes
0
Public
Click a slice to open those files.
.pt3.3 GB · 100%
From the Hugging Face model README
Multilingual toxic comment classification model fine-tuned on English and Russian datasets.
xlm-roberta-baseEnglish:
Russian:
import torch
from transformers import AutoTokenizer
from huggingface_hub import hf_hub_download
# Download model
model_path = hf_hub_download(
repo_id="Anchar21/Hate-Speech-Detector-XLM-RoBERTa",
filename="model.pt"
)
# Load model architecture (you need BertClassifier class)
from your_module import BertClassifier
model = BertClassifier(
model_name="xlm-roberta-base",
num_labels=2,
dropout=0.1
)
# Load weights
checkpoint = torch.load(model_path, map_location='cpu')
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Tokenizer
tokenizer = AutoTokenizer.from_pretrained("xlm-roberta-base")
# Inference
text = "Your text here"
encoding = tokenizer(
text,
max_length=128,
padding='max_length',
truncation=True,
return_tensors='pt'
)
with torch.no_grad():
logits = model(encoding['input_ids'], encoding['attention_mask'])
probs = torch.softmax(logits, dim=1)
pred = torch.argmax(logits, dim=1)
print(f"Prediction: {'non-toxic', 'toxic'}[pred.item()]")
print(f"Confidence: {probs[0][pred].item():.3f}")
@misc{xlm-roberta-hate-speech-en-ru,
author = {Anchar21},
title = {XLM-RoBERTa Hate Speech Detector},
year = {2026},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Anchar21/Hate-Speech-Detector-XLM-RoBERTa}}
}
MIT