🛡️ Persian Offensive Language Detection

Detects whether a Persian (Farsi) text is offensive or not offensive.

🚀 Quick Start

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

model_id = "HamidRezaei/Persian-Offensive-Language-Detection"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForSequenceClassification.from_pretrained(model_id)

text = "متن فارسی خود را اینجا بنویسید"
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=92)

with torch.no_grad():
    score = torch.sigmoid(model(**inputs).logits).item()

print("Offensive" if score >= 0.5 else "Not offensive", round(score, 3))

The model returns a score between 0 and 1. A score of 0.5 or higher means the text is offensive.

📝 Citation

If you use this model in your research, project or product, please cite it:

@misc{rezaei_persian_offensive_detection,
  author       = {Hamid Rezaei},
  title        = {Persian Offensive Language Detection},
  year         = {2024},
  publisher    = {Hugging Face},
  howpublished = {\url{https://huggingface.co/HamidRezaei/Persian-Offensive-Language-Detection}}
}

💬 Contact

Questions or feedback? Open a discussion in the Community tab.

Downloads last month
62
Safetensors
Model size
0.2B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Space using HamidRezaei/Persian-Offensive-Language-Detection 1