π Introduction
proGENTRL is a PyTorch Lightning implementation of Generative Tensorial Reinforcement Learning (GENTRL) β a deep generative model designed to explore chemical space and propose novel molecules with desirable properties, such as synthetic feasibility and biological activity.
This blog post walks through what proGENTRL is, how it works, whatβs inside the repository, and how you can get started building and experimenting with it.
Repository: github.com/Bibyutatsu/proGENTRL
π§ What is GENTRL?
Generative Tensorial Reinforcement Learning (GENTRL) is a two-stage model developed for de novo small-molecule design. The original research demonstrated that GENTRL could:
- Optimize synthetic feasibility, novelty, and biological activity of molecules.
- Generate novel small-molecule inhibitors for the DDR1 kinase target within a matter of weeks.
The model combines a Variational Autoencoder (VAE) with reinforcement learning (RL). Initially, the VAE is trained on a dataset of molecules, learning a smooth latent representation of chemical space. Then, an RL agent explores this latent space to find points that decode into molecules with high reward as defined by property-based scoring.
Research Paper: Deep learning enables rapid identification of potent DDR1 kinase inhibitors - Nature Biotechnology, 2019
π§ Why It Matters
Chemical space β the total set of possible small molecules β is astronomically large. Traditional in-silico screening methods can only explore a tiny fraction of this. Models like GENTRL use deep learning to generalize learning from existing molecules and guide exploration toward regions that satisfy multiple objectives (like drug-likeness, activity against a target, or synthesis feasibility).
This makes such models powerful tools in drug discovery, materials design, and other chemistry-driven fields.
π¦ Whatβs Inside the proGENTRL Repository
Hereβs a high-level look at the repository structure:
proGENTRL/
ββ images/ # Images shown in README
ββ progentrl/ # Core model and training implementation
ββ Example.ipynb # Demo notebook with workflow
ββ README.md # Project information & installation
ββ setup.py # Install script
ββ LICENSE # MIT License
Key Components
| Component | Description |
|---|---|
| VAE Module | Encodes/decodes SMILES strings to/from latent space |
| RL Module | Reinforcement learning for latent space optimization |
| Tokenizer | Custom SMILES tokenizer for molecular strings |
| Trainer | PyTorch Lightning training loops |
π οΈ Installation & Setup
Follow these steps to get proGENTRL running:
Step 1 β Create Conda Environment
Install RDKit, which is required for molecule handling:
conda create -c rdkit -n progentrl-env rdkit
conda activate progentrl-env
Step 2 β Install proGENTRL
Option A: Install via pip:
pip install progentrl
Option B: Install from source:
git clone https://github.com/Bibyutatsu/proGENTRL.git
cd proGENTRL
python3 setup.py install
Step 3 β Install PyTorch
Install PyTorch with the appropriate CUDA version:
python3 -m pip uninstall torch torchvision
conda install pytorch torchvision cudatoolkit=11.3 -c pytorch
Replace cudatoolkit=11.3 with your CUDA version.
Step 4 β (Optional) Setup Jupyter Kernel
python3 -m pip install ipykernel
python3 -m ipykernel install --user --name progentrl
This makes it easy to run notebooks with the correct environment.
π§ͺ Example Workflow
The included Example.ipynb demonstrates the core workflow:
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββ
β Pretrain VAE β βββΆ β Freeze Weights β βββΆ β Reinforcement Learning β βββΆ β Sample SMILES β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββββββββββ βββββββββββββββββββ
- Pretrain the VAE: Learn a latent representation of molecules.
- Freeze VAE weights: Lock them except for the prior.
- Run Reinforcement Learning: Search the latent space for high-reward vectors.
- Sample SMILES strings: Decode optimized latent points into candidate molecules.
This notebook is the recommended starting point to understand how the model flows from training to molecule generation.
π Core Concepts Explained
Variational Autoencoder (VAE)
A VAE encodes molecules (e.g., SMILES strings) into a continuous latent space and decodes back to molecule representations. The learning objective encourages the latent space to be smooth and meaningful.
SMILES Input β Encoder β Latent Space (z) β Decoder β SMILES Output
β β β
"CCO" β [0.2, -0.5, 1.3, ...] β "CCO"
Reinforcement Learning (RL) Optimization
Once pretrained, the VAEβs weights are mostly frozen. Reinforcement learning is applied on top of the latent representation:
- A reward function guides the agent toward latent points that decode into molecules with desired properties.
- The exploration is driven by a reward score (e.g., drug-likeness, synthetic accessibility).
π§ Real-World Performance
The original GENTRL research found potent DDR1 inhibitors in a short timeframe β generating molecules with promising activity and validating them experimentally in biochemical and cellular assays.
Generated Molecules Examples
Below are examples of molecules generated by the model:

More samples available here
This provides an exciting example of how generative models can accelerate the early stages of drug discovery.
π§ Extending proGENTRL
Here are ways to enhance the project:
π― Better Reward Functions
Design multi-objective reward functions that incorporate:
- Predicted biological target affinity
- Synthetic accessibility scores
- Drug-like metrics (e.g., QED, logP, Lipinski scores)
βοΈ Advanced Generative Models
Beyond VAEs, you can explore:
- Transformer-based generative models β Attention mechanisms for sequential SMILES
- Graph neural networks β Molecular graph representations
- Diffusion models β State-of-the-art generative approach
These can bring richer representations and better optimization.
π‘ Final Thoughts
The proGENTRL repository provides a strong starting point to experiment with deep generative models and reinforcement learning in chemistry. Whether youβre exploring de novo drug design or generative modeling, this PyTorch Lightning implementation gives you a practical and modifiable codebase to build from.
Why PyTorch Lightning?
PyTorch Lightning offers:
- Clean separation of research code from engineering
- Multi-GPU support out of the box
- Reproducibility through standardized training loops
- Reduced boilerplate β focus on the model, not infrastructure
π Resources
- proGENTRL Repository: github.com/Bibyutatsu/proGENTRL
- Original GENTRL: github.com/insilicomedicine/gentrl
- My GENTRL Fork: github.com/Bibyutatsu/GENTRL
- Research Paper: Nature Biotechnology Publication
| *Originally published: June 7, 2020 | Updated: January 2025* |