#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. |
The problem
Section titled “The problem”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:
- The Jev gate deletes all text the model writes. It delivers only the exact quotes that Jev accepts. The code is
appendCanonicalSourcesinapps/bioagent/src/tools/verification/jev-pubmed-crosscheck.ts. - 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.
What the gate does today
Section titled “What the gate does today”- The model writes the answer with markers. Each marker becomes the exact NCBI quote.
- The gate deletes every quote that is not exact.
- The gate sends each exact quote to Jev, with the article and the de-identified search.
- 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.
- 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.
Proposal
Section titled “Proposal”- 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.
- 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.
- 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.
- 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.
How the faithfulness judge works
Section titled “How the faithfulness judge works”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.
- Input. For each Spanish sentence, the judge gets the sentence and the exact English quotes that the sentence marks.
- Six questions. For each sentence, the judge checks if the sentence changes something in the quote:
- The same patients (population)?
- The same drug or treatment (intervention)?
- The same comparison?
- The same result?
- The same direction (better or worse)?
- The same certainty?
- Output. For each sentence, the judge gives a verdict (“supported” or “not supported”) and a confidence from 0 to 1.
- 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.
How strict it is
Section titled “How strict it is”| 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 |
Example
Section titled “Example”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.
What the design is based on
Section titled “What the design is based on”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. |
What research says can go wrong
Section titled “What research says can go wrong”- 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.
Cost and time
Section titled “Cost and time”- 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 |
Date search (already built)
Section titled “Date search (already built)”The branch fix/bioagent-pubmed-answers-176 has the date change. It has no commit yet.
- If the question asks for recent evidence (“últimos”, “recientes”, “nuevos”, “latest”, “recent”), the search uses only the last 5 years.
- Inside those 5 years, the order stays by relevance. A date-only order shows letters and case reports first.
- If the dated search returns fewer than 5 articles, RheumAI searches again without dates.
- 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.
Search problems that remain
Section titled “Search problems that remain”- 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.
Evaluations
Section titled “Evaluations”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:
- If RheumAI delivers or refuses the answer.
- How many sentences pass the gate.
- How many sources are in the expected set.
- How many expected drugs it mentions.
- If it says something wrong.
We run the set locally before each change to the gate, the prompt or the search.
Open decisions
Section titled “Open decisions”- Proposal with the faithfulness judge, or the alternative without it?
- Do we accept that the answer says only what the abstracts say?
- One PR with the date search and the proposal (recommended), or the date search first?
References
Section titled “References”- 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
- 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/
- 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
- 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
- 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/
- 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
- Panickssery A, Bowman SR, Feng S. LLM Evaluators Recognize and Favor Their Own Generations. NeurIPS 2024. https://arxiv.org/abs/2404.13076
- 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