SlowGuess/NeurIPS_2023_OCR huggingface dataset:
Mohammadamin Tavakoli
mohamadt@uci.edu
Alexander Shmakov
ashmakov@uci.edu
David Van Vranken
david.vv@uci.edu
Yin Ting T.Chiu
yintc@uci.edu
Ann Marie Carlton
agcarlto@uci.edu
Pierre Baldi
pfbaldi@uci.edu
Deep learning-based reaction predictors have undergone significant architectural evolution. However, their reliance on reactions from the US Patent Office results in a lack of interpretable predictions and limited generalizability to other chemistry domains, such as radical and atmospheric chemistry. To address these challenges, we introduce a new reaction predictor system, RMechRP, that leverages contrastive learning in conjunction with mechanistic pathways, the most interpretable representation of chemical reactions. Specifically designed for radical reactions, RMechRP provides different levels of interpretation of chemical reactions. We develop and train multiple deep-learning models using RMechDB, a public database of radical reactions, to establish the first benchmark for predicting radical reactions. Our results demonstrate the effectiveness of RMechRP in providing accurate and interpretable predictions of radical reactions, and its potential for various applications in atmospheric chemistry.
Three primary approaches have been employed for the systematic prediction of chemical reactions: Quantum Mechanics simulations [1; 2], Template-based methods [3; 4; 5; 6; 7; 8], and machine learning methods [9; 10; 11; 12; 13; 14; 15]. Notably, among these methods, machine learning techniques have demonstrated superior generalization capabilities and have enabled high-throughput predictions.
However, the majority of recently developed data-driven predictive models are primarily designed to operate at the level of overall transformations. These predictors are trained using the chemical transformation dataset sourced from the US Patent Office (USPTO) [16], along with a few additional, though relatively small, datasets introduced scatteredly in various studies [17; 18; 19]. It is important to note that all these datasets have notable limitations, which include: limited coverage of chemical reactions, lack of information about the byproducts, an imbalance between reactants and products,
and a scarcity of information concerning elementary reaction steps. For example, the USPTO dataset predominantly presents chemical reactions as overall transformations with a single primary product, providing limited insights into underlying mechanisms, critical intermediates, and side products. Moreover, extracting information on radical reactions is challenging, as they are underrepresented in this dataset.
The utilization of this constrained source of data for training data-driven models leads to predictive models that may have inherent limitations and biases, primarily catering to specific types of chemical reactions. These models often struggle to predict balanced reactions and lack crucial information regarding intermediate byproducts. Moreover, they fall short in offering explanations regarding the underlying chemistry responsible for the predicted products. Given the scarcity of available training data, there is currently no widely adopted reaction predictor specifically tailored for radical reactions. Radical reactions play a significant role in various domains, including synthetic pathway planning, biological chemistry, and atmospheric chemistry. These reactions frequently involve intricate sequences of chemical steps and highly branched mechanistic pathways. Hence, there is a critical need to develop an accurate radical reaction predictor that can effectively address the aforementioned limitations.
2 Interpretability of Mechanistic Reaction Steps
Instead of overall transformations (e.g., samples of the USPTO dataset), expert chemists typically employ an alternative approach to represent and conceptualize chemical reactions. Specifically, they utilize an intuitive representation that involves the consideration of single-state transitions and arrow-pushing mechanisms, which we refer to as elementary reaction mechanisms or elementary steps. Overall chemical transformations can be deconstructed into a chain of elementary reaction mechanisms, each characterized by a singular transition state [20; 21]. Figure 1 provides an illustrative example of this process. Curved arrows (or fish-hook arrows for radical reactions) are employed to depict the reaction mechanisms [22], and correspond to the interaction of singly occupied molecular orbitals with both the highest occupied molecular orbital (HOMO) and the lowest unoccupied molecular orbital (LUMO) [23]. Hence, the development of a reaction predictor that operates at the reaction mechanism level can confer three critical benefits (shown in Figure 1 that none of the current reaction predictors can offer.
Chemical interpretability: The first key benefit is enhanced chemical/orbital interpretability. The use of curly arrows, or arrow-pushing mechanisms, allows for an accurate understanding of the fundamental chemistry underlying each reaction step. This approach facilitates the understanding of the interactions between molecular orbitals, which ultimately drive each reaction step.
Pathway interpretability: The second key benefit is enhanced pathway/transformation interpretability. A predictor trained to predict elementary steps can be iterated to expand a tree of such steps rooted at the initial reactants. This allows for the interpretation of any overall transformations leading to several final products, some of which are unknown. By expanding such a tree of pathways there is no chance of missing key intermediates that give rise to competing pathways during change. This level of interpretability enables several applications, most importantly for drug discovery and atmospheric chemistry where highly reactive radicals are involved in massively branched reactions.
Balance and atom mapping: Finally, the third benefit is the preservation of the balance between reactants and products, in conjunction with the underlying atom mapping. The balance is maintained at all times throughout the tree of pathways (i.e., the chain of reaction steps), which can be highly valuable, for instance in retrosynthesis [24], and mass spectrometry.
3 Data
To develop a radical reaction predictor operating at the mechanistic steps, we utilize the standard train and test sets from the recently released RMechDB dataset [25]. This dataset comprises approximately 5500 radical elementary step reactions sourced from chemistry textbooks (core reactions) and scientific articles on atmospheric chemistry (atmospheric reactions). Each reaction in the RMechDB dataset is labeled with different categorizations enabling comprehensive evaluation of the predictive models trained on RMechDB. See Table 1 for a summary of the RMechDB dataset used in subsequent training and testing experiments.
Figure 1: The reaction at the top is an overall, unbalanced, transformation from the USPTO dataset. It can be broken down into four mechanistic steps with arrow-pushing mechanisms. This provides chemical interpretability for each step, as well as for the overall pathway while maintaining full balance at each step.
Table 1: The size of the various subsets of elementary radical reaction steps contained in the RMechDBdatabase [25]. These are used to train and test the predictors.
Train	Test
Core	1512	150
Specific	3397	367
Combined	4909	517
4 Methods
Here we first describe the OrbChain as a model of radical mechanistic reaction based on the interaction of idealized molecular orbitals. We utilize Orbchain to represent and process radical mechanistic reactions for machine learning models. Then we describe three different machine learning approaches for predicting the outcome of radical mechanistic reactions with or without their associated arrow-pushing mechanisms. The first approach follows the methodology described in [20; 21; 26] where predictions are carried out using deep learning in two steps. The first step identifies reactive sites, while the second step ranks the plausibility of all possible reactions based on the interactions of the previously identified reactive sites. In the second approach, we directly predict the most reactive pair of molecular orbital. Within this one-step prediction approach, we test two different representations for the atoms: our own atom descriptor and RxnHypergraph [27] which applies a transformer model to the molecular graph representations. Lastly, we use a purely text-based approach [28] leveraging transformers and large language models to predict the products of radical reactions using a neural machine translation system [29]. This approach is based on the text representation of chemical reaction and aims to "translate" the sequence of reactants into the sequence of products. Notably, this approach only outputs the string associated with the products, without the arrow-pushing information. As a result, this approach cannot provide chemical interpretability, although it shows promising results on the RMechDB test sets.
4.1 OrbChain: Standard Model of Mechanistic Reactions
A radical mechanistic reaction Rxn is a reaction with a single transition state that involves at least one half-occupied orbital. Rxn consists of a set of reactant molecules  $R = \{R_i\}_{i=1}^{n_r}$ , a set of product molecules  $P = \{P_i\}_{i=1}^{n_p}$ , and a set of fish-hook arrows  $A$  showing a bond cleavage and movements of a single electrons. Each of the reactant and product molecules  $R_i, P_i$  is represented by a connected molecular graph  $G_i = (N_i, V_i)$  where the vertices  $N_i$  represent labeled atoms  $\{a_j^i\}$  and edges  $V_i$  represent labeled bonds  $\{b_j^i\}$ . Inspired by [20; 21], we model a radical mechanism by OrbChain as
the interaction between two reactive Molecular Orbitals (MOs)  $m_1^{(*)}$  and  $m_2^{(*)}$  (we refer to an MO as  $m$  and a reactive MO as  $m^{(*)}$ ). This reaction model matches the arrow-pushing diagram where the interaction is shown by a group of directed half arrows from one reactive MO to the other reactive MO.
Since arrow-pushing mechanism  $A$ , uniquely defines the single transition state (see [25]), by knowing the atom mapped  $R$ , atom mapped  $P$ , and  $A$ , OrbChain can uniquely determine the reactive pair of orbitals,  $(m_1^{(*)}, m_2^{(*)})$ , in  $R$ . Also, by knowing the atom mapped  $R$  and two orbital pairs (assumed to be reactive)  $(m_1^{(*)}, m_2^{(*)})$ , OrbChain can uniquely determine the atom mapped  $P$  and  $A$ .
We summarize the OrbChain in the Equation 1.
OrbChain:  $\left\{ \begin{array}{l} (1) R, P \xrightarrow{A} (m_1, m_2): \text{Atom mapped } R, P \text{ and } A, \text{ determine the reactive MOs.} \\ (2) R \xrightarrow{(m_i, m_j)} P', A': \text{A mechanism is an interaction between a pair of MOs } m_i, m_j. \end{array} \right.$
The problem of predicting the outcome of a radical reaction mechanism is to find the  $P$  and  $A$  given  $R$ . Using OrbChain, this problem is equivalent to finding the reactive pair of molecular orbitals  $(m_1^{(*)}, m_2^{(*)})$  given  $R$ .
To determine  $P$  and  $A$  in accordance with the model described above, the first step is for OrbChain to identify all molecular orbitals (MOs) by performing an iterative process over the set of nodes  $a_{j}^{i}$  present in the reactant molecules  $R_{i}$ . Each MO is associated with four distinct parameters  $m = (a,e,n,c)$ , where  $a$  represents the atom corresponding to the MO (i.e., the central atom of the MO),  $e$  denotes the number of electrons involved in the MO (0, 1, or 2),  $n$  indicates the atom adjacent to the atom  $a$  in the case of a bond orbital (such as a  $\pi$  or  $\sigma$  bond), and  $c$  signifies the possible chain of filled or unfilled MOs (such as a  $\pi$  system). By utilizing  $c$ , we can uniquely determine  $P$  and  $A$  by recursively following the electron transfers from one MO to the next.
In a reactant molecule  $R_{i}$  with  $n_i$  atoms, we show the set of found MOs as  $m_{i} = \{m_{i}^{j}\}$ . Then the total number of possible (not plausible) mechanistic radical reactions from the reactant molecules  $R = \{R_{i}\}_{i=1}^{n_{r}}$ , is approximated in Equation 2. This would be a large number for molecular systems with approximately 20 atoms. Within this vast space of possible mechanistic reactions, the number of plausible ones (e.g.,  $(m_1^{(*)}, m_2^{(*)})$ ) is tiny, usually less than or equal to three.
$$
| X | \approx \binom {\sum_ {i = 1} ^ {n _ {r}} \left| \left\{m _ {i} \right\} \right|)} {2} \tag {2}
$$
4.2 Two-Step Prediction
To address the challenges associated with the multitude of potential mechanistic reactions, we adopt a method inspired by [20]. We begin by shrinking the pool of potential mechanisms through a filtering process called reactive sites identification. In this step, we filter the potentially reactive MOs, so we can only consider the interaction between the potentially reactive MOs. This filtering process offers two key advantages: (1) reduced computation time and (2) removal of false positives, leading to improved precision and recall in the overall prediction. After reactive sites identification, we employ a reaction ranker, a machine learning model that ranks the possible interactions  $(m_i,m_j)$  within the refined space of filtered MOs. The reaction ranker facilitates the identification of the most favorable orbital interactions for the specific set of reactants under examination.
4.2.1 Reactive Sites Identification
We divide orbitals into reactive and non-reactive orbitals based on their role in the reaction. Based on statement (2) in Equation 1, there are only two reactive orbitals for each radical mechanistic step  $(R,P,A)$ . Instead of predicting the reactive MOs  $(a = atom,e,n,c)$ , it is more convenient to predict the label of atom  $a$ , which is associated with the MO as follows:
$$
g \left(a _ {j} ^ {i}\right) = \left\{ \begin{array}{l l} 0 & m ^ {*} \notin \{m \mid m = \left(a _ {j} ^ {i}, e, t, c\right) \} \\ 1 & m ^ {*} \in \{m \mid m = \left(a _ {j} ^ {i}, e, t, c\right) \} \end{array} \right. \tag {3}
$$
Then, finding a set of potentially reactive atoms in a group of reactant molecules is a classic node classification problem in the context of graph learning.
We adopt the reactive sites identification method from [20], which represents atoms using continuous vectors based on predefined atomic and graph-topological features. We expand these atom descriptors by incorporating more atomic features such as the number of radical electrons. For all the atoms within the RMechDB datasets, we extract these feature vectors to train a classifier that can classify each atom into reactive or non-reactive. The parameters of the trained model and the statics of the training data can be found in the Appendix.
To improve this atom classification and circumvent the manual feature extraction part, we deploy a form of graph convolution neural network (GNN) suitable for the atom classification [30; 5; 17] augmented with attention mechanisms [31]. More information on the parameters and specifications of the GNN can be found in the Appendix. Table 2 shows the statistics of the training data for the reactive sites identification part.
The results of reactive sites identification are presented in Table 2. While these methods achieve reasonable accuracies, they overlook a crucial aspect: the context of the reaction, which encompasses both spectator and reagent molecules. Given that the reactivity of various sites and functional groups can be significantly influenced by the reaction context, we will propose context-aware approaches in Sections 4.3 and 4.4 to address this limitation.
4.2.2 Plausibility Ranking
Once reactive sites are identified within a set of reactant molecules, we employ OrbChain's statement (2) for all combinations of reactive sites. Since each reactive sites (i.e., atoms) corresponds to an MO, this process yields all possible mechanistic reactions from the set of input reactants. Each of these mechanistic reactions includes atom-mapped products and arrow codes representing interactions between predicted MOs. To rank the proposed mechanistic reactions, we utilize a deep Siamese neural network [32] designed for entity ranking. During training, this network takes a pair of plausible and implausible mechanistic reactions as input and produces a real-valued number for each. The network's parameters are learned by minimizing the following loss function:
$$
\mathcal {L} = \sigma \left[ f \left(\mathrm {R x n} _ {\text {p l a u s i b l e}}\right) - f \left(\mathrm {R x n} _ {\text {i m p l a u s i b l e}}\right) \right] \tag {4}
$$
In the given loss function,  $f$  represents a neural network,  $\sigma$  denotes the logistic function, and Rxn represents a mechanistic reaction. Minimizing this loss function allows the function  $f$  to assign higher scores to plausible reactions. To establish a relative plausibility score, we train the model using pairs of  $\mathrm{Rxn}_{\text{plausible}}$  and  $\mathrm{Rxn}_{\text{implausible}}$  with identical reactants. During training, the  $\mathrm{Rxn}_{\text{plausible}}$  is a sample of the RMechDB dataset while the  $\mathrm{Rxn}_{\text{implausible}}$  is generated using OrbChain's statement (2) with randomly chosen non-reactive MOs of the same sample from RMechDB. Once the model is trained, the output of function  $f$  can be interpreted as the plausibility score. We use this output to rank all generated mechanistic steps from the combination of reactive sites.
The performance of the model is significantly influenced by the choice of reaction representation and the corresponding neural network architecture for function  $f$ . We explore and compare four different reaction representations and their corresponding neural architectures: (1) pre-defined feature vectors [20], (2) reactionFP [33] with three different molecular fingerprints including atom pair fingerprints (AP) [34], Morgan fingerprints [35], and Topological Torsion fingerprints (TT) [36], (3) Differential Reaction Fingerprint (DRFP) [37], and rxnfp, a text-based reaction representation based on a pre-trained model for yield prediction [38]. Detailed descriptions of the methods for generating implausible reactions, the specific parameters used for each neural network, and the parameters used for each reaction fingerprint can be found in the Appendix. The comparative results of the plausibility ranking are presented in Table 3.
4.3 Contrastive Learning
As stated above, the context of a reaction can affect the dynamic of orbital interactions by changing the reactivity of different functional groups. An informative atom representation for reactive sites identification must take this context into account. In this section, we solve this problem by proposing a new method similar to [14] which computes and learns the atom representations by considering the entire context of the reaction. The key idea is to consider a pair of atoms and predict the most
reactive pair instead of predicting the reactive atoms separately. We take into account the full context of the reactions by considering all possible atom pairs and comparing them with the most reactive one in a contrastive learning manner. This contrastive learning model can approximate the probability distribution in Equation 5. Notably, this method not only captures the impact of the reaction context but also streamlines the prediction process into a single step, resulting in faster inference when compared to the two-step prediction method.
$$
\mathbb {P} \left(\left(m _ {i}, m _ {j}\right) = \left(m _ {1} ^ {*}, m _ {2} ^ {*}\right) \mid R\right) \tag {5}
$$
4.3.1 Atom Pairs and Atom Descriptor
First, we establish a baseline for approximating the probability mentioned above using atom descriptors. In this approach, the positive data consists of the most productive reactions  $(R, P, A)$  (i.e., each sample of the RMechDB dataset), while the negative data includes all other possible reactions from the same set of reactants  $(R, P', A')$ . To train the contrastive model, reactions, whether positive or negative are represented as a pair of atoms where each atom is the representative of its reactive MO. The targets  $y_{ij}$  for an atom pair  $(a_i, a_j)$  is obtained as shown in Equation 3. We calculate the marginalized probability (Eqn. 5) by considering all possible atom pairs in reactants  $R$ . This approach has two advantages: (1) It enables one-step reaction prediction by identifying the most reactive pair of MOs, determining the product and arrows according to Orbchain (statement (2)). (2) It reduces false negatives by not discouraging less reactive, yet still plausible, MO pairs. These pairs are ranked highly, with the most reactive MO pair receiving the highest ranking.
$$
y _ {\left(a _ {i}, a _ {j}\right)} = \left\{ \begin{array}{l l} 1 & m _ {1} ^ {*} = \left(a _ {i}, e, n, c\right) \& m _ {2} ^ {*} = \left(a _ {j}, e ^ {\prime}, n ^ {\prime}, c ^ {\prime}\right) \\ 0 & \text {O t h e r w i s e ;} \end{array} \right. \tag {6}
$$
Figure 2 (left side) shows the schematics of the constrastive model. Table 4 presents the results of this method, while the Appendix provides details on the objective function, parameters of the contrastive model (Figure 2), and the atom descriptor.
4.3.2 Rxn-Hypergraph
Considering all atom pairs in a contrastive learning fashion would take the reaction context into account. However, we can compute a more informative representation of atom pairs by utilizing the Rxn-Hypergraph. Rxn-Hypergraph introduced in [27] is a graph attentional neural network that operates on the hypergraph of the entire reaction. Instead of using the atom descriptor, we can train a Rxn-Hypergraph model, to automatically learn a contextual representation of all atoms of the reactant sides.
To adapt the Rxn-Hypergraph for the reaction predictor task (OrbChain Statement (2)), we modify the original structure of the hypergraph by duplicating the reactants on both sides of the graph. This modification allows us to provide the reactants on one side while maintaining the full context on the other side. Following the training procedure of [27], we compute atom representations and generate pairs of atoms. These pairs are then fed into the contrastive network depicted in Figure 2 to obtain a ranked list of atom pairs. Each atom pair corresponds to an interaction between two orbitals, which enables us to generate products and arrows using OrbChain. The results of the reaction predictor using atom pair prediction with Rxn-Hypergraph are presented in Table 4.
4.4 Text Representation and Sequence to Sequence Models
Considering the SMILES string as the text representation of molecules [39; 40], a chemical reaction can be seen as the transformation of a sequence of characters (reactants) to another (products). This makes the sequence-to-sequence models, such as the Transformer [41; 42] and models based on the recurrent neural network architecture, a suitable predictive model for chemical reaction predictions [43; 44; 45; 28], retrosynthesis prediction [46] and molecular optimization [47].
Existing text-based models for chemical reaction prediction exhibit limitations in various aspects, notably in terms of interpretability and balance in their predictions. SMILES representations are not unique and do not encode inherent molecular properties, such as invariance to atom permutations. Consequently, these models often require extensive data augmentation to improve performance. Nonetheless, we seek to leverage the success of these models and apply them to the prediction of
Figure 2: Left: The architecture of the contrastive learning approach. Right: The schematic depiction of the Rxn-hypergraph.