Paper deep dive
GRAIN: Molecules Are Not the Right Granularity -- Active-Ingredient Modeling for Safe Medication Recommendation
Juao Fan, Jinhan Li, Shengxin Zhu
Intelligence
Status: succeeded | Model: Gemma-4-26B-A4B | Prompt: intel-v1 | Confidence: 92%
Last extracted: 8/4/2026, 3:47:45 AM
Summary
The paper introduces IngMamba (also referred to as GRAIN in the abstract), a medication recommendation framework for MIMIC-IV that utilizes a Mamba-based selective state space model to process longitudinal patient trajectories. It addresses the limitations of drug-code-level safety by introducing ingredient-level DDI modeling via RxNorm normalization, combining drug-level DDI graphs, ingredient-level DDI graphs, and EHR co-prescription graphs into a unified multi-granular training objective. The model significantly improves predictive accuracy and reduces adverse drug-drug interaction rates compared to baselines.
Entities (8)
Relation Signals (7)
IngMamba â uses â Mamba
confidence 95% · We propose IngMamba, a medication recommendation framework that couples a selective state space sequence model... Mamba introduces selective state space modeling
IngMamba â uses â MIMIC-IV
confidence 95% · Using the large-scale intensive-care EHR dataset MIMIC-IV, we encode longitudinal patient trajectories...
IngMamba â outperforms â MambaHealth
confidence 90% · IngMamba outperforms a re-implemented MambaHealth baseline on all standard multi-label metrics
IngMamba â reduces â Drug-Drug Interaction (DDI)
confidence 90% · IngMamba improves... while roughly halving the drug-level DDI rate
IngMamba â uses â RxNorm
confidence 90% · normalize medications to active ingredients via RxNorm
IngMamba â uses â TwoSIDES
confidence 85% · Using the TwoSIDES resource... we standardize drug identifiers into ingredient sets
IngMamba â uses â ATC
confidence 85% · standardize medication tokens using the WHO Anatomical Therapeutic Chemical (ATC) classification
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
Abstract:Medication recommendation from electronic health records must balance predictive accuracy against the risk of adverse drug-drug interactions (DDIs) under polypharmacy. Existing safety-aware recommenders operate at one of two granularities: the drug code, which treats each medication as an indivisible token, or the molecular substructure, which is finer than pharmacological interaction knowledge is actually organized. We argue that the active ingredient is the missing granularity, and introduce GRAIN, a medication recommendation framework built around it. GRAIN encodes longitudinal patient trajectories (diagnoses, procedures, past medications) with a selective state space backbone that handles long, irregular visit sequences in linear time. On top of it we introduce a joint objective unifying three knowledge sources aligned to a common medication vocabulary: a drug-level DDI graph, an ingredient-level DDI graph obtained by normalizing medication codes to active ingredients via RxNorm, and an EHR-derived co-prescription graph. A proportional controller adapts the accuracy-safety trade-off to the observed validation DDI rate rather than fixing it a priori. Under strictly matched settings -- identical preprocessing, cohort, vocabulary, split, and evaluation code -- GRAIN improves over a re-implemented MambaHealth baseline on MIMIC-IV across all standard multi-label metrics (Jaccard 0.4488 to 0.4983, PRAUC 0.6911 to 0.7485, F1 0.5989 to 0.6453) while reducing the drug-level DDI rate from 0.1875 to 0.0948. We further define an ingredient-level DDI rate, a safety measure invisible to drug-code-level evaluation. The results indicate that ingredient-level normalization recovers predictive signal erased by code-level aggregation, and that it is complementary to, rather than in competition with, accurate sequence modeling.
Tags
Links
- Source: https://arxiv.org/abs/2608.00098v1
- Canonical: https://arxiv.org/abs/2608.00098v1
Trouble viewing inline? Open PDF directly â
Full Text
48,292 characters extracted from source content.
Expand or collapse full text
IngMamba: Ingredient-Level DrugâDrug Interaction Modeling with Selective State Space Models for Medication Recommendation on MIMIC-IV Juao Fan Equal contribution. Jinhan Li11footnotemark: 1 Shengxin Zhu Corresponding author: [TODO: corresponding e-mail] (Guangdong Provincial Key Laboratory of Interdisciplinary Research and Application for Data Science, Beijing NormalâHong Kong Baptist University, Zhuhai, China ) Abstract Medication recommendation in critical care requires balancing two competing objectives: clinicians need accurate, personalized prescriptions for complex and evolving patient needs, while polypharmacy carries a substantial risk of adverse drugâdrug interactions (DDIs). We propose IngMamba, a medication recommendation framework that couples a selective state space sequence model with multi-granular pharmacological knowledge. Using the large-scale intensive-care EHR dataset MIMIC-IV, we encode longitudinal patient trajectories (diagnoses, procedures, and past medications) with a Mamba-based backbone that handles long, irregular visit sequences in linear time. On top of this backbone we introduce a joint training objective unifying three knowledge sources: (i) a drug-level DDI graph, (i) an ingredient-level DDI graph obtained by normalizing medication codes to active ingredients via RxNorm, and (i) an EHR-derived co-prescription graph reflecting real-world prescribing patterns. This design penalizes risky combinations while preserving predictive coverage and clinically realistic co-prescription behavior. Under strictly matched experimental settingsâidentical preprocessing, cohort, vocabulary, data split, and evaluation codeâIngMamba outperforms a re-implemented MambaHealth baseline on all standard multi-label metrics (Jaccard 0.4488â0.49830.4488â 0.4983, PRAUC 0.6911â0.74850.6911â 0.7485, F1 0.5989â0.64530.5989â 0.6453) while roughly halving the drug-level DDI rate (0.1875â0.09480.1875â 0.0948). We further report an ingredient-level DDI rate, a finer pharmacological safety measure that is invisible to drug-code-level evaluation. These results indicate that selective state space modeling and multi-level safety constraints are complementary rather than competing, and provide a reproducible starting point for future work on polypharmacy risk reduction in EHR-based clinical decision support. Keywords: medication recommendation; electronic health records; MIMIC-IV; state space model; drugâdrug interaction; ingredient-level safety; polypharmacy. 1 Introduction 1.1 Background and Motivation Large foundation modelsâincluding large language models (LLMs) and multimodal modelsâhave reshaped general-purpose representation learning, transferring broad pretraining into downstream tasks with minimal task-specific engineering (Bommasani et al., 2021). In healthcare, early evidence suggests that LLMs can encode non-trivial clinical knowledge and support medical reasoning in controlled settings, although reliability, safety, and evaluation remain central concerns (Singhal et al., 2023). These trends motivate a concrete question for clinical decision support: how can we build models that are simultaneously scalable on long, information-dense clinical trajectories and explicitly constrained by safety knowledge? Medication recommendation from longitudinal electronic health records (EHRs) is a representative high-stakes instance of this problem. The task is to recommend a set of medications for a patient visit given the patientâs evolving clinical context. The difficulty is not only predictive accuracyâmatching historically prescribed regimensâbut also safety under polypharmacy: harmful drugâdrug interactions (DDIs) contribute to preventable adverse drug events in hospitalized populations (de Andrade Santos et al., 2020). Better sequence modeling alone is therefore insufficient; safety signals must enter both the learning objective and the evaluation protocol. The data landscape for ICU EHR modeling has matured in parallel. The MIMIC family has driven open, reproducible critical-care machine learning: MIMIC-I substantially expanded earlier releases and enabled wide research adoption (Johnson et al., 2016), and MIMIC-IV was subsequently released as a contemporary EHR dataset spanning roughly a decade of admissions (2008â2019) with more precise digital information sources such as electronic medication administration records (Johnson et al., 2023). A practical bottleneck in MIMIC-style medication modeling is vocabulary heterogeneity: real-world prescription codes (e.g., NDC and RxNorm) are not stable across institutions and over time. To reduce sparsity and improve interoperability, many clinical pipelines standardize medication tokens using the WHO Anatomical Therapeutic Chemical (ATC) classification, which organizes drugs by anatomical, therapeutic, and chemical properties (World Health Organization, n.d.). This motivates our design choice to unify medication tokens at a consistent ATC level (ATC3 in our implementation) while retaining finer pharmacological resolution through ingredient-level safety modeling. A further observation motivates our central contribution. Drug-code-level DDI graphs treat each medication token as an indivisible unit, but interactions are mechanistically determined by active ingredients. Two ATC3 tokens may appear unrelated at the code level while sharing an interacting ingredient pair, and conversely a single code may aggregate several ingredients with heterogeneous risk profiles. Consequently, safety constraints imposed purely at the code level are systematically blind to a class of interaction risks that clinical knowledge bases actually curate at the ingredient level (Nelson et al., 2011; Fung et al., 2017). Overall, this work pursues a single goal: a MIMIC-IV medication recommender that (i) models long ICU trajectories efficiently and (i) enforces safety at multiple pharmacological granularities, rather than treating safety as an afterthought. 1.2 Contributions We propose IngMamba, a safety-aware medication recommendation framework on MIMIC-IV, with the following contributions. âą A Mamba-based medication recommendation pipeline for MIMIC-IV with unified medication tokens. We construct patientâvisit sequences from diagnoses, procedures, and prescriptions, and standardize medication tokens through an NDC â RxCUI â ATC4 â ATC3 mapping chain to improve coverage and reduce label sparsity (World Health Organization, n.d.). âą Ingredient-level safety modeling. Beyond drug-code-level constraints, we normalize medications to active ingredients via RxNorm (Nelson et al., 2011) and construct an ingredient-pair DDI graph from TwoSIDES (Tatonetti et al., 2012). Both a training signal and an evaluation metric are defined at this granularity, matching the level at which DDI knowledge is curated and applied in practice (Fung et al., 2017). âą A unified multi-granular training objective. We combine the multi-label prediction loss with drug-level DDI risk, ingredient-level DDI risk, and an EHR co-prescription plausibility reward, balanced by a proportional controller that adapts the safety weight to the observed validation DDI rate. âą Consistent empirical gains under strictly matched settings. Using a common pipeline, vocabulary, cohort, split, and evaluation code on MIMIC-IV, IngMamba improves over a re-implemented MambaHealth baseline (Wang et al., 2024) on Jaccard, PRAUC, and F1, while reducing the drug-level DDI rate by approximately 49%49\% relative and yielding a more clinically plausible average medication count per visit. 2 Related Work 2.1 Medication Recommendation on MIMIC-IV Medication recommendation predicts a safe and effective medication set for each patient visit from longitudinal EHRs. With the release of MIMIC-IV as a large-scale, freely accessible ICU EHR dataset, recent work has re-examined the task under more contemporary coding, coverage, and cohort settings (Johnson et al., 2023). Earlier longitudinal modelsâattention- and memory-based sequence learnersâestablished the importance of modeling multi-visit trajectories rather than treating visits independently (Le et al., 2018). Building on this line, more recent methods explore richer temporal representations for variable-length visit sequences and more structured generation of medication sets, including hierarchical prediction networks (Liu et al., 2023) and conditional generation paradigms for multi-label medication prediction (Wu et al., 2022). 2.2 State Space Models for Long Clinical Sequences Transformers have been widely applied to clinical sequence modeling, but their quadratic cost in sequence length becomes a bottleneck for long EHR histories. Structured state space models (SSMs) scale more favorably while preserving long-range dependency modeling, as demonstrated by S4 (Gu et al., 2021). Mamba introduces selective state space modeling to achieve linear-time sequence modeling with strong empirical performance on information-dense sequences (Gu and Dao, 2023). Outside healthcare, Mamba-style backbones have been explored for efficient sequential recommendation with competitive effectivenessâefficiency trade-offs (Liu et al., 2024). Within healthcare, MambaHealth demonstrated that a lightweight Mamba backbone is viable for drug recommendation on MIMIC-I (Wang et al., 2024); we adopt it as our baseline and starting point. 2.3 Safety-Aware Recommendation and DDI Mitigation A central challenge in medication recommendation is the trade-off between predictive accuracy and safety, commonly operationalized through DDI avoidance. A representative family of methods injects pharmacological knowledgeâparticularly DDI graphsâinto the learning objective or representation space to penalize high-risk combinations. SafeDrug introduces molecular-structure-aware representations with explicit DDI-aware learning to encourage safer combinations while maintaining therapeutic relevance (Yang et al., 2021). DrugDoctor targets realistic cold-start clinical scenarios by emphasizing visit-level learning and training strategies that improve early-visit recommendation quality while retaining safety objectives (Kuang and Xie, 2024). Closest to our motivation of bridging pharmacology and clinical intent, DATR proposes DDI-aware therapeutic structure reconstruction, conditionally encoding drug structures using ATC-derived therapeutic labels and introducing a selectivity-based DDI constraint to reduce interaction risk during recommendation (Anonymous, 2025). The authors motivate ATC precisely because it links therapeutic intent to chemical structure. This line of work reflects a broader trend: safe recommendation benefits from aligning chemical-level signals with clinically meaningful therapeutic organization, rather than relying on molecular structure alone. 2.4 Ingredient-Level Pharmacological Modeling Despite progress in DDI-aware learning, many safety signals in clinical decision support are ultimately defined at the active-ingredient level, or require ingredient-normalized interoperability across drug vocabularies (Nelson et al., 2011). Commercial DDI knowledge bases likewise curate interactions between ingredients rather than between dispensing codes, and differ substantially in coverage (Fung et al., 2017). Our work advances this direction by introducing explicit ingredient-level safety modeling in addition to drug-code-level signals. In contrast to approaches that regularize only code-level co-prescription, our ingredient-aware design targets interaction mechanisms closer to pharmacological reality, complementing ATC-based therapeutic organization (World Health Organization, n.d.). 2.5 Positioning of IngMamba In contrast to prior MIMIC-IV medication recommendation systems that rely on RNN- or Transformer-style backbones and treat drugs as indivisible tokens, IngMamba advances the literature in two complementary directions. First, it adapts Mamba-style selective SSM sequence modeling to MIMIC-IV medication recommendation, enabling efficient longitudinal representation learning over long visit histories. Second, it introduces ingredient-level modeling as an explicit safety signal, bridging clinical drug codes and pharmacological mechanism units to complement drug-level DDI constraints. Together, these choices target both scalability and safety realism for regimen recommendation in complex ICU settings. 3 Methodology 3.1 Data Representation and Medication Token Standardization MIMIC-IV data form. For our task, MIMIC-IV is viewed as a collection of relational tables (diagnoses, procedures, prescriptions) aggregated into patientâvisit sequences. Each visit is identified by the tuple (subject_id,hadm_id)( subject\_id, hadm\_id). After aggregation, each patient becomes a variable-length sequence of visits =(Dt,Pt,Mt)t=1T,S=\(D_t,P_t,M_t)\_t=1^T, (1) where DtD_t is the set of diagnosis codes, PtP_t the set of procedure codes, and MtM_t the set of medication tokens at visit t. Medication token unification. Prescriptions in MIMIC-IV are recorded as NDC codes. To reduce heterogeneity and sparsity, we standardize medications through the mapping chain NDCâRxCUIâATC4âATC3.NDC 4 3. (2) We use ATC3 as the final medication token space: it provides clinically meaningful therapeutic grouping while keeping the vocabulary manageable and improving coverage. Medications that fail to map are dropped rather than backed off to raw NDC/RxCUI, so that all tokens live in a single consistent space. Top-K frequency filtering and outputs. To control long-tail noise and stabilize training, we retain the most frequent codes: the top 2000 diagnoses, top 1000 procedures, and top 300 ATC3 medications. Preprocessing emits five artifacts: data_final.pkl, voc_final.pkl, records_final.pkl, ehr_adj_final.pkl, and ddi_A_final.pkl. Figure 1 summarizes the pipeline. [TODO: add a dataset statistics table here (#patients, #visits, avg visits/patient, avg meds/visit, |Vd||V_d|, |Vp||V_p|, |Vm||V_m|, #ingredients, #ingredient-DDI edges). A skeleton is provided in the commented block below.] [FIGURE PLACEHOLDER] fig_preprocess_pipeline.png file not found Figure 1: MIMIC-IV preprocessing and medication token standardization pipeline (NDC â RxCUI â ATC4 â ATC3) and generated artifacts. 3.2 Graph Construction for Safety and Clinical Plausibility We construct three graphs aligned to the medication vocabulary VmV_m. Each is a symmetric adjacency matrix Aâ0,1|Vm|Ă|Vm|Aâ\0,1\^|V_m|Ă|V_m| (weighted only during intermediate counting). Two are described here; the ingredient-level graph AINGA^ING requires additional normalization machinery and is described in Section 3.3. 3.2.1 EHR Co-prescription Graph (AEHRA^EHR) This graph captures empirical clinical plausibilityâwhat clinicians actually co-prescribe in the cohort. For each visit t, every unordered pair (i,j)(i,j) with iâ jiâ j and i,jâMti,jâ M_t contributes a co-occurrence. Aggregating over all visits, AiâjEHR=1,if âiâ and âjâ co-occur in at least one visit,0,otherwise.A^EHR_ij= cases1,&if i and j co-occur in at least one visit,\\ 0,&otherwise. cases (3) Intuitively, AEHRA^EHR provides a data-driven prior over combinations that are compatible in observed practice. 3.2.2 Filtered Drug-Level DDI Graph (ADDIA^DDI) This graph encodes explicit pharmacological safety constraints. Starting from drug-DDI.csv (STITCH CID pairs with side-effect annotations) and drug-atc.csv (CID â ATC list), we map (CID1,CID2)âATCâATC3âalign to âVm.(CID_1,CID_2) 3 to V_m. (4) To improve reliability and reduce spurious density, we apply a three-stage filter: (i) keep only the top 60 side effects; (i) keep CID pairs with frequency â„15â„ 15; (i) cap the result at the 1000 most frequent CID pairs. The resulting ADDIA^DDI is substantially sparser and concentrated on higher-confidence risky interactions (Figure 2). [FIGURE PLACEHOLDER] fig_two_graphs.png file not found Figure 2: Two graphs aligned to the medication vocabulary: (A) the EHR co-prescription graph AEHRA^EHR encoding empirical plausibility, and (B) the filtered DDI graph ADDIA^DDI encoding explicit safety constraints, retaining the top 60 side effects, pairs with frequency â„15â„ 15, and at most 1000 CID pairs. 3.3 Ingredient-Level DDI Graph 3.3.1 Drug Normalization We extract NDC codes from prescriptions.csv in MIMIC-IV, normalize the raw strings (removing non-digit characters and generating zero-padded candidates), and query RxNorm (Nelson et al., 2011) to map each code to its corresponding RxCUI. 3.3.2 Ingredient Vocabulary We follow the IN/PIN (ingredient / precise ingredient) relationships in RxNorm to extract drugâingredient mappings, yielding a function Iâ(â )I(·) from drug_rxcui to a set of ingredient_ids. All ingredients are assigned indices in a trainable embedding table. 3.3.3 Graph Construction and Projection to VmV_m Using the TwoSIDES resource (Tatonetti et al., 2012), we standardize drug identifiers into ingredient sets and build an ingredient-pair DDI graph G, aggregating support counts, adverse-drug-event overlaps, and proportional reporting ratio (PRR) statistics into a sparse adjacency representation. Two views of this graph are used, and it is important to distinguish them: âą For training, we project G onto the medication vocabulary to obtain AINGâ0,1|Vm|Ă|Vm|A^INGâ\0,1\^|V_m|Ă|V_m|, where AiâjING=1A^ING_ij=1 if any ingredient of token i interacts with any ingredient of token j in G. This projection makes AINGA^ING dimensionally compatible with the probability-based safety scores of Section 3.5. âą For evaluation, we operate in the native ingredient space: a predicted medication set is decomposed into its ingredient set and pairs are checked directly against G (Algorithm 2). This avoids the information loss introduced by projection and yields the ingredient-level DDI rate reported in Section 4.1.3. 3.4 Model Architecture IngMamba consists of two core modules: patient health state modeling (a two-stream shared Mamba encoder) and prescription generation (fusion, attention head, and multi-label output), with safety scores computed from the predicted probabilities (Figure 3). 3.4.1 Visit-Level Set Embedding Let Edââ|Vd|ĂdE^d ^|V_d|Ă d and Epââ|Vp|ĂdE^p ^|V_p|Ă d be learnable embedding tables for diagnoses and procedures. For visit t we sum the embeddings of the codes in each set, etd=âcâDtEdâ[c],etp=âcâPtEpâ[c],e_t^d= _câ D_tE^d[c], e_t^p= _câ P_tE^p[c], (5) yielding two sequences etdt=1T\e_t^d\_t=1^T and etpt=1T\e_t^p\_t=1^T. We use d=128d=128 and dropout 0.30.3. 3.4.2 Two-Stream Shared Mamba Encoder We apply L=3L=3 stacked Mamba blocks to each stream across time: Hd=Mamba(L)â(etdt=1T),Hp=Mamba(L)â(etpt=1T),H^d=Mamba^(L)(\e_t^d\_t=1^T), H^p=Mamba^(L)(\e_t^p\_t=1^T), (6) where Hd,HpââTĂdH^d,H^p ^TĂ d are per-visit hidden states. The two streams share weights, which halves the parameter count of the encoder and empirically stabilizes training on patients with few visits. We use lightweight Mamba settings dconv=4d_conv=4 and expand=2expand=2, and set the SSM state dimension to dstate=|Vm|.d_state=|V_m|. (7) This choice was made empirically; we did not observe instability from the resulting state width, though a systematic sensitivity analysis over dstated_state is left to future work. 3.4.3 Fusion and Attention-Based Prescription Head At each visit t we fuse the two streams by concatenation and project back to d: ht=MLPâ([htd;htp])ââd.h_t=MLP\! ([h_t^d;h_t^p] ) ^d. (8) We then apply single-head self-attention over the temporal states H=htt=1TH=\h_t\_t=1^T, Q=HâWQ,K=HâWK,V=HâWV,Attâ(H)=softmaxâ(QâKâ€d)âV,Q=HW_Q, K=HW_K, V=HW_V, (H)=softmax\! ( QK d )V, (9) with a causal mask so that visit t attends only to visits â€t†t. With a residual connection and layer normalization, the attended representation h~t h_t produces medication logits zt=Woâh~t+b,pt=Ïâ(zt),z_t=W_o h_t+b, p_t=Ï(z_t), (10) where ptâ(0,1)|Vm|p_tâ(0,1)^|V_m| is a multi-label probability vector. The predicted medication set is M^t=iâŁpt,iâ„Ï,Ï=0.5. M_t=\i p_t,iâ„Ï\, Ï=0.5. (11) [FIGURE PLACEHOLDER] fig_model_architecture.png file not found Figure 3: End-to-end framework and model architecture of IngMamba: a two-stream shared Mamba encoder for patient state modeling, a fusion and attention-based prescription head, and probability-based multi-granular safety scoring. 3.5 Safety Scoring and Training Objective 3.5.1 Probability-Based Quadratic Safety Scores All three graphs of Sections 3.2 and 3.3 enter the objective through the same differentiable quadratic form applied to the predicted probabilities ptp_t. For the drug-level DDI adjacency, rtDDI=sâ âi=1|Vm|âj=1|Vm|pt,iâpt,jâAiâjDDI=sâ ptâ€âADDIâpt,r_t^DDI=s· _i=1^|V_m| _j=1^|V_m|p_t,i\,p_t,j\,A^DDI_ij=s· p_t A^DDIp_t, (12) where s=5Ă10â4s=5Ă 10^-4 is a scaling factor keeping the safety terms on a comparable scale to the task loss. Analogously, the EHR co-prescription plausibility score and the ingredient-level risk score are rtEHR=sâ ptâ€âAEHRâpt,rtING=sâ ptâ€âAINGâpt.r_t^EHR=s· p_t A^EHRp_t, r_t^ING=s· p_t A^INGp_t. (13) Note the difference in sign convention: rtDDIr_t^DDI and rtINGr_t^ING are risks to be minimized, whereas rtEHRr_t^EHR is a reward measuring agreement with observed co-prescription practice and is therefore maximized. 3.5.2 Multi-Label Task Loss The task loss combines binary cross-entropy with a multi-label margin term âMLML_MLM, following standard practice in this literature (Yang et al., 2021): âtask=αââBCE+(1âα)ââMLM,α=0.95,L_task=α\,L_BCE+(1-α)\,L_MLM, α=0.95, (14) where, for a visit with ground-truth set YtY_t, âBCE=â1|Vm|ââi=1|Vm|[yt,iâlogâĄpt,i+(1âyt,i)âlogâĄ(1âpt,i)],L_BCE=- 1|V_m| _i=1^|V_m| [y_t,i p_t,i+(1-y_t,i) (1-p_t,i) ], (15) âMLM=1|Vm|ââiâYtâjâYtmaxâĄ(0, 1â(pt,iâpt,j)).L_MLM= 1|V_m| _iâ Y_t\ _jâ Y_t (0,\,1-(p_t,i-p_t,j) ). (16) 3.5.3 Unified Multi-Granular Objective Averaging each safety score over visits gives âDDI=1Tâât=1TrtDDI,âING=1Tâât=1TrtING,âEHR=1Tâât=1TrtEHR.L_DDI= 1T _t=1^Tr_t^DDI, _ING= 1T _t=1^Tr_t^ING, _EHR= 1T _t=1^Tr_t^EHR. (17) The full objective couples the task loss with the three knowledge sources: â=ÎČââtask+(1âÎČ)â(λDDIââDDI+λINGââINGâλEHRââEHR),L=ÎČ\,L_task+(1-ÎČ) ( _DDI\,L_DDI+ _ING\,L_ING- _EHR\,L_EHR ), (18) with λDDI=[TODO: value] _DDI= [rgb]1,0,0[TODO: value], λING=[TODO: value] _ING= [rgb]1,0,0[TODO: value], and λEHR=[TODO: value] _EHR= [rgb]1,0,0[TODO: value]. Setting λING=λEHR=0 _ING= _EHR=0 recovers the drug-level-only objective used by the MambaHealth baseline, which makes the comparison in Section 4.5 a controlled one. 3.5.4 Dynamic Safety Weighting Rather than fixing the accuracyâsafety trade-off a priori, we adapt ÎČ with a proportional controller driven by the validation drug-level DDI rate RDDIR_DDI against a target Îł: ÎČnew=clipâ(ÎČ+Kpâ(ÎłâRDDI),ÎČmin,ÎČmax), _new=clip (ÎČ+K_p(Îł-R_DDI),\; _ , _ ), (19) with Îł=0.05Îł=0.05, Kp=0.5K_p=0.5, ÎČmin=0.2 _ =0.2, and ÎČmax=0.95 _ =0.95. When the observed DDI rate exceeds the target, ÎČ decreases and the safety terms gain weight; when it falls below, the model is allowed to prioritize accuracy. For stability we apply exponential moving average smoothing, ÎČâmâÎČ+(1âm)âÎČnew,m=0.9.ÎČâ mÎČ+(1-m) _new, m=0.9. (20) 3.6 Training Protocol and Implementation Details We split patients (not visits) into train/validation/test sets with an 80/10/10 ratio, so that no patient trajectory spans two splits. Training uses Adam with learning rate 3Ă10â53Ă 10^-5 for up to 50 epochs with early stopping (patience 10) on validation Jaccard. Mini-batches are formed at the patient-sequence level, and variable-length visit sequences are preserved by a custom collate function. At inference we threshold at Ï=0.5Ï=0.5. 3.7 Evaluation Procedures Algorithms 1 and 2 give the two DDI evaluation procedures. The drug-level procedure is identical to the reference implementation used by MambaHealth and prior work, ensuring that baseline and IngMamba are scored by exactly the same code path. Algorithm 1 Drug-level DDI rate for a single visit 1:Predicted medication set Y^v Y_v; drug-level DDI adjacency A 2:Drug-level DDI rate for visit v 3:ddiâ0ddiâ 0; pairsâ0pairsâ 0 4:for all pairs (mi,mj)(m_i,m_j) in Y^v Y_v with i<ji<j do 5: pairsâpairs+1pairs +1 6: if Aâ[mi,mj]=1A[m_i,m_j]=1 then 7: ddiâddi+1ddi +1 return pairs>0â?âddi/pairs: 0pairs>0\ ?\ ddi/pairs\ :\ 0 Algorithm 2 Ingredient-level DDI rate for a single visit 1:Predicted medication set Y^v Y_v; ingredient mapping I; ingredient DDI graph G 2:Ingredient-level DDI rate for visit v 3:âvââmâY^vIâ(m)I_vâ _mâ Y_vI(m) 4:ddiâ0ddiâ 0; pairsâ0pairsâ 0 5:for all pairs (gi,gj)(g_i,g_j) in âvI_v with i<ji<j do 6: pairsâpairs+1pairs +1 7: if (gi,gj)âG(g_i,g_j)â G then 8: ddiâddi+1ddi +1 return pairs>0â?âddi/pairs: 0pairs>0\ ?\ ddi/pairs\ :\ 0 4 Experiments We validate IngMamba from both predictive-accuracy and pharmacological-safety perspectives. All evaluations use MIMIC-IV under a unified preprocessing pipeline. We compare (i) our re-implemented MambaHealth baseline and (i) IngMamba. We additionally reproduce published numbers from DATR (Anonymous, 2025) for context; because DATR uses its own preprocessing and split protocol, those values are reference points rather than strictly comparable baselines. 4.1 Evaluation Metrics 4.1.1 Accuracy For each visit v with ground-truth medications YvY_v and predicted set Y^v Y_v, Jaccardâ(v)=|Yvâ©Y^v||YvâȘY^v|,Precision=|Yvâ©Y^v||Y^v|,Recall=|Yvâ©Y^v||Yv|,Jaccard(v)= |Y_vâ© Y_v||Y_vâȘ Y_v|, = |Y_vâ© Y_v|| Y_v|, = |Y_vâ© Y_v||Y_v|, (21) F1=2â Precisionâ RecallPrecision+Recall.F1= 2·Precision·RecallPrecision+Recall. (22) We additionally report PRAUC, the area under the precisionârecall curve computed over the medication probability vector, which is threshold-independent and better suited to the strong label imbalance of the task. 4.1.2 Drug-Level DDI Rate Following MambaHealth and prior work, the drug-level DDI rate uses the released DDI matrix ddi_A_final.pkl. For visit v, DDIdrugâ(v)=âi<jAmi,mj(|Y^v|2),Drug-DDI=1||ââvâDDIdrugâ(v),DDI_drug(v)= _i<jA_m_i,m_j | Y_v|2, -DDI= 1|V| _v DDI_drug(v), (23) where V is the set of test visits. This is identical to the computation in the original MambaHealth implementation, ensuring strict fairness between baseline and IngMamba. 4.1.3 Ingredient-Level DDI Rate To evaluate safety at finer pharmacological resolution, we decompose each predicted medication set into its active ingredient set âvI_v and score pairs against the ingredient-level DDI graph G (Algorithm 2): DDIingâ(v)=â(gi,gj)ââvĂâv,i<jâ[(gi,gj)âG](|âv|2),Ingredient-DDI=1||ââvâDDIingâ(v).DDI_ing(v)= _(g_i,g_j) _vĂI_v,\,i<j1 [(g_i,g_j)â G ] |I_v|2, -DDI= 1|V| _v DDI_ing(v). (24) This metric captures incompatibilities that drug-code-level evaluation cannot express. We emphasize that Drug-DDI and Ingredient-DDI are not on a common scale: they are computed over different pair universes, and the ingredient graph is considerably denser than the filtered drug-level graph. The two numbers should therefore be compared across models within a level, never across levels. 4.2 Experimental Setup âą Dataset: MIMIC-IV [TODO: confirm exact version: v2.0 / v2.2 / v3.1], preprocessed as described in Section 3.1. âą Hardware: a single NVIDIA A100 GPU. âą Optimization: Adam, learning rate 3Ă10â53Ă 10^-5, up to 50 epochs, early stopping with patience 10. âą Metrics: Jaccard, PRAUC, F1, Drug-DDI, Ingredient-DDI. âą Variability: reported intervals are [TODO: state whether these are seed-based standard deviations or bootstrap CIs, and give n]. Note that the baseline and IngMamba currently report identical spreads, which reviewers do notice. 4.3 Training Dynamics and Convergence [FIGURE PLACEHOLDER] fig_training_curves.png file not found Figure 4: Training dynamics over epochs for IngMamba (ingredient-aware) and the MambaHealth baseline under identical settings on MIMIC-IV: (a) training loss, (b) PRAUC, (c) Jaccard similarity, and (d) micro-F1. Figure 4 shows training loss, PRAUC, Jaccard similarity, and micro-F1 across epochs for both models under identical settings. Both models exhibit a rapid decrease in training loss during the early epochs followed by gradual convergence, indicating stable optimization; IngMamba maintains a consistently lower training loss than the baseline throughout. On all three quality metrics, IngMamba improves faster in the initial phase and remains above the baseline for the entire run. Both curves begin to plateau after roughly 20 epochs, suggesting convergence under the current protocol. Incorporating ingredient-level information therefore does not compromise optimization stability, and is associated with consistently better predictive performance during training. 4.4 Published Reference Results Table 1 reproduces benchmark numbers reported by DATR (Anonymous, 2025) on MIMIC-I and MIMIC-IV. These situate our results within the range reported in the literature. We stress that these numbers were produced under a different preprocessing pipeline, cohort construction, and data split, and that DATR is at the time of writing a non-archival submission under review; they are reproduced for context only. Table 1: Benchmark results for medication recommendation models, as reported by Anonymous (2025). Reproduced for context only; these numbers are not directly comparable to ours due to differing preprocessing and splits. MIMIC-I MIMIC-IV Method Jaccard â PRAUC â F1 â DDI â Jaccard â PRAUC â F1 â DDI â LR 0.4935 0.7634 0.6512 0.0788 0.4152 0.6783 0.5651 0.0732 LEAP 0.4521 0.6581 0.6152 0.0720 0.3909 0.5542 0.5439 0.0550 GAMENet 0.5210 0.7780 0.6762 0.0781 0.4401 0.6833 0.5933 0.0718 COGNet 0.5109 0.7665 0.6615 0.0737 0.4313 0.6712 0.5850 0.0866 RAREMed 0.5342 0.7820 0.6938 0.0530 0.4620 0.6965 0.6152 0.0510 MICRON 0.5119 0.7690 0.6676 0.0610 0.4495 0.6753 0.6033 0.0502 SHAPE 0.5348 0.7791 0.6885 0.0850 0.4659 0.6928 0.6171 0.0917 SafeDrug 0.5255 0.7732 0.6804 0.0688 0.4560 0.6858 0.6098 0.0689 MoleRec 0.5303 0.7795 0.6844 0.0692 0.4502 0.6867 0.6040 0.0699 DrugDoctor 0.5422 0.7813 0.6975 0.0603 0.4703 0.6988 0.6190 0.0705 DATR 0.5506 0.7905 0.7073 0.0366 0.4783 0.7020 0.6216 0.0425 4.5 Main Results 4.5.1 Accuracy under Matched Settings Table 2 reports Jaccard, PRAUC, and F1 for the re-implemented MambaHealth baseline and IngMamba under identical settings on MIMIC-IV, alongside the DATR values from Table 1. Table 2: Accuracy metrics on MIMIC-IV. The DATR row is taken from Table 1 and is not strictly comparable, as it was obtained under a different preprocessing pipeline and data split. Only the last two rows form a controlled comparison. Model Jaccard â PRAUC â F1 â DATR (Anonymous, 2025), published 0.4783±0.0020.4783± 0.002 0.7020±0.0020.7020± 0.002 0.6216±0.0030.6216± 0.003 MambaHealth (our re-implementation) 0.4488±0.0020.4488± 0.002 0.6911±0.0020.6911± 0.002 0.5989±0.0030.5989± 0.003 IngMamba (ours) 0.4983±0.0020.4983± 0.002 0.7485±0.0020.7485± 0.002 0.6453±0.0030.6453± 0.003 IngMamba improves over the MambaHealth baseline on all three predictive metrics under matched conditions, with absolute gains of +0.0495+0.0495 Jaccard, +0.0574+0.0574 PRAUC, and +0.0464+0.0464 F1. Since the two rows differ only in whether the ingredient-level graph and its associated loss terms are active (Eq. 18), the improvement is attributable to the ingredient-level signal rather than to any change in backbone, cohort, or evaluation code. IngMamba also exceeds the published DATR scores on this dataset. We deliberately refrain from reading this as evidence of state-of-the-art performance: DATR constructs its cohort and splits differently, and cross-pipeline differences on MIMIC-IV can easily reach the magnitude observed here. The comparison indicates that IngMamba is competitive with the range reported in the recent literature, no more. 4.5.2 Safety Table 3 reports the safety metrics. Table 3: Safety metrics on MIMIC-IV. Drug-DDI is computed with the reference ddi_rate_score function over all predicted test visits; Ingredient-DDI is computed at the ingredient level via Algorithm 2. Lower is better. The two columns are on different scales and should not be compared to one another. Model Drug-DDI â Ingredient-DDI â MambaHealth (our re-implementation) 0.18750.1875 â IngMamba (ours) 0.09480.0948 0.20630.2063 [TODO: add an âAvg. #Medâ column to Table 3, or soften the claim. The abstract and the contribution list both assert a âmore clinically plausible average medication count per visitâ, but no such number appears anywhere in the paper.] Relative to MambaHealth, IngMamba reduces the drug-level DDI rate from 0.18750.1875 to 0.09480.0948, a relative reduction of approximately 49%49\%, while simultaneously improving all accuracy metrics. This is the central empirical claim of the paper: the usual accuracyâsafety trade-off does not bind here, because the ingredient-level signal supplies information that is genuinely complementary to the drug-level graph rather than merely suppressing predictions. Two caveats deserve explicit statement. First, our re-implemented baseline reaches a drug-level DDI rate of 0.18750.1875, roughly two to four times higher than the values reported for published methods in Table 1. We attribute this primarily to differences in cohort construction and to the fact that the baseline configuration optimizes the drug-level safety term with a comparatively low weight; the number should be read as the DDI rate of our baseline under our pipeline, not as a reproduction of MambaHealthâs published safety behavior. Second, IngMambaâs drug-level DDI rate of 0.09480.0948 remains above the controller target of Îł=0.05Îł=0.05 and above DATRâs reported 0.04250.0425. Tightening this gapâfor instance by increasing λDDI _DDI or by widening the controllerâs admissible rangeâis a natural next step, and we expect it to trade against accuracy. The ingredient-level DDI rate is reported for IngMamba only. Evaluating the baseline at this granularity requires running the ingredient normalization and checking pipeline over its predictions, which we leave to future work; the number is included here to establish the metric and a reference value for subsequent comparisons rather than to support a comparative claim. [TODO: strongly recommended before submission: fill in and uncomment the ablation table below. Without it, reviewers cannot attribute the gain to the ingredient-level component specifically, which is the paperâs headline contribution.] 5 Limitations Several limitations qualify the results above. Knowledge base coverage. Our external resources (RxNorm, TwoSIDES) are themselves imperfect and encode only known interactions. TwoSIDES in particular is derived from spontaneous adverse event reports and inherits their reporting biases. Emerging, rare, or undocumented DDIs are not captured, so a low measured DDI rate is evidence of avoiding known risks, not of pharmacological safety in general. Graph simplicity. We use a binary co-occurrence graph derived from MIMIC-IV. Richer statistical models of co-prescribingâconditional dependence, temporal co-occurrence dynamics, or severity-weighted interaction edgesâwould likely yield more informative safety priors than the unweighted formulation used here. Retrospective evaluation. Evaluation is retrospective and confined to structured MIMIC-IV data from a single institution. Agreement with historically prescribed regimens is a proxy for clinical quality, not a measure of it: a recommendation that differs from the recorded prescription is scored as an error even when it is clinically superior. Real-world deployment would require prospective validation, robustness testing across institutions, and clinician review. Model scale and missing ablations. Our experiments center on a medium-sized model due to computational constraints, leaving open questions about scaling behavior, data efficiency, and calibration at larger capacity. We also do not currently report an efficiency comparison against a Transformer backbone, nor a component-wise ablation of the three graph terms; both are needed to fully substantiate the motivation for the SSM backbone and the attribution of gains to the ingredient-level signal. 6 Conclusion and Future Work We presented IngMamba, a Mamba-based medication recommendation framework for the MIMIC-IV intensive care cohort equipped with multi-granular safety modeling. Motivated by the clinical need to balance predictive accuracy against DDI control, we asked whether selective state space models can serve as effective sequence encoders for ICU trajectories, and how pharmacological knowledge can be integrated more systematically into the training objective. Both questions admit an affirmative answer: under strictly matched settings, IngMamba improves over a re-implemented MambaHealth baseline in Jaccard, PRAUC, and F1 while roughly halving the drug-level DDI rate. Our contributions are threefold. First, we provide a systematic evaluation of Mamba-style models for medication recommendation on MIMIC-IV, showing that selective state space architectures capture temporal dynamics in long and irregular ICU trajectories. Second, we introduce a unified objective integrating DDI knowledge at two granularitiesâdrug level and ingredient levelâalongside an EHR-derived co-occurrence graph, letting the model jointly balance clinical accuracy, pharmacological safety, and empirical prescribing behavior. Third, through controlled experiments with identical preprocessing, vocabulary, and evaluation code, we show that multi-level safety signals can be injected into a Mamba backbone without degrading predictive performance. Several directions follow naturally. Richer pharmacological knowledge graphsâ mechanism-of-action networks, pathway-level interactions, or molecular representation learning via SMILES transformers or graph neural networksâcould deepen the safety signal. Combining medication recommendation with causal or counterfactual reasoning would better capture treatment effects and individualized risk, potentially improving generalization beyond MIMIC-IV. Multi-task formulations that jointly model diagnoses, procedures, and laboratory results alongside medications may yield more clinically coherent representations. On the architectural side, hybrids of Mamba with attention or retrieval-based memory could further improve long-range reasoning. Finally, real-world evaluationâphysician-in-the-loop studies, robustness under distribution shift, and fairness analysis across demographic subgroupsâwill be essential for assessing clinical viability. In summary, this work combines state space modeling with multi-level pharmacological safety constraints for medication recommendation on MIMIC-IV. By demonstrating consistent gains in both predictive accuracy and DDI reduction, it suggests that selective state space models coupled with structured safety knowledge are a promising direction for practical and trustworthy clinical decision support. Ethics Statement This study uses MIMIC-IV (Johnson et al., 2023), a de-identified critical care database distributed by PhysioNet. Access requires completion of human-subjects research training and execution of a data use agreement; all authors who accessed the data hold current credentialed access and complied with the agreement. The dataset is de-identified in accordance with HIPAA Safe Harbor provisions, and no attempt was made to re-identify individuals. No protected health information appears in this paper or in any released artifact. IngMamba is a research prototype. It is not a medical device, has not undergone prospective clinical validation, and must not be used to guide patient care. Reported DDI rates measure agreement with specific curated interaction resources and should not be interpreted as a guarantee of pharmacological safety. Retrospective agreement with historically prescribed regimens is a proxy metric that may encode existing prescribing biases, including disparities across demographic subgroups that we have not audited. Data and Code Availability MIMIC-IV is available to credentialed users at https://physionet.org/content/mimiciv/. RxNorm is distributed by the U.S. National Library of Medicine, and TwoSIDES (Tatonetti et al., 2012) is publicly available. Code for preprocessing, model training, and both DDI evaluation procedures is released at [TODO: public code repository URL] to support reproduction. Acknowledgements We thank Dr. Shengxin Zhu for his constructive guidance and valuable suggestions throughout this project. References Anonymous (2025) DATR: DDI-Aware therapeutic structure reconstruction for safer medication recommendation (ICLR 2026 submission). Note: OpenReviewOpenReview submission; PDF: https://openreview.net/pdf?id=6tumuDYeny External Links: Link Cited by: §2.3, §4.4, Table 1, Table 2, §4. R. Bommasani, D. A. Hudson, E. Adeli, R. Altman, S. Arora, S. von Arx, others, and P. Liang (2021) On the opportunities and risks of foundation models. Note: arXiv External Links: 2108.07258, Document, Link Cited by: §1.1. T. N. G. de Andrade Santos, S. A. M. Mendonça, M. G. C. d. S. de Oliveira, and H. L. L. Coelho (2020) Prevalence of clinically manifested drug interactions in hospitalized patients: a systematic review and meta-analysis. PLOS ONE 15 (7), p. e0235353. External Links: Document, Link Cited by: §1.1. K. W. Fung, J. Kapusnik-Uner, J. Cunningham, S. Higby-Baker, and O. Bodenreider (2017) Comparison of three commercial knowledge bases for detection of drugâdrug interactions in clinical decision support. Journal of the American Medical Informatics Association 24 (4), p. 806â812. External Links: Document, Link Cited by: 2nd item, §1.1, §2.4. A. Gu and T. Dao (2023) Mamba: linear-time sequence modeling with selective state spaces. arXiv preprint arXiv:2312.00752. Cited by: §2.2. A. Gu, K. Goel, and C. RĂ© (2021) Efficiently modeling long sequences with structured state spaces. Note: arXiv External Links: 2111.00396, Document, Link Cited by: §2.2. A. E. W. Johnson, L. Bulgarelli, L. Shen, A. Gayles, A. Shammout, S. Horng, T. J. Pollard, S. Hao, B. Moody, B. Gow, L. H. Lehman, L. A. Celi, and R. G. Mark (2023) MIMIC-IV, a freely accessible electronic health record dataset. Scientific Data 10 (1), p. 1. External Links: Document, Link Cited by: §1.1, §2.1, Ethics Statement. A. E. W. Johnson, T. J. Pollard, L. Shen, L. H. Lehman, M. Feng, M. Ghassemi, others, and R. G. Mark (2016) MIMIC-I, a freely accessible critical care database. Scientific Data 3, p. 160035. External Links: Document, Link Cited by: §1.1. Z. Kuang and J. Xie (2024) DrugDoctor: visit-level training for medication recommendation. In Proceedings of the AAAI Conference on Artificial Intelligence, Vol. 38, p. 8586â8594. Cited by: §2.3. H. Le, T. Tran, and S. Venkatesh (2018) Dual memory neural computer for asynchronous two-view sequential learning. In Proceedings of the 24th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining (KDD â18), External Links: Document, Link Cited by: §2.1. C. Liu, J. Lin, J. Wang, H. Liu, and J. Caverlee (2024) Mamba4Rec: towards efficient sequential recommendation with selective state space models. Note: arXiv External Links: 2403.03900, Document, Link Cited by: §2.2. S. Liu, X. Wang, J. Du, Y. Hou, X. Zhao, H. Xu, H. Wang, Y. Xiang, and B. Tang (2023) SHAPE: a sample-adaptive hierarchical prediction network for medication recommendation. Note: arXiv External Links: 2309.05675, Document, Link Cited by: §2.1. S. J. Nelson, K. Zeng, J. Kilbourne, T. Powell, and R. Moore (2011) Normalized names for clinical drugs: RxNorm at 6 years. Journal of the American Medical Informatics Association 18 (4), p. 441â448. External Links: Document, Link Cited by: 2nd item, §1.1, §2.4, §3.3.1. K. Singhal, T. Tu, J. Gottweis, R. Sayres, E. Wulczyn, L. Hou, others, and V. Natarajan (2023) Large language models encode clinical knowledge. Nature 620, p. 172â180. External Links: Document, Link Cited by: §1.1. N. P. Tatonetti, P. P. Ye, R. Daneshjou, and R. B. Altman (2012) Data-driven prediction of drug effects and interactions. Science Translational Medicine 4 (125), p. 125ra31. Cited by: 2nd item, §3.3.3, Data and Code Availability. Y. Wang, X. He, and S. Zhu (2024) MambaHealth: a lightweight foundation model for efficient drug recommendation. In AIM-FM Workshop, 38th Conference on Neural Information Processing Systems (NeurIPS 2024), Note: Workshop paper External Links: Link Cited by: 4th item, §2.2. World Health Organization (n.d.) ATC/D Toolkit. Note: Web resourceRetrieved December 26, 2025 External Links: Link Cited by: 1st item, §1.1, §2.4. R. Wu, Z. Qiu, J. Jiang, G. Qi, and X. Wu (2022) COGNet: a conditional generation network for medication recommendation. In Proceedings of the ACM Web Conference 2022 (W â22), p. 935â945. External Links: Document, Link Cited by: §2.1. C. Yang, C. Xiao, F. Ma, L. Glass, and J. Sun (2021) SafeDrug: dual molecular graph encoders for recommending effective and safe drug combinations. In Proceedings of the Thirtieth International Joint Conference on Artificial Intelligence (IJCAI-21), p. 3735â3741. External Links: Document, Link Cited by: §2.3, §3.5.2.