TempRe: Template generation for single and direct multi-step retrosynthesis

Nguyen Xuan-Vu, Daniel P. Armstrong, Zlatko Joncev, Philippe SchwallerarXiv 2025 · DOI

Abstract

Retrosynthesis is a fundamental challenge in drug discovery, traditionally divided between rigid template-based classification and flexible but error-prone template-free generation. This paper introduces TempRe, a generative framework that treats reaction templates as a sequence generation task using SMARTS strings. By decoupling reaction center complexity from molecular size, TempRe achieves superior scalability and handles rare chemistry more effectively than traditional classifiers. Furthermore, the model enables direct multi-step retrosynthesis, providing a lightweight alternative to computationally intensive search algorithms.

Introduction

Retrosynthesis—the process of identifying starting materials for a target molecule—is essential for chemical synthesis planning. Current computational methods generally fall into two categories: template-based and template-free. Template-based methods treat retrosynthesis as a classification problem, selecting rules from a fixed library. While chemically reliable, they scale poorly and cannot generalize to chemistry outside their training set. Conversely, template-free methods use sequence-to-sequence translation (SMILES-to-SMILES), offering flexibility but often "hallucinating" chemically invalid structures, especially as molecular complexity increases.

The authors address the "length generalization" failure of template-free models and the inherent rigidity of classification models. TempRe bridges this gap by generating the reaction template itself as a sequence, combining the chemical safety of templates with the generative flexibility of translation models.

Methodology

TempRe reformulates retrosynthesis as a sequence-to-sequence task where the model predicts a reaction template (expressed as a SMARTS string) rather than the reactant molecules directly.

Model Architecture

  • P2T (Product-to-Template): A Transformer-based model that maps a product's SMILES string to a generated template.
  • Tokenization: The framework utilizes a frequency-sensitive tokenizer (P2T-Tok) that treats common templates as single tokens while decomposing rare ones into smaller sub-units, allowing the model to learn semantic correlations between similar reactions.
  • Direct TempRe: An extension that generates an entire multi-step synthetic route in a single inference call by outputting a sequence of templates.
Overview of conventional planning vs. TempRe for single and multi-step retrosynthesis.

Hybrid "Strict" Variants

To ensure chemical validity, the authors introduced "Strict" variants that filter generated templates against a known library. This provides a safety net, combining generative power with the reliability of classification-level validation.

Experimental Results

Robustness to Molecular Size

In out-of-distribution (OOD) tests, standard SMILES-based models (P2R) saw accuracy drop from 70% to 42% as molecular weight increased. In contrast, TempRe (P2T) remained stable, maintaining approximately 57% accuracy even for the largest molecules. This is because the template (the "reaction center") remains relatively short regardless of the overall molecular size.

Performance on Rare Chemistry

On a "Hard" test set enriched with rare templates, TempRe outperformed the popular AiZynthFinder (AZF) classifier. TempRe achieved 85% top-80 accuracy compared to AZF’s 76%, demonstrating its ability to exploit sub-structural patterns in SMARTS strings to understand fringe chemistry.

Top-K single-step accuracy comparison on PaRoutes and Hard reaction datasets.

Multi-step Efficiency

When integrated into Monte Carlo Tree Search (MCTS), TempRe variants achieved solve rates above 90% on the PaRoutes benchmark. Notably, Direct TempRe—which generates the entire route at once—solved 68% of targets in the N1 benchmark without iterative, CPU-intensive searching, proving to be a highly efficient alternative to traditional search-based methods.

Conclusion and Future Work

TempRe demonstrates that treating reaction templates as a language task significantly improves the robustness and scalability of retrosynthesis models. While the model currently shows a bias toward shorter routes and can occasionally produce invalid SMARTS strings, these issues are mitigated by "Strict" filtering. Future research will focus on integrating reinforcement learning to guide generation toward higher-yield routes and applying these principles to larger language model architectures.

Summary updated

BibTeX
@misc{xuanvu2025tempre,
  author = {Nguyen Xuan-Vu and Daniel P. Armstrong and Zlatko Joncev and Philippe Schwaller},
  title = {{TempRe: Template generation for single and direct multi-step retrosynthesis}},
  year = {2025},
  eprint = {2507.21762},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.21762},
}
Figure