Source-linked AI summary
Molecule Edit Graph Attention Network: Modeling Chemical Reactions as Sequences of Graph Edits
Mikołaj Sacha, Mikołaj Błaż, Piotr Byrski, Paweł Dąbrowski-Tumański, Mikołaj Chromiński, Rafał Loska, Paweł Włodarczyk-Pruszyński, Stanisław Jastrzębski
TL;DR
Automated synthesis planning needs reliable prediction of diverse reaction outcomes, especially when constraints make the most likely pathway unusable. MEGAN models reactions as sequences of graph edits in an end-to-end encoder-decoder architecture, extending the approach to retrosynthesis and large datasets. It achieves competitive performance across retrosynthesis and forward synthesis and state-of-the-art top-k accuracy for large K values on all tested datasets.
Problem
Automated synthesis planning requires reliable modeling of diverse reaction outcomes, including alternatives when synthesis constraints rule out a likely pathway.
Method
MEGAN is an end-to-end encoder-decoder model that represents reactions as sequences of graph edits and applies them to retrosynthesis and forward synthesis.
Results
MEGAN achieves competitive performance on retrosynthesis and forward synthesis, with state-of-the-art top-k accuracy for large K values on all tested datasets.
Takeaways & Limitations
Graph-edit reaction generation provides MEGAN with a template-free approach that covers both reaction-prediction directions and performs strongly across tested datasets.
Takeaways & Limitations
The authors identify forward-prediction training strategy as a promising topic for future work and report incorrect chirality predictions as a limitation.
Abstract
from arXiv · showhide
The central challenge in automated synthesis planning is to be able to generate and predict outcomes of a diverse set of chemical reactions. In particular, in many cases, the most likely synthesis pathway cannot be applied due to additional constraints, which requires proposing alternative chemical reactions. With this in mind, we present Molecule Edit Graph Attention Network (MEGAN), an end-to-end encoder-decoder neural model. MEGAN is inspired by models that express a chemical reaction as a sequence of graph edits, akin to the arrow pushing formalism. We extend this model to retrosynthesis prediction (predicting substrates given the product of a chemical reaction) and scale it up to large datasets. We argue that representing the reaction as a sequence of edits enables MEGAN to efficiently explore the space of plausible chemical reactions, maintaining the flexibility of modeling the reaction in an end-to-end fashion, and achieving state-of-the-art accuracy in standard benchmarks. Code and trained models are made available online at https://github.com/molecule-one/megan.
Introduction
Automated synthesis planning must model diverse reaction outcomes while accommodating constraints that can rule out the most likely pathway. MEGAN addresses limitations of template-based and sequence-to-sequence approaches by generating reactions as graph-edit sequences for both retrosynthesis and forward synthesis.
- Motivation: Synthesis planning is demanding because it must predict diverse reaction outcomes and accommodate constraints such as avoiding starting materials or using green chemistry.These capabilities support computer-aided synthesis planning and drug discovery.
- Limitations of prior methods: Template-based methods use static graph-transformation rules but restrict the accessible chemical reaction space through a limited number of templates.The restriction is attributed to computational limitations.
- Limitations of prior methods: Deep learning models improve chemical-space coverage but sequence-to-sequence models tend to propose a limited set of plausible reactions.The paper hypothesizes that left-to-right SMILES generation lacks a natural decomposition of the predictive distribution into different plausible reactions.
- Graph-edit representation: Graph-edit representations express reactions through operations such as bond additions and removals, inspired by chemists’ arrow-pushing descriptions.Prior graph-edit methods were limited by reaction topology, synthesis direction, or lack of atom-addition support.
- MEGAN: MEGAN is an end-to-end encoder-decoder model that generates reactions as graph-edit sequences and supports both retrosynthesis and forward synthesis on large datasets.Its architecture and training procedure avoid the need for reinforcement learning.
- Results: MEGAN achieves competitive performance on retrosynthesis and forward synthesis, with state-of-the-art top-k accuracy for large K values on all tested datasets.The authors also present this as evidence of excellent reaction-space coverage and release code and trained models.
Related work
Reaction prediction methods include template-based and template-free approaches, each offering different trade-offs in coverage, diversity, interpretability, and modeling flexibility. MEGAN builds on graph-edit generation to provide an end-to-end approach for both retrosynthesis and forward synthesis.
- Template-based methods use reaction rules mined from known reactions or defined manually, but their limited coverage motivated template-free alternatives.
- Sequence-to-sequence template-free models can support forward synthesis and retrosynthesis, but may make trivial mistakes and generate reactions with limited diversity.
- Sequence-to-sequence models are black boxes that do not explain predictions or map atoms between substrates and products.
- Graph-edit generation represents reactions as sequential direct transformations on molecules while remaining template-free and potentially more interpretable.
- MEGAN extends graph-edit reaction generation to retrosynthesis and proposes an end-to-end model usable for both retro and forward synthesis.
- Reaction outcome prediction supports automated synthesis planning, including filtering generated molecules that are difficult to synthesize.
Molecule Edit Graph Attention Network
MEGAN is an encoder-decoder graph model that predicts molecular transformations as sequential graph actions. Its architecture updates molecular graphs step by step until a stop action, using attention-based graph convolution and task-specific action ordering.
- Output representation: MEGAN predicts a sequence of actions on atoms and bonds, applying each action to the input graph to produce the desired output graph.Actions include editing atom properties, editing bonds, adding atoms, adding benzene rings, and stopping generation.
- Input representation: MEGAN represents atom and bond features with one-hot encodings projected into separate learned spaces before graph processing.Features include chemical properties such as atomic number, formal charge, chirality, aromaticity, bond type, and bond stereometry.
- Input representation: A supernode connects all atoms using a special bond type, helping graph convolutions pass information between connected components.
- Encoder-decoder architecture: The model uses an encoder-decoder architecture based on graph convolutional networks, with the encoder invoked once and the decoder generating successive actions.
- Generating graph actions: At each step, the decoder computes atom and bond action probabilities from current node features and applies the selected action until Stop is output.
- Model architecture: GCN-att layers augment graph convolutional attention by incorporating bond features when computing attention values.
- Gradient-based training: Training uses teacher forcing and maximum likelihood, requiring a fixed action ordering to define ground-truth edit sequences.
- Gradient-based training: BFS RAND-AT achieves the highest accuracy among tested orderings, prioritizing bond deletion for retrosynthesis and bond addition for forward synthesis.
Experiments
MEGAN is evaluated on retrosynthesis and forward synthesis across standard and large-scale reaction datasets, using top-k accuracy and ranked candidate generation. It achieves strong retrosynthesis performance, while forward synthesis remains a comparatively weaker setting.
- Datasets and tasks: MEGAN is evaluated on USPTO-50k, USPTO-FULL, and USPTO-MIT for retrosynthesis and forward synthesis prediction.The evaluation covers approximately 50,000-reaction, large-scale, and forward-synthesis benchmarks.
- Evaluation protocol: Retrosynthesis accuracy is measured by whether the predicted reactant set matches the mapped ground-truth reactants, using top-k ranked candidates.MEGAN uses beam search to generate multiple ranked candidates for each product.
- Retrosynthesis results: On USPTO-50k, MEGAN beats prior models for K ≥3 when reaction type is unknown and concurrent models for K ≥10.With reaction type given, MEGAN outperforms all baselines in all reported metrics except top-1.
- Retrosynthesis results: 93.2% top-50 accuracy is achieved when reaction type is unknown, versus 95.3% when reaction type is provided.These results indicate broad ranked-candidate coverage on USPTO-50k.
- Large-scale retrosynthesis: On USPTO-FULL, MEGAN achieves competitive large-scale retrosynthesis performance and slightly outperforms other methods in top-10 accuracy.The large-scale split contains approximately 800k/100k/100k training, validation, and test reactions.
Analysis and ablation studies
The analyses examine whether differing retrosynthesis predictions are chemically valid, how edit-action ordering affects MEGAN, and how performance varies with reaction popularity. MEGAN’s alternatives are often judged chemically correct, but performance depends on ordering and reaction frequency.
- Alternative reactions: The first four illustrative alternative reactions were feasible by standard methods, while the fifth involved difficult regioselectivity dependent on reaction conditions.The examples concern five random USPTO-50k targets whose predictions differed from ground truth.
- Chemical correctness: Among predictions differing from ground truth, chemists judged 79.6% of MEGAN’s top-ranked retrosynthesis predictions correct.Ground-truth reactions were judged correct in 89.5% of cases in the same analysis.
- Chemical correctness: Incorrect substrate chirality was the most common labeled error, occurring in 7.1% of predictions versus 0.5% of ground-truth reactions.Ignoring a reactive functional group was another common error source.
- Action ordering: BFS RAND-AT achieved the highest performance across most K values and was selected for training MEGAN on retrosynthesis.The ordering choice strongly affects performance; RANDOM ordering produced over 4% lower top-1 accuracy than DFS RAND-AT.
- Reaction popularity: MEGAN performs better than Molecular Transformer on popular reaction types but underperforms it on the rarest reactions.Reaction popularity is approximated by counting template occurrences in the training set.
Conclusions
MEGAN is a template-free encoder-decoder model that represents reactions as graph-edit sequences for retrosynthesis and forward synthesis. It achieves competitive performance across both tasks, scales to large reaction datasets, and supports efficient exploration of plausible reactions, while mapping and chirality remain improvement areas.
- Conclusions: MEGAN is a template-free model for retrosynthesis and forward synthesis that represents reactions as sequences of graph edits.Its representation is inspired by how chemists describe chemical reactions.
- Conclusions: MEGAN achieves competitive performance on both retrosynthesis and forward synthesis, with state-of-the-art top-k accuracy for large K values across tested datasets.The model also scales to large reaction datasets.
- Conclusions: The graph-edit representation is argued to enable more efficient search through the space of plausible reactions.The authors suggest its chemistry-inspired inductive bias might explain the model's strong empirical performance.
- Conclusions: Graph-edit sequences are described as promising for more intuitive human-computer interaction in synthesis planning.This implication is presented as a future-facing benefit of the representation.
- Conclusions: Reducing reliance on product–substrate atom mapping and improving chirality prediction are identified as future directions.Incorrect output chirality was the most common error source on USPTO-50k, and these improvements could further advance prediction performance.
Data and Software Availability
The authors provide the MEGAN code and trained models online, with an MIT-licensed implementation based on freely available software. The datasets are also available online with references in the main text.
- Data and Software Availability: MEGAN's code and trained models are open-sourced at the project's GitHub repository.The implementation is released under the MIT license.
- Data and Software Availability: All datasets used are available online, with references provided in the main text.
Supplementary Material
The supplementary material specifies MEGAN's graph features, action space, and training-action ordering. It also documents how atom and bond edits are represented and prioritized for forward and retrosynthesis prediction.
- Graph representation: Atoms and bonds are represented with concatenated one-hot feature vectors, including an IS EDITED indicator for modified graph elements.Features are selected to reconstruct products and substrates in each dataset, with RdKit used to calculate feature values.
- Graph representation: The supplementary tables enumerate the atom and bond features and the graph actions used on USPTO-50k.Table 7 lists features, while Table 8 lists graph actions.
- Graph actions: EditAtom changes specified atom properties in one action, while EditBond changes bond properties; AddAtom and AddBenzene expand the graph.BondEdit actions operate on atom pairs, whereas other action types operate on single atoms.
- Graph actions: The Stop action terminates reaction generation, while action types use different parameter sets.
- Action ordering: Training uses an ordered sequence of ground-truth graph edits that transforms the input graph into the target graph and supports maximum-likelihood optimization.
- Action ordering: Bond deletion receives highest priority in retrosynthesis, while bond addition receives highest priority in forward synthesis because these actions usually determine the reaction center.Other action-type priorities were determined experimentally.
1. Whether an atom has already been modified (BFS vs DFS)
The training-action algorithm selects candidate atoms and orders them using breadth-first or depth-first strategies, with canonical or random atom ordering. The final hyperparameters were manually tuned on USPTO-50k validation data, and some benchmark comparisons were excluded because of information leakage.
- 1. Whether an atom has already been modified (BFS vs DFS): BFS and DFS ordering differ in how candidate atoms are selected, while CANO-AT uses canonical-SMILES atom order and RAND-AT uses random ordering.
- 1. Whether an atom has already been modified (BFS vs DFS): Algorithm 1 constructs training actions from atoms that can be edited to transform the input graph into the target graph.It tracks atoms modified or added by previous actions and filters candidate atoms according to the ordering type.
- 1. Whether an atom has already been modified (BFS vs DFS): After selecting an atom, the algorithm chooses the applicable action type with the highest priority and then resolves action-specific atom choices.EditAtom, EditBond, AddAtom, and AddBenzene actions are handled separately.
- 1. Whether an atom has already been modified (BFS vs DFS): The final USPTO-50k hyperparameters were manually selected using validation performance, with only slight modifications for other datasets.
- 1. Whether an atom has already been modified (BFS vs DFS): Some retrosynthesis methods were excluded from benchmark comparisons because information leaked between their training and test sets.The excluded methods include GraphRetro and RetroXpert.