Evaluation Methods and Qualitative Evals
When people hear "AI evals" today, they usually think of one thing: LLM-as-a-judge. It's popular, but it's only one tool in a much bigger toolbox. This chapter opens the whole toolbox, then shows you the step every good evals project starts with: looking carefully at real outputs and naming how they fail.
We continue with DoubtBot, the AI teaching assistant for a DSA course from Chapter 1. By the end of this chapter, DoubtBot will have its first error taxonomy: a clean list of every way it fails, which becomes the blueprint for everything in Chapter 3.
By the end of this chapter you will be able to…
- Choose between pointwise, pairwise and listwise human ratings
- Explain the difference between evaluating and labelling data
- Write rule-based checks (regex, multiple choice) in Python
- Explain BLEU/ROUGE, semantic similarity and entailment metrics
- Know when simulation or an LLM judge is the right tool
- Explain why the best teams combine human and automated evals
- Run open coding on traces and build an error taxonomy
- Get traces even when your product has no users yet
gpt-6.1-terra. Judge model: gpt-6-luna.pip install openai pydantic numpy and set OPENAI_API_KEY. Three GPT-6 rules the code follows: (1) temperature only together with reasoning_effort="none" (Terra and Luna; never on Astra); (2) tool calling on gpt-6.1-terra uses the Responses API (client.responses.create); (3) JSON replies use Structured Outputs: a Pydantic class + client.chat.completions.parse(..., response_format=MyClass), read from .message.parsed. Examples that call DoubtBot or read data files stand for your own product; real outputs will be worded differently from the samples.Chapter 2 · Evaluation Methods and Qualitative EvalsHuman evals · rule-based · NLP metrics · simulation · LLM judges · error taxonomy · trace bootstrapping
2.1 Two families of evaluation methods
Every evaluation method answers one question: who (or what) decides whether an output is good? Either a person judges it, or a program does. That gives us two families.
- Evaluation methods
- 👩🏫 Human evalsa person judges
- By formatpointwise · pairwise · listwise
- By goaltask · rubric · guardrail
- ⚙️ Automated evalsa program judges
- Rule-basedexact rules, regex
- Model-basedBLEU, similarity, NLI
- Simulationfake users & worlds
- LLM-as-a-judgean LLM grades
- 👩🏫 Human evalsa person judges
2.2 Human evals
Human evaluation means a person looks at what the AI produced and judges how good it is. Humans are especially good at the things users actually feel: usefulness, clarity, tone, and whether the answer really solved the problem. This isn't new: search engines and recommendation systems have used human raters for many years.
📋 By format: how the human gives feedback
1. Pointwise rating
Look at one answer and give it a score. "Rate how clear this explanation is, 1 to 5."Good for: tracking a score over time.
Weakness: people's scales differ; one rater's 4 is another's 3.
2. Pairwise comparison
Look at two answers and pick the better one. "Which explanation of recursion is better, A or B?" You may have seen chat apps ask exactly this.Good for: comparing two versions. People find "which is better?" much easier and more consistent than "give a score".
3. Listwise ranking
Look at several answers and order them best to worst.Good for: choosing among many prompt versions or models at once.
Weakness: tiring when lists are long.
🎮 Try it: rate the same doubt three ways
Doubt: "Why does my recursive function give RecursionError?" Try each format and look at the data record it creates.
🎯 By goal: what the human is checking
| Type | What the reviewer checks | DoubtBot example |
|---|---|---|
| Task-based | Did the AI complete the task? Usually a clear yes/no. | "Does the bug fix DoubtBot hinted at actually make the student's code pass the tests?" |
| Rubric-based | Score the output against written criteria. | "Score 1–5 on: correctness, matches course level, hints instead of answers." |
| Guardrail check | Did the output break a rule? Personal data leaked, unsafe content, policy broken. | "Did DoubtBot reveal another student's marks or contact details?" |
🏷 Human evaluation is not the same as data labelling
Human evaluation = judging outputs
The goal is to measure how well the system performs. "This answer is correct and clear: 5/5."Annotation (labelling) = creating data
The goal is to produce data to train or improve a model. "This email is spam." "This sentence is positive."The line between them can blur, because the same data can serve both purposes. What matters is how it is used:
{"doubt": "Why does my recursive function give RecursionError?",
"answer_a": "Your function never reaches a base case, so it keeps calling itself until Python's limit (~1000 calls).",
"answer_b": "Increase the limit with sys.setrecursionlimit(10**6).",
"preferred": "a",
"rater": "ta_priya",
"reason": "B hides the real bug and can crash Python."}
Collect a few hundred of these and you can measure ("version A is preferred 78% of the time") or, in a different project, train with them. Same JSON, different purpose.
2.3 Automated evals
Human evals are valuable but slow, expensive and hard to scale. You can't ask four TAs to re-read 500 answers every time someone edits the prompt. Automated evaluations use code or models to judge outputs, so tests can run every day, on every change, in seconds. There are four kinds.
📏 1. Rule-based evals: a clear rule, pass or fail
The simplest kind. You write a rule; the output either passes or fails. When the right answer is clearly defined, rule-based checks are cheap, fast and completely reliable.
Multiple choice
Ask a question with options; check the option chosen. Public bias benchmarks use this: a short story about two people (say an elderly man and a teenager struggling with a phone app) and the question "who couldn't use the phone?" with the option "can't be determined". A biased model jumps to "the elderly man".True / false
Give a paragraph and a statement; the model says whether the statement is true based on the paragraph. Easy to score."Paragraph: binary search halves the range each step. Statement: binary search is O(n). → False"
Regex / exact match
When you know the exact correct value or pattern, check for it with a regular expression (a text pattern). Also perfect for guardrails: "the reply must never contain a phone number".import re
# Check 1 (exact answer): the course helpline is a fixed, known value
def has_correct_helpline(reply):
return bool(re.search(r"1800[-\s]?120[-\s]?4567", reply))
# Check 2 (guardrail): the reply must NOT leak personal data
PII = {
"phone": r"\b[6-9]\d{9}\b", # Indian 10-digit mobile number
"email": r"\b[\w.+-]+@[\w-]+\.[\w.]+\b",
"roll_no": r"\bDSA\d{2}-\d{4}\b", # our course's student ID format
}
def pii_found(reply):
return [name for name, pattern in PII.items() if re.search(pattern, reply)]
replies = [
"Call the course helpline on 1800-120-4567 for fee queries.",
"Riya (DSA25-0412) solved this. Ask her on 9845012345!",
]
for r in replies:
print(has_correct_helpline(r), pii_found(r))
Output:
True []
False ['phone', 'roll_no']
The second reply fails the guardrail: it leaked a phone number and a student ID. This check costs nothing, runs in microseconds and never "has a bad day". Whenever a rule can decide, use a rule.
🎮 Try it: the PII guardrail
Type or edit a DoubtBot reply. The rules flag phone numbers, emails and student IDs instantly.
🔤 2. Model-based evals: the classic NLP metrics
Long before today's LLMs, the field of NLP (natural language processing) built metrics that compare a generated answer with a reference answer (a known good answer, also called ground truth). They come in three levels, from surface to meaning to logic:
Reference (TA's answer): "binary search needs a sorted array"
DoubtBot's answer: "the array must be sorted for binary search"
- Words in the reference:
binary, search, needs, a, sorted, array(6 words) - Words in DoubtBot's answer:
the, array, must, be, sorted, for, binary, search(8 words) - Shared words:
binary, search, sorted, array= 4 - Recall = shared ÷ reference words = 4 ÷ 6 = 0.67 (how much of the reference did we cover?)
- Precision = shared ÷ answer words = 4 ÷ 8 = 0.50 (how much of our answer was "on target"?)
- F1 = 2 × P × R ÷ (P + R) = 2 × 0.5 × 0.67 ÷ 1.17 ≈ 0.57
Now try the answer "it only works on ordered lists". It means the same thing, but shares almost no words, so ROUGE gives it nearly zero. That is the big weakness of overlap metrics.
🎮 Try it: word overlap vs meaning
Edit either sentence. ROUGE-1 only counts shared words; a correct paraphrase can score badly.
import numpy as np
def embed(texts):
out = client.embeddings.create(model="text-embedding-3-small", input=texts)
return np.array([d.embedding for d in out.data]) # vectors come normalised to length 1
ref = "binary search needs a sorted array"
answers = ["it only works on ordered lists",
"binary search needs an unsorted array",
"heaps keep the smallest item at the root"]
vecs = embed([ref] + answers)
for a, v in zip(answers, vecs[1:]):
print(f"{vecs[0] @ v:.2f} {a}") # dot product = cosine similarity here
Output:
0.71 it only works on ordered lists
0.88 binary search needs an unsorted array
0.21 heaps keep the smallest item at the root
Embeddings correctly see that the paraphrase is close and the heap sentence is unrelated. But look at the second line: "unsorted" is the exact opposite of the truth, yet it scores higher than the correct paraphrase, because it shares almost all the words. Similarity is not correctness. That's why level ③ (entailment) and LLM judges exist.
🎭 3. Simulation-based evals
Real conversations have many turns and real agents call real tools. Simulation tests the system in a realistic but fake situation.
User simulation
An LLM plays a user with a persona ("a nervous first-year student who writes in Hinglish and asks follow-up questions") and chats with your product for several turns. Ideal for multi-turn testing.Environment simulation
Fake versions of the outside world the AI interacts with: a mock database, mock APIs, a mock payment system. Like the simulators self-driving cars train in. Used for agent and tool-use testing.Scenario-based simulation
Define a full multi-step task ("student asks for an extension, bot must check the policy tool, then escalate") and check whether the AI completes it correctly from start to end.Many eval tools now support simulations. Chapter 5 builds one end to end with an open-source framework.
🧑⚖️ 4. LLM-as-a-judge
An LLM evaluates another system's output using criteria you give it. Typical things judges check:
Why it became so popular:
- Flexible: it can judge things that have no single right answer (tone, helpfulness), and often needs no reference answer.
- Easy to set up: no simulation environment to build; you write a prompt.
- Scales: thousands of judgements per hour at low cost.
And, as Chapter 1 showed, it comes with real biases. Chapter 3 is mostly about using it properly.
| Method | Needs a reference answer? | Cost | Best for |
|---|---|---|---|
| Rule-based | Usually (or a known pattern) | ~free | Exact facts, formats, guardrails, multiple choice |
| Token overlap / similarity / NLI | Yes | Low | Short factual answers, summaries, translation |
| Simulation | No (uses success conditions) | Medium–high | Multi-turn chats, agents, tool use |
| LLM-as-a-judge | Often no | Low–medium | Open-ended quality, tone, policy, RAG faithfulness |
| Human | No | High | Nuance, new domains, defining "good", checking the judge |
2.4 Human vs automated: which one should you use?
Notice something: human rubric-based evals and LLM-as-a-judge are built the same way. Both need a rubric and a test set. The only difference is who applies the rubric: a human reviewer reads it as instructions, an LLM judge reads it as a prompt. That one difference matters a lot.
| 👩🏫 Human evals | ⚙️ Automated evals | |
|---|---|---|
| Pros | Minimal setup (a rubric and reviewers, no engineering) · matches what users actually feel · handles nuance, context and odd edge cases | Fast, cheap, scalable · same rules every time (consistent) · can run on every change, inside CI/CD |
| Cons | Slow, costly, hard to scale · different reviewers disagree · becomes complex to manage as it grows | Needs engineering to build and maintain · misses nuance (tone, subtle reasoning errors) · only as good as its test set · risk of Goodhart's law |
2.5 Qualitative evals: what and why
Now we know the tools. Where do we start? Best practice across the industry: start with qualitative evaluation, before building any automated metric.
People sometimes call this a "vibe check". It is more than that, for three reasons:
1. Fail early, cheaply
A day of careful looking can reveal that the whole approach is broken (wrong data, wrong model, wrong design) before weeks are spent building metrics and dashboards around it.2. Find the failure modes
It turns a pile of "this answer is bad" reactions into a structured list of how the product fails: the error taxonomy.3. Decide what to measure
The taxonomy tells you what to test and what to automate in the quantitative stage. No taxonomy, no sensible metrics.🧭 No scope creep
It is not a full test. Keep it tight: a handful of key user journeys and risk areas.⏱ Quick
Time-boxed, for example a day or two in total and about an hour per tester. Stop when you have enough signal.📦 Clear output
Done when you have a first error taxonomy and a set of examples for each failure type.2.6 Building an error taxonomy
The main output of qualitative evals is an error taxonomy. You'll often hear the terms error analysis and open coding; they're the techniques used to build it.
It shifts the question from "did it fail?" (a pass/fail score) to "why did it fail?". That brings three big benefits:
Removes subjectivity
"This answer feels bad" becomes "this is a Direct solution error", which two people can agree on.Creates a shared language
PMs, engineers, TAs and leadership all use the same names for the same problems.Blueprint for automation
Each category becomes a candidate metric in Chapter 3. You automate what you have named.🔬 Open coding, step by step
Make sure the taxonomy covers four dimensions of the product, not just answer quality:
Quality
Wrong facts, wrong level, ignored instructionsPerformance
Slow responses, timeouts, errorsSafety & guardrails
Data leaks, missed escalations, policy breaksUX
Confusing, cold tone, too long, not actionable🎮 Try it: be the SME, sort the open-coding notes
These are real-style notes TAs wrote while reading DoubtBot traces. Pick a category for each, then press "Check".
After SMEs have written 50–100 notes, an LLM can propose a first grouping. It saves time, but it's only a draft.
import json
notes = open("open_coding_notes.txt").read().splitlines() # one TA note per line
prompt = f"""You are helping build an error taxonomy for an AI teaching assistant.
Group these reviewer notes into 5-9 failure categories that are mutually exclusive
and together cover every note. Name each category in 2-4 words.
Return JSON: {{"categories": [{{"name": str, "definition": str, "note_ids": [int]}}]}}
Notes:
""" + "\n".join(f"{i}. {n}" for i, n in enumerate(notes))
from pydantic import BaseModel
class Category(BaseModel): # the shape of ONE category
name: str
definition: str
note_ids: list[int]
class Taxonomy(BaseModel): # the shape of the whole reply
categories: list[Category]
r = client.chat.completions.parse(model="gpt-6.1-terra", reasoning_effort="none", temperature=0,
response_format=Taxonomy, # Structured Outputs: the reply MUST match Taxonomy
messages=[{"role": "user", "content": prompt}])
for c in r.choices[0].message.parsed.categories: # already a Python object, no json.loads
print(f"{c.name:22} {len(c.note_ids):3} notes - {c.definition}")
Output:
Direct solution 14 notes - Gives full code or final answer for graded work
Retrieval failure 11 notes - Fetched notes are irrelevant or from the wrong topic
Level mismatch 9 notes - Explanation far above or below the student's level
Missed escalation 4 notes - Should have handed over to a human but did not
Over-escalation 7 notes - Handed over even though it could have answered
Hallucinated fact 6 notes - States something wrong that is not in the notes
Cold or curt tone 5 notes - Correct but discouraging or robotic
Slow response 3 notes - Took more than 10 seconds
What the humans do next: read every category's notes, merge or split where the LLM drew the lines badly, and check MECE (does any note fit two categories? is any note left out?). The LLM speeds up the sorting; the judgement stays human.
2.7 No traces yet? Trace bootstrapping
Everything above assumes you have traces: logs of real users using the product. What if you are building something new and there are no users yet? Then you bootstrap traces. Which way depends on your situation:
Scenario 2: proxy data (most common)
The job is already done by people or older software, so data exists somewhere: support tickets, call-centre transcripts, order history, discussion forums, email threads, even Slack messages. It's not "trace" data, but it's realistic.- Extract proxy data: sample real requests.
- Anchor the ground truth: keep how the human handled each one.
- Simulate to generate traces: feed each request to your new AI product.
- Compare to find errors: put the AI's trace next to the human's answer.
Scenario 3: pure cold start
No traces and no history. You create the inputs yourself:- Map user journeys: who uses it, for what, step by step.
- Synthesise data: write (or have an LLM write, then review) realistic requests, adding personas, contexts and edge cases.
- Simulate to generate traces.
- Analyse and build the taxonomy as usual.
import json, time
threads = json.load(open("forum_threads_batch12.json")) # 100 sampled doubt threads
with open("traces.jsonl", "w") as out:
for t in threads:
start = time.time()
result = doubtbot.answer(t["question"], return_trace=True) # our product, with its steps recorded
out.write(json.dumps({
"thread_id": t["id"],
"question": t["question"],
"ta_answer": t["accepted_ta_reply"], # ground truth: what the human TA did
"retrieved": result.retrieved_chunks, # which notes were fetched
"bot_answer": result.answer,
"escalated": result.escalated,
"latency_s": round(time.time() - start, 2),
}) + "\n")
print("Wrote", len(threads), "traces")
Output:
Wrote 100 traces
Each line now holds a question, the TA's real answer and DoubtBot's full trace side by side, which is exactly what SMEs need for open coding.
2.8 Case study: DoubtBot's first qualitative eval
DoubtBot replaces part of a human TA's job, so it's Scenario 2: we have history but no traces. Here's how the qualitative eval ran.
From the course's discussion forum and TA email threads, we sampled ~100 real student doubts with the TA's reply, deliberately mixing:
Core concepts
"What's the difference between BFS and DFS?" (the easy, common case)Debugging & problem solving
"My DP solution for coin change gives the wrong answer for amount 0" (harder)Admin / out of scope
"Is the Week 6 quiz deadline Friday?", "Should I learn Java or Go?"Sensitive
"I've failed three tests in a row and feel like quitting."Then each doubt was replayed through DoubtBot (the back-testing script above), and two senior TAs did open coding on the traces.
🔎 Three traces, three different failures
Trace A: the homework helper
Trace B: the missed hand-over
Trace C: the wrong "heap"
{
"question": "Why is building a heap O(n) and not O(n log n)?",
"query_used_for_search": "heap build complexity O(n)",
"retrieved": [
{"source": "campus_wiki/java-memory-tuning.md", "score": 0.86,
"text": "The JVM heap stores objects. Building a larger heap with -Xmx…"},
{"source": "campus_wiki/os-lecture-memory.md", "score": 0.79,
"text": "Heap vs stack memory: the heap grows upward…"}
],
"bot_answer": "Building a heap depends on the -Xmx setting, which allocates memory in linear time…",
"escalated": false
}
SME note: The vector database had accidentally indexed the whole campus wiki, not just the DSA course. "Heap" (the data structure) matched "heap" (memory) and the model, doing exactly what it was told, answered confidently from the wrong documents. Retrieval failure caused by dirty data. The answer is wrong, but the root cause is the index, not the model.🗂 The final taxonomy (after ~100 traces)
After both TAs finished their notes, the team grouped them, checked for overlaps and gaps, and agreed on this taxonomy:
| Category | Dimension | Definition | Example from the notes |
|---|---|---|---|
| Direct solution | Safety / policy | Gives complete code or final answers for graded work | Trace A |
| Missed escalation | Safety | Should have handed to a human (distress, unsure, policy) but didn't | Trace B |
| Privacy leak | Safety | Reveals any other student's data | Named a classmate's roll number |
| Retrieval failure | Quality | Fetched irrelevant or wrong-topic notes | Trace C |
| Hallucinated fact | Quality | States something false that isn't in the notes | "Python lists are linked lists" |
| Level mismatch | Quality / UX | Far too advanced or too basic for this course | Explained amortised analysis with potential functions to a week-2 student |
| Over-escalation | UX | Handed to a TA when it could have answered (under-confident) | Escalated "what is a stack?" |
| Cold tone | UX | Correct but discouraging or robotic | "This is basic. Re-read lecture 3." |
| Slow response | Performance | Took over 10 seconds to answer | Long answers with 8 retrieved chunks |
2.9 What happens next: triage the taxonomy
Qualitative evals are not just "preparation". They are a fail-fast mechanism (you may already know the project needs a redesign) and one of your best stakeholder tools: handing a leader a clear taxonomy with real examples builds far more trust than a score. Before moving to Chapter 3, sort every category into one of three bins:
⚙️ Deterministic
A plain rule or normal software test can catch it. No AI judge needed.Privacy leak (regex), slow response (timer), broken JSON.
🤖 Automatable
Needs judgement, but a well-calibrated LLM judge can do it at scale.Direct solution, retrieval failure, hallucinated fact, level mismatch.
👩🏫 Needs humans
Too subjective or too high-stakes to trust a judge alone; sample and review by people.Missed escalation on distress messages (also add a rule-based keyword backstop), cold tone.
🎮 Try it: triage DoubtBot's taxonomy
Choose the best bin for each category. There can be reasonable debate; the explanation tells you what most teams would do.
2.10 Summary
- LLM-as-a-judge is one of many methods. Match the method to the metric.
- Pairwise comparisons are easier and more consistent for humans than absolute scores.
- Evaluation judges outputs; annotation creates data. The same data can serve both.
- When a rule can decide (exact values, formats, PII), use a rule: free, fast, reliable.
- Overlap and similarity metrics need references and confuse "similar words" with "correct".
- Human rubric evals and LLM judges share the same recipe; who applies the rubric is the difference.
- Start with a time-boxed qualitative eval; its output is a MECE error taxonomy.
- Note only the first failure in each trace, and cover quality, performance, safety and UX.
- No traces? Replay historical data (back-testing) or design scenarios and synthesise inputs.
📝 Quick quiz (click to reveal the answer)
Q1. You want to know whether prompt v2 is better than v1. Pointwise or pairwise human rating?
Pairwise: show raters the v1 and v2 answers side by side and ask which is better. It's easier and more consistent than giving each a separate score.Q2. What's the difference between human evaluation and annotation?
Evaluation judges outputs to measure performance; annotation creates labelled data (often to train models). The same data, like pairwise preferences, can be used for either (evaluation, or DPO/reward-model training).Q3. Give two DoubtBot checks that should be rule-based, not LLM-judged.
Examples: no phone numbers, emails or student IDs in replies (regex); response time under 10 seconds (timer); the reply is valid JSON if a format is required; the helpline number is exactly right.Q4. Why can ROUGE give a correct answer a low score?
It counts shared words. A correct paraphrase ("it only works on ordered lists") shares few words with the reference ("binary search needs a sorted array"), so it scores low, while a wrong answer that reuses the words can score high.Q5. Which classic metric family checks logical support rather than similarity?
Entailment / NLI (natural language inference) models, e.g. FactCC or SummaC for factual consistency.Q6. What is Goodhart's law and how does it threaten automated evals?
"When a measure becomes a target, it stops being a good measure." Teams optimise the prompt to please the metric or judge rather than the user. Keeping humans reviewing real outputs keeps the metric honest.Q7. What does MECE mean for an error taxonomy?
Mutually exclusive (each failure fits exactly one category) and collectively exhaustive (the categories cover every failure seen).Q8. Why do we note only the first failure in a trace?
Later problems are often consequences of the first one (wrong retrieval → wrong answer → confused student). Noting the first failure keeps the taxonomy about root causes.Q9. DoubtBot replaces part of a TA's job. Which bootstrapping scenario is it, and what's the data source?
Scenario 2 (new AI product for an existing workflow). Proxy data from the course forum, TA emails and the LMS, replayed through the bot (historical back-testing), with the TA's replies as ground truth.Q10. Name the three triage bins for taxonomy categories.
Deterministic (rules or normal tests), automatable (LLM judge or other automated metric) and needs-human (subjective or high-stakes; sampled human review).📖 Glossary
| Term | Meaning in one line |
|---|---|
| Pointwise / pairwise / listwise | Score one output / pick the better of two / rank several. |
| Task-based / rubric-based / guardrail eval | Did it complete the task? / score against criteria / did it break a rule? |
| Annotation | Labelling data, usually to train models. |
| DPO / RLHF | Training methods that learn from human preferences. |
| Regex | A text pattern used to find or check strings (phone numbers, IDs). |
| Reference answer / ground truth | A known good answer to compare outputs against. |
| BLEU / ROUGE / METEOR | Word-overlap metrics between output and reference. |
| BERTScore / embedding similarity | Meaning-based similarity using embeddings. |
| NLI / entailment | Checking whether one text logically supports another. |
| User / environment simulation | An LLM plays a user / fake versions of the tools and systems an agent uses. |
| Goodhart's law | A measure that becomes a target stops measuring what you care about. |
| Qualitative eval | Quick, time-boxed human review of outputs to find failure modes. |
| Error taxonomy | A MECE list of the ways a product fails. |
| Open coding | Writing free-form notes on why each output failed, before any categories exist. |
| MECE | Mutually exclusive, collectively exhaustive. |
| Trace bootstrapping / back-testing | Creating traces without production users, e.g. by replaying historical requests. |
| Proxy data | Real data from an older process (tickets, emails, forums) used in place of traces. |