cs.IRMar 5, 2026

CBR-to-SQL: Rethinking Retrieval-based Text-to-SQL using Case-based Reasoning in the Healthcare Domain

Authors: Hung Nguyen, Hans Moen, Pekka Marttinen

Organizations: Department of Computer Science Aalto University · Department of Clinical Medicine Aalborg University

Abstract

Extracting insights from Electronic Health Record (EHR) databases often requires SQL expertise, creating a barrier for clinical decision-making and research. A promising approach is to use Large Language Models (LLMs) to translate natural language questions into SQL through Retrieval-Augmented Generation (RAG), where relevant question-SQL examples are retrieved to generate new queries via few-shot learning. However, adapting this method to the medical domain is non-trivial, as effective retrieval requires examples that align with both the logical structure of the question and its referenced entities (e.g., drug names, procedure titles). Standard single-step RAG struggles to optimize both aspects simultaneously and often relies on near-exact matches to generalize effectively. This issue is especially severe in healthcare, as questions often contain noisy and inconsistent medical jargon. To address this, we present CBR-to-SQL, a framework inspired by Case-based Reasoning theory that decomposes RAG's single-step retrieval into two explicit stages: one that focuses on retrieving structurally relevant examples, and one that aligns entities with the target database schema. Evaluated on two clinical benchmarks, CBR-to-SQL achieves competitive accuracies compared to fine-tuned methods. More importantly, it demonstrates considerably higher sample efficiency and robustness than the standard RAG approach, particularly under data scarcity and retrieval perturbations.

Figures & tables

Appendix figures & tables17 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. EHR-Complex: Benchmarking Medical Agents for Complex Clinical Reasoning

    Jun 22, 2026Yitong Qiao, Lei Liu, Yue Shen +4AI Agent BenchmarksClinical Reasoning

  2. DecoSearch: Complexity-Aware Routing and Plan-Level Repair for Text-to-SQL

    Jun 16, 2026Esteban Schafir, Xu Zheng, Hojat Allah Salehi +4Schema LinkingQuestion Decomposition

  3. IESR:Efficient MCTS-Based Modular Reasoning for Text-to-SQL with Large Language Models

    Feb 5, 2026Tao Liu, Jiafan Lu, Bohan Yu +11Small Language ModelsText-to-SQL