Skip to chapter content
navan✳THE BUILD LABAI ENGINEERING / GUIDE
0/21 read
CHAPTER 07 / 21 · EVIDENCE AND EVALUATION

How to judge generated answers.

Separate exact checks, reference comparisons, human review, and model judges without treating one metric as truth.

BY NAVAN SAMILONG READTHEORY FIRST
01 / FROM THE BEGINNING

Start with the meaning.

A generated answer can be grammatically excellent and factually wrong. Evaluation therefore asks several questions: did the system follow the requested format, use permitted evidence, answer the question, and avoid unsupported claims? These are different properties. A single score called “quality” hides which property failed.

Exact checks work well for parseable fields, tool-call arguments, citations to known identifiers, and deterministic calculations. They are weaker for prose because two correct answers may use different words. Similarity scores can indicate overlap with a reference answer, but overlap is not the same as factual support. A copied wrong answer can score highly; a concise correct answer can score poorly.

02 / THE SYSTEM

How the idea works.

Human reviewers can assess nuance, but they need a rubric and enough context. Ask them to mark specific failure types, such as unsupported claim, omitted requirement, wrong citation, or tone mismatch. Two reviewers can compare decisions on a sample to see whether the rubric is clear. Review time is limited, so use automatic checks for obvious failures and reserve human attention for ambiguous or high-impact cases.

A model can also judge another model's output. This may help sort large numbers of cases, but the judge can share biases, miss subtle errors, or prefer fluent text. Give the judge the original task, evidence, and a precise rubric; ask for a reason tied to that evidence. Validate a sample of judge decisions against human review. A judge score should be treated as a measurement instrument with known error, not as an authority.

Pairwise comparison asks which of two outputs better meets a criterion. It can be easier than assigning an absolute score, but output order, length, and style can bias the choice. Randomise presentation and inspect ties. If a new system wins on style but loses on factual support, report both.

A rubric becomes useful when it names observable evidence. “Good answer” is vague. “Every factual claim is supported by an allowed passage; the answer includes the deadline; no unsupported exception is added” gives reviewers something concrete to mark. If the passage is supplied to a model judge, ask for the exact supporting span or the unsupported claim. Then sample the judge's decisions for human review, especially cases where the judge is most confident.

Metrics can conflict. A system that declines every question will avoid unsupported claims but fail to help anyone. A system that answers every question may have high coverage and many false claims. Track answer rate and correctness together. For a high-impact workflow, give serious errors their own count instead of letting common harmless successes dilute them in an average. The product decision depends on the pattern of mistakes and their consequences.

01ContractExpected behavior02CasesRoutine and hard03ChecksDistinct properties04DiagnosisFind weak slices
Measure behavior on representative cases and inspect failures by slice.
03 / PYTHON, EXPLAINED

Follow the code.

judging-generated-answers.py
def score_answer(result, case):
    checks = {
        "has_text": bool(result.get("answer", "").strip()),
        "source_allowed": set(result.get("sources", [])) <= set(case["allowed_sources"]),
        "required_source": case["required_source"] in result.get("sources", []),
    }
    return checks

The function returns three named booleans instead of averaging them immediately. That preserves the reason for failure. The subset comparison verifies that every cited source is allowed for this case. The required-source check verifies the expected document appears. Neither proves that every claim in the answer is supported.

A report could count pass rates for each check and each slice of cases. If source_allowed fails often, the retrieval or permission layer needs attention. If has_text fails, transport or generation may be failing. Diagnosis is easier when metrics correspond to system stages.

04 / THE BOUNDARY

What the result does not say.

A good evaluation combines automated, human, and operational evidence. Error rates, latency, and user correction patterns all matter, though none alone proves the system is useful.

When labels are uncertain, document the uncertainty. Treating an ambiguous case as a hard fact can drive the system toward the wrong behavior.

05 / KEEP THIS

One clear idea.

Measure distinct failure types and inspect examples; one score cannot explain an AI system.

THE CODE IN CONTEXT

The AI cookbook

Complete, explained local workflows sit alongside this reading course.

Browse the cookbook
Finished reading?
Built with curiosity. By Navan Sami. ↗AI engineering · From model calls to reliable systems.