Patent Description:
The output of each hidden layer is used as input to one or more other layers in the network, i.e., one or more other hidden layers, the output layer, or both.

<NPL> describes a retrosynthesis predictor that uses transformer neural networks.

This specification describes a system implemented as computer programs on one or more computers in one or more locations that performs retrosynthesis using a neural network. Retrosynthesis is the process of determining, from a target chemical compound, a set of chemical reactants for synthesizing the target compound.

In one aspect there is described a computer-implemented method for generating a prediction of a set of a plurality of predicted reactants that are combinable to generate a target compound. The generating comprises processing, for each of a plurality of candidate sets of reactants, a network input characterizing the candidate set using a neural network. The network input is generated from (i) data identifying the target compound and (ii) data identifying the candidate set of reactants.

The processing comprises processing the network input using a first subnetwork to generate a predicted prior probability of the candidate set of reactants, in particular a prior probability according to a data distribution of sets of predicted reactants and target compounds. For example the prior probability may be a prior probability that the set of a plurality of predicted reactants is combinable to generate the target compound. The processing also comprises processing the network input using a second subnetwork to generate a predicted conditional probability of the target compound conditioned on the candidate set of reactants according to the (empirical) data distribution. The processing also comprises processing the network input using a third subnetwork to generate a predicted conditional probability of the candidate set of reactants conditioned on the target compound according to the (e.g. empirical) data distribution.

The method further comprises determining, for each candidate set of the plurality of candidate sets, a score using the generated probabilities, and selecting a particular candidate set of one or more reactants using the determined scores.

In some implementations the method performs one-step retrosynthesis but in such implementations multi-step retrosynthesis may be performed by applying the method recursively. That is, in some implementations the method generates a prediction of a set of a plurality of predicted reactants that are combinable in one-step without having first to make intermediate molecules, to generate the target compound.

The network input characterizing the candidate set of reactants may be e.g. any type of representation of the set of reactants. For example in some implementations the network input represents the set of reactants as a one-dimensional sequence of tokens e.g. each reactant may be represented as a string of characters. There are various standardized approaches for representing chemical structures in this way e.g. based around SMILES (simplified molecular-input line-entry system) or a variant thereof; or using other linear notations.

In implementations the method includes synthesizing the target compound, i.e. physically combining the particular candidate set of one or more reactants selected by the method to chemically synthesize, i.e. to physically generate, the target compound.

The above-described data distribution may be an empirical data distribution i.e. a data distribution that is determined by experimental data (from physical molecules) e.g. that has been learned during training.

The subject matter described in this specification can be implemented in particular embodiments so as to realize one or more of the following advantages.

Using techniques described in this specification, a system can automatically perform retrosynthesis in an efficient and accurate manner to determine an optimal set of reactants to use to synthesize a target compound. The search space of possible sets of reactants for synthesizing a particular target compound can be very large, growing exponentially with the number of individual reactants considered. For example, even when only considering <NUM> unique reactants that can be included in a set of reactants to synthesize a target compound, the number of candidate sets that can be generated is on the order of <NUM><NUM>. A system can use the techniques described herein to drastically reduce the time and computational cost required to determine an optimal set of reactants.

Using techniques described in this specification, a training system can perform consistent training of a neural network to generate predicted probabilities that unify the forward direction of reaction prediction and the backward direction of retrosynthesis. That is, the training system can leverage the duality of the forward and backward directions to ensure that the neural network generates consistent predicted probabilities.

After training using the described dual loss, the neural network is able to generate predictions that are more accurate than some existing approaches such as some existing graph-based models for retrosynthesis. Furthermore, the neural network can use an autoregressive architecture for each subnetwork, which yields higher capacity and better performance than some existing models for retrosynthesis.

This specification describes a system that performs retrosynthesis using a neural network. This specification also describes a system that trains a neural network to perform retrosynthesis.

<FIG> is a diagram of an example retrosynthesis system <NUM>. The retrosynthesis system <NUM> is an example of a system implemented as computer programs on one or more computers in one or more locations, in which the systems, components, and techniques described below can be implemented.

The retrosynthesis system <NUM> includes a target compound system <NUM>, a candidate reactant system <NUM>, and a neural network system <NUM>.

The target compound system <NUM> is configured to determine a target compound <NUM> to be retrosynthesized, i.e., a target compound <NUM> for which the retrosynthesis system <NUM> is to determine a set of reactants <NUM> that synthesizes the target compound <NUM>.

In some implementations, the target compound system <NUM> obtains an input from an external system that identifies the target compound <NUM>. For example, the target compound system <NUM> can obtain a user input from a user of the retrosynthesis system <NUM> that identifies the target compound <NUM> that the user wishes to be retrosynthesized. As a particular example, the target compound system <NUM> can obtain an input that includes the chemical formula and/or the name of the target compound <NUM>. Some other examples of ways to represent a target compound <NUM> are discussed below.

As another example, the target compound system <NUM> can obtain an input from an external system that is configured to perform in silico screening of candidate target compounds to identify the target compound <NUM> that has one or more desired qualities. For example, the external system can be a simulation system that automatically simulates the interaction between the target compound <NUM> and other compounds.

As another example, the target compound system <NUM> can obtain an input from an external system that is configured to perform high-throughput screening (HTS) of many different candidate target compounds to identify the target compound <NUM> that has one or more desired qualities. For example, the external system can be a robotic system that includes one or more robots configured to perform screening, e.g., HTS.

In some other implementations, the target compound system <NUM> can determine the target compound <NUM> without receiving an external input. For example, the target compound system <NUM> can itself be an in silico screening system or an HTS system as described above.

After determining the target compound <NUM>, the target compound system <NUM> can provide data characterizing the target compound <NUM> to the candidate reactant system <NUM>.

The candidate reactant system <NUM> is configured to determine multiple different candidate sets <NUM> of reactants that may synthesize the target compound <NUM>. Each candidate set <NUM> of reactants includes one or more reactants, where the candidate reactant system <NUM> has determined that it is possible or likely that the one or more reactants synthesize the target compound <NUM>.

In some implementations, the candidate reactant system <NUM> determines one or more of the multiple different candidate sets <NUM> of reactants using templates that each identify, for target compounds exhibiting a respective pattern (called a "target pattern"), a corresponding pattern (called a "reactant pattern") for candidate sets <NUM> of reactants that are known to synthesize target compounds. In this specification, a "pattern" for a set of one or more compounds (e.g., the target compound <NUM> or the candidate set <NUM> of reactants) is data defining one or more characteristics that the compounds in the set share. For example, a pattern for a set of compounds can be defined by a network graph that includes multiple nodes (e.g., nodes representing molecules) and edges between pairs of nodes (e.g., edges representing chemical bonds between molecules). If a graph representation of a compound includes a subgraph that matches the pattern, then the compound is defined to "match" the pattern. In this example, a template can be defined by a graph rewriting rule that specifies how to transform the target pattern (i.e., the graph pattern corresponding to a target compound) to the reactant pattern (i.e., the graph pattern corresponding to a set of reactants). As another example, the template can be defined by a graph rewriting rule that specifies how to transform the reactant pattern to the target pattern.

The candidate reactant system <NUM> can maintain a database of templates. Given the target compound <NUM>, the candidate reactant system <NUM> can identify one or more templates in the database for which the target compound <NUM> matches the target pattern of the template. Then, for each identified template, the candidate reactant system <NUM> can identify one or more candidate sets <NUM> of reactants that match the reactant pattern of the identified pattern.

Instead of or in addition to using templates, the candidate reactant system <NUM> can determine one or more of the multiple different candidate sets <NUM> of reactants using the neural network the neural network system <NUM>. As described in more detail below, the neural network system <NUM> is configured to execute a neural network that processes a network input generated from the target compound <NUM> and a candidate set <NUM> of reactants and generates a network output characterizing a score that represents a likelihood that the candidate set <NUM> of reactants will synthesize the target compound <NUM>. After the neural network has been trained, the candidate reactant system <NUM> can sample pairs of target compounds and sets of reactants that are likely to have a high score. Thus, given the target compound <NUM>, the candidate reactant system <NUM> can use the trained neural network to sample corresponding candidate sets <NUM> of reactants that are likely to have a high score. Example techniques for sampling from the neural network are discussed in more detail below with reference to <FIG>.

In some implementations, the candidate reactant system <NUM> can generate candidate sets <NUM> of reactants that include reactants that satisfy one or more conditions. For example, the candidate reactant system <NUM> can generate candidate sets <NUM> that include only reactants that are commercially available or that are themselves synthesizable using commercially available reactants. That is, if a particular reactant is not commercially available and cannot be easily synthesized, then it will not be useful for the system to output a set <NUM> of reactants that includes the particular reactant, as the set <NUM> cannot be practically used to synthesize the target compound <NUM>.

As mentioned above, the neural network system <NUM> is configured to obtain a network input generated from (i) data identifying the target compound <NUM> and (ii) data identifying a particular candidate set <NUM> of reactants, and to process the network input using a neural network to generate a network output characterizing a score that represents a likelihood that the particular candidate set <NUM> of reactants will synthesize the target compound <NUM>.

For example, the target compound <NUM> can be represented by a sequence of tokens, e.g., the simplified molecular input line entry system (SMILES) representation of the target compound <NUM>. Similarly, the candidate set <NUM> of reactants can be represented by a sequence of tokens that includes a respective subsequence representing each reactant in the candidate set <NUM>, e.g., the SMILES representation of the reactant in the candidate set <NUM>. In this example, the neural network of the neural network system <NUM> can be configured to process (i) the sequence of tokens representing the target compound <NUM> and (ii) the sequence of tokens representing the candidate set <NUM> and to generate the score for the candidate set <NUM>. As a particular example, the neural network can be a recurrent neural network. As another particular example, the neural network can be an attention-based neural network that attends across the tokens in the two sequences.

As another example, the target compound <NUM> and the candidate set <NUM> of reactants can be represented by respective graphs, as described above. In this example, the neural network of the neural network system <NUM> can be a graph neural network (GNN) that is configured to process (i) the graph representing the target compound <NUM> and (ii) the graph representing the candidate set <NUM> and to generate the score for the candidate set <NUM>.

An example neural network that is configured to perform retrosynthesis is described in more detail below with reference to <FIG>.

For each candidate set <NUM> generated by the candidate reactant system <NUM>, the neural network system <NUM> can generate a respective score, as described above. The neural network system <NUM> can then select, using the generated scores, a final set <NUM> of reactants from the multiple different candidate sets <NUM> of reactants. For example, the neural network system <NUM> can select the candidate set <NUM> that corresponds to the highest score.

In some implementations, the neural network system <NUM> can update the scores generated by the neural network to generate a final score for each candidate set <NUM> of reactants. For example, the neural network system <NUM> can update the scores according to one or more constraints or preferences for the synthesis of the target compound <NUM>.

As a particular example, the neural network system <NUM> can determine, for each candidate set <NUM> of reactants, a number of retrosynthesis steps required to synthesize the target compound <NUM> using the candidate set <NUM>. The neural network system <NUM> can then update the scores for the candidate sets <NUM> to reward candidate sets <NUM> that have fewer retrosynthesis steps (i.e., lowering the score for candidate sets <NUM> that have relatively many retrosynthesis steps and raising the score for candidate sets <NUM> that have relatively few retrosynthesis steps), because generally a candidate set that requires fewer retrosynthesis steps is preferred. In some implementations, the neural network system <NUM> can determine to discard candidate sets <NUM> that have a number of retrosynthesis steps that exceeds a predetermined threshold (i.e., determine not to select any such candidate set <NUM> to be the final set <NUM> of reactants). Instead or in addition, the neural network system <NUM> can scale the scores according to the number of retrosynthesis steps, e.g., by multiplying the score for a candidate set <NUM> by the inverse of the number of retrosynthesis steps of the candidate set <NUM>.

As another particular example, the neural network system <NUM> can determine, for each candidate set <NUM> of reactants, a selection of solvents and/or reagents that can be used to synthesize the target compound <NUM> using the candidate set <NUM> of reactants. The neural network system <NUM> can then update the scores for candidate sets <NUM> to reward candidate sets <NUM> that use preferred solvents and/or reagents. For instance, a user of the retrosynthesis system <NUM> might prefer not to use a particular solvent because it is hazardous or bad for the environment. In this example, the neural network system <NUM> can determine a lower final score for candidate sets <NUM> that require the particular solvent and a higher final score for candidate sets <NUM> that do not require the particular solvent to synthesize the target compound <NUM>. In some implementations, the neural network system <NUM> can determine to discard candidate sets <NUM> that require "blacklisted" solvents and/or reactants, i.e., solvents and/or reactants that have been identified, e.g., by a user of the system <NUM>, as disallowed.

As another particular example, the neural network system <NUM> can determine, for each candidate set <NUM> of reactants, a temperature at which the candidate set <NUM> of reactants can synthesize the target compound <NUM>. The system can then update the scores for candidate sets <NUM> to reward candidate sets <NUM> that do not require extreme temperature to synthesize the target compound <NUM>. In some implementations, the neural network system <NUM> can determine to discard candidate sets <NUM> that require temperatures that are outside of a predetermined acceptable range. Instead or in addition, the neural network system <NUM> can scale the score of a candidate set <NUM> according to the extent to which the required temperature of the candidate set <NUM> deviates from a predetermined range, e.g., by multiplying the score by the inverse of the difference between the required temperature and the closest temperature in the predetermined range.

After determining the final set <NUM> of reactants, the retrosynthesis system <NUM> can provide data identifying the final set <NUM> to a synthesis execution system <NUM>. The synthesis execution system <NUM> can be configured to synthesize the reactants in the final set <NUM> to generate the target compound <NUM>. For example, the synthesis execution system <NUM> can include one or more robotic components that can automatically execute the synthesis.

Instead or in addition to provide data identifying the final set <NUM> to a synthesis execution system <NUM>, the retrosynthesis system <NUM> can provide data identifying the final set <NUM> to a user system for display to a user of the retrosynthesis system <NUM>.

<FIG> is a diagram of an example neural network system <NUM> configured to perform retrosynthesis. The neural network system <NUM> is an example of a system implemented as computer programs on one or more computers in one or more locations, in which the systems, components, and techniques described below can be implemented.

The neural network system <NUM> is configured to obtain data identifying (i) a target compound <NUM> and (ii) a candidate set <NUM> of reactants, and to process a network input generated from the obtained data to generate score <NUM> that represents a likelihood that the candidate set <NUM> of reactants can synthesize the target compound <NUM>. For example, the neural network system <NUM> can be the neural network system <NUM> depicted in <FIG>.

The neural network system <NUM> includes three subnetworks <NUM>, <NUM>, and <NUM>, each of which are configured to generate a prediction for a different likelihood related to the candidate set <NUM> of reactants and the target compound <NUM>.

The first subnetwork <NUM> is configured to process a first subnetwork input generated from the candidate set <NUM> of reactants and to generate a predicted prior probability <NUM> of the candidate set <NUM> of reactants. That is, the first subnetwork <NUM> is configured to generate a prior probability p(X) of the candidate set of reactants X, which is a prediction of the likelihood of the candidate set X according to a data distribution of sets of reactants, e.g., according to an empirical data distribution of sets of reactants determined from a training data set.

For example, the first subnetwork input can be a sequence of tokens that represents the candidate set <NUM>, e.g., where the sequence includes a respective subsequence characterizing each reactant in the candidate set <NUM>. The subsequence corresponding to a particular reactant can include tokens that collectively represent the particular reactant, e.g., where each token represents a component of the structure of the reactant such as an atom, bond, molecule, substructure or, potentially, sterechemistry. As a particular example, the subsequence can be the simplified molecular input line entry system (SMILES) representation of the reactant. As another example the subsequence can be a representation based on a SELFIES (SELF-referencIng Embedded Strings) representation of the reactant (arXiv:<NUM>).

In some implementations, the first subnetwork <NUM> is a self-attention based neural network that attends to the tokens of the sequence representing the candidate set <NUM>. For example, the first subnetwork <NUM> can be a transformer neural network that includes an encoder configured to process, e.g., a placeholder input and to generate an encoder output, and a decoder configured to process (i) the encoder output and (ii) the sequence characterizing the candidate set <NUM> of reactants to generate the predicted prior probability p(X) <NUM> of the candidate set <NUM> of reactants. The placeholder input can be any choice of one or more tokens, e.g., period '. As another example, the first subnetwork <NUM> can include only the decoder of the transformer neural network that is configured to process the sequence characterizing the candidate set <NUM> of reactants to generate the predicted prior probability <NUM>.

In particular, the decoder of the transformer neural network can be an autoregressive neural network that is configured to iteratively generate a next token in a sequence of tokens by processing the previously-generated tokens in the sequence of tokens. The output of the decoder can include, for each possible next token, a respective score characterizing a likelihood that the possible next token should be selected to be the next token in the sequence.

In this example, the decoder of the first subnetwork <NUM> can be configured to iteratively process the first k tokens in the sequence representing the candidate set <NUM> and to generate an output that identifies, for each possible token (e.g., each possible SMILES token), a likelihood that the possible token should be selected for the sequence. The first subnetwork <NUM> can then identify the likelihood corresponding to the (k + <NUM>)th token in the sequence representing the candidate set <NUM> (i.e., the actual next token in the sequence). In this way the first subnetwork <NUM> can determine a likelihood corresponding to each token in the sequence representing the candidate set <NUM> (conditioned on the previous tokens in the sequence). The first subnetwork <NUM> can then multiply the determined likelihoods together to generate the predicted prior probability p(X) <NUM> of the candidate set <NUM> of reactants, since the prior probability p(X) is equal to the product of the likelihood of each token of X conditioned on the previous tokens, i.e., p(X) = p(x<NUM>) · p(x<NUM>|x<NUM>) · p(x<NUM>|x<NUM>,x<NUM>)···.

In some other implementations, the first subnetwork <NUM> can be a graph neural network that is configured to process a graphical representation of the candidate set <NUM> of reactants (e.g., graphical representation described above where each node of the graph represents a respective molecule and each edge represents a chemical bond between respective molecules) and to generate the predicted probability p(X) <NUM>.

In some other implementations, the first subnetwork <NUM> can be a feedforward neural network that is configured to process an embedding of the candidate set <NUM> of reactants (e.g., the sequence of tokens described above or any other appropriate embedding) and to generate the predicted probability p(X) <NUM>. In this specification, an embedding is an ordered collection of numeric values that represents an input in a particular embedding space. For example, an embedding can be a vector of floating point or other numeric values that has a fixed dimensionality.

The second subnetwork <NUM> is configured to process a second subnetwork input generated from the candidate set <NUM> of reactants and the target compound <NUM> and to generate a predicted conditional probability <NUM> of the target compound <NUM> given the candidate set <NUM> of reactants. That is, the second subnetwork <NUM> is configured to generate a predicted conditional probability p(y|X) of the target compound y conditioned on the candidate set of reactants X according to an empirical data distribution of pairs of (i) target compounds and (ii) sets of reactants.

For example, as described above the second subnetwork input can include (i) a sequence of tokens that represents the candidate set <NUM> and (ii) a sequence of tokens that represents the target compound <NUM>.

In some implementations, the second subnetwork <NUM> is a self-attention based neural network that attends to the tokens of the sequences representing the candidate set <NUM> and the target compound <NUM>. For example, the second subnetwork <NUM> can be a transformer neural network that includes an encoder configured to process the sequence characterizing the candidate set <NUM> of reactants and to generate an encoder output, and a decoder configured to process i) the encoder output and ii) the sequence characterizing the target compound <NUM> and to generate the predicted conditional probability p(y|X) <NUM> of the target compound <NUM> conditioned on the candidate set <NUM> of reactants.

In particular, the decoder of the second subnetwork <NUM> can be configured to iteratively process the first k tokens in the sequence representing the target compound <NUM> and to generate an output that identifies, for each possible token (e.g., each possible SMILES token), a likelihood that the possible token should be selected for the sequence. The second subnetwork <NUM> can then identify the likelihood corresponding to the (k + <NUM>)th token in the sequence representing the target compound <NUM> (i.e., the actual next token in the sequence). In this way the second subnetwork <NUM> can determine a likelihood corresponding to each token in the sequence representing the target compound <NUM> (conditioned on the previous tokens in the sequence). The second subnetwork <NUM> can then multiply the determined likelihoods together to generate the predicted conditional probability p(y|X) <NUM> of the target compound <NUM> conditioned on the candidate set <NUM> of reactants, since the conditional probability p(y|X) is equal to the product of the likelihood of each token of y conditioned on the previous tokens and X, i.e., p(y|X) = p(y<NUM>|X) · p(y<NUM>|y<NUM>,X) · p(y<NUM>|y<NUM>,y<NUM>,X)···.

In some other implementations, the second subnetwork <NUM> is a graph neural network that is configured to process (i) a graphical representation of the candidate set <NUM> of reactants and (ii) a graphical representation of the target compound <NUM> and to generate the predicted probability p(y|X) <NUM>.

In some other implementations, the second subnetwork <NUM> is a feedforward neural network that is configured to process (i) an embedding of the candidate set <NUM> of reactants and (ii) an embedding of the target compound <NUM> and to generate the predicted probability p(y|X) <NUM>.

The third subnetwork <NUM> is configured to process a third subnetwork input generated from the candidate set <NUM> of reactants and the target compound <NUM> and to generate a predicted conditional probability <NUM> of the candidate set <NUM> of reactants given the target compound <NUM>. That is, the third subnetwork <NUM> is configured to generate a predicted conditional probability p(X|y) of the candidate set of reactants X conditioned on the target compound y according to the empirical data distribution of pairs of (i) target compounds and (ii) sets of reactants.

For example, as described above the third subnetwork input can include (i) a sequence of tokens that represents the candidate set <NUM> and (ii) a sequence of tokens that represents the target compound <NUM>.

In some implementations, the third subnetwork <NUM> is a self-attention based neural network that attends to the tokens of the sequences representing the candidate set <NUM> and the target compound <NUM>. For example, the third subnetwork <NUM> can be a transformer neural network that includes an encoder configured to process the sequence characterizing the target compound <NUM> and to generate an encoder output, and a decoder configured to process (i) the encoder output and (ii) the sequence characterizing the candidate set <NUM> of reactants and to generate the predicted conditional probability p(X|y) <NUM> of the candidate set <NUM> of reactants conditioned on the target compound <NUM>.

In particular, the decoder of the third subnetwork <NUM> can be configured to iteratively process the first k tokens in the sequence representing the candidate set <NUM> and to generate an output that identifies, for each possible token (e.g., each possible SMILES token), a likelihood that the possible token should be selected for the sequence. The third subnetwork <NUM> can then identify the likelihood corresponding to the (k + <NUM>)th token in the sequence representing the candidate set <NUM> (i.e., the actual next token in the sequence). In this way the third subnetwork <NUM> can determine a likelihood corresponding to each token in the sequence representing the candidate set <NUM> (conditioned on the previous tokens in the sequence). The third subnetwork <NUM> can then multiply the determined likelihoods together to generate the predicted conditional probability p(X|y) <NUM> of the candidate set <NUM> of reactants conditioned on the target compound <NUM>, since the conditional probability p(X|y) is equal to the product of the likelihood of each token of X conditioned on the previous tokens and y, i.e., p(X|y) = p(x<NUM>|y) · p(x<NUM>|x<NUM>,y) · p(x<NUM>|x<NUM>,xo,y)···.

In some other implementations, the third subnetwork <NUM> is a graph neural network that is configured to process i) a graphical representation of the candidate set <NUM> of reactants and ii) a graphical representation of the target compound <NUM> and to generate the predicted probability p(X|y) <NUM>.

In some other implementations, the third subnetwork <NUM> is a feedforward neural network that is configured to process i) an embedding of the candidate set <NUM> of reactants and ii) an embedding of the target compound <NUM> and to generate the predicted probability p(X|y) <NUM>.

In implementations a self-attention based neural network as described above is a neural network with one or more self-attention layers i.e. a layer configured to apply a self-attention mechanism. The one or more self-attention layers may be also referred to as transformer neural network layers. A transformer neural network as described above may include an encoder coupled to a decoder, each of the encoder and decoder including one or more self-attention neural network layers.

In general a self-attention mechanism maps a query and a set of key-value pairs to an output, where the query, keys, and values are all vectors. The output is computed as a weighted sum of the values, where the weight assigned to each value is computed by a compatibility function of the query with the corresponding key. The exact self-attention mechanism applied depends on the configuration of the attention neural network. A self-attention mechanism is configured to relate different positions in the same sequence to determine a transformed version of the sequence as an output. For example a self-attention layer may generate a query and a key-value pair for an input e.g. derived from a sequence of tokens, and may then apply each of the queries to each of the key-value pairs, to determine a transformed version of the input. Tokens of a processed sequence may be combined with a position encoding value to define a position of a token in the sequence.

The neural network system <NUM> includes a scoring engine <NUM> that is configured to process (i) the prior probability <NUM> of the candidate set <NUM>, (ii) the conditional probability <NUM> of the target compound <NUM> given the candidate set <NUM>, and (iii) the conditional probability <NUM> of the candidate set <NUM> given the target compound <NUM>, and to generate the score <NUM>.

For example, the determined score can be dependent upon e.g. proportional to p(X) generated by the first subnetwork, p(y|X) generated by the second subnetwork, and p(X|y) generated by the third subnetwork. As a particular example, the score can be equal to or proportional to exp(log p(X) + log p(y|X) + log p(X|y)).

The neural network system <NUM> can be executed for each of multiple different candidate sets <NUM> of reactants, and the respective scores <NUM> for the different candidate sets <NUM> can be used to identify a final set of reactants that will be used to synthesize the target compound <NUM>, as described above.

<FIG> and <FIG> are diagrams of example training systems <NUM> and <NUM>, respectively, that are configured to train a neural network to perform retrosynthesis. The training systems <NUM> and <NUM> are examples of systems implemented as computer programs on one or more computers in one or more locations, in which the systems, components, and techniques described below can be implemented.

The neural network trained by the training systems <NUM> and <NUM> are configured to process a network input characterizing (i) a target compound and (ii) a candidate set of reactants and to generate a score for the candidate set, as described above. The neural network includes three subnetworks <NUM>, <NUM>, and <NUM>, which can be configured similarly to the subnetworks <NUM>, <NUM>, and <NUM>, respectively, described above with reference to <FIG>. That is, the first subnetwork <NUM> can be configured to process a first subnetwork input characterizing the candidate set and to generate a prior probability p(X) of the candidate set; the second subnetwork <NUM> can be configured to process the second subnetwork input characterizing the target compound and the candidate set and to generate a conditional probability p(y|X) of the target compound given the candidate set; and the third subnetwork <NUM> can be configured to process a third subnetwork input characterizing the candidate set and the target compound and to generate a conditional probability p(X|y) of the candidate set given the target compound.

The training systems <NUM> and <NUM> can train the neural network using a dual loss function that leverages the fact that the joint probability p(X,y) can be factorized in two ways: a "forward" direction p(X)p(y|X) which represents synthesis given a set of reactants, and a "backward" direction p(y)p(X|y) which represents retrosynthesis given a target compound. In theory, the probabilities corresponding to both directions should be equal, i.e., equal to p(X,y). Thus, the dual loss can encourage the subnetworks <NUM>, <NUM>, and <NUM> of the neural network to generate probabilities that satisfy this equality. In some implementations, the p(y) value can be fixed, e.g., fixed at a value of one, because the target compound is predetermined.

Referring, to <FIG>, the training system <NUM> is configured to train the subnetworks <NUM>, <NUM>, and <NUM> of the neural network in parallel.

The training system <NUM> can obtain a training example that includes (i) a training set <NUM> of reactants and ii) a training target compound <NUM>, and process the training example using the neural network to generate a first subnetwork output <NUM> corresponding to the first subnetwork <NUM> (characterizing the prior probability of the training set <NUM>), a second subnetwork output <NUM> corresponding to the second subnetwork <NUM> (characterizing the conditional probability of the training target compound <NUM> given the training set <NUM>), and a third subnetwork output corresponding to the third subnetwork <NUM> (characterizing the conditional probability of the training set <NUM> given the training target compound). A training engine <NUM> of the training system <NUM> can then determine an update <NUM> to the parameters of the neural network in order to minimize a dual loss that characterizes, for the training set of reactants, a difference between (i) a first predicted joint probability of the training set of reactants and the training target compound defined by the first subnetwork output and the second subnetwork output and (ii) a second predicted joint probability of the training set of reactants and the training target compound defined by the third subnetwork output.

As a particular example, the dual loss can penalize a KL divergence between (i) a distribution corresponding to the first predicted joint probability and (ii) a distribution corresponding to the second predicted joint probability. For instance, the dual loss can be equal to, proportional to, or generated from: <MAT> where (X,y) is the training set of reactants and training target compound, (X, y) is the training data set, P(X,y) is the first joint probability, and Q(X,y) is the second joint probability.

Optionally data augmentation may be used, permuting an order of the training set of reactants in a training sample, for order invariance.

In some implementations, instead of or in addition to penalizing the different between the respective likelihoods of the forward and backward directions, the dual loss can penalize the difference between (i) the one or both of the two distributions described above and (ii) the empirical distribution of the training data. As a particular example, the training system <NUM> can sample the training example from an empirical data distribution (e.g., a predetermined empirical data distribution defined by a training data set), and determine the loss according to the empirical data distribution. Thus in implementations the empirical data distribution is determined by the training data. The empirical data distribution can include, for each pair of (i) training target compound and (ii) training set of reactants, a corresponding joint probability. The dual loss can include a term Ê[log p(X) + log p(y|X)] corresponding to the first subnetwork output and the second subnetwork output, where Ê[·] indicates an expectation over the empirical data distribution. The dual loss can include a term Ê[logp(X|y)] corresponding to the third subnetwork output, where Ê[·] indicates an expectation over the empirical data distribution. Example dual losses are discussed in more detail below with reference to <FIG>.

Referring to <FIG>, the training system <NUM> can train the third subnetwork <NUM> in a first training stage and the first subnetwork <NUM> and second subnetwork <NUM> in a second training phase.

In the first training phase, to train the third subnetwork <NUM>, the training system <NUM> can sample training examples that each include a training target compound and a training set of reactants, and determine updates to the parameters of the third subnetwork <NUM> according to a difference between (i) a predicted joint probability determined using the third subnetwork output and (ii) the empirical data distribution of the training data, as described above with reference to <FIG>. For example, the training system <NUM> can determine parameter updates using backpropagation and gradient descent, e.g. by backpropagating gradients of the dual loss function.

In the second training phase, the training system <NUM> can use the third subnetwork <NUM> to sample training examples for the first subnetwork <NUM> and the second subnetwork <NUM>. That is, the training system <NUM> can sample, from a predicted data distribution defined by the trained subnetwork, a training example that includes (i) a set <NUM> of reactants and ii) a target compound <NUM>. For example, the training system <NUM> can sample the training example using beam search on the trained third subnetwork <NUM>.

The training system <NUM> can then process a first subnetwork input generated from the sampled set <NUM> of reactants using the first subnetwork <NUM> to generate a first subnetwork output <NUM> characterizing predicted p(X), as described above. The training system <NUM> can process a second subnetwork input generated from the sampled set <NUM> and the sampled target compound <NUM> using the second subnetwork <NUM> to generate a second subnetwork output <NUM> characterizing predicted p(y|X), as described above.

A training engine <NUM> of the training system <NUM> can then determine the dual loss for the first subnetwork <NUM> and the second subnetwork <NUM> according to (i) the predicted data distribution defined by the trained third subnetwork <NUM>, (ii) the first subnetwork output <NUM>, and (iii) the second subnetwork output <NUM>. For example, the dual loss can include a term <MAT>, where <MAT> indicates an expectation over an empirical data distribution of y (e.g., the empirical data distribution defined by the training data), EX|y indicates an expectation over the predicted data distribution corresponding to the third subnetwork, and β is a weight value.

As a particular example, the dual loss can be equal to <MAT>.

The training engine <NUM> can then determine a parameter update <NUM> for the first subnetwork <NUM> and the second subnetwork <NUM> according to the determined dual loss, e.g., using backpropagation and stochastic gradient descent.

<FIG> is a flowchart of an example process <NUM> for performing retrosynthesis using a neural network. The process <NUM> can be implemented by one or more computer programs installed on one or more computers and programmed in accordance with this specification. For example, the process <NUM> can be performed by a retrosynthesis system, e.g., the retrosynthesis system <NUM> depicted in <FIG>. For convenience, the process <NUM> will be described as being performed by a system of one or more computers.

The neural network is configured to generate a prediction of a set of multiple predicted reactants that are combinable to generate a target compound.

The system processes, for each of multiple candidate sets of reactants, a network input characterizing the candidate set using the neural network. This processing includes steps <NUM>, <NUM>, and <NUM>, described in more detail below. That is, the system repeats steps <NUM>-<NUM> for each of the multiple different candidate sets of reactants.

The system processes the network input using a first subnetwork to generate a predicted prior probability of the candidate set of reactants according to an empirical data distribution of sets of predicted reactants and target compounds (step <NUM>).

The system processes the network input using a second subnetwork to generate a predicted conditional probability of the target compound conditioned on the candidate set of reactants according to the empirical data distribution (step <NUM>).

The system processes the network input using a third subnetwork to generate a predicted conditional probability of the candidate set of reactants conditioned on the target compound according to the empirical data distribution (step <NUM>).

The system determines, for each candidate set of the multiple candidate sets of reactants, a score using the generated probabilities (step <NUM>). For example, the system can compute a sum of the logs of the probabilities.

The system selects a particular candidate set of reactants using the determined scores (step <NUM>). For example, the system can select the candidate set with the highest score.

Claim 1:
A computer-implemented method for generating a prediction of a set of a plurality of predicted reactants (<NUM>, <NUM>) that are combinable to generate a target compound (<NUM>, <NUM>), the generating comprising:
processing (<NUM>), for each of a plurality of candidate sets of reactants, a network input characterizing the candidate set using a neural network (<NUM>, <NUM>), the network input being generated from (i) data identifying the target compound and (ii) data identifying the candidate set of reactants, the processing comprising:
processing (<NUM>) the network input using a first subnetwork (<NUM>, <NUM>) to generate a predicted prior probability (<NUM>) of the candidate set of reactants according to a data distribution of sets of predicted reactants and target compounds;
processing (<NUM>) the network input using a second subnetwork (<NUM>, <NUM>) to generate a predicted conditional probability (<NUM>) of the target compound conditioned on the candidate set of reactants according to the data distribution;
processing (<NUM>) the network input using a third subnetwork (<NUM>, <NUM>) to generate a predicted conditional probability (<NUM>) of the candidate set of reactants conditioned on the target compound according to the data distribution;
determining (<NUM>), for each candidate set of the plurality of candidate sets, a score (<NUM>) using the generated probabilities; and
selecting (<NUM>) a particular candidate set of one or more reactants (<NUM>) using the determined scores.