Evaluation & Testing AI Systems
You'll be able to:
You can define an evaluation suite for an LLM feature and explain why human eval differs from automatic metrics.
Opening You've spent weeks fine-tuning your large language model (LLM) feature, but when you deploy it to production, users report inconsistent and sometimes incorrect results. The root cause often lies not in the model itself, but in how it's evaluated and tested.
Evaluation Metrics for LLMs
What they are
Evaluation metrics measure an LLM's performance, providing insights into its strengths and weaknesses.
Non-obvious production insight
While automatic metrics like perplexity and BLEU scores are useful, human evaluation is essential to capture nuances in language understanding. Experienced engineers know that relying solely on automated metrics can lead to over-optimization for specific tasks, resulting in poor generalizability.
Analogy for non-technical stakeholders
Think of LLM evaluation like assessing a chef's skills. Automatic metrics are like measuring the temperature and cooking time – they provide some insight but don't guarantee a delicious dish. Human evaluation is like having a food critic taste and review the meal, providing a more comprehensive understanding of the chef's abilities.
Building an evaluation suite
An evaluation suite is the repeatable test you run on every change. Build it in four steps:
- Write success criteria per behaviour. "Answers well" is untestable. "Cites the right policy page in at least 95% of billing questions" and "never invents a refund amount" are specific and measurable. Most features need several: correctness, tone, refusals, latency, cost.
- Collect test cases. Start with real traffic (sampled and anonymised), then add edge cases the traffic misses: empty input, another language, a prompt-injection attempt, a question the knowledge base cannot answer. Cover every behaviour in your criteria, not just the common ones.
- Give each criterion a grader. Use exact match or code checks where the answer is checkable (a JSON field, a cited ID). Use a written rubric where it is not. An LLM-as-judge can apply that rubric at scale, but add human spot checks. Judges show known biases: they can favour the first answer shown (position), longer answers (verbosity), and output from their own model family (self-enhancement).
- Check the judge against people. Have the domain expert label a sample pass or fail, then measure how often the judge agrees, separately on passes and on fails. A judge that passes everything can score high agreement while catching no errors.
Then run the suite on every prompt, model, or retrieval change, and compare against the last accepted run. That is the regression test: it catches the fix that quietly breaks something else.
Retrieval-Augmented Generation (RAG)
What it is
RAG is a technique that combines a retriever model with a generator model to improve language understanding and generation capabilities.
Non-obvious production insight
Modern RAG usually combines BM25-style lexical retrieval with dense embeddings and a reranker: lexical search is cheap and precise on exact terms and identifiers, dense retrieval also matches paraphrases and synonyms, and the reranker orders the merged candidates.
Analogy for non-technical stakeholders
Imagine a librarian searching for books on a specific topic. Traditional methods would involve scanning book titles and summaries (sparse retrieval), while dense vector retrieval is like using a sophisticated cataloging system that understands the nuances of language and catches paraphrases a title scan would miss; a good librarian uses both.
Failure Modes
| Name | Root Cause | Observable Signal |
|---|---|---|
| Stale Knowledge | Outdated training data or inadequate knowledge updates | Model provides incorrect information on recent events or developments |
| Overfitting to Evaluation Metrics | Over-reliance on automated evaluation metrics during fine-tuning | Model performs well on specific tasks but struggles with generalization and real-world scenarios |
| Indexing Inconsistencies | Inconsistent or incomplete indexing of the document database | Model provides irrelevant or outdated results due to incomplete or inaccurate information |
Swipe sideways to see every column →
Stakeholder Communication
When explaining LLM evaluation and testing to non-technical stakeholders, use analogies like:
- "Evaluating an LLM is like assessing a student's understanding – we need to look beyond just grades (automatic metrics) and consider their actual performance in real-world scenarios (human evaluation)."
- "Think of RAG like a highly specialized research assistant that can efficiently find relevant information in a vast library. We need to ensure it's trained on the right materials and can adapt to new information."
- "Just as a chef needs feedback from customers to improve their dishes, an LLM needs human evaluation to refine its understanding of language and provide accurate results."
Check Yourself
Module Mission
20–30 minFor a hypothetical chatbot, define 5 test cases. For each, specify: input, expected behavior, how to measure success, and one failure mode.
Loading your work…
Curated Materials
55minThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- CA-RAG: Constraint-Aligned Retrieval for Structurally Faithful Long-Form GenerationarXiv ·
- ITC Neocloud raises $2.5M in share placing amid AI infrastructure pivotDealroom.co ·
- IQM Quantum Computers Sells 54-Qubit Radiance R3 System to South Korean Quantum-AI Infrastructure Firm QAIQuantum Computing Report ·