Lesson 28 Eval Fundamentals
Theme:
Lesson 28 · Slide 1

Eval Fundamentals

How do you know if your LLM application is actually working? Evaluation is the discipline of measuring model output quality — and it is harder than it sounds.

Learning Objectives

Lesson 28 · Slide 2

Why Eval Is Hard

Evaluating LLM outputs is fundamentally different from evaluating traditional software. A unit test has a single expected answer. An LLM response can be correct in many different ways — or wrong in subtle ways that only a domain expert would catch.

Core Challenges

Notes: The key insight is that eval is not a one-time activity — it is a continuous practice that evolves with your application. Think of it like testing in software: you start with basic checks and build up to comprehensive suites.
Lesson 28 · Slide 3

Automated Metrics

Automated metrics provide fast, reproducible signals. None is perfect alone — use them in combination.

MetricWhat it measuresBest for
Exact MatchOutput == reference (binary)Factual Q&A, classification, code output
BLEUN-gram overlap with referenceTranslation, constrained generation
ROUGE-LLongest common subsequenceSummarisation
PerplexityHow "surprised" the model is by the textLanguage modelling, fluency
F1 / Precision / RecallToken-level overlapExtractive QA, NER

Limitations

BLEU and ROUGE penalise valid paraphrases. A summary that says the same thing in different words scores low. Always pair automated metrics with semantic evaluation.

Lesson 28 · Slide 4

LLM-as-Judge

Use a strong model (e.g., Claude Sonnet) to evaluate outputs from a weaker or differently-prompted model. This is the most practical approach for evaluating open-ended generation at scale.

How It Works

  1. Define a rubric — what constitutes a good answer (accuracy, completeness, tone, format)
  2. Send the original prompt + model output + rubric to the judge model
  3. Ask the judge to return a structured score (e.g., 1-5) with reasoning
  4. Calibrate by comparing judge scores against human labels on a sample
judge_prompt = f"""Rate the following answer on a scale of 1-5.
Rubric:
- 5: Accurate, complete, well-structured
- 3: Partially correct, missing key details
- 1: Incorrect or irrelevant

Question: {question}
Answer: {model_output}

Return JSON: {{"score": int, "reasoning": str}}"""
Notes: LLM-as-judge has known biases: position bias (prefers the first option in comparisons), verbosity bias (prefers longer answers), and self-enhancement bias (prefers its own outputs). Mitigate with randomised ordering and blind evaluation.
Lesson 28 · Slide 5

Human Evaluation

Human eval remains the gold standard — but it is expensive, slow, and surprisingly unreliable without careful protocol design.

Key Protocols

Absolute Rating

Each output is rated independently on a Likert scale (1-5). Simple but subject to calibration drift — raters' standards shift over time.

Pairwise Comparison

Raters choose which of two outputs is better (A vs B). More reliable than absolute ratings but scales as O(n^2) with the number of systems.

Inter-Annotator Agreement

Lesson 28 · Slide 6

Benchmark Suites

Standard benchmarks let you compare models on well-defined tasks. Know what each measures — and what it does not.

BenchmarkTasksWhat it tests
MMLU57 subjects, multiple choiceBroad academic knowledge
HumanEval164 Python problemsCode generation (pass@k)
GSM8K8.5K grade-school mathMulti-step arithmetic reasoning
HellaSwagActivity completionCommonsense reasoning
TruthfulQA817 tricky questionsResistance to common misconceptions

Benchmark Limitations

High benchmark scores do not guarantee good performance on your task. Benchmarks are static; models may have seen the test data during training (contamination). Always build custom eval sets for your domain.

Lesson 28 · Slide 7

Building Custom Evals & A/B Testing

The most impactful eval work is building evaluation sets specific to your application.

Custom Eval Set Design

  1. Collect real examples — sample from production queries, not synthetic data
  2. Stratify by difficulty — include easy, medium, and hard cases; include edge cases
  3. Write gold references — have domain experts create reference answers
  4. Target 50-200 examples — enough for statistical power, small enough to maintain
  5. Version your eval set — track changes over time; never modify in place

A/B Testing and Statistical Significance

Notes: Emphasise that eval-driven development means: write the eval first, then iterate on prompts/models until the eval passes. This is the LLM equivalent of test-driven development.
Lesson 28 · Slide 8

Lab & Homework

Lab Exercises

  1. Eval Pipeline — build a reusable evaluation harness that computes exact match, ROUGE-L, and a custom semantic similarity score across a dataset
  2. LLM-as-Judge — implement a judge prompt with a rubric, run it on sample outputs, and calibrate against your own human labels
  3. Custom Benchmark — create a 20-example eval set for a specific task, run two prompt variants, and test for statistical significance

Homework Tasks

  1. Extend the eval pipeline with BLEU scoring and compare BLEU vs ROUGE-L correlation with human judgments
  2. Research a benchmark not covered in class and write a 200-word analysis of what it tests and its limitations
  3. Design a complete eval strategy for a real-world LLM use case you care about
1 / ?