Training-Free Guidance for Discrete Diffusion Models for Molecular Generation

Thomas J. Kerby, Kevin R. MoonarXiv 2024 · OpenReview

Abstract

Training-free guidance methods for continuous data have seen an explosion of interest due to the fact that they enable foundation diffusion models to be paired with interchangeable guidance models. Currently, equivalent guidance methods for discrete diffusion models are unknown. We present a framework for applying training-free guidance to discrete data and demonstrate its utility on molecular graph generation tasks using the discrete diffusion model architecture of DiGress. We pair this model with guidance functions that return the proportion of heavy atoms that are a specific atom type and the molecular weight of the heavy atoms and demonstrate our method's ability to guide the data generation.

Introduction

Diffusion models have established themselves as a premier method for high-quality data generation. However, in specialized fields like drug discovery, unconditional generation is insufficient; researchers require molecules with specific properties, such as target molecular weights or low toxicity.

Existing guidance techniques face significant barriers. Classifier guidance requires training auxiliary models to interpret extremely noisy intermediate states, while classifier-free guidance necessitates retraining the entire diffusion model for every new condition. Furthermore, while "training-free" guidance exists for continuous domains (e.g., images), it has been unavailable for discrete data like molecular graphs. Discrete diffusion models operate on categorical states, making standard mathematical shortcuts like Tweedie’s formula inapplicable.

Methodology

We introduce a framework for training-free guidance tailored for discrete diffusion, specifically utilizing the DiGress architecture. The approach bridges the gap between discrete and continuous guidance through three core components:

  1. Clean State Estimation: Instead of a mathematical shortcut, we use the diffusion model’s internal prediction ($p_\theta(x_0|x_t)$) to estimate the final clean graph ($\hat{x}_0$) from a noisy state.
  2. Guidance Function Application: We define a differentiable function $f$ that calculates a specific property (e.g., molecular weight) from the estimated clean graph.
  3. Gradient-Based Steering: During denoising, we calculate the gradient of the loss between the estimate’s property and the target. This gradient is used to shift the probability distribution for the next step toward the desired outcome.

Crucially, we found that a "one-sample" approximation—taking a single sample from the predicted clean distribution to calculate the gradient—is computationally efficient and sufficient for effective guidance.

Key Results

The framework was evaluated on the QM9 dataset (approx. 134,000 small organic molecules) across two primary tasks.

Node Attribute Guidance

The model was tasked with generating molecules with specific carbon atom proportions (0% or 100%). As shown in Figure 1, the guidance successfully steered the generation process. At high guidance scales ($\lambda = 100,000$), the generator achieved a 100% success rate in matching target atom proportions.

Visual examples of molecules generated with 0% (top) and 100% (bottom) carbon atom targets.

Molecular Weight Guidance

We targeted specific molecular weights, such as 105 and 135 Daltons. The model successfully shifted the average molecular weight of generated samples to meet these targets. To reach higher weights, the model autonomously increased the concentration of heavier atoms like Fluorine.

Quantitative results for molecular weight guidance, showing the relationship between guidance scale ($\lambda$), achieved weight, and validity.

As indicated in the results, the guidance scale ($\lambda$) acts as a balancing factor. While higher $\lambda$ values ensure the target property is met, extreme values can push the model "off the manifold," leading to a decrease in chemical validity as the model prioritizes the target property over learned structural rules.

Discussion and Conclusion

The primary contribution of this work is demonstrating that discrete diffusion models can be guided without retraining or specialized noisy classifiers. By leveraging the model's own posterior distribution, we can apply energy-based guidance logic previously reserved for continuous models.

While effective, the method has limitations. Extreme guidance can exacerbate the production of disconnected or invalid graphs. Future work will explore using trained neural networks as guidance functions for complex properties like bioactivity and extending this framework to other discrete domains, such as text generation.

Summary updated

Abstract

Training-free guidance methods for continuous data have seen an explosion of interest due to the fact that they enable foundation diffusion models to be paired with interchangable guidance models. Currently, equivalent guidance methods for discrete diffusion models are unknown. We present a framework for applying training-free guidance to discrete data and demonstrate its utility on molecular graph generation tasks using the discrete diffusion model architecture of DiGress. We pair this model with guidance functions that return the proportion of heavy atoms that are a specific atom type and the molecular weight of the heavy atoms and demonstrate our method's ability to guide the data generation.
BibTeX
@misc{kerby2024training,
  author = {Thomas J. Kerby and Kevin R. Moon},
  title = {{Training-Free Guidance for Discrete Diffusion Models for Molecular Generation}},
  year = {2024},
  eprint = {2409.07359},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2409.07359},
}
Figure