A Reinforcement Learning-Driven Transformer GAN for Molecular Generation

Chen Li, Huidong Tang, Ye Zhu, Yoshihiro YamanishiarXiv 2025 · DOI

Abstract

Generating molecules with desired chemical properties presents a critical challenge in fields such as chemical synthesis and drug discovery. Recent advancements in artificial intelligence (AI) and deep learning have significantly contributed to data-driven molecular generation. However, challenges persist due to the inherent sensitivity of simplified molecular input line entry system (SMILES) representations and the difficulties in applying generative adversarial networks (GANs) to discrete data. This study introduces RL-MolGAN, a novel Transformer-based discrete GAN framework designed to address these challenges. Unlike traditional Transformer architectures, RL-MolGAN utilizes a first-decoder-then-encoder structure, facilitating the generation of drug-like molecules from both de novo and scaffold-based designs. In addition, RL-MolGAN integrates reinforcement learning (RL) and Monte Carlo tree search (MCTS) techniques to enhance the stability of GAN training and optimize the chemical properties of the generated molecules. To further improve the model's performance, RL-MolWGAN, an extension of RL-MolGAN, incorporates Wasserstein distance and mini-batch discrimination, which together enhance the stability of the GAN. Experimental results on two widely used molecular datasets, QM9 and ZINC, validate the effectiveness of our models in generating high-quality molecular structures with diverse and desirable chemical properties.

Introduction

Designing novel therapeutic agents is often likened to searching for a needle in a haystack, where the "haystack" represents the vast chemical space of potential drug-like molecules. While Generative Adversarial Networks (GANs) have shown promise in navigating this space, they face significant hurdles when dealing with discrete data like SMILES (Simplified Molecular Input Line Entry System) strings. In SMILES, even a minor character substitution can render a molecule chemically invalid. Furthermore, the non-differentiable nature of discrete token selection prevents the direct backpropagation of gradients from a discriminator to a generator.

To address these limitations, we present RL-MolGAN, a framework that synergizes Transformer architectures with Reinforcement Learning (RL) and Monte Carlo Tree Search (MCTS) to produce high-quality, valid, and property-optimized molecular structures.

Methodology: The RL-MolGAN Framework

RL-MolGAN departs from standard Transformer configurations by employing a "first-decoder-then-encoder" structure. In this setup, the Transformer decoder acts as the generator ($G_\theta$), producing SMILES strings character by character. Conversely, the Transformer encoder serves as the discriminator ($D_\phi$), evaluating the authenticity of the generated sequences.

Overview of the RL-MolGAN framework, illustrating de novo and scaffold-based generation, the Transformer-based GAN architecture, and the RL-MCTS reward loop.

Scaffold-Based Generation and Positional Encoding

A key innovation in RL-MolGAN is its ability to perform both de novo generation and scaffold-based design. To facilitate the latter, the model utilizes a specialized positional encoding scheme involving Segment IDs and Offset IDs. This allows the generator to distinguish between the fixed scaffold (the core structure) and the functional groups to be added, ensuring structural integrity during the expansion process.

Detailed view of the scaffold-based generation process, highlighting the use of Segment and Offset IDs to manage attachment points.

Stabilizing GANs with RL and MCTS

To overcome the gradient bottleneck of discrete data, RL-MolGAN treats SMILES generation as a sequence of actions in a reinforcement learning environment. Monte Carlo Tree Search (MCTS) is employed to provide intermediate rewards during the generation process. By performing "rollouts" to complete partial strings, MCTS allows the model to estimate the long-term value of a specific character choice, guiding the generator toward valid and high-scoring chemical structures.

The reward function is multi-faceted, incorporating feedback from the discriminator alongside specific chemical property scores, such as QED (drug-likeness), LogP (solubility), and SA (synthetic accessibility). To further stabilize training, the RL-MolWGAN extension incorporates Wasserstein distance and mini-batch discrimination to prevent mode collapse.

Experimental Results

The model was rigorously evaluated using the QM9 and ZINC datasets, focusing on molecules with up to nine heavy atoms.

Performance Benchmarks

RL-MolGAN demonstrated significant improvements over existing baselines:

  • Scaffold-Based Success: On the ZINC dataset, RL-MolGAN achieved a total score (validity × uniqueness × novelty) of 80.4%, surpassing the MoLeR model's 73.5%.
  • Property Optimization: In de novo tasks, the model outperformed the ORGAN baseline by 23.6% in QED and 32.4% in SA scores, indicating a superior ability to generate practical drug candidates.
  • Targeted Generation: In a case study targeting the dopamine receptor D2 (DRD2), RL-MolGAN successfully shifted the distribution of generated molecules toward higher bioactivity scores, proving its utility in goal-directed lead optimization.

Conclusion

RL-MolGAN represents a significant step forward in discrete molecular generation. By combining the sequence-modeling strengths of Transformers with the strategic foresight of MCTS and RL, the framework achieves high chemical validity and property optimization. While the computational cost of MCTS rollouts remains a challenge, future work focusing on more robust representations like SELFIES and the integration of 3D structural data holds promise for further expanding the boundaries of AI-driven drug discovery.

Summary updated

BibTeX
@misc{li2025reinforcement,
  author = {Chen Li and Huidong Tang and Ye Zhu and Yoshihiro Yamanishi},
  title = {{A Reinforcement Learning-Driven Transformer GAN for Molecular Generation}},
  year = {2025},
  eprint = {2503.12796},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.12796},
}
Figure