TL;DR
The paper introduces CLINSQL, a new expert-annotated text-to-SQL benchmark designed to evaluate how well large language models (LLMs) handle complex, multi-table clinical queries involving patient-similarity cohorts. Testing 22 state-of-the-art models reveals that even top-tier systems like GPT-5-mini and DeepSeek-R1 fall short of clinical reliability, particularly when navigating intricate temporal constraints and medical coding systems.
What Problem Does This Paper Address?
While LLMs have become remarkably proficient at translating natural language into SQL queries on standard enterprise datasets, real-world electronic health records (EHRs) present a unique set of challenges. Clinical data analysis rarely consists of simple single-table lookups. Instead, clinicians frequently ask questions that require constructing patient-similarity cohorts—grouping and comparing patients who share complex clinical profiles over specific temporal windows (e.g., "the first 24 hours of an ICU stay").
Prior clinical text-to-SQL benchmarks (like MIMICSQL or EHRSQL) largely focused on single-patient lookups or basic statistical summaries. They failed to capture the multi-table joins, specialized medical terminologies (such as ICD-9/10 codes), and outcome-aware analytics that define actual clinical decision-making.
Methods
To rigorously evaluate models in this domain, the authors developed a multi-stage pipeline to construct CLINSQL:
- Scenario Design & Question Formulation: Medical experts crafted realistic clinical questions across six distinct scenario families (e.g., Vital Signs Monitoring, Lab Results Analysis, Medication Management), stratifying them by difficulty (Easy, Medium, Hard).
- Gold SQL Curation: Experts wrote highly optimized, executable BigQuery SQL queries incorporating complex multi-table joins, date-time functions, and exact clinical code mappings.
- Fine-Grained Rubric-Based Evaluation: Rather than relying solely on exact string matching or simple execution checks, the authors introduced a hierarchical, tree-structured rubric evaluation framework.
The evaluation relies on a Critical-First Score Aggregation algorithm. The rubric tree separates criteria into critical nodes (essential requirements like correct gender filtering or exact ICD code matching) and non-critical nodes (supportive formatting or style choices). If a model fails a critical node, the parent node fails automatically, preventing structurally flawed queries from receiving partial credit just because they happen to execute successfully.
Models were evaluated under both Direct Output and Chain-of-Thought (CoT) prompting regimes, supplemented by up to two rounds of execution-driven self-refinement. The authors also explored a Schema-Hinted setting, where models were pre-supplied with validated ICD filters and expected output columns to see if domain constraints could mitigate common errors.
Datasets
The benchmark introduces CLINSQL, which consists of 633 expert-annotated tasks built on top of the widely used MIMIC-IV v3.1 database. The dataset is split across three difficulty tiers: Easy (30%), Medium (40%), and Hard (30%), determined by the underlying SQL complexity and the depth of clinical reasoning required.
Key Insights and Ideas
- Execution Success $\neq$ Clinical Correctness: One of the paper's most critical findings is that a query can execute perfectly and return numbers that look plausible, yet be fundamentally wrong. An outlier study showed that 95% of cases with a large gap between SQL logic and execution scores had high execution scores but failed basic clinical logic (e.g., missing a secondary exclusion criterion).
- Cohort Specification Drift: Models frequently struggle to maintain strict cohort definitions. Instead of using exact ICD codes or specific
itemidconstraints, they often fall back on loose keyword heuristics, dangerously broadening the patient cohort and invalidating the clinical statistics. - Rubrics Provide Actionable Feedback: Traditional text-to-SQL metrics fail to capture why a clinical query is wrong. By breaking down evaluation into distinct dimensions (Patient Cohort Construction, Medical Concept Implementation, Database Integration, and Clinical Analytics), the rubric tree provides interpretable error diagnostics.
Key Results
The authors benchmarked 22 proprietary and open-source models. The key quantitative takeaways include:
- GPT-5-mini achieved the highest overall test execution score at 74.7%, followed closely by Gemini-2.5-Pro at 73.7%.
- DeepSeek-R1 led the open-source models with an execution score of 69.2%, outperforming several proprietary models including OpenAI's o4-mini and Grok-4-Fast.
- The "Hard" Split Bottleneck: Performance drops sharply on complex queries. For instance, Gemini-2.5-Pro falls from 85.5% execution accuracy on Easy tasks to just 67.2% on Hard tasks. No model broke the 70% execution barrier on the Hard split.
- Schema Hints Help: Providing explicit schema hints (validated ICD codes and target columns) yielded substantial performance gains for GPT-5-mini, pushing its medium-difficulty execution score up by over 10 percentage points (from 75.63% to 85.85%).
Limitations and Future Work
The authors note two primary limitations:
- Single-System Dependency: CLINSQL is built entirely on the MIMIC-IV database from a single health system using Google BigQuery SQL. This limits its immediate generalizability to other EHR data models (like OMOP CDM) or different SQL dialects.
- High Curation Burden: Constructing the gold-standard queries and detailed evaluation rubrics requires substantial time and effort from medical domain experts, making the benchmark difficult to scale up significantly without automated assistance.
Future work will likely focus on developing automated tools to scale clinical rubric generation and extending text-to-SQL capabilities to cross-institutional EHR schemas.
Summary updated