Training LLMs for EHR-Based Reasoning Tasks via Reinforcement Learning

Jiacheng Lin, Zhenbang Wu, Jimeng Sun

TL;DR

The authors introduce EHRMIND, a framework that adapts small Large Language Models (LLMs) to complex clinical reasoning tasks using Reinforcement Learning with Verifiable Rewards (RLVR). By combining a lightweight Supervised Fine-Tuning (SFT) warm-up with Group Relative Policy Optimization (GRPO), a 3B-parameter model can outperform massive proprietary models like GPT-4 and DeepSeek-R1 on specialized medical benchmarks.

What Problem Does This Paper Address?

Reinforcement Learning with Verifiable Rewards (RLVR)—the core mechanism behind models like DeepSeek-R1—has achieved massive success in structured domains like mathematics and coding. In those fields, code can be executed or math equations checked automatically to provide a clear, binary reward signal.

Applying this paradigm to healthcare and Electronic Health Records (EHRs) introduces unique challenges. EHR data is notoriously noisy, combining structured data (labs, medications) with unstructured clinical notes. The authors identify two primary failure modes when trying to apply pure RLVR to medical tasks:

  1. Misapplied Knowledge: The model possesses the underlying medical knowledge but struggles to apply it correctly within a complex, task-specific clinical context.
  2. Missing Knowledge: The model completely lacks the specialized domain knowledge required for the task.

When knowledge is entirely missing, the model rarely generates a correct answer by chance. This creates a "sparse reward" problem where the RL algorithm receives no positive feedback signals, causing the training process to collapse.

Methods

EHRMIND addresses these challenges using a two-stage training recipe:

  1. Lightweight SFT Warm-up: The model is first fine-tuned on a small set (~2,000) of high-quality, step-by-step reasoning examples. This phase injects missing domain knowledge, stabilizes subsequent training, and teaches the model to output structured, interpretable reasoning paths.
  2. Reinforcement Learning (RLVR): The model is then optimized using Group Relative Policy Optimization (GRPO), a memory-efficient RL algorithm that eliminates the need for a separate critic model. It uses rule-based, verifiable reward functions (such as exact match or classification accuracy) to reinforce correct final outcomes, allowing the model to discover and refine its own optimal reasoning paths.

To determine when the SFT warm-up is actually necessary, the authors introduce Pass@k (and a stricter variant, Reliable Pass@k for classification) as a diagnostic tool. If a base model has a low initial Pass@k on a training set, it signifies missing knowledge, meaning an SFT warm-up is essential before initiating RL.

Relationship between initial Pass@k and subsequent RL performance gains.

Datasets

The framework was validated across three distinct clinical tasks:

  • MEDCALC: A benchmark of medical calculation questions (e.g., calculating a CHA₂DS₂-VASc score) grounded in patient notes.
  • TREC CLINICAL TRIALS: A patient-trial matching dataset where the model determines if a patient is Eligible, Excluded, or Irrelevant for a clinical trial based on eligibility criteria.
  • EHRSHOT: A few-shot evaluation benchmark used here for binary disease diagnosis prediction (Acute Myocardial Infarction, Hyperlipidemia, Hypertension, and Pancreatic Cancer) using structured EHR event sequences.

Key Insights and Ideas

  • RLVR Refines, It Doesn't Teach: A critical takeaway is that RLVR enhances reasoning by helping the model effectively leverage its existing knowledge rather than introducing entirely new information. If the underlying clinical formula or concept was never encountered, RLVR fails to improve performance.
  • Preventing Reasoning Collapse: In pure RL environments, models often learn to "hack" rewards by shortening their outputs and skipping intermediate steps to output the final answer directly. The SFT warm-up acts as an anchor, preserving detailed, structured, and clinically meaningful rationales throughout the RL training process.
Figure 3: Quantitative and qualitative analysis of reasoning improvements from SFT warm-up on disease diagnosis tasks. (a) Reasoning lengths averaged over 100 sampled test examples per condition. (b) Pairwise evaluation results of comparing reasoning quality between EHRMIND-SFT-RLVR and EHRMIND-RLVR. (c) Case study from the Pancreatic Cancer task. EHRMIND-SFT-RLVR demonstrates more structured and clinically aligned reasoning, explicitly connecting diagnostic evidence to the prediction, whereas EHRMIND-RLVR lacks such specificity.
  • Superior Cross-Task Generalization: Models optimized via RLVR develop transferable clinical reasoning patterns that generalize to out-of-distribution tasks much better than models trained purely on SFT data.

Key Results

EHRMIND achieves state-of-the-art performance using only a 3B-parameter LLaMA-3 base model, consistently outperforming models that are orders of magnitude larger.

  • Medical Calculations (MEDCALC): EHRMIND-SFT-RLVR achieved an overall accuracy of 51.96%, outperforming GPT-4 (37.92%), Claude-3.5-Sonnet (41.18%), o3-mini (46.42%), and DeepSeek-R1 (48.13%).
  • Patient-Trial Matching: On the TREC dataset, the framework achieved a Balanced Accuracy (BACC) of 63.14% and a Macro F1 of 44.47%, significantly beating all zero-shot baselines.
  • Disease Diagnosis (EHRSHOT): The model achieved top-tier performance across multiple conditions, notably hitting an 80.41% BACC on Pancreatic Cancer prediction.
Table 1: Accuracy on the MEDCALC test set across seven calculator categories. Bold indicates the best result; underlined denotes the second and third best. EHRMIND achieves state-of-the-art performance with only 3B parameters. We provide further analysis for the Lab , Risk , and Sev. tasks in Finding 3 below, where EHRMIND (seemingly) ties/underperforms relative to baselines.

Limitations and Future Work

Despite its strong performance, the authors note several limitations:

  • Context Length Constraints: Long-term patient histories can contain tens of thousands of events, which can overwhelm standard LLM context windows. Future work will need to explore hybrid or multimodal architectures to compress these timelines.
  • Reward Function Design: EHRMIND relies on rule-based, verifiable rewards. While this works well for calculations and classification, it is incredibly difficult to design rule-based rewards for open-ended clinical tasks like medical report generation or summarization.

Summary updated

BibTeX
@misc{lin2025training,
  author = {Jiacheng Lin and Zhenbang Wu and Jimeng Sun},
  title = {{Training LLMs for EHR-Based Reasoning Tasks via Reinforcement Learning}},
  year = {2025},
  eprint = {2505.24105},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.24105},
}
Figure