LLM evaluation and guardrails platform system design: judges, guard latency, paired eval gates and safe rollouts
How to design an evaluation and guardrails platform for every LLM feature in a company, in real interview order: guard checks per second, judge calls a day and eval examples per run as the numbers that matter, an AI gateway API with versioned configs and structured block events, an explainer on what an LLM judge's score really means (sensitivity, specificity and the correction), input and output guards, traces, graders, datasets, online scoring and release gates built in passes, one support request walked from guards to a regression test and a canary, a lab on whether an eval can see a regression (set size, pairing, judge quality), a lab on guards on the hot path (latency, false blocks, misses, cost and exposed tokens), rollouts, online scoring, prompt vs fine-tune, and what happens when each part fails.
The 1-minute answer
How this page follows the interview
Each phase is a section below, in the order you'd present it. Click a phase for what to say, what to write, and the trap.
Serving the models is Part 22; RAG Part 25; agents and tool safety Part 28; moderating user posts Part 34; A/B tests for rankers Part 35. This page is the platform that checks all of them. Designed from public material only: no employer's internal systems.
Requirements and numbers
Agree what must never happen, what should be good, and how much latency guards may add, then size guard checks per second, judge calls a day, and eval examples per run. Change any input: each number comes with the decision it forces.
Functional
- Every LLM call from every product goes through one gateway with input and output guards
- Versioned configs: model, prompt, guard policy, per product
- Offline evals on every change: datasets, graders (code, classifiers, LLM judges), a pass/fail gate
- Online scoring of sampled production traces; user feedback joined to traces
- Staged rollouts with automatic rollback
Non-functional
- Guards add ≤ ~150 ms before the first token, plus one held-back chunk
- Few good conversations blocked (≤ 1%); known attacks caught (≥ 95%)
- Eval results reproducible: pinned datasets, graders and judge versions
- A 3-point quality drop caught before most users see it
- PII masked in traces and datasets; data stays where policy says
Out of scope (say it)
Training the product models, the serving stack (Part 22), retrieval (Part 25), tool execution (Part 28) and moderating user posts (Part 34).
Capacity calculator
Every input is an assumption 🔶: say it out loud. Volumes and prices are round teaching numbers, not any company's ❓. For scale: Prompt Guard 2's 22M-parameter classifier takes 19.3 ms per 512-token check on an A100 ✅ Prompt Guard 2
- Checks, not requests: one input check plus one per output chunk.
- Judges cost per call: online sample × traffic, plus runs × examples × 2 versions.
- People are the scarce part: label a small, well-chosen share.
Core entities and the API
Products call the gateway by product name; CI calls the eval runner with a candidate and a baseline. What they listen for: config versions on every trace, a structured block event, and eval results as a paired difference with an interval.
| Entity | Key fields | Note |
|---|
What does the judge's score really mean?
An LLM judge is a classifier with its own errors. Give it a few hundred examples people have labelled, count where it agrees and where it doesn't, and you can correct the pass rate it reports on production. Pick a judge, or type your own counts.
What the sources say
- Strong judges ≈ people, on average: GPT-4 agreed with human preferences over 80% of the time, as often as people agree with each other. ✅ Zheng et al. 2023
- But biased: position, verbosity and self-enhancement bias. ✅ Zheng et al. 2023
- Correct the score: imperfect sensitivity and specificity bias the naive score; intervals should include the calibration set's uncertainty. ✅ Lee et al. 2025
- Check with people: "track the correlation between model-based and human evaluation". ✅ Husain 2024
The correction is the classic Rogan–Gladen formula p = (q + spec − 1) ÷ (sens + spec − 1). It assumes the calibration set looks like production; the counts are made up for teaching 🔶.
High-level design
Build it in passes and say why each box exists. Click any box to see what it does, what it owns, what's inside it and what you'd watch.
Walk one request, box by box
At 22:10 Arjun, in Pune, asks the support assistant of a lender (Kaveri Finance, made up) why he was charged a late fee, and types his PAN number. Each step lights up the path and shows what goes over the wire, what's stored and how long it takes, through the guards, the trace, a flagged answer, a new regression test and the fixed prompt's rollout.
Arrows show who calls whom, and the numbers give the order. Replies go back along the same line.
What keeps it fast and cheap
Putting an LLM judge in front of every answer is a demo. These six details are what keep guards to tens of milliseconds and judge bills sane.
Data and database choices
Version everything a score depends on. Traces go to a log and daily files, datasets are immutable versions, eval scores are rows you can join by example, and configs are versioned like code.
| Data | Pick | Considered | Why not those |
|---|
The one thing to know: the paired gate
# Score both versions on the SAME examples. a = score(baseline, examples) # 0/1 per example b = score(candidate, examples) # same judge@v3 d = [bi - ai for ai, bi in zip(a, b)] delta = mean(d) se = stdev(d) / sqrt(len(d)) # paired SE lo, hi = delta - 1.96*se, delta + 1.96*se # Block if the drop could be > 1 point, # or if any regression case fails. ok = lo > -0.01 and all(regression_pass)
Illustrative; names made up. Anthropic recommends paired differences and standard errors when comparing two models ✅ Anthropic Nov 2024
Why it's written like that
- Same examples: the per-example difference cancels how hard each example is. ✅ Anthropic Nov 2024
- Same judge version: otherwise you're measuring the judge's change. 🧭
- An interval, not a number: block when the drop could be bigger than you accept. ✅ Miller 2024
- Regression cases are absolute: a past failure that comes back blocks, whatever the average says. ✅ Husain 2024
More database questions
Deep dive: can the eval see a regression?
An eval gate is a statistical test. With too few examples it waves regressions through; with a weak judge the drop shrinks before you can measure it. How many examples, paired or not, and how good the judge must be decide whether the gate means anything. Pick a preset, then change the numbers.
Each example passes or fails. The judge passes a truly good answer with probability = sensitivity and fails a bad one with probability = specificity, so it sees (sens + spec − 1) × the real drop. Two-sided 5% test; paired variance = Var(A) + Var(B) − 2ρ·SD(A)·SD(B) ✅ Anthropic Nov 2024. Rounded teaching values 🔶.
The rules this lab teaches
- Size the set from the drop: 100 examples only see ~20-point drops; a 3-point drop needs thousands. 🔶
- Pair everything: same examples for both versions roughly halves the examples needed here. ✅ Anthropic Nov 2024
- Fix the judge before the set: a judge with J = 0.55 hides almost half of every drop. ✅ Lee et al. 2025
- Gate on a subset, run the rest nightly: a huge set with a big judge is too slow and costly for every change. 🧭
Real guidance to quote
Anthropic (Nov 2024): report the standard error of the mean; cluster standard errors when questions aren't independent; resample answers and average per question; use paired differences; and "use power analysis". ✅ Anthropic Nov 2024
Shankar et al. (2024): LLM evaluators "inherit all the problems of the LLMs they evaluate, requiring further human validation"; criteria drift as people grade. ✅ Shankar et al.
Hamel Husain (Mar 2024): three levels: unit tests on every change, model and human evals on a cadence, A/B tests after significant changes. ✅ Husain 2024
Deep dive: guards on the hot path
Every guard trades five things at once: milliseconds before the first token, good conversations wrongly blocked, bad ones let through, dollars, and tokens a user sees before a block. Where the guard sits (before or alongside the model, held-back chunks or streamed first) moves all five. Bars past the dashed line break a limit. Pick a preset, then change the switches and numbers.
Cascade: the classifier checks everything and sends the uncertain band to the judge; recall = Rc + (1 − Rc) × share of misses in the band × Rj; a block from either counts, so its false-positive rate is an upper bound. Every check can fire falsely: 1 − (1 − FPR)checks. Rates and prices are rounded teaching values 🔶; chunking follows NeMo Guardrails ✅ NeMo docs.
Three rules, in order
- Cheap first, smart second: a classifier on everything, the judge on the uncertain band. 🧭
- Hide latency, not risk: run the input check alongside the model; hold back output chunks for leaks, stream first only for tone. ✅ OpenAI cookbook · NeMo
- Count checks, not only accuracy: five checks at 0.15% each block 0.75% of good answers. 🔶
Numbers to quote
Llama Prompt Guard 2: 22M model 19.3 ms and 86M model 92.4 ms per 512-token check on an A100; 88.7% and 97.5% recall at 1% false positives on Meta's English jailbreak set; 512-token context. ✅ Prompt Guard 2
NeMo Guardrails: output rails check 200-token chunks with 50 tokens of context by default; with stream_first on, "if a rail blocks the content, the user has already received the tokens". ✅ NeMo docs
OpenAI cookbook (Dec 2023): "send your guardrails asynchronously along with your main LLM call"; weigh accuracy, latency and cost. ✅ OpenAI cookbook
Deep dive: rollouts, online scoring, and prompt vs fine-tune
Offline evals rank changes; real users decide. A worse model returns fast, polite answers that are a little less right, so every change climbs a ladder, and production is scored all the time.
The release ladder
How fast does online scoring notice a drop?
n = ((1.96·√(o₀(1−o₀)) + 0.84·√(o₁(1−o₁))) ÷ (o₀ − o₁))² for the judge's own before/after scores o₀ and o₁, a one-sample test against a known baseline at 80% power 🔶. Oversample a canary arm to see it sooner.
Offline evals, judges and A/B tests: useful, with limits
Prompt a judge, fine-tune a guard, or buy one?
Tick what's true for this check.
Cost and latency per request
- Route checks by difficulty: code, then classifier, then judge; most requests never reach the judge. 🧭
- Batch guard models: small classifiers batched across requests on shared GPUs. ✅ Prompt Guard 2
- Cache verdicts: the same system prompt or retrieved document is checked once per version, not per request. 🧭
- Cheaper judge for gates, big judge nightly: calibrate both on the same human labels. 🧭
- Sample by risk: every thumbs-down and canary trace, 1% of the rest. 🧭
Guardrails beyond the guards
- Least privilege: tools get only what the task needs; their own tokens, handled in code. ✅ OWASP LLM01
- Human approval for high-risk actions, whatever the guard says. ✅ OWASP LLM01
- Untrusted content marked: retrieved and tool text kept separate from instructions. ✅ OWASP LLM01
- Red-team regularly: attack simulations against the live config. ✅ OWASP LLM01
Regression tests for models, prompts and policies
- Every incident becomes a case: the failing trace, masked, with the expected behaviour. ✅ Husain 2024
- Assertions in CI: fast, cheap checks on every change. ✅ Husain 2024
- Red-team set hourly: known attacks against the live guard config. 🧭
- A reference config scored daily: if its score moves, the judge or data changed, not the product. 🧭
A change's lifecycle
Every change (a model, prompt, policy or judge version) moves through a small state machine, from draft to retired. Click events to move it; ones that can't happen from the current state are disabled. Each event shows what fires across the system.
Edge cases interviewers love
Failure, monitoring and recovery
This platform fails loudly (guards slow every answer) and quietly (a judge that drifts, a guard that fails open, a set that's been learned). The quiet ones cost more. Click a box to take it down: red is the failed part, amber is its blast radius. Each answer covers impact, degraded mode, the alert, automatic and manual recovery, and how you'd trace it.
Tracing it back: a normal request vs a judge outage
Every span carries trace_id and config versions. Times are from the request; illustrative. In the bad trace the injection classifier is unsure, the judge escalation is rate-limited, and the policy says fail closed: the user gets a polite refusal and a hand-off.
How one failure becomes three
What you'd alert on (SLOs)
| Signal | Target | Alert |
|---|
Incident playbook
The toolkit
Name the technique, then say where it goes in this design.
Making it fast, and who owns what
Guards live in milliseconds; scores in minutes; verdicts in days. Keep the judge off the request path except for the uncertain few percent. Bars are sizing estimates, not measured figures.
| Team | Owns | Paged when… |
|---|
Senior follow-ups beyond the happy path
Interviewers pick from these themes once the design is on the board. Have one concrete answer per theme, tied to this design.
Practice ladder
Real interviews go level by level. Answer out loud before opening each one. Levels 6–7 are where Senior becomes Staff.
Sources
- A statistical approach to model evaluations, Anthropic (19 Nov 2024)
- Adding Error Bars to Evals: A Statistical Approach to Language Model Evaluations, Evan Miller (Nov 2024)
- Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena, Zheng et al., NeurIPS (2023)
- How to Correctly Report LLM-as-a-Judge Evaluations, Lee et al. (Nov 2025, revised May 2026)
- Who Validates the Validators? Aligning LLM-Assisted Evaluation of LLM Outputs with Human Preferences, Shankar et al. (Apr 2024)
- Llama Prompt Guard 2 22M model card, Meta on Hugging Face (checked Nov 2026)
- Llama Guard 4 12B model card, Meta via NVIDIA (Apr 2025)
- Output rail streaming configuration, NVIDIA NeMo Guardrails docs (checked Nov 2026)
- How to implement LLM guardrails, OpenAI Cookbook (19 Dec 2023)
- Expanding on what we missed with sycophancy, OpenAI (2 May 2025)
- Your AI Product Needs Evals, Hamel Husain (29 Mar 2024)
- LLM01:2025 Prompt Injection, OWASP Gen AI Security Project (Apr 2025)
- LLM evaluation and guardrails, PracHub (third party, used to cross-check interview expectations)
Checked November 2026. Eval statistics are from Anthropic's 'A statistical approach to model evaluations' (19 Nov 2024: standard errors, clustering, resampling, paired differences, power analysis) and Evan Miller's paper behind it (Nov 2024). Judge accuracy is from Zheng et al. (2023: over 80% agreement with people; position, verbosity and self-enhancement bias), Lee et al. (Nov 2025, revised May 2026: correcting for judge sensitivity and specificity) and Shankar et al. (Apr 2024: criteria drift). Guard numbers are from Meta's Llama Prompt Guard 2 model card (latency and recall at 1% false positives, checked Nov 2026), the Llama Guard 4 card (Apr 2025), NVIDIA's NeMo Guardrails streaming docs (200-token chunks, 50 tokens of context, stream_first; checked Nov 2026) and OpenAI's guardrails cookbook (Dec 2023: guards in parallel with the model). Rollouts lean on OpenAI's sycophancy post-mortem (2 May 2025); eval levels and traces on Hamel Husain (Mar 2024); prompt injection on OWASP LLM01:2025. The labs use rounded teaching values and textbook formulas, and say so. PracHub is a third-party prep site, used only to cross-check what interviewers expect. Nothing here comes from any employer's internal systems.
System Design Mastermind · AI / ML systems
Series homeAll of AI / ML systems
8 published · 1 comingLLM and ML systems, where interviews are heading.
LLM serving platform system design (ChatGPT-style): tokens, GPUs and safe model changes
Chat API (auth, token limits, history, safety, SSE with resumable event ids) → router picks model (easy turns to a small one), version (registry canary split) and a replica with the prefix cached → vLLM-style engines batch continuously up to the time-per-token target. Admit by priority because GPUs take minutes to add; ship every model change through evals, shadow and canary, with rollback by one number.
RAG assistant over company docs system design: retrieval, permissions and answers you can trust
Ingestion (change events + full sync → parse → chunk with a context line → embed only changed chunks) fills a versioned index of keywords, vectors and allowed principals. Serving rewrites the question, runs hybrid search with the permission filter inside it, reranks 150 → 8, answers only from numbered sources, checks grounding and re-checks cited docs. A golden set gates every change.
AI agent platform system design: tools, durable runs, approvals and agents you can trust
A durable orchestrator runs each agent as workflow code: pin the version, call the model through a caching gateway, record every step so crashes resume. The model only proposes tool calls; a tool gateway validates, authorizes with the user's own token, adds idempotency keys and parks irreversible steps for approval. Budgets stop runaways; end-state evals with k tries gate every release.
Offline GPU batch inference system design: millions of LLM calls by a deadline, on GPUs that can vanish
Validate the file, split it into ~20-minute shards, lease them to GPU workers on spot that load the model once and run hundreds of rows at a time with the shared prompt cached. Each attempt writes its own file; one conditional commit per shard makes output exactly-once. Golden set and canary shard gate every new version.
Content moderation pipeline system design: hash matching, classifiers, LLM checks and human review at a billion items a day
Hash at upload against known-bad lists, score every policy with small classifiers in ~50 ms, two lines per policy: remove above, allow below, and the band between goes to an LLM that reads the policy, then a review queue ordered by severity × reach × likelihood. Every decision logged with a reason, appealable, and gated by golden set → shadow → canary.
Recommendation system design (TikTok-style For You feed): candidates, ranking, freshness and A/B tests
Several sources (two-tower ANN search, like-your-likes, trending, a fresh pool) retrieve a few thousand items; a light ranker keeps a few hundred; a heavy multi-task ranker predicts finish, like, share and skip; a value model and re-rank add diversity, in ~200 ms. Events stream back to features in seconds and to incremental training in minutes; models ship via interleaving and A/B tests.
LLM evaluation and guardrails platform system design: judges, guard latency, paired eval gates and safe rollouts
Every product calls an AI gateway: versioned config, input guards (PII mask, a small injection classifier, an LLM judge only when unsure), output guards on streamed chunks, a trace per request. Off the path: sampled traces judged online, people calibrating the judges, failures turned into regression tests, and every change gated by a paired eval with error bars, then shadow, canary and A/B.
AI coding agent system design (Claude Code, Cursor, Codex): context, edits, sandboxes and evals
Three shapes, one backend: a small self-served Tab model per keystroke; an agent loop with a context engine (grep plus an optional index), a cached prompt to a frontier model, text-anchored edits or a fast apply model, permissions and an OS sandbox; and background agents in a container per task that open a PR. An eval harness gates every change on pass^k.