arXiv:2603.05569cs.IRcs.AI2026-03

用案例推理提升医疗文本转SQL的准确率和鲁棒性

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

  • 分两步检索:先找结构相似案例,再对齐实体与数据库模式
  • 在少量数据下表现优于传统RAG,错误率降低37%
  • 适合医疗数据少、术语不规范的场景使用

从电子健康记录(EHR)数据库中提取洞察通常需要掌握SQL技能,对临床决策和研究构成障碍。利用大语言模型(LLM)通过检索增强生成(RAG)将自然语言问题转化为SQL是一种有前景的方法,即通过检索相关的问题-SQL示例,基于少样本学习生成新查询。然而,在医疗领域适配该方法具有挑战性,因为有效检索需同时匹配问题的逻辑结构和引用的实体(如药物名称、手术名称)。标准单步RAG难以兼顾两者,常依赖近似匹配才能泛化,这在医疗领域尤为严重,因问题中常含噪声和不一致的医学术语。为此,我们提出CBR-to-SQL,受案例推理理论启发,将RAG的单步检索分解为两个显式阶段:一是检索结构相关的示例,二是对齐实体与目标数据库模式。在两个临床基准上评估,CBR-to-SQL达到与微调方法相当的准确率。更重要的是,它在数据稀缺和检索扰动下表现出显著更高的样本效率和鲁棒性。

原文摘要 · Abstract (English)

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.

文本转SQL医疗AI案例推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。