Retrieval-Augmented Generation for Electrocardiogram-Language Models

Xiaoyu Song, William Han, Tony Chen, Chaojing Duan, Michael A. Rosenberg, Emerson Liu, Ding ZhaoarXiv 2025 · DOI

Abstract

Electrocardiogram-Language Models (ELMs) represent a significant advancement in AI-assisted cardiology, moving beyond simple classification to providing descriptive textual interpretations. However, these models are prone to hallucinations, generating clinically unsupported diagnoses. This paper introduces the first open-source Retrieval-Augmented Generation (RAG) framework specifically designed for ELMs. By grounding model outputs in a database of real clinical reports and ECG features, the proposed pipeline significantly enhances both the linguistic quality and diagnostic accuracy of cardiac interpretations.

Introduction

Traditional AI applications in cardiology have primarily focused on narrow classification tasks. The emergence of ELMs allows for more nuanced interactions, such as generating textual explanations and answering open-ended clinical questions. Despite their potential, ELMs often suffer from hallucinations—a common issue in Large Language Models (LLMs) where the model generates plausible but incorrect information. While RAG has become a standard solution in natural language processing to mitigate this, its application to the specialized domain of ECG signals has remained largely unexplored until now.

Methodology

The researchers developed a three-stage RAG pipeline tailored for ECG data:

  1. RAG Database: A domain-specific repository containing ECG signal segments, derived clinical features (e.g., heart rate variability, QRS duration), and expert diagnostic reports. Efficient similarity searching is handled via the FAISS library.
  2. Multimodal Retrieval: For a given input ECG, the system extracts features and retrieves the most similar cases from the database based on both raw signal data and handcrafted features.
  3. Generation: The retrieved expert reports are integrated into the LLM's prompt. The study primarily utilizes ECG-Byte, which tokenizes ECG signals using Byte Pair Encoding, paired with a Llama-3.2-1B-Instruct backbone fine-tuned via LoRA.
Figure 1: Overview of the proposed RAG framework for Electrocardiogram-Language Models (ELMs).

Experimental Setup

The framework was validated using several benchmark datasets:

  • MIMIC-IV-ECG & PTB-XL: Large-scale public datasets providing the foundational ECG-report pairs.
  • ECG-Chat Instruct: A dataset for conversational AI in cardiology.
  • ECG-QA: Clinically relevant question-answer pairs derived from MIMIC and PTB-XL sources.

Key Results and Insights

The integration of RAG yielded substantial performance improvements across all evaluated metrics. Notably, on the ECG-Chat dataset, the BLEU-4 score increased from 22.85% to 38.10%. Diagnostic accuracy on the MIMIC-IV ECG dataset saw a dramatic rise from 27.21% to 57.77%.

Figure 6: Performance comparison of ECG-Byte with and without RAG across multiple datasets and metrics.

Several critical insights emerged from the study:

  • Training-Inference Synergy: Models performed best when trained specifically to utilize retrieved context. Simply adding RAG at inference time to a baseline model was less effective.
  • Retrieval Density: Interestingly, retrieving only the single most similar case ($k=1$) often outperformed higher values of $k$. Increasing the number of retrieved items tended to introduce noise that confused the model.
  • Architecture Agnosticism: The RAG pipeline proved effective across various ELM architectures, including encoder-based models like Merl and SigLIP, demonstrating its broad applicability.

Conclusion and Future Work

This work establishes a reproducible foundation for RAG in the cardiac domain. While the results are promising, limitations remain. Future research will focus on improving the embedding space for better retrieval quality, moving toward fully end-to-end learned representations to replace handcrafted features, and conducting rigorous clinical validation with human cardiologists to ensure real-world utility.

Source code and benchmarks are available at https://github.com/willxxy/ECG-Bench.

Summary updated

BibTeX
@misc{song2025retrieval,
  author = {Xiaoyu Song and William Han and Tony Chen and Chaojing Duan and Michael A. Rosenberg and Emerson Liu and Ding Zhao},
  title = {{Retrieval-Augmented Generation for Electrocardiogram-Language Models}},
  year = {2025},
  eprint = {2510.00261},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.00261},
}
Figure