Skip to content

#176: verified answers

This page is for the development team. It describes a problem with PubMed answers and a proposal to fix it. Issue: #176.

Animated version: Explainer: the evidence gate.

Status: Proposal. Waits for Mel’s decision. Blocks the promotion of staging to production.

Term Meaning
Jev The external Typesafe service that checks if a PubMed source supports a claim.
Exact quote A sentence copied without change from the title or abstract of an NCBI article.
Marker The tag [[S:pmid:n]] that links an answer sentence to sentence n of an article.
Faithfulness judge A new check, proposed here, that confirms a Spanish sentence says the same as its exact quotes. It is an LLM-as-judge: one AI model grades the answer of another.

A physician asked on staging: “Dame los últimos tratamientos de biológicos para LES” (latest biologic treatments for lupus). RheumAI replied with three exact English quotes and a source list. One source is from 2013. The reply does not mention anifrolumab, obinutuzumab or CAR-T. There is no Spanish text.

There are two causes:

  1. The Jev gate deletes all text the model writes. It delivers only the exact quotes that Jev accepts. The code is appendCanonicalSources in apps/bioagent/src/tools/verification/jev-pubmed-crosscheck.ts.
  2. The PubMed search sorts by relevance and uses no dates. So “latest” does not change the result.

Production delivers a written answer today. If we promote staging without a change, physicians get only loose quotes.

  1. The model writes the answer with markers. Each marker becomes the exact NCBI quote.
  2. The gate deletes every quote that is not exact.
  3. The gate sends each exact quote to Jev, with the article and the de-identified search.
  4. Jev answers two questions: does the source support the quote, and does the bibliographic data agree. The gate accepts the quote only if both answers are positive at confidence 0.9 or more.
  5. The gate delivers the accepted quotes and the source list. The model’s text never reaches the physician.

Step 5 has two reasons:

Reason Explanation
Accuracy Nobody checked the model’s text against the source.
Privacy Jev is an external service. The model’s text can repeat data from the patient case. So Jev receives only exact NCBI text.

The privacy rule does not change in this proposal. We send no model-written sentence to Jev.

  1. Model answer. The model writes short sentences in the physician’s language. Each sentence has one or more markers. The gate deletes every sentence without a marker.
  2. Jev, unchanged. The gate sends each exact quote to Jev, as today. If Jev rejects a quote, the gate deletes every sentence that uses that quote.
  3. Faithfulness judge (new). One call to the model the chat already uses checks each remaining sentence. It asks: does the sentence say only what its quotes say, with no change to population, intervention, comparison, outcome, direction or certainty? It uses the same rule as Jev and the same 0.9 threshold. If a sentence fails, the gate deletes it.
  4. Delivery. The physician sees each Spanish sentence and, below it, its exact English quote with the PubMed link. The source list comes last. If no sentence remains, RheumAI refuses the answer, as today.

The faithfulness judge sends no data to a new service. The chat model already has the conversation.

The judge is an LLM-as-judge. It is a second call to gpt-4o that grades what the first call wrote. It writes nothing for the physician.

  1. Input. For each Spanish sentence, the judge gets the sentence and the exact English quotes that the sentence marks.
  2. Six questions. For each sentence, the judge checks if the sentence changes something in the quote:
    1. The same patients (population)?
    2. The same drug or treatment (intervention)?
    3. The same comparison?
    4. The same result?
    5. The same direction (better or worse)?
    6. The same certainty?
  3. Output. For each sentence, the judge gives a verdict (“supported” or “not supported”) and a confidence from 0 to 1.
  4. Rule. The gate keeps the sentence only if the verdict is “supported” and the confidence is 0.9 or more. If not, the gate deletes the sentence.

One call checks all the sentences of the answer.

Example. The quote says: “Anifrolumab reduced disease activity in patients with moderate to severe SLE.”

Spanish sentence Result Reason
“Anifrolumab redujo la actividad de la enfermedad en LES moderado a grave.” Kept It says the same as the quote.
“Anifrolumab es el tratamiento de primera línea para LES.” Deleted The quote does not say “first line”.
“Anifrolumab redujo la actividad en todos los pacientes con LES.” Deleted Different patients: the quote says “moderate to severe”.

Why gpt-4o and not Jev. Jev is an external service and can never see the text that the model writes. OpenAI already has the conversation, so the judge sends no new data outside RheumAI.

Limit of the judge. gpt-4o grades gpt-4o. It can miss its own errors. The judge reduces the risk, but it is not proof. The evaluations (below) measure how often it lets a bad sentence through. A judge on a different model is possible, but it sends text to a new provider.

Rule Today With the proposal
Every delivered sentence has a source Yes Yes
Jev accepts each exact quote Yes Yes
Model text sent to Jev No No
The physician gets a written answer No Yes
Written sentence checked against its quote Not applicable Yes, threshold 0.9

For the lupus biologics question, the physician sees four or five sentences like this one: “Anifrolumab, un anticuerpo contra el receptor de interferón tipo I, mejoró la actividad de la enfermedad en el estudio TULIP-2.” Below it, the physician sees the exact English quote and the article link.

The answer says only what the article abstracts say. If the search returns bad articles, the answer is honest but thin.

We did not invent the method. Each part comes from a known source. The new part is the combination.

Part of the judge Based on Reference
The six questions The clinical team’s Jev rule. It comes from PICO (how evidence-based medicine frames a clinical question) and GRADE (how guideline panels rate the certainty of evidence). [1], [2]
One AI model grades the answer of another LLM-as-judge [3]
The sentence says only what the source says Faithfulness and attribution checks [4], [5]
One sentence at a time Atomic fact checking [6]
Spanish sentence against English quote, threshold 0.9 Ours. Not tested.
  • The model favors its own text. A model grades text it wrote higher [7]. Here gpt-4o grades gpt-4o.
  • The confidence a model states is too high. When a model states its confidence, it is almost always between 0.8 and 1.0, also when it is wrong [8]. So the 0.9 threshold is a filter, not a guarantee. The number is the model’s own estimate, not a measured probability.

The evaluations measure this: reference questions plus bad sentences that we add on purpose, to see how often the judge lets them through.

Alternative: sentence and quote, no faithfulness judge

Section titled “Alternative: sentence and quote, no faithfulness judge”

This is the same proposal without step 3. The physician reads the sentence and the quote together and decides. It is simpler and cheaper. The risk: a sentence that overstates its quote shows next to a verified source. We do not recommend it for a clinical tool.

  • The proposal adds one model call per answer. The call checks all sentences together. It takes 2 to 4 seconds with gpt-4o.
  • Jev calls do not change: one per quote.
  • Today, answers on staging take 8 to 20 seconds. With the proposal they stay far below the Cloudflare limit of 100 seconds.
In Out
Normal /api/chat answers that cite PubMed Study mode and the benchmark (no change, so the evaluations stay valid)
tools/reply/index.ts: the prompt asks for sentences with markers Deep research (changes later, when chat works)
jev-pubmed-crosscheck.ts: delivers sentences, not loose quotes The Jev request (createRequest does not change)
A new module for the faithfulness judge
The sentence-and-quote view in the interface

The branch fix/bioagent-pubmed-answers-176 has the date change. It has no commit yet.

  1. If the question asks for recent evidence (“últimos”, “recientes”, “nuevos”, “latest”, “recent”), the search uses only the last 5 years.
  2. Inside those 5 years, the order stays by relevance. A date-only order shows letters and case reports first.
  3. If the dated search returns fewer than 5 articles, RheumAI searches again without dates.
  4. The search that NCBI receives does not change. No word of the question goes to NCBI.

NCBI test with the lupus question: without dates, 7 of the top 10 articles are from 2010 to 2017. With dates, all 10 are from 2022 to 2026, and anifrolumab appears.

  • The search uses a fixed vocabulary and joins the terms with AND. Terms like “treatment” bring off-topic articles: a ChatGPT study, juvenile arthritis, a scleritis case report.
  • The word “les” (a common Spanish pronoun) triggers the lupus term.
  • Without evaluations, every search change is a guess.

Every change until today used 2 to 4 test questions. So we found the problems late.

Proposal: a set of 20 to 30 reference questions, written by the clinical team. Each question states what a rheumatologist expects: key drugs, current guidelines, acceptable sources and serious errors. For each answer we measure:

  1. If RheumAI delivers or refuses the answer.
  2. How many sentences pass the gate.
  3. How many sources are in the expected set.
  4. How many expected drugs it mentions.
  5. If it says something wrong.

We run the set locally before each change to the gate, the prompt or the search.

  1. Proposal with the faithfulness judge, or the alternative without it?
  2. Do we accept that the answer says only what the abstracts say?
  3. One PR with the date search and the proposal (recommended), or the date search first?
  1. Richardson WS, Wilson MC, Nishikawa J, Hayward RS. The well-built clinical question: a key to evidence-based decisions. ACP Journal Club. 1995;123(3):A12-A13. https://doi.org/10.7326/ACPJC-1995-123-3-A12
  2. Guyatt GH, Oxman AD, Vist GE, et al. GRADE: an emerging consensus on rating quality of evidence and strength of recommendations. BMJ. 2008;336(7650):924-926. https://pubmed.ncbi.nlm.nih.gov/18436948/
  3. Zheng L, Chiang WL, Sheng Y, et al. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena. NeurIPS 2023, Datasets and Benchmarks. https://arxiv.org/abs/2306.05685
  4. Es S, James J, Espinosa-Anke L, Schockaert S. Ragas: Automated Evaluation of Retrieval Augmented Generation. arXiv 2309.15217, 2023. https://arxiv.org/abs/2309.15217
  5. Rashkin H, Nikolaev V, Lamm M, et al. Measuring Attribution in Natural Language Generation Models. Computational Linguistics. 2023;49(4):777-840. https://aclanthology.org/2023.cl-4.2/
  6. Min S, Krishna K, Lyu X, et al. FActScore: Fine-grained Atomic Evaluation of Factual Precision in Long Form Text Generation. EMNLP 2023. https://aclanthology.org/2023.emnlp-main.741
  7. Panickssery A, Bowman SR, Feng S. LLM Evaluators Recognize and Favor Their Own Generations. NeurIPS 2024. https://arxiv.org/abs/2404.13076
  8. Xiong M, Hu Z, Lu X, et al. Can LLMs Express Their Uncertainty? An Empirical Evaluation of Confidence Elicitation in LLMs. ICLR 2024. https://arxiv.org/abs/2306.13063