LearnSystem design

Harmful-content and bot detection

Detect and act on posts that violate content policy (hate, spam, coordinated bots) across text, images and video.

ML engineering8 parts

Contents

Constraints

  • 500M new posts/day
  • violating prevalence ~0.1–1% depending on policy
  • human reviewer capacity ~100k items/day
  • some harms need action within minutes

What to cover

Sketch your own design first. A complete answer has these parts; the notes say what each should settle.

  1. RequirementsDetect and act on posts that violate content policy (hate, spam, coordinated bots) across text, images and video.
  2. Estimates500M new posts/day; violating prevalence ~0.1–1% depending on policy; human reviewer capacity ~100k items/day; some harms need action within minutes.
  3. API
  4. Data model
  5. ArchitecturePolicy taxonomy; multimodal classifiers (text encoders, image/video models, fused embeddings).; Account- and behaviour-level features for bots (graph, velocity).; Hash matching for known content.; Thresholds per action: remove, downrank, send to review.; Review queue prioritisation by severity × reach; appeals; active learning from reviewer decisions; adversarial adaptation monitoring.
  6. Deep dives
  7. Trade-offsprecision vs recall per harm severity; automated removal vs human review cost; latency (pre-publication vs post-publication); multilingual coverage; fairness across dialects.
  8. EvaluationOffline: per-policy PR curves and recall at fixed precision; sampled prevalence estimates.; Online: prevalence of violating views (impression-weighted), appeal overturn rate, reviewer agreement.; Red-team evaluation on adversarial variants.

Reference design

One way to answer it, part by part. Open a part once you have your own version of it.

Requirements

Functional: score every new post (text, images, video, audio) against each content policy; detect bot and coordinated-inauthentic accounts; take actions — remove, reduce distribution, add interstitials, send to human review, act on accounts; let users report and appeal; feed reviewer decisions back into models.

Policy taxonomy with severity tiers (assumption): tier 1 — child sexual exploitation, terrorism, credible threats (minutes matter; legal reporting duties); tier 2 — hate speech, harassment, graphic violence, self-harm promotion; tier 3 — spam, scams, engagement bait, coordinated inauthentic behaviour.

Non-functional: tier-1 known content blocked before publication (synchronous, < 1–2 s); other policies acted on within minutes after publication, before most views accrue; reviewer capacity ~100k items/day is the binding resource; transparency reporting (UK Online Safety Act, EU DSA statements of reasons).

Assumptions to confirm: ~500M posts/day, prevalence 0.1–1% by policy, dozens of languages and dialects, adversaries who adapt within days, existing hash-sharing programmes for known illegal content.

Estimates

  • Throughput: 500M posts/day ≈ 5.8k posts/s, ~15k/s at peak.
  • Violations: 0.1–1% → 0.5M–5M violating posts/day. Reviewers handle 100k/day, i.e. 2–20% of violations at best, so automation must act on most cases at high precision, and review must be spent where it changes outcomes.
  • Media: assume 40% of posts carry images (200M/day ≈ 2.3k/s) and 10% video (50M/day). Sampling video at 1 frame/s over ~30 s ≈ 1.5B frames/day ≈ 17k frames/s. At ~1–2k images/s per GPU: ~10–20 GPUs for frames on average (~2.5× that at peak), a few more for images, plus ASR for spoken content.
  • Text: a multilingual encoder at ~3k posts/s per GPU → ~5 GPUs at peak, ×2 for redundancy.
  • Hash matching: perceptual hashes (PDQ for images, video hashes) checked against banks of known content in milliseconds; near-free per post.
  • Review allocation: 100k reviews/day across ~1,000 reviewers; priority = p(violation) × severity × predicted reach, so a borderline post about to go viral outranks a likely violation with no audience.
  • Bots: ~50M accounts posting per day get behavioural scores in real time; graph features over the full account graph recomputed daily.

API

POST /v1/integrity/classify    (synchronous for pre-publication checks)
  {post_id, author_id, text, media: [{type, uri, hash?}], lang?, surface, audience}
  → {actions: [{policy, action: "block"|"remove"|"downrank"|"interstitial"|"review"|"none",
                score, severity, threshold_version}], hash_match?: {bank, match_id}}

Async event: post.created → full multimodal scoring → enforcement service
GET  /v1/review/queue/next?reviewer_id=…   → item with context, policy guidance, history
POST /v1/review/decisions  {item_id, policy, decision, sub_reasons[], confidence}
POST /v1/appeals           {enforcement_id, statement} → {appeal_id}
GET  /v1/accounts/{id}/risk → {bot_score, cluster_id, signals[]}

Scoring is idempotent per post and model version; re-scoring with new context (reports, comments, sudden reach) appends new scores rather than overwriting, so every enforcement stays auditable. Enforcement is a separate service, so thresholds change without redeploying models.

Data model

  • Post: post_id, author, text, media references, language, surface, created_at, distribution state.
  • MediaHash: perceptual hashes per image and video segment; matches against known-content banks.
  • Score: post_id, policy, model version, score, timestamp (several per post as models re-score with more context, e.g. after comments arrive).
  • Enforcement: post or account, action, policy, automated vs human, threshold version, timestamp, reversal status.
  • ReviewDecision: item, reviewer, policy, decision, time spent, agreement sample flag.
  • Appeal: enforcement id, outcome, reviewer.
  • AccountFeatures: age, verification, posting velocity, device and IP/ASN sharing, follower graph features, content-similarity with other accounts.
  • Cluster: coordinated-behaviour clusters with member accounts and evidence.
  • LabelSet: versioned training and evaluation labels with policy version and source (reviewer, appeal, red team).

Architecture

Flow · 4 stepsPost lifecycle from upload to enforcement

Post lifecycle from upload to enforcementThe flow runs from upload through pre-publication, publish, scoring and thresholds. Pre-publication splits into block + legal report on hash match, hold for review on extreme hits, and publish otherwise. Bot detection feeds bot score, velocity and graph into scoring and sends clusters to account actions; reviewer decisions and appeal reversals fill the label store, which feeds active learning back into scoring.Uploadnew postBot detectionvelocity + graph jobsPre-publicationsync, < 1–2 sAccount actionsclustersBlock + legalreporttier-1 knowncontentPublishafterpre-publicationPost-publication scoringtext · image · video + ASRThresholds per actionremove / downrank / review / noneAutomated actionshigh precision bandReview queuepriority = p × severity ×reachLabel storeversioned labelshash matchhold if extremepublishbot featuresper-policy scoreshigh precisionuncertain bandclustersdecisions + reversalsactive learning1234IntakeScoringReviewLearning
  1. Pre-publication Known tier-1 content is blocked before publication; extreme hits are held for review; otherwise the post is published.
  2. Score Post-publication scoring fuses text, image and video with ASR and account/behaviour features.
  3. Threshold and act High precision removes or downranks automatically, uncertain items go to review, and bot clusters trigger account actions.
  4. Learn Reviewer decisions and appeal reversals fill the label store, which feeds active learning and retraining back into scoring.

Known tier-1 content is blocked before publication, extreme hits are held, and the rest are scored and thresholded into automated action or review, with decisions feeding active learning.Diagram drafted by a local AI model (Inkling 2 Mini) from this page's text and drawn from data. Checked by an independent reviewer.
Data
Steps
StepTitleWhat happens
1Pre-publicationKnown tier-1 content is blocked before publication; extreme hits are held for review; otherwise the post is published.
2ScorePost-publication scoring fuses text, image and video with ASR and account/behaviour features.
3Threshold and actHigh precision removes or downranks automatically, uncertain items go to review, and bot clusters trigger account actions.
4LearnReviewer decisions and appeal reversals fill the label store, which feeds active learning and retraining back into scoring.

Source: This page's text

Boxes
BoxGroupDetail
UploadIntakenew post
Pre-publicationIntakesync, < 1–2 s
Block + legal reportIntaketier-1 known content
PublishIntakeafter pre-publication
Post-publication scoringScoringtext · image · video + ASR
Thresholds per actionScoringremove / downrank / review / none
Automated actionsScoringhigh precision band
Bot detectionScoringvelocity + graph jobs
Account actionsScoringclusters
Review queueReviewpriority = p × severity × reach
Label storeLearningversioned labels

Source: This page's text

Upload ─► Pre-publication (sync, < 1–2 s):
            hash match vs known-content banks ─► block + legal report
            fast high-severity text/image classifiers ─► hold for review if extreme
        ─► publish
post.created ─► Post-publication scoring (minutes):
      text encoder · image model · video frames + ASR · fused multimodal embedding
      + account/behaviour features (bot score, velocity, graph)
      ─► per-policy scores ─► thresholds per action:
           high precision band → remove / downrank automatically
           uncertain band      → review queue (priority = p × severity × reach)
           low                 → none (sampled for measurement)
Bot detection: streaming velocity rules + daily graph jobs (shared devices/IPs,
      synchronised posting, near-duplicate content) ─► clusters ─► account actions
Review tool ─► decisions ─► label store ─► active learning + retraining
Appeals ─► second review ─► reversals feed back as labels
Adversarial monitoring: obfuscation variants, new clusters, sudden score shifts

Deep dives

Thresholds per action. For each policy, pick the remove threshold where measured precision is ≥ ~99% (higher for low-severity, where a wrong removal of legitimate speech is the bigger harm), a downrank threshold at moderate precision (reduced reach is reversible and cheap to be wrong about), and a review band where human time changes outcomes. Thresholds are re-validated per language.

Coordinated bots. Single posts often look innocent; the signal is collective. Build an account graph (shared devices, IP ranges, creation bursts, synchronised posting times, near-duplicate content) and run community detection; act on clusters, which raises the cost to the adversary more than removing posts one by one.

Adversarial adaptation. Expect misspellings, text in images (OCR in the pipeline), cropped or re-encoded media (perceptual not exact hashes) and coded language. Monitor for score-distribution shifts and spikes in user reports on content the models allowed; feed reviewer decisions on those into active learning within days.

Trade-offs

  • Precision vs recall per harm severity: for child safety and terrorism favour recall and send borderline items to specialist review; for spam and low-severity policies favour precision, since over-removal silences legitimate users at scale.
  • Automated removal vs human review cost: automation scales and is fast but makes confident mistakes; reviewers are accurate but capacity-bound and exposed to harmful material. Automate the confident extremes, review the middle, and prioritise by reach.
  • Latency (pre- vs post-publication): pre-publication checks prevent harm but add upload latency and false holds; reserve them for known content and the most severe classes, and act post-publication within minutes for the rest.
  • Multilingual coverage: one multilingual model covers many languages but is weaker in low-resource ones; add language-specific data and reviewers where prevalence is high.
  • Fairness across dialects: classifiers often over-flag dialects such as African American English or regional slang; measure false-positive rates by dialect and adjust data and thresholds.

Evaluation

  • Offline: per-policy precision–recall curves and recall at a fixed precision on recent, policy-versioned labelled sets; results by language, dialect and media type; sampled prevalence estimates from uniform samples of new posts.
  • Online: prevalence of violating views (impression-weighted, from expert-labelled random samples of views, with CIs) as the headline metric; appeal overturn rate per policy; reviewer agreement (inter-rater kappa on double-reviewed items); time to action for tier-1 content.
  • Red-team evaluation: adversarial variants (obfuscated text, edited media, coordinated account rings) generated each month; recall on them tracked and regressions blocked.
  • Monitoring: score drift, review backlog and age, automated-action volumes per policy against baselines (a spike can mean a broken model), false-positive reports from users.

What a strong design shows

  • Uses separate thresholds per action and policy, with automation at the confident extremes and human review in the middle.
  • Prioritises scarce reviewer time by probability × severity × reach.
  • Combines content classifiers, hash matching for known content and account/graph signals for coordinated bots.
  • Measures impression-weighted prevalence from samples, not just classifier metrics, and tracks appeal overturns.
  • Plans for adversaries and dialect fairness explicitly.

Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.