Manuscript Offprint
arXiv:2611.01409RAG-TRACE: Tracing Measurement Evidence and Diagnostic Completeness in AI-Generated ECG Reports
Abstract
Purpose: Retrieval-augmented generation (RAG) can introduce electrocardiogram (ECG) criteria that lack patient-specific measurement support. This study evaluates the reliability of retrieved diagnostic criteria in AI-generated ECG reports. Methods: We analyzed 1,083 human-validated PTB-XL patient records using a library of 47 criteria cards, including 33 without numeric verification rules. Language models generated structured reports with and without retrieval. Criterion applicability was evaluated using Marquette 12SL measurements, with independent assessment using Uni-G and comparison against expert-validated diagnostic labels. Results: Keyword retrieval introduced untestable or measurement-disconfirmed criteria in 46.8% of GPT-4.1-mini reports. A deterministic verification rule withdrew 647 criterion applications, including 639 without numeric checks, while preserving 268 of 269 applications independently supported by Uni-G. Restricting retrieval to 14 testable criteria reduced the initial unsupported-criterion rate to 13.8%. Under matched instructions and an identical output schema, retrieval increased unsupported-criterion reports from 17.4% to 31.1%, while hypertrophy recall remained unchanged at 62.6%. Conclusion: These findings identify a fundamental limitation of retrieval-based clinical report generation: retrieved criteria do not necessarily provide valid patient-specific evidence. Measurement-based verification can reduce unsupported criterion applications, but diagnostic validity requires independent assessment.
Keywords: electrocardiogram, language models, retrieval, measurement criteria, calibration, PTB-XL
1 Introduction
The 12-lead electrocardiogram (ECG) is an essential diagnostic tool for assessing cardiac activity through measurable intervals, axes, and voltages [1, 2]. Large datasets such as PTB-XL, comprising 21,799 recordings from 18,869 patients [3], have advanced automated ECG interpretation [4]. Deep learning models have achieved strong performance in detecting cardiac abnormalities [5–8] and supporting cardiovascular screening [9, 10]. Nevertheless, generating reliable clinical reports requires more than diagnostic predictions. Each reported finding must be supported by patient-specific evidence.
Large language models (LLMs) have demonstrated considerable potential for generating clinical narratives [11] and diagnostic explanations [12, 13]. Their outputs can contain unsupported statements and inaccurate evidence attribution [14, 15]. Retrieval-augmented generation (RAG) incorporates external knowledge to improve factual grounding [16–18], with promising applications in medical question answering [19, 20] and clinical information extraction [21]. Recent studies have investigated evidence alignment in clinical question answering [22] and query-level reliability in retriever upgrades [23]. These advances highlight the importance of evidence quality, but the reliability of retrieved criteria in ECG report generation remains insufficiently examined.
ECG interpretation depends on standardized criteria, including QRS duration, Sokolow–Lyon voltage, and corrected QT intervals [24–31]. Clinical guidelines establish measurable thresholds and diagnostic definitions [2, 32, 33]. A retrieved criterion may be clinically relevant without being satisfied by the patient's measurements. Other retrieved information, such as calibration settings or laboratory values, may lack a corresponding ECG measurement. These limitations create a critical gap between retrieval relevance and verifiable diagnostic evidence.
This study presents RAG-TRACE, a measurement-based framework for evaluating retrieved criteria in AI-generated ECG reports. We analyze 1,083 held-out PTB-XL patients using 47 criteria cards, including 14 with numeric checks and 33 without measurable verification rules. Structured reports are generated with and without retrieval. A deterministic rule evaluates applied criteria against Marquette 12SL measurements, while Uni-G provides independent assessment. Diagnostic agreement and completeness are evaluated separately against expert-validated labels. Additional experiments assess retrieval constraints, controlled generation settings, and generalizability to other physiological recordings. The evaluation distinguishes criterion applicability, independent measurement agreement, and diagnostic accuracy, following established reporting principles [34, 35]. Our objective is to determine whether retrieved clinical criteria provide verifiable patient-specific evidence and whether deterministic verification reduces unsupported applications without altering diagnostic conclusions.
2.1 Data, Measurements, and Diagnostic Probabilities
PTB-XL version 1.0.3 comprises 21,799 ECG recordings from 18,869 patients [3]. The diagnostic cohort includes 21,375 recordings from 18,610 patients, annotated across five superclasses: normal, myocardial infarction, ST/T change, conduction disturbance, and hypertrophy. Patient-disjoint folds 1–8, 9, and 10 were assigned to training, calibration, and testing, respectively. Sex was encoded as 0 for male and 1 for female. All calibration and test records contained human-validated diagnostic labels, which served as the reference standard without additional clinical adjudication.
ECG measurements were obtained from PTB-XL+ version 1.0.1 [36]. Marquette 12SL provided the primary measurements for criterion verification, with Uni-G serving as an independent reference. The 12SL-based verification used Uni-G exclusively for subsequent assessment, while the agreement-based configuration required concordant support from both algorithms. ECGDeli was included in measurement agreement analyses. All measurements were derived from published feature tables, without additional signal delineation or model training.
Diagnostic probabilities for the five superclasses were estimated using one-versus-rest histogram gradient-boosting classifiers trained with inverse-frequency weighting, a learning rate of 0.08, a maximum of 31 leaves, and 120 iterations with early stopping. Class-specific isotonic calibration was performed on fold 9 [37], followed by evaluation on the held-out fold 10. Diagnostic assertions with calibrated probabilities below 0.5 were classified as low-probability, solely for analytical purposes.
2.2 Criteria cards and retrieval
The criteria library comprised 47 cards, including eight established measurement thresholds, six opposing numeric checks, and 33 cards without numeric verification rules. The original numeric cards use simplified measurement predicates taken from established ECG standards [24–26, 29–32]. Meeting one predicate is not a clinical diagnosis. Table 1 summarizes the library.
Following construction of the criteria library, three retrieval strategies were evaluated: keyword overlap, term frequency-inverse document frequency (TF-IDF), and Okapi BM25. Retrieval queries were constructed from the names of diagnostic superclasses with calibrated probabilities , without access to held-out diagnostic labels. For keyword retrieval, the relevance score between query and criterion card was defined as
where and denote their respective token sets. Ties were resolved using card identifiers. TF-IDF and BM25 operated on the same queries and criterion descriptions, with BM25 parameters and . Each strategy retrieved the three highest-ranked cards. BM25 was evaluated using saved queries without generating additional reports, and biomedical embedding-based retrieval was not
Table 1 Composition of the ECG criteria library. Each numeric threshold is an operational predicate used for verification. It is not sufficient, by itself, for a clinical diagnosis.
| Criterion | Threshold or description | Cards |
|---|---|---|
| Original numeric criteria | ||
| QRS duration | ≥ 120 ms | 1 |
| PR interval | ≥ 200 ms | 1 |
| QRS axis | ≤ −30° | 1 |
| Sokolow–Lyon voltage | ≥ 3.5 mV | 1 |
| Bazett QTc | ≥ 450 ms (men); ≥ 460 ms (women) | 1 |
| ST deviation (lead II) | ≤ −0.1 mV | 1 |
| Q-wave duration | ≥ 40 ms (II, III, aVF, or V1–V4) | 1 |
| Heart rate | ≥ 100 bpm | 1 |
| Opposing numeric checks | Six complementary measurement predicates | 6 |
| Cards without numeric checks | Calibration pulse, paper speed, notch filter, pediatric QRS limit, lead reversal, age, troponin, wall thickness, potassium, and digoxin | 33 |
| Total | 47 | |
included. Figure 1 illustrates the overall RAG-TRACE pipeline, from dataset preparation and criteria library construction to evidence retrieval and structured ECG report generation.

Fig. 1 Overview of the RAG-TRACE framework, showing dataset preparation, ECG criteria library construction, evidence retrieval strategies, and structured inputs for language model-based ECG report generation.
2.3 Report Generation and Verification
Structured ECG reports were generated under three conditions: no retrieval, keyword retrieval, and TF-IDF retrieval. GPT-4.1-mini was evaluated at temperature 0, with diagnostic claims restricted to calibrated probabilities ≥ 0.5. Reports were assessed for diagnostic affirmation using predefined linguistic cues and an exploratory label-aware approach.
RAG-TRACE applied deterministic verification to retrieved criteria using Marquette 12SL measurements. Criteria without measurable support were withdrawn, while diagnostic statements remained unchanged. Uni-G provided independent assessment, with an additional configuration requiring agreement between both measurement algorithms. The verification process is illustrated in Figure 2.

Fig. 2 RAG-TRACE framework for ECG report generation and measurement-based verification using Marquette 12SL and Uni-G.
The evaluation included 1,083 held-out patients, with one ECG per patient. Diagnostic superclass distributions are presented in Figure 3. Statistical comparisons used 10,000 patient-level bootstrap resamples and exact McNemar tests for paired outcomes.
2.4 Evaluation Metrics
Three complementary metrics were used to assess criterion applicability, independent measurement agreement, and diagnostic consistency with expert-validated labels. For record , let denote the set of applied criteria, the corresponding measurements, and the numeric verification rule associated with criterion . The predicates and represent Marquette 12SL and Uni-G evaluations, respectively. Let denote the reference diagnostic superclasses and the affirmed superclasses extracted from the generated report. The record-level indicators were defined as

Fig. 3 Distribution of diagnostic superclass combinations among 1,083 PTB-XL patients. Bars represent combination frequencies, with normal-only recordings forming the largest group (n = 483).
The corresponding rates were calculated as the mean of each indicator across records. The release score () identifies untestable or measurement-disconfirmed criterion applications. Deterministic 12SL withdrawal sets this score to zero by construction, while the Uni-G score () provides an independent assessment. The agreement-based configuration requires both measurement predicates to hold and consequently sets by construction. Withdrawals were categorized by missing numeric checks or failed 12SL predicates, with the latter further classified according to Uni-G agreement. Low-probability diagnostic assertions, defined by calibrated probabilities below 0.5, were evaluated separately. The earlier combined rate represents their union with release-score violations.
Diagnostic consistency () identifies reports affirming at least one superclass absent from the reference labels. Affirmed diagnoses were extracted using the prespecified cue-based rule and, separately, the exploratory label-aware approach. Since verification modifies only criterion applications, diagnostic consistency remains unchanged after withdrawal. An additional statement-level metric assessed discrepancies between the original eight criteria and their linked cardiologist statement codes, including unsupported applications and omitted findings.
Diagnostic agreement was quantified using micro-averaged precision, recall, and F1 across the five superclasses. Class-specific recall was calculated among patients with the corresponding reference diagnosis, while patient-level recall measured the proportion of reference superclasses identified in each report. Paired effects were expressed as , comparing keyword retrieval with no retrieval on the same patients. Confidence intervals were obtained from 10,000 patient-level bootstrap resamples using the 2.5th and 97.5th percentiles.
2.5 Additional Experiments and Model Evaluation
Additional experiments assessed retrieval constraints, model variability, and robustness. Retrieval was restricted to 14 verifiable criteria, with a separate configuration requiring valid card identifiers. Two GPT-4.1 mini comparisons involving 1,083 patients used fixed instructions with identical or different output schemas to distinguish retrieval effects from schema-dependent diagnostic scores (Figure 1).
Evaluation included Qwen3-8B and Qwen3-14B [38], Gemma 3 12B, MedGemma 4B, DeepSeek-R1-Distill-Llama-8B [39], and Llama 3.1 8B Instruct [40]. Models used greedy decoding and a 1,200-token limit. Paired sample sizes were 1,082, 1,083, 1,083, 850, 112, and 4, respectively; Llama was excluded from rate comparisons. GLM-5.3-Flash was evaluated separately on 1,083 patients per arm.
3 Results
3.1 Diagnostic Baseline
The calibrated superclass classifier was evaluated on 2,157 held-out ECGs. Macro AUROC, AUPRC, and F1 were 0.935, 0.816, and 0.751, respectively (Table 2). Isotonic calibration reduced macro expected calibration error from 0.062 to 0.020 [41, 42]. Selective Hamming loss decreased from 0.106 at full coverage to 0.081 at 80% coverage and 0.047 at 50% coverage [43, 44].
Table 2 Calibrated superclass model on the PTB-XL test fold (n = 2,157).
| Class | AUROC | AUPRC | F1 |
|---|---|---|---|
| Normal | 0.949 | 0.923 | 0.865 |
| Myocardial infarction | 0.940 | 0.839 | 0.745 |
| ST/T change | 0.934 | 0.793 | 0.750 |
| Conduction disturbance | 0.931 | 0.847 | 0.765 |
| Hypertrophy | 0.918 | 0.680 | 0.633 |
| Macro average | 0.935 | 0.816 | 0.751 |
3.2 Effects of Criterion Retrieval
All 1,083 GPT-4.1-mini patients and 1,082 Qwen3-8B patients had parseable reports across the three retrieval conditions. For GPT-4.1-mini, the prespecified cue-based expert-absent diagnosis rate increased from 7.5% without retrieval to 10.1% with keyword retrieval (paired difference 0.026, 95% CI 0.006–0.045; McNemar p = 0.008). TF-IDF produced a rate of 11.0%. This cue-based metric misses some affirmative statements, as examined in Section 3.8.
Keyword retrieval produced untestable or 12SL-disconfirmed criterion applications in 46.8% of GPT-4.1-mini reports. Each report contained an average of 0.891 applied criteria: 0.590 lacked numeric checks, 0.007 failed 12SL predicates, and 0.294 were supported. The release score became zero after deterministic withdrawal by definition; independent Uni-G and expert-label results remained separate (Table 3). At least one top-three card lacked a numeric check in 81.4% of keyword queries, 79.8% of BM25 queries, and 73.6% of TF-IDF queries.
Table 3 Keyword retrieval and the same note after the 12SL withdrawal. Expert diagnosis absent: an affirmed superclass is missing from the PTB-XL label. Uni-G rejects: an applied criterion fails the second algorithm. Release: an applied card has no check, or the 12SL predicate is false. The last row is a mean count, not a record rate.
| gpt-4.1-mini | Qwen3-8B | |||
|---|---|---|---|---|
| Keyword | After 12SL | Keyword | After 12SL | |
| Expert diagnosis absent | 0.101 | 0.101 | 0.051 | 0.051 |
| Uni-G rejects a criterion | 0.053 | 0.046 | 0.208 | 0.047 |
| Release score | 0.468 | 0 | 0.654 | 0 |
| Mean 12SL-supported criteria kept | 0.294 | 0.294 | 0.306 | 0.306 |
3.3 Independent Verification
Following 12SL withdrawal, Uni-G rejection decreased from 5.3% to 4.6% for GPT-4.1-mini and from 20.8% to 4.7% for Qwen3-8B. Of 647 GPT-4.1 mini withdrawals, 639 involved unchecked cards and eight involved failed numeric predicates. Uni-G independently rejected seven of those eight predicates. For Qwen3-8B, the corresponding counts were 880 unchecked applications and 211 failed predicates, of which Uni-G rejected 203. Verification retained 268 of 269 Uni-G-supported applications for GPT-4.1 mini and 274 of 282 for Qwen3-8B (Table 4). Uni-G was not an input to the 12SL withdrawal rule.
Table 4 Keyword-note applications judged by Uni-G. Uni-G was not an input to the 12SL edit. The second row is the subset of the failed 12SL predicates that Uni-G also rejected. The unchecked row is separate.
| gpt-4.1-mini | Qwen3-8B | |
|---|---|---|
| Uni-G supports, and the edit keeps | 268/269 | 274/282 |
| 12SL false, and Uni-G rejects | 7/8 | 203/211 |
| No numeric check, withdrawn | 639/639 | 880/880 |
| 12SL predicate false, withdrawn | 8/8 | 211/211 |
3.4 Agreement With Expert Statement Codes
For the eight criteria linked to cardiologist statement codes, keyword retrieval increased statement mismatch from 7.5% to 24.9% for GPT-4.1 mini and from 1.6% to 34.1% for Qwen3-8B. The two-algorithm agreement rule reduced these rates to 22.2% and 19.6%, respectively, without a substantial increase in unstated linked findings (Table 5). Among retained applications, the linked code was present in 27.5% of 204 GPT-4.1 mini applications and 12.8% of 218 Qwen3-8B applications. Numeric support and diagnostic-label agreement therefore remained distinct.
Table 5 Statement mismatch against stored cardiologist codes for the original eight checks, and the mean number of those findings left unstated.
| Note | gpt-4.1-mini | Qwen3-8B | ||
|---|---|---|---|---|
| Mismatch | Unstated | Mismatch | Unstated | |
| No retrieval | 0.075 | 0.344 | 0.016 | 0.344 |
| Keyword retrieval | 0.249 | 0.289 | 0.341 | 0.311 |
| 12SL withdrawal | 0.246 | 0.289 | 0.228 | 0.314 |
| Both algorithms | 0.222 | 0.293 | 0.196 | 0.318 |
3.5 Controlled Retrieval Experiments
Removing the 33 cards without numeric checks reduced the GPT-4.1 mini release score from 46.8% to 13.8% (Table 6). With the 14-card library, requiring a retrieved-card identifier further reduced the release score to 3.0%. In the identical-schema experiment, both arms used the same instructions and could generate criterion claims; only the keyword arm received retrieved cards. The release score increased from 17.4% without cards to 31.1% with cards (Table 6). Hypertrophy recall was identical in both arms at 0.626 (67 of 107 patients).
3.6 Model Completion
Llama 3.1 8B Instruct completed all three reports for only four patients and was excluded from rate comparisons. DeepSeek-R1-Distill-Llama-8B contributed 112 complete paired records in the final analysis. An earlier parse contained 116 paired records; its previously reported combined rates were not recomputed on the final subset. These selected samples do not establish full-cohort replication.
3.7 Waveform and Specificity Controls
The four-head waveform network achieved macro AUROC of 0.981 on the PTB-XL test fold. On 200 MIMIC-IV-ECG studies, AUROC was 0.962 for wide QRS, 0.957 for long PR, 0.943 for left-axis deviation, and 0.998 for tachycardia. In EEG and sleep-recording specificity controls, the withdrawal rule addressed criterion-related errors without correcting unrelated errors.
Table 6 Controlled retrieval on the same 1,083 patients. The upper block uses the 14 cards that have a numeric check, and its control column is the original note. The lower block is the identical-schema comparison on the full library. Both arms use one instruction and one JSON schema, and both may emit a criterion claim. Only the keyword arm receives retrieved cards.
| Control | Keyword | After 12SL | |
|---|---|---|---|
| 14 numeric cards | |||
| Expert diagnosis absent | 0.075 | 0.098 | 0.098 |
| Uni-G rejects a criterion | 0 | 0.079 | 0.055 |
| Release score | 0 | 0.138 | 0 |
| Mean 12SL-supported criteria kept | 0 | 0.386 | 0.386 |
| Identical schema, full library | |||
| Expert diagnosis absent | 0.076 | 0.106 | 0.106 |
| Uni-G rejects a criterion | 0 | 0.059 | 0.043 |
| Release score | 0.174 | 0.311 | 0 |
| Mean 12SL-supported criteria kept | 0 | 0.299 | 0.299 |
3.8 Exploratory Diagnostic Agreement
The prespecified cue list recognized only 3 of 15 audited ordinary diagnosis sentences and omitted 846 of 1,360 keyword-note diagnosis sentences. An exploratory label-aware rule was therefore evaluated separately. In a 1,000-sentence audit, two language-model judges agreed on 862 sentences. Against their shared labels, the label-aware rule achieved micro-F1 of 0.932, compared with 0.435 for the cue list. Under the label-aware rule, GPT-4.1 mini expert-absent diagnosis rates increased from 19.8% without cards to 23.0% with keyword cards (95% CI for the difference: 0.016–0.049). In the matched-prompt comparison, rates were 21.2% and 22.1%, with a confidence interval including zero. Effects differed across models: Qwen3-14B and MedGemma 4B showed lower expert-absent rates with retrieval, Gemma 3 12B showed a higher rate, and Qwen3-8B showed little change (Table 7). Figures 4, 5, and 6 summarize class recall, diagnostic precision, micro-F1, and expert-absent diagnosis rates across the saved original-prompt comparisons.
Table 7 Exploratory label-aware expert-absent rates. A counted diagnosis is a saved superclass label that the sentence does not negate. The no-card column for the numeric-only and constrained arms is the original no-card note, joined by electrocardiogram identifier. Intervals are 95% bootstrap confidence intervals.
| Arm | n | No cards | Keyword | Difference |
|---|---|---|---|---|
| gpt-4.1-mini, full library | 1,083 | 0.198 | 0.230 | 0.032 (0.016, 0.049) |
| gpt-4.1-mini, 14 numeric cards | 1,083 | 0.198 | 0.252 | 0.054 (0.038, 0.072) |
| gpt-4.1-mini, matched prompt | 1,083 | 0.212 | 0.221 | 0.008 (-0.001, 0.018) |
| gpt-4.1-mini, constrained identifier | 1,083 | 0.198 | 0.140 | -0.057 (-0.077, -0.038) |
| Qwen3-8B | 1,082 | 0.217 | 0.218 | 0.001 (-0.009, 0.011) |
| Qwen3-14B | 1,083 | 0.227 | 0.178 | -0.049 (-0.062, -0.037) |
| Gemma 3 12B | 1,083 | 0.173 | 0.198 | 0.025 (0.015, 0.036) |
| MedGemma 4B | 850 | 0.285 | 0.253 | -0.032 (-0.055, -0.007) |
| DeepSeek-R1 8B | 112 | 0.188 | 0.214 | 0.027 (-0.018, 0.071) |


Fig. 4 Diagnosis agreement for the same models. A, class recall with no retrieval. B, class recall with keyword retrieval. C, notes with a false diagnosis. D, micro-F1. In C and D, blue is no retrieval and green is keyword retrieval. Sample sizes are 1,083 except Qwen3-8B (1,082), MedGemma (850), and DeepSeek (112). DeepSeek is a selected subset.

Fig. 5 Precision, recall, micro-F1, and false-diagnosis notes for the six models with a full paired sample. A, no retrieval. B, keyword retrieval. Cell values are percentages. Blue darkens as precision, recall, and F1 rise. Red darkens as the false-diagnosis rate rises. The row label gives the number of patients. MedGemma is the 850 patients with all three notes. DeepSeek is omitted.

Fig. 6 The same four measures for those six models. Each axis rises when agreement improves. The fourth axis is the percentage of notes with no false diagnosis. The radial scale starts at 55. A, no retrieval. B, keyword retrieval. MedGemma is the 850 patients with all three notes.
3.9 Schema Effects on Diagnostic Agreement
A separate different-schema comparison used the same instructions but allowed criterion claims only when retrieved cards were present. Micro-F1 decreased from 0.804 to 0.795 (difference -0.009, 95% CI -0.014 to -0.004), while scored hypertrophy recall decreased from 0.617 to 0.514 (Table 8). The expert-absent diagnosis rate changed from 17.5% to 16.7% (p = 0.077). Of 11 scored hypertrophy losses, six no-card credits involved a stored HYP label attached to hypertension wording. Other discrepancies involved denied voltage criteria, qualified diagnoses, or endorsements outside diagnosis claims. These scores do not represent 11 clinically missed diagnoses. The identical-schema comparison showed unchanged hypertrophy recall. An earlier identifier-constrained comparison joined against a different no-card prompt showed a larger recall decline (0.772 to 0.546), which cannot be attributed solely to retrieval. Figure 7 presents paired micro-F1 changes across models. All diagnosis comparisons use stored PTB-XL codes, not newly adjudicated clinician interpretations.
Table 8 Different-schema diagnosis agreement for gpt-4.1-mini, n = 1,083. Both arms use one instruction. The schema admits a criterion claim only when retrieved cards are present. The identical-schema comparison is Table 6. Precision, recall, and F1 are micro averages against the stored PTB-XL superclass codes. A false-diagnosis note affirms at least one superclass that is absent from that code.
| Arm | Precision | Recall | F1 | False-diagnosis notes | Omissions |
|---|---|---|---|---|---|
| No cards | 0.841 | 0.770 | 0.804 | 0.175 | 312 |
| 14-card constraint | 0.844 | 0.752 | 0.795 | 0.167 | 337 |
| Model | Difference (95% CI) | Diagnosis agreement |
|---|---|---|
| MedGemma 4B | -8.4 (-10.6, -6.2) | |
| GLM-5.3-Flash | -1.5 (-2.4, -0.6) | |
| gpt-4.1-mini | -0.8 (-1.8, +0.3) | |
| Qwen3-8B | -0.2 (-0.8, +0.3) | |
| Qwen3-14B | +0.3 (-0.2, +0.9) | |
| Gemma 3 12B | +7.3 (+6.0, +8.7) |

Fig. 7 Diagnosis micro-F1 change under keyword retrieval. Each row is keyword minus no retrieval on the same patients. The dot is the estimate, the line is the 95% bootstrap interval, and the gray shape is the bootstrap distribution. The interval uses 10,000 patient resamples. MedGemma is the 904 patients who have both notes. The three-note table uses 850.
An exploratory classification of 965 GPT-4.1 mini keyword applications identified 639 without a numeric check, 174 supported, 150 indeterminate, and two refuted. Among the original eight linked checks, the corresponding cardiologist code was present for 34.8% of 132 supported applications and 12.0% of 117 indeterminate applications.
4 Discussion
Retrieval-augmented ECG reporting exposes a gap between clinical relevance and patient-specific evidence. Keyword retrieval introduced untestable or measurement-disconfirmed criteria in 46.8% of GPT-4.1 mini reports, with 639 of 647 withdrawn applications lacking numeric checks. Qwen3-8B exhibited a distinct failure pattern, with 203 of 211 measurement-disconfirmed applications independently rejected by Uni-G. The differences highlight two sources of unreliable reporting: unverifiable retrieved content and incorrect application of measurable criteria. The deliberately constructed criteria library increased exposure to these failures, limiting generalization to routine clinical practice. RAG-TRACE complements research on retrieval robustness, medical citation reliability, and multi-step clinical reasoning [45-47] by assessing retrieved evidence against patient-specific measurements. Verification preserved 268 of 269 independently supported GPT-4.1 mini applications and 274 of 282 Qwen3-8B applications. This selective withdrawal offers that unsupported criteria can be removed with limited loss of measurement-supported claims. The zero release score reflects the deterministic rule itself, making independent measurement agreement essential for assessing verification performance.
Controlled comparisons further distinguish retrieval effects from changes in diagnostic scoring. Under identical instructions and output schemas, unsupported-criterion reports increased from 17.4% to 31.1%, while hypertrophy recall remained at 62.6%. The different-schema comparison showed a modest decrease in micro-F1 (0.804 to 0.795) and scored hypertrophy recall (0.617 to 0.514). Six of the 11 apparent hypertrophy losses involved hypertension statements assigned hypertrophy labels. Such discrepancies illustrate how output structure and scoring definitions can influence apparent diagnostic performance.
For clinical RAG systems, evidence retrieval and criterion verification serve distinct purposes. A clinically relevant criterion requires measurable patient support before its application can be justified. Deterministic verification can address unsupported criterion claims without modifying diagnostic statements. Measurement agreement, diagnostic completeness, and clinical validity must therefore be assessed independently.
5 Limitations
The evaluation relied on published PTB-XL diagnostic labels without independent clinical review of generated reports. The prespecified affirmation rule undercounted diagnostic assertions, while the exploratory label-aware analysis excluded 138 sentences with disagreement between judges. Model comparisons were constrained by incomplete JSON generation for Llama, 112 paired DeepSeek cases, and the use of a single closed model for numeric-only retrieval. The identical-schema and different-schema comparisons addressed distinct experimental conditions. BM25 was evaluated without report generation, and TF-IDF did not incorporate biomedical embeddings. The reported cue-list contrast was significant (); the other comparisons were exploratory. The absence of prospective clinical evaluation limits conclusions about diagnostic safety and real-world applicability.
6 Conclusion
RAG-TRACE establishes a measurement-centered approach to assessing evidence reliability in AI-generated ECG reports. The evaluation highlights the importance of distinguishing retrieved clinical information from criteria supported by patient-specific measurements. Its verification mechanism provides a transparent means of identifying unsupported applications while preserving valid quantitative evidence. Importantly, criterion-level reliability and diagnostic completeness represent separate dimensions of report quality that require independent assessment. Integrating these principles into clinical RAG pipelines could support more interpretable and auditable AI-generated reports. Future work should extend RAG-TRACE to broader clinical datasets, incorporate measurement-aware retrieval, and evaluate its impact through clinician-adjudicated assessments.
Declarations
Funding. Not applicable.
Competing interests. The authors declare no competing interests.
Ethics approval. Not applicable. The study used public recordings and recruited no participants.
Author contributions. All authors contributed to the manuscript and approved the submitted version.
Data and code availability. All code and study materials are publicly available at https://github.com/Elyasirankhah/RAG-TRACE.
References
[1] Kligfield, P., Gettes, L.S., Bailey, J.J., Childers, R., Deal, B.J., Hancock, E.W., Herpen, G., Kors, J.A., Macfarlane, P., Mirvis, D.M., et al.: Recommendations for the standardization and interpretation of the electrocardiogram. Part I: the electrocardiogram and its technology. Circulation 115(10), 1306–1324 (2007)
[2] Mason, J.W., Hancock, E.W., Gettes, L.S.: Recommendations for the standardization and interpretation of the electrocardiogram. Part II: electrocardiography diagnostic statement list. Circulation 115(10), 1325–1332 (2007)
[3] Wagner, P., Strodthoff, N., Bousseljot, R.-D., Kreiseler, D., Lunze, F.I., Samek, W., Schaeffter, T.: PTB-XL, a large publicly available electrocardiography dataset. Scientific Data 7, 154 (2020) https://doi.org/10.1038/ s41597-020-0495-6
[4] Strodthoff, N., Wagner, P., Schaeffter, T., Samek, W.: Deep learning for ECG analysis: benchmarks and insights from PTB-XL. IEEE Journal of Biomedical and Health Informatics 25(5), 1519–1528 (2021) https://doi.org/10.1109/JBHI.2020.3022989
[5] Ribeiro, A.H., Ribeiro, M.H., Paixão, G.M.M., Oliveira, D.M., Gomes, P.R., Canazart, J.A., Ferreira, M.P.S., Andersson, C.R., Macfarlane, P.W., Meira Jr, W., et al.: Automatic diagnosis of the 12-lead ECG using a deep neural network. Nature Communications 11, 1760 (2020)
[6] Hannun, A.Y., Rajpurkar, P., Haghpanahi, M., Tison, G.H., Bourn, C., Turakhia, M.P., Ng, A.Y.: Cardiologist-level arrhythmia detection and classification in ambulatory electrocardiograms using a deep neural network. Nature Medicine 25, 65–69 (2019)
[7] Alday, E.A.P., Gu, A., Shah, A.J., Robichaux, C., Wong, A.-K.I., Liu, C., Liu, F., Rad, A.B., Elola, A., Seyedi, S., et al.: Classification of 12-lead ECGs: the PhysioNet/Computing in Cardiology challenge 2020. Physiological Measurement 41(12), 124003 (2020) https://doi.org/10.1088/1361-6579/abc960
[8] Mehari, T., Strodthoff, N.: Self-supervised representation learning from 12-lead ECG data. Computers in Biology and Medicine 141, 105114 (2022)
[9] Attia, Z.I., Kapa, S., Lopez-Jimenez, F., McKie, P.M., Ladewig, D.J., Satam, G., Pellikka, P.A., Enriquez-Sarano, M., Noseworthy, P.A., Munger, T.M., et al.: Screening for cardiac contractile dysfunction using an artificial intelligence-enabled electrocardiogram. Nature Medicine 25, 70–74 (2019) https://doi.org/10.1038/s41591-018-0240-2
[10] Siontis, K.C., Noseworthy, P.A., Attia, Z.I., Friedman, P.A.: Artificial intelligence-enhanced electrocardiography in cardiovascular disease management. Nature Reviews Cardiology 18, 465–478 (2021)
[11] Tu, T., Schaekermann, M., Palepu, A., Saab, K., Freyberg, J., Tanno, R., Wang, A., Li, B., Amin, M., Cheng, Y., et al.: Towards conversational diagnostic artificial intelligence. Nature 642, 442–450 (2025)
[12] Singhal, K., Azizi, S., Tu, T., Mahdavi, S.S., Wei, J., Chung, H.W., Scales, N., Tanwani, A., Cole-Lewis, H., Pfohl, S., et al.: Large language models encode clinical knowledge. Nature 620, 172–180 (2023)
[13] Nori, H., King, N., McKinney, S.M., Carignan, D., Horvitz, E.: Capabilities of GPT-4 on medical challenge problems. arXiv preprint arXiv:2303.13375 (2023)
[14] Ji, Z., Lee, N., Frieske, R., Yu, T., Su, D., Xu, Y., Ishii, E., Bang, Y.J., Madotto,
A., Fung, P.: Survey of hallucination in natural language generation. ACM Computing Surveys 55(12), 1–38 (2023)
[15] Maynez, J., Narayan, S., Bohnet, B., McDonald, R.: On faithfulness and factuality in abstractive summarization. In: Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, pp. 1906–1919 (2020)
[16] Lewis, P., Perez, E., Piktus, A., Petroni, F., Karpukhin, V., Goyal, N., Küttler, H., Lewis, M., Yih, W.-t., Rocktäschel, T., et al.: Retrieval-augmented generation for knowledge-intensive NLP tasks. In: Advances in Neural Information Processing Systems, vol. 33, pp. 9459–9474 (2020)
[17] Gao, Y., Xiong, Y., Gao, X., Jia, K., Pan, J., Bi, Y., Dai, Y., Sun, J., Wang, M., Wang, H.: Retrieval-augmented generation for large language models: a survey. arXiv preprint arXiv:2312.10997 (2024)
[18] Shuster, K., Poff, S., Chen, M., Kiela, D., Weston, J.: Retrieval augmentation reduces hallucination in conversation. In: Findings of the Association for Computational Linguistics: EMNLP, pp. 3784–3803 (2021)
[19] Xiong, G., Jin, Q., Lu, Z., Zhang, A.: Benchmarking retrieval-augmented generation for medicine. In: Findings of the Association for Computational Linguistics: ACL, pp. 6233–6251 (2024)
[20] Zakka, C., Shad, R., Chaurasia, A., Dalal, A.R., Kim, J.L., Moor, M., Fong, R., Phillips, C., Alexander, K., Ashley, E., et al.: Almanac—retrieval-augmented language models for clinical medicine. NEJM AI 1(2) (2024)
[21] Agrawal, M., Hegselmann, S., Lang, H., Kim, Y., Sontag, D.: Large language models are few-shot clinical information extractors. In: Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pp. 1998–2022 (2022)
[22] Irankhah, E., Fodeh, S.: Yale-dm-lab at archehr-qa 2026: Deterministic grounding and multi-pass evidence alignment for ehr question answering. In: Proceedings of the Third Workshop on Patient-Oriented Language Processing (CL4Health) at LREC 2026, pp. 515–523 (2026). https://doi.org/10.63317/2wd3di8agfag
[23] Irankhah, E., Arif, M.: Ragflip: Measuring query-level negative flips in retriever upgrades. arXiv preprint arXiv:2610.07266 (2026) https://doi.org/10.48550/arXiv.2610.07266
[24] Surawicz, B., Childers, R., Deal, B.J., Gettes, L.S.: Recommendations for the standardization and interpretation of the electrocardiogram. Part III: intraventricular conduction disturbances. Circulation 119(10), 235–240 (2009)
[25] Sokolow, M., Lyon, T.P.: The ventricular complex in left ventricular hypertrophy as obtained by unipolar precordial and limb leads. American Heart Journal 37(2), 161–186 (1949)
[26] Hancock, E.W., Deal, B.J., Mirvis, D.M., Okin, P., Kligfield, P., Gettes, L.S.: Recommendations for the standardization and interpretation of the electrocardiogram. Part V: electrocardiogram changes associated with cardiac chamber hypertrophy. Circulation 119(10), 251–261 (2009)
[27] Casale, P.N., Devereux, R.B., Kligfield, P., Eisenberg, R.R., Miller, D.H., Chaudhary, B.S., Phillips, M.C.: Electrocardiographic detection of left ventricular hypertrophy: development and prospective validation of improved criteria. Journal of the American College of Cardiology 6(3), 572–580 (1985)
[28] Peguero, J.G., Lo Presti, S., Perez, J., Issa, O., Brenes, J.C., Tolentino, A.: Electrocardiographic criteria for the diagnosis of left ventricular hypertrophy. Journal of the American College of Cardiology 69(13), 1694–1703 (2017)
[29] Bazett, H.C.: An analysis of the time-relations of electrocardiograms. Heart 7, 353–370 (1920)
[30] Rautaharju, P.M., Surawicz, B., Gettes, L.S.: Recommendations for the standardization and interpretation of the electrocardiogram. Part IV: the ST segment, T and U waves, and the QT interval. Circulation 119(10), 241–250 (2009)
[31] Primeas, R.J., Crow, R.S., Zhang, Z.-M.: The Minnesota Code Manual of Electrocardiographic Findings, 2nd edn. Springer, London (2010). https://doi.org/10.1007/978-1-84882-778-3
[32] Wagner, G.S., Macfarlane, P., Wellens, H., Josephson, M., Gorgels, A., Mirvis, D.M., Pahlm, O., Surawicz, B., Kligfield, P., Childers, R., et al.: Recommendations for the standardization and interpretation of the electrocardiogram. Part VI: acute ischemia/infarction. Circulation 119(10), 262–270 (2009)
[33] Thygesen, K., Alpert, J.S., Jaffe, A.S., Chaitman, B.R., Bax, J.J., Morrow, D.A., White, H.D.: Fourth universal definition of myocardial infarction (2018). Circulation 138(20), 618–651 (2018)
[34] Collins, G.S., Moons, K.G.M., Dhiman, P., Riley, R.D., Beam, A.L., Van Calster, B., Ghassemi, M., Liu, X., Reitsma, J.B., Smeden, M., et al.: TRIPOD+AI statement: updated guidance for reporting clinical prediction models that use regression or machine learning methods. BMJ 385, 078378 (2024)
[35] Gallifant, J., Afshar, M., Ameen, S., Aphinyanaphongs, Y., Chen, S., Cacciamani, G., Demner-Fushman, D., Dligach, D., Daneshjou, R., Fernandes, C., et al.: The TRIPOD-LLM reporting guideline for studies using large language models. Nature Medicine (2025) https://doi.org/10.1038/s41591-024-03425-5
[36] Strodthoff, N., Mehari, T., Nagel, C., Aston, P.J., Sundar, A., Graff, C., Kanters, J.K., Haverkamp, W., Dössel, O., Loewe, A., Bär, M., Schaeffter, T.: PTB-XL+, a comprehensive electrocardiographic feature dataset. Scientific Data 10, 279 (2023) https://doi.org/10.1038/s41597-023-02153-8
[37] Niculescu-Mizil, A., Caruana, R.: Predicting good probabilities with supervised learning. In: Proceedings of the 22nd International Conference on Machine Learning, pp. 625–632 (2005)
[38] Qwen Team: Qwen3 technical report. arXiv preprint arXiv:2505.09388 (2025)
[39] DeepSeek-AI: DeepSeek-R1: incentivizing reasoning capability in LLMs via reinforcement learning. arXiv preprint arXiv:2501.12948 (2025)
[40] Llama Team: The Llama 3 herd of models. arXiv preprint arXiv:2407.21783 (2024)
[41] Guo, C., Pleiss, G., Sun, Y., Weinberger, K.Q.: On calibration of modern neural networks. In: Proceedings of the 34th International Conference on Machine Learning, pp. 1321–1330 (2017)
[42] Naeini, M.P., Cooper, G.F., Hauskrecht, M.: Obtaining well calibrated probabilities using Bayesian binning. In: Proceedings of the AAAI Conference on Artificial Intelligence, vol. 29 (2015)
[43] El-Yaniv, R., Wiener, Y.: On the foundations of noise-free selective classification. Journal of Machine Learning Research 11, 1605–1641 (2010)
[44] Geifman, Y., El-Yaniv, R.: Selective classification for deep neural networks. In: Advances in Neural Information Processing Systems, vol. 30 (2017)
[45] Park, S.-I., Lee, J.-Y.: Toward robust ralms: Revealing the impact of imperfect retrieval on retrieval-augmented language models. Transactions of the Association for Computational Linguistics 12, 1686–1702 (2024) https://doi.org/10.1162/tacl_a_00724
[46] Wu, K., Wu, E., Wei, K., Zhang, A., Casasola, A., Nguyen, T., Riantawan, S., Shi, P., Ho, D., Zou, J.: An automated framework for assessing how well llms cite relevant medical references. Nature Communications 16, 3615 (2025) https://doi.org/10.1038/s41467-025-58551-6
[47] Wind, S., Sopa, J., Truhn, D., Lotfinia, M., Nguyen, T.-T., Bressem, K., Adams, L., Rusu, M., Köstler, H., Wellein, G., Maier, A., Tayebi Arasteh, S.: Multi-step retrieval and reasoning improves radiology question answering with large language models. npj Digital Medicine 8, 790 (2025) https://doi.org/10.1038/s41746-025-02250-5