Retrosynthesis Prediction Explained
10 min read · updated August 11, 2026
Retrosynthesis runs chemistry backwards: given a target molecule, propose starting materials that could produce it. As a machine learning problem it is one-to-many, weakly supervised and evaluated against a reference answer that is only one of several correct ones.
The problem, stated precisely
Single-step retrosynthesis takes a product molecule and returns a set of reactant molecules. Input and output are both SMILES, and the disconnection is a bond — or a small set of bonds — whose breaking corresponds to a known forward reaction run in reverse.
Training data comes overwhelmingly from patents. Daniel Lowe’s text-mined extraction of reactions from United States patent applications is the foundation of the field; the derived USPTO-50k set, about fifty thousand atom-mapped reactions grouped into ten reaction classes, is the benchmark most single-step papers report on. Every property of that corpus becomes a property of the model: it contains reactions that worked and were patented, so it encodes no failures, and its class distribution reflects what pharmaceutical patents contain rather than what chemistry can do.
Worked: one amide disconnection
Paracetamol is CC(=O)Nc1ccc(O)cc1. A chemist looking at it sees an amide and disconnects the carbon-nitrogen bond, giving an aniline and an acylating agent.
target CC(=O)Nc1ccc(O)cc1 (N-(4-hydroxyphenyl)acetamide)
disconnect the amide C-N bond
precursors Nc1ccc(O)cc1 (4-aminophenol)
CC(=O)OC(C)=O (acetic anhydride)
as a retro template in reaction SMARTS:
[C:1](=[O:2])[NH1:3][c:4] >> [C:1](=[O:2])[OH1] . [NH2:3][c:4]
the mapped numbers pin atoms across the arrow, so the template
transfers to any anilide, not just this oneApplying that template to the target with an RDKit reaction object returns the two precursors mechanically. The chemistry the template encodes — that anilides come from anilines — was extracted from atom-mapped examples, not written by hand, which is the whole point: tens of thousands of templates are mined automatically, and Connor Coley’s rdchiral handles the stereochemistry-preserving application that naive template matching gets wrong.
Note that the same molecule admits other disconnections: the phenol could come from a protected precursor, or the ring could be assembled later. A model that returns acetic anhydride plus 4-aminophenol and a model that returns acetyl chloride plus 4-aminophenol have both answered correctly.
Template-based and template-free
Template-based models turn retrosynthesis into classification: given the product, which of N mined templates applies? Apply the top-ranked ones and read off the precursors. The output is chemically valid by construction, because a template application either matches or does not. The ceiling is the template library — a disconnection with no template in the corpus is unreachable, and rare templates have few examples to learn from.
A neighbour-based variant sidesteps the classification entirely: find the most similar product in the reaction corpus and transfer its reaction, an approach Coley and colleagues set out in “Computer-Assisted Retrosynthesis Based on Molecular Similarity” (ACS Central Science, 2017). It is a strong baseline and worth running before anything heavier.
Template-free models treat it as translation: product SMILES in, reactant SMILES out, with a sequence model. They can propose disconnections no template covers, and they can emit strings that are not molecules. Validity is then a metric rather than a guarantee, and every output has to be parsed and sanitised before it counts. Graph-edit approaches sit between the two, predicting which bonds to break and then completing the resulting fragments.
One step is not a route
A synthesis is a tree, not an edge. Multi-step planning applies the one-step model recursively until every leaf is a purchasable building block, which turns it into a search problem over an enormous branching tree — each expansion offers ten or more candidate disconnections and each precursor needs its own expansion.
Marwin Segler, Mike Preuss and Mark Waller combined neural expansion with Monte Carlo tree search in “Planning chemical syntheses with deep neural networks and symbolic AI” (Nature, 2018). The open-source AiZynthFinder from Samuel Genheden and colleagues, published in the Journal of Cheminformatics in 2020, implements the same shape and is the usual starting point for running this yourself.
Two components decide whether the search terminates usefully. The stock file — what counts as purchasable — sets the leaves, and a generous stock produces short routes that are not actually buyable. The expansion policy’s cutoff decides how many candidates each node contributes; too many and the tree explodes, too few and the search misses the disconnection that unlocks the route.
Why top-1 accuracy misleads
Single-step models are scored by top-k exact match: does the recorded precursor set from the patent appear among the model’s first k proposals, after canonicalisation? It is easy to compute and it systematically undercounts.
The reference is one route somebody happened to patent. A model proposing acetyl chloride where the patent used acetic anhydride scores zero on a correct answer. A model proposing a shorter route than the patent scores zero. Meanwhile top-k for large k rewards a model for hedging with ten variations on one disconnection.
The complementary check is round-trip validation: feed each proposed precursor set to a forward reaction predictor and ask whether it predicts the original target. That measures internal consistency rather than agreement with a patent, and it catches proposals that are chemically incoherent regardless of what the reference says. It is not a substitute for a chemist reading the output.
What these models do not know
- Selectivity. A template matches a substructure. If the molecule has two amines, the template fires on both and the model has no representation of which one actually reacts.
- Protecting groups. Patent reactions record the protected step, so models learn to propose protection and deprotection as steps but not to reason about when a group is needed.
- Conditions. Most single-step datasets strip solvent, temperature, catalyst and time. A disconnection that is correct in principle and requires a reagent nobody stocks is scored as correct.
- Failure. There is no negative data. The corpus cannot teach a model that a reaction was tried and did not work, so confidence reflects frequency in patents, not probability of success in a flask.
Treat the output as a ranked list of hypotheses for a synthetic chemist to triage. That is a genuinely useful thing — it surfaces disconnections a human might not enumerate — and it is not a route. The interface matters as much as the model: showing the proposed precursors alongside the template that produced them, the patent examples the template was mined from, and the stock status of each precursor turns a ranked list into something a chemist can accept or reject in seconds.