Representing Molecules as Random Walks Over Interpretable Grammars

Michael Sun, Minghao Guo, Weize Yuan, Veronika Thost, Crystal Elaine Owens, Aristotle Franklin Grosz, Sharvaa Selvan, Katelyn Zhou, Hassan Mohiuddin, Benjamin J Pedretti, Zachary P Smith, Jie Chen, Wojciech Matusik

Abstract

Traditional molecular machine learning often struggles with large, complex "designer" molecules due to extreme data scarcity and high structural dependency. We introduce a hierarchical representation that treats molecules as random walks over a context-sensitive motif graph. By leveraging graph heat diffusion and expert-defined motifs, our method significantly improves property prediction and generative synthesizability on small, specialized datasets, outperforming state-of-the-art pretrained models.

Introduction

Most research in molecular machine learning focuses on small, drug-like molecules found in massive databases. However, critical applications—such as designing gas-separation membranes or high-efficiency photovoltaics—involve much larger, modular structures. These "designer molecules" present two major challenges: data scarcity (often fewer than 300 labeled examples) and structural complexity, where chemical behavior is highly dependent on the local context of functional groups (motifs).

Existing methods like Graph Neural Networks (GNNs) often require massive datasets to learn these relationships from scratch. Conversely, traditional "bag-of-motifs" approaches lose vital information regarding how those motifs are connected. This paper proposes a bridge between symbolic logic and deep learning to address these gaps.

Methodology

The proposed framework represents a molecule as a sequence of transitions—a random walk—over a structured "motif graph."

Decomposition of a complex molecule into a sequence of motifs and its representation as a path on a motif graph.

1. Motif Graph and Context-Sensitive Grammar

First, a motif graph $G$ is constructed where nodes represent chemical motifs and edges represent valid attachment points. Rather than using simple assembly rules, the model learns a context-sensitive grammar. This ensures that the probability of adding a new motif is conditioned on the existing structure, capturing long-range dependencies.

2. Learnable Heat Diffusion

The random walk is formulated as a graph heat diffusion process. The model learns a time-dependent Laplacian matrix that parameterizes transition probabilities. A set-based memory mechanism allows the model to "remember" previously visited nodes, adjusting the diffusion process based on the current assembly state.

The generative process modeled as a random walk over time, where each step selects a motif based on the current context and learned grammar.

3. Dual-Purpose Architecture

This representation is versatile: it can be integrated into a GNN (such as a Graph Isomorphism Network) for property prediction or sampled forward to generate novel, chemically valid, and synthesizable molecules.

Experimental Results

The study evaluated the model on three datasets characterized by complex structures and low volume: Group Contribution (GC) for membranes, Harvard Organic Photovoltaic (HOPV), and the Predictive Toxicology Challenge (PTC).

  • Superior Prediction: On the HOPV and GC datasets, the model outperformed state-of-the-art (SOTA) pretrained models like MolCLR and UniMol. It achieved an $R^2$ of 0.80 on GC, a significant improvement over the next best result of 0.70.
  • High Synthesizability: In generative tasks, the model produced molecules with a 39% higher Retro* Score (a measure of ease of synthesis) on the HOPV dataset compared to previous grammar-based methods.
  • Interpretability: The model allows for the extraction of "hard" symbolic rules, such as identifying specific moieties that increase toxicity, providing actionable insights for experimental chemists.

Discussion and Key Insights

The core innovation lies in the use of structural priors. By baking chemical validity into the motif graph, the model does not need to learn basic chemistry from scratch; it only needs to learn the specific design rules of the target dataset. Representing a molecule as a walk effectively treats it as a set of assembly instructions, making the model inherently interpretable.

Limitations and Future Work

While the model excels with expert-curated motifs, performance drops when using automatically generated heuristic motifs. This suggests a dependency on domain expertise that could be mitigated in the future by using Large Language Models (LLMs) to autonomously extract interpretable grammar rules. Additionally, improving the canonicalization of walks—ensuring a single molecule isn't represented by too many redundant paths—remains an area for further optimization.

Summary updated

BibTeX
@inproceedings{sun2024representing,
  author = {Michael Sun and Minghao Guo and Weize Yuan and Veronika Thost and Crystal Elaine Owens and Aristotle Franklin Grosz and Sharvaa Selvan and Katelyn Zhou and Hassan Mohiuddin and Benjamin J Pedretti and Zachary P Smith and Jie Chen and Wojciech Matusik},
  title = {{Representing Molecules as Random Walks Over Interpretable Grammars}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=gS3nc9iUrH},
}
Figure