Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Proposing new molecules and crystals
Only a tiny fraction of possible molecules and crystals has ever been made, so chemists want models that suggest promising candidates. A generative model learns from known structures what a plausible structure looks like and proposes new ones. The catch is that chemistry has hard rules: each atom can form only so many bonds, a crystal must be charge-neutral and atoms cannot overlap. A model that ignores them produces impossible structures, so generators build in the rules, by construction or by checking as they go. The demo generates small graphs of carbon, nitrogen and oxygen with and without a valence constraint and marks the ones that break it.
The same pipelines are used for battery and catalyst materials, radiation-tolerant alloys for spacecraft, propellants and lightweight structural compounds: the generator proposes, cheap models screen, and simulation or synthesis confirms.
- 1. A hard constraint on molecules is…
- 2. A generative model for molecules proposes…
- 3. Generated candidates are usually…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.Representations, models and metrics
- Strings: SMILES with a character VAE or RNN (Gomez-Bombarelli et al., 2018; Segler et al., 2018) is simple but many strings are invalid. SELFIES (Krenn et al., 2020) is designed so that every string decodes to a molecule.
- 2-D graphs: Junction Tree VAE (Jin, Barzilay and Jaakkola, 2018) assembles chemically valid fragments; GraphAF (Shi et al., 2020) is an autoregressive flow with valency masks; DiGress (Vignac et al., 2023) is a discrete diffusion model over atom and bond types.
- 3-D structures: E(3)-equivariant diffusion (EDM, Hoogeboom et al., 2022) generates coordinates and types together; equivariance means a rotated input gives the rotated output, which removes the need to learn rotations from data.
- Biology: RFdiffusion (Watson et al., Nature 2023) designs protein backbones, with designs validated experimentally; DiffDock (Corso et al., 2023) treats molecular docking as generative pose sampling over translations, rotations and torsions; AlphaFold 3 (Abramson et al., Nature 2024) predicts complexes with a diffusion module over atom coordinates.
- Materials: CDVAE (Xie et al., 2022) and DiffCSP diffuse fractional coordinates, types and the lattice; MatterGen (Zeni et al., Nature 2025) is a diffusion model conditioned on chemistry, symmetry and properties such as bulk modulus or magnetic density; GNoME (Merchant et al., Nature 2023) used generation plus graph-network energy prediction and DFT checks to propose about 2.2 million stable candidate crystals.
- Conditioning: property guidance, conditional training, fine-tuning on a target class, or reinforcement learning on a docking or energy score; inverse design means asking for structures with a property, not screening a fixed library.
- Metrics: validity, uniqueness, novelty, distribution match (atom and bond statistics, ring sizes, fragment or scaffold overlap, Frechet ChemNet distance), and for crystals the energy above the convex hull from DFT. Benchmarks include MOSES and GuacaMol for molecules and Matbench Discovery for materials.
- Known failure modes: valid but strained or unsynthesisable molecules, memorised training structures, metrics gamed by trivial samples, and screening models that are confidently wrong off their training distribution.
- 1. SELFIES was designed so that…
- 2. E(3)-equivariant diffusion generates…
- 3. For crystals, stability is usually judged by…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.Checking what a generator produced
Exercise 1.
- A valence and connectivity validity check.
- The smallest ring size (girth) of a molecular graph.
- A Weisfeiler-Lehman hash for counting distinct molecules.
Practice.
- Report validity, uniqueness and novelty together: each alone is trivial to maximise.
- Compare distributions, not only averages: ring sizes, atom and bond counts, scaffolds, and a learned distance such as Frechet ChemNet distance.
- Deduplicate with a canonical form (canonical SMILES, InChI) or a graph hash; check how many generated structures are in the training set.
- Build hard constraints into the sampler (valency masks, charge balance, minimum interatomic distances) rather than filtering afterwards.
- Screen with a model and then verify with simulation (DFT, docking, molecular dynamics); report how many candidates survive each stage, not only the first.
- Check synthesisability (retrosynthesis scores, SA score) and strain before claiming a hit.
import torch
# a valency mask for autoregressive graph generation: forbid bonds that would exceed remaining valence
def bond_logits(logits, remaining, new_atom_remaining):
mask = (remaining <= 0) | (new_atom_remaining <= 0) # per existing atom
return logits.masked_fill(mask, float("-inf"))
# equivariant 3-D diffusion keeps the centre of mass fixed so the model is translation-invariant
def zero_com(x):
return x - x.mean(dim=-2, keepdim=True)- 1. Uniqueness alone can be maximised by…
- 2. Hard constraints are best enforced…
- 3. Candidate crystals are verified with…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Why independent bonds fail. If every pair of n atoms is bonded independently with probability p, the degree of an atom is Binomial(n − 1, p) with mean (n − 1)p. Validity needs every degree below its valence and the graph connected. For n = 8 and p = 0.34 the mean degree is 2.4 but the probability that all eight atoms stay within valence is small, and it falls quickly with n: errors multiply over atoms.
Autoregressive masking. Building the graph atom by atom, always bonding the new atom to one with free valence, keeps the partial graph connected and within valence at every step, so every sample is valid by construction. Masking is the discrete analogue of a projection onto the constraint set.
Valid is not realistic. Constraints are necessary, not sufficient. A valence-correct generator can still place three- and four-membered rings, which are valid graphs but highly strained and almost absent from drug-like molecules. Only a model that learns the ring-size distribution matches the data.
Equivariance. If a model’s prediction satisfies f(Rx + t) = R f(x) + t for rotations R and translations t, then the generated distribution is invariant to the pose of the molecule, so the model does not waste capacity learning rotations and generalises from fewer examples.
Metric gaming. Validity, uniqueness and novelty are each maximisable alone: a valence-masked chain generator can reach 100% validity, high uniqueness and high novelty while producing nothing a chemist would want. Distribution-level metrics and downstream simulation are what make the claim meaningful.
Exercise check. The toy data had bond density 0.339 and a ring in 30% of molecules; the one-shot model matched both in expectation yet was valid only 21% of the time.
- 1. Independent bonds break valence more often as molecules get…
- 2. Autoregressive valency masking gives validity…
- 3. 100% validity with high novelty proves…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.Does enforcing chemical constraints make a generator good, and what do validity metrics miss?
History.
- R. Gomez-Bombarelli et al., “Automatic chemical design using a data-driven continuous representation of molecules” (ACS Central Science, 2018).
- W. Jin, R. Barzilay and T. Jaakkola, “Junction tree variational autoencoder for molecular graph generation” (ICML 2018).
- M. Krenn, F. Hase, A. Nigam, P. Friederich and A. Aspuru-Guzik, “Self-referencing embedded strings (SELFIES)” (2020).
- E. Hoogeboom, V. G. Satorras, C. Vignac and M. Welling, “Equivariant diffusion for molecule generation in 3D” (ICML 2022).
- J. L. Watson et al., “De novo design of protein structure and function with RFdiffusion” (Nature, 2023).
- A. Merchant et al., “Scaling deep learning for materials discovery” (Nature, 2023; GNoME).
- C. Zeni et al., “A generative model for inorganic materials design” (Nature, 2025; MatterGen).
Exercise 2.
- Reference data: 1000 toy heavy-atom graphs over C, N and O with valences 4, 3 and 2. They grow as trees that branch preferentially at carbon, and half of them close exactly one ring between atoms 4 or 5 bonds apart, so every ring in the data has 5 or 6 atoms.
- Generators fitted to the same counts (sizes, atom frequencies, bond density 0.339, ring probability 0.302): a one-shot model with independent atom types and independent bonds; an autoregressive model with no constraint; the same with a valence mask; and the masked model restricted to closing 5- or 6-membered rings.
- Metrics: validity (connected, within valence), uniqueness by Weisfeiler-Lehman hash, novelty against the training hashes, and the share of valid ringed samples whose smallest ring has 3 or 4 atoms.
- 400 samples per generator.
| generator | validity | uniqueness | novelty | strained 3-/4-rings |
|---|---|---|---|---|
| reference data | 1.000 | 0.658 | – | 0.000 |
| one-shot, independent bonds | 0.210 | 0.929 | 0.910 | 0.968 |
| autoregressive, no mask | 0.748 | 0.823 | 0.793 | 0.800 |
| autoregressive + valence mask | 1.000 | 0.897 | 0.852 | 0.783 |
| mask + learned ring sizes | 1.000 | 0.812 | 0.782 | 0.000 |
- Constraints matter: independent bonds gave 21% validity even though the bond density was fitted exactly; sequential construction gave 75%, and a valence mask 100%.
- Validity is not chemistry: the fully valid masked model still put a strained 3- or 4-membered ring in 78% of its ringed samples, something the data never does. Only modelling ring sizes fixed it, at a small cost in uniqueness and novelty.
- High novelty is cheap: every generator scored above 0.78 on novelty, including the 21%-valid one. Novelty measures distinctness from the training set, not quality.
- A negative result worth reporting: the training data itself had uniqueness 0.658, so about a third of the toy molecules repeat; a generator scoring 0.9 is less repetitive than the data, which is a sign of over-dispersion rather than of being better.
- Seeds 1 and 2: validity 0.242 and 0.242 for one-shot, 0.750 and 0.767 unmasked, 1.000 masked; strained-ring share 0.812 and 0.742 masked, 0.000 with learned ring sizes.
- Caveat: the toy chemistry has single bonds only, no stereochemistry, no 3-D geometry and no energies. Real pipelines add bond orders, charges, conformers and DFT or docking checks.
Generative chemistry in AI, robotics and aerospace
- Materials for hardware: generative models conditioned on properties propose battery electrolytes, thermal-protection ceramics and radiation-tolerant alloys, which are then screened by graph networks and DFT.
- Protein and enzyme design: RFdiffusion-style backbone design plus sequence design has produced experimentally validated binders and enzymes.
- Pipelines, not single models: generation is cheap, verification is not, so the figure of merit is how many proposals survive simulation and synthesis.
- Autonomous laboratories: generative proposals feed robotic synthesis and characterisation loops, closing the design cycle.
References
- R. Gomez-Bombarelli et al. (2018). “Automatic chemical design using a data-driven continuous representation of molecules.” ACS Central Science 4.
- W. Jin, R. Barzilay and T. Jaakkola (2018). “Junction tree variational autoencoder for molecular graph generation.” ICML.
- M. Krenn, F. Hase, A. Nigam, P. Friederich and A. Aspuru-Guzik (2020). “Self-referencing embedded strings (SELFIES): a 100% robust molecular string representation.” Machine Learning: Science and Technology 1.
- E. Hoogeboom, V. G. Satorras, C. Vignac and M. Welling (2022). “Equivariant diffusion for molecule generation in 3D.” ICML.
- T. Xie, X. Fu, O.-E. Ganea, R. Barzilay and T. Jaakkola (2022). “Crystal diffusion variational autoencoder for periodic material generation.” ICLR.
- G. Corso, H. Stark, B. Jing, R. Barzilay and T. Jaakkola (2023). “DiffDock: diffusion steps, twists, and turns for molecular docking.” ICLR.
- J. L. Watson et al. (2023). “De novo design of protein structure and function with RFdiffusion.” Nature 620.
- A. Merchant, S. Batzner, S. S. Schoenholz, M. Aykol, G. Cheon and E. D. Cubuk (2023). “Scaling deep learning for materials discovery.” Nature 624.
- J. Abramson et al. (2024). “Accurate structure prediction of biomolecular interactions with AlphaFold 3.” Nature 630.
- C. Zeni et al. (2025). “A generative model for inorganic materials design.” Nature 639.