Instructions to use Sheshank2609/content-moderation-distilbert with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Sheshank2609/content-moderation-distilbert with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Sheshank2609/content-moderation-distilbert")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Sheshank2609/content-moderation-distilbert") model = AutoModelForSequenceClassification.from_pretrained("Sheshank2609/content-moderation-distilbert", device_map="auto") - Notebooks
- Google Colab
- Kaggle
π‘οΈ Content Moderation Model (DistilBERT Fine-Tuned)
Model Description
This model is based on DistilBERT and fine-tuned on the Jigsaw Toxic Comment Classification dataset for multi-label content moderation.
It can detect multiple forms of toxic or harmful language in English comments, including:
- toxic
- severe_toxic
- obscene
- threat
- insult
- identity_hate
- safe (added when no toxic categories apply)
DistilBERT is a smaller, faster version of BERT while retaining most of its performance, making it suitable for real-time moderation tasks.
π·οΈ Intended Use
- Moderating online communities (forums, chat apps, social media).
- Filtering toxic comments in user-generated text.
- Educational and research purposes.
β οΈ Not for production without further evaluation. Models may misclassify sarcasm, slang, or subtle harassment. Always use human moderators for critical cases.
π Training Details
- Base model:
distilbert-base-uncased - Dataset: Jigsaw Toxic Comment Classification
- Task: Multi-label classification (comments can have multiple labels).
- Labels: toxic, severe_toxic, obscene, threat, insult, identity_hate, safe
- Hyperparameters:
- Batch size: 16 (train), 32 (eval)
- Learning rate: 1e-5
- Epochs: 5
- Weight decay: 0.01
- Metric: Macro-F1
π Evaluation Results
Validation performance (held-out split):
- Macro-F1 Score: ~0.91
- Training loss stabilized around ~0.14
- Validation loss ~0.15
β
Strong at detecting direct insults and threats.
β οΈ Struggles with sarcasm or subtle negativity.
π How to Use
from transformers import pipeline
classifier = pipeline(
"text-classification",
model="your-username/content-moderation-distilbert",
tokenizer="your-username/content-moderation-distilbert",
return_all_scores=True,
function_to_apply="sigmoid" # multi-label classification
)
texts = [
"You are an amazing person and I respect you.",
"I hate you, you are disgusting!",
"I will not kill you tomorrow"
]
for t in texts:
preds = classifier(t)
print(f"\nInput: {t}")
for label in preds[0]:
print(f"{label['label']}: {label['score']:.3f}")
- Downloads last month
- 2
Model tree for Sheshank2609/content-moderation-distilbert
Base model
distilbert/distilbert-base-uncased