Design a Prohibited Item Detection System
Understanding the Problem
🚫 What is a prohibited item detection system? A marketplace lets anyone list things for sale: a title, a description, a price and some photos. Some things aren't allowed: firearms and ammunition, drugs, counterfeit goods, live animals, recalled products, and items that are legal in one country and banned in the next. A prohibited item detection system checks every new or edited listing, decides whether it breaks a policy, and blocks it, sends it to a human, or lets it through. It's content moderation specialized for commerce, where the content is a product.
The usual phrasing is "design a system to block weapons from being sold on a marketplace." Weapons are a good concrete case because they're clearly harmful, legally sensitive, and full of hard edges: a toy gun, an airsoft rifle, a gun safe, a holster, a hunting knife, a replica on a film set. We'll design for weapons first and build it so the same system handles every policy category.
Functional Requirements
We're the integrity team of a large consumer marketplace (think Facebook Marketplace, eBay or Craigslist) in many countries.
Core Requirements
- Every new listing, and every edit, should be checked against the prohibited-items policy before it's visible to buyers, with a decision: publish, reject with a reason, or hold for human review.
- The system should cover multiple policy categories (weapons, drugs, animals, counterfeits...) with per-country rules.
- Human reviewers should get a prioritized queue, and their decisions should become training labels.
- Sellers should be able to appeal, and repeat offenders should face escalating penalties.
- When a model or policy changes, the system should re-check listings that are already live.
Below the line (out of scope)
- Scams and fake listings (a real-looking item that doesn't exist). That's closer to fraud detection.
- Spam and bots posting listings in bulk (see bot and spam detection), though we'll use their account signals.
- Moderating buyer-seller chat in depth, beyond using it as a signal.
Non-Functional Requirements
Ask about volume and how long a seller will wait. Our numbers: 10 million new or edited listings a day (about 115 per second on average, 500 per second at peak), 5 photos per listing on average (so 50 million images a day, 2,500 per second at peak), and 100 million active listings at any time. Prohibited listings are rare: on the order of 0.5% across all categories, and around 0.05% for weapons.
Core Requirements
- A listing should get an automatic decision within 2 seconds at p95. Sellers tolerate a short "publishing..." step; they won't tolerate minutes.
- Recall on severe categories (firearms, explosives, hard drugs) matters most: we target catching over 95% of firearm listings before they get any views.
- Precision on auto-rejects must be high (above 95%), because wrongly rejecting a legitimate seller loses revenue and trust. Uncertain cases go to humans.
- Rules differ per country, and the system must apply the right one by listing location.
- Human review of held listings should finish within an hour for most cases.
Below the line (out of scope)
- Legal reporting to law enforcement (an output of the review tool, not of the model).
- Real-time video listings.
Some arithmetic. If 0.3% of listings land in the review band, that's 30,000 reviews a day. At roughly a minute per decision, one reviewer does about 450 in a shift, so we need on the order of 70 reviewers across time zones. If the band were 3%, we'd need 700, so the model's job is to keep the uncertain band narrow. On the compute side, 2,500 images per second at peak through a ViT-B-sized image encoder is a handful of modern GPUs with batching, plus OCR, which is often more expensive than the classifier.
A strong opening line: "This is a multimodal, multi-label classification problem with a human in the loop. The model's real job is to make humans efficient: auto-handle the clear cases and send the right few thousand to review."
Framing It as an ML Problem
ML Objective
The business wants low prevalence of prohibited listings seen by buyers (measured on views, by sampling and labeling) at an acceptable cost in false rejections (appeals overturned, seller churn) and review headcount.
The model predicts, for each listing and each policy category c, a calibrated P(violates c | listing, seller). Each category has its own severity and thresholds:
- Auto-reject above a high threshold, chosen for 95%+ precision.
- Hold for review in a middle band, chosen so that recall on severe categories hits target and the queue fits reviewer capacity.
- Publish below, but possibly with reduced distribution if the score is close.
Inputs and Outputs
- Input: title, description, price, currency, category chosen by the seller, location, the photos, text extracted from the photos (OCR), seller account features, and for re-checks, buyer messages and reports about the listing.
- Output: a score per policy category (multi-label, since a listing can be both a weapon and a counterfeit), the decision, and the evidence: which image, which phrase. Reviewers and sellers both need the "why."
Choosing the ML Approach
Multi-label classification over a fixed policy taxonomy, with multimodal inputs. Text alone misses a listing titled "black case, DM for details" with a photo of a pistol. Images alone miss "selling my AR, $900, local pickup" over a photo of a closed bag. You need both, plus OCR for text written on the photos.
We'll add two non-classification tools: nearest-neighbor retrieval against an index of known violating listings (embeddings plus perceptual hashes), which catches reposts and near-copies of banned listings, and a vision-language model (VLM) for ambiguous cases and for new policies that have no labeled data yet.
Data and Labels
Labels come mostly from human review, which makes label quality a design problem in itself.
- Reviewer decisions on held listings. High volume, but biased toward listings the model already found suspicious.
- Appeals overturned or upheld. Small, high-value; overturned ones are the best hard negatives we have.
- User reports from buyers. Noisy, but they find what the model missed.
- Random audit samples: a few thousand random published listings a day labeled by reviewers. The only unbiased source for prevalence and recall.
- Policy expert gold sets: a few hundred carefully labeled listings per category, used to test reviewers and to evaluate models on the hard edges.
Label quality. Policies are subtle ("airsoft guns are allowed in country A only with an orange tip visible"), and reviewers disagree. We measure agreement on items reviewed twice, plant gold items in each reviewer's queue, and send disagreements to a senior reviewer. The training label is the final adjudicated decision, and we store the reviewer's reason code, which gives us fine-grained subcategory labels for free.
Imbalance. At 0.05% for weapons, a random sample of 10 million listings has about 5,000 positives. We get more by active learning: send a slice of review capacity to listings the model is most uncertain about, and to near neighbors of confirmed violations, which yields far more positives and hard negatives per review than random sampling. Keep the random audit sample separate so evaluation stays unbiased.
Leakage. Don't train on features that exist because of enforcement (a listing's "number of reports" after it was already held), and split train/test by seller and by time, so a seller's 50 near-identical listings don't land on both sides.
Feature Engineering
Text features
- Title and description run through a multilingual transformer encoder (fine-tuned). Weapons sellers use code words and misspellings ("pew pew," "boom stick," "9mm" written with letters and symbols), so subword tokenization and a model trained on real evasion examples beat any keyword list.
- OCR text from images (seller adds "DM for the real price" or a model number in the photo), run through the same encoder.
- Simple signals: contact info in the text ("text me at..."), "local pickup only," "no questions."
Image features
- An image embedding per photo from a pretrained vision encoder (a CLIP-style ViT), fine-tuned on our policy labels.
- An object detector (a YOLO- or DETR-style model) for weapon parts: barrels, magazines, triggers, ammunition. Detectors localize, which gives reviewers a bounding box and catches a gun in the background of a "selling my jacket" photo.
- Perceptual hashes (PDQ, pHash) matched against an index of previously removed images, which stops the same photo being reposted.
Listing and price features
- The seller's chosen category, and the mismatch between that category and the predicted one (a "phone case" whose photos look like a firearm).
- Price vs category norm: a "gun case" at $800 is suspicious when gun cases sell for $40. Price z-score within the predicted category is a cheap, strong feature.
Seller features
- Account age, verified identity, past violations by category, past appeals won, listing velocity, location, and the account's bot score from the spam system.
Retrieval features
- Cosine similarity to the nearest known violating listings in an embedding index (Faiss or an HNSW index), and the categories of those neighbors.
Batch vs real-time. Seller features and violation history update in near-real time from enforcement events (a seller just rejected for a firearm should be scrutinized on their next listing seconds later). Image embeddings are computed once per photo and cached in object storage keyed by photo hash, so re-checks don't pay for them again. Category price norms update daily.
Modeling
Bad Solution: Keyword Lists and Category Blocks
Approach
Reject listings whose text contains words like "pistol," "rifle" or "ammo," and remove the "firearms" category from the site.
Challenges
Sellers just don't use the word. They post a photo and write "hunting accessory." Meanwhile "Nerf rifle," "rifle scope cleaning kit" and "Pistol Pete basketball jersey" get rejected. Keyword lists give you low recall and low precision at the same time.
Good Solution: Separate Text and Image Classifiers, Late Fusion
Approach
Train a text classifier on title, description and OCR text, and an image classifier on each photo (fine-tuned ViT, multi-label heads per category). Combine with a small GBDT over the text score, the max image score across photos, the detector outputs, price features and seller features.
Challenges
The two models never see each other's input. A listing whose text says "replica" and whose photo shows a realistic gun needs both at once to judge (in many places, realistic replicas fall under a separate rule). Late fusion over scores loses those interactions. Each policy category needs enough labeled data in both modalities, and a new category starts from nothing.
Great Solution: Multimodal Fusion Model, Retrieval and a VLM for the Hard Cases
Approach
- A multimodal fusion model. Encode the text (title, description, OCR) with a text transformer and each photo with an image encoder, then fuse them with a small transformer that attends across the text tokens and all image embeddings of the listing. Output multi-label scores per policy category, plus per-image attention weights that show which photo drove the decision. Starting from CLIP-style encoders pretrained on image-text pairs helps a lot, because they already align "rifle" with pictures of rifles.
- Retrieval against known violations. Look up the listing's embedding and image hashes in the violation index. A near-copy of a listing we removed last week is caught even if the classifier is unsure.
- A decision GBDT that takes the fusion scores, detector outputs, retrieval similarities, price anomaly and seller history, and outputs calibrated per-category probabilities. Seller history matters: the same ambiguous photo from a seller with two prior firearm violations is a different case.
- A vision-language model for the uncertain band. Before a listing goes to a human, a VLM (an open-weight model served with vLLM, or a hosted one) gets the photos, text and the written policy for the suspected category, and answers whether it violates and why. It's too slow and expensive for every listing (hundreds of milliseconds to seconds on a GPU), but on the 1-2% in the uncertain band it resolves many cases and gives reviewers a summary.
Challenges
The fusion model is bigger to train and serve, and needs paired data in all modalities. The VLM needs guardrails: it can be confidently wrong, so we never auto-reject on its word alone in severe categories, and we evaluate it on the gold sets like any other model. Retrieval needs the violation index kept fresh as reviewers confirm new cases.
Training
Loss. Binary cross-entropy per category (multi-label, not softmax, since categories aren't exclusive), with per-category positive weights. For rare severe categories, focal loss or oversampling positives helps the model focus on hard examples.
Fine-tuning strategy. Start from pretrained encoders, fine-tune the top layers and the fusion module on our labels. Full fine-tuning of the image encoder is worth it once we have hundreds of thousands of labeled images, because marketplace photos (cluttered, badly lit, partial) are unlike web photos.
Hard negatives. Toy guns, airsoft and paintball, gun-shaped lighters, holsters and safes, hunting knives where they're allowed, movie props, video game merchandise. Mine them from overturned appeals and from reviewer reason codes, and keep them in every training set. They're what separates a usable model from one that rejects every water pistol.
Cadence. Retrain the decision GBDT weekly, fine-tune the fusion model every few weeks or when a policy changes, and add confirmed violations to the retrieval index within minutes, which is our fastest way to respond to a new pattern.
Per-country policies live in the decision layer, not the model. The model predicts "this is an airsoft gun" or "this is a knife with a blade over 10 cm," and per-country rules decide whether that's allowed. That keeps one model and many policies, rather than a model per country.
Evaluation
Offline Metrics
- Recall at the auto-reject precision target, per category. For firearms: of all firearm listings, what fraction do we auto-reject at 95% precision, and what fraction do we catch including the review band?
- PR-AUC per category, because categories have very different base rates and averaging hides the rare severe ones.
- Review band size at the target recall: how many listings go to humans. This directly prices the model in headcount.
- Gold-set accuracy on the hard edges (replicas, airsoft, parts), checked before every launch.
- Slices by country, language, and seller tenure.
Online Metrics and A/B Testing
- Violating view prevalence: views on prohibited listings per million views, from the daily audit sample.
- Proactive rate: the share of removed listings caught before any user report.
- Overturn rate on appeals and seller complaints per thousand rejects.
- Review queue size and time to decision.
- Seller-side guardrails: listing completion rate and publish latency.
A/B test by seller, not by listing. Compare proactive rate, overturn rate, review load and seller metrics. For severe categories you can't run a holdout that lets weapons through, so the challenger is evaluated in shadow mode first (score every listing, act on none), and its disagreements with the champion are labeled by reviewers before it takes over.
Serving
Listings are saved as PENDING and checked by a moderation pipeline before they're published.
- The Listing Service stores the listing and photos (photos go to S3) with status
PENDINGand calls the Moderation Orchestrator. - The orchestrator runs steps in parallel: fetch seller features from the online feature store, compute or fetch cached image embeddings, run OCR, look up perceptual hashes and embedding neighbors in the violation index.
- The fusion model and detector run on a GPU inference service (NVIDIA Triton), batched across listings.
- The decision GBDT and per-country policy produce the outcome. Clear cases are published or rejected; uncertain ones go to the VLM and then, if still uncertain, to the review queue.
Latency budget, p95:
| Step | Budget |
|---|---|
| Download and resize 5 photos | 150 ms |
| Image encoder + detector (batched on GPU) | 100 ms |
| OCR on photos with text | 300 ms (parallel) |
| Text encoder + fusion model | 50 ms |
| Feature fetch, hash and kNN lookups | 50 ms (parallel) |
| Decision model and policy | 10 ms |
| Queueing and headroom | ~1 s |
The automatic path finishes well under the 2-second target; the VLM adds a second or two for the 1-2% that need it, still acceptable for a seller. Anything sent to human review is held, and the seller is told the listing is "under review."
Batch prediction handles everything that isn't a new listing: re-scanning all 100 million active listings when a model or policy changes, nightly re-scoring of listings whose seller was just penalized, and refreshing the violation index. Because embeddings are cached, a full re-scan only reruns the fusion head and decision model, which is cheap.
Potential Deep Dives
1) How do we handle sellers who try to evade the system?
Weapons sellers are motivated and adapt. Common tricks and counters:
- Clean text, telling photo (or the reverse). The multimodal model sees both; the detector catches weapons in the background.
- Code words and misspellings. Learned from labels, not lists; reviewer reason codes surface new slang, which gets added to training data and to the violation index quickly.
- Text on images ("DM for price," a serial number). OCR.
- Innocent first, edit later. Publish a phone case, then swap the photos for a pistol. Every edit is a new check, and edits that change photos or price sharply get a higher prior.
- Move the deal off-platform. The listing is vague and the real details are in chat. Use chat signals where policy allows: a classifier on buyer-seller messages can re-score the listing and flag it for review.
- Reposting after removal. Perceptual hashes and embedding neighbors catch reused photos and near-copies; seller and device links catch new accounts made by banned sellers.
When you list evasion tactics, pair each one with a specific counter. "Adversaries adapt, so we retrain" is weaker than "edits trigger a re-check, and reused photos hit the PDQ index."
2) How do we make human review efficient?
Bad Solution: First In, First Out
Approach
Every held listing goes into one queue, oldest first.
Challenges
A likely firearm waits behind 500 borderline lighter listings, and reviewers spend most of their time on low-stakes calls.
Good Solution: Priority by Severity and Confidence
Approach
Order the queue by expected harm: severity of the predicted category times its probability, boosted by predicted reach (a seller with many followers, a popular category). Route items to reviewers trained on that category and language.
Challenges
It's efficient for enforcement but not for learning: the queue is full of cases the model is already fairly sure about, which teach the next model little.
Great Solution: Priority Queue Plus Active Learning and Quality Control
Approach
Most capacity goes to the priority queue. A fixed slice (say 10-15%) goes to active learning: the listings where the model is most uncertain or where models disagree, which add the most information per label. Another slice is the random audit. Each reviewer's queue includes gold items to measure accuracy, items are double-reviewed at a sampled rate to measure agreement, and disagreements go to adjudication. The tool shows the model's evidence (highlighted phrase, the image with the detector's box, nearest known violations) so decisions take seconds, not minutes.
Challenges
Active learning trades a little short-term enforcement for long-term model quality, which needs explicit buy-in. Showing model evidence speeds reviewers up but can anchor them toward the model's answer, so the gold items are also how we detect reviewers rubber-stamping.
3) How do we add a new policy category quickly?
A new rule ("no listings of a recalled baby product," "no knives over 10 cm in country X") arrives with zero labels and a launch date in two weeks.
- Zero-shot first. Use CLIP-style image-text similarity with prompts describing the item, plus the VLM with the policy text, to score the catalog. Precision won't be great, so everything above a threshold goes to review, not auto-reject.
- Bootstrap labels. Reviewers label the zero-shot candidates. A few thousand labels with active learning are usually enough to fine-tune a new head on the fusion model.
- Add the head. The multi-label fusion model gets a new output; the shared encoders already understand the visual concepts, so the new head trains quickly.
- Graduate to auto-actions once the head hits the precision target on a held-out set.
Per-country rules that only change what's allowed (not what the item is) are just a policy table change, with no retraining.
4) How do we re-check 100 million live listings after a model change?
When a new model ships, or a policy tightens, existing listings must be re-evaluated. A batch inference job (Spark or Ray over the listing table) reads cached image and text embeddings, reruns the fusion head and decision model, and writes new scores. With embeddings cached, the heavy encoders don't rerun, so 100 million listings is a few hours on a modest cluster. Newly flagged listings are throttled into the review queue at a rate reviewers can handle, highest severity first, so a policy change doesn't create a million-item backlog overnight. Listings whose photos were never embedded (older than the cache) are encoded in the same job on GPUs.
5) How do we measure prevalence and keep thresholds right?
Prevalence is estimated from a daily stratified random sample of viewed listings, oversampling high-risk categories and countries and weighting back, so a 0.05% category gets enough samples for a useful confidence interval. Thresholds per category are set from precision-recall curves on recent labeled data and re-checked weekly. Calibration drifts as sellers adapt and as the catalog mix changes (holiday seasons bring floods of new categories), so recalibrate the decision model on fresh review labels rather than trusting last quarter's thresholds.
What is Expected at Each Level?
Mid-level
You should frame it as classification over listing text and images, explain why keyword lists fail, and propose text and image models combined somehow. You should mention human review for uncertain cases, use precision and recall, and know that labels come from reviewers. A reasonable serving flow where listings are held as pending until checked is enough.
Senior
You should design a multimodal multi-label model with OCR, detectors and seller features, and separate the per-country policy from the model. Expect to discuss label quality (gold sets, agreement, adjudication), hard negatives like toys and airsoft, active learning, thresholds per category tied to review capacity, and shadow-mode evaluation for severe categories. You should handle re-checks on edits and catalog re-scans.
Staff+
You should treat the human review system and the model as one product: the model exists to keep the review band small and to make each review fast, and review exists to produce labels and handle edge cases. Expect to drive evasion tactics and their counters, retrieval against known violations, a VLM for the uncertain band and for zero-shot new policies, the cost model of review headcount vs model thresholds, and unbiased prevalence measurement. Strong candidates also cover seller fairness and appeals as part of the system, not an afterthought.