Sub topic 2
Defining what good looks like
This chapter assumes you can write basic Python, have called an LLM through an API, and know what a proportion is.
Why criteria come before metrics
If you pick a metric first, you end up measuring whatever is easy to measure. "The answers should be good" cannot be scored. A success criterion is a statement about an output that two people could check separately and reach the same verdict on.
From task to criteria
Work in this order:
- Describe the task and the user it serves.
- List the ways the application can fail.
- Turn each failure mode into a criterion with a pass or fail verdict.
- Set a threshold for each criterion.
- Only then choose how to score it.
Take a support bot that answers from help-center articles. Its failure modes come from what a bad answer would cost the user or the business.
| Failure mode | Criterion | Likely scoring method |
|---|---|---|
| Invents a refund policy | Every claim is supported by the retrieved articles | LLM judge |
| Ignores the question | The answer addresses what was asked | LLM judge or human review |
| Leaks customer data | No email addresses or order numbers from other users appear | Programmatic check |
| Rambles | The answer is at most 120 words | Programmatic check |
Hard requirements and quality goals
Not every criterion deserves the same bar. A hard requirement, such as "never leak personal data", must hold on every case, so its threshold is 1.0. A quality goal, such as "addresses the question", can tolerate some misses, so a pass rate of 0.90 may be enough. Write the two kinds down separately. Otherwise a strong average hides a serious failure.
You can store criteria as data, so the harness and the people reviewing it read the same definition.
CRITERIA = [
{"name": "grounded", "kind": "goal", "threshold": 0.95},
{"name": "no_pii", "kind": "hard", "threshold": 1.0},
{"name": "concise", "kind": "goal", "threshold": 0.90},
]
def meets_threshold(criterion, pass_rate):
return pass_rate >= criterion["threshold"]
observed = {"grounded": 0.96, "no_pii": 0.99, "concise": 0.93}
for c in CRITERIA:
ok = meets_threshold(c, observed[c["name"]])
print(c["name"], c["kind"], "OK" if ok else "BELOW THRESHOLD")Here no_pii fails at 0.99, even though the other two criteria pass. That is the intended behavior for a hard requirement.
Common errors
- Vague wording. "Helpful" and "natural" need an observable definition, or reviewers will disagree.
- One blended score. A single number mixes unrelated failures. Score each criterion separately so a drop points to a cause.
- Invented thresholds. A threshold of 0.95 should come from the cost of a miss or from a baseline you measured, not from a round number.
- Criteria written only from imagination. Read 20 to 50 real outputs first. Failure modes you did not predict will show up, and each one needs a criterion.
Exercise
A travel-booking assistant summarizes cancellation rules for users. Name two failure modes, write a pass/fail criterion for each, and say which one should be a hard requirement.
Show answer
One failure mode is stating a cancellation window that the policy document does not contain. The criterion is "every date and fee in the summary appears in the policy text". Another is omitting a fee that applies. The criterion is "every fee in the policy that applies to the booking is mentioned". The wrong-window case is a good hard requirement, because a user could lose money by relying on it, so its threshold should be 1.0. Answers may vary, as long as each criterion can be checked as pass or fail.