OntoMedRec: Logically-Pretrained Model-Agnostic Ontology Encoders for Medication Recommendation

Weicong Tan, Weiqing Wang, Xin Zhou, Wray Buntine, Gordon Bingham, Hongzhi Yin

TL;DR

OntoMedRec introduces a model-agnostic framework that pretrains medical ontology encoders using Logic Tensor Networks (LTNs) to solve the data sparsity problem in medication recommendation. By injecting hierarchical, first-order logic rules (like parental and sibling relationships) into medical code embeddings, it significantly boosts the accuracy of existing deep learning models, particularly for rare, few-shot medications.

What Problem Does This Paper Address?

Data-driven clinical decision support systems rely heavily on Electronic Health Records (EHRs) to recommend safe and effective medication regimens. However, medical concepts in EHR datasets typically follow a strict power-law distribution. A few common diagnoses and medications appear frequently, while the vast majority occur very rarely.

This long-tail distribution creates a severe data sparsity issue. Standard deep learning models fail to learn robust representations for these rare concepts, leading to poor recommendation performance for uncommon conditions.

While external knowledge bases like medical ontologies (hierarchical classification systems) can help bridge this gap, existing approaches fall short. Many models treat ontologies as undirected graphs using Graph Attention Networks (GATs), ignoring the fact that ontologies are inherently Directed Acyclic Graphs (DAGs). Furthermore, they fail to capture nuanced relationships, such as the clinical differences between "sibling" nodes (e.g., distinguishing between codeine-based and non-codeine cough suppressants).

Fig. 1: Frequency distribution of diagnoses and medications in MIMIC-III dataset. The last bin is the cropped diagnoses/medications with a frequency higher than 200/40000.

Methods

The authors propose OntoMedRec, a logically-pretrained, model-agnostic ontology encoder framework grounded in Logic Tensor Networks (LTNs). LTNs bridge the gap between symbolic logic and deep learning by grounding first-order logic formulas into neural network computations.

Key components of the methodology include:

  1. Logical Axiom Design: The authors define specific logical rules (axioms) to enforce the structural properties of DAGs. This includes non-reflexive and non-commutative rules for parent and ancestor relationships, alongside explicit definitions for sibling relationships to capture both similarities and differences.
  2. Axiom-Oriented Sampling: Standard LTNs suffer from high space complexity ($O(n|N|d)$) when dealing with large graphs, making them too memory-intensive for real-world medical ontologies (which contain tens of thousands of nodes). OntoMedRec introduces a localized sampling method that restricts variable creation to a training node batch and its immediate relatives, reducing space complexity to $O(nbd)$, where $b \ll |N|$.
  3. Cross-Ontology Alignment: To connect medications with their corresponding diagnoses, the authors leverage the external MEDI dataset to logically align the separate embedding spaces of diagnoses and medications using known indication relationships.
  4. Model-Agnostic Integration: Once pretrained, these logically sound embeddings can be plugged directly into the embedding tables of any downstream medication recommendation model (whether instance-based or longitudinal) without altering the downstream architecture.
Fig. 2: An excerpt of the ATC ontology. Some nodes are omitted.

Datasets

The framework was trained and evaluated using several publicly available datasets:

  • Ontologies: The ATC ontology for medications and the ICD9-CM ontology (split into separate sub-ontologies for diagnoses and procedures) sourced from BioPortal.
  • Alignment: The MEDI dataset, which provides ground-truth indication relationships between medications and diagnoses.
  • Downstream Evaluation: The benchmark MIMIC-III clinical dataset, containing records for over 35,000 patients.
  • Safety Evaluation: The TWOSIDES dataset, used to evaluate Drug-Drug Interaction (DDI) rates.

Key Insights and Ideas

  • Ontologies are DAGs, Not Undirected Graphs: Treating medical hierarchies as undirected graphs discards directional meaning. OntoMedRec preserves the strict asymmetry of parent-child and ancestor-descendant relationships.
  • The Importance of Sibling Rivalry: Sibling nodes share a parent classification but have distinct chemical or clinical properties. Explicitly modeling sibling relationships allows the encoder to learn what makes similar drugs different (e.g., dependency risks or specific side effects).
  • Scalable Symbolic AI: Pure logic-based neural frameworks often choke on large datasets. By designing an axiom-oriented sampling strategy, this paper demonstrates how symbolic reasoning can be scaled to large, real-world knowledge graphs.

Key Results

The authors integrated OntoMedRec into five prominent downstream medication recommendation models: LEAP, SafeDrug, MICRON, 4SDrug, and RETAIN.

  • Universal Performance Boost: OntoMedRec consistently improved the Jaccard coefficient and F1 scores across almost all baseline models on the entire MIMIC-III dataset.
  • Superiority in Few-Shot Scenarios: The most dramatic improvements occurred in the few-shot test set (medications in the lowest 30% frequency tier). For instance, when integrated with the RETAIN model in few-shot settings, the Jaccard score jumped from 0.5057 to 0.5229.
  • Sparsity Resilience: As shown in the paper's analysis, the performance gap between models utilizing OntoMedRec and those using randomly initialized tables widens as the data becomes scarser, proving its efficacy at mitigating the long-tail problem.
Performance comparison of OntoMedRec (omr) vs random embedding tables across different tail percentages.

Limitations and Future Work

While OntoMedRec successfully improves recommendation accuracy and maintains DDI (Drug-Drug Interaction) rates below the dataset's ground truth, it does not always achieve the absolute lowest DDI score compared to safety-specific baselines like SafeDrug. The authors note that while the embeddings are safer than raw clinical practice trends, explicitly optimizing for multi-drug safety constraints within the logical framework remains an open area for future enhancement.

Summary updated

BibTeX
@article{tan2024ontomedrec,
  author = {Weicong Tan and Weiqing Wang and Xin Zhou and Wray Buntine and Gordon Bingham and Hongzhi Yin},
  title = {{OntoMedRec: Logically-Pretrained Model-Agnostic Ontology Encoders for Medication Recommendation}},
  journal = {WWW},
  year = {2024},
  doi = {10.1007/s11280-024-01268-1},
}
Figure