Text Classification
Transformers
Safetensors
Persian
bert
persian
farsi
offensive-language-detection
content-moderation
parsbert
text-embeddings-inference
Instructions to use HamidRezaei/Persian-Offensive-Language-Detection with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HamidRezaei/Persian-Offensive-Language-Detection with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="HamidRezaei/Persian-Offensive-Language-Detection")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("HamidRezaei/Persian-Offensive-Language-Detection") model = AutoModelForSequenceClassification.from_pretrained("HamidRezaei/Persian-Offensive-Language-Detection", device_map="auto") - Notebooks
- Google Colab
- Kaggle
🛡️ 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