Large language model chatbot-based text-to-SQL application for database analyses in liver diseases and hepatology research
Open Access
- 5 May 2026
- journal article
- Published by Oxford University Press (OUP) in JAMIA Open
- Vol. 9 (3) , ooag106
Abstract
Objective: Large language models (LLMs) may improve analysis of structured clinical data by enabling natural language (NL) queries. We developed an interactive, PHI-compliant “Text2SQL” chatbot as a proof-of-concept for hepatocellular carcinoma (HCC) research. Materials and methods: Using the University of California, San Francisco’s secure artificial intelligence platform, we configured the chatbot to translate NL queries into Structured Query Language (SQL), execute them, and return both code and results. Clinicians posed 30 questions, and outputs were compared with SQL written by a data scientist. We assessed prompt interpretation, SQL accuracy, output accuracy, and error types according to strict binary criteria. Results: Prompt interpretation accuracy was 73.3%, SQL accuracy ranged from 53% to 63%, and output accuracy from 53% to 63%. Frequent errors included group comparisons, ambiguous variables, and exploratory questions. Discussion: Text2SQL enables PHI-compliant interaction with clinical datasets without coding, though performance varies across query types. Conclusion: LLM-powered Text2SQL offers a promising approach for clinician-friendly clinical data access.Keywords
Funding Information
- Financial/Grant Support (K23DK139455)
- National Institute of Diabetes and Digestive and Kidney Diseases, Ge (P30DK026743)
- National Institute of Diabetes and Digestive and Kidney Diseases, Ge (UCSF Liver Center Grant)
- National Institute of Diabetes and Digestive and Kidney Diseases, Ge (R01DK133527)
- National Institute of Diabetes and Digestive and Kidney Diseases (K24AG080021)
- National Institute on Aging (T32DK060414)
- National Institute of Diabetes and Digestive and Kidney Diseases
This publication has 6 references indexed in Scilit:
- Evaluation of OpenAI o1: Opportunities and Challenges of AGIarXiv, 2025
- Graph-empowered Text-to-SQL generation on Electronic Medical RecordsPattern Recognition, 2025
- DeepSeek vs. ChatGPT vs. Claude: A comparative study for scientific computing and scientific machine learning tasksTheoretical and Applied Mechanics Letters, 2025
- MedT5SQL: a transformers-based large language model for text-to-SQL conversion in the healthcare domainFrontiers in Big Data, 2024
- EHRSQL: A Practical Text-To-SQL Benchmark for Electronic Health Records2022
- Development of a novel frailty index to predict mortality in patients with end‐stage liver diseaseHepatology, 2017