Query, Don’t Train: Privacy-Preserving Tabular Prediction from EHR Data via SQL Queries
Josefa Lia Stoisser *, Marc Boubnovski Martell *, Kaspar Märtens, Lawrence Phillips, Stephen Michael Town, Rory Donovan-Maiye, Julien Fauqueur · 2025
Read Query, Don’t Train: Privacy-Preserving Tabular Prediction from EHR Data via SQL Queries by Josefa Lia Stoisser *, Marc Boubnovski Martell *, Kaspar Märtens, Lawrence Phillips, Stephen Michael Town, Rory Donovan-Maiye, Julien Fauqueur (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2505-21801.txt.
Introduction
Josefa Lia Stoisser and six co-authors predict hospital returns without ever training on patient records in a 2025 paper. Privacy laws bar access to individual health data, so their method, Query Don't Train, never touches it. A language model reads a task description and the database layout, then writes database queries.
The queries return population-level statistics, and the model reasons over them to predict for a new patient. The approach needs no imputation for missing data and leaves an auditable trail of queries. On thirty-day readmission for diabetes patients, it scored slightly above a strong tabular baseline. The authors present it as the first query-only, privacy-preserving structured prediction of its kind.
Catalog record
| CREATOR | Josefa Lia Stoisser *, Marc Boubnovski Martell *, Kaspar Märtens, Lawrence Phillips, Stephen Michael Town, Rory Donovan-Maiye, Julien Fauqueur |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 12 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2505-21801
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Query, Don’t Train: Privacy-Preserving Tabular Prediction from EHR Data via SQL Queries Josefa Lia Stoisser *, Marc Boubnovski Martell *, Kaspar Märtens, Lawrence Phillips, Stephen Michael Town, Rory Donovan-Maiye, Julien Fauqueur Abstract Electronic health records (EHRs) contain richly structured, longitudinal data essential for predictive modeling, yet stringent privacy regulations (e.g., HIPAA, GDPR) often restrict access to individual-level records. We introduce Query, Don’t Train (QDT): a structured-data foundation-model interface enabling tabular inference via LLM-generated SQL over EHRs. Instead of training on or accessing individual-level examples, QDT uses a large language model (LLM) as a schema-aware query planner to generate privacy-compliant SQL queries from a natural language task description and a test-time input. The model then extracts summary-level population statistics through these SQL queries and the LLM performs, chain-of-thought reasoning over the results to make predictions. ”This inference-time–only approach (1) eliminates the need for supervised model training or direct data access, (2) ensures interpretability through symbolic, auditable queries, (3) naturally handles missing features without imputation or preprocessing, and (4) effectively manages high-dimensional numerical data to enhance analytical capabilities. We validate QDT on the task of 30-day hospital readmission prediction for Type 2 diabetes patients using a MIMIC-style EHR cohort, achieving F1 = 0.70, which outperforms TabPFN (F1 = 0.68). To our knowledge, this is the first demonstration of LLM-driven, privacy-preserving structured prediction using only schema metadata and aggregate statistics—offering a scalable, interpretable, and regulation-compliant alternative to conventional foundation-model pipelines. * Equal contribution. Listing order is random. 1 Introduction EHRs store richly structured, longitudinal data spanning diagnoses, laboratory results, procedures, medications, and outcomes—resources that are critical for predictive modeling and clinical decision support [ 8 , 11 ] . However, regulations such as the U.S. HIPAA Privacy Rule and the EU GDPR impose strict safeguards for protected health information, including consent, minimization, and access controls, with substantial legal and institutional constraints on data use [ 3 , 12 ] . These policies often prohibit direct access to patient-level records, creating significant barriers for model development, particularly in cross-institutional settings where data-sharing agreements are difficult to establish or enforce. Despite these constraints, public datasets such as MIMIC-III have enabled research in EHR-driven prediction under carefully controlled conditions, supporting tasks such as mortality forecasting, hospital readmission risk, and treatment efficacy modeling [ 7 , 10 ] . Traditional supervised models—especially tree-based methods like XGBoost—continue to dominate tabular prediction tasks due to their robustness to heterogeneous features, irregular target functions, and missing data [ 5 , 13 ] . Transformer-based in-context learners, such as TabPFN, offer classification via training-set conditioning, though they still require access to raw examples at inference time [ 6 ] . LLMs have recently demonstrated strong performance in structured reasoning tasks, including text-to-SQL translation [ 4 ] , with execution accuracy exceeding 86% on cross-domain benchmarks like Spider. These capabilities suggest a new opportunity: using LLMs not just for text generation, but for schema-aware query planning that operates under privacy constraints. SQL serves as a controlled, interpretable interface that enables LLMs to retrieve relevant aggregate statistics—without exposing individual-level data—thereby preserving compliance with HIPAA and GDPR [ 3 , 12 ] . In this work, we introduce Query, Don’t Train , a two-stage, framework for clinical tabular prediction without direct access to raw EHR data. Our approach is grounded in three pillars: • Privacy preservation , by ensuring only policy-compliant SQL queries are issued and no patient-level data is revealed. • Structured reasoning , which derives interpretability from two key sources: (1) LLM-mediated chain-of-thought predictions over query results, and (2) the symbolic, auditable queries themselves. • Robustness to missing data , as the model dynamically selects and conditions on available features at inference without imputation. We validate our approach on 30-day readmission prediction in a MIMIC-style cohort for Type 2 diabetes patients, showing that it obtains an F1-score of 0.70 while offering interpretability and compliance out of the box. Figure 1: Comparison of TabPFN and our ”Query, Don’t Train” (QDT) approach. TabPFN uses the training set directly during inference. In contrast, QDT follows: (1) receive test record and task prompt, (2) generate SQL queries, (3) enforce compliance with privacy policies, (4) execute approved queries to retrieve summary statistics, (5) predict using chain-of-thought reasoning. QDT enables privacy-preserving, interpretable inference without raw data access. 2 Methodology 2.1 Problem Formulation We consider a tabular classification task under strict access constraints. Let \mathcal{D}_{\text{train}}=\{(x_{i},y_{i})\}_{i=1}^{N} denote a training set of patient records x_{i}\in\mathbb{R}^{d} and associated outcomes y_{i}\in\mathcal{Y} . Direct access to \mathcal{D}_{\text{train}} is prohibited due to regulatory or institutional privacy restrictions. Given a test-time instance x^{\text{test}} , the goal is to predict its label y^{\text{test}} by interacting with \mathcal{D}_{\text{train}} exclusively via a privacy-compliant SQL interface that enforces data governance policies. 2.2 Framework Overview Our method adopts a two-stage architecture in which an LLM serves as both a query-generation agent and a predictor through structured reasoning. The process, illustrated in Figure 1 , proceeds as follows: 1. Input: The LLM receives (i) a natural language prompt describing the prediction task (e.g., “Predict 30-day readmission for Type 2 diabetes”), and (ii) the test-time patient record x^{\text{test}} . 2. Query Generation: Based on the prompt and x^{\text{test}} , the agent generates SQL queries targeting the database containing \mathcal{D}_{\text{train}} . These queries are designed to retrieve summary-level statistics (e.g., “average length of stay for similar patients”). 3. Privacy Filtering: Only queries that comply with predefined privacy constraints (e.g., returning aggregates over groups of at least 2 individuals) are executed. 4. Query Loop: The agent may iteratively generate follow-up queries to refine its understanding of relevant cohort-level statistics. 5. Prediction: The outputs of the executed queries are returned to the LLM, which uses chain-of-thought reasoning to produce a prediction for y^{\text{test}} . This inference-time-only framework enables structured prediction without accessing raw patient data. The agent implicitly performs dynamic feature selection by deciding which summary statistics to request during the Query Loop. 3 Experiments 3.1 Experimental Setup We use OpenAI’s o4-mini model as the LLM agent in our setup and for the LLM-only baseline. We leverage the LangChain library 1 1 1 https://python.langchain.com/api_reference/community/agent_toolkits/langchain_community.agent_toolkits.sql.toolkit.SQLDatabaseToolkit.html to implement the agent. For the privacy policies, we restricted queries via the system prompt to summary-level statistics, which are defined as data averaged over two or more patients. To ensure the queries do not access patient-level information, we have a seperate agent to ensure that only those queries requesting summary-level statistics proceed to execution. In practice, this validation would be enforced by a firewall to prevent unauthorized data access [ 9 ] . 3.2 Datasets We focus on predicting 30-day hospital readmissions for patients with Type 2 Diabetes in US hospitals [ 2 ] 2 2 2 https://www.kaggle.com/c/1056lab-diabetes-readmission-prediction/data . The dataset consists of patient records x_{i} , which include demographics, laboratory results, procedures, and prior admissions, with binary outcome labels y_{i}\in\{0,1\} . 3.3 Baselines We compare our method against three baselines: TabPFN [ 6 ] is a pre-trained transformer-based predictor trained to perform tabular classification by conditioning on the training set at inference time. It is particularly relevant as it accesses \mathcal{D}_{\text{train}} during inference, similar in spirit to our method, albeit without privacy constraints. XGBoost [ 1 ] is a widely-used gradient boosting framework for tabular data. We train XGBoost on