Skip to content

    AI Architect Case Files

    Case File: A RAG Assistant That Is Confident and Wrong

    A hospital staff assistant answered procedure questions fluently and wrongly. Separate retrieval and generation metrics showed why, and abstention fixed it.

    By Published 7 min read

    • ai-architect
    • case-file
    • industry-healthcare
    • pattern-llm-judge
    • failure-retrieval-miss
    • kind-composite
    Share

    Composite scenario, not a real company. Assembled from common industry patterns; every number is illustrative and its assumptions are listed at the end.

    This case belongs to Evaluating AI systems.

    NOTE

    This page is about evaluation design for an internal procedure-lookup assistant in an invented scenario. It is not medical, clinical or regulatory advice, and it is not guidance for patient care or for choosing a clinical system.

    Context

    • A regional hospital group gives ward and laboratory staff an assistant that answers questions about internal procedures: specimen labelling, patient-transfer paperwork, equipment cleaning logs.
    • It retrieves passages from the procedure library and answers with the passage ids it used.
    • It gives no diagnosis or dosing advice. Staff remain responsible for following the official procedure.

    Problem statement

    After launch, staff reported certain-sounding wrong answers, such as a labelling rule the library had replaced a year earlier. The only dashboard showed a mean faithfulness score of 0.93, so the assistant looked healthy. Here "hallucination" means a confident wrong answer; most were not invented text.

    Measure Value
    Human audit 200 sampled questions
    Confident wrong answers 38 (19%, 95% interval 14.2% to 25.0%)
    Target Measure retrieval and generation separately, at most 5% confident wrong, and say "I could not find a current procedure" when evidence is weak

    Constraints

    • Fixed: no patient data in questions or answers; the system prompt forbids clinical advice.
    • Fixed: every answer cites passage ids that were actually retrieved.
    • Limit: two procedure owners could label 200 questions with their answering passage.
    • Limit: a person must be able to read why the assistant declined.

    Why the traditional approach fell short

    Approach Where it breaks
    Keyword search over the intranet Returns every version of a procedure at equal rank; the staff member picks
    Rules or FAQ list Covers top questions and goes stale as procedures change
    Manual review of a few answers Catches wording errors, but the reviewer rarely sees which passage the model saw, so cannot tell if it was current

    Options considered

    Option Verdict Reason
    A. Curated "current procedures" page and better intranet search (non-AI) Kept Cheap and exact; the destination of the abstention message
    B. Keep the faithfulness-only dashboard and tune the prompt Rejected Faithfulness is judged against the retrieved text, so a faithful answer from the wrong passage scores well
    C. Retrieval and generation metrics, an evidence check with abstention, a sampled judge Accepted Locates the failure and stops answering when evidence is weak
    D. Put the whole library in every prompt Rejected Superseded versions stay in the context, so the model still has to choose

    Solution architecture

    Figure 1. Two measurement points and an evidence check

    Retrieval and generation measured separatelyClient app to Orchestrator; Orchestrator to Retriever (query); Retriever to Vector index; Orchestrator to Model gateway (evidence ok); Model gateway to LLM provider; Orchestrator to Abstain (evidence weak); Orchestrator to Trace store; Trace store to Eval service; Eval service to Retriever (recall, MRR, nDCG); Eval service to Model gateway (faithfulness)Vector index: version, effective dateVector indexversion,effective dateRetrieverRetrieverAbstain: no current procedureAbstainno currentprocedureClient appClient appOrchestrator: evidence checkOrchestratorevidence checkTrace storeTrace storeEval serviceEval serviceModel gatewayModel gatewayLLM providerLLM providerqueryevidence okevidence weakrecall, MRR, nDCGfaithfulness

    How to read this: the two arrows leaving the Eval service point at the part each metric measures, so a drop is traced to retrieval or to generation.

    Figure 2. One question, with the abstain path

    sequenceDiagram accTitle: Runtime path with abstention accDescr: The Orchestrator retrieves passages, checks that a current passage is present and relevant, and either abstains or generates a cited answer. It validates the citations and records a trace that the Eval service samples for faithfulness. participant CA as Client app participant OR as Orchestrator participant RT as Retriever participant MG as Model gateway participant LP as LLM provider participant TS as Trace store participant EV as Eval service CA->>OR: Question OR->>RT: Top 5 passages, current versions only RT-->>OR: Passages with ids and effective dates alt no current passage above the relevance threshold OR-->>CA: Abstain, link to the curated page else evidence present OR->>MG: Question and passages MG->>LP: Request LP-->>MG: Answer citing passage ids MG-->>OR: Answer OR->>OR: Check that every cited id was retrieved OR-->>CA: Answer with citations end OR->>TS: Trace with ids, versions and outcome TS-->>EV: Sampled traces, faithfulness judged

    How to read this: the alt block is the decision to answer or decline, made before the model is called.

    How AI solved it, step by step

    Step through one question, then switch to "Without the fix".

    One procedure question (interactive when JavaScript is on)

    As designed

    1. Ask. A nurse asks how long a labelled specimen may wait before processing. The Client app sends it on.
    2. Retrieve current versions. The Orchestrator asks the Retriever for the top 5 passages, current versions only.
    3. Passages come back. The Retriever returns passages with ids, version and effective date.
    4. Decision: answer or abstain. The evidence check needs a current passage above a relevance threshold tuned on the golden set. If none qualifies, the Orchestrator abstains and links the curated page.
    5. Generate with citations. Otherwise the Model gateway sends the question and passages to the provider, and the model cites the ids it used.
    6. Verify citations. The Orchestrator rejects any answer citing an id that was not retrieved.
    7. Trace and evaluate. The Trace store keeps ids, versions and outcome. Nightly, the Eval service reruns the golden set for recall and MRR and judges 100 sampled traces for faithfulness.
    8. Weekly human check. A person reads 30 answers and 30 abstentions, to catch declined questions that had an answer.

    Without the fix

    1. Retrieve every version. The same question arrives and retrieval searches every version of the library. The gold passage is outside the top 5 for 48 of 200 audit questions; the model may be given a superseded passage.
    2. Model answers anyway. With no evidence check, the model writes a fluent answer from what it was given.
    3. Dashboard says healthy. The answer is faithful to its context, so the judge scores it 1.0 and the mean stays at 0.93. Staff follow the replaced rule.

    Under the hood

    The Ragas paper (Es et al.) defines three reference-free scores, each computed with LLM prompts.

    Score How it is computed Agreement with humans
    Faithfulness An LLM splits the answer into statements S and checks each against the retrieved context. F = V / S, with V the supported statements 0.95
    Answer relevance An LLM writes n questions from the answer. AR is the mean cosine similarity of their embeddings to the original question 0.78
    Context relevance An LLM extracts the sentences needed from the context. CR is those over all sentences in the context 0.70

    Agreement is from pairwise comparisons on the paper's WikiEval set. The authors found context relevance the hardest to evaluate.

    For an architect:

    • Faithfulness asks whether the answer follows from the context it was given, not whether the context was right. A faithful answer from a superseded passage scores 1.0.
    • Context relevance uses the retrieved text alone, so it cannot see the passage that was missed. Only a labelled set with gold passage ids can count that miss, which is why recall at k and ranking metrics sit beside these scores.

    Recall at 5 is the share of questions whose gold passage is in the top 5. Gate it at a lower bound of 0.85 (two-sided 95%). Set passes to 152, the audit result: the interval falls to 69.6% to 81.4% and the gate fails.

    Recall at 5 gate (interactive when JavaScript is on)
    Observed pass rate90.0%
    Interval (z = 1.96)85.1% to 93.4%
    Gate: lower bound at least 85.0%pass

    The target, 180 of 200, gives 85.1% to 93.4% and passes. The mechanism is in Under the hood: Generation metrics.

    What went wrong / failure modes

    Failure What happened and the mitigation
    Faithful but wrong 29 of the 38 were faithful to a wrong or superseded passage, judged 1.0. Use retrieval metrics against gold ids and a current-version filter
    Unsupported claims (hallucination in the narrow sense) The other 9 had statements in no retrieved passage. Sample with the faithfulness judge; check citations
    Over-abstention A high threshold declines answerable questions. Track the abstention rate; read declined questions weekly
    Judge error A judge can misgrade, especially on long contexts. Compare 60 judged answers with a human: 54 agree (90%, interval 79.9% to 95.3%); see the summarisation case
    Gold set drift Procedures change. Owners re-label when a version changes

    Results

    All results are illustrative targets, not measurements.

    Measure At audit Target
    Recall at 5 152 of 200 (0.76) At least 180 of 200 (0.90, lower bound 0.85)
    MRR at 5 0.63 Report it; watch the trend
    Confident wrong answers 38 of 200 (19%) At most 10 of 200 (5%)
    No current passage Answered anyway Declined, with a link to the curated page

    Tradeoffs and when NOT to use this approach

    • Abstention has a cost. Every declined question sends someone to a human or a page. Tune the threshold against both errors.
    • Small libraries. A few dozen procedures suit a curated page.
    • Clinical advice. This design suits procedure lookup. Answers that guide patient care need clinical governance beyond this page.
    • Judge-only quality. An uncalibrated judge must not decide releases.

    Design rules extracted

    1. Measure retrieval and generation separately; a generation score cannot see a miss.
    2. Keep gold passage ids for a labelled set; report recall at k and a rank metric nightly.
    3. Decide when to abstain before the model is called, using metadata and a tuned threshold.
    4. Calibrate a judge against humans, then sample.
    5. Cite ids and verify them in code.

    Assumptions

    All numbers are illustrative.

    • Audit set: 200 questions, one gold passage each. Confident wrong: 38 of 200 = 0.19; Wilson 95% (z = 1.96): 0.1417 to 0.2500. Of the 38, 29 faithful to a wrong passage and 9 with unsupported claims. All 38 fall among the 48 questions whose gold passage was outside the top 5; the other 10 were right or hedged (the audit predates the abstention check).
    • Rank of the gold passage: 1 for 110 questions, 2 for 20, 3 for 12, 4 for 6, 5 for 4, outside the top 5 for 48. Recall at 5 = 152 / 200 = 0.76. MRR is the mean of 1 / rank, as the TREC-8 question answering track scored it (Voorhees and Tice, LREC 2000): (110 x 1 + 20 / 2 + 12 / 3 + 6 / 4 + 4 / 5) / 200 = 126.3 / 200 = 0.6315.
    • nDCG at 5 (Stanford IR book), DCG = sum of (2^grade - 1) / log2(1 + m). Grades: 3 current, 2 supporting, 1 superseded, 0 irrelevant. Retrieved [1, 0, 3, 0, 2] gives 5.6606; the ideal order gives 9.3928; nDCG = 0.6026.
    • Wilson 95%: 180 of 200 gives 0.8506 to 0.9343; 152 of 200 gives 0.6963 to 0.8139.
    • Faithfulness mean 0.93 and the judge sample (54 of 60 agree, Wilson 0.7985 to 0.9534) are assumed. The hospital group, procedures and thresholds are invented.

    Last verified: 2026-10-22

    Ask about this article

    Get answers grounded in this post. AI-generated — based on this article, and may be imperfect.

    Scaled AI Weekly

    Enjoyed this? Get more like it every Monday.

    Real architecture decisions, LLMOps patterns that survive production, and engineering leadership advice — from 12+ years of building at enterprise scale. Free. No spam. Unsubscribe anytime.

    Get new articles by email

    Free. We email a confirmation link first, and you can unsubscribe from any email.

    Join engineers building production AI systems

    Comments