GraphAF: a Flow-based Autoregressive Model for Molecular Graph Generation

Chence Shi, Minkai Xu, Zhaocheng Zhu, Weinan Zhang, Ming Zhang, Jian Tang

TL;DR

GraphAF is a novel generative model for molecules that combines the parallel training efficiency of Normalizing Flows with the structural validity of Autoregressive generation. It achieves state-of-the-art results in molecular property optimization while training twice as fast as previous leading methods like GCPN.

The Challenge of Molecular Generation

Designing new drugs is a classic "needle in a haystack" problem. The chemical space of potential drug-like molecules is estimated at $10^{33}$—far too large for exhaustive search. Researchers need generative models that can:

  1. Generate valid structures: Molecules must obey the strict laws of chemistry (valency).
  2. Optimize properties: We don't just want any molecule; we want ones that are soluble, non-toxic, and drug-like.
  3. Train efficiently: Many existing models are either slow to train (sequential RNNs) or struggle to produce valid structures (one-shot GANs/Flows).

Previous "one-shot" flow models (like GraphNVP) generate the entire graph at once, which often leads to "broken" molecules because they can't check chemical rules during the process. Conversely, autoregressive models (like GCPN) generate molecules step-by-step, ensuring validity but making training painfully slow because each step depends on the previous one.

Methods: The GraphAF Approach

GraphAF (Graph Autoregressive Flow) proposes a hybrid approach. It defines an invertible, flow-based transformation between a base Gaussian distribution and the discrete structure of a molecular graph.

  • The Flow Mechanism: By using a normalizing flow, the model can compute the exact likelihood of a molecule. Because the transformation is designed with a triangular Jacobian (similar to MAF or MADE), the training can be done in parallel across all nodes and edges using masking.
  • Sequential Generation: During sampling, the model acts autoregressively, generating one node or edge at a time. This allows the authors to bake in valency constraints: if the model proposes a bond that violates chemical rules, it is simply rejected and resampled.
GraphAF Framework: Parallel Training and Sequential Sampling
  • Dequantization: Since flows operate on continuous data and molecules are discrete (atoms and bonds), the authors use a dequantization technique—adding uniform noise to the discrete features—to map them into a continuous space.
  • Reinforcement Learning (RL): To steer the model toward specific goals (like high solubility), the authors fine-tune the pre-trained GraphAF using Proximal Policy Optimization (PPO).

Key Insights

  • The Best of Both Worlds: The core "aha moment" is that you can have parallel training (via the flow's change-of-variables formula) and sequential sampling (via the autoregressive structure) in the same model. This solves the efficiency-validity trade-off.
  • Learning Chemistry vs. Hard-coding it: While GraphAF achieves 100% validity with chemical rules, it achieves 68% validity without them. This is significantly higher than previous state-of-the-art models (GCPN only managed 20% without rules), suggesting that the flow-based density estimation is much better at capturing the underlying distribution of "what a molecule looks like."
  • Efficiency Matters: Training GraphAF is roughly 2x faster than GCPN. In the world of deep learning, where iteration speed is everything, this is a major practical advantage.

Key Results

GraphAF was evaluated on standard benchmarks including ZINC250k, QM9, and MOSES, as well as generic graph datasets.

  • Validity & Novelty: On the ZINC dataset, GraphAF achieved 100% validity (with rules), 99.1% uniqueness, and 100% novelty.
Performance Comparison on ZINC250k
  • Property Optimization: In the task of maximizing "penalized logP" (a measure of solubility and synthetic accessibility), GraphAF found molecules with a score of 12.23, shattering the previous record held by MRNN (8.63) and GCPN (7.98).
  • Constrained Optimization: When tasked with taking an existing molecule and improving it slightly while maintaining structural similarity, GraphAF significantly outperformed JT-VAE and GCPN across all similarity thresholds.

Limitations and Future Work

  • Graph Size: The experiments were limited to molecules with up to 48 atoms. While this covers most drug-like molecules, scaling to much larger proteins or polymers remains a challenge.
  • Dequantization Complexity: The authors used simple uniform dequantization. They suggest that more advanced variational dequantization could potentially improve the model's density estimation further.
  • Beyond Molecules: While the paper focuses on chemistry, the underlying architecture is a general graph generator. The authors express interest in applying GraphAF to other domains, such as social network modeling or citation graphs.

Summary updated

BibTeX
@inproceedings{shi2020graphaf,
  author = {Chence Shi and Minkai Xu and Zhaocheng Zhu and Weinan Zhang and Ming Zhang and Jian Tang},
  title = {{GraphAF: a Flow-based Autoregressive Model for Molecular Graph Generation}},
  booktitle = {International Conference on Learning Representations},
  year = {2020},
  url = {https://openreview.net/forum?id=JNTeTB1mW7J},
}
Figure