Duration: 4 hours | Difficulty: Intermediate–Advanced | Prerequisites: Modules 01–06
Learning Objectives
By the end of this module, you will be able to:
- Identify the unique challenges of evaluating LLM outputs
- Implement RAGAS metrics for RAG pipeline evaluation
- Build LLM-as-judge evaluation pipelines
- Design and run A/B tests for LLM applications
- Create continuous evaluation systems for production monitoring
1. Why LLM Evaluation is Hard
Unlike assert add(2,2)==4, “good summary?” is subjective, contextual, and sampler-dependent. You need multiple signals: human labels, automatic proxies, and product metrics.
┌─────────────────────────────────────────┐
│ LLM Evaluation Methods │
│ │
│ ┌────────────┐ ┌───────────────────┐ │
│ │ Automated │ │ Human Evaluation │ │
│ │ ┌─────────┐│ │ ┌─────────────┐ │ │
│ │ │Reference││ │ │ Expert review│ │ │
│ │ │-based ││ │ │ User studies │ │ │
│ │ │(BLEU, ││ │ │ A/B testing │ │ │
│ │ │ROUGE) ││ │ └─────────────┘ │ │
│ │ └─────────┘│ └───────────────────┘ │
│ │ ┌─────────┐│ │
│ │ │LLM-as- ││ ┌───────────────────┐ │
│ │ │Judge ││ │ RAG-Specific │ │
│ │ │ ││ │ (RAGAS, DeepEval) │ │
│ │ └─────────┘│ └───────────────────┘ │
│ └────────────┘ │
└─────────────────────────────────────────┘| Trap | Fix |
|---|---|
| Eval set = training paraphrases | Fresh prompts, adversarial set |
| Single numeric score | Dashboard of metrics |
| Judge model = same as subject | Use stronger / different model cautiously |
Concept: Evaluation is a product discipline, not a one-off notebook cell.
2. RAGAS: RAG Evaluation
RAGAS scores faithfulness, answer relevancy, context precision/recall—useful sanity checks when you have reference answers.
Key Example: Minimal
evaluatecall—expand the dataframe before trusting headline numbers.
[object Object],
,[object Object], ragas ,[object Object], evaluate
,[object Object], ragas.metrics ,[object Object], faithfulness, answer_relevancy, context_precision, context_recall
,[object Object], datasets ,[object Object], Dataset
eval_data = {
,[object Object],: [,[object Object],, ,[object Object],],
,[object Object],: [
,[object Object],,
,[object Object],,
],
,[object Object],: [
[,[object Object],],
[,[object Object],],
],
,[object Object],: [
,[object Object],,
,[object Object],,
],
}
ds = Dataset.from_dict(eval_data)
results = evaluate(ds, metrics=[faithfulness, answer_relevancy, context_precision, context_recall])
,[object Object],(results)Understanding RAGAS Metrics
| Metric | Measures | Aim high when… |
|---|---|---|
| Faithfulness | Claims supported by context | Medical/legal-ish |
| Answer relevancy | Addresses question | Customer support |
| Context precision | Retrieved noise level | Big corpora |
| Context recall | Missing gold facts | Compliance Q&A |
Fun Fact: RAGAS itself uses LLM calls—budget for eval cost like you budget for prod.
3. LLM-as-Judge
Use a strong model with a rubric (“rate 1–5 on accuracy, safety, concision”) and blind presentation when comparing candidates.
| Good practice | Bad practice |
|---|---|
| Show reference answer if available | Let judge see model names |
| Average multiple judge samples | Single roll decides launch |
4. Building an Evaluation Pipeline
| Stage | Artifact |
|---|---|
| Curate | eval_set.jsonl with tags |
| Run | Batch script + structured logs |
| Analyze | Failure taxonomy dashboard |
| Gate | CI job blocking regressions |
Plain-English loop: nightly run on golden set → Slack alert if faithfulness drops > X%.
5. A/B Testing LLM Systems
Route traffic to A/B prompts or models; measure task success, not just CTR. Watch latency and cost—a “smarter” model might lose on economics.
| Metric | Tooling |
|---|---|
| Win rate on thumbs | Product analytics |
| Business KPI | Warehouse / BI |
Key Takeaway
Ship eval hooks before you ship the feature flag.
Practice Exercises
Exercise 1: Golden Set Curation (Beginner)
50 questions with must-cite chunk IDs.
Exercise 2: RAGAS on Your Corpus (Intermediate)
Run full metrics; inspect worst rows.
Exercise 3: Judge Rubric Design (Intermediate)
Write anchored 1–5 scale; test inter-rater on 20 rows.
Exercise 4: CI Eval Job (Advanced)
GitHub Action fails PR if metric regresses.
Exercise 5: Online Monitoring (Advanced)
Sample prod traffic to shadow eval pipeline.
Mini-Project: LLM Evaluation Dashboard
Streamlit or Grafana page: latest RAGAS run, latency percentiles, cost per 1k queries, top failure tags.
Key Takeaways
Key Takeaway
- There is no single “accuracy” for generative apps—use suites.
- RAGAS gives fast RAG health checks; still spot-check manually.
- LLM judges need rubrics, blindness, and variance control.
- Pipelines + CI beat quarterly manual reviews.
- A/B tests tie model changes to outcomes stakeholders understand.