---
title: Evaluation and monitoring platform for LLM features
url: https://gurkanozkan.ai/learn/design/applied-llm-sd-08/
markdown: https://gurkanozkan.ai/learn/design/applied-llm-sd-08.md
kind: design
role: Applied LLM
json: https://gurkanozkan.ai/api/learn/design/applied-llm-sd-08.json
---

# Evaluation and monitoring platform for LLM features

Design a platform that lets product teams evaluate LLM features before release (datasets, graders, LLM judges, comparisons) and monitor them in production.

## What to cover

- **Requirements**: number of teams/features; data sensitivity; human labelling capacity; release cadence; online traffic volume
- **Estimates**
- **API**
- **Data model**
- **Architecture**: dataset 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 dives**: the judge model is upgraded — what happens to historical comparisons?; How do you detect eval-set contamination or staleness?
- **Trade-offs**: judge cost vs coverage; reproducibility (pinned models) vs freshness; central platform vs team autonomy; storing raw traces vs privacy
- **Evaluation**: judges validated and versioned; statistics, not point estimates; slices; tight loop from production failures into datasets; privacy controls

## Reference design

### 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

```
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

**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.

---

*Study material compiled with AI: drafted by a local model (Inkling 2 Mini) from public sources, then checked against those sources by independent AI reviewers (Claude) in November 2026. Not reviewed line by line by a person.*
