Designing a Multimodal Weapon Ad Moderation Pipeline
System DesignModel answerLast updated
Design a scalable multimodal machine learning system to detect and block illegal weapon ads under strict latency and high recall requirements.
Context
You are tasked with designing the automated policy enforcement system for a global digital platform. The system must analyze every ad submission—including headline text, static images, video streams, audio tracks, and linked landing pages—to identify and block prohibited items, specifically restricted firearms, illegal weapon components, and related contraband, prior to ad delivery.
System Requirements
Functional Requirements
- Multimodal Analysis: Combine features from copy text, image OCR, visual object detection, speech transcripts, and landing page contents.
- Real-Time Moderation: Provide low-latency verdicts for newly submitted ads.
- Human Review Workflow: Escalate uncertain or suspicious cases to human moderation queues without blocking overall platform throughput.
- Adversarial Resilience: Detect obfuscation strategies, including text baked into images, homoglyphs, evasive video editing, and clean ad creative pointing to restricted destination URLs.
Non-Functional Requirements
- Low Latency: The initial synchronous submission evaluation must complete with a P99 latency $< 200\text{ ms}$ for standard static formats.
- High Recall & Precision Controls: Weapon policy enforcement demands high recall (target $\ge 98%$) while controlling false positives to protect legitimate advertiser workflows.
- High Throughput & Elasticity: Baseline capacity of $\sim 150\text{ QPS}$ with burst tolerance exceeding $1,500\text{ QPS}$ during peak shopping periods.
Key Discussion Points
- System & Processing Architecture: Synchronous vs. asynchronous execution paths, API contracts, caching mechanisms, and fallback patterns under load.
- ML Pipeline & Fusion Strategy: Text, vision, and audio feature extraction, along with early, intermediate, and late fusion trade-offs.
- Adversarial Defenses: Technical solutions for evading policy detection across all modalities.
- Human-in-the-Loop & Model Operations: Dynamic thresholding, prioritized queueing, active learning feedback loops, and canary deployments.
Hints
Hint 1
Distinguish between ad submission moderation and real-time auction bidding. Full video processing should happen asynchronously post-submission while keeping the ad unlisted, rather than trying to fit frame analysis into sub-200ms auction SLAs.
Hint 2
Construct a multi-stage funnel: fast perceptual hashing/deduplication -> lightweight single-modality checks -> multimodal intermediate fusion -> prioritized human review.
Hint 3
Consider cross-modal semantic dependency. A photo of an unmachined metal cylinder is benign on its own, but combined with copy stating 'no FFL required,' it represents a clear policy violation.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Requirement Clarifications & Scale Estimation
Operational Scope
Ad safety moderation operates at creative submission or edit time, decoupled from the sub-10ms ad auction execution path.
- Synchronous Path ($\le 200\text{ ms}$ P99): Evaluates text copy, metadata, and static images to issue a synchronous decision (
APPROVEDorREJECTED). Rich media and video receive aPENDING_SCANstatus. - Asynchronous Path (Seconds to Minutes): Executes video frame extraction, audio ASR transcription, web crawling of destination URLs, and human review routing. The creative remains inactive for auction participation until this pipeline issues an
APPROVEDverdict.
Quantitative Scale Estimates
- Daily Submission Volume: $\sim 10\text{M}$ ad creatives per day ($\sim 115\text{ QPS}$ average).
- Peak Throughput: Up to $10\times$ burst during promotional events ($\sim 1,500\text{ QPS}$).
- Modality Mix: $60%$ static images, $25%$ video/rich media, $15%$ text-only.
- Violation Prevalence: Low ($\approx 0.1%-0.3%$). Due to severe class imbalance, system accuracy is an uninformative metric; performance is evaluated using Precision-Recall AUC (PR-AUC) and Recall at Target Precision (e.g., Recall @ 95% Precision).
2. High-Level System Architecture
+------------------------+
| Ad Submission API |
+-----------+------------+
|
v
+------------------------+
| Kafka Ingestion Bus |
+-----------+------------+
|
+-------------------+-------------------+
| |
v v
+---------------------------+ +---------------------------+
| Sync Pipeline (<200ms) | | Async Pipeline (Media) |
+-------------+-------------+ +-------------+-------------+
| |
+-------------+-------------+ +-------------+-------------+
| Stage 0: Hash Matching | | Frame Extraction & OCR |
| Stage 1: Fast Text & Risk | | Audio ASR Pipeline |
| Stage 2: Vision & OCR | | Destination URL Crawler |
| Stage 3: Multimodal Head | +-------------+-------------+
+-------------+-------------+ |
| |
+-------------------+-------------------+
|
v
+---------------------------+
| Decision Service |
+-------------+-------------+
|
+-------------------------+-------------------------+
| | |
v v v
+-------------------+ +-------------------+ +-------------------+
| Auto-Approve | | Human Review | | Auto-Reject |
| (Verdict KV Store)| | Priority Queues | | (Verdict KV Store)|
+-------------------+ +---------+---------+ +-------------------+
|
v
+-------------------+
| Label Store & |
| Continuous Train |
+-------------------+
Multistage Evaluation Funnel
Stage 0: Fast Deduplication & Known Violation Lookup ($\sim 5\text{ ms}$)
- Perceptual Hashing: Generates PDQ/pHash values for static images and Temporal Match Kernels (TMK) for video.
- Vector Search: Queries an HNSW vector index of previously confirmed policy-violating assets.
- Action: Immediate rejection upon exact or near-duplicate match, short-circuiting downstream inference engines.
Stage 1: Lightweight Metadata & Text Inspection ($\sim 15\text{ ms}$)
- Runs a distilled, multi-lingual text model (e.g., MiniLM) over headlines and body copy.
- Computes advertiser risk indicators derived from account tenure, historical policy violation rates, and payment profile risk.
Stage 2: Parallel Vision & Extraction Engines ($\sim 70-90\text{ ms}$)
- Object Detection: Fine-tuned YOLO / RT-DETR model trained to identify weapon components (receivers, suppressors, magazines, ammunition, conversion kits).
- Visual OCR: Extracts embedded image text overlays.
Stage 3: Multimodal Fusion & Score Calibration ($\sim 10\text{ ms}$)
- Combines object detection signals, text embeddings, OCR embeddings, and account metadata.
- Outputs a calibrated violation probability score ($P_{\text{violation}} \in [0, 1]$).
Stage 4: Decision Router
- Writes the final status to a globally distributed, low-latency KV store (e.g., Redis/ScyllaDB) queried by auction services.
3. Multimodal Model Strategy
Ad Copy Text ---> [ Distilled XLM-R ] ---+
|
Image OCR Text -> [ Shared Tokenizer ] --+
| Concat / Cross-Attention
Visual Asset ---> [ ViT / YOLO Detect ] -> +-------------------------> [ Fusion Head ] ---> Policy Score
|
Advertiser Meta -> [ Dense Embedding ] --+
Architecture & Modality Integration
- Text Pipeline: A distilled XLM-RoBERTa encoder handles primary ad copy, OCR-extracted text, and ASR speech transcripts using unified tokenization.
- Vision Pipeline:
- Fine-tuned Vision Transformer (ViT) generates visual representations for general context.
- Targeted object detector (YOLO-based) generates localized feature maps and class scores for specific contraband classes (e.g., 80% lower receivers, bump stocks).
- Fusion Mechanics (Hybrid Intermediate + Late Fusion):
- Intermediate Fusion: Cross-attention layers combine text embeddings and visual feature maps prior to final classification. This captures intent where individual modalities appear benign (e.g., a photo of a metallic tube paired with text stating "solvent trap - no registration").
- Late Fusion Rule Overrides: Hard logical gates override the model output if single-modality confidence exceeds a safety threshold (e.g., object detector output $\ge 0.95$ for a firearm auto-rejects the ad regardless of low-risk text scores).
4. Adversarial Defenses
| Evasion Technique | System Countermeasure |
|---|---|
Homoglyphs & Character Obfuscation (e.g., G*u*n, A-K-4-7) | Character-level tokenization; Unicode normalization (NFKD format); data augmentation using synthetic obfuscated text. |
| Baking Text into Image Overlays | Mandatory OCR extraction across all image assets and sampled video frames; OCR output fed directly into the text encoder. |
| Visual Masking, Edits & Rotation | Extensive spatial training augmentations; visual embedding similarity search replacing rigid hash lookups. |
| Carousel / Frame Splitting (violating context distributed across frames) | Temporal pooling and attention-based aggregation across all frames and carousel cards. |
| Evasive Landing Pages (clean ad creative pointing to violating content) | Headless crawler execution with proxy rotation to inspect landing page DOMs, media assets, and checkout flows. |
5. Thresholding, Human Review & Operational Feedback Loop
+---------------------------------+
| Calibrated Score (0.0 - 1.0) |
+----------------+----------------+
|
+------------------------+------------------------+
| | |
v v v
[ Score < t_low ] [ t_low <= Score <= t_high ] [ Score > t_high ]
| | |
v v v
+-----------------+ +-----------------+ +-----------------+
| Auto-Approve | | Human Review | | Auto-Reject |
+-----------------+ | Priority Queue | +-----------------+
+--------+--------+
|
v
+-----------------+
| Label Store & |
| Retraining Loop |
+-----------------+
Threshold Strategy
The system uses dual calibrated thresholds:
- Auto-Approve ($P_{\text{violation}} < t_{\text{low}}$): Ad creative is released for auction delivery.
- Human Review ($t_{\text{low}} \le P_{\text{violation}} \le t_{\text{high}}$): Ad creative is routed to a moderation queue.
- Auto-Reject ($P_{\text{violation}} > t_{\text{high}}$): Ad creative is blocked, and feedback is supplied to the advertiser interface.
$t_{\text{low}}$ Setting: Derived directly from the recall SLA (e.g., ensuring $\ge 98%$ recall against a gold validation dataset). Review Queue Capacity: The margin between $t_{\text{low}}$ and $t_{\text{high}}$ is dynamically adjusted based on reviewer throughput capacity to prevent backlogs.
Sampling Strategy for Continuous Model Improvement
- Uncertainty Sampling: Cases within the borderline band ($t_{\text{low}} \le P_{\text{violation}} \le t_{\text{high}}$) are routed for human labeling.
- Disagreement Sampling: Cases where individual modality outputs conflict (e.g., text scores low risk, but vision scores high risk) are prioritized.
- Random Auditing: A small percentage ($0.1%$) of auto-approved ads undergo manual review to track true platform prevalence and detect unmodeled false negatives.
Trade-Off Summary
| Architectural Dimension | Approach Taken | Trade-Off Rationale |
|---|---|---|
| Evaluation Timing | Asynchronous Video / Sync Image | Guarantees sub-200ms submission SLAs for standard ads while allowing deep multi-frame video analysis. |
| Fusion Type | Intermediate Cross-Attention + Rule Overrides | Captures multi-modal evasion strategies without the latency overhead of large joint multimodal transformers. |
| Threshold Tuning | Dual Thresholds with Dynamic Band | Maintains target recall rates ($\ge 98%$) while dynamically matching review queue volume to operational capacity. |