MAGNet: Motif-Agnostic Generation of Molecules from Scaffolds

Leon Hetzel, Johanna Sommer, Bastian Rieck, Fabian J Theis, Stephan Günnemann

Introduction

Recent advances in machine learning for molecules exhibit great potential for facilitating drug discovery. However, most state-of-the-art molecular generative models rely on a "motif-based" approach. They decompose molecules into a vocabulary of frequently occurring substructures—like benzene rings or common carbon chains—and then assemble them to create new compounds.

While this aids in learning molecular distributions, it creates a "vocabulary ceiling." To keep models computationally efficient, vocabularies are usually limited to the top-$k$ most frequent motifs. If a molecule contains an uncommon structure (like a complex junction found in a new FDA-approved drug), the model must resort to building it atom-by-atom, which frequently fails.

MAGNet separates structure from features to overcome the limitations of fixed motif vocabularies, allowing it to capture key structures missed by traditional generative models.

To address this limitation, researchers introduce MAGNet, a "motif-agnostic" approach to molecule generation. By separating a molecule's structural skeleton (scaffold) from its chemical features (atom and bond types), MAGNet achieves superior structural expressivity and successfully reconstructs complex drug-like molecules that traditional models miss.

The MAGNet Pipeline: Separating Structure from Features

The core innovation of MAGNet is the separation of structure from features. Instead of picking a specific "Chlorine-substituted Benzene" from a predefined list, MAGNet first predicts a generic 6-membered ring (the scaffold) and then "paints" the features onto it.

  1. Scaffold-Level Generation: The model predicts a multiset of scaffolds (untyped structural skeletons) and their connectivity.
  2. Atom-Level Refinement: It then "freely learns" the featurization, assigning atom types to the scaffold nodes and bond types to the edges.
  3. Hierarchical Factorization: The authors derive a novel mathematical factorization of the molecular data distribution that breaks the process into: Scaffolds $\rightarrow$ Connectivity $\rightarrow$ Motifs $\rightarrow$ Join Nodes $\rightarrow$ Leaf Nodes.
  4. Architecture: MAGNet is built as a Variational Autoencoder (VAE) using Graph Transformers. To prevent "latent space collapse" (where the model ignores the latent code), they employ Conditional Flow Matching (CFM) to ensure a smooth and highly active latent space.

Key Insights

  • The "Top-k" Trap: The standard Fréchet ChemNet Distance (FCD) metric can be misleading. A model can achieve a high FCD score by simply mastering the most common scaffolds, even if it fails completely on the rest of the chemical space.
  • Structure is Simpler than Motifs: By abstracting motifs into scaffolds, the model reduces combinatorial complexity. There are far fewer unique "skeletons" than there are "skeletons + chemical types."
  • Motif-Agnosticism: Because MAGNet doesn't rely on a fixed motif set, it can generate novel motifs it has never explicitly seen, provided it understands the underlying scaffold.
  • Latent Fidelity: MAGNet shows a much higher correlation between its latent space and the resulting output. Moving a small distance in the latent space changes the molecule in a consistent, predictable way, which is vital for drug optimization.

Key Results and Performance

The model was primarily trained and evaluated on standard datasets like ZINC, alongside QM9, GuacaMol, CheMBL, and L1000 for zero-shot transferability tests.

MAGNet successfully decodes uncommon scaffolds that baseline models like MoLeR, PS-VAE, and MiCaM fail to reconstruct.
  • Superior Reconstruction: MAGNet significantly outperforms baselines in reconstructing uncommon scaffolds, such as large rings and complex junctions.
  • Distribution Matching: While other models tend to "hallucinate" structures or oversample common ones, MAGNet’s sampled molecules closely match the actual frequency of scaffolds found in the training data.
  • Benchmark Performance: On the GuacaMol benchmark, MAGNet outperformed all other graph-based models on the FCD metric and showed competitive results in goal-directed generation (optimizing for specific properties like QED or logP).
  • Zero-Shot Transfer: MAGNet demonstrated a 20% improvement over the strongest baseline in similarity scores when tested on entirely new datasets, proving its structural logic generalizes well.

Limitations and Future Work

Like many hierarchical models, MAGNet suffers from potential error propagation; if it makes a mistake at the scaffold level, subsequent atom and bond assignments cannot fix the underlying structural error. Furthermore, while the model generates diverse structures, it does not explicitly account for synthesizability in a wet lab. Integrating synthesizability constraints or extending this scaffold-first approach to 3D conformer generation represent promising directions for future structure-based drug design.

Summary updated

BibTeX
@inproceedings{hetzel2025magnet,
  author = {Leon Hetzel and Johanna Sommer and Bastian Rieck and Fabian J Theis and Stephan Günnemann},
  title = {{MAGNet: Motif-Agnostic Generation of Molecules from Scaffolds}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=5FXKgOxmb2},
}
Figure