Predicting a patient's future diagnosis based on their medical history is a "holy grail" of health AI, potentially enabling early intervention and better resource allocation. However, two major hurdles have historically limited progress: the "Knowledge Gap," where standard Large Language Models (LLMs) lack inherent understanding of structured medical codes (e.g., ICD-9/10), and the "Needle in a Haystack" problem, where models must navigate tens of thousands of possible diagnoses.
The MERA (Memorize and Rank) framework addresses these challenges by transforming LLMs into state-of-the-art clinical predictors. By teaching models to "memorize" medical code definitions and using hierarchical contrastive learning to navigate complex diagnosis ontologies, MERA significantly outperforms both traditional graph-based models and vanilla LLMs.
The MERA Methodology
MERA utilizes a three-step pipeline designed to bridge the gap between structured medical data and linguistic reasoning.
Medical Code Memorization
Before learning to predict, the LLM undergoes a "medical school" phase. It is fine-tuned on synthetic Q&A pairs to learn the bidirectional mapping between medical codes and their natural language definitions (e.g., "What is the definition of code X?" and "What code corresponds to definition Y?"). This step is crucial, as the authors found that even GPT-4 can only correctly identify about 45% of ICD-9 codes from their definitions out of the box.
Hierarchical Contrastive Learning (HCL)
To handle the massive search space of over 13,000 ICD-9 codes, MERA leverages the hierarchical structure of the ICD system. Instead of simple classification, the model is trained to distinguish a true diagnosis from "neighboring" diseases within the same category. This forces the model to learn the subtle nuances between similar conditions.
Dynamic Confidence Thresholding
Rather than predicting a fixed number of diseases, MERA learns to output a special <EOV> (End of Visit) token. This allows the model to dynamically decide when it has listed all the "confident" diagnoses for a specific patient encounter, rather than being forced to provide a top-k list that may include irrelevant codes.
Intra-visit Pattern Learning
The framework incorporates order-agnostic training for codes within a single visit while maintaining sensitivity to the chronological sequence of visits. This is achieved through in-visit order perturbation during the training phase.
Experimental Results
The researchers evaluated MERA using two gold-standard Electronic Health Record (EHR) datasets: MIMIC-III and MIMIC-IV. They tested the model on General Diagnosis Prediction and Heart Failure Prediction.
Key Findings
- State-of-the-Art Performance: On MIMIC-III, MERA (using BioMistral-7B) achieved a Recall@20 of 49.01%, nearly 8 points higher than the previous best graph-based model, KGxDP (41.29%).
- Doubling LLM Capability: A vanilla LLaMA2-7B model only achieved a Recall@20 of 23.56%. MERA's training recipe more than doubled the performance of the base LLM.
- Architecture Matters: Large decoder-only models (like BioMistral-7B and LLaMA2-7B) significantly outperformed encoder-decoder models (like T5) at mapping codes to definitions.
- Heart Failure Prediction: MERA reached an AUC of 90.78 on MIMIC-III and 98.74 on MIMIC-IV, outperforming all baselines.
Conclusion and Future Directions
MERA demonstrates that with the right training recipe—specifically code memorization and hierarchical ranking—LLMs can become powerful tools for clinical prediction. While the current framework focuses on structured codes, future work could more deeply integrate raw clinical notes and address the computational costs of full-parameter fine-tuning. Moving toward real-time clinical decision support will also require addressing challenges in data latency and model interpretability for clinicians.
Summary updated