Abstract
Optimising discrete data for a desired characteristic using gradient-based methods involves projecting the data into a continuous latent space and carrying out optimisation in this space. Carrying out global optimisation is difficult as optimisers are likely to follow gradients into regions of the latent space that the model has not been exposed to during training; samples generated from these regions are likely to be too dissimilar to the training data to be useful. We propose Constrained Optimisation with Latent Distributions (COLD), a constrained global optimisation procedure to find samples with high values of a desired property that are similar to yet distinct from the training data. We find that on MNIST, our procedure yields optima for each of three different objectives, and that enforcing tighter constraints improves the quality and increases the diversity of the generated images. On the ChEMBL molecular dataset, our method generates a diverse set of new molecules with drug-likeness scores similar to those of the highest-scoring molecules in the training data. We also demonstrate a computationally efficient way to approximate the constraint when evaluating it exactly is computationally expensive.
The Challenge of Latent Space Optimization
Optimizing discrete data, such as molecular graphs or text, presents a significant challenge because gradient-based optimization cannot be applied directly to discrete steps. A common solution is to use a Variational Autoencoder (VAE) to map these objects into a continuous latent space, where gradients can guide a search for points with high predicted scores for a target property (e.g., drug-likeness).
However, standard optimizers are inherently greedy. Without constraints, they often drift into "out-of-distribution" regions of the latent space—areas the model never encountered during training. When the decoder attempts to map these points back to discrete objects, the results are frequently invalid or unrealistic. Consequently, research has often been limited to local optimization (small tweaks to existing data) rather than true global discovery.
The COLD Methodology
To address this, we introduce COLD (Constrained Optimisation with Latent Distributions), a framework that maps the model's reliability to guide the search process. The approach consists of four key components:
- Predictive VAE (PVAE): A VAE and a property predictor are trained jointly, ensuring the latent space is organized by both structure and the target characteristic.
- The GMM Map: The training set is passed through the encoder to create a Gaussian Mixture Model (GMM). High-density regions in this GMM represent "safe zones" where the model is likely to produce realistic samples.
- Constrained Optimization: COLD performs global optimization subject to a density constraint: the GMM density must remain above a threshold ($\eta$).
- Efficient Approximation: To handle high-dimensional spaces, we use a K-Nearest Neighbors (KNN) approximation via the HNSW (Hierarchical Navigable Small World) algorithm, significantly accelerating density checks during optimization.
Experimental Results
MNIST: Quality and Diversity
We tested COLD on the MNIST dataset, specifically optimizing the digit "3" for three traits: rotation, thickness, and aspect ratio. To verify quality, we used an independent classifier trained on AffNIST to determine if the generated images remained recognizable as "3"s.
Our findings indicate that tighter density constraints (moving toward 0 on the log scale) counter-intuitively improve both quality and diversity. As shown in the figure above, tighter constraints lead to higher confidence from the independent classifier. Furthermore, while looser constraints often cause the optimizer to collapse into a few local optima, tighter constraints force the search to stay near various high-density "islands," preserving diversity across optimization runs.
Molecular Discovery on ChEMBL
On the ChEMBL dataset, COLD successfully generated novel molecules with Quantitative Estimate of Drug-likeness (QED) scores as high as 0.94, matching the top-tier molecules in the training set. Comparison of SMILES strings confirmed that these high-scoring molecules were not present in the training data, demonstrating true de novo discovery.
Conclusion and Future Work
COLD demonstrates that explicitly modeling training distribution density allows for effective global optimization in latent spaces. By building a "fence" around reliable regions, we can generate high-quality, novel samples.
Future work will address the current sampling bottleneck, as the method relies on initial grid points that may miss promising regions if not sampled optimally. Additionally, we aim to refine the sensitivity to sampling distribution variance and address memory constraints for scaling to even larger datasets.
Summary updated