NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Reinforcement Learning for Out-of-Distribution Reasoning in LLMs: An Empirical Study on Diagnosis-Related Group Coding

Hanyin Wang, Zhenbang Wu, Gururaj J. Kolar, Hariprasad Reddy Korsapati, Brian Bartlett, Bryan Hull, Jimeng Sun

Abstract

Automating Diagnosis-Related Group (DRG) coding is a critical challenge in healthcare administration, requiring complex reasoning over clinical data that is often out-of-distribution (OOD) for general-purpose large language models (LLMs). This paper introduces DRG-SAPPHIRE, a specialized model based on the Qwen2.5-7B architecture, optimized through a pipeline of bootstrap Chain-of-Thought (CoT), supervised fine-tuning (SFT), and reinforcement learning (RL) using Group Relative Policy Optimization (GRPO). Our findings reveal a "bitter lesson" for OOD reasoning: RL performance scales linearly with the logarithm of SFT data, suggesting that RL primarily sharpens existing knowledge rather than teaching new domain-specific facts. DRG-SAPPHIRE achieves a state-of-the-art accuracy of 54.8% on the MIMIC-IV dataset, outperforming both specialized models and general-purpose frontier models like GPT-4o.

1. Introduction

Diagnosis-Related Group (DRG) coding serves as the foundation for hospital reimbursement and clinical auditing. The process involves synthesizing a patient's entire hospital stay—including procedures, comorbidities, and clinical complexity—into a single classification code. Currently, this task is performed manually by specialized coders, a process that is both labor-intensive and prone to variability.

While Large Language Models (LLMs) have demonstrated remarkable reasoning capabilities in general domains, they struggle with DRG coding due to the highly specialized nature of clinical notes and the strict, hierarchical rules governing over 700 potential codes. These clinical datasets are typically underrepresented in public pretraining corpora, making DRG coding a quintessential out-of-distribution (OOD) reasoning task. This study explores how to effectively adapt LLMs to this domain using a combination of SFT and RL.

2. Methodology

2.1 The DRG-SAPPHIRE Pipeline

We developed DRG-SAPPHIRE using a three-stage training pipeline designed to bridge the gap between general reasoning and specialized medical coding:

  1. Bootstrap CoT: We utilized the base model to generate initial reasoning paths for historical medical records, creating a synthetic dataset of clinical logic.
  2. Cold-Start SFT: The model was fine-tuned on this reasoning data to infuse the necessary domain knowledge and formatting requirements.
  3. Large-Scale RL: We employed Group Relative Policy Optimization (GRPO), utilizing rule-based rewards to align the model’s outputs with correct DRG assignments.

2.2 Algorithmic Optimizations for OOD Stability

Standard RL approaches often fail when applied to OOD tasks. To address this, we introduced three key modifications:

  • Dynamic Resampling: To mitigate "gradient vanishing"—where a lack of performance variance within a group halts learning—we resampled prompts until a sufficient spread of rewards was achieved.
  • KL Divergence Decay: We observed that maintaining proximity to the SFT reference model is vital for stability in OOD tasks. We implemented a cosine decay for the Kullback–Leibler (KL) penalty to balance exploration and stability.
  • Cognitive Behavior Intervention: We evaluated different reasoning architectures, specifically comparing "Answer-First" (outputting the code before the reasoning) against "CoT-First" (reasoning before the code).

3. Experimental Setup

Experiments were conducted using the MIMIC-IV dataset, focusing on the "brief hospital course" section of discharge summaries. The training set comprised 236,192 cases, with a test set of 26,244 cases. The target labels were MS-DRG version 34.0 codes. Performance was measured primarily by Pass@1 accuracy and physician-led qualitative review.

4. Key Insights and Results

4.1 State-of-the-Art Performance

DRG-SAPPHIRE achieved a 54.8% accuracy on the MIMIC-IV benchmark. This result surpasses the previous state-of-the-art (DRG-LLaMA at 53.9%) and exceeds the performance of proprietary models, including GPT-4o and o3-mini, in this specific domain. Furthermore, in a blind evaluation, four physicians assigned the model's reasoning a median score of 4 out of 5 for both accuracy and helpfulness.

4.2 The SFT Bottleneck in RL Scaling

A primary finding of this study is that RL performance in OOD domains is heavily dependent on the volume of SFT data. We observed that RL performance scales linearly with the logarithm of the number of SFT examples. This suggests that RL does not "teach" the model new clinical facts; rather, it acts as a distributor that optimizes the retrieval and application of knowledge already embedded during the SFT phase.

4.3 Reasoning Patterns: Answer-First vs. CoT-First

Contrary to trends in mathematical reasoning, DRG-SAPPHIRE performed better in the "Answer-First" configuration. This suggests that for medical coding, the model may leverage implicit knowledge within its latent space more effectively than it does through explicit, step-by-step verbalization. While CoT provides transparency, the direct-to-answer approach yielded higher raw accuracy.

4.4 RL as a Precision Tool, Not a Diversity Tool

While RL significantly improved Pass@1 accuracy, it simultaneously reduced the diversity of the model's outputs (Pass@8). This reinforces the view of RL as a mechanism that collapses the model's probability distribution toward high-reward pathways, effectively "sharpening" the model's focus at the expense of exploratory reasoning.

5. Discussion and Limitations

The fragility of RL in OOD environments was a recurring theme. Unlike math-based RL, which is relatively robust, medical coding RL proved highly sensitive to hyperparameters; for instance, removing the KL divergence penalty led to immediate training collapse.

Limitations of the current study include the reliance on outcome-based rewards (correctness of the final code) rather than process-based rewards (correctness of the reasoning steps). Additionally, the curriculum for selecting training cases was static; a dynamic curriculum that adapts to the model's learning progress could further enhance efficiency.

6. Conclusion

DRG-SAPPHIRE demonstrates that LLMs can achieve expert-level performance in highly specialized, OOD tasks like medical billing. However, the study highlights that for such tasks, scaling SFT data is often a more efficient path to improvement than scaling RL compute alone. Future work will investigate whether these principles apply to other complex, rule-bound domains such as legal reasoning and engineering compliance.

Summary updated

BibTeX
@inproceedings{wang2025reinforcement,
  author = {Hanyin Wang and Zhenbang Wu and Gururaj J. Kolar and Hariprasad Reddy Korsapati and Brian Bartlett and Bryan Hull and Jimeng Sun},
  title = {{Reinforcement Learning for Out-of-Distribution Reasoning in LLMs: An Empirical Study on Diagnosis-Related Group Coding}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=0jvnfH0WYV},
}
Figure