Design an automated content moderation system (Facebook/YouTube)

    An automated content-moderation system screens user uploads (text/image/video) for policy violations using multiple ML models, an orchestrating policy engine, and a human-in-the-loop for ambiguous cases.

    AI & Machine Learning, 8 components, about 35 min

    1. Scope

    In scope

    • • Multi-modal violation detection
    • • Policy decisions
    • • Human review for low confidence
    • • Feedback into training

    Out of scope

    • • Model training internals
    • • Appeals workflow UI
    • • Legal/regulatory specifics

    2. Functional requirements

    Must have

    • • Detect violations in text/image/video
    • • Auto-act on high confidence
    • • Route uncertain cases to humans
    • • Improve from human labels

    Nice to have

    • • Real-time pre-publish checks
    • • Severity tiers
    • • Multi-language

    3. Non-functional requirements

    LatencyReal-time check at upload; deep checks async
    RecallHigh — missing harmful content is costly
    PrecisionHigh enough to auto-act
    ThroughputAll uploads

    4. Back-of-envelope estimation

    Assumptions

    • • Millions of uploads/day
    • • Separate models per modality
    • • High-confidence auto-block
    • • Sample to human review

    Derived numbers

    Model invocationsMillions/day × modalities
    Human reviewSmall % (low-confidence)
    GPU fleetFor image/video models

    5. API design

    POST/api/moderate

    Submit content → { decision, confidence }

    6. High-level design

    What each box in the reference diagram is responsible for:

    Ingestion Svc — Receives uploads; fans out to modality models.
    NLP Mod (BERT) — Text classification (hate, spam, etc.).
    CV Mod (ViT) — Image classification (nudity, violence).
    Video Mod — Frame/clip-level video analysis.
    Policy Engine — Combines model signals + business rules → decision.
    Human Review Tool — Reviewers handle low-confidence cases.
    Violation DB — Records decisions + labels.

    7. Data model

    Violation DB: content_id → {scores, decision, reviewer}

    8. Deep dives

    Multi-modal detection

    Different content types need different models: BERT-style for text, ViT/CNN for images, 3D-CNN/frame-sampling for video. Each emits per-policy scores. A piece of content (e.g., a video with a caption) may run through several models in parallel.

    Policy engine & thresholds

    Raw model scores aren't decisions. The policy engine combines signals with business rules and per-policy thresholds: high confidence → auto-block; medium → limit/age-gate; low → allow or send to human. Thresholds tune the precision/recall trade-off per policy (e.g., be aggressive on CSAM, lenient on borderline spam).

    Human-in-the-loop

    Models are uncertain on edge cases. Route low-confidence items to human reviewers; their decisions are both the final call and high-quality training labels. This keeps precision high where automation is risky.

    Active learning loop

    Human labels flow back into the training pipeline, prioritizing examples the model was most unsure about (active learning). Over time this raises model confidence and shrinks the share needing human review.

    9. Bottlenecks

    • Video model cost → sample frames, async deep checks
    • Human review capacity → tune thresholds, prioritize severity
    • Adversarial evasion → continuous retraining

    10. Trade-offs

    Where to run checks

    Choose: Fast, cheap checks inline at upload (hash matching against known bad content, light classifiers); heavier models async.

    Instead of: Run everything inline: slow uploads and expensive.

    Known-bad hashes catch the worst content instantly; most content is fine and can be checked after publishing.

    Thresholds

    Choose: Three bands per policy: auto-remove above a high threshold, human review in the middle, allow below.

    Instead of: One threshold: forces a choice between too many false removals and too many misses.

    Humans are expensive; spend them where the model is unsure.

    One model or many

    Choose: Separate models per modality and policy, combined by a policy engine.

    Instead of: One giant model for everything: harder to update one policy without regressions.

    Policies change independently and have different legal requirements.

    11. Failure modes

    Adversarial edits evade classifiers

    Harmful content stays up.

    Mitigation: Perceptual hashing robust to edits, adversarial training data, and user reports feeding retraining.

    Mass false positives after a model update

    Legitimate creators removed.

    Mitigation: Shadow-run new models and compare decisions before enabling; appeals path with fast reversal.

    Reviewer queue overwhelmed during an event

    Harm spreads before review.

    Mitigation: Prioritize by predicted severity and reach; temporarily limit distribution of uncertain content.

    12. What interviewers probe

    Answer each one yourself before opening it.

    How do you measure the system?Show a strong answer

    Prevalence (sampled views of violating content), precision and recall per policy from labelled samples, and appeal overturn rate.

    How do you protect reviewers?Show a strong answer

    Blurring by default, exposure limits, wellness support, and routing the worst categories to specialized teams.

    How do you handle live video?Show a strong answer

    Sample frames and audio continuously, escalate on detection, and give reviewers the power to end streams.

    How do you handle different laws per country?Show a strong answer

    Policy engine applies global rules plus per-jurisdiction rules, restricting content by region where needed.

    Sign in to track this guide in your curriculum progress.