Learning to Make Generalizable and Diverse Predictions for Retrosynthesis

1 INTRODUCTION . This paper proposes a novel approach for one-step retrosynthesis . This task is crucial for material and drug manufacturing ( Corey & Wipke , 1969 ; Corey , 1991 ) and aims to predict which reactants are needed to generate a given target molecule as the main product . For instance , Figure 1 demonstrates that the input molecule “ [ N- ] = [ N+ ] =NCc1ccc ( SCCl ) cc1 ” , expressed here as a SMILES string ( Weininger , 1988 ) , can be generated using reactants “ CSc1ccc ( CN= [ N+ ] = [ N- ] ) cc1 ” and “ ClCCl ” . For decades , this task has been solved using template-based approaches ( Gelernter et al. , 1990 ; Satoh & Funatsu , 1999 ) . Templates encode transformation rules as regular expressions operating on SMILES strings and are typically extracted directly from the available training reactions . The primary limitation of such templates is coverage , i.e. , it is possible that none of the templates applies to a test molecule . In order to better generalize to newer or broader chemical spaces , recently developed template-free approaches cast the problem as a sequence-to-sequence prediction task . These approaches were first explored by Liu et al . ( 2017 ) using LSTM models ; the current state-of-the-art performance on this task uses Transformer models ( Lin et al. , 2019 ; Karpov et al. , 2019 ) . Out-of-the-box Transformers nevertheless do not effectively generalize to rare reactions . For instance , model accuracy drops by 25 % on reactions with 10 or fewer representative instances in the training set.1 Another key issue is diversity . Manufacturing processes involve a number of additional criteria — such as green chemistry ( having low detrimental effects on the environment ) . It is therefore helpful to generate a diverse collection of alternative ways of synthesizing the given target molecule . However , predicted reactions are unlikely to encompass multiple reaction classes ( see Figure 2 ) without additional guidance . This is because the training data only provides a single reactant set for each input target , even if this is not the only valid reaction to synthesize the target . We extend molecular Transformers to address both of these challenges . First , we propose a novel pre-training approach to drive molecular representations to better retain alternative reaction possibilities . Our approach is reminiscent of successful pre-training schemes in natural language processing ( NLP ) applications ( Devlin et al. , 2018 ) . However , rather than using conventional token masking methods , we adopt chemically-relevant auxiliary tasks . Each training instance presents a single way to decompose a target molecule into its reactants . Here , we add alternative proxy decompositions for each target molecule by either 1 ) randomly removing bond types that can possibly break during reactions , or 2 ) transforming the target based on templates . While neither of these two auxiliary tasks are guaranteed to construct valid chemical reactions , they are closely related to the task of interest . Indeed , representations trained in this manner provide useful initializations for the actual retrosynthesis problem . To improve the diversity of predicted reactions , we incorporate latent variables into the generation process . Specifically , we merge the Transformer architecture with a discrete mixture over reactions . The role of the latent variable is to encode distinct modes that can be related to underlying reaction classes . Even though the training data only presents one reaction for each target molecule , our model learns to associate each reaction with a latent class , and in the process covers multiple reaction classes across the training set . At test time , a diverse collection of reactions is then obtained by collecting together predictions resulting from conditioning on each latent class . Analogous mixture models have shown promise in generating diverse predictions in natural language translation tasks ( He et al. , 2018 ; Shen et al. , 2019 ) . We demonstrate similar gains in the chemical context . We evaluate our model on the benchmark USPTO-50k dataset , and compare it against state-ofthe-art template-free baselines using the Transformer model . We focus our evaluation on top-10 accuracy , because there are many equally valuable reaction transformations for each input target , though only one is presented in the data . Compared to the baseline , we achieve better performance overall , with over 13 % increase in top-10 accuracy for our best model . When we create a split of the data based on different reaction templates ( a task that any template-based model would fail on ) , we similarly observe a performance increase for our model . Additionally , we demonstrate that our model outputs exhibit significant diversity through both quantitative and human evaluations . 2 RELATED WORK . Template-based Models Traditional methods for retrosynthetic reaction prediction use templatebased models . Templates , or rules , denote the exact atom and bond changes for a chemical reaction . 1See Appendix A for details on how this dataset is constructed . Coley et al . ( 2018 ) applies these templates for a given target compound based on similar reactions in the dataset . Going one step further , Segler & Waller ( 2017 ) learns the associations between molecules and templates through a neural network . Baylon et al . ( 2019 ) uses a hierarchical network to first predict the reaction group and then the correct template for that group . However , to have the flexibility to generalize beyond extracted rules , we explore template-free generative models . Molecule Generation There are two different approaches to generative tasks for molecules , demonstrated through graph and SMILES representations . The graph-generation problem has been explored in Li et al . ( 2018 ) as a node-by-node generation algorithm , but this model does not guarantee the validity of the output chemical graph . Jin et al . ( 2018a ; b ) improves upon this method using a junction-tree encoder-decoder that forces the outputs to be constrained in the valid chemical space ; however , these models require complex , structured decoders . We focus on the generative task of SMILES string representations of the molecules , which has been explored in Kusner et al . ( 2017 ) and Gómez-Bombarelli et al . ( 2018 ) . Pre-training Pre-training methods have been shown to vastly improve the performance of Transformer models in NLP tasks without additional data supervision . Devlin et al . ( 2018 ) use a masked language modeling objective to help their model learn effective representations for downstream tasks . Similar pre-training methods on molecules have been explored by Hu et al . ( 2019 ) , where they mask out atoms in molecular graphs . Meanwhile , our work does not use a masked objective , but instead creates pre-training tasks that are relevant to the retrosynthesis prediction problem . 3 BACKGROUND . Given an input target molecule , the task of retrosynthetic reaction prediction is to output likely reactants that can form the target product . Formally , we express a molecule as a text string via its SMILES representation , and cast our task into a sequence-to-sequence ( seq2seq ) prediction problem ( example shown in Figure 1 ) . For this task , the input target is always a single molecule , while the output predictions are usually a set of more than one molecule concatenated by separators “ . ” . To provide more intuition for this generative task , we describe some properties of SMILES strings . Each SMILES string is 1-D encoding of a 2-D molecular graph . If the predicted SMILES does not adhere to the SMILES grammar , then a valid molecular graph can not be reconstructed . Moreover , each molecule has many equivalent SMILES representations , as a single instance of its SMILES is just a graph traversal starting at some arbitrary node . Therefore , two very different SMILES string can encode the same molecule ( see Appendix B ) , and the model needs to be robust to the given input . One method , proposed by Schwaller et al . ( 2019 ) , augments the input data with different SMILES strings of the same input target molecule . For our model architecture , we apply a Transformer model for the seq2seq task , which has an encoder-decoder structure ( Vaswani et al. , 2017 ; Schwaller et al. , 2019 ) . The encoder maps an input sequence of tokens ( from the SMILES string ) to a sequence of continuous representations , which are then fed to the decoder to generate an output sequence of tokens one element at a time , auto-regressively . Once the model is trained , a beam search procedure is used at inference time to find likely output sequences . The main building block of the Transformer architecture lies in its global self-attention layers , which are well-suited for predictions of the latent graph structure of SMILES strings . For example , two tokens that are far apart in the SMILES string could be close together topologically in the corresponding molecular graph . The global connectivity of the Transformer model allows it to better leverage this information . Additionally , since SMILES follow a rigid grammar requiring long rangedependencies , these dependencies can be more easily learned through global attention layers ( see Appendix B ) . 4 APPROACH . Despite the flexible architecture of Transformer models , we recognize that there are ways to improve model generalization . Additionally , there is no inductive bias for proposing diverse outputs . We propose two techniques to enhance the base molecular Transformer model , which we describe now . 4.1 PRE-TRAINING . In the data , each input target molecule is associated with a single reaction transformation — though there are many equally good chemical reactions . Therefore , for each input target , we construct several new prediction examples that are chemically meaningful , and pre-train the model on these auxiliary examples . We do so without requiring additionally data , or data supervision . The two variants of our method are described in detail below , with examples shown in Figure 3 . Random pre-training For each input target molecule , we generate new examples by selecting a random bond to break . The types of bonds that we consider are acyclic single bonds , because these are the bonds most commonly broken in chemical reactions . As we break an acyclic bond , the input molecule is necessarily broken up into two output molecules , each being a subgraph of the input molecule . Although the examples generated by this method do not cover the entire space of chemical reactions ( for instance some reactions do not break any bonds at all ) , these examples are easy to generate and cover a diverse range of transformations . Template-based pre-training Instead of randomly breaking bonds , we can also use the templates extracted from the training data to create reaction examples . An example of a template is shown in Figure 4 : each template matches a specific pattern in the input molecule , and transforms that pattern according to the template specifications . When the matched pattern is a single acyclic bond , this method will generate similar outputs as the random pre-training method , except that templates usually add additional pieces ( functional groups ) to the output example . As shown in Figure 3 , both examples are derived from the same bond broken in the input target molecule , but for the template-based example , an additional functional group was added , matching a more realistic reaction context . On average , for a random input molecule , there are 10 different possible examples that can be extracted from the random pre-training method , while there are over 200 different possible examples that can be extracted using the template-based pre-training method . However , many of these 200 examples represent similar chemical transformations , only differing in the type of functional group added . More broadly speaking , we can say that the template pre-training method generates more chemically valid reactions compared to the random pre-training method . However , the advantage of the random pre-training method is that it can break bonds that are not represented within the templates , thereby perhaps conferring a higher ability to generalize . As routine , the model is pre-trained on these automatically constructed auxiliary tasks , and then used as initialization to be fine-tuned on the actual retrosynthesis data .

Summary: This paper is very well-written and combines the state-of-the-art NLP model and the domain knowledge in retrosynthetic reaction predictions.  The authors propose pre-training models to help improve the model's generation to rare reactions. In addition, a discrete latent variable model is used in the model to encourage the model to produce a diverse set of alternative predictions.  The experiments in the paper also show the effectiveness of the two main contributions.