Designing a Multimodal Classifier for Prohibited Item Listings
Machine LearningModel answerLast updated
Design an end-to-end ML system that detects policy-violating item-for-sale posts by combining text, image, and behavioral signals at platform scale.
The Problem
A large social platform allows users to post buy/sell listings in a dedicated marketplace surface as well as in general feeds and community groups. Platform policy prohibits listings that offer regulated items — firearms, ammunition, and certain weapon components — for sale, trade, or transfer between private individuals.
Your task is to design a scalable ML system that automatically detects and acts on these violating posts.
What you are building
A real-time and near-real-time classification pipeline that:
- Reads each new post (text, images, metadata) and outputs a violation score
- Takes an enforcement action — auto-remove, queue for human review, or allow — based on that score
- Handles millions of posts per day with p99 latency under 500 ms on high-risk surfaces
- Remains effective as adversarial users try to evade detection
Scope
Structure your answer around these four areas:
- Policy and labeling — What counts as a violation? How do you build and maintain ground-truth labels at scale?
- System architecture — How does a post flow from ingestion to an enforcement decision?
- Multimodal modeling — How do you extract and combine signals from text, images, OCR, and metadata?
- Reliability and drift — How do you handle adversarial evasion, monitor quality over time, and keep the system improving?
Constraints and expectations
- The violating class is rare: roughly 0.01–0.05% of posts
- Errors are asymmetric: false positives harm legitimate users; false negatives allow policy violations to spread
- Sellers actively adapt their language and images to avoid detection
- Human review capacity is finite (order of tens of thousands of items per day), so the model must route intelligently
- Content is multilingual and may include up to ~10 images per post
A strong answer defines the violation precisely, justifies architectural choices with trade-offs, explains how the multimodal signals interact, and addresses adversarial robustness and feedback loops — not just model selection.
Hints
Hint 1
Start by pinning down what makes a post a violation: it is the combination of a regulated item AND transactional intent, not either one alone. This distinction drives your labeling criteria, your hard-negative strategy, and your fusion approach.
Hint 2
Think in stages: a cheap cascade of keyword/hash filters, then parallel feature extraction (text encoder, image encoder, OCR), then a fusion model. Most posts exit early, which lets you keep p99 latency under budget without burning GPU on every post.
Hint 3
Adversarial evasion is a core requirement, not an afterthought. Cover text normalization (homoglyphs, leetspeak, slang), OCR on images (sellers embed prices in photos), and perceptual hashing for known violating media. Then explain how your retraining loop catches novel evasion patterns.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
What this problem is really testing
This is a content-integrity classification problem with four properties that make it hard and that should anchor every design decision:
- Extreme class imbalance. Violating posts are ~0.01–0.05% of traffic, so naive approaches optimize toward "always allow."
- Intent-defined violation. A photo of a firearm is not a violation. Offering it for sale is. The model must detect the combination.
- Adaptive adversary. Sellers change wording, use images to embed text, crop photos, and adopt new slang specifically to evade classifiers.
- Asymmetric error costs. False positives hurt legitimate users (hunters, collectors, journalists). False negatives let harmful listings spread. Both have real costs — the system needs tiered enforcement, not a single threshold.
1. Policy and labeling
Precise violation definition. A post is violating when it contains both:
- A regulated item — firearms, ammunition, receivers, suppressors, 80% lowers, or other regulated weapon components
- Transactional intent — a price, "DM me," payment handles, contact info, "selling / trading / WTS," or a marketplace-style listing format
Neither signal alone is sufficient. Gun reviews, hunting trip photos, news discussion, airsoft content, and licensed retailer pages are explicitly allowed. Write this as a decision tree for raters, with borderline examples for each branch.
Labeling pipeline. Start with seed positives from historical enforcement actions and confirmed user reports. Scale up with:
- Embedding-similarity mining: embed known positives, retrieve nearest neighbors from unlabeled data
- Weak supervision: combine keyword lists, price-regex detectors, and a fine-tuned image classifier as labeling functions, then denoise with Snorkel or a similar framework
- LLM pre-labeling with human spot-check verification for efficiency
Crucially, oversample hard negatives — gun-related posts that are allowed (hunting, news, range photos). Without them, the model learns "gun present → violating" and false positives explode.
Track inter-rater Cohen's κ. Persistent disagreement on a category means the policy definition is ambiguous, not that the raters are wrong.
Split train/eval by time and by account to prevent leakage from repeat sellers. Maintain a random-sample evaluation set so you can estimate true prevalence and recall in production.
2. System architecture
Assumed scale: ~100M posts/day, ~1.2K QPS average, ~5K QPS peak. Violating volume: 10K–50K/day. Human review capacity: ~20K items/day.
Pipeline stages:
Stage 0 — cheap filters (< 5 ms):
- PDQ perceptual hash lookup against a database of known violating images → instant remove
- Keyword and regex scan after text normalization
- Account risk score (prior strikes, account age, posting velocity)
About 90% of posts exit here as clearly allowed. This keeps GPU costs manageable.
Stage 1 — feature extraction (parallel, GPU, ~100–150 ms):
- Text: normalize homoglyphs, leetspeak, and emoji substitutions; encode with a multilingual transformer (XLM-R or a distilled multilingual LLM)
- Image: ViT or CLIP-style encoder fine-tuned on weapon/transaction data; an auxiliary object detector for weapons and components handles cropped or partial views
- OCR: extract text from images and run it through the same text encoder — sellers routinely embed prices and phone numbers in photos to evade text classifiers
- Metadata: surface type (Marketplace raises the prior significantly), price fields, contact info present, posting velocity, graph distance to known sellers
Stage 2 — fusion model (< 10 ms): outputs a calibrated P(violating). Covered in section 3.
Decision layer with per-surface thresholds:
- Score ≥ τ_high (~99% precision operating point): auto-remove, user notified, appeal available
- τ_low ≤ score < τ_high: route to human review queue, ranked by score × expected reach
- Score < τ_low: allow; optionally demote borderline content
Reviewer decisions and appeal outcomes write back to the labels table and feed the retraining loop.
3. Multimodal fusion
Why fusion matters: an image of a rifle paired with "DM for price $800" is violating; neither signal alone is sufficient. The model needs to learn the joint pattern.
Late fusion — averaging per-modality scores — is simple and degrades gracefully when a modality is missing, but it misses cross-modal interactions entirely.
Intermediate fusion (recommended for production):
- Concatenate the text embedding, attention-pooled image embedding(s), OCR embedding, and scalar metadata features
- Pass through a small MLP or lightweight cross-attention transformer
- Train with frozen pretrained encoders and a trainable head first; fine-tune end-to-end once the head converges. Frozen-encoder training is cheap enough to run frequently, which matters for keeping up with adversarial drift.
Large multimodal model (second-pass only): too expensive for every post, but useful as a high-accuracy second pass on the review band, or as a teacher for knowledge distillation into the production model.
Practical training details:
- Apply modality dropout so the model handles text-only and image-only posts robustly
- Add per-modality auxiliary classification heads — they improve gradient flow and double as explanation signals for human reviewers
- Use focal loss or class-weighted cross-entropy to handle the imbalance
- Calibrate output scores with isotonic regression on recent held-out data so thresholds remain meaningful across retrains
4. Adversarial robustness and monitoring
Evasion attack surface and mitigations:
| Evasion tactic | Mitigation |
|---|---|
| Misspellings, leetspeak, homoglyphs | Text normalization before encoding |
| Slang and code words ("heater," "strap") | Continuous vocabulary mining from confirmed violations |
| Price/contact embedded in image | OCR pipeline |
| Cropped or partial weapon photos | Object detector trained on partial views |
| Reposting slightly altered images | Perceptual hashing (PDQ) |
Monitoring and drift detection:
- Track precision and recall on the rolling random-sample eval set, not just on the model's own flagged output (which is biased high)
- Monitor score distribution shifts over time — a sudden drop in high-confidence positives often signals a new evasion pattern
- Run monthly adversarial red-team exercises: have a team attempt to post violating content that evades the current model; use failures as training data
- Measure reviewer override rate as a lagging signal: high override rate on auto-removes means τ_high drifted
Retraining cadence: retrain the fusion head weekly on recent data; full encoder fine-tuning monthly. Shadow-deploy new versions and compare metrics before promoting.
Common mistakes to avoid
- Treating any gun-related content as violating rather than requiring transactional intent — this is the single biggest source of false positives
- Skipping OCR, leaving a large and easily exploited evasion channel open
- Setting a single global threshold regardless of surface — Marketplace posts warrant a lower threshold than feed posts
- Evaluating only on the flagged set rather than a random sample, which gives an optimistic and misleading recall estimate
- Treating adversarial evasion as an edge case rather than a continuous operational reality that the feedback loop must address