Skip to content
Ameen Abozaid
MID-070

LLM evaluation and observability

  • 7 Lessons
  • 3 h practice (estimate)
On this page 8 topics

Overview

Topics

  • Evaluation sets in CI
  • LLM-as-judge caveats
  • regression detection
  • token
  • latency
  • and cost tracing

Learn first

3 h of practice (estimate)

Learning outcomes

  1. Build an evaluation set of realistic questions with expected sources and acceptance criteria.
  2. Measure retrieval recall, answer groundedness (faithfulness to sources), and refusal correctness.
  3. Use an LLM as a judge with calibration against human-labeled samples, and state its limits.
  4. Run evaluations in CI so prompt, model, or retrieval changes cannot silently degrade quality.
  5. Trace each request with token counts, latency per step, model version, and cost, and build dashboards and alerts on them.

Lessons

  1. 01Why LLM features need evaluations
  2. 02Building an evaluation set
  3. 03Metrics: recall, groundedness, refusals
  4. 04LLM-as-judge and its caveats
  5. 05Evaluations in CI
  6. 06Tracing tokens, latency, and cost
  7. 07Demo: an evaluation run catching a prompt regression

Lab and exercises

Lab

MID-070-LAB1 · Measured assistant

Outcomes: 1–5 · Time: ~3 h Create a 50-question evaluation set for the order-support assistant and run it in CI with pass thresholds. Add OpenTelemetry spans for retrieval, model call, and tools with token and cost attributes. Build a Grafana dashboard for cost per conversation and p95 latency. Acceptance: a deliberately worse prompt fails the pipeline; cost per conversation is visible per day.

Exercises (assessment: evaluation plan for a new AI feature)

IDOutcomeTask
MID-070-EX011Write 20 evaluation rows (question, expected sources, must and must-not criteria) covering normal, edge, adversarial, and must-refuse cases.
MID-070-EX022Compute retrieval recall for the set by checking whether the expected source is in the top-k results.
MID-070-EX032Write a rule-based check for refusal correctness and one for citation presence.
MID-070-EX043Label 30 answers by hand, run a judge model with a rubric, and compute agreement; list two judge failures.
MID-070-EX054Add a CI stage that fails when groundedness drops below 0.9 or falls more than 3 points from baseline.
MID-070-EX065Add spans with model version, prompt version, tokens, and cost; verify them in the trace backend.
MID-070-EX071–5Design an evaluation plan for a new "product description generator": data, metrics, thresholds, what blocks a release, and the dashboards and alerts.
Show solutions
  • EX01 Include rows such as a policy question, an ambiguous one, a prompt-injection attempt, and one whose answer is not in the sources (expected: refusal).
  • EX02 recall = rows where expected source in top-k / total rows.
  • EX03 Refusal: the answer matches a refusal pattern exactly when no source supports it; citation: the answer cites a retrieved source id.
  • EX04 Agreement = matching labels / 30; typical failures: rewards verbose answers, misses subtle unsupported claims.
  • EX05 Compare the run's metrics with the stored baseline; non-zero exit when below threshold or margin.
  • EX06 Span attributes for model, prompt version, token counts, and computed cost; check them in Jaeger or Tempo.
  • EX07 Include a held-out set, human review sample, calibrated judge, thresholds (for example groundedness at least 0.9), release blockers (any threshold miss, any safety failure), and cost and latency alerts.

Outcome 1 is also checked by quiz Q01-Q02; outcome 3 by the quiz and EX04.

Quiz

Outcomes: O1 evaluation sets · O2 metrics · O3 LLM-as-judge · O4 evaluations in CI · O5 tracing tokens and cost.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1Why use an evaluation set?O1
  2. 2A good evaluation set includes:O1
  3. 3Retrieval recall measures whether:O2
  4. 4Groundedness means:O2
  5. 5Refusal correctness means the assistant:O2
  6. 6Before trusting a judge model you should:O3
  7. 7A known bias of judge models:O3
  8. 8In CI the evaluation should fail the build when:O4
  9. 9Which belongs on a model-call span?O5
  10. 10Cost problems are best caught by:O5

Practical part

Seven exercises MID-070-EX01 to EX07 (EX07 is the evaluation plan for a new AI feature) plus the measured-assistant lab. Pass: at least five exercises including EX07, and a lab where a worse prompt fails the pipeline and cost per conversation is visible per day.

Common mistakes

Evaluating with five hand-picked questions; trusting an uncalibrated judge model; no record of which prompt and model version produced an answer; cost discovered on the monthly invoice.

Assessment

Design an evaluation plan for a new AI feature, including thresholds and what blocks a release.

Career relevance

Evaluation-gated releases (SRC-022) and AI vendor and model evaluation (ARC-047).

Type to search levels, phases, modules and lessons.