Sub topic 12
Offline Evaluation Versus Online Monitoring
This chapter assumes you have read the earlier chapters on evaluation datasets, graders, metrics, and release gates. You should be able to read short Python snippets and know what a pass rate and a severity level are.
Your evaluation set and release gate answer one question: "Is this version good enough to ship?" They cannot answer a second question: "Is the shipped feature still good for the people using it today?" Offline evaluation covers the first question and online monitoring covers the second. A team needs both, and each one compensates for the other's blind spots.
What each one does
Offline evaluation runs a candidate version of the feature against a fixed, labeled set of cases before users see it. You control the inputs, so two runs are comparable. You can repeat the run, bisect a regression, and compare two prompts or models on identical cases.
Online monitoring observes the live feature on real traffic. You do not control the inputs, and usually no one has labeled the right answer. You collect signals, judge a sample of conversations, and watch trends over time.
| Property | Offline evaluation | Online monitoring |
|---|---|---|
| Inputs | Fixed, curated cases | Real user traffic |
| Ground truth | Known (labels, checks, reference facts) | Mostly missing; inferred from signals or sampled judgments |
| When it runs | Before release, and on every change | Continuously after release |
| Main question | Is this version safe to ship? | Is the live feature still healthy? |
| Cost of a failure found | A blocked release | A user already saw the bad output |
| Weakness | Cases may not match real usage | Slow, noisy, and sees failures only after they happen |
| Typical output | Pass rate, critical failure list | Trend lines, alerts, sampled review queue |
Why offline results do not transfer perfectly
An offline pass rate of 94% does not mean 94% of live answers are good. Several gaps explain the difference.
- Distribution shift. Your cases were written from last quarter's guesses about users. Real users phrase things differently, ask about new products, and paste long documents you never anticipated.
- Missing categories. Your dataset has a "refund policy" category. Users ask about shipping insurance, which has no cases at all, so no offline score covers it.
- Different context. Offline runs often use a clean retrieval index and a short conversation. Live sessions have stale documents, long histories, and partial outages in upstream services.
- Dataset reuse. If you tune prompts against the same cases for weeks, the score rises while generalization does not. Treat a set you have optimized against as a development set, and keep a held-out portion that you only run at release time.
- Population weighting. An evaluation set is balanced so that rare categories get enough cases. Real traffic is not balanced. A category that is 3% of your set might be 40% of traffic, so the live experience tracks it far more.
The practical conclusion is that offline evaluation gives a controlled, comparable measurement and online monitoring checks that the measurement still matches reality.
Signals you can observe online
Online, you rarely have a correct answer to compare against. You use proxies, and each proxy has a known bias.
- Explicit feedback. Thumbs up or down and written complaints. These are direct, but few users give them, and unhappy users are over-represented.
- Behavioral signals. Regenerate clicks, immediate rephrasing of the same question, abandonment, escalation to a human agent, or copy-and-paste of the answer. These are more plentiful but ambiguous: a rephrase can mean the answer was wrong or that the user had a follow-up.
- Automatic checks. Code-based graders that need no label, such as "answer contains a currency amount not found in the retrieved text," refusal rate, response length, latency, or format validity.
- Sampled judgments. A model-based judge or human reviewers grade a small random sample of live conversations on the same quality dimensions you used offline.
- Safety and policy flags. Output filters and user reports for the critical failure modes you listed in your taxonomy.
Reuse your graders where you can. If the groundedness grader works on an evaluation case, it can usually run on a sampled production conversation, provided the retrieved context is logged along with the answer. Decide what to log early, because you cannot grade a trace you did not store. Apply your privacy rules to that logging, such as redaction and retention limits.
Sampling production traffic
Reviewing every conversation is too expensive, and reviewing only complaints gives a biased view. A common design combines two streams: a small uniform random sample for an unbiased estimate, and a targeted stream for conversations with risk signals.
import random
def sample_for_review(events, rate=0.05, seed=7, always_include=("thumbs_down", "escalated")):
rng = random.Random(seed)
picked = []
for event in events:
flagged = any(event.get(flag) for flag in always_include)
if flagged or rng.random() < rate:
picked.append(event)
return pickedKeep the two streams separate when you compute metrics. The random stream estimates the true failure rate. The targeted stream finds new failure patterns but overstates the rate, because you chose it for being suspicious. Tag each sampled event with the stream it came from, such as "stream": "random", so the estimate stays honest.
Turning signals into alerts
Monitoring needs thresholds, just as release gates do, but they work differently. A release gate is a one-time decision on a fixed set. A monitor looks at a moving window of noisy data, so it needs a minimum volume and a comparison against a baseline.
def check_window(events, limits):
total = len(events)
if total == 0:
return ["no traffic in window"]
alerts = []
for name, limit in limits.items():
rate = sum(1 for e in events if e.get(name)) / total
if rate > limit:
alerts.append(f"{name} rate {rate:.1%} exceeds {limit:.1%}")
return alerts
events = [{"id": i, "thumbs_down": i % 10 == 0, "policy_flag": i == 3} for i in range(200)]
limits = {"thumbs_down": 0.08, "policy_flag": 0.0}
for alert in check_window(events, limits):
print(alert)Running this prints two alerts: thumbs_down rate 10.0% exceeds 8.0% and policy_flag rate 0.5% exceeds 0.0%. The second shows the zero-tolerance rule carried over from your requirements. A single critical event in the window raises an alert, no matter how small the rate.
Set the limits from data, not from hope. Measure the rate for a few weeks after launch, then set the warning level a little above the normal range and the critical level well above it. With small windows, one or two events can swing a rate, so wait for a minimum number of events before alerting on a rate. Treat zero-tolerance categories differently: alert on any single event, with no minimum.
How the two fit together
The two activities form a loop. Online findings feed new cases into the offline set, and the offline set protects against repeating the failure.
When a monitor finds a bad conversation, follow a routine:
- Reproduce it: the exact input, the retrieved context, and the model settings.
- Classify it with your failure taxonomy and assign a severity.
- Add it to the evaluation set as a case, with a type such as
edge_caseoradversarialand the correct checks. - Fix the feature, and confirm the new case now passes along with the old ones.
Each incident then becomes a permanent regression test.
Release strategies that bridge the gap
Between "passed offline" and "everyone gets it" there are intermediate steps that let online data decide before full exposure.
- Shadow mode. The new version runs on live requests, but its answers are logged and not shown to users. You grade its outputs against the current version's outputs. There is no user risk, but you also get no behavioral signals, because no one reacts to the shadow answers.
- Canary release. A small share of traffic, say 1% to 5%, gets the new version. You compare monitors between the canary and the control group, and roll back automatically if a critical alert fires.
- A/B test. Users are split between versions to measure effects on product outcomes such as task completion. This needs enough traffic to detect a difference, and it answers "which is better for users," which a quality grade alone cannot.
A canary should not skip the offline gate. The gate keeps known failures away from users, and the canary catches the unknown ones.
Common errors
- Treating a green offline score as proof of live quality. Always plan the online check, and log enough to grade it.
- Monitoring only thumbs-down rates. Most users never click, and many wrong answers look fine to the user. Add sampled grading against your quality dimensions.
- Computing metrics on mixed streams. Combining random and targeted samples inflates failure rates.
- Alerting without an owner or action. Each alert needs a named responder and a decision: roll back, disable a feature path, or open a fix.
- Never feeding findings back. If the evaluation set stays frozen, it drifts away from real use, and the next chapter covers how to keep it current.
- Ignoring changes you did not make. The provider may update a hosted model, a document in the index may change, or a tool may alter its output. Offline scores stay the same because you did not rerun them, while live quality moves. Rerun the offline set on a schedule, and not only when your own code changes.
Exercise
Your offline evaluation shows a 96% pass rate and the release gate passed. Two weeks after launch, the random-sample online pass rate is 84%, and most failures are in questions about "shipping insurance," a topic with no offline cases. Name two reasons the numbers differ and describe what you do next.
Show answer
The reasons are a coverage gap (the evaluation set has no shipping-insurance category, so offline could not detect failures there) and a distribution difference (real traffic weights topics differently than the balanced offline set). Because the 84% comes from the random stream, it is a fair estimate of live quality. Next, reproduce several failing conversations, classify them by failure mode and severity, add a shipping-insurance category with typical, edge, and adversarial cases to the evaluation set, fix the feature, and rerun the full offline set. Confirm the new cases pass and the old ones do not regress. Keep monitoring that category for a few weeks.
Exercise
A monitor computes the rate of thumbs-down feedback over a one-hour window that contained 12 conversations, and 2 had thumbs-down. The alert limit is 10%. Should this page someone? What would you change in the monitor?
Show answer
The rate is 16.7%, which is above the limit, but 12 conversations is too few to trust. One more or one fewer thumbs-down moves the rate by about 8 points. Add a minimum volume (or a longer window) before rate-based alerts fire. Keep any zero-tolerance critical event, such as a policy violation, as an immediate alert regardless of volume.