Lesson 28 Eval Fundamentals
Theme:

Homework

Complete these tasks before Lesson 29. Work in a Python script or notebook. The goal is to deepen your understanding of evaluation strategy and build practical skills you will use in the next lesson with promptfoo.

Task 1: Add BLEU Scoring and Compare Metrics

Goal: Extend your eval pipeline from the lab with BLEU scoring and analyse how different metrics correlate with human judgment.

Instructions

  1. Install the nltk library and use nltk.translate.bleu_score.sentence_bleu to compute BLEU scores for each example in your eval set.
  2. For each example, you should now have three automated metrics: exact match, ROUGE-L, and BLEU.
  3. Manually rate each model output yourself on a 1-5 scale (your human judgment).
  4. Compute the Spearman rank correlation between each automated metric and your human scores:
    from scipy.stats import spearmanr
    
    corr_rouge, p_rouge = spearmanr(rouge_scores, human_scores)
    corr_bleu, p_bleu = spearmanr(bleu_scores, human_scores)
    print(f"ROUGE-L vs Human: r={corr_rouge:.3f} (p={p_rouge:.3f})")
    print(f"BLEU vs Human:    r={corr_bleu:.3f} (p={p_bleu:.3f})")
  5. Write 3-4 sentences analysing your findings. Which metric correlates better with your human judgment? Are there cases where one metric is misleading?

Deliverable

A script that prints a comparison table and your written analysis.

Self-check

Task 2: Benchmark Research Report

Goal: Deepen your understanding of how the LLM community measures progress by researching a benchmark not covered in the slides.

Instructions

Choose one of the following benchmarks (or another of your choosing):

Write a 200-word analysis covering:

  1. What it tests: What capability or skill does this benchmark measure?
  2. Format: How are questions structured? How is scoring done?
  3. Current state-of-the-art: Which models lead and what scores do they achieve?
  4. Limitations: What does this benchmark fail to capture? Is there evidence of contamination?

Deliverable

A 200-word written analysis (plain text or in a comment block in your script).

Self-check

Task 3: Design an Eval Strategy

Goal: Practice designing a complete evaluation strategy for a realistic LLM application.

Instructions

Choose one of the following scenarios (or use a real project you are working on):

Design a complete eval strategy by specifying:

  1. Eval dimensions: What aspects of quality matter? (accuracy, completeness, safety, tone, latency, etc.) Rank them by importance.
  2. Automated metrics: Which automated metrics would you use for each dimension? Justify each choice.
  3. LLM-as-judge: Write the exact rubric you would use. Define each score level (1-5) with concrete criteria specific to your chosen scenario.
  4. Human eval protocol: How many examples? How many raters? What agreement threshold? How often do you re-evaluate?
  5. Eval set composition: How would you source examples? What categories and difficulty levels would you include? How many examples per category?
  6. Regression testing: How would you detect if a prompt change or model update degrades performance?

Deliverable

A structured document (in your script as comments, or a separate text file) covering all six points. Target 300-500 words total.

Self-check

📥 Reference Solution

⬇ lab_answer.py

Submission

There is no formal submission for this course. These tasks are for your own development. However:

Next lesson: Lesson 29 — Eval Frameworks (promptfoo) — turn your eval strategy into automated, repeatable test suites.