HEM-Med: A Hierarchical Agentic Memory Framework for Safe Multi-Center Medication Recommendation

Min Xiao, Jin Li, Shoujin Wang, Yeguang Zhen, Yishuo Li, Wenpeng Lu

TL;DR

HEM-Med is a novel hierarchical agentic memory framework designed to improve medication recommendations in multi-center hospital settings. By explicitly disentangling general medical consensus from hospital-specific prescribing patterns and incorporating a safety-aware decoding process, it achieves superior accuracy and safety over state-of-the-art transfer learning and LLM-based baselines.

What Problem Does This Paper Address?

Medication Recommendation (MR) systems aim to suggest the best set of drugs for a patient based on their Electronic Health Records (EHR). While most research focuses on single-center settings, real-world healthcare is multi-center. Large medical centers have abundant data, while smaller, low-resource hospitals suffer from data sparsity.

The authors identify two major gaps in current multi-center MR:

  1. Entangled Knowledge: Prescribing decisions are a mix of universal medical knowledge and local hospital "residues" (specific protocols, local formularies, or physician preferences). Simply pooling data or aligning representations often leads to negative transfer, where the patterns of a large hospital poorly fit the needs of a smaller one (see Figure 1).
  2. Safety Constraints: Most models prioritize accuracy (matching what a doctor did) but overlook safety (avoiding dangerous Drug-Drug Interactions (DDI)) and local feasibility (whether a drug is actually available in that hospital's pharmacy).
Fig. 1: Motivating example of multi-center medication recom- mendation. Heterogeneous hospital prescribing patterns may cause negative transfer, and ignoring local feasibility and drug safety may lead to unsafe medication combinations.

Methods

The authors propose HEM-Med, which uses a "Hierarchical Agentic Memory" to separate and store different types of clinical experience.

1. Patient-Level Attribution Memory (L3)

Raw EHR data rarely explicitly states why a drug was prescribed. HEM-Med uses an LLM (specifically DeepSeek-v4-flash) as an "agent" to analyze patient records and create auditable links between medications and clinical anchors (diagnoses, procedures, or lab results).

2. Memory Disentanglement (L1 & L2)

The framework then aggregates these individual records into a hierarchy:

  • L1 (Cross-hospital Experience Memory): Stores high-confidence associations that appear consistently across multiple hospitals (the "consensus").
  • L2 (Hospital-specific Residual Memory): Captures patterns unique to a specific hospital—whether a drug is used more frequently (amplified), less frequently (suppressed), or exclusively (localized) compared to the global average.
  • Weak Auxiliary Pool: Retains rare or "long-tail" associations that don't meet strict thresholds but might still be useful for unusual cases.

3. Safety-Aware Recommendation

During inference, the system retrieves experiences from both L1 and L2. Instead of a simple top-K selection, it uses a DDI-aware set decoding objective. This mathematical optimization balances clinical relevance with a penalty for dangerous drug combinations and therapeutic redundancy (prescribing two drugs that do the same thing).

Fig. 2: Overall agentic framework of HEM-Med. HEM-Med retrieves disentangled cross-hospital and hospital-specific experience, and generates medication sets through calibrated prediction and DDI-aware decoding.

Datasets

The model was evaluated on the eICU Collaborative Research Database, a massive real-world multi-center dataset containing over 200,000 ICU admissions across 149 hospitals in the United States. The authors processed this into a cohort of ~90,000 records, maintaining a ground-truth DDI rate of roughly 11.66%.

Key Insights and Ideas

  • Disentanglement over Alignment: Traditional transfer learning tries to make different hospital data "look" the same. HEM-Med argues it's better to acknowledge the differences and explicitly model the "residual" local behavior.
  • LLMs as Clinical Interpreters: Rather than using an LLM to make the final recommendation (which can be prone to hallucination), the authors use it as a tool to structure the training data by inferring the intent behind historical prescriptions.
  • The "SafeScore": The authors introduce a unified metric that combines accuracy (PRAUC, F1, Jaccard) with safety (1 - DDI rate). This prevents models from "cheating" by achieving high accuracy while recommending lethal drug combinations.

Key Results

HEM-Med significantly outperformed all baselines, including specialized MR models like SafeDrug and general LLM recommenders like Reason4Rec.

  • Accuracy: Achieved a PRAUC of 0.4161 and an F1 of 0.4532, a substantial jump over the strongest MR baseline (SafeDrug at 0.3926 PRAUC).
  • Safety: Maintained a low DDI rate of 0.0831, which is lower than the ground truth in the dataset (~0.11).
  • Overall Trade-off: It achieved the highest SafeScore (0.3649), proving it manages the accuracy-safety balance better than existing methods.

The authors also performed a parameter analysis (Figure 3/6), finding that incorporating "weak" auxiliary experience is beneficial up to a point (weight of 0.42), after which it introduces too much noise.

Fig. 3: Parameter analysis of weak experience weight and candidate depth.

Limitations and Future Work

While HEM-Med shows great promise, the authors note several areas for growth:

  • Richer Constraints: Future versions could incorporate more complex clinical rules beyond simple DDI pairs, such as dosage limits or contraindications based on kidney/liver function.
  • Fine-grained Safety: The current DDI knowledge is graph-based; integrating more nuanced, text-based safety knowledge could improve the "Safety Review" phase.
  • Prospective Validation: Like most AI in medicine papers, this was a retrospective study on historical data. Real-world clinical trials are needed to see how physicians actually interact with these "agentic" suggestions.

Summary updated

BibTeX
@misc{xiao2026hem,
  author = {Min Xiao and Jin Li and Shoujin Wang and Yeguang Zhen and Yishuo Li and Wenpeng Lu},
  title = {{HEM-Med: A Hierarchical Agentic Memory Framework for Safe Multi-Center Medication Recommendation}},
  year = {2026},
  eprint = {2610.20191},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.20191},
}
Figure