Design a Low-Latency Safety Classifier Pipeline for Prompts and Completions
Last updated: November 29, 2026
Quick Overview
Design a system that classifies every user prompt and model completion for policy violations (for example self-harm, sexual content involving minors, violent extremism) with very high recall on the most severe categories and minimal added latency, including during streaming.
OpenAI
November 29, 20260
0
0 solved
Design a system that classifies every user prompt and model completion for policy violations (for example self-harm, sexual content involving minors, violent extremism) with very high recall on the most severe categories and minimal added latency, including during streaming.
OpenAI runs moderation at enormous volume across ChatGPT and the API, and the classifiers must be fast, accurate across languages, and able to act on streamed output before harm is shown. Interviewers look at the cascade architecture, label strategy with policy experts, streaming checks, and evaluation by category severity.
What the Interviewer Expects
- Define a taxonomy with severity tiers and per-category thresholds
- Use a cascade: cheap fast classifier for everything, larger model for uncertain or high-severity cases
- Classify streamed completions incrementally without blocking tokens
- Build labels with policy-trained annotators plus model-assisted labeling
- Measure recall at fixed precision per category and per language
- Handle adversarial inputs (obfuscation, jailbreak phrasing)
Key Topics to Cover
How to Approach This
- Start by mapping the business objective to a concrete ML objective and metric.
- Cover the full pipeline: data collection, feature engineering, model selection, training, serving.
- Discuss online vs offline evaluation. Plan an A/B test to validate real-world impact.
- Address the serving latency budget and whether batch or real-time inference is needed.
- Think about the data flywheel: how user feedback improves the model over time.
Possible Follow-up Questions
- How do you check a streaming answer without delaying every token?
- How do you set thresholds when categories have very different base rates and harms?
- How do you evaluate for low-resource languages?
- How do you update the classifier quickly when a new jailbreak pattern appears?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice ML System Design ProblemsSample Answer
Requirements
- Classify inputs and outputs across a policy taxonomy, multi-label with scores.
- Added latency: under 30 ms p95 on input; on output, flag within about one sentence of violating text.
- Recall on the...
High-Level Design
- Stage 1: small multilingual transformer (distilled, a few hundred million parameters or less) scoring all categories, served on GPUs with dynamic batching.
- Stage 2: a larger LLM-based judg...