Failures Reveal What Metrics Miss: An Evidence-Driven Agent for Recursive Refinement of ECG Classifiers

Jinliang Deng, Yiming Niu, Yibo Pan, Zhiqi Shao, Qin Luo, Yongxin TongarXiv 2026

TL;DR

Researchers have developed RecursiveECG, an agentic framework that uses Large Language Models (LLMs) as offline "designers" to automatically improve ECG classifiers. By grounding model failures in concrete clinical evidence rather than just aggregate scores, the system achieves a 10% average performance boost across major datasets while remaining highly efficient for real-world deployment.

What Problem Does This Paper Address?

Deep learning has revolutionized 12-lead ECG classification, but the process of "polishing" these models remains a manual, expert-intensive task. When a model fails, developers typically look at aggregate metrics like accuracy or F1-score. However, these numbers don't explain why a model failed.

For instance, a model might misclassify a case of Wolff-Parkinson-White (WPW) syndrome as a Myocardial Infarction (MI). As shown in Figure 1, the label mismatch tells you the model is wrong, but it doesn't highlight that the model missed a "slurred delta wave" or was misled by "Pseudo-Q waves."

Figure 1: Motivation example illustrating how ECG model failures can be analyzed using evidence for refinement.

Current LLM-based approaches often try to use the LLM as the classifier itself, which is computationally expensive and prone to "hallucinations." This paper proposes a middle ground: using the LLM to intelligently design and refine a traditional, efficient neural network.

Methods

The authors introduce RecursiveECG, which operates on an LLM-as-Designer paradigm. Instead of making predictions, the LLM analyzes failures and writes code to improve the classifier.

Figure 2: Comparison of agentic paradigms for ECG analysis.

The framework consists of three main stages:

  1. Criteria-to-Measurement Compilation (CMC): The system takes established clinical ECG criteria (e.g., "a PR interval > 200ms indicates heart block") and uses an LLM to compile them into deterministic Python functions. This creates a library of reproducible, reference-backed measurements.
  2. Evidence-Grounded Failure Review (EGFR): When the current classifier fails, the agent selects these "failure cases" and constructs an evidence profile. It compares the failed case against similar cases the model got right (contrastive diagnosis) to identify specific signal characteristics the model is ignoring.
  3. Recursive Refinement: Based on this diagnosis, the LLM proposes code-level revisions to the model's architecture or training logic. These revisions are trained, tested, and only kept if they improve performance on a validation set.

The final output is a "frozen" classifier—a standard neural network that requires no LLM calls during actual medical use, ensuring speed and reliability.

Datasets

The framework was evaluated on three major public 12-lead ECG benchmarks:

  • PTB-XL: A large-scale dataset with hierarchical diagnostic labels.
  • Georgia (PhysioNet 2020): A multi-label dataset used in international challenges.
  • CPSC2018: A benchmark focused on various arrhythmia types.

Key Insights and Ideas

  • Beyond the "Black Box": By forcing the agent to use clinical measurements (CMC), the authors ground the LLM's reasoning in medical reality. This prevents the agent from making arbitrary changes and provides an audit trail for every model update.
  • Automated Inductive Bias: The agent can discover dataset-specific architectural improvements. For example, on PTB-XL, it evolved a simple ResNet into a complex model that separately processes limb and chest leads using cross-lead attention (see Figure 6).
  • Efficiency is Key: Unlike "LLM-as-Classifier" methods that are slow and expensive, RecursiveECG produces a model that is actually more efficient than many standard deep learning baselines.
Figure 6: Model design evolution on PTB-XL.

Key Results

RecursiveECG consistently outperformed strong baselines (like xLSTM-ECG and TimesNet) across all datasets.

  • Performance Boost: It achieved an average relative improvement of 10.0% in Macro-F1 score.
  • Efficiency: On the PTB-XL dataset, the final evolved model achieved superior accuracy while using 10.6% fewer parameters than xLSTM-ECG and 90.5% fewer FLOPs than UniTS.
  • Robustness: The system proved effective regardless of whether it used DeepSeek or Qwen as the underlying LLM "brain."

Limitations and Future Work

While powerful, RecursiveECG is currently limited by the quality of the clinical criteria provided to it and the reasoning capabilities of the underlying LLM. The authors also note that the system has only been evaluated retrospectively on historical data.

Future work aims to expand this "evidence-driven" approach to other medical time-series data, such as EEG or blood pressure monitoring, potentially creating a general-purpose agent for autonomous medical model refinement.

Summary updated

BibTeX
@misc{deng2026failures,
  author = {Jinliang Deng and Yiming Niu and Yibo Pan and Zhiqi Shao and Qin Luo and Yongxin Tong},
  title = {{Failures Reveal What Metrics Miss: An Evidence-Driven Agent for Recursive Refinement of ECG Classifiers}},
  year = {2026},
  eprint = {2607.24419},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2607.24419},
}
Figure