download

How do you score refusal when retrieved context lacks the answer?

AI engineering~12 minReviewed 3 Dec 2026Free · No sign-in

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).

PromptAnswerable (140): right / wrong / refusedUnanswerable (60): answered / refused
Aggressive120 / 13 / 727 / 33
Cautious115 / 4 / 216 / 54
  1. Compute hallucinated-answer rate, false-refusal rate, coverage, and selective accuracy for both prompts.
  2. Why does measuring hallucination rate alone fail, and how do you choose the right operating point?
Show hints (3)
  1. "USE SEPARATE DENOMINATORS"

    Divide hallucinated answers by the 60 unanswerable queries. Divide false refusals by the 140 answerable queries.

  2. "COVERAGE AND SELECTIVE ACCURACY"

    Coverage is total non-refusals divided by 200. Selective accuracy is right answers divided by total non-refusals.

  3. "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).

"SOLUTION · PYTHON"
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%}")
"OUTPUT"
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.

MetricFormulaAggressiveCautious
Hallucination on unanswerableanswered / 6027/60 (45%)6/60 (10%)
False refusal on answerablerefused / 1407/140 (5%)21/140 (15%)
Coverage (answer rate)total answered / 200160/200 (80.0%)125/200 (62.5%)
Selective accuracyright / total answered120/160 (75%)115/125 (92%)
Overall pass (right + right refuse)(ok + ok_ref) / 200153/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 →

Original OfferVibe question. Pranav Rajpurkar, Robin Jia, and Percy Liang, "Know What You Don't Know: Unanswerable Questions for SQuAD" (ACL 2018); Ran El-Yaniv and Yair Wiener, "On the Foundations of Noise-free Selective Classification" (JMLR, 2010) · NIST AI 600-1 Generative AI Profile.
© 2026 OfferVibe · Text CC BY-NC-SA 4.0 · code MITFree to share and adapt with credit, not for commercial use. Code samples are free for any use.