Sub topic 16
Online evaluation, user feedback, and monitoring
This chapter assumes you can write the Python harness from earlier chapters, know how an LLM judge is built and validated, and understand rates and confidence intervals. Offline evaluation tells you whether a version is good enough to ship. Online evaluation tells you whether it keeps working once real users reach it.
Why offline results are not enough
Your test set is a snapshot. Real users ask questions you did not predict, your documents change, and the provider may update the model behind an API name. Quality can drop without any code change on your side. Production gives you the only unbiased view of the real input distribution.
What to log
Log one trace per request, so every problem can be replayed:
- The user input and the final output.
- The prompt version, model name, and parameters.
- Retrieved document IDs and tool calls, if any.
- Latency, token counts, and errors.
- A trace ID that links later feedback to the request.
Redact personal data before storing traces, and follow your retention policy.
Three signals
| Signal | Source | Strength | Weakness |
|---|---|---|---|
| Explicit feedback | Thumbs up/down, ratings | Direct user opinion | Sparse and skewed toward extreme experiences |
| Implicit feedback | Regenerate clicks, edits, abandonment, copy actions | High volume | Ambiguous meaning |
| Sampled scoring | Judge or human review of sampled traces | Matches your own criteria | Costs money or time |
No single signal is reliable alone. Treat feedback as a trend indicator. A rise in thumbs-down from 4% to 9% matters more than the absolute value.
The monitoring loop
The last steps close the loop. Each failure you find in production should become a case in your offline dataset, so it cannot regress silently.
A minimal monitor
This code samples traces for scoring and raises an alert when the recent thumbs-down rate exceeds a baseline by a set margin.
import random
def sample_traces(traces, rate=0.05, seed=0):
rng = random.Random(seed)
return [t for t in traces if rng.random() < rate]
def check_alert(events, baseline, window=200, margin=0.05):
"""events: list of 1 (thumbs-down) or 0 (no complaint), oldest first."""
recent = events[-window:]
if not recent:
return False, 0.0
rate = sum(recent) / len(recent)
return rate > baseline + margin, rate
events = [0] * 180 + [1] * 20
alert, rate = check_alert(events, baseline=0.04)
print(alert, rate) # True 0.1The sampled traces go to the judge from the earlier chapters. Run the judge only on a sample, because scoring every request multiplies your inference cost.
Comparing versions safely
To test a change on live traffic, use a staged rollout. Send a small share of users (for example 5%) to the new version, and compare the same metrics for both groups. Assign users to groups at random and keep each user in one group. Otherwise, differences in who uses each version can look like differences in quality. Keep a fast rollback path.
Common errors
- Reading explicit feedback as accuracy. Users rate tone and speed too, and many never rate at all.
- Monitoring only latency and error rates. A model can return fast, well-formed, wrong answers.
- Letting the production judge drift from the one you validated. Re-check it against fresh human labels periodically.
- Not versioning prompts in traces, which makes a drop impossible to attribute.
Exercise
Your thumbs-down rate rose from 4% to 7% over a week, and no code was deployed. Name two possible causes and one step to investigate each.
Show answer
One cause is a change in user inputs, such as a new topic or a marketing campaign. Check by clustering recent inputs and comparing them with your offline dataset. Another cause is an upstream model or data change, such as a provider model update or a changed document index. Check by looking at the logged model version and retrieved document IDs, then replay a sample of old traces and compare scores.