Offline vs online evaluation
Offline evals score a version on fixed datasets before deploy; online evals measure live traffic through user behavior, feedback and sampled judging. You need both, and if they disagree, trust neither until you know why.
Analogy: Offline is the flight simulator: cheap, repeatable, safe. Online is real flights with passengers: the only true test, so you start with a few routes and watch the instruments closely.
How it works
- Offline is cheap, repeatable and safe, but only as good as the dataset's match to real traffic.
- Online, instrument outcomes, implicit behavior (edits, retries, abandonment), guardrail triggers and a judge on 1–5% of traces.
- Thumbs up/down are sparse and skewed toward unhappy users: use explicit feedback to find examples, not to score.
- Shadow mode logs a new version's outputs on copied traffic; a canary serves ~1–5% of users with automatic rollback.
- Use the same rubric both ways; if offline gains but online is flat, mine failing live traces into the set.
Check yourself
Answer to mark it learned; your answers aren't scored.
v2 of an email agent passed every offline gate. Its tools can send emails and update CRM records. You want to see it on real traffic before any user is exposed. What do you do?
Go deeper
Full explanation
Offline evaluation scores a version before deploy on fixed data: golden sets, regression suites, LLM judges. It is cheap, repeatable and safe, but only as good as the dataset's match to real traffic. Online evaluation measures the live system on real users. It is the ground truth for outcomes, but noisy, delayed and riskier.
Online signals to instrument:
- Outcomes: task completed, ticket resolved without escalation, retention.
- Implicit behavior: copy or accept rate, how much users edit a draft, regenerate and retry clicks, abandonment, handoffs to a human. High volume and honest.
- Explicit feedback: thumbs up/down. Sparse and skewed toward unhappy users: use it to find examples, not to score.
- Guardrail triggers: refusals, PII or toxicity blocks, schema failures.
- LLM judge on sampled traffic: reference-free checks (groundedness, policy, tone) on a hashed 1–5% of traces.
Bridges between the two: shadow mode sends a copy of real requests to the new version and logs outputs nobody sees; a canary serves it to ~1–5% of users with automatic rollback on guardrails.
You need both, and they must agree. Use the same rubric offline and online so the numbers compare. If offline says +8 points and online is flat, the eval set no longer represents production: mine failing live traces back into it.
Code Online metrics plus hashed judge sampling
import hashlib
from dataclasses import dataclass
JUDGE_SAMPLE_RATE = 0.02 # ~2% of live traffic; judge cost scales linearly
@dataclass
class Trace:
id: str
question: str
context: str
answer: str
thumbs: int | None # +1 / -1 / None: most users never click
regenerated: bool
escalated: bool
version: str # prompt + model + index version that served it
def in_sample(trace_id: str, rate: float = JUDGE_SAMPLE_RATE) -> bool:
# Hash, not random(): a trace is always in or out, so runs are replayable
h = int(hashlib.sha256(trace_id.encode()).hexdigest()[:8], 16)
return h / 0xFFFFFFFF < rate
def online_metrics(traces: list[Trace]) -> dict:
n, rated = len(traces), [t for t in traces if t.thumbs is not None]
# Same groundedness rubric as the offline suite, so the numbers compare
judged = [judge_groundedness(t) for t in traces if in_sample(t.id)] # 0 or 1
return {
"feedback_coverage": len(rated) / n,
"thumbs_up_rate": sum(t.thumbs > 0 for t in rated) / max(len(rated), 1),
"regenerate_rate": sum(t.regenerated for t in traces) / n,
"escalation_rate": sum(t.escalated for t in traces) / n,
"judge_grounded": sum(judged) / max(len(judged), 1),
"judged_n": len(judged), # ~400 judged traces -> about ±5 pts at 95%
}
report = {v: online_metrics(ts) for v, ts in group_by(traces_24h, "version").items()} # canary vs controlReal example
A support copilot passes the offline gate: 91% correctness on 400 golden questions vs 88% before. In a 5% canary for a week, thumbs-up is flat, but escalations climb from 11% to 14% and regenerate clicks rise ~30%. Reading 200 escalated traces shows 40% concern a pricing change launched after the golden set was built: the eval measured last quarter's questions. The team rolls back, adds 60 of those traces to the golden set, and the next version wins both offline and online.
Trade-offs +3 · −3
+ You gain
- Offline is cheap, repeatable and safe: it blocks regressions before any user sees them.
- Online measures real outcomes on the real query mix, including cases no dataset anticipated.
- Shadow mode and canaries turn a big-bang release into a measured, reversible one.
− You pay
- Offline sets drift away from production as users, documents and products change.
- Online signals are noisy, delayed and biased: thumbs come mostly from unhappy users.
- Live judging and trace logging cost money and raise privacy and retention questions.
Use it when
Always both. Offline gates every change before users see it; online confirms the effect on real traffic and feeds new failure cases back into the offline set.
Avoid it when
Don't expose users to a change that fails offline gates or carries safety risk: shadow it first. Don't trust offline alone for anything user-facing at scale.
Numbers to know 3
- Rule of thumb: canary at ~1–5% of users, then staged ramps (e.g., 25% → 50% → 100%) gated on guardrails.
- Judge precision depends on volume, not percentage: ~400 judged traces give ±~5 pts at 95%, ~100 give ±~10.
- GitHub Copilot study (Ziegler et al., 2022): the acceptance rate of shown suggestions predicted perceived productivity better than other usage metrics.
Common pitfalls 4
- Treating thumbs-up rate as the quality metric: it is a tiny, self-selected sample.
- Never refreshing the golden set from production, so offline scores climb while users see no change.
- Shadow-testing an agent whose tools have side effects: the shadow sends real emails. Stub every write.
- Using different judge prompts offline and online, so the two numbers can't be compared.
Interview questions 2
Answer out loud first, then reveal.
Offline evals improved 6 points but online metrics are flat. What's going on?Show answer
Most likely a distribution or metric mismatch. I'd run the same offline judge on a sample of live traces. If live quality did improve but users behave the same, the offline metric isn't what users value, so I revisit the rubric with real outcomes. If live quality didn't improve, the golden set is stale or too easy for today's traffic, and I mine recent failures and escalations into it. I'd also check that the online test had the power to detect the change at all.
What online signals would you instrument for an LLM feature?Show answer
Three layers. Outcomes: task completed, ticket resolved without escalation, retention. Implicit behavior: accept or copy rate, edit distance on drafts, regenerate clicks, abandonment, handoffs to a human; high volume and honest. Explicit thumbs, which are sparse and skewed, so I use them to find examples, not to score. On top, guardrail triggers and an LLM judge on a hashed sample of traces with the same rubric as offline. Everything is keyed by trace id and by the prompt, model and index version that served it.