Skip to content

PKUDigitalHealth/ECG-R1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ECG-R1: Protocol-Guided and Modality-Agnostic MLLM for Reliable ECG Interpretation

If you find this project useful, please give us a star🌟.

Jiarui Jin, Haoyu Wang, Xingliang Wu, Xiaocheng Fang, Xiang Lan, Zihan Wang
Deyun Zhang, Bo Liu, Yingying Zhang, Xian Wu, Hongyan Li, Shenda Hong

Introduction

Electrocardiography (ECG) serves as an indispensable diagnostic tool in clinical practice, yet existing multimodal large language models (MLLMs) remain unreliable for ECG interpretation, often producing plausible but clinically incorrect analyses. To address this, we propose ECG-R1, the first reasoning MLLM designed for reliable ECG interpretation via three innovations. First, we construct the interpretation corpus using Protocol-Guided Instruction Data Generation, grounding interpretation in measurable ECG features and monograph-defined quantitative thresholds and diagnostic logic. Second, we present a modality-decoupled architecture with Interleaved Modality Dropout to improve robustness and cross-modal consistency when either the ECG signal or ECG image is missing. Third, we present Reinforcement Learning with ECG Diagnostic Evidence Rewards to strengthen evidence-grounded ECG interpretation. Additionally, we systematically evaluate the ECG interpretation capabilities of proprietary, open-source, and medical MLLMs, and provide the first quantitative evidence that severe hallucinations are widespread, suggesting that the public should not directly trust these outputs without independent verification. Code and data are publicly available at Github and HuggingFace, and an online platform can be accessed at ECG-R1-Online-Platform.

πŸ”₯Updates

Stay tuned for updates!

Resource

Paper: πŸ“„ Arxiv

Model: πŸ€— ECG-R1-8B

Setup

git clone https://github.com/PKUDigitalHealth/ECG-R1
cd ECG-R1
conda create -n ecg_r1 python=3.10 -y
conda activate ecg_r1
pip install -e .
pip install -r requirements.txt
pip install -e ./ecg_r1  # ECG-R1 vLLM support

Data Preparation

Please download required data:

ECG:

Images:

After downloading all of them, organize the data as follows in ./data,

β”œβ”€β”€ ecg_timeseries
    └── champan-shaoxing
    └── code15
    └── cpsc2018
    └── ptbxl
    └── georgia
    └── mimic-iv
β”œβ”€β”€ ecg_images
    └── cod15_v4
    └── csn_aug_all_layout_papersize
    └── csn_ori_layout_papersize
    └── csn_part_noise_layout_papersize
    └── gen_images
      └── mimic_gen
    └── mimic
    └── mimic_v4
    └── ptb-xl
β”œβ”€β”€ ecg_bench
    β”œβ”€β”€ ptb-test.jsonl
    β”œβ”€β”€ cpsc-test.jsonl
    β”œβ”€β”€ code15-test.jsonl
    β”œβ”€β”€ csn-test-no-cot.jsonl
    └── g12-test-no-cot.jsonl
β”œβ”€β”€ ecg_jsons
    β”œβ”€β”€ train_set
    β”‚   β”œβ”€β”€ ECG-Protocol-Guided-Grounding-CoT-30k.jsonl
    β”‚   β”œβ”€β”€ ECG-Protocol-Guided-Grounding-CoT-RL-4k.jsonl
    β”‚   └── ECGInstruct.jsonl
    └── test_set
        β”œβ”€β”€ ecg-grounding-test-mimiciv_full.jsonl
        β”œβ”€β”€ ecg-grounding-test-mimiciv_ecg_missing25.jsonl
        β”œβ”€β”€ ...
        β”œβ”€β”€ ecg-grounding-test-mimiciv_image_missing25.jsonl
        └── ...

Pretrained Model Preparation

Pretrained ECG Encoder:

  • ECG-CoCa : download cpt_wfep_epoch_20.pt, place it in ecg_coca/open_clip/checkpoint

Train

For SFT training from scratch:

  • step 1. specify paths in scripts/shells/sft_train.sh
  • step 2. run bash scripts/shells/sft_train.sh

For RL training from scratch:

  • step 1. specify paths in scripts/shells/rl_train_rollout.sh and scripts/shells/rl_train_dapo.sh
  • step 2. make sure you have installed ecg-r1 vllm support
  • step 3. run scripts/shells/rl_train_rollout.sh
  • step 4. run scripts/shells/rl_train_dapo.sh

Evaluation

For ECG Interpretation:

  • step 1. generate interpretations: scripts/shells/inference.sh
  • step 2. generate evaluation reports: scripts/evaluation/grounded_interpretation/generate_volcengine_evaluation_result_batch.py
  • step 3. process evaluation reports and get scores: scripts/evaluation/grounded_interpretation/compute_metrics.py

For Modality Missing:

  • step 1. generate image-only ECG interpretation by setting --val_dataset to ecg-grounding-test-mimiciv_ecg_missing100.jsonl in scripts/shells/inference.sh
  • step 2. generate signal-only ECG interpretation by setting --val_dataset to ecg-grounding-test-mimiciv_image_missing100.jsonl in scripts/shells/inference.sh
  • step 3. compute metrics: scripts/evaluation/modality_missing/compute_score.py

For ECGBench:

  • step 1. extract images from the .parquet files provided by ECGBench for each subset: scripts/ecgbench/extract_img.py
  • step 2. generate the initial results by running the inference script: scripts/shells/ecgbench_inference.sh
  • step 3. convert the initial results into the .jsonl format required by the evaluation scripts: ecgbench_convert_scripts.sh
  • step 4. compute metrics: scripts/evaluation/ecgbench/compute_metrics.py

Note

    1. You need to specify the result paths in all evaluation scripts.
    1. For a quick start, you can directly set --model PKUDigitalHealth/ECG-R1-8B-RL (from HuggingFace) to run the evaluation without additional local checkpoint preparation.
    1. You may slightly adapt the evaluation generation scripts to accommodate DeepSeek APIs from different providers.

Citation

If you find ECG-R1 helpful for your research and applications, please cite our paper:

@misc{jin2026ecgr1,
      title={ECG-R1: Protocol-Guided and Modality-Agnostic MLLM for Reliable ECG Interpretation}, 
      author={Jiarui Jin and Haoyu Wang and Xingliang Wu and Xiaocheng Fang and Xiang Lan and Zihan Wang and Deyun Zhang and Bo Liu and Yingying Zhang and Xian Wu and Hongyan Li and Shenda Hong},
      year={2026},
      eprint={2602.04279},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2602.04279}, 
}

Acknowledgement

We thank the authors of PULSE, ECG-Chat, GEM, and Swift for their publicly released models, datasets, and training codes.

About

[ICML 2026] ECG-R1: Protocol-Guided and Modality-Agnostic MLLM for Reliable ECG Interpretation

Resources

License

Stars

56 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages