Downloads · 30 days
13
36% of all-time downloads
yasmineelqorashy/reddit-moderator-model
reddit-moderator-model is a text classification model from yasmineelqorashy. Use it when you need a label for a piece of text. It is set up for peft. The card lists the license as apache-2.0.
A fine-tuned version of SmolLM2-360M-Instruct for Reddit content moderation. This model classifies text into 11 content safety categories with 4 severity levels each.
Downloads · 30 days
13
36% of all-time downloads
All-time downloads
36
Public
Repo size
30 MB
Likes
0
Public
Click a slice to open those files.
.json4.3 MB · 57%
From the Hugging Face model README
A fine-tuned version of SmolLM2-360M-Instruct for Reddit content moderation. This model classifies text into 11 content safety categories with 4 severity levels each.
This model performs multi-category content classification for moderation purposes. It analyzes text and provides severity ratings across 11 distinct content safety categories, making it ideal for content moderation pipelines and safety applications.
Training Method: LoRA (Low-Rank Adaptation) Base Model: SmolLM2-360M-Instruct Parameters: 360M (base) + 819K (LoRA adapter) Dataset: Reddit moderation examples with 11-category labels
The model classifies content across these 11 categories:
Severity Levels: none | low | medium | high
pip install transformers peft torch
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load model
base_model_name = "HuggingFaceTB/SmolLM2-360M-Instruct"
adapter_path = "YOUR_USERNAME/smollm2-reddit-moderator"
tokenizer = AutoTokenizer.from_pretrained(base_model_name)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_name,
device_map="auto",
torch_dtype=torch.float16
)
model = PeftModel.from_pretrained(base_model, adapter_path)
model.eval()
⚠️ The model requires this EXACT prompt format to work correctly:
def classify_comment(text):
# EXACT prompt format - do not modify!
prompt = f"""Classify this Reddit comment for content moderation.
Comment: {text}
Provide severity levels (high/medium/low/none) for each category."""
messages = [{"role": "user", "content": prompt}]
# Apply chat template
input_text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
# Generate with optimized settings
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=250,
temperature=0.3,
top_p=0.9,
do_sample=True,
pad_token_id=tokenizer.eos_token_id,
repetition_penalty=1.2
)
# Decode
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Extract assistant response
if "assistant" in response:
response = response.split("assistant")[-1].strip()
return response
# Example usage
comment = "You're an absolute idiot if you believe that nonsense."
result = classify_comment(comment)
print(result)
harassment: high
harassment_threatening: none
hate: medium
hate_threatening: none
self_harm: none
self_harm_instructions: none
self_harm_intent: none
sexual: none
sexual_minors: none
violence: none
violence_graphic: none
Input:
classify_comment("This is really helpful advice, thank you so much!")
Output:
harassment: none
harassment_threatening: none
hate: none
hate_threatening: none
self_harm: none
self_harm_instructions: none
self_harm_intent: none
sexual: none
sexual_minors: none
violence: none
violence_graphic: none
Input:
classify_comment("Get lost you piece of trash. Nobody wants you here.")
Output:
harassment: high
harassment_threatening: none
hate: medium
hate_threatening: none
self_harm: none
self_harm_instructions: none
self_harm_intent: none
sexual: none
sexual_minors: none
violence: low
violence_graphic: none
Input:
classify_comment("That's a damn good point, hadn't thought of it that way.")
Output:
harassment: none
harassment_threatening: none
hate: none
hate_threatening: none
self_harm: none
self_harm_instructions: none
self_harm_intent: none
sexual: none
sexual_minors: none
violence: none
violence_graphic: none
def parse_categories(response):
"""Parse model output into a dictionary"""
categories = {}
for line in response.split('\n'):
if ':' in line:
parts = line.split(':', 1)
if len(parts) == 2:
category = parts[0].strip().lower().replace('-', '_')
severity = parts[1].strip().lower()
categories[category] = severity
return categories
# Example usage
result = classify_comment("Some comment text here")
categories = parse_categories(result)
# Check for high-risk content
high_risk = [cat for cat, sev in categories.items() if sev == 'high']
if high_risk:
print(f"⚠️ High risk detected in: {', '.join(high_risk)}")
# Check for any concerning content
concerning = [cat for cat, sev in categories.items()
if sev in ['high', 'medium']]
if concerning:
print(f"🔍 Review needed for: {', '.join(concerning)}")
⚠️ Critical Settings for Best Results:
# Recommended generation parameters
outputs = model.generate(
**inputs,
max_new_tokens=250, # Enough for all 11 categories
temperature=0.3, # Low for consistent format
top_p=0.9, # Standard nucleus sampling
do_sample=True, # Enable sampling
pad_token_id=tokenizer.eos_token_id,
repetition_penalty=1.2 # Prevent repetition
)
✅ Recommended Applications:
❌ Not Recommended For:
Source: ifmain/text-moderation-01 Content: Reddit moderation examples with 11-category labels Format: Chat-style instruction tuning
q_proj, v_proj⚠️ Technical Limitations:
⚠️ Content & Ethical Considerations:
⚠️ Safety Considerations:
The model has been tested on its core task of 11-category classification with the following characteristics:
This model should NOT be used for:
Model Type: Causal Language Model (Fine-tuned for Classification) Language: English License: Apache 2.0 Base Model: HuggingFaceTB/SmolLM2-360M-Instruct Adapter Type: LoRA Task: Multi-category content classification
If you use this model, please cite:
@misc{smollm2-reddit-moderator,
author = {Your Name},
title = {SmolLM2 Reddit Content Classifier},
year = {2025},
publisher = {HuggingFace},
howpublished = {\url{https://huggingface.co/YOUR_USERNAME/smollm2-reddit-moderator}}
}
This model is a research and development tool designed to assist human moderators, not replace them. The model's outputs are predictions and may contain errors.
Critical Content Warning: For content flagged as high-risk in the following categories, immediate human review and intervention is required:
Always use this model responsibly and maintain human oversight in all moderation decisions.