Designing a Content Moderation System for Prohibited Videos
Machine LearningModel answerLast updated
Design a production pipeline to detect harmful video content at scale, handling extreme imbalance, adversarial evasion, and human review workflows.
Context
Your platform hosts user-uploaded videos and needs to automatically identify content that violates platform policies. The system processes millions of daily uploads, but harmful content represents less than 0.01% of total volume. Malicious uploaders actively attempt to evade detection using techniques like frame manipulation, audio distortion, and re-encoding.
Your Task
Design an end-to-end machine learning system that classifies videos as violating, safe, or requiring manual review. Address these components:
1. Multimodal Design
Explain how you would architect a classifier that processes video frames, audio streams, and accompanying metadata (uploader history, title, tags). How should these signals be combined?
2. Handling Data Challenges
The training data suffers from severe class imbalance (harmful content is extremely rare), label noise from human annotators, and adversarial examples designed to fool detectors. Describe your training approach.
3. Review Workflow
You have limited human moderator capacity—perhaps 5,000 reviews per day. Design a policy that routes content to automatic approval, automatic blocking, or human review queues.
4. Production Monitoring
What metrics would you track beyond standard classification measures? How do you detect when the model is degrading or when adversaries are evolving their tactics?
Constraints
- Initial screening decisions must complete within 500ms
- Privacy regulations prohibit long-term storage of non-violating content
- False positives damage user trust; missed violations cause platform harm
Expected Output Format
For a given video upload, your system should return:
- A probability score indicating likelihood of violation
- A routing decision: Auto-approve, Auto-block, or Send-to-review
- Explanatory signals (which modality triggered the flag)
- Model version for auditability
Hints
Hint 1
Start by quantifying the scale: at 0.01% prevalence with millions of uploads, even 99.9% specificity yields many false positives. Precision becomes more critical than recall.
Hint 2
Consider a multi-stage cascade: cheap filters first (hash lookups, lightweight models) that catch obvious cases, then expensive deep learning only on suspicious content.
Hint 3
Train your encoders to be invariant to adversarial transformations—use augmentations that mirror real evasion tactics during pretraining.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer: Content Moderation System Design
This problem tests your ability to build a practical ML system under operational constraints. A strong answer demonstrates quantitative reasoning about trade-offs, not just model architecture choices.
1. Establish Scale and Constraints
Begin by anchoring the discussion with numbers:
- Upload volume: 5 million videos/day ≈ 60/sec average, with peaks potentially 3-4× higher
- Prevalence: At 0.01%, expect roughly 500 true violations daily
- The precision problem: A 99.9% specific classifier generates ~5,000 false positives/day—10× the true positive count. This means precision is the bottleneck, not AUC or recall.
- Moderator budget: Assume 5,000 human reviews/day available
- Latency target: 500ms for initial decision; heavier analysis can run asynchronously
- Storage: Cannot retain raw media for non-violating content beyond a short window
These constraints immediately suggest a staged architecture rather than a single monolithic model.
2. System Architecture: Multi-Stage Cascade
Stage 0: Hash-Based Matching (10-20ms)
- Compute perceptual hashes for video frames (using techniques like pHash or PDQ) and audio fingerprints
- Query a database of known-violating content using approximate nearest neighbor search
- Direct matches lead to immediate blocking—catches re-uploads, which comprise most evasion attempts
- Perceptual hashes survive minor transformations: compression, resizing, cropping, slight blur
Stage 1: Lightweight Screener (200-300ms)
- Sample 6-8 keyframes; pass through a small image encoder (e.g., distilled ResNet or EfficientNet)
- Extract audio features from 5-10 second windows (mel-spectrograms through a lightweight CNN)
- Compute metadata features: account age, prior strikes, upload velocity, content of title/description (via text embeddings)
- Combine through a gradient-boosted tree or small feedforward network
- Tune for 99%+ recall: this stage forwards only 1-2% of traffic to the expensive model
- Most content receives approval here
Stage 2: Deep Multimodal Model (2-5 seconds, asynchronous)
- Dense frame sampling + full audio track + OCR from frames + speech-to-text transcript + metadata
- Content distribution is throttled until this completes
- Feeds the human review triage system
Why a cascade? Economics. Running deep models on every upload at 60/sec is prohibitively expensive. The cascade concentrates compute where it matters while maintaining low latency for the common case.
3. Multimodal Fusion Strategy
Three fusion approaches exist:
Early fusion (concatenate raw features): Brittle when modalities are missing or deliberately removed by adversaries.
Late fusion (average per-modality scores): Robust but misses cross-modal patterns, like benign visuals paired with violating audio commentary.
Mid-level fusion (recommended):
- Each modality encoder produces a sequence of token embeddings
- A fusion transformer with modality-type embeddings attends across all tokens
- Use a [CLS] token for final classification
- Critical technique: Train with modality dropout—randomly zero out entire modalities during training so the model degrades gracefully when adversaries strip audio or overlay content
- Maintain auxiliary heads per modality for interpretability ("flagged due to audio content")
Adversarial robustness: Pretrain encoders with contrastive learning where positive pairs are original/augmented versions. Augmentations mirror real evasion tactics:
- Video: crop, flip, blur, speed shifts (0.9×-1.1×), color adjustment, picture-in-picture, overlays, compression artifacts
- Audio: pitch shift, background noise, speed change, amplitude scaling
- Goal: embeddings become invariant to transformations attackers use
4. Training Strategy for Imbalanced, Noisy Data
Handling class imbalance:
- Never train at natural prevalence—downsample negatives to perhaps 1:100 ratio
- Use focal loss or class weights to emphasize hard examples
- Crucially: Recalibrate probabilities afterward using isotonic regression or Platt scaling on a held-out set at true prevalence, since threshold decisions depend on accurate probabilities
Hard negative mining:
- Curate challenging benign classes: educational content, news footage, medical videos, sports, film clips
- Each training iteration, mine high-scoring false positives from recent moderator decisions
- Find nearest benign neighbors to true positives in embedding space and upweight them
Noisy labels:
- Collect multiple annotations on ambiguous cases; use agreement rate as soft labels
- Weight training examples by annotator reliability (track per-rater accuracy over time)
- Maintain a gold-standard evaluation set reviewed by experts, never used for training
- Consider co-teaching or small-loss sample selection to downweight likely mislabeled examples
Sparse positive examples:
- Self-supervised pretraining on the unlabeled upload stream to learn general video representations
- Conservative pseudo-labeling: only augment training data with very high-confidence predictions
Adversarial robustness:
- Augment with transformations observed in the wild
- Conduct red-team exercises to generate evasive variants
- When moderators catch clusters of evasive content the model missed, feed those back as training positives immediately
5. Human-in-the-Loop Triage Policy
Use an expected cost framework rather than a single threshold. Let p be the calibrated probability score.
Auto-block: p ≥ τ_high (e.g., 0.95)
- Choose τ_high to ensure measured precision ≥ 99% based on recent audit data
- Allow appeals with expedited human review
- Hash matches also route here
Auto-approve: p < τ_low (e.g., 0.02)
- Choose τ_low such that estimated miss rate stays within tolerance
- Most content (98%+) receives approval
Human review queue: τ_low ≤ p < τ_high
- Rank by
p × severity_weight × expected_reach - Expected reach estimated from uploader's audience size and early view velocity—viral content jumps the queue
- Size the thresholds so daily queue volume matches moderator capacity
- If backlog grows, temporarily throttle distribution of queued content (never auto-approve to clear backlog)
Unbiased monitoring: Randomly sample 1-2% from auto-approved and auto-blocked sets for audit. This is the only way to measure true recall and precision at the extremes, since you otherwise never see what you approved incorrectly.
Active learning: Reserve 5-10% of review capacity for uncertainty/diversity sampling rather than pure top-score items. This prevents confirmation bias from only labeling content the model already flags.
6. Operational Metrics
Beyond accuracy, track:
Harm metrics:
- Violating view rate: (views of violating content before removal) / (total views)
- Time from upload to action (detection latency)
- Recall estimated from random audits
False positive impact:
- Precision at auto-block threshold
- Appeal overturn rate (% of auto-blocks overturned on appeal)
- False positive rate sliced by creator size, region, language
- Creator churn after wrongful blocks
Model health:
- Score distribution drift (Population Stability Index or KL divergence) across segments
- Embedding space drift over time
- Calibration error (Expected Calibration Error) on fresh audit sets
- Moderator-model agreement rate
Adversarial drift:
- Fraction of catches from hash matching vs. ML model (decreasing model share suggests evasion)
- Near-duplicate cluster growth (many slight variants of same content)
- Time-to-catch for new violation types
- Manual review volume trend (increasing suggests model degradation)
Operational:
- Stage 1/2 latency p50, p99
- Queue depth and age
- Moderator throughput and review quality (inter-rater agreement)
Set up dashboards with drill-down by content type, geography, and time. Automated alerts trigger when metrics exceed thresholds, prompting model retraining or policy adjustment.
7. Common Mistakes to Avoid
- Optimizing AUC on the natural distribution (AUC looks great but precision is terrible)
- Training without calibration, then setting thresholds on uncalibrated scores
- Not accounting for adversarial data shift—the distribution under attack differs from passive uploads
- Ignoring the moderator feedback loop as a source of training signal
- Overlooking privacy constraints (storing raw violating content indefinitely)
- No plan for handling modality-missing cases (audio stripped, silent videos)
This system design balances multiple objectives: harm reduction, user experience, cost, moderator wellbeing, and adversarial robustness. Success requires continuous monitoring and rapid iteration as both content and evasion tactics evolve.