Molecule Design by Latent Prompt Transformer

Deqian Kong, Yuhao Huang, Jianwen Xie, Edouardo Honig, Ming Xu, Shuanghong Xue, Pei Lin, Sanping Zhou, Sheng Zhong, Nanning Zheng, Ying Nian Wu

TL;DR

The Latent Prompt Transformer (LPT) unifies molecule generation and property optimization into a single end-to-end framework, using a continuous latent vector as a prompt to guide a causal Transformer. By combining MCMC-based maximum likelihood estimation with an online distribution-shifting algorithm, LPT progressively generates molecules with highly optimized target properties, achieving state-of-the-art results across single-objective, multi-objective, and structure-constrained design tasks.

What Problem Does This Paper Address?

Designing molecules with specific biological or chemical properties is a cornerstone of drug discovery, but navigating the vast chemical space is notoriously difficult. A popular approach is Latent Space Optimization (LSO), which maps discrete molecular structures into a continuous, low-dimensional latent space (often using a Variational Autoencoder, or VAE) where optimization algorithms can search more easily.

However, traditional LSO methods suffer from a major drawback: decoupling. The generative model is trained completely separately from the property optimization stage. As a result, the learned latent space isn't tailored to the specific target properties you want to optimize. Furthermore, VAEs require an auxiliary encoder network for training, which introduces extra parameters and complexity.

This paper introduces the Latent Prompt Transformer (LPT) to solve these issues by unifying molecule generation and property prediction within a single, cohesive probabilistic framework.

Methods

LPT models the joint distribution of a molecule $x$ and its property $y$ via a shared continuous latent variable $z$, which acts as an information bottleneck. The architecture consists of three core components:

  1. A Learnable Prior Model $p_\alpha(z)$: Instead of a standard, uninformative Gaussian prior, LPT uses an implicit generator (parameterized by a 1D UNet) that transforms Gaussian white noise into an informative latent prompt space.
  2. A Molecule Generation Model $p_\beta(x|z)$: A 3-layer causal Transformer that treats the latent vector $z$ as a prompt, incorporating it at every step of autoregressive sequence generation via cross-attention mechanisms.
  3. A Property Predictor Model $p_\gamma(y|z)$: A small multi-layer perceptron (MLP) that predicts real-valued properties or binary constraints directly from the latent prompt.
Figure 1: Left: Overview of Latent Prompt Transformer (LPT). The latent vector z ∈Rd is a neural transformation of z0, i.e., z = Uα(z0), where z0 ∼N(0, Id). Given z, x and y are independent. pβ(x|z) is the molecule generation model and pγ(y|z) predicts the property value or constraint based on z. Right: Illustration of molecule generation model pβ(x|z). The latent vector z is used as a prompt in the pβ(x|z) via cross-attention.

Training and Optimization Loop

  • MCMC-based MLE: LPT eliminates the need for an auxiliary variational encoder network. Instead, it uses Markov chain Monte Carlo (MCMC) sampling—specifically Langevin dynamics—to sample from the exact posterior distribution $p(z_0|x,y)$ during Maximum Likelihood Estimation (MLE) training.
  • Online Learning via Distribution Shifting: To discover molecules that far exceed the properties present in the initial training data, the authors use an online learning loop. The model targets a property value slightly beyond its current boundary ($y^* + \delta_y$), infers the corresponding latent prompt, generates new candidate molecules, evaluates them using an external oracle, and adds them to a replay buffer to retrain the model.
  • Persistent Markov Chains (PMC): To overcome the computational overhead of MCMC, LPT initializes the sampling chains from the previous iteration's output rather than restarting from random noise, reducing the required MCMC steps from 15 down to 2 (a $5\times$ speedup).

Datasets

The authors evaluated LPT across several chemical and biological benchmarks:

  • ZINC (250K dataset): Used for offline pre-training of the molecular sequence generation model using SELFIES representations.
  • Design-Bench: Evaluated on TF Bind 8 (optimizing 8-base DNA sequences for binding affinity) and GFP (optimizing 237-amino acid protein sequences for fluorescence).
  • Practical Molecular Optimization (PMO): Used to evaluate sample efficiency under a strict budget of 10,000 oracle queries.
  • PHGDH-NAD (New Benchmark): The authors introduced a highly practical new task: designing molecules that bind to the NAD binding site of Phosphoglycerate dehydrogenase (PHGDH), a critical cancer therapeutic target. They manually processed data to ensure compatibility with AutoDock-GPU docking software.

Key Insights and Ideas

  • Latent Vectors as Prompts: Instead of using the latent vector merely to initialize a decoder, LPT feeds the latent vector into the Transformer via cross-attention at every generation step. This ensures the target property constraints tightly guide the entire autoregressive generation process.
  • The Power of Posterior Sampling: By treating optimization as a conditional sampling problem ($x \sim p(x|y)$), LPT can leverage Bayes' rule to infer the ideal latent prompt from a desired property value before generating the molecule.
  • Prioritized Retraining: During the online learning phase, LPT uses weighted retraining, assigning higher importance weights to synthetic molecules that achieve top property scores. This forces the generative model to focus its capacity on high-value regions of chemical space.

Key Results

LPT achieved state-of-the-art performance across single-objective, multi-objective, and structure-constrained optimization tasks.

Binding Affinity Maximization

When optimizing for binding affinity (measured by the dissociation constant $K_D$, where lower is better), LPT significantly outperformed strong baselines like LIMO and SGDS. On the newly proposed PHGDH target, LPT discovered molecules with exceptionally strong binding affinities:

Table 2: Single-objective binding affinity maxi- mization results for PHGDH, reporting the 1st, 2nd, and 3rd performance, along with average performance of top 50 and top 100 molecules for each model. Performance is measured by KD(10−2nM). The highest scores are in bold.

Online Distribution Shifting

The online learning algorithm successfully shifted the generated molecule distribution toward higher docking scores over successive iterations, demonstrating its ability to extrapolate effectively beyond the training data.

Figure 2: Illustration of online learning LPT. For each shift iteration, we plot the densities of docking scores E using AutoDock-GPU. The increase of the docking scores indicates better binding affinity.

Biological Sequence Design

On the Design-Bench tasks, LPT achieved a top performance score of 0.954 on TF Bind 8 (outperforming GFlowNet-AL's 0.84) and 0.857 on GFP (outperforming COMS' 0.831), while maintaining highly competitive sequence diversity.

Limitations and Future Work

While LPT demonstrates exceptional performance and sample efficiency, the authors note a few limitations:

  • Data Intensity: Generative models inherently require a substantial amount of data for initial training compared to purely heuristic or genetic algorithms, which can create a performance gap when working under extremely tight data budgets without pre-training.
  • Multi-Objective Trade-offs: While LPT handles multi-objective tasks via heuristic combinations, future work is needed to better characterize and navigate the exact Pareto front of optimal solutions.
  • Alternative Architectures: The current model relies on sequence-based representations (SMILES/SELFIES); extending the latent prompt framework to graph- or 3D-based molecular architectures remains an open area for exploration.

Summary updated

Abstract

This work explores the challenging problem of molecule design by framing it as a conditional generative modeling task, where target biological properties or desired chemical constraints serve as conditioning variables. We propose the Latent Prompt Transformer (LPT), a novel generative model comprising three components: (1) a latent vector with a learnable prior distribution modeled by a neural transformation of Gaussian white noise; (2) a molecule generation model based on a causal Transformer, which uses the latent vector as a prompt; and (3) a property prediction model that predicts a molecule's target properties and/or constraint values using the latent prompt. LPT can be learned by maximum likelihood estimation on molecule-property pairs. During property optimization, the latent prompt is inferred from target properties and constraints through posterior sampling and then used to guide the autoregressive molecule generation. After initial training on existing molecules and their properties, we adopt an online learning algorithm to progressively shift the model distribution towards regions that support desired target properties. Experiments demonstrate that LPT not only effectively discovers useful molecules across single-objective, multi-objective, and structure-constrained optimization tasks, but also exhibits strong sample efficiency.
BibTeX
@inproceedings{kong2024molecule,
  author = {Deqian Kong and Yuhao Huang and Jianwen Xie and Edouardo Honig and Ming Xu and Shuanghong Xue and Pei Lin and Sanping Zhou and Sheng Zhong and Nanning Zheng and Ying Nian Wu},
  title = {{Molecule Design by Latent Prompt Transformer}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=dg3tI3c2B1},
}
Figure