Abstract
<title>Abstract</title> <p>Background Large language models (LLMs) are increasingly applied in clinical settings, yet their tendency to generate confident but inaccurate responses ("hallucinations") poses meaningful risks in high-stakes disciplines such as metabolic and bariatric surgery (MBS). Retrieval-Augmented Generation (RAG) offers a pathway toward safer, more verifiable AI outputs by grounding generation in authoritative, domain-specific sources. We developed and evaluated a bariatric surgery question-answering system anchored exclusively to the ASMBS Textbook of Bariatric Surgery (2nd edition) and compared its performance against unaided LLMs. Methods We curated a 200-question benchmark drawn systematically from end-of-chapter assessments across all 56 chapters of the ASMBS textbook, spanning seven clinical domains including epidemiology, physiology, patient selection, perioperative care, operative technique, complications, and nutrition/outcomes. A multi-stage RAG pipeline was implemented incorporating medicalized query rewriting, structured query expansion, ChromaDB vector retrieval using OpenAI's text-embedding-3-large model, and two-tiered LLM-based relevance and usefulness filtering prior to answer generation. Three proprietary LLMs (GPT-4o-mini, GPT-4, and GPT-5) were evaluated in both raw (no retrieval) and textbook-augmented RAG configurations. Accuracy was defined as the proportion of correct responses, with Wilson score 95% confidence intervals computed for each condition. Results Textbook-augmented RAG produced consistent and significant accuracy gains across all models. GPT-5 with RAG achieved the highest overall accuracy (188/200; 94.0%; 95% CI 89.8–96.5%), compared to 87.0% for GPT-5 raw (+ 7.0 percentage points; +14 questions). GPT-4 with RAG reached 89.5% versus 81.0% raw (+ 8.5 pp; +13 questions), and GPT-4o-mini improved from 70.5% to 84.5% with RAG (+ 14.0 pp; +28 questions). Domain-level analysis revealed perfect scores in epidemiology (100%) and perioperative care (100%), while procedural technique and complications management showed the greatest residual error rates (88.9% each), reflecting the challenge of multi-step clinical reasoning. Error analysis of the 12 incorrect GPT-5 + RAG responses identified recurrent failure modes including evidence-level mismatch, polarity errors in EXCEPT-type questions, scope misinterpretation, and retrieval salience bias. Conclusion A domain-restricted RAG system anchored to the ASMBS textbook substantially improves LLM accuracy for bariatric surgery clinical question answering, with the best configuration surpassing previously reported benchmarks by 11 percentage points. Systematic error analysis reveals specific, addressable failure modes that can inform the next generation of AI-assisted clinical decision support tools. These findings support the deployment of curated, auditable RAG frameworks as a practical strategy for reducing hallucinations and enhancing the reliability of AI in specialized surgical practice.</p>