How do you score refusal when retrieved context lacks the answer?
Question
You test two prompts for a medical-benefits RAG assistant on 200 fixed queries. 140 are answerable from retrieved chunks, and 60 are unanswerable (context lacks the answer, so the bot must refuse).
| Prompt | Answerable (140): right / wrong / refused | Unanswerable (60): answered / refused |
|---|---|---|
| Aggressive | 120 / 13 / 7 | 27 / 33 |
| Cautious | 115 / 4 / 21 | 6 / 54 |
- Compute hallucinated-answer rate, false-refusal rate, coverage, and selective accuracy for both prompts.
- Why does measuring hallucination rate alone fail, and how do you choose the right operating point?
Show hints (3)
- "USE SEPARATE DENOMINATORS"
Divide hallucinated answers by the 60 unanswerable queries. Divide false refusals by the 140 answerable queries.
- "COVERAGE AND SELECTIVE ACCURACY"
Coverage is total non-refusals divided by 200. Selective accuracy is right answers divided by total non-refusals.
- "CHECK THE TRIVIAL BASELINE"
A bot that refuses every query scores 0% hallucination on unanswerable queries. What happens to its false-refusal rate and coverage?
Show checked explanation
Track unanswerable hallucinations and answerable false refusals together, along with coverage and selective accuracy. The aggressive prompt covers 80.0% of queries at 75% selective accuracy, yet hallucinates on 45% of unanswerable cases (27/60). The cautious prompt cuts hallucinations to 10% (6/60) and lifts selective accuracy to 92%, trading 15% false refusals (21/140).
from fractions import Fraction # (prompt, ans_ok, ans_wrong, ans_refuse, unans_halluc, unans_refuse) runs = [ ("aggressive", 120, 13, 7, 27, 33), ("cautious", 115, 4, 21, 6, 54), ] for name, ok, wrong, f_ref, hall, ok_ref in runs: ans_n = ok + wrong + f_ref unans_n = hall + ok_ref answered = ok + wrong + hall cov = Fraction(answered, ans_n + unans_n) sel_acc = Fraction(ok, answered) hall_rate = Fraction(hall, unans_n) fref_rate = Fraction(f_ref, ans_n) print(f"{name:10} hall={float(hall_rate):.0%} " f"false_ref={float(fref_rate):.0%} " f"cov={float(cov):.1%} sel_acc={float(sel_acc):.0%}")
aggressive hall=45% false_ref=5% cov=80.0% sel_acc=75% cautious hall=10% false_ref=15% cov=62.5% sel_acc=92%
Code and exact rational calculations run on CPython 3.12.10 against the 200-query local fixture above; official NIST documentation link checked. Checked by an editor other than the author.
Walkthrough
Abstention is a two-sided trade-off between guessing when you should refuse and refusing when you could answer.
1. Split the 200 cases into four paired metrics.
| Metric | Formula | Aggressive | Cautious |
|---|---|---|---|
| Hallucination on unanswerable | answered / 60 | 27/60 (45%) | 6/60 (10%) |
| False refusal on answerable | refused / 140 | 7/140 (5%) | 21/140 (15%) |
| Coverage (answer rate) | total answered / 200 | 160/200 (80.0%) | 125/200 (62.5%) |
| Selective accuracy | right / total answered | 120/160 (75%) | 115/125 (92%) |
| Overall pass (right + right refuse) | (ok + ok_ref) / 200 | 153/200 (76.5%) | 169/200 (84.5%) |
2. Why hallucination rate alone is broken. A trivial bot that replies "I don't know" to all 200 queries achieves 0% hallucination on the 60 unanswerable queries, yet suffers 100% false refusal (140/140) and 0% coverage. You can only judge abstention when you read risk and coverage side by side.
3. Read the risk-coverage trade-off. Selective risk is 1 - selective accuracy (the error rate among answers users actually receive). Moving from Aggressive to Cautious lowers coverage by 17.5 points (from 80.0% to 62.5%), while cutting selective risk by more than two-thirds, from 25% (40/160) down to 8% (10/125). For a medical-benefits assistant where a wrong policy answer is costly and a clean escalation to a human is cheap, the cautious point is far safer.
4. Make unanswerable tests realistic. Build your 60 unanswerable queries from near-miss topics that share keywords with your docs (for example, asking about dental coverage when only vision chunks exist). Easy off-topic questions like "Who won the World Cup?" hide real hallucination risk.
Common mistakes
- Optimizing hallucination rate without tracking false refusals. A prompt that refuses almost everything wins the hallucination metric while making the product useless.
- Testing abstention only on obviously off-topic prompts. Real RAG failures happen on near-miss queries where retrieved chunks look related yet omit the specific fact.
- Confusing selective accuracy with overall pass rate. Selective accuracy (115/125 = 92%) scores only answered queries; pair it with coverage (62.5%) so refusals stay visible.
- Treating all wrong answers and false refusals as equal cost. High-stakes domains like medical or billing tolerate higher refusal rates than casual search.
Follow-up questions
- "Your compliance lead wants hallucinations under 5%, so you tune stricter rules and false refusals jump from 15% to 25%. How do you improve both instead of only sliding along the curve?" Improve the input evidence and decision signal rather than just prompt wording. Fix retrieval misses, add a retrieval-score or reranker confidence threshold to trigger abstention before generation, and run a groundedness check before returning borderline answers.
- "How do you detect whether a response actually refused without brittle exact-string matching?" Use a structured output field like
status: "answered" | "abstained"alongside the text, backed by a lightweight refusal classifier audited against human labels. Watch for hedging answers that say "I cannot be sure" and then guess anyway; count those as answers, not refusals.
What a strong answer covers
Computes all four paired metrics on both prompts: Aggressive (45% hallucination, 5% false refusal, 80.0% coverage, 75% selective accuracy) vs Cautious (10%, 15%, 62.5%, 92%). Explains the risk-coverage trade-off, calls out the always-refuse trap, and tests near-miss unanswerable queries.
Open in interactive practice deck →