Skip to main content

Overview

Guardian API uses four models working in parallel to provide comprehensive content moderation. Each model specializes in different aspects of harmful content detection.

Model 1: Sexism Classifier

LASSO Regression Model

Custom-trained binary classifier for sexism detection

Technical Details

Feature Engineering

The model uses a combination of text and numerical features:
CountVectorizer Configuration:
  • max_features: 2,500
  • ngram_range: (1, 2)
  • min_df: 2 (minimum document frequency)
  • max_df: 0.8 (maximum document frequency)
  • stop_words: English (with gendered words preserved)
Preserved Gendered Words:
  • Pronouns: he, him, she, her, etc.
  • Nouns: man, woman, men, women, boy, girl
  • Important for detecting sexist language patterns

Prediction Process

Output Format

Model 2: Toxicity Transformer

HuggingFace Transformer

Multi-label toxicity detection using RoBERTa

Technical Details

Toxicity Categories

The model detects 7 categories of toxicity:

Overall Toxicity

General toxic language score

Severe Toxicity

Extremely harmful content

Obscene

Vulgar or obscene language

Threat

Threatening language

Insult

Personal insults and attacks

Identity Attack

Attacks on identity groups

Sexual Explicit

Sexually explicit content

Device Management

The toxicity model automatically uses GPU if available:
Performance Comparison:
  • GPU (RTX 4050): ~10-15ms per request
  • CPU: ~40-60ms per request
Memory Usage:
  • GPU: ~2GB VRAM
  • CPU: ~1GB RAM

Output Format

The overall score is automatically set to at least the maximum of all sub-category scores.

Model 3: Rule Engine

Heuristic-Based System

Pattern matching and rule-based detection

Technical Details

Rule Categories

File: backend/app/models/rules/slurs.jsonDetection: Exact word matching (case-insensitive)Purpose: Identify hate speech and slursFormat:

Output Format

Customization

Adding new rules is straightforward:
1

Edit JSON File

Navigate to backend/app/models/rules/ and edit the appropriate JSON file
2

Add Your Rules

  • For slurs/profanity: Add words to the array
  • For threats: Add regex patterns
  • For self-harm: Add phrases
3

Restart API

The API will automatically load the new rules on startup

Model 4: Ensemble

Aggregation Layer

Combines outputs from all three models
The ensemble model performs intelligent fusion of all model outputs. See Ensemble for details.

Model Comparison

Next Steps

Ensemble

Learn how models are combined

Response Structure

Understand API responses

Configuration

Configure model settings

API Reference

Try the API