Papers
Topics
Authors
Recent
Search
2000 character limit reached

DiagECG: LLM-Driven ECG Diagnostic Framework

Updated 9 July 2026
  • DiagECG is a framework that transforms continuous 12-lead ECG signals into discrete tokens, enabling generative diagnostic reasoning beyond fixed-label classification.
  • It employs a lead-wise Inception/TIE encoder with quantization to retain waveform fidelity and integrate ECG data with natural language processing.
  • Empirical results demonstrate improved generalization and transfer, with high accuracy in ECG question answering and robust clinical report generation metrics.

DiagECG is an LLM-driven framework for diagnostic reasoning via discretized ECG tokenization that converts raw 12-lead electrocardiograms into symbolic tokens usable by a LLM for ECG question answering and diagnostic report generation. Its defining premise is that continuous physiological waveforms can be transformed into a discrete symbolic vocabulary, allowing ECG and natural language to be handled within one autoregressive modeling regime rather than through a separate continuous multimodal interface. In that formulation, ECG is treated as a sequence of tokens that can be forecast, conditioned on, and mapped to clinical text, with the stated goals of improving generalization across tasks and supporting open-ended reasoning rather than only fixed-label classification (Yang et al., 21 Aug 2025).

1. Historical and methodological position

DiagECG emerged within a research landscape dominated by task-specific ECG classifiers. Earlier raw-signal systems typically optimized closed-set recognition objectives such as multi-label arrhythmia classification or patient-specific congestive heart failure detection. Examples include a 1D residual network for 12-lead arrhythmia diagnosis with an average AUC of 0.970 and an average F1 score of 0.813, as well as a patient-specific CHF detector based on second-order difference plots that reported 100% accuracy in its best patient-based evaluation setting (Zhang et al., 2020, Kutlu et al., 2017). Feature-engineered approaches also broadened the diagnostic scope by showing that ECG intervals, axes, and demographics could estimate both cardiac and non-cardiac ICD-10-CM diagnoses, with 23 cardiac and 21 non-cardiac conditions above 0.7 AUROC (Alcaraz et al., 2024).

Against that background, DiagECG addresses a different problem formulation. Rather than learning a classifier tied to a fixed label space, it is designed to support ECG question answering, diagnostic report generation, and out-of-distribution transfer using a unified ECG-language backbone. The framework is therefore aligned with a broader shift from discriminative ECG labeling toward generative medical reasoning. This suggests a conceptual redefinition of automated ECG analysis: the target output is no longer only a diagnosis code or binary decision, but potentially a structured answer, a narrative report, or a task-conditioned explanation grounded in waveform morphology (Yang et al., 21 Aug 2025).

2. Signal tokenization and symbolic representation

The framework operates on a 12-lead ECG signal X={xi}i=1nX=\{x_i\}_{i=1}^n, where each record xiRL×Cx_i\in\mathbb{R}^{L\times C} has L=5000L=5000 time steps and C=12C=12 leads. Its tokenizer is explicitly lead-wise: each lead is z-normalized and encoded independently with the same encoder, which is intended to preserve lead-specific waveform structure and avoid early cross-lead interference. The encoder uses an Inception Block with parallel 1D convolutions of kernel sizes {1,3,5,7}\{1,3,5,7\}, followed by GroupNorm, LeakyReLU, and a residual connection: h(i)=LeakyReLU(GN(kConv1Dk(h(i1)))+h(i1)).\mathbf{h}^{(i)}=\mathrm{LeakyReLU}\left(\mathrm{GN}\left(\sum_k \mathrm{Conv1D}_k(\mathbf{h}^{(i-1)})\right)+\mathbf{h}^{(i-1)}\right). It then applies Temporal Inception Enhancement blocks,

h(i+1)=TIEBlock(h(i)),\mathbf{h}^{(i+1)}=\mathrm{TIEBlock}(\mathbf{h}^{(i)}),

to deepen contextual modeling, expand receptive fields, and downsample the temporal dimension while preserving waveform information (Yang et al., 21 Aug 2025).

After encoding, the latent vectors are discretized by a fixed-scale quantization module. For each timestep tt,

ztcont=σ(Wzt+b),\mathbf{z}_t^{\mathrm{cont}}=\sigma(\mathbf{W}\mathbf{z}_t+\mathbf{b}),

and each dimension is uniformly quantized into discrete levels: ztdisc=1L1round ⁣(ztcont(L1)).\mathbf{z}_t^{\mathrm{disc}}=\frac{1}{L-1}\cdot \mathrm{round}\!\left(\mathbf{z}_t^{\mathrm{cont}}\cdot (L-1)\right). A straight-through estimator is used during training, and a symmetric decoder with reconstruction loss,

xiRL×Cx_i\in\mathbb{R}^{L\times C}0

is included to preserve signal fidelity. Tokenization itself is performed by positional base conversion. If xiRL×Cx_i\in\mathbb{R}^{L\times C}1 is the discretized value of the xiRL×Cx_i\in\mathbb{R}^{L\times C}2-th dimension, then

xiRL×Cx_i\in\mathbb{R}^{L\times C}3

The resulting index addresses an ECG-specific vocabulary entry, and that vocabulary extends the LLM’s original token set. The central architectural consequence is that ECG tokens and text tokens inhabit a shared embedding space (Yang et al., 21 Aug 2025).

3. Pretraining, instruction tuning, and reasoning interface

DiagECG uses a three-stage workflow. First, the tokenizer converts ECG into symbolic sequences. Second, the model is pretrained on ECG forecasting. Third, the pretrained model is instruction-tuned for ECG question answering and report generation. In pretraining, a random slice of ECG tokens is split into context and target, often in a 9:1 ratio, and the model learns next-token prediction with

xiRL×Cx_i\in\mathbb{R}^{L\times C}4

The pretraining corpus comes from MIMIC-IV-ECG and yields more than 1.5 million time-series slices. During this stage, the ECG embedding table and output classification head are fully trained, while transformer projection layers such as QKV and feedforward matrices are adapted with LoRA (Yang et al., 21 Aug 2025).

Instruction tuning preserves the same backbone and promptable autoregressive format. The prompts can include a dataset description, a task instruction, metadata such as patient ID, age, sex, height, weight, recording date, nurse ID, device ID, and site, and optionally a natural-language question. ECG token sequences are inserted between markers such as xiRL×Cx_i\in\mathbb{R}^{L\times C}5 and xiRL×Cx_i\in\mathbb{R}^{L\times C}6. The model then generates either an answer or a report with standard language-model cross-entropy over the target text. No task-specific classification heads are added. The framework therefore unifies yes/no verification, multiple-choice selection, open-ended querying, and report writing within one generative interface (Yang et al., 21 Aug 2025).

A key claim of the framework is that this autoregressive symbolic interface narrows the modality gap between continuous physiology and discrete language. The paper argues that, by first learning the temporal grammar of ECG token sequences and only then mapping to clinical text, the model can internalize waveform dynamics using native language-model machinery rather than relying on a soft-prompt or cross-attention adaptor (Yang et al., 21 Aug 2025).

4. Empirical performance and generalization

DiagECG is evaluated on ECG-QA and ECG report generation using MIMIC-IV-ECG and PTB-XL. For question answering, exact match accuracy is reported on verify, choose, and query questions derived from ECG attributes including extra systole, heart axis, signal noise, numerical indicators, SCP codes, and infarction stages. The framework achieves 56.63% average EM accuracy on MIMIC-IV-ECG and 54.98% on PTB-XL. For report generation, it reports BLEU, METEOR, and ROUGE-F1, reaching BLEU-4 of 29.74 and ROUGE-L of 58.63 on MIMIC-IV-ECG, and BLEU-4 of 33.60 and ROUGE-L of 59.24 on PTB-XL (Yang et al., 21 Aug 2025).

The paper also reports zero-shot transfer from MIMIC-IV-ECG to PTB-XL. In that setting, DiagECG achieves the best overall QA average and the strongest scores on QA-Verify and QA-Query among the compared methods, outperforming TIMELLM, TEST, MEIT, LLMTIME, ChatTime, ST-MEM, and W2V-CMSC-RLM. The ablation study attributes this performance to several components. Removing discretization harms all tasks, removing fine-tuning reduces performance substantially, especially on QA-Choose, and removing tabular metadata causes smaller but consistent drops. The encoder analysis further shows that the lead-independent Inception/TIE encoder outperforms MultiCNN, CausalCNN, Unet2D, and IndUnet1D, especially on nuanced QA-Query cases (Yang et al., 21 Aug 2025).

The paper supplements these quantitative results with representational analyses. UMAP plots show compact, overlapping ECG-text embeddings, and reconstruction examples indicate that the symbolic tokens preserve the original waveform well. Qualitative attention analyses suggest diagnosis-dependent localization: for non-diagnostic T-wave abnormalities, attention concentrates on the T-wave, while for myocardial infarction queries it shifts toward P and QRS complexes. This suggests that the shared symbolic space is not merely a transport mechanism for signal features but a substrate for query-conditioned morphological grounding (Yang et al., 21 Aug 2025).

5. Relation to adjacent ECG-diagnosis paradigms

DiagECG differs from several neighboring lines of work. One line emphasizes end-to-end raw-signal diagnosis with interpretable or high-performing discriminative architectures. A representative example is a 34-layer 1D CNN-based residual network for 12-lead multi-label diagnosis, coupled with SHAP analysis at patient and population levels; that model showed that full 12-lead input outperformed any single lead and identified lead II, aVR, V1, V2, V5, and V6 as especially important in the global attribution analysis (Zhang et al., 2020). Another line broadens the disease scope using structured ECG features and XGBoost rather than raw waveforms, demonstrating that ECG carries signal relevant to non-cardiac conditions as well as cardiac disease (Alcaraz et al., 2024).

A separate family of systems starts from ECG images rather than sampled signals. Pic2Diagnosis performs direct diagnosis from printed or scanned ECG pictures using a two-step curriculum learning framework with segmentation-mask pretraining, grayscale inverted-image fine-tuning, and an ensemble of three models; it reports an AUROC of 0.9534 and an F1 score of 0.7801 on the BHF ECG Challenge dataset (Büyüksolak et al., 26 Jul 2025). CRT-Net instead converts hospital ECG images into 1-D signals via a bi-directional connectivity algorithm and then classifies them with a CNN–bi-directional GRU–Transformer model, whereas “Automated Optical Reading of Scanned ECGs” focuses on classical image processing for recovering digitized waveforms from paper traces (Liu et al., 2021, Pazos-Santomé et al., 2024). DiagECG is distinct from both approaches because it assumes raw 12-lead digital input and targets language generation and reasoning rather than image-only classification or digitization.

Other adjacent directions address structural transfer, topology, quality control, and infrastructure. Multimodal ECG–CMR pretraining transfers CMR-derived structural information into ECG embeddings for downstream ECG-only screening (Turgut et al., 2023). Persistent homology-based \v{C}ech complex analysis seeks biomarkers of NSR, MCI, and non-MCI via topological features such as birth-death pairs, Betti curves, and persistent entropy (Reddy et al., 2024). Diagnostic quality assessment for low-dimensional ECG representations argues that preprocessing quality should be measured by preservation of diagnostic interpretation rather than only by MSE or PRD (Kovács et al., 2022). ElectroCardioGuard, finally, addresses patient misidentification in ECG databases through pairwise verification rather than diagnosis itself (Seják et al., 2023). Taken together, these works indicate that DiagECG belongs to a broader research transition in which ECG systems are being evaluated not only by classification accuracy, but also by reasoning capacity, interpretability, robustness to acquisition format, and preservation of clinically meaningful content.

6. Limitations, implications, and research significance

The reported ablations show that discretization alone is not sufficient. Removing fine-tuning reduces downstream performance substantially, and removing metadata produces smaller but consistent declines. This suggests that symbolic tokenization is most effective when combined with task adaptation and structured clinical context rather than used as an isolated representation trick (Yang et al., 21 Aug 2025). The paper also argues that representation quality remains decisive: the lead-independent Inception/TIE encoder outperforms several alternative time-series encoders, indicating that the LLM component does not eliminate the need for domain-specific ECG front ends (Yang et al., 21 Aug 2025).

A broader implication is that DiagECG should be understood as an interface proposal as much as a task model. It does not merely attach an ECG encoder to a LLM; it recasts ECG as a symbolic language. That design has consequences for transfer, prompting, and report generation, but it also raises questions familiar from adjacent literature. Diagnostic distortion introduced by representation learning remains a concern in any compressed or transformed ECG pipeline (Kovács et al., 2022). Data integrity remains critical, since patient assignment errors can corrupt both longitudinal reasoning and model supervision (Seják et al., 2023). In settings where ECGs exist only as paper records, image-based diagnosis or digitization may still be required before a token-based LLM can be applied (Büyüksolak et al., 26 Jul 2025, Pazos-Santomé et al., 2024).

Within the development of automated ECG analysis, DiagECG marks a move from label prediction toward open-ended medical language grounded in waveform data. Its significance lies in demonstrating that 12-lead ECG can be discretized into a symbolic vocabulary, pretrained with next-token forecasting, and then instruction-tuned for clinical text generation without modifying the core LLM. A plausible implication is that future ECG systems may increasingly be evaluated as general-purpose reasoning models rather than only as specialized classifiers, with tokenization, prompting, and cross-task transfer becoming central design axes (Yang et al., 21 Aug 2025).

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to DiagECG.