Contents
What to cover
Sketch your own design first. A complete answer has these parts; the notes say what each should settle.
- Requirementsnumber of teams/features; data sensitivity; human labelling capacity; release cadence; online traffic volume
- Estimates
- API
- Data model
- Architecturedataset registry (versioned, slices, provenance, PII controls); grader library (code checks, model-graded with versioned prompts, human review queues); judge calibration against human labels; experiment runner (concurrency, caching, seeds, repeated samples); comparison reports with confidence intervals and slice breakdowns; CI gates; production tracing (prompts, retrieval, tools, cost); sampled online grading and alerting; feedback-to-dataset loop
- Deep divesthe judge model is upgraded — what happens to historical comparisons?; How do you detect eval-set contamination or staleness?
- Trade-offsjudge cost vs coverage; reproducibility (pinned models) vs freshness; central platform vs team autonomy; storing raw traces vs privacy
- Evaluationjudges validated and versioned; statistics, not point estimates; slices; tight loop from production failures into datasets; privacy controls
Reference design
One way to answer it, part by part. Open a part once you have your own version of it.
Requirements
Functional: versioned datasets; a library of graders (code checks, LLM judges, human review); experiment runs comparing variants (prompt, model, retrieval config); reports with uncertainty; CI gates; production tracing; sampled online grading with alerts; a path from production failures into datasets.
Assumptions to confirm
- Teams and features: ~40 teams, ~150 LLM features (chat, RAG, agents, extraction), each with its own quality definition.
- Data sensitivity: production traces contain customer PII and confidential documents; some features are regulated. Redaction, access control and retention are requirements, not options.
- Human labelling capacity: ~10 annotators plus part-time SMEs ≈ 2k labels/day in total — far below traffic, so humans calibrate judges rather than grade at scale.
- Release cadence: prompt and retrieval changes daily, model upgrades monthly, provider deprecations a few times a year.
- Online traffic: ~50M LLM calls/day across features.
- Users: engineers and PMs, not ML specialists; the default path must give statistically sound answers without expertise.
- Non-goals: training infrastructure; the platform does not own each team’s quality definition.
Estimates
- Trace volume: 50M calls/day × ~10 KB (prompt, output, retrieval ids, tool calls, metadata) ≈ 500 GB/day raw, ~100 GB/day compressed; 30 days hot ≈ 3 TB; afterwards only aggregates and curated examples.
- Online grading: code checks (format, schema, PII, refusal markers) on 100% — cheap. Small-model judge on 1% = 500k grades/day × ~3k tokens ≈ 1.5B tokens/day ≈ $225/day at an assumed $0.15/M. Strong judge on 0.1% = 50k grades ≈ 150M tokens × $3/M ≈ $450/day. Humans: ~2k/day, stratified.
- Offline runs: a typical run is 1,000 items × 5 samples × 2 variants = 10k generations + 10k judge calls ≈ 60M tokens ≈ $50–200 depending on models. 150 features × ~1 full run/week × ~$100 ≈ $15k/week; caching responses on (model, prompt, params, seed) means the unchanged baseline is never paid for twice, roughly halving that to ~$30k/month. Small smoke runs on every PR cost cents.
- Statistical resolution: for a pass rate near 80% with n = 1,000, SE = √(0.8 × 0.2 / 1,000) ≈ 1.3 points → 95% CI ±2.5 points. Comparing two variants on the same items: unpaired, the difference has SE ≈ √2 × 1.3 ≈ 1.8 points; pairing (assuming item-level correlation ≈ 0.5) halves that variance, giving SE ≈ 1.3 points. A difference of ~2.5 points then reaches significance, and the minimum detectable effect at 80% power is ≈ 2.8 × 1.3 ≈ 3.5 points. Reliably catching 2-point regressions needs ~3,000 items (2.8 × √(0.16 / 3,000) ≈ 2 points) or more samples per item.
API
SDK (OpenTelemetry GenAI conventions):
with tracer.span("rag.answer", feature="kb-assistant") as s: ... # llm, retrieval, tool spans
POST /v1/datasets {name, schema, items[] | from_traces: {query, sample_n}, pii_policy, slices}
→ {dataset_id, version}
POST /v1/graders {type: "code"|"llm_judge"|"human", spec: {template, rubric, judge_model, output_schema}}
→ {grader_id, version}
POST /v1/graders/{id}/calibrate {gold_set_id} → {agreement, kappa, bias_by_slice}
POST /v1/experiments {feature, dataset_version, variants: [{prompt_version, model, params}],
graders: [grader@version], samples_per_item: 5, seed} → {run_id}
GET /v1/experiments/{run_id}/report → metrics with CIs, paired deltas, per-slice tables, worst items
POST /v1/gates {feature, metric, comparator: "non_inferior", margin: 0.02, baseline: "prod"}
POST /v1/monitors {feature, sample_rate, graders, alert: {metric, threshold, window}}
POST /v1/traces/{id}/promote {dataset_id, label?, note}Data model
- Feature: owner team, data classification, linked prompts and models, gates.
- Dataset / DatasetVersion (immutable): items, slice tags, provenance (production trace, synthetic, SME-written, red-team), PII class, split (dev | held-out), created_from query.
- Item: input, optional reference, metadata, slice tags, content hash.
- Grader / GraderVersion (immutable): type, template hash, rubric, judge model snapshot, output schema, calibration record.
- Calibration: grader version × gold set → agreement, Cohen’s kappa, bias per slice, date.
- Run: variant config hash, dataset version, grader versions, seeds, samples per item, cost.
- Output and Score: (run, item, sample) → output; (output, grader version) → value, rationale.
- Trace / Span: feature, request id, prompts, retrieval ids, tool calls, tokens, cost, latency — payloads redacted at ingest, stored separately with shorter retention than metadata.
- HumanLabel: item or trace, annotator, label, time spent, guideline version.
- Alert: monitor, window, metric value, linked traces.
ClickHouse for spans and scores, object storage for payloads, Postgres for registries.
Architecture
Flow · 4 stepsOffline evaluation flow
- Prepare inputs A versioned dataset and versioned graders are selected for the feature.
- Calibrate judges Human review queues supply gold labels; the calibration service checks agreement, kappa and bias by slice against human gold sets.
- Run experiments The runner executes variants with seeds, samples per item and response caching, then writes outputs and scores.
- Report and gate Reports show paired deltas with bootstrap CIs and per-slice tables; the CI gate applies the non-inferiority margin before release.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Prepare inputs | A versioned dataset and versioned graders are selected for the feature. |
| 2 | Calibrate judges | Human review queues supply gold labels; the calibration service checks agreement, kappa and bias by slice against human gold sets. |
| 3 | Run experiments | The runner executes variants with seeds, samples per item and response caching, then writes outputs and scores. |
| 4 | Report and gate | Reports show paired deltas with bootstrap CIs and per-slice tables; the CI gate applies the non-inferiority margin before release. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| Dataset registry | Data | versioned, slices, provenance, PII policy |
| Grader library | Data | code checks, LLM judges, human review |
| Human review queues | Data | labelling tool, SMEs, guidelines |
| Calibration service | Compute | judges vs human gold sets |
| Experiment runner | Compute | concurrency, cache, seeds, k samples |
| Score store | Compute | outputs and scores per grader version |
| Reports | Output | paired bootstrap CIs, slice tables |
| CI gate | Output | GitHub check, non-inferiority margin |
| Release | Output | gates refuse uncalibrated graders |
Source: This page's text
Flow · 4 stepsHow production traces become alerts
- Ingest and redact Product services send traces through the SDK/OTel; payloads are redacted and tokenised at ingest.
- Store and sample Redacted traces land in the trace store, then the sampler selects what to grade.
- Grade online Code checks run on 100%, a small judge on 1% and a strong judge on 0.1%.
- Alert Scores become metrics and alerts per feature and per slice, sent to on-call and team channels.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Ingest and redact | Product services send traces through the SDK/OTel; payloads are redacted and tokenised at ingest. |
| 2 | Store and sample | Redacted traces land in the trace store, then the sampler selects what to grade. |
| 3 | Grade online | Code checks run on 100%, a small judge on 1% and a strong judge on 0.1%. |
| 4 | Alert | Scores become metrics and alerts per feature and per slice, sent to on-call and team channels. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| Product services | Ingest | SDK/OTel |
| Trace collector | Ingest | |
| PII redaction/tokenisation | Ingest | payloads redacted at ingest |
| Trace store | Store | ClickHouse + object store |
| Sampler | Store | |
| Online graders | Grade | code 100% · small judge 1% · strong judge 0.1% |
| Metrics + alerting | Alert | per feature, per slice |
| on-call / team channels | Alert |
Source: This page's text
Product services ──SDK/OTel──► Trace collector ─► PII redaction/tokenisation
─► Trace store (ClickHouse + object store, per-feature access control)
─► Sampler ─► Online graders: code checks 100%, small judge 1%, strong judge 0.1%
─► Metrics + alerting (per feature, per slice) ─► on-call / team channels
Curation UI: filter traces (thumbs-down, judge failures, incidents) ─► promote to dataset
Dataset registry (versioned, slices, provenance, PII policy)
Grader library (versioned) ◄─► Calibration service (judges vs human gold sets)
Human review queues (labelling tool, SMEs, guidelines per feature)
Experiment runner: job queue, per-provider concurrency limits, response cache,
retries, seeds, k samples per item ─► Score store
─► Reports: paired bootstrap CIs, slice tables, worst-item browser
─► CI gate (GitHub check) ─► release
Same graders run offline and online, so a production regression and a pre-release eval speak the same language.
Deep dives
Flow · 5 stepsHow a judge model upgrade is handled
- New grader version A new judge becomes a new grader version with a pinned snapshot.
- Calibrate Calibrate the new version against human gold sets for agreement, kappa and bias by slice.
- Bridge re-score Re-score a fixed bridge set of stored historical outputs with both versions to quantify the shift.
- Show both Show both versions in reports during the transition window; never mix versions on one trend line.
- Re-baseline Notify teams whose gates depend on the judge and re-baseline those gates.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | New grader version | A new judge becomes a new grader version with a pinned snapshot. |
| 2 | Calibrate | Calibrate the new version against human gold sets for agreement, kappa and bias by slice. |
| 3 | Bridge re-score | Re-score a fixed bridge set of stored historical outputs with both versions to quantify the shift. |
| 4 | Show both | Show both versions in reports during the transition window; never mix versions on one trend line. |
| 5 | Re-baseline | Notify teams whose gates depend on the judge and re-baseline those gates. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| Judge upgrade | Upgrade | provider model change |
| New grader version | Upgrade | pinned judge snapshot |
| Human gold sets | Calibration | agreement, kappa, bias by slice |
| Bridge set | Calibration | stored historical outputs |
| Reports | Transition | both versions, no mixed trend line |
| Gate-dependent teams | Transition | re-baseline gates |
Source: This page's text
The judge model is upgraded — what happens to historical comparisons? Graders are immutable versions with a pinned judge snapshot, and scores are stored per grader version, so old numbers never silently change. A new judge becomes a new grader version: calibrate it against the human gold sets (agreement, kappa, bias by slice); re-score a fixed bridge set of stored historical outputs (not regenerated) with both versions to quantify the shift; show both in reports during a transition window; never mix versions on one trend line; notify teams whose gates depend on it and re-baseline those gates.
Detecting contamination or staleness. Contamination: near-duplicate search (n-gram and embedding) between eval items and fine-tuning data, few-shot examples and retrieval corpora; canary strings in held-out sets; provenance tracking; a held-out split that teams cannot view or iterate prompts on, scored only at release. Staleness: compare eval inputs with recent production traffic (embedding-cluster coverage, topic and language mix) and alert when production clusters are under-represented; watch for divergence between offline scores and online judge scores; refresh sets quarterly from recent traces.
Trade-offs
- Judge cost vs coverage: a cascade of code checks on everything, a cheap judge on a sample and a strong judge on a smaller sample buys coverage cheaply; humans calibrate rather than grade.
- Reproducibility (pinned models) vs freshness: pinned judge snapshots and cached outputs make results reproducible, but providers deprecate models; plan judge migrations as explicit version changes with bridge sets.
- Central platform vs team autonomy: the platform owns primitives (datasets, runners, statistics, gates, tracing) and safe defaults; teams own their rubrics, datasets and thresholds. A central team writing every grader would become a bottleneck.
- Storing raw traces vs privacy: raw payloads help debugging but are a liability. Redact at ingest, keep payloads 30 days, aggregates for a year, restrict access per feature, require approval for retained raw examples, and honour deletion requests across traces and datasets.
Evaluation
- Judges validated and versioned: every judge has a calibration record (target kappa ≥ 0.6–0.7 against humans) and a version; gates refuse uncalibrated graders.
- Statistics, not point estimates: reports show paired deltas with bootstrap CIs, several samples per item to capture model randomness, and an explicit non-inferiority margin for gates.
- Slices: every report breaks down by language, customer segment, input length and feature-specific tags; a regression in any critical slice blocks a release even if the average improves.
- Tight loop from production to datasets: median time from a production failure to a regression item < 2 days; count of items promoted per feature per month.
- Privacy controls: redaction recall audited on samples; access logs; retention enforced automatically.
- Platform health: adoption (features with gates and monitors), incidents caught before vs after release, alert precision, run turnaround time, spend per feature.
What a strong design shows
- Versions judges and calibrates them against humans; never mixes grader versions on one chart.
- Reports uncertainty — confidence intervals, paired comparisons, repeated samples — and states the minimum detectable effect.
- Makes slices first-class and blocks releases on slice regressions, not just averages.
- Turns production failures into dataset items quickly and guards held-out sets against contamination and staleness.
- Treats trace privacy (redaction, retention, access) as a core design constraint.