Molecular graph generation method and device
Through the molecular graph generation method, candidate atomic and chemical bond prediction sub-models are used to generate candidate atomic sequences and chemical bonds, which solves the problems of low drug design efficiency and high computing resource consumption in the prior art, and achieves efficient molecular graph generation and drug design.
Patent Information
- Application Number
- CN202210554539.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-20
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2042-05-20
AI Technical Summary
The prior art is difficult to efficiently screen molecules with drug characteristics in the fields of chemical and drug discovery, and a large amount of computing resources and time is required in the design process of brand new drug.
Using the molecular graph generation method, by obtaining a molecular graph generation model including an atomic predictor model and a chemical bond predictor model, atomic prediction is used to perform atomic prediction, candidate atomic sequence is determined, and molecular graphs corresponding to candidate atomic sequence are generated through chemical bond prediction.
It improves the efficiency of candidate atomic sequences and chemical bond generation, narrows the search space for target chemical molecules, improves drug design efficiency and reduces costs.
Smart Images

Figure CN114822721B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, specifically to the field of biological computing technology and the field of artificial intelligence technology, and especially to a method and device for generating a molecular graph. Background Art
[0002] In the field of chemistry and drug discovery, screening molecules with drug properties from a huge chemical space is the main problem faced in drug design. The current virtual screening method consumes a lot of computing resources and time costs, and it is difficult to generate new molecular structures. De novo drug design can narrow the search space for target chemical molecules, greatly improve drug design efficiency and reduce costs.
[0003] With the continuous development and progress of artificial intelligence, a large number of molecular generation models have emerged and have become an effective means of new drug design. In the model architecture design, the existing molecular generation models can be generated by sampling from the latent space. Summary of the invention
[0004] The present disclosure provides a molecular graph generation method, device, electronic device, storage medium and computer program product.
[0005] According to one aspect of the present disclosure, a molecular graph generation method is provided, the method comprising: obtaining a molecular graph generation model, wherein the molecular graph generation model comprises an atom prediction sub-model and a chemical bond prediction sub-model; inputting a start symbol into the atom prediction sub-model for atom prediction to determine a candidate atom sequence; inputting the candidate atom sequence into the chemical bond prediction sub-model for chemical bond prediction to generate a molecular graph corresponding to the candidate atom sequence.
[0006] According to another aspect of the present disclosure, a molecular graph generation device is provided, which includes: an acquisition module, configured to acquire a molecular graph generation model, wherein the molecular graph generation model includes an atom prediction sub-model and a chemical bond prediction sub-model; an atom prediction module, configured to input a start symbol into the atom prediction sub-model for atom prediction, and determine a candidate atom sequence; and a chemical bond prediction module, configured to input a candidate atom sequence into the chemical bond prediction sub-model for chemical bond prediction, and generate a molecular graph corresponding to the candidate atom sequence.
[0007] According to another aspect of the present disclosure, an electronic device is provided, which includes at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned molecular graph generation method.
[0008] According to another aspect of the present disclosure, a computer-readable medium is provided, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the above-mentioned molecular graph generation method.
[0009] According to another aspect of the present disclosure, an embodiment of the present application provides a computer program product, which includes a computer program / instructions, and when the computer program / instructions are executed by a processor, the above-mentioned molecular graph generation method is implemented.
[0010] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0012] Figure 1 is a flow chart of one embodiment of a molecular graph generation method according to the present disclosure;
[0013] Figure 2 is a schematic diagram of an application scenario of the molecular graph generation method according to the present disclosure;
[0014] Figure 3 is a flow chart of one embodiment of determining a candidate atomic sequence according to the present disclosure;
[0015] Figure 4 is a flow chart of an embodiment of generating a molecular graph corresponding to a candidate atomic sequence according to the present disclosure;
[0016] Figure 5 is a flow chart of one embodiment of optimizing a molecular graph according to the present disclosure;
[0017] Figure 6 is a flow chart of an embodiment of obtaining an atomic prediction sub-model according to the present disclosure;
[0018] Figure 7 is a flow chart of an embodiment of obtaining a chemical bond prediction sub-model according to the present disclosure;
[0019] Figure 8 is a schematic structural diagram of an embodiment of a molecular graph generating device according to the present disclosure;
[0020] Fig. 9 It is a block diagram of an electronic device used to implement the molecular graph generating method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0021] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0022] refer to Figure 1 , Figure 1 A flowchart 100 of an embodiment of a molecular graph generation method that can be applied to the present disclosure is shown. The molecular graph generation method comprises the following steps:
[0023] Step 110, obtaining a molecular graph generation model.
[0024] In this embodiment, the execution entity of the molecular graph generation method (such as a server) can read the molecular graph generation model used to generate a molecular graph through the network or locally. The molecular graph can be a compound molecular graph, which is composed of multiple atoms and chemical bonds. The molecular graph generation model can be used to perform untargeted random sampling molecular generation tasks, that is, it can sample and predict atoms and chemical bonds to generate random molecular graphs, and a variety of molecular graphs can be obtained.
[0025] The above-mentioned molecular graph generation model includes an atom prediction sub-model and a chemical bond prediction sub-model, which can be a model trained based on a natural language pre-training model (uniLM). The atom prediction sub-model can be connected to the chemical bond prediction sub-model, and the output result of the atom prediction sub-model can be directly input into the chemical bond prediction sub-model. Among them, the atom prediction sub-model can be a neural network including a Transformer encoder, which is used to perform atom prediction to obtain a random candidate atom sequence, and input the obtained candidate atom sequence into the chemical bond prediction sub-model; the chemical bond prediction sub-model can be a neural network including a Transformer encoder and an attention mechanism, which is used to perform chemical bond prediction for each candidate atom in the candidate atom sequence. Based on the attention mechanism, the relationship between the currently generated chemical bond and the historically generated chemical bond can be considered, thereby predicting the chemical bond of each candidate atom in the candidate atom sequence.
[0026] Step 120: input the start symbol into the atom prediction sub-model to perform atom prediction and determine a candidate atom sequence.
[0027] In this embodiment, after the execution subject obtains the molecular graph generation model including the atom prediction sub-model and the chemical bond prediction sub-model, it can receive the start symbol set by the operator, which can be used as a special node in the molecular graph and can be expressed as <cls>The start symbol can be used as the input of the atom prediction sub-model to start the atom prediction operation. After the execution subject obtains the start symbol, it inputs the start symbol into the atom prediction sub-model. After receiving the start symbol, the atom prediction sub-model starts to predict atoms based on the start symbol, autonomously learns based on the learning samples in the training process, randomly predicts multiple candidate atoms, and determines the predicted multiple candidate atoms as candidate atom sequences.
[0028] The candidate atom sequence may include multiple randomly predicted candidate atoms, for example, <cls>The atom prediction submodel can learn autonomously according to the learning samples in the training process. After receiving the start symbol, it can randomly predict multiple candidate atoms that can be used to generate chemical bonds. The present disclosure does not specifically limit the number and type of candidate atoms.
[0029] Step 130 , input the candidate atomic sequence into the chemical bond prediction sub-model to perform chemical bond prediction, and generate a molecular graph corresponding to the candidate atomic sequence.
[0030] In this embodiment, after the execution subject determines the candidate atomic sequence through the atom prediction sub-model, the candidate atomic sequence is input into the chemical bond prediction sub-model. After the chemical bond prediction sub-model receives the candidate atomic sequence, it can determine the current atom from the candidate atomic sequence according to the arrangement order of the atoms, and then predict the chemical bonds between the current atom and other candidate atoms in the candidate atomic sequence, so as to determine whether there are chemical bonds between the current atom and other candidate atoms. Then the execution subject can use the candidate atom sorted after the current atom in the candidate atomic sequence as the new current atom, and predict the chemical bonds between the new current atom and other candidate atoms in the candidate atomic sequence until the chemical bonds of each candidate atom in the candidate atomic sequence are determined.
[0031] After the above-mentioned execution entity determines the chemical bond of each candidate atom in the candidate atomic sequence through the chemical bond prediction sub-model, each candidate atom can be connected according to the chemical bond of each candidate atom to generate a molecular graph corresponding to the candidate atomic sequence, which includes each candidate atom in the candidate atomic sequence and the chemical bond between each candidate atom.
[0032] Continue to see Figure 2 , Figure 2 It is a schematic diagram of an application scenario of the molecular graph generation method according to this embodiment.
[0033] exist Figure 2 In the application scenario, the server 201 may locally store a molecular graph generation model including an atom prediction submodel and a chemical bond prediction submodel. The terminal 202 may send a start symbol to the server 201, and the server 201 may read the locally stored molecular graph generation model including an atom prediction submodel and a chemical bond prediction submodel. After receiving the start symbol sent by the terminal 202, the server 201 may input the start symbol into the atom prediction submodel for atom prediction, determine a candidate atomic sequence, and then the server 201 may input the candidate atomic sequence into the chemical bond prediction submodel for chemical bond prediction, generate a molecular graph corresponding to the candidate atomic sequence, and send the generated molecular graph to the terminal 202.
[0034] The molecular graph generation method provided by the embodiments of the present disclosure obtains a molecular graph generation model, which includes an atom prediction submodel and a chemical bond prediction submodel, then inputs a start symbol into the atom prediction submodel for atom prediction, determines a candidate atom sequence, and finally inputs the candidate atom sequence into the chemical bond prediction submodel for chemical bond prediction, generates a molecular graph corresponding to the candidate atom sequence, can predict the required candidate atom sequence according to the start symbol, does not need to generate an atom feature matrix by sampling from the latent space of the molecular graph, improves the search efficiency of the candidate atom sequence, and can predict the corresponding chemical bonds based on the candidate atom sequence and the chemical bond prediction submodel, does not need to collect an adjacency matrix with chemical bond features from the latent space of the molecular graph, improves the efficiency of chemical bond generation, and completes the generation of the molecular graph by using the two steps of candidate atom sequence generation and chemical bond generation between candidate atoms, can effectively improve the effect of molecular graph generation, reduce the difficulty of molecular graph generation, and improve operating efficiency.
[0035] refer to Figure 3 , Figure 3 A flowchart 300 of an embodiment of determining a candidate atomic sequence is shown, that is, the above step 120, inputting the start symbol into the atom prediction sub-model for atom prediction, and determining the candidate atomic sequence may include the following steps:
[0036] Step 310: input the start symbol into the atom prediction sub-model to perform atom prediction and obtain a predicted atom sequence.
[0037] In this embodiment, after the execution subject obtains the molecular graph generation model including the atom prediction sub-model and the chemical bond prediction sub-model, it can receive the start symbol set by the operator, which can be used as a special node in the molecular graph and can be expressed as <cls>And other forms, which can be connected to atoms in molecular diagrams.
[0038] The above-mentioned start symbol can be used as the input of the atom prediction sub-model. After the above-mentioned execution subject obtains the start symbol, the start symbol can be input into the atom prediction sub-model. After receiving the start symbol, the atom prediction sub-model starts to predict atoms based on the start symbol, autonomously learns based on the learning samples in the training process, and randomly predicts multiple predicted atoms. The above-mentioned execution subject can be arranged according to the prediction order of the predicted atoms to obtain the predicted atom sequence corresponding to the multiple predicted atoms.
[0039] Step 320: In response to predicting the end symbol, determine the predicted atomic sequence as a candidate atomic sequence.
[0040] In this embodiment, the execution subject can make random predictions for each atomic node using the atomic prediction submodel, and directly output the predicted atoms until the predicted node is an end symbol, at which time the atomic prediction submodel stops atomic prediction and uses the predicted atomic sequence before the end symbol as the candidate atomic sequence. The end symbol can be used as a special node in the molecular graph, which can be expressed as <sp>It can be connected to atoms in the molecular graph and can be used to terminate the atomic prediction of the atomic prediction submodel.
[0041] When training, the atom prediction submodel can learn the molecular graph annotated with a start symbol and an end symbol. The start symbol can be used to start the atom prediction of the atom prediction submodel, and the end symbol can be used to terminate the atom prediction of the atom prediction submodel. When the atom prediction submodel receives the start symbol, it can start atom prediction and output the predicted candidate atoms. When the end symbol is predicted, it can stop atom prediction and output all predicted candidate atoms. For example, it can be expressed as <cls>CCC <sp>The atom prediction submodel can learn autonomously according to the learning samples in the training process. After receiving the start symbol, it can randomly predict multiple candidate atoms that can be used to generate chemical bonds. After predicting the end symbol, it stops atom prediction. The present disclosure does not specifically limit the number and type of candidate atoms.
[0042] In this embodiment, special symbols such as start and end symbols are introduced to construct the input of the atom prediction sub-model to start and stop the atom prediction of the atom prediction sub-model, thereby avoiding endless atom prediction, improving the accuracy and flexibility of atom prediction, and using the atom prediction sub-model for atom prediction, thereby improving the prediction efficiency and accuracy of candidate atoms.
[0043] refer to Figure 4 , Figure 4 A flowchart 400 of an embodiment of generating a molecular graph corresponding to a candidate atomic sequence is shown, that is, the above step 130, inputting the candidate atomic sequence into a chemical bond prediction sub-model for chemical bond prediction, and generating a molecular graph corresponding to the candidate atomic sequence, which may include the following steps:
[0044] Step 410: Input the candidate atomic sequence into the encoding layer for encoding processing to obtain the encoding vector corresponding to the candidate atomic sequence.
[0045] The above-mentioned chemical bond prediction sub-model may include an encoding layer and an attention mechanism, wherein the encoding layer may be a Transformer Encoder (Transformer Encoder), which may be connected to an attention mechanism (attention), and may be followed by a residual layer (add / norm).
[0046] In this embodiment, after the execution subject obtains the candidate atomic sequence through the atomic prediction sub-model, the candidate atomic sequence can be input into the encoding layer of the chemical bond prediction sub-model. The encoding layer of the chemical bond prediction sub-model can encode each candidate atom in the candidate atomic sequence to obtain the encoding vector corresponding to the candidate atomic sequence.
[0047] In step 420, the encoding vector is input into the attention mechanism for attention processing to predict the chemical bonds of the candidate atomic sequence.
[0048] In this embodiment, after the execution subject obtains the encoding vector corresponding to the candidate atomic sequence through the encoding layer of the chemical bond prediction sub-model, the obtained encoding vector can be input into the attention mechanism of the chemical bond prediction sub-model. The attention mechanism of the chemical bond prediction sub-model can perform attention processing on the encoding vector corresponding to the candidate atomic sequence to consider the relationship between the currently generated chemical bonds and the historically generated chemical bonds, and perform residual processing through the residual layer to predict the chemical bonds of each candidate atom in the candidate atomic sequence.
[0049] As an optional implementation method, as well as the above-mentioned step 420, inputting the coding vector into the attention mechanism for attention processing to predict the chemical bonds of the candidate atomic sequence can include the following steps: performing a first attention processing on the coding vector through the attention mechanism to obtain a first processing result corresponding to the coding vector; performing a second attention processing on the first processing result through the attention mechanism to predict the chemical bonds of the candidate atomic sequence.
[0050] In this implementation, the attention mechanism processing includes a first attention processing for focusing on the correlation between the current candidate atom and other candidate atoms and a second attention processing for focusing on the correlation between the current candidate atom and other atomic relationships in the current subgraph that have been predicted. The first attention processing can be an attention processing for the correlation between the current candidate atom and other candidate atoms, and the correlation between the current candidate atom and each of the other candidate atoms is determined; the second attention processing can be an attention processing for the correlation between the current candidate atom and other atomic relationships in the current subgraph that have been predicted, and the correlation between the current candidate atom and the determined historical chemical bonds is determined.
[0051] After the above-mentioned execution subject obtains the encoding vector corresponding to the candidate atomic sequence through the encoding layer of the chemical bond prediction sub-model, the obtained encoding vector can be input into the attention mechanism of the chemical bond prediction sub-model. The attention mechanism of the chemical bond prediction sub-model can perform a first attention processing on the encoding vector corresponding to the candidate atomic sequence, analyze the correlation between the current candidate atom and each candidate atom in the candidate atomic sequence, and obtain the corresponding first processing result. Then the attention mechanism of the chemical bond prediction sub-model can perform a second attention processing on the first processing result, analyze the correlation between the current candidate atom and the historical chemical bonds in the generated molecular graph, and thus predict the chemical bonds of the candidate atomic sequence.
[0052] As an example, the above execution subject obtains a candidate atomic sequence through the atomic prediction sub-model, and the candidate atomic sequence is <cls>abc <sp>, the candidate atomic sequence <cls>abc <sp>Input into the encoding layer in the chemical bond prediction sub-model to obtain the corresponding encoding vector. <cls>abc <sp>The corresponding encoding vector is input into the attention mechanism in the chemical bond prediction sub-model, which can analyze the correlation between candidate a and candidate b, candidate a and candidate c, and candidate b and candidate c. After determining the correlation between each candidate atom and other candidate atoms, it is necessary to further analyze the correlation between the chemical bonds of candidate a, candidate b, and candidate c, so as to determine the candidate atomic sequence. <cls>abc <sp>The corresponding chemical bonds.
[0053] If candidate atom a and candidate b and the chemical bond between candidate a and candidate b are known, and a new candidate atom c is obtained, when predicting the chemical bond between the new candidate atom c and candidate a, the correlation between the new candidate atom c and candidate a, and the correlation between candidate atom a and candidate b will be analyzed; when predicting the chemical bond between the new candidate atom c and candidate b, the correlation between the new candidate atom c and candidate b, and the correlation between candidate atom a and candidate b will be analyzed, and the chemical bond between the predicted new candidate atom c and candidate a will also be analyzed.
[0054] In this implementation, the encoding vector is processed by the attention mechanism. In the process of predicting chemical bonds, the relationship between the previously generated chemical bonds and the current candidate atoms can be taken into account, which increases the dimension of chemical bond prediction and makes the predicted chemical bonds more accurate, thereby improving the generation effect of molecular graphs.
[0055] Step 430: Generate a molecular graph corresponding to the candidate atomic sequence based on the chemical bonds of the candidate atomic sequence.
[0056] In this embodiment, after the execution subject predicts the chemical bonds of the candidate atomic sequence through the attention mechanism in the chemical bond prediction sub-model, each candidate atom can be connected based on the chemical bonds of each candidate atom to generate a molecular graph corresponding to the candidate atomic sequence.
[0057] In this embodiment, by adding an attention mechanism to perform attention processing on the encoding vector, the dimension of chemical bond prediction is increased, making the predicted chemical bonds more accurate, thereby improving the generation effect of the molecular graph.
[0058] refer to Figure 5 , Figure 5 A flowchart 500 showing one embodiment of optimizing a molecular graph may include the following steps:
[0059] Step 510: Obtain the molecular graph to be optimized.
[0060] In this embodiment, the above-mentioned execution entity can obtain the molecular graph to be optimized by reading it through the network or receiving it uploaded by users. The molecular graph to be optimized may include multiple reference atoms that have reference chemical bonds connected, and the reference atoms in the molecular graph to be optimized may be marked with start symbols and end symbols.
[0061] Step 520: Input the molecular graph to be optimized into the atom prediction sub-model for atom prediction to determine the optimized atom sequence corresponding to the molecular graph to be optimized.
[0062] In this embodiment, the above-mentioned execution entity inputs the acquired molecular graph to be optimized into the atom prediction sub-model, and the atom prediction sub-model predicts and identifies the molecular graph to be optimized, detects the start symbol in the molecular graph to be optimized, and the atom prediction sub-model starts to detect the reference atoms in the molecular graph to be optimized, and performs atom prediction based on the reference atoms in the molecular graph to be optimized, and determines the optimized atom sequence corresponding to the molecular graph to be optimized. The optimized atom sequence includes the reference atoms included in the molecular graph to be optimized, and also includes predicted atoms predicted based on the reference atoms. Until the predicted node is an end symbol, the atom prediction sub-model stops atom prediction, and uses the reference atoms and predicted atoms before the end symbol as the optimized atom sequence.
[0063] Step 530, input the optimized atomic sequence into the chemical bond prediction sub-model to perform chemical bond prediction, and generate an optimized molecular graph corresponding to the molecular graph to be optimized.
[0064] In this embodiment, after the above-mentioned execution subject obtains the optimized atomic sequence, the optimized atomic sequence can be input into the chemical bond prediction sub-model. After the chemical bond prediction sub-model receives the optimized atomic sequence, the current atom can be determined from the optimized atomic sequence according to the arrangement order of the atoms, and then the chemical bonds between the current atom and other optimized atoms in the optimized atomic sequence are predicted, so as to determine whether there are chemical bonds between the current atom and other optimized atoms. Then the above-mentioned execution subject can use the optimized atom sorted after the current atom in the optimized atomic sequence as the new current atom, and predict the chemical bonds between the new current atom and other optimized atoms in the optimized atomic sequence until the chemical bonds of each optimized atom in the optimized atomic sequence are determined.
[0065] After the above-mentioned execution entity determines the chemical bond of each optimized atom in the optimized atomic sequence through the chemical bond prediction sub-model, each optimized atom can be connected according to the chemical bond of each optimized atom to generate an optimized molecular graph corresponding to the optimized atomic sequence. The optimized molecular graph includes each optimized atom in the optimized atomic sequence and the chemical bond between each optimized atom, and is a molecular graph obtained after the molecular structure of the optimized molecular graph is optimized.
[0066] In this embodiment, the molecular structure of the molecular graph to be optimized is optimized through the atomic prediction submodel and the chemical bond prediction submodel to generate a molecular structure with better properties, thereby improving the effect of the molecular graph. The molecular graph generation model including the atomic prediction submodel and the chemical bond prediction submodel can not only generate random molecular graphs, but also optimize the molecular graphs, making the molecular graph generation model more task-diverse, effectively improving the effect of molecular graph generation, reducing the difficulty of model migration, thereby reducing the difficulty of use and improving the operating efficiency of the product.
[0067] refer to Figure 6 , Figure 6 A flowchart 600 of an embodiment of obtaining an atomic prediction sub-model is shown, which may include the following steps:
[0068] Step 610: Obtain a first training sample set.
[0069] In this step, the first training sample set may include sample molecular graphs annotated with start and end symbols and sample atomic sequences corresponding to the sample molecular graphs. The execution subject may obtain multiple sample molecular graphs from a predetermined database through a network, each sample molecular graph including multiple sample atoms, annotate the sample atoms in each sample molecular graph, and determine the start and end symbols corresponding to the sample molecular graph. The execution subject uses the sample molecular graphs annotated with start and end symbols and the sample atomic sequences corresponding to the sample molecular graphs as the first training sample set for training.
[0070] Step 620, construct a first initial model including an input layer and a Transformer encoder.
[0071] In this step, after the execution subject obtains the first training sample set, it can construct a first initial model including an input layer and a Transformer encoder.
[0072] Step 630, using a machine learning method, taking the sample molecular graph as the input of the input layer, and the sample atomic sequence corresponding to the sample molecular graph as the expected output of the Transformer encoder, training the first initial model to obtain an atomic prediction sub-model.
[0073] In this step, after the above-mentioned execution entity obtains the first training sample set and constructs the first initial model, it can use a machine learning method to train the first initial model based on the first training sample set using a unified pre-trained language model (unilm, Unified Language Model Pre-training for Natural Language Understanding and Generation) training method to obtain an atomic prediction sub-model.
[0074] Specifically, the above-mentioned execution entity can input the sample molecular graph into the first initial model, and use the sample molecular graph as the input of the input layer. After processing by the first initial model, the predicted atomic sequence corresponding to the sample molecular graph can be obtained. The network structure of the above-mentioned first initial model can be a network framework including an input layer and a Transformer encoder in the relevant technology, and the processing flow of parameters in other network layers can also refer to the processing flow of the unilm model in the relevant technology.
[0075] During the training process, the above-mentioned execution subject can use the sample atomic sequence corresponding to the sample molecular graph as the expected output of the Transformer encoder, and then compare the output predicted atomic sequence with the expected output to determine whether the predicted atomic sequence meets the constraint conditions. If the predicted atomic sequence does not meet the constraint conditions, the network parameters of the first initial model are adjusted, and the sample molecular graph is input again to continue training. If the predicted atomic sequence meets the constraint conditions, the model training is completed and the atomic prediction sub-model is obtained. Among them, the constraint condition can be that the difference between the predicted atomic sequence and the sample atomic sequence in the first training sample set meets a preset threshold. The preset threshold can be pre-set based on experience, and the present disclosure does not make specific limitations on this.
[0076] In this implementation, the first initial model is trained by acquiring sample molecular graphs and sample atomic sequences to obtain an atom prediction sub-model, which can improve the efficiency and accuracy of atom prediction, and can improve the accuracy and efficiency of generating molecular graphs.
[0077] refer to Figure 7 , Figure 7 A flowchart 700 showing an embodiment of obtaining a chemical bond prediction sub-model may include the following steps:
[0078] Step 710: Obtain a second training sample set.
[0079] In this step, the second training sample set may include sample atomic sequences and sample chemical bonds corresponding to the sample atomic sequences. The execution subject may obtain the sample atomic sequences from a predetermined database through a network, determine chemical bonds of sample atoms in the sample atomic sequences, and obtain sample chemical bonds corresponding to the sample atomic sequences. The execution subject uses the sample atomic sequences and the sample chemical bonds corresponding to the sample atomic sequences as the second training sample set used when training the model.
[0080] Step 720, construct a second initial model including a Transformer encoder and an attention mechanism.
[0081] In this step, after the execution subject obtains the second training sample set, a second initial model including a Transformer encoder and an attention mechanism can be constructed.
[0082] Step 730, using a machine learning method, taking the sample atomic sequence as the input of the Transformer encoder, and the sample chemical bonds corresponding to the sample atomic sequence as the expected output of the attention mechanism, the second initial model is trained to obtain a chemical bond prediction sub-model.
[0083] In this step, after the above-mentioned execution entity obtains the second training sample set and constructs the second initial model, it can use a machine learning method to train the second initial model based on the second training sample set using a unified pre-trained language model (unilm, Unified Language Model Pre-training for Natural Language Understanding and Generation) training method to obtain a chemical bond prediction sub-model.
[0084] Specifically, the above-mentioned execution entity can input the sample atomic sequence into the second initial model, and use the sample atomic sequence as the input of the Transformer encoder. After processing by the second initial model, the predicted chemical bonds corresponding to the sample atomic sequence can be obtained. The network structure of the above-mentioned second initial model can be a network framework including a Transformer encoder and an attention mechanism in the relevant technology, and the processing flow of parameters in other network layers can also refer to the processing flow of the unilm model in the relevant technology.
[0085] During the training process, the above-mentioned execution subject can use the sample chemical bonds corresponding to the sample atomic sequence as the expected output of the attention mechanism, and then compare the output predicted chemical bonds with the expected output to determine whether the predicted chemical bonds meet the constraints. If the predicted chemical bonds do not meet the constraints, the network parameters of the second initial model are adjusted, and the sample atomic sequence is input again to continue training. If the predicted chemical bonds meet the constraints, the model training is completed and a chemical bond prediction sub-model is obtained. Among them, the constraint condition can be that the difference between the predicted chemical bond and the sample chemical bond in the second training sample set meets a preset threshold. The preset threshold can be pre-set based on experience, and the present disclosure does not make specific limitations on this.
[0086] In this implementation, the second initial model is trained by acquiring sample atomic sequences and sample chemical bonds to obtain a chemical bond prediction sub-model, which can improve the efficiency and accuracy of chemical bond prediction, as well as the accuracy and efficiency of generating molecular graphs.
[0087] Further references Figure 8 As an implementation of the methods shown in the above figures, the present disclosure provides an embodiment of a molecular graph generating device, and the device embodiment is similar to Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0088] like Figure 8 As shown, the molecular graph generating device 800 of this embodiment includes: an acquisition module 810 , an atom prediction module 820 and a chemical bond prediction module 830 .
[0089] Wherein, the acquisition module 810 is configured to acquire a molecular graph generation model, wherein the molecular graph generation model includes an atom prediction sub-model and a chemical bond prediction sub-model;
[0090] The atom prediction module 820 is configured to input the start symbol into the atom prediction sub-model to perform atom prediction and determine a candidate atom sequence;
[0091] The chemical bond prediction module 830 is configured to input the candidate atomic sequence into the chemical bond prediction sub-model to perform chemical bond prediction and generate a molecular graph corresponding to the candidate atomic sequence.
[0092] In some optional aspects of this embodiment, the atom prediction module 820 is further configured to: input the start symbol into the atom prediction sub-model for atom prediction to obtain a predicted atom sequence; and in response to predicting the end symbol, determine the predicted atom sequence as a candidate atom sequence.
[0093] In some optional embodiments of the present embodiment, the chemical bond prediction sub-model includes an encoding layer and an attention mechanism; and the chemical bond prediction module 830 includes: an encoding unit, configured to input the candidate atomic sequence into the encoding layer for encoding processing, and obtain an encoding vector corresponding to the candidate atomic sequence; an attention unit, configured to input the encoding vector into the attention mechanism for attention processing, and predict the chemical bonds of the candidate atomic sequence; and a generation unit, configured to generate a molecular graph corresponding to the candidate atomic sequence based on the chemical bonds of the candidate atomic sequence.
[0094] In some optional embodiments of this embodiment, the attention mechanism processing includes a first attention processing for focusing on the correlation between the current candidate atom and other candidate atoms and a second attention processing for focusing on the correlation between the current candidate atom and other atomic relationships in the current subgraph that have been predicted; and the attention unit is further configured to: perform a first attention processing on the encoding vector through the attention mechanism to obtain a first processing result corresponding to the encoding vector; perform a second attention processing on the first processing result through the attention mechanism to predict the chemical bonds of the candidate atomic sequence.
[0095] In some optional modes of this embodiment, the acquisition module 810 is further configured to acquire the molecular graph to be optimized; the atom prediction module 820 is further configured to input the molecular graph to be optimized into the atom prediction sub-model for atom prediction, and determine the optimized atom sequence corresponding to the molecular graph to be optimized; the chemical bond prediction module 830 is further configured to input the optimized atom sequence into the chemical bond prediction sub-model for chemical bond prediction, and generate an optimized molecular graph corresponding to the molecular graph to be optimized.
[0096] In some optional methods of this embodiment, the atom prediction sub-model is obtained based on the following steps: obtaining a first training sample set, wherein the first training sample set includes a sample molecular graph marked with a start symbol and an end symbol and a sample atomic sequence corresponding to the sample molecular graph; constructing a first initial model including an input layer and a Transformer encoder; using a machine learning method, taking the sample molecular graph as the input of the input layer, and the sample atomic sequence corresponding to the sample molecular graph as the expected output of the Transformer encoder, training the first initial model, and obtaining the atom prediction sub-model.
[0097] In some optional methods of this embodiment, the chemical bond prediction sub-model is obtained based on the following steps: obtaining a second training sample set, wherein the second training sample set includes sample atomic sequences and sample chemical bonds corresponding to the sample atomic sequences; constructing a second initial model including a Transformer encoder and an attention mechanism; using a machine learning method, taking the sample atomic sequence as the input of the Transformer encoder and the sample chemical bonds corresponding to the sample atomic sequence as the expected output of the attention mechanism, training the second initial model, and obtaining a chemical bond prediction sub-model.
[0098] The molecular graph generation device provided by the embodiment of the present disclosure obtains a molecular graph generation model, which includes an atom prediction submodel and a chemical bond prediction submodel, and then inputs a start symbol into the atom prediction submodel for atom prediction to determine a candidate atom sequence, and finally inputs the candidate atom sequence into the chemical bond prediction submodel for chemical bond prediction to generate a molecular graph corresponding to the candidate atom sequence. The device can predict the required candidate atom sequence according to the start symbol, and does not need to generate an atom feature matrix by sampling from the latent space of the molecular graph, thereby improving the search efficiency of the candidate atom sequence. The device can also predict the corresponding chemical bonds based on the candidate atom sequence and the chemical bond prediction submodel, and does not need to collect an adjacency matrix with chemical bond features from the latent space of the molecular graph, thereby improving the efficiency of chemical bond generation. The device completes the generation of the molecular graph by using the two steps of candidate atom sequence generation and chemical bond generation between candidate atoms, thereby effectively improving the effect of molecular graph generation, reducing the difficulty of molecular graph generation, and improving operating efficiency.
[0099] Those skilled in the art will appreciate that the above device also includes some other well-known structures, such as a processor, a memory, etc. In order to unnecessarily obscure the embodiments of the present disclosure, these well-known structures are described in detail. Figure 8 Not shown in FIG.
[0100] In the technical solution of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0101] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0102] Fig. 9 A schematic block diagram of an example electronic device 900 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0103] like Fig. 9 As shown, the electronic device 900 includes a computing unit 901, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 902 or a computer program loaded from a storage unit 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the device 900 can also be stored. The computing unit 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.
[0104] Multiple components in the electronic device 900 are connected to the I / O interface 905, including: an input unit 906, such as a keyboard, a mouse, etc.; an output unit 907, such as various types of displays, speakers, etc.; a storage unit 908, such as a disk, an optical disk, etc.; and a communication unit 909, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 909 allows the device 900 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0105] The computing unit 901 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 901 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 901 performs the various methods and processes described above, such as the molecular graph generation method. For example, in some embodiments, the molecular graph generation method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 908. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 900 via the ROM 902 and / or the communication unit 909. When the computer program is loaded into the RAM 903 and executed by the computing unit 901, one or more steps of the molecular graph generation method described above may be performed. Alternatively, in other embodiments, the computing unit 901 may be configured to perform the molecular graph generation method in any other appropriate manner (e.g., by means of firmware).
[0106] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0107] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0108] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0109] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0110] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0111] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0112] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0113] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.< / sp> < / cls> < / sp> < / cls> < / sp> < / cls> < / sp> < / cls> < / sp> < / cls> < / sp> < / cls> < / cls> < / cls>
Claims
1. A method for generating a molecular graph, comprising: Acquire a molecular graph generation model, wherein the molecular graph generation model includes an atom prediction sub-model and a chemical bond prediction sub-model, the chemical bond prediction sub-model includes an encoding layer and an attention mechanism, and the attention mechanism processing includes a first attention processing for focusing on the correlation between the current candidate atom and other candidate atoms and a second attention processing for focusing on the correlation between the current candidate atom and other atomic relationships in the current sub-graph that have been predicted; Inputting the start symbol into the atom prediction sub-model to perform atom prediction and determine a candidate atom sequence; The candidate atomic sequence is input into the encoding layer for encoding processing to obtain an encoding vector corresponding to the candidate atomic sequence; a first attention processing is performed on the encoding vector through the attention mechanism to obtain a first processing result corresponding to the encoding vector; a second attention processing is performed on the first processing result through the attention mechanism to predict the chemical bonds of the candidate atomic sequence; based on the chemical bonds of the candidate atomic sequence, a molecular graph corresponding to the candidate atomic sequence is generated.
2. The method according to claim 1, wherein: The step of inputting the start symbol into the atom prediction sub-model to perform atom prediction and determine a candidate atom sequence includes: Inputting the start symbol into the atom prediction sub-model to perform atom prediction and obtain a predicted atom sequence; In response to predicting the end symbol, the predicted atomic sequence is determined as the candidate atomic sequence.
3. The method according to claim 1 or 2, further comprising: Obtain the molecular graph to be optimized; Inputting the molecular graph to be optimized into the atom prediction submodel to perform atom prediction, and determining an optimized atom sequence corresponding to the molecular graph to be optimized; The optimized atomic sequence is input into the chemical bond prediction sub-model to perform chemical bond prediction, and an optimized molecular graph corresponding to the molecular graph to be optimized is generated.
4. The method according to claim 1 or 2, wherein: The atomic prediction submodel is obtained based on the following steps: Acquire a first training sample set, wherein the first training sample set includes a sample molecular graph annotated with a start symbol and an end symbol and a sample atomic sequence corresponding to the sample molecular graph; Construct a first initial model including an input layer and a Transformer encoder; By using a machine learning method, the sample molecular graph is used as the input of the input layer, and the sample atomic sequence corresponding to the sample molecular graph is used as the expected output of the Transformer encoder, and the first initial model is trained to obtain the atomic prediction sub-model.
5. The method according to claim 1 or 2, wherein: The chemical bond prediction submodel is obtained based on the following steps: Acquire a second training sample set, wherein the second training sample set includes sample atomic sequences and sample chemical bonds corresponding to the sample atomic sequences; Build a second initial model including Transformer encoder and attention mechanism; By using a machine learning method, the sample atomic sequence is used as the input of the Transformer encoder, and the sample chemical bonds corresponding to the sample atomic sequence are used as the expected output of the attention mechanism. The second initial model is trained to obtain the chemical bond prediction sub-model.
6. A molecular graph generating device, comprising: An acquisition module is configured to acquire a molecular graph generation model, wherein the molecular graph generation model includes an atom prediction sub-model and a chemical bond prediction sub-model, the chemical bond prediction sub-model includes an encoding layer and an attention mechanism, and the attention mechanism processing includes a first attention processing for focusing on the correlation between the current candidate atom and other candidate atoms and a second attention processing for focusing on the correlation between the current candidate atom and other atomic relationships in the current sub-graph that have been predicted; an atom prediction module, configured to input the start symbol into the atom prediction sub-model to perform atom prediction and determine a candidate atom sequence; The chemical bond prediction module is configured to input the candidate atomic sequence into the encoding layer for encoding processing to obtain the encoding vector corresponding to the candidate atomic sequence; perform a first attention processing on the encoding vector through the attention mechanism to obtain a first processing result corresponding to the encoding vector; perform a second attention processing on the first processing result through the attention mechanism to predict the chemical bonds of the candidate atomic sequence; and generate a molecular graph corresponding to the candidate atomic sequence based on the chemical bonds of the candidate atomic sequence.
7. The device according to claim 6, wherein: The atom prediction module is further configured to: Inputting the start symbol into the atom prediction sub-model to perform atom prediction and obtain a predicted atom sequence; In response to predicting the end symbol, the predicted atomic sequence is determined as the candidate atomic sequence.
8. The device according to claim 6 or 7, wherein: The acquisition module is further configured to acquire a molecular graph to be optimized; The atom prediction module is further configured to input the molecular graph to be optimized into the atom prediction sub-model for atom prediction, and determine an optimized atom sequence corresponding to the molecular graph to be optimized; The chemical bond prediction module is further configured to input the optimized atomic sequence into the chemical bond prediction sub-model to perform chemical bond prediction, and generate an optimized molecular graph corresponding to the molecular graph to be optimized.
9. The device according to claim 6 or 7, wherein: The atomic prediction submodel is obtained based on the following steps: Acquire a first training sample set, wherein the first training sample set includes a sample molecular graph marked with a start symbol and an end symbol and a sample atomic sequence corresponding to the sample molecular graph; Construct a first initial model including an input layer and a Transformer encoder; By using a machine learning method, the sample molecular graph is used as the input of the input layer, and the sample atomic sequence corresponding to the sample molecular graph is used as the expected output of the Transformer encoder, and the first initial model is trained to obtain the atomic prediction sub-model.
10. The device according to claim 6 or 7, wherein: The chemical bond prediction submodel is obtained based on the following steps: Acquire a second training sample set, wherein the second training sample set includes sample atomic sequences and sample chemical bonds corresponding to the sample atomic sequences; Build a second initial model including Transformer encoder and attention mechanism; By using a machine learning method, the sample atomic sequence is used as the input of the Transformer encoder, and the sample chemical bonds corresponding to the sample atomic sequence are used as the expected output of the attention mechanism. The second initial model is trained to obtain the chemical bond prediction sub-model.
11. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.
12. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-5.
13. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 1 are implemented.