Source-linked AI summary

Large Language Models for Structured Clinical Data Analysis: Dual-Agent Grounding and Validation

Erfan D. Dehkalani, Seetha Shankaran, Abbot R. Laptook, C. Michael Cotten, P. Ellen Grant, Yangming Ou

arXiv:2609.34039v1cs.AI

TL;DR

CLEAR-Med addresses the challenge of grounding numerical answers to structured clinical data in the intended schema, cohort, and executed calculation. It uses an Invocation Agent to generate and execute SQL and retain the result for separate validation; the reported evaluation covers a 25-query repeated-trial benchmark, while its formal guarantee is limited to encoded properties.

  • Problem

    Clinical-table answers must follow the schema, cohort, denominator, and executed calculation, which fluent wording alone does not establish.

    Source: §1 · p. 2
  • Method

    CLEAR-Med separates SQL generation and execution from validation, retaining the executed query and database result as evidence for the draft.

    Source: §1 · p. 2
  • Results

    The described evaluation covers Invocation Agent accuracy and consistency across 25 query templates with repeated trials, alongside configuration and scalability analyses.

    Source: §1 · p. 2
  • Takeaways & Limitations

    The formal guarantee covers encoded properties, and unresolved cases can abstain rather than emit an answer that fails those checks.

    Source: §1 · p. 2

    The guarantee does not extend to clinical judgments that have not been encoded as executable checks.

    Source: §1 · p. 2

Abstract

from arXiv · show

Objective: To develop and characterize CLEAR-Med, a dual-agent framework for natural-language analysis of structured clinical data that separates SQL-based invocation from independent validation. Methods: CLEAR-Med uses one agent to translate a question into executable Structured Query Language (SQL), retain the executed query and database result, and produce a draft. Deterministic checks and a separately invoked cross-provider Validation Agent then accept the draft, request one bounded repair, or abstain. We formalized the system as a bounded selective pipeline and evaluated CLEAR-Med's configuration and scalability, and the Invocation Agent's accuracy and consistency on a 25-query development benchmark, using a harmonized 21-site neonatal hypoxic-ischemic encephalopathy table containing 532 de-identified infant records and approximately 1,300 variables. Results: CLEAR-Med completed all six nominal scalability configurations, including 500x1300. Across 25 development-benchmark queries repeated five times, the Invocation Agent answered 83 of 125 responses correctly (66.4%; query-cluster bootstrap 95% CI, 48.0-83.2%), compared with 15 of 125 (12.0%; 95% CI, 3.2-22.4%) for the ungrounded ChatGPT baseline, a paired improvement of 54.4 percentage points (95% CI, 36.8-72.0%). Conclusion: CLEAR-Med provides a general architecture for traceable analysis of structured clinical data: numerical claims remain linked to executed SQL, and unresolved cases can fail closed. The reported experiments characterize CLEAR-Med's configuration and scalability and the Invocation Agent's accuracy, while the formal analysis establishes the encoded-property guarantee of the complete control flow; a prospective full-pipeline evaluation of the validation and abstention stages is the next stage of this work.

1 Introduction

Relational clinical analysis requires answers grounded in the intended schema, cohort, denominator, and executed calculations. CLEAR-Med separates SQL invocation from validation and abstention, while its formal guarantee applies only to encoded properties.

1 Introduction

  • The HIE analysis table harmonizes two multicenter trials across 21 sites and contains 532 de-identified infant records with approximately 1,300 variables per record.The study domain combines treatment assignments, physiological measurements, imaging variables, and longitudinal outcomes.Source: §1 · p. 2
  • Exact columns, joins, filters, and aggregation operators matter because prompt-serializing the clinical table does not scale as a general query mechanism.The answer must also preserve the cohort and numerical meaning when translating between natural language, SQL, and results.Source: §1 · p. 2
  • CLEAR-Med pairs an Invocation Agent that generates and executes SQL with a separately invoked Clinical Validation Agent that checks the draft, query, and result.The system can accept the draft, request bounded repair, or abstain after checks.Source: §1 · p. 2
  • The evaluation covers CLEAR-Med configuration and scalability and Invocation Agent accuracy and consistency across 25 query templates with repeated trials.The introduction describes an oracle-scored development benchmark with task-level breakdowns.Source: §1 · p. 2
  • For a stated property, sound executable checks constrain emitted answers to satisfy it, while unresolved cases abstain.The guarantee does not extend to clinical judgments that have not been encoded as executable checks.Source: §1 · p. 2

2 Related Work

Prior biomedical language-model work spans clinical language tasks, while healthcare-agent research extends toward planning and tool use. CLEAR-Med focuses on auditable numerical answers from relational tables, retaining execution evidence for independent validation.

2 Related Work

  • Biomedical language models have been adapted for medical dialogue, consultation, multilingual question answering, and domain knowledge [10] [11] [12].Healthcare-agent research extends toward planning, tool use, and multi-agent collaboration.Source: §2 · p. 3
  • Clinical text-to-SQL work includes UniQA for electronic health-record questions [14], MedT5SQL, and Criteria2Query 3.0 for clinical-trial eligibility queries.Other work examined context-aware pharmacovigilance SQL and generalization across medical text-to-SQL datasets [17] [18].Source: §2 · p. 3
  • CLEAR-Med treats query generation as a first stage, retaining executed SQL, raw database results, and the natural-language draft for a separate validation decision.Its design combines explicit provenance, executable checks, independent review, bounded repair, and abstention for relational aggregates.Source: §2 · p. 3

3 Methods

CLEAR-Med analyzes structured disease-specific clinical data with a dual-agent workflow. Its formalization bounds repair to one attempt and sends unresolved paths to abstention under stated checker and execution assumptions.

3.1 Overview

  • CLEAR-Med is a dual-agent framework for natural-language analysis of structured disease-specific clinical data.The overview points to separate descriptions of the database, agents, and complete control flow.Source: §3.1 · pp. 3–4

3.2 Formal Dual-Agent Guarantee

  • The formalization maps each attempt’s SQL, executed result, draft, and checker outcomes to accept, repair, or abstain, with outputs r0, r1, or ⊥.It permits at most one repair; ⊥ denotes abstention.Source: §3.2 · p. 4
  • Under sound checkers, faithful database execution, and fail-closed control flow, every unresolved path terminates in abstention after at most one repair.The guarantee applies to properties encoded by the checkers.Source: §3.2 · p. 4

Appendix A.4 gives the proof and the risk–coverage definitions used in evaluation.

This section describes CLEAR-Med’s SQL-grounded workflow and database/evaluation setup, including evaluation of scalability, numerical accuracy, and repeated-run consistency; full-pipeline validation and abstention are reserved for prospective evaluation.

3.5 Clinical Validation Agent

  • CLEAR-Med combines deterministic SQL/result and clinical-consistency checks with independent accept, repair, or abstain decisions, allowing one repair before fail-closed abstention.The validator cannot author replacement numbers; a repaired query is executed and revalidated, and unresolved failures produce explicit abstention.Source: Figure 1 · p. 4, §3.5 · p. 6

3.3 Convert Excel to SQLite Database

  • 532 participant rows and approximately 1,300 variables in the Excel table were converted to SQLite; adaptation may be needed for datasets with different variable definitions.The 500 × 1300 size used later is a nominal synthetic scalability configuration, not the analysis table’s observed size.Source: §3.3 · pp. 4–5

3.4 Invocation Agent

  • The Invocation Agent uses schema-guided text-to-SQL rather than document-retrieval RAG, with the executed relational database serving as the source of numerical evidence.The approach requires no fine-tuning.Source: §3.4 · p. 6

3.6 Pseudocode for CLEAR-Med

  • The pseudocode preserves provenance through invocation and validation, emits an accepted draft as the final output, and never emits an unaccepted draft.The workflow includes one repair and fail-closed abstention.Source: §3.6 · p. 6

3.7 Evaluation Design

  • The evaluation comprised configuration screening, end-to-end scalability comparison, and a 25-question development benchmark repeated five times per condition; full-pipeline validation and abstention were reserved for prospective study.The benchmark compared Invocation Agent responses with an ungrounded ChatGPT baseline, yielding 125 responses per condition.Source: §3.7 · p. 7

3.8.1 Choosing the ChatGPT configuration

  • Configuration screening prioritized successful SQL generation over speed when the two conflicted.ChatGPT Thinking and ChatGPT Instant were compared on time-based and operational diagnostics.Source: §3.8.1 · p. 8

3.8.2 Optimizing other hyperparameters

  • Four hyperparameters—iteration limit, execution-time limit, agent type, and Top K—were varied individually, prioritizing successful SQL generation and execution, then fewer errors and lower execution cost.SQL length and complexity were descriptive diagnostics.Source: §3.8.2 · p. 8

3.9.1 Language-Model Comparators and Interface

  • Five biomedical, medical-dialogue, and general-purpose models were compared end to end against CLEAR-Med, which used SQLite with schema-guided SQL tools while comparators processed serialized tables in context.All systems used the same six nominal table sizes, five-minute timeout, and success definition.Source: §3.9.1 · p. 8

3.9.2 Scalability Metric

  • A scalability configuration counted as successful only if it completed within 300 seconds without GPU out-of-memory failure; reporting included completion percentage, largest successful cell count, and elapsed time.The measures covered six configurations.Source: §3.9.2 · p. 9

3.9.3 Accuracy and Consistency Metrics

  • For nonzero deterministic oracles, accuracy metrics were signed relative error, mean absolute error over defined predictions, and the percentage of attempts within 5% of the oracle.Oracle-zero outputs were excluded from Err; missing and nonnumeric outputs were also excluded from Err but counted as failures for GT5%.Source: §3.9.3 · p. 9
  • Repeated-run consistency was summarized by the within-query range and standard deviation of signed relative error, averaged across queries with at least two defined predictions.Source: §3.9.3 · p. 9

4 Results

The Invocation Agent outperformed the ungrounded ChatGPT baseline on the 25-query benchmark, and CLEAR-Med completed all six tested scalability configurations. Configuration screens selected the operating settings used for those evaluations.

4.1.1 Choosing the ChatGPT configuration

  • ChatGPT Thinking took 167.44 s versus 29.23 s for ChatGPT Instant, but produced usable SQL while Instant returned no valid SQL.Both made two database invocations; Thinking completed without errors, while Instant produced three errors and hit the iteration limit.Source: §4.1.1 · p. 9

4.1.2 Setting up other key hyperparameters

  • The reported configuration selected openai-tools for lower execution cost and a 60 s maximum execution time because only that tested limit reached a database invocation.Errors remained constant at three per run across the tested time limits.Source: §4.1.2 · p. 10
  • The reported configuration retained Top K = 10 and Max Iterations = 50; at Top K = 10, 50 iterations was fastest (134.19 s), used one database invocation, and retained high complexity.Source: §4.1.2 · pp. 9–10

4.2.1 Scalability

  • CLEAR-Med completed six of six fixed scalability configurations, versus four of six or one of six for the comparison models.It processed the nominal 500 × 1300 table; the largest-table run used approximately 19.71 GB of 39.56 GB GPU memory and took 28 s.Source: Table 2 · p. 10, §4.2.1 · p. 10

4.3 CLEAR-Med Development-Benchmark Results

  • 39 of 60 Invocation Agent responses were within 5% of the oracle on percentage-valued queries, versus 4 of 60 baseline responses.These 60 responses covered 12 percentage-valued queries; Table 3 reports accuracy and consistency across five repetitions.Source: Table 3 · p. 11, §4.3 · p. 11
  • 66.4% of Invocation Agent responses were correct versus 12.0% for the ungrounded ChatGPT baseline, a paired improvement of 54.4 percentage points.The benchmark included 25 queries repeated five times; overall accuracy was reported with query-cluster bootstrap confidence intervals.Source: Table 4 · p. 11, §4.3 · p. 11

5 Discussion

The discussion interprets the benchmark and scalability results as evidence for a traceable, selective workflow for retrospective structured-data analysis. It distinguishes that demonstrated scope from both related approaches and the study’s limitations.

5.1 Principal Findings and Interpretation

  • The 25-query development benchmark yielded 66.4% Invocation Agent accuracy against 12.0% for the ungrounded ChatGPT baseline, while CLEAR-Med completed all six nominal scalability configurations.The accuracy comparison reflects the full invocation configuration, including database access, schema guidance, and prompt design.Source: §5.1 · pp. 11–12

5.2 Comparison with Related Approaches

  • CLEAR-Med extends clinical text-to-SQL into a selective evidence pipeline with distinct operations, explicit terminal decisions, and bounded repair after independent validation.Its architectural claim is not that a second model replaces a database oracle, but that an independently invoked validator can review the complete evidence record after deterministic checks.Source: §5.2 · p. 12

5.3 Applicability

  • The demonstrated use case is retrospective research analysis of a harmonized neonatal HIE schema; other governed relational datasets require replacement of schema guidance, constraint cards, and oracles.Transfer calls for dataset-specific validation.Source: §5.3 · p. 12

5.4 Limitations

  • The study is limited to one harmonized HIE schema, sequential configuration screening, and a 25-query development benchmark whose errors informed prompt and oracle corrections.The conditional guarantee covers only properties represented by sound executable checkers under faithful database execution; open-ended clinical reasoning, individualized prognosis, and schema transfer remain outside demonstrated scope.Source: §5.4 · p. 12

6 Conclusion

CLEAR-Med links structured clinical questions to SQL-backed numerical answers through a dual-agent framework. Component studies show scalability and stronger oracle-scored development-query accuracy than an ungrounded baseline, while full-pipeline evaluation remains future work.

  • CLEAR-Med combines SQL provenance, deterministic checks, independent validation, bounded repair, and explicit abstention in a dual-agent framework for structured clinical data.Source: §6 · p. 13
  • The SQL interface scaled to the full nominal HIE table, and the Invocation Agent substantially outperformed an ungrounded ChatGPT baseline on oracle-scored development queries.Source: §6 · p. 13
  • Held-out testing and full-pipeline evaluation of validation and abstention remain the next stage of this work.Source: §6 · p. 13
  • Acceptance contingent on an inspectable evidence record defines a route to auditable numerical answers in governed relational data.Source: §6 · p. 13

A.1 System and Dataset Summary

The system and dataset summary describes a natural-language interface to a harmonized neonatal HIE dataset, with independent validation and retained run identifiers. Reported measures cover configuration, scalability, accuracy, and consistency.

  • The intended use is research and educational analysis of structured neonatal HIE trial data through natural-language questions.Source: §A.1 · p. 13
  • ChatGPT Thinking handles invocation and Claude provides independent validation; the system uses no fine-tuning and retains requested and returned identifiers and access timestamps per run.Source: §A.1 · p. 13
  • The de-identified harmonized database combines the Optimizing Cooling and Late Hypothermia trials across 21 sites, with variables defined by established NRN protocols.Access is restricted.Source: §A.1 · p. 13
  • Reported measures include configuration diagnostics, scalability success, numerical accuracy, oracle error, repeated-run dispersion, and task- and difficulty-stratified accuracy.Source: §A.1 · p. 13
  • Unresolved or malformed cases abstain after at most one repair, and accepted numbers retain SQL provenance and pass deterministic and independent validation.Source: §A.1 · p. 13

A.3 Illustrative SQL Examples

The appendix illustrates SQLite-based clinical queries and formalizes CLEAR-Med as a bounded selective pipeline. Its analysis proves validity for properties covered by sound executable checks and defines quantities for prospective full-pipeline evaluation.

A.3 Illustrative SQL Examples

  • SQLite examples use grouped SQL to summarize cognitive, language, and motor scores by HIE severity, an analysis described as cumbersome in Excel.Source: §A.3 · pp. 13, 16
  • SQLite is described as able to manage millions of records, with an example query aggregating HIE clinical measures across time points where Excel may struggle.Source: §A.3 · p. 16

A.4 Formal Analysis of the Dual-Agent Selective Pipeline

  • The appendix formalizes the bounded selective pipeline, defines endpoints for prospective full-pipeline evaluation, and limits its guarantee to sound executable checks.Source: §A.4 · p. 16

A.4.1 State and Transition Semantics

  • The pipeline tracks the question, generated SQL, executed result, draft, and repair history; a separate cross-provider validator may accept, repair, or abstain.Source: §A.4.1 · pp. 16–17

A.4.2 Proof of the Encoded-Validity Guarantee

  • Every emitted response satisfies the encoded properties, giving zero probability of an encoded-property violation for any admissible question.The guarantee depends on deterministic checks being sound and applies only to represented properties.Source: §A.4 · p. 16, §A.4.2 · p. 17

A.4.3 Selective Evaluation Quantities

  • Selective evaluation defines coverage, incorrect-emission risk, accepted-output accuracy, and paired changes using resampling that preserves repeated trials from each question template.Source: §A.4.3 · pp. 17–18

A.4.4 Dependence-Aware Residual Risk

  • Residual incorrect-acceptance risk is decomposed across no-repair and repair branches without assuming independence between agents.For errors caught by a sound checker, the deterministic-pass factor is zero; the bound does not extend to unencoded clinical judgments.Source: §A.4.4 · p. 18

A.4.5 Conditional Predictive Uncertainty

  • Conditional predictive uncertainty separates model-induced variability from irreducible clinical outcome uncertainty; the control flow checks executable properties and routes unresolved cases to abstention.Source: §A.4.5 · p. 18
Loading 2609.34039v1…