KatInterview

Content moderation classifier for social platforms

Machine LearningModel answer
MediumModel answerMachine Learningclassificationimbalanced-dataproduction-ml

Last updated

Design an ML system to flag inappropriate user posts in real time, covering data collection, model architecture, threshold tuning, and production monitoring.

You're building a machine learning pipeline to automatically detect inappropriate content in user-generated posts on a social platform.

Context

Your platform receives approximately 100 million posts daily. A small fraction (well under 1%) violates community guidelines. Human moderators can review roughly 50,000 flagged items per day. The system must make decisions quickly enough not to degrade the user posting experience.

Your Task

Design the end-to-end ML system. Address each of these dimensions:

  1. Data collection and labeling. The rate of policy-violating posts is very low, and human raters often disagree on borderline cases. How will you gather training data? How will you handle annotation disagreement and ensure label quality?

  2. Model selection. Compare at least two modeling approaches—one lightweight (such as logistic regression with text features) and one deeper (such as a compact transformer). What are the trade-offs for a high-traffic production service? Which would you choose and why?

  3. Evaluation and threshold setting. Letting harmful posts through is more costly than incorrectly flagging benign ones. Which metrics matter most? How will you choose classification thresholds when you have actions like auto-remove, send to human review, and allow?

  4. Deployment and monitoring. Inference must complete in under 50 milliseconds at the 99th percentile, and language evolves constantly. How will you meet the latency requirement? How will you detect when the model's performance degrades over time?

Assumptions

  • You have access to a team of trained human moderators for labeling.
  • The platform supports multiple languages.
  • You can define what "inappropriate" means for this exercise (hate speech, harassment, spam, etc.).

Hints

Hint 1

Think about mixing random sampling with targeted sampling strategies—relying only on random samples wastes your annotation budget when the base rate is so low.

Hint 2

Consider a tiered architecture: a fast model handles every post synchronously, while a slower, more accurate model processes uncertain cases asynchronously.

Hint 3

Accuracy is a misleading metric when 99%+ of posts are fine—focus on precision-recall curves and measure performance on a holdout set that reflects true prevalence.