Knowledge graph-enhanced molecular contrastive learning with functional prompt

Yin Fang, Qiang Zhang, Ningyu Zhang, Zhuo Chen, Xiang Zhuang, Xin Shao, Xiaohui Fan, Huajun Chen

Abstract

Predicting molecular properties is a cornerstone of digital drug discovery, yet many deep learning models treat molecules as abstract graphs, neglecting fundamental chemical principles. We present KANO (Knowledge graph-enhanced molecular contrastive learning with functional prompt), a framework that integrates a chemical element-oriented knowledge graph into molecular representation learning. KANO employs element-guided augmentation for pre-training and task-specific functional prompts for fine-tuning. Our results across 14 benchmarks demonstrate that KANO significantly outperforms existing self-supervised learning methods, particularly in data-scarce scenarios and regression tasks.

Introduction

The "holy grail" of digital drug discovery is the accurate prediction of molecular behavior—ranging from toxicity and solubility to protein inhibition. While deep learning has advanced this field, many current models remain "chemically illiterate." They process molecules as mathematical graphs without incorporating over a century of chemical intuition.

Most molecular models utilize Self-Supervised Learning (SSL), pre-training on large unlabeled datasets by applying random perturbations to molecular graphs (e.g., atom or bond removal). However, chemistry is inherently fragile. Unlike computer vision, where a cropped image of a cat remains a cat, removing a single atom or altering a bond in a molecule can fundamentally change its identity and properties. Standard data-driven augmentations often violate chemical semantics, introducing noise. Furthermore, a "task gap" exists between general pre-training and the specific nuances required for downstream property prediction.

The KANO Framework

To address these limitations, the KANO framework introduces three primary innovations designed to infuse deep learning with chemical domain knowledge.

Overview of the KANO framework, including ElementKG construction, contrastive pre-training, and prompt-enhanced fine-tuning.

1. ElementKG: The Chemical Knowledge Base

The foundation of KANO is ElementKG, a specialized Knowledge Graph constructed from the Periodic Table and Wikipedia. Rather than a simple list, ElementKG maps complex relationships between elements, such as shared periods, similar electronegativity, and their roles within functional groups—the specific atomic clusters (e.g., carboxyl or phenyl groups) that dictate chemical behavior.

2. Element-Guided Augmentation

During pre-training, KANO avoids random graph destruction. Instead, it uses ElementKG to perform "element-guided augmentation." By adding "virtual" edges between atoms that share chemical similarities or belong to the same element class, the model explores microscopic atomic associations while preserving the molecule's underlying chemical identity. This contrastive learning approach ensures the model learns representations that are both robust and chemically meaningful.

3. Functional Prompts and Fine-Tuning

Borrowing from "prompt-tuning" in Natural Language Processing, KANO utilizes functional prompts during the fine-tuning phase. The model detects functional groups within a target molecule, retrieves their corresponding embeddings from the Knowledge Graph, and employs a self-attention "mediator" to inject this context into the pre-trained encoder. This process "stimulates" the model to recall task-relevant chemical knowledge, effectively bridging the gap between general structure and specific properties.

Experimental Evaluation

KANO was pre-trained on 250,000 unlabeled molecules from the ZINC15 database. Its performance was evaluated across 14 major benchmarks from MoleculeNet, spanning four domains:

  • Physiology: BBBP, Tox21, ToxCast, SIDER, ClinTox.
  • Biophysics: BACE, MUV, HIV.
  • Physical Chemistry: ESOL, FreeSolv, Lipophilicity.
  • Quantum Mechanics: QM7, QM8, QM9.

Results and Discussion

KANO achieved state-of-the-art (SOTA) performance across all 14 datasets. Key findings include:

  • Data Efficiency: On small datasets like ESOL and FreeSolv, KANO showed an average improvement of 21.7% over baselines. This suggests that the Knowledge Graph acts as a powerful regularizer, compensating for a lack of labeled data.
  • Regression Performance: The model demonstrated a 15.8% relative improvement across six regression tasks, highlighting its precision in predicting continuous physical and quantum values.
  • Interpretability: The attention mechanism within the functional prompts allows researchers to visualize which chemical groups drive specific predictions. For instance, in toxicity prediction (Tox21), the model correctly identified "azo" groups—known carcinogens—as high-importance features.
  • Latent Space Quality: t-SNE visualizations confirmed that KANO clusters molecules with similar scaffolds more effectively than purely data-driven models, indicating a superior understanding of molecular similarity.

Conclusion

KANO represents a significant step toward "chemically-aware" AI. By integrating structured domain knowledge through ElementKG and functional prompting, the framework overcomes the fragility of standard graph augmentations and the limitations of small-scale labeled data. Future work will explore expanding ElementKG to include macromolecular systems and drug-disease associations, further enhancing the model's utility in complex drug discovery pipelines.

Summary updated

BibTeX
@article{fang2023knowledge,
  author = {Yin Fang and Qiang Zhang and Ningyu Zhang and Zhuo Chen and Xiang Zhuang and Xin Shao and Xiaohui Fan and Huajun Chen},
  title = {{Knowledge graph-enhanced molecular contrastive learning with functional prompt}},
  journal = {Nat. Mac. Intell.},
  year = {2023},
  doi = {10.1038/s42256-023-00654-0},
}
Figure