Build a golden-set eval with an LLM-as-judge scorer and a regression gate that runs in CI.
How a prompt change passes or fails the eval gate
Step 1 of 5
Golden set
A fixed list of questions with their reference context. Using the same set every run is what makes scores comparable.
Step 2 of 5
Generate answers
Run each question through the prompt version under test, collecting an answer for every example.
Step 3 of 5
Judge answers
An LLM judge scores faithfulness (is every claim supported by context) and relevance. Use a different model from the one being judged.
Step 4 of 5
Compare baseline
Aggregate the per-example scores and compare them to the stored baseline. The report keeps both views.
Step 5 of 5
Gate in CI
If a score drops by more than 5% from baseline, the check fails and the change cannot ship.
The gate turns eval scores into a decision, so regressions are caught before a deploy.
Scenario
You're shipping prompt changes weekly and regressions keep slipping through. Build an eval pipeline that gates deploys.
Objective
Implement run_eval(golden_set, prompt_version) -> Report with faithfulness and answer_relevance scores.
Starter code
Implement the TODOs to complete the lab.
eval.py
~117 tokens
def run_eval(golden_set: list[dict], prompt_version: str) -> dict:
"""Run eval against golden set.
- Generate answers with the prompt version
- Score with LLM-as-judge on faithfulness + relevance
- Compare to baseline; gate if regression > 5%
"""
# TODO
pass
def faithfulness_score(answer: str, context: list[str]) -> float:
"""LLM-as-judge: is every claim in answer supported by context?"""
# TODO
pass
Solution hints
1Judge model should differ from system model
2Faithfulness: every claim must be supported by context
3Answer relevance: does the answer address the question
4Gate if score drops > 5% from baseline
Validation steps
Your implementation should pass these checks.
Eval returns per-example and aggregate scores
Faithfulness is 1.0 for fully-supported answers
Regression gate triggers on > 5% drop
Eval runs in < 5 minutes for 50 examples
Run validation
This is a simulated validation environment. In production, this would run your code against the validation steps.