A processing method and device of a molecular generation model

By configuring molecular generation instruction templates and post-processing models, and training a large language model using publicly available molecular library data, the problem that general models cannot understand the 3D structural features of molecules in molecular generation tasks is solved, thereby improving the chemical accuracy of generated molecular sequences.

CN122177289APending Publication Date: 2026-06-09BEIJING DP TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING DP TECH CO LTD
Filing Date
2026-04-14
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing general-purpose large language models are unable to deeply understand the 3D structural features and physicochemical properties of molecules in molecular generation tasks, resulting in poor chemical rationality of the generated molecular sequences.

Method used

Configure molecular generation instruction templates and optimize the molecular structure of a general large language model by combining molecular descriptions. Train the generation model through post-processing model and population relative strategy optimization mechanism. Use public molecular libraries for data collection and annotation, build multiple datasets for model training, and finally build a molecular generation model to improve the ability of chemical knowledge reasoning.

Benefits of technology

It improves the chemical accuracy of the generated molecular sequences, enhances the model's chemical reasoning ability, and makes the generated molecular sequences more consistent with chemical laws.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122177289A_ABST
    Figure CN122177289A_ABST
Patent Text Reader

Abstract

This invention relates to a method and apparatus for processing molecular generation models. The method includes: configuring a molecular generation instruction template; selecting a large language model and configuring a corresponding post-processing model for it; constructing first, second, and third datasets; training the post-processing model based on the first dataset; performing inference training on the first large language model based on the molecular generation instruction template and the second dataset; after inference training, further strengthening training on the first large language model based on the molecular generation instruction template and the third dataset using a population relative strategy optimization mechanism; after both models are trained, constructing a molecular generation model with the first large language model and the post-processing model as the core; substituting the molecular description input by the user into the molecular generation instruction template to obtain molecular generation instructions; inputting the molecular generation instructions into the molecular generation model for processing to obtain the corresponding molecular sequence and feeding it back to the current user. This invention can improve the chemical accuracy of generated molecules.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a method and apparatus for processing molecular generation models. Background Technology

[0002] Text-based molecular generation is the process of generating SELFIES-formatted molecular sequences from natural language descriptions. This technology has significant application value in fields such as drug design and materials design. Currently, general-purpose large language models (LLMs), such as Qwen, GPT, and DeepSeek, have made significant progress in a series of general natural language processing (NLP) tasks (such as text generation, translation, question answering, and thought chain derivation). However, some problems still exist in handling molecular generation tasks in specialized chemical fields: the inability to deeply understand the 3D structural features and physicochemical properties of molecules, and the lack of specialized chemical reasoning ability, resulting in poor chemical rationality of the generated molecular sequences. Summary of the Invention

[0003] The purpose of this invention is to address the shortcomings of existing technologies by providing a method, apparatus, electronic device, and computer-readable storage medium for processing molecular generation models. This invention first selects a general-purpose large language model as the first large language model and configures a post-processing model for optimizing the molecular structure of the generated molecular sequences from the first large language model by combining molecular descriptions, along with a corresponding molecular generation instruction template. Then, large-scale data collection of molecular sequences from publicly available molecular libraries is performed. Molecular descriptions for each collected sequence are obtained by querying the molecular library, and the molecular sequences and inference chain tags of each collected sequence are labeled. Based on preset structural tampering rules, each sequence tag is tampered with to obtain the corresponding sequence to be optimized. A first dataset is constructed based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags; a second dataset is constructed based on all molecular descriptions and their corresponding inference chain tags; and a third dataset is constructed based on all molecular descriptions and their corresponding sequence tags. Then, the post-processing model is trained based on the first dataset. When training the first large language model, it is first trained for inference based on the molecular generation instruction template and the second dataset, and then reinforced based on the Group Relative Policy Optimization (GRPO) mechanism using the molecular generation instruction template and the third dataset. After training the two types of models, a molecular generation model is constructed using the primary language model and the post-processing model as its core. This molecular generation model is then used to process the user's molecular generation tasks. The model processes the molecular generation instructions X input to the model and outputs the corresponding molecular sequences S. * When processing user tasks, the molecular description input by the user is substituted into the molecular generation instruction template for setting. The resulting molecular generation instruction X is then input into the molecular generation model for processing to obtain the molecular sequence S. * Provide feedback to the current user. This invention can improve the model's chemical knowledge reasoning ability and increase the chemical accuracy of the generated molecular sequences.

[0004] To achieve the above objectives, a first aspect of the present invention provides a method for processing molecular generation models, the method comprising: Configure the molecule generation instruction template; Select a general-purpose language model that has completed pre-training for both a large language model and a general NLP task as the corresponding first large language model; and configure a post-processing model to optimize the molecular structure of the molecular sequences generated by the first large language model in conjunction with molecular descriptions; the first large language model includes at least the Qwen series models, GPT series models, and DeepSeek series models; the general-purpose NLP task includes at least text generation, translation, question answering, and thought chain derivation tasks; the post-processing model is used to optimize the molecular structure based on the molecular description D and molecular sequence S input to the model and output the optimized molecular sequence S. * ; We collect molecular sequences from publicly available molecular libraries, obtain molecular descriptions for each collected sequence by querying the library, and label the molecular sequence and inference chain tags for each collected sequence. Based on preset structural tampering rules, we tamper with each sequence tag to obtain the corresponding sequence to be optimized. We construct a first dataset based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, a second dataset based on all molecular descriptions and their corresponding inference chain tags, and a third dataset based on all molecular descriptions and their corresponding sequence tags. The post-processing model is trained based on the first dataset; The first large language model is trained for inference based on the molecular generation instruction template and the second dataset; after the inference training is completed, the first large language model is further trained for reinforcement based on the group relative strategy optimization mechanism according to the molecular generation instruction template and the third dataset. After both types of models have been trained, a corresponding molecular generation model is constructed using the first large language model and the post-processing model as the core. The molecular generation model is used to process molecular generation tasks according to the molecular generation instructions X input to the model and output the corresponding molecular sequence S. * The molecule generation instruction X is an instruction text generated based on the molecule generation instruction template, and its text structure is consistent with the molecule generation instruction template. The molecular description input by the user is substituted into the molecular generation instruction template to set the molecular description text of the template's molecular description segment, thereby obtaining the corresponding molecular generation instruction X. The molecular generation instruction X is then input into the molecular generation model for processing to obtain the corresponding molecular sequence S. * Provide feedback to the current user.

[0005] Preferably, the molecule generation instruction template consists of an instruction requirement section, a molecule description section, a reasoning step description section, and a formatting requirement section; The instruction requires the text to be a fixed natural language text, which prompts the model to perform step-by-step analysis and reasoning based on the molecular description information given in the molecular description text, the step sequence given in the reasoning step description text, and to generate a SELFIES molecular sequence that conforms to chemical laws based on the reasoning context. The molecular description segment consists of a fixed description segment title and configurable molecular description text; the description segment title defaults to the string "Molecular description:"; the molecular description text is initialized to empty; The inference step description is a fixed natural language text consisting of N inference step texts, where N is the preset total number of inference steps. Each inference step text is a step description text for one step of inference, used to prompt the model to analyze and reason according to the requirements of this step based on the current inference context, and to use the result of this step as the corresponding single-step inference text C. i And output, 1≤index i≤N; the current inference context includes the molecular description information given by the molecular description text, the inference results of all historical steps before the current inference step; the single-step inference text C corresponding to the Nth step. i=N The corresponding SELFIES molecular sequences; The formatting requirement text is a fixed natural language text used to prompt the model to encapsulate and output the generated SELFIES molecular sequences according to a preset molecular sequence output format; the molecular sequence output format is formed by connecting the preset start marker text, the model-generated SELFIES molecular sequences, and the preset end marker text in sequence by default. The publicly available molecular libraries include at least the PubChem database and the PDB database; The structural modification rules include at least atomic substitution rules, chemical bond substitution rules, and functional group substitution rules; The atom substitution rule is used to configure one or more classes of specified types of atoms and to configure a corresponding substitution atom type for each class of specified types of atoms; and it stipulates that when tampering with the molecular conformation, one or more atoms are randomly selected from the current conformation as substitution objects based on some or all of the specified types of atoms, and the current object is replaced based on the substitution atom type corresponding to each substitution object; The chemical bond substitution rules are used to configure one or more specified types of chemical bonds and to configure corresponding substitution bond types for each specified type of chemical bond; and stipulate that when tampering with the molecular conformation, one or more chemical bonds are randomly selected from the current conformation as substitution objects based on some or all of the specified types of chemical bonds, and the current object is replaced based on the substitution bond type corresponding to each substitution object; The functional group replacement rule is used to configure one or more specified types of functional groups and to configure a corresponding replacement functional group type for each specified type of functional group; and stipulates that when tampering with the molecular conformation, one or more functional groups are randomly selected from the current conformation as replacement objects based on some or all of the specified type of functional groups, and the current object is replaced based on the replacement functional group type corresponding to each replacement object; The first dataset includes multiple first data records; each first data record includes a first sequence to be optimized, a first molecular description, and a first label sequence; the first sequence to be optimized and the first label sequence are each a SELFIES molecular sequence, and the first training sequence is obtained by modifying the sequence information of the corresponding first label sequence based on the structure modification rule; The second dataset includes multiple second data records; each second data record includes a second molecule description and a first label inference chain; the first label inference chain includes N single-step inference labels. ; The third dataset includes multiple third data records; each third data record includes a third molecular description and a second tag sequence; the second tag sequence is a SELFIES molecular sequence.

[0006] Preferably, the first model input terminal of the post-processing model is used to receive the molecular description D, the second model input terminal is used to receive the molecular sequence S, and the model output terminal is used to output the molecular sequence S. * ; The post-processing model includes a text encoder, a molecular conformation conversion module, a Uni-Mol model, a global feature fusion module, an atom pair feature gating module, an atom type feature gating module, a chemical bond prediction module, an atom coordinate prediction module, an atom type prediction module, and a molecular sequence conversion module. The input end of the text encoder is connected to the input end of the first model, and the output end is connected to the first input end of the global feature fusion module; the input end of the molecular conformation conversion module is connected to the input end of the second model, the first output end is connected to the first input end of the chemical bond prediction module, and the second output end is connected to the input end of the Uni-Mol model; the first output end of the Uni-Mol model is connected to the second input end of the global feature fusion module, the second output end is connected to the second input end of the atom pair feature gating module, and the third output end is connected to the second input end of the atom type feature gating module; the output end of the global feature fusion module is connected to the second input end of the chemical bond prediction module, the second output end of the molecular conformation conversion module, and the third output end of the molecular conformation conversion module. The first input terminal of the atom pair feature gating module and the first input terminal of the atom type feature gating module are connected; the output terminal of the atom pair feature gating module is connected to the third input terminal of the chemical bond prediction module and the first input terminal of the atom coordinate prediction module, respectively; the output terminal of the atom type feature gating module is connected to the fourth input terminal of the chemical bond prediction module, the second input terminal of the atom coordinate prediction module, and the input terminal of the atom type prediction module, respectively; the output terminals of the chemical bond prediction module, the atom coordinate prediction module, and the atom type prediction module are connected to the first, second, and third input terminals of the molecular sequence conversion module, respectively; the output terminal of the molecular sequence conversion module is connected to the model output terminal. The text encoder is implemented based on the Transformer architecture; the text encoder is used to encode the molecular description D to obtain the corresponding text feature vector H. D Sending to the global feature fusion module specifically involves: segmenting the molecular description D according to a preset professional chemical vocabulary to obtain the corresponding current segmentation sequence; embedding the current segmentation sequence into an embedded vector; performing feature encoding on the text embedding vector to obtain the corresponding feature encoding vector; and performing max pooling on each feature channel of the feature encoding vector to obtain the corresponding text feature vector H. D Send to the global feature fusion module; The terminology set of the specialized chemical vocabulary includes symbols, numbers, characters, and words from the natural language domain, as well as symbols, numbers, characters, and words from the specialized chemical knowledge domain and the molecular sequence characterization domain; the feature encoding vector has a shape of L×d. D L represents the total number of word segments corresponding to the molecular description D, and d D The preset text feature dimensions; the feature vector H D The shape is 1×d D ; The molecular conformation conversion module is used to identify the atom type, atomic coordinates, and chemical bonds of the molecular sequence S to obtain the corresponding atom type set A, atom coordinate set P, and chemical bond set E, and then send them to the corresponding chemical bond prediction module and the Uni-Mol model. Specifically, it uses a preset cheminformatics tool to perform molecular conformation conversion on the molecular sequence S to obtain the corresponding current conformation; it uses the cheminformatics tool to identify the atom type and atomic coordinates of each atom in the current conformation atom set and to identify the chemical bonds between the atoms in the current conformation to obtain the corresponding atom type set A, atom coordinate set P, and chemical bond set E; and it sends the chemical bond set E to the chemical bond prediction module and sends the atom type set A and the atom coordinate set P to the Uni-Mol model. The cheminformatics tools include at least the RDKit tool; the total number of atoms in the current conformation is denoted as N. A The atom type set A includes N A Atom type a j 1 ≤ atomic index j ≤ N A The atomic coordinate set P includes N A Atom coordinates p j The atomic coordinates p j The coordinates are three-dimensional; the chemical bond set E includes multiple chemical bonds e, each chemical bond e including a corresponding atom pair index group and a chemical bond type; the atom pair index group consists of the atom indices j and k of the two atoms corresponding to the current chemical bond, where 1 ≤ atom index k ≤ N. A k≠j; The Uni-Mol model has completed large-scale pre-training. The pre-training tasks of the Uni-Mol model include at least masked atom prediction and atom coordinate prediction tasks. The Uni-Mol model is used to perform atomic-level feature encoding and global molecular feature recognition on the current molecule based on the atom type set A and the atom coordinate set P to obtain the corresponding molecular feature vector H. cls Atom pair characteristic matrix H P Atomic eigenvectors H A and the molecular feature vector H cls Send the atom pair feature matrix H to the global feature fusion module. P and the atomic eigenvector H A Send the atomic feature vector H to the atom pair feature gating module. A Sending to the atom type feature gating module specifically involves: generating a corresponding atom sequence based on the atom type set A, and performing embedding encoding on the atom sequence to obtain the corresponding atom embedding vector; and setting the initialized atom pair feature matrix H based on the atom coordinate set P. P; and combined with the atomic pair feature matrix H P The atomic embedding vector is feature encoded to obtain the corresponding atomic feature vector H. A And during the encoding process, the feature matrix H of the atom pairs is... P Perform iterative updates; and update the final atomic feature vector H. A The molecular feature vector H is obtained by performing average pooling on each feature channel. cls ; and the molecular feature vector H cls Send the atom pair feature matrix H to the global feature fusion module. P and the atomic eigenvector H A Send the atomic feature vector H to the atomic pair feature gating module. A Send to the atom type feature gating module; Wherein, the atomic feature vector H A The shape is N A ×d A d A The atomic feature vector H is defined by a preset atomic type feature dimension. A By N A The vectors have a length of d. A For feature vectors Composition; the atom pair feature matrix H P The shape is N A ×N A ×3; the molecular feature vector H cls The shape is 1×d A The atom pair feature matrix H P By N A ×N A Each feature vector has a length of 3. Composition, 1 ≤ atomic index k ’ ≤N A Each of the feature vectors Used for their corresponding atom pairs (j,k) ’ The three-dimensional coordinate spacing is used for feature characterization; The global feature fusion module is used to perform attention-weighted fusion based on the text feature vector H. D and the molecular feature vector H cls Generate the corresponding global feature vector H G Sending the text feature vector H to the chemical bond prediction module, the atom pair feature gating module, and the atom type feature gating module specifically involves: sending the text feature vector H... D and the molecular feature vector H cls The two projection vectors H are obtained by projecting them onto a predefined global feature space.D-p H cls-p ; and for the two projection vectors H D-p H cls-p The corresponding two attention weights at D-p ,at cls-p Perform calculations; and based on the two attention weights at D-p ,at cls-p For the two projection vectors H D-p H cls-p The corresponding global feature vector H is obtained by performing feature weighting. G Send to the chemical bond prediction module, the atom pair feature gating module, and the atom type feature gating module; Among them, the two projection vectors H D-p H cls-p The calculation method is as follows: , ; W D-p b D-p W represents the text feature projection transformation matrix and bias vector of the model. cls-p b cls-p W represents the molecular feature projection transformation matrix and bias vector of the model; D-p The shape is d G ×d D W cls-p The shape is d G ×d A b D-p b cls-p The shape is 1×d G d G The feature dimension of the global feature space; the projection vector H D-p H cls-p The shape is 1×d G ; The two attention weights at D-p ,at cls-p The calculation method is as follows: ; W at1 W at2 Let b be the first and second attention transformation matrices of the model. at1 b at2 W represents the first and second attention bias vectors of the model. at1 The shape is d at ×2d G b at1 The shape is 1×d at W at2The shape is 2×d at b at2 The shape is 1×2, d at AT represents the preset attention feature dimensions; concate() is the vector concatenation function, tanh() is the Tanh activation function, and softmax() is the Softmax function; AT represents the attention vector. vector The shape is 1×2d G ; vector The shape is 1×d at ; vector The shape is 1×2; The attention vector AT has a 1×2 shape and is composed of the corresponding attention weights at. D-p ,at cls-p Composition, at D-p +at cls-p =1; The global feature vector H G The calculation method is as follows: ; The global feature vector H G The shape is 1×d G ; The atom pair feature gating module is used to determine the global feature vector H. G The atom pair feature matrix H P and the atomic eigenvector H A Adding a global feature-gated component to each atom pair feature yields a new atom pair feature matrix. Sending to the chemical bond prediction module and the atom coordinate prediction module, specifically: based on the global feature vector H G The atom pair feature matrix H P and the atomic eigenvector H A For each atom pair (j,k) ’ Generate the corresponding gated scalar and candidate feature vectors ; and based on each atom pair (j,k) ’ The corresponding gated scalar The candidate feature vector and the feature vector Calculate the corresponding gated feature vector ; and from the obtained N A ×N A The gated feature vectors The corresponding atom pair feature matrix is ​​formed. Send to the chemical bond prediction module and the atomic coordinate prediction module; Among them, the gated scalar The calculation method is as follows: ; W g1 b g1 Let the first gating transformation matrix and bias vector of the model be denoted as . The atomic feature vector H A The eigenvector of the k-th atom W g1 The shape is 1×(3+2d) A +d G ), b g1 The shape is 1×1; sigmoid() is the sigmoid activation function; vector The shape is 1×(3+2d) A +d G ); The candidate feature vector The calculation method is as follows: ; W g2 b g2 W represents the second gating transformation matrix and bias vector of the model. g2 The shape is 3×(3+2d) A +d G ), b g2 The shape is 1×3; the candidate feature vector The shape and the feature vector Maintain consistency; The gated feature vector The calculation method is as follows: ; The atom pair feature matrix The shape is N A ×N A ×3; The atom type feature gating module is used to determine the global feature vector H. G and the atomic eigenvector H A Adding a global feature-gated component to each atomic feature yields a new atomic feature vector. Sending to the chemical bond prediction module, the atom coordinate prediction module, and the atom type prediction module, specifically: based on the global feature vector H G and the atomic eigenvector H A Generate a corresponding gated scalar g for each atom j and candidate feature vectors ; and based on the gate scalar g corresponding to each atom j The candidate feature vector and the feature vector Calculate the corresponding gated feature vector ; and from the obtained N A The gated feature vectors The corresponding atomic feature vectors are formed Send to the chemical bond prediction module, the atomic coordinate prediction module, and the atom type prediction module; Wherein, the gated scalar g j The calculation method is as follows: ; W g3 b g3 W represents the third gating transformation matrix and bias vector of the model. g3 The shape is 1×d A b g1 The shape is 1×1; The candidate feature vector The calculation method is as follows: ; W g4 b g4 W represents the fourth gating transformation matrix and bias vector of the model. g4 The shape is d A ×(d A +d G ), b g2 The shape is 1×d A ;vector The shape is 1×(d A +d G The candidate feature vector The shape and the feature vector Maintain consistency; The gated feature vector The calculation method is as follows: ; The atomic feature vector The shape is N A ×d A ; The chemical bond prediction module is used to predict chemical bonds based on the chemical bond set E and the global feature vector H. G The atom pair feature matrix and the atomic feature vector Chemical bond prediction yields the corresponding chemical bond set E. *Sending to the molecular sequence conversion module specifically involves: first setting a shape of N A ×N A ×N C The all-zero matrix is ​​used as the initial chemical bond characteristic matrix H. E N C The chemical bond feature matrix H represents the preset total number of chemical bond types. E By N A ×N A The length of each vector is N C eigenvectors Composition; then, based on each chemical bond e in the chemical bond set E and its corresponding feature vector Perform one-hot encoding; then index the two symmetric atom pairs (j,k) by row / column index of each matrix. ’ ), (k ’ (j) form a corresponding symmetric group, and the index k in each symmetric group ’ ≠j; then based on the atomic feature vector The atom pair feature matrix The chemical bond feature matrix H E The two gated feature vectors corresponding to each of the symmetric groups Two gated feature vectors Two eigenvectors and the global feature vector H G Predict the corresponding chemical bond prediction vector c; then set the corresponding chemical bond e based on the chemical bond prediction vector c of each symmetry group. * Then, the chemical bonds of the invalid chemical bond type e are... * Clear, by all remaining said chemical bonds e * The corresponding chemical bond set E * Send to the molecular sequence conversion module; The chemical bond prediction vector c corresponding to the symmetry group is calculated as follows: , , , , ; W c b c W represents the chemical bond transformation matrix and bias vector of the model. c The shape is N C ×(2d A +3+d G +N C ), bc The shape is 1×N C ;vector , The shape is 1×(2d) A +3+d G +N C ); , For the two atomic pairs (j,k) in the symmetry group ’ ), (k ’ The eigenvectors corresponding to each of the following are all of shape 1×N. C ; , For the two atomic pairs (j,k) in the symmetry group ’ ), (k ’ The prediction vectors corresponding to each of the following are all of shape 1×N. C All are composed of N C Each prediction probability consists of a set of prediction probabilities, and each prediction probability corresponds to a type of chemical bond; the prediction vector c is composed of two corresponding prediction vectors. , The mean vector is also determined by N. C Each predicted probability consists of; The chemical bond e corresponding to the symmetry group * The setting method is as follows: the maximum predicted probability in the prediction vector c corresponding to the current symmetry group is taken as the candidate probability; and it is identified whether the candidate probability is less than a preset effective probability threshold; if so, the chemical bond type corresponding to the current symmetry group is set as an invalid chemical bond type; if not, the chemical bond type corresponding to the candidate probability is taken as the chemical bond type corresponding to the current symmetry group; and the atomic indices j and k corresponding to the current symmetry group are used as the chemical bond type. ’ A corresponding atom pair index group is formed; and the corresponding chemical bond e is formed by the chemical bond type corresponding to the current symmetry group and the atom pair index group. * ; The atomic coordinate prediction module is implemented based on the task model of the atomic coordinate prediction task of the Uni-Mol model, specifically an SE(3) equivariant graph neural network model; the atomic coordinate prediction module is used to predict the atomic feature vectors. and the atom pair feature matrix The 3D changes of all atomic coordinates are predicted to obtain the corresponding coordinate change set ΔP; and the atomic coordinate set P is corrected based on the coordinate change set ΔP to obtain a new atomic coordinate set P. * Send to the molecular sequence conversion module; Wherein, the atomic coordinate set P includes N A The atomic coordinates p jThe coordinate transformation set △P includes N A The coordinate change Δp j The atomic coordinate set P * Including N A atomic coordinates , ; The atom type prediction module is used to predict the atom type based on the atom feature vector. A new set of atom types, A, is obtained by performing atom type prediction. * Sending to the molecular sequence conversion module specifically involves: processing the atomic feature vectors. Each of the gated feature vectors A linear transformation yields a shape of 1×d AC eigenvectors d AC The total number of preset atom types; and based on the Softmax function according to each of the aforementioned feature vectors. Calculate the corresponding probability vector ; and each of the probability vectors The atom type corresponding to the highest probability in the atom is used as the corresponding atom type. ; The obtained N A The atom types The corresponding atom type set A is formed. * Send to the molecular sequence conversion module; Wherein, the feature vector The probability vector The calculation method is as follows: , ; W ac b ac To predict the transformation matrix and bias vector for the model type, W ac The shape is d AC ×d A b ac The shape is 1×d AC The probability vector The shape is 1×d AC , by d AC Each prediction probability consists of a class of atomic types; The molecular sequence conversion module is used to convert the chemical bond set E according to... * The atomic coordinate set P * and the set of atomic types A *Set the corresponding optimized molecular conformation; and use the cheminformatics tool to perform SELFIES molecular sequence conversion on the optimized molecular conformation to obtain the corresponding optimized molecular sequence; and use the optimized molecular sequence as the corresponding molecular sequence S. * Output.

[0007] Preferably, the model input terminal of the molecular generation model is used to receive the molecular generation instruction X, and the model output terminal is used to output the molecular sequence S. * The molecular generation model includes a task scheduling module, a first large language model, and the post-processing model; the input end of the task scheduling module is connected to the input end of the model, and the output end is connected to the output end of the model; the task scheduling module is also connected to the first large language model and the post-processing model respectively. The task scheduling module is used to send the received molecular generation instruction X to the first large language model; receive the formatted molecular sequence text returned by the first large language model; extract the molecular description segment from the molecular generation instruction X as the corresponding molecular description D; extract the model-generated SELFIES molecular sequence from the formatted molecular sequence text according to the molecular sequence output format of the formatting requirement segment of the molecular generation instruction template as the corresponding molecular sequence S; send the molecular description D and the molecular sequence S to the post-processing model; and receive the molecular sequence S returned by the post-processing model. * Output.

[0008] Preferably, the process involves large-scale data collection of molecular sequences from publicly available molecular libraries, obtaining molecular descriptions for each collected sequence by querying the molecular library, labeling the molecular sequence and inference chain tags for each collected sequence, modifying each sequence tag according to preset structural tampering rules to obtain the corresponding sequence to be optimized, constructing a first dataset based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, constructing a second dataset based on all molecular descriptions and their corresponding inference chain tags, and constructing a third dataset based on all molecular descriptions and their corresponding sequence tags. Specifically, this includes: A first sequence set is formed by collecting multiple sequences from the SMILES and SELFIES molecular sequences in the publicly available molecular library; the first sequence set includes multiple first sequences; each first sequence is a SMILES molecular sequence or a SELFIES molecular sequence. Each of the first sequences is taken as the current sequence; a molecular summary or comprehensive description corresponding to the current sequence is obtained by querying the molecular library and used as a set of corresponding first molecular description, second molecular description and third molecular description; the sequence format of the current sequence is identified as SELFIES sequence format. If it is, the current sequence is used as a set of corresponding first tag sequence and second tag sequence. Otherwise, a preset cheminformatics tool is used to convert the current sequence into a SELFIES molecular sequence and the conversion result is used as a set of corresponding first tag sequence and second tag sequence; all the step description texts of the reasoning step description section of the molecular generation instruction template are sequentially traversed once; at the beginning of this round of traversal, the corresponding reasoning context is initialized to empty; during this round of traversal, the step description text of the current traversal is used as the current step description, and a corresponding current question is formed by the current sequence, the current step description and the reasoning context according to the preset question construction rules. The current question is processed through a preset professional chemical question and answer interface, and the answer text obtained in this processing is used as a corresponding single-step reasoning tag. The current question and answer are combined to form a corresponding question-and-answer text pair, which is then added to the reasoning context. At the end of this round of traversal, the N single-step reasoning tags obtained from this round of traversal are... A corresponding first tag inference chain is formed; the current sequence is transformed into a molecular conformation using the cheminformatics tool to obtain the corresponding current conformation, and the current conformation is randomly modified based on the structure tampering rule to obtain the corresponding current tampered conformation. The current tampered conformation is then transformed into a SELFIES molecular sequence using the cheminformatics tool, and the transformation result is used as the corresponding first sequence to be optimized; wherein, the cheminformatics tool includes at least the RDKit tool; the question construction rule is used to set the analysis question with the current sequence and the inference context as the reference context and the current step description as the current analysis target; the professional chemistry question-answering interface is a type of manual question-answering task processing interface for professional chemistry experts, a type of system question-answering task processing interface for professional chemistry question-answering systems, or a type of model question-answering task processing interface for professional chemistry large models; Each of the first sequences to be optimized and its corresponding first molecular description and first tag sequence constitutes a corresponding first data record; and all the obtained first data records constitute the corresponding first dataset; Each second molecule description and its corresponding first label inference chain constitute a corresponding second data record; and all the obtained second data records constitute the corresponding second dataset; Each of the third molecule descriptions and its corresponding second tag sequence constitutes a corresponding third data record; and all the obtained third data records constitute the corresponding third dataset.

[0009] Preferably, training the post-processing model based on the first dataset specifically includes: Step 61: The model parameter set of the text encoder, global feature fusion module, atom pair feature gating module, atom type feature gating module, chemical bond prediction module, atom coordinate prediction module, and atom type prediction module of the post-processing model is taken as the current model parameter set; and the first dataset is divided into multiple first data batches based on a preset batch size B1; and the first first data batch is taken as the current data batch. Each of the first data batches includes B1 first data records; the first tag sequence of each first data record in each of the first data batches is denoted as the corresponding tag sequence. , 1 ≤ index q ≤ B1; Step 62: Take each of the first data records in the current data batch as the current record; and input the first molecular description and the first sequence to be optimized of the current record as the corresponding molecular description D and molecular sequence S into the post-processing model for processing, and input the chemical bond set E generated by the model during this processing. * Atomic coordinate set P * and atomic type set A * As the corresponding chemical bond set Atomic coordinate set and atomic type set ; and use preset cheminformatics tools to analyze the currently recorded tag sequence. Perform molecular conformational transformation and use the cheminformatics tools to analyze the chemical bond set corresponding to the current conformation. Atomic coordinate set and atomic type set Identification is performed; and the chemical bond set corresponding to the current record is used to... Atomic coordinate sets Atom type set pairs Form a corresponding first prediction-label group; The cheminformatics tools include at least the RDKit tool; Step 63: Substitute the B1 first prediction-label groups of the current data batch into the preset first model loss function L. M1 The corresponding first loss value is obtained through calculation; Wherein, the first model loss function L M1 for: ; Atom type loss function L A Based on the cross-entropy loss function, the atomic coordinate loss function L... P Based on L1 or L2 loss functions, chemical bond loss function L E Implemented based on the cross-entropy loss function; Step 64: Identify whether the first loss value meets the preset first loss value range; if not, then based on the preset first model optimizer, move towards making the first model loss function L... M1 The direction that reaches the minimum value is used to perform a round of parameter modulation on the current model parameter set, and the process returns to step 62 when the parameter adjustment is completed. If the condition is met, it is identified whether the current data batch is the last first data batch. If not, the next first data batch is taken as the new current data batch and the process returns to step 62. If the condition is met, training is stopped and the post-processing model training is confirmed to be completed. The first model optimizer includes the Adam optimizer and the SGD optimizer.

[0010] Preferably, the step of training the first large language model for inference based on the molecular generation instruction template and the second dataset specifically includes: Step 71: Divide the second dataset into multiple second data batches based on the preset batch size B2; and take the first second data batch as the current data batch; Each second data batch includes B2 second data records; the first tag inference chain of each second data record in each second data batch is denoted as the corresponding tag chain. , 1 ≤ index g ≤ B2; each of the stated tag chains Each of the aforementioned single-step reasoning tags Record as the corresponding single-step label Each of the aforementioned single-step labels The total number of word segments is denoted as n. g,i Each of the aforementioned single-step labels Each word segment is recorded as the corresponding 1 ≤ index u ≤ n g,i ; Step 72: Substitute the second molecular description of each second data record in the current data batch into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. g ; and the molecular generation instruction X gThe first large language model is input for processing; the autoregressive text generation process of the first large language model during this processing is recorded; and after completing B2 model processing iterations, the second model loss function L is used as the basis for the processing. M2 Calculate the corresponding second loss value; Wherein, the second model loss function L M2 It is implemented based on the cross-entropy loss function, specifically as follows: ; The reasoning label sequence is formed by concatenating the reasoning labels from the previous i-1 steps. For the single-step label The word segmentation sequence preceding the u-th word; For the model in the autoregressive generation step of the inference text at step i, the corresponding molecular generation instruction X is used. g Inference label sequence and word segmentation sequence The u-th word generated for the context is the corresponding word. The probability of; Step 73: Identify whether the second loss value meets the preset second loss value range; if not, then based on the preset second model optimizer, move towards making the second model loss function L... M2 The model parameters of the first large language model are fine-tuned in the direction of reaching the minimum value, and the process returns to step 72 after the fine-tuning is completed. If the condition is met, it is identified whether the current data batch is the last second data batch. If not, the next second data batch is taken as the new current data batch and the process returns to step 72. If the condition is met, training is stopped and the inference training of the first large language model is confirmed to be completed. The second model optimizer includes the Adam optimizer, the SGD optimizer, and the AdamW optimizer.

[0011] Preferably, the group-based relative strategy optimization mechanism performs reinforcement training on the first large language model based on the molecular generation instruction template and the third dataset, specifically including: Step 8-1: Copy the first large language model to obtain two copied models, and denote the current first large language model as the corresponding new policy model M. new The two replication models are denoted as the corresponding old policy models M. old Reference Model M ref and the reference model M ref The model parameters are solidified; and the new strategy model M is then... newThe old strategy model M old The reference model M ref The model parameters are denoted as the corresponding model parameters θ. new Model parameters θ old Model parameters θ ref The third dataset is divided into multiple third data batches based on a preset batch size B3, and the first third data batch is taken as the current data batch. Each data batch includes B3 third data records; the second tag sequence of each third data record in each data batch is denoted as the corresponding tag sequence. , 1 ≤ index o ≤ B3; Step 8-2: Take each of the third data records in the current data batch as the current record; and substitute the third molecular description of the current record into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. o And continuously send the molecule generation command X M times. o Input the old strategy model M old The process yields M corresponding predicted texts. ; and according to the formatting requirements of the molecular generation instruction template, the molecular sequence output format is obtained from each of the predicted texts. Extract the corresponding SELFIES molecular sequences as the corresponding predicted sequences. ; Wherein, the number of repetitions M is a preset positive integer, 1 ≤ index m ≤ M; each of the predicted texts The total number of word segments is recorded as the corresponding Each of the predicted texts Each word segment is recorded as the corresponding 1≤index t≤ Each segmentation The corresponding predicted probability is denoted as ; Step 8-3, for each of the predicted texts The system identifies whether the text format meets the molecular sequence output format of the molecular generation instruction template; if it does, the corresponding format check result FM is set. o,m Set the value to 1; if not satisfied, set the corresponding format check result FM. o,m =0; Step 8-4: Use preset cheminformatics tools to analyze each of the stated tag sequences. The predicted sequence The corresponding tag fingerprints are obtained by calculating the three types of molecular fingerprints. , , fingerprint prediction , , ; and using the cheminformatics tools to analyze each of the tag sequences. The predicted sequence The molecular side chains and functional groups are identified to obtain the corresponding tag side chain fragment set. , collection of tagged functional groups Predicted sidechain fragment set Predictive functional group set ; The three types of molecular fingerprints include Morgan fingerprints, MACCS fingerprints, and RDKit fingerprints; The cheminformatics tools include at least the RDKit tool; The set of tag sidechain fragments When not empty, it consists of one or more tag sidechain fragments. composition; The set of label functional groups When not empty, it consists of one or more label functional groups. Composition, each of the stated tag functional groups It consists of its corresponding functional group type and functional group fragment; The predicted sidechain fragment set When not empty, it consists of one or more predictive sidechain fragments. composition; The predictive functional group set When not empty, it is determined by one or more predictive functional groups. Composition, each of the predicted functional groups It consists of its corresponding functional group type and functional group fragment; Step 8-5, for each of the predicted sequences The corresponding tag sequence Sequence similarity fingerprint similarity Fragment similarity Functional group similarity The calculation is performed, and the average of the four similarities is used as the corresponding structural reward. ; and check the FM result according to the stated format. o,m and the structural reward Calculate the corresponding generated reward R o,m ; Wherein, the sequence similarity Achieved through the BLEU evaluation algorithm: ; fingerprint similarity This is achieved by averaging the similarity of three types of fingerprints: , f s () represents a preset fingerprint similarity function, f. s Including the Jaccard similarity function and the cosine similarity function; The similarity of the segments The calculation method is as follows: ; For the predicted sidechain fragment set With the set of tag sidechain fragments The total number of overlapping segments; For the predicted sidechain fragment set With the set of tag sidechain fragments The total number of segments in the collection; For the set of tag sidechain fragments The total number of fragments; when confirming overlapping fragments, the similarity of the fragment molecular fingerprint is calculated to determine if the predicted sidechain fragment set... One of the predicted sidechain fragments and the set of the tag sidechain fragments If the molecular fingerprint similarity of a tag sidechain fragment exceeds a preset fingerprint similarity threshold, the two are considered as overlapping fragments; when counting the total number of fragments in the set, overlapping fragments are only counted once; The functional group similarity The calculation method is as follows: ; N GC The total number of functional group types is preset, where 1 ≤ index gc ≤ N. GC ; The set of predictable functional groups The statistical number of GC-class functional groups in the middle; The set of tag functional groups The statistical number of GC-class functional groups in the middle; A preset small constant that is greater than zero; The structural reward The calculation method is as follows: ; The generated reward R o,m The calculation method is as follows: ; Step 8-6: The various tag sequences of the current data batch... The corresponding M predicted sequences Cluster them into groups; and calculate the average reward µ for each group. o and standard deviation σ o Perform calculations; and based on each of the predicted sequences in each group. The corresponding generated reward R o,m The average value µ o and the standard deviation σ o Calculate the corresponding within-group advantage V o,m ; Wherein, the average value µ o The standard deviation σ o and the aforementioned intra-group advantage V o,m The calculation method is as follows: , ; ; λ1 is a preset small constant used to prevent the denominator from being zero, and its value is greater than zero; Step 8-7: Substitute the third molecular description of each of the third data records in the current data batch into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. o And continuously send the molecule generation command X M times. o Input the reference model M ref Processing is performed; and during the m-th task processing corresponding to the o-th third data record, the probability vector of the word list corresponding to the t-th segment generated in this step is compared with the corresponding predicted text. The t-th segmentation The corresponding word segmentation probabilities are extracted and used as the corresponding prediction probabilities. ; Step 8-8: Substitute the third molecular description of each of the third data records in the current data batch into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. o And continuously send the molecule generation command X M times. o Input the new strategy model M new Processing is performed; and during the m-th task processing corresponding to the o-th third data record, the probability vector of the word list corresponding to the t-th segment generated in this step is compared with the corresponding predicted text. The t-th segmentation The corresponding word segmentation probabilities are extracted and used as the corresponding prediction probabilities. ; Steps 8-9: For each of the predicted texts Each of the aforementioned words Importance sampling ratio r o,m,t And truncation sampling ratio Perform calculations; Wherein, the importance sampling ratio r o,m,t and the truncation sampling ratio The calculation method is as follows: , ; λ2 is the preset truncation threshold, and Clip() is the Clip truncation function; Steps 8-10: Based on the preset third model loss function L M3 The corresponding third loss value is obtained through calculation; Wherein, the third model loss function L M3 The objective function J based on the group relative strategy optimization algorithm GRPO To achieve this, the objective function J of the group relative strategy optimization algorithm is... GRPO Then, by the policy function term J policy , divergence function term J KL The composition is as follows: , , ; β is the preset divergence coefficient; Steps 8-11 involve identifying whether the third loss value meets a preset range; if the third loss value does not meet the preset range, the third model optimizer is then used to optimize the third model loss function L. M3 The direction for reaching the minimum value corresponds to the new strategy model M. new The model parameters θ new Perform one round of modulation, and return to step 8-2 at the end of this round of modulation; if the third loss value meets the range of the third loss value, then based on the model parameter θ new For the old strategy model M old The model parameters θ old Perform a reset and identify whether the current data batch is the last third data batch. If not, use the next third data batch as the new current data batch and return to step 8-2. If yes, stop training and confirm that the reinforcement training of the first large language model is complete, and set the new policy model M. new As the latest and largest language model; The third model optimizer includes the Adam optimizer and the AdamW optimizer.

[0012] A second aspect of the present invention provides an apparatus for implementing the molecular generative model processing method described in the first aspect above. The apparatus includes: an instruction template configuration module, a model selection and construction module, a dataset construction module, a post-processing model training module, a large language model training module, a generative model construction module, and a generative model application module. The instruction template configuration module is used to configure the molecule generation instruction template; The model selection and construction module is used to select a general-purpose language model that has completed pre-training for both large language models and general NLP tasks as the corresponding first large language model; and to configure a post-processing model for optimizing the molecular structure of the molecular sequences generated by the first large language model in conjunction with molecular descriptions; the first large language model includes at least the Qwen series models, GPT series models, and DeepSeek series models; the general-purpose NLP tasks include at least text generation tasks, translation tasks, question answering tasks, and thought chain derivation tasks; the post-processing model is used to optimize the molecular structure based on the molecular description D and molecular sequence S input to the model and output the optimized molecular sequence S. * ; The dataset construction module is used to collect molecular sequences from public molecular libraries, obtain molecular descriptions of each collected sequence by querying the molecular library, label the molecular sequence and inference chain tags of each collected sequence, modify each sequence tag according to preset structural tampering rules to obtain the corresponding sequence to be optimized, construct a first dataset based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, construct a second dataset based on all molecular descriptions and their corresponding inference chain tags, and construct a third dataset based on all molecular descriptions and their corresponding sequence tags. The post-processing model training module trains the post-processing model based on the first dataset; The large language model training module performs inference training on the first large language model based on the molecular generation instruction template and the second dataset; after the inference training is completed, the first large language model is further enhanced by the group relative strategy optimization mechanism based on the molecular generation instruction template and the third dataset. The generative model building module is used to construct a corresponding molecular generation model based on the first large language model and the post-processing model after both types of models have been trained. The molecular generation model is used to process molecular generation tasks according to the molecular generation instructions X input by the model and output the corresponding molecular sequence S. *The molecule generation instruction X is an instruction text generated based on the molecule generation instruction template, and its text structure is consistent with the molecule generation instruction template. The generative model application module is used to substitute the molecular description input by the user into the molecular generation instruction template, set the molecular description text of the template's molecular description segment to obtain the corresponding molecular generation instruction X, and input the molecular generation instruction X into the molecular generation model for processing to obtain the corresponding molecular sequence S. * Provide feedback to the current user.

[0013] A third aspect of the present invention provides an electronic device, including: a memory, a processor, and a transceiver; The processor is used to couple with the memory, read and execute instructions in the memory to implement the steps of the method described in the first aspect above; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

[0014] A fourth aspect of the present invention provides a computer-readable storage medium storing computer instructions that, when executed by a computer, cause the computer to perform the instructions described in the first aspect.

[0015] This invention provides a method, apparatus, electronic device, and computer-readable storage medium for processing molecular generation models. As described above, this invention first selects a general-purpose large language model as the first large language model and configures a post-processing model for optimizing the molecular structure of the generated molecular sequences from the first large language model by combining molecular descriptions. A corresponding molecular generation instruction template is also configured. Then, large-scale data collection of molecular sequences from publicly available molecular libraries is performed. Molecular descriptions for each collected sequence are obtained by querying the molecular library. The molecular sequences and inference chain tags of each collected sequence are labeled, and each sequence tag is modified according to preset structural tampering rules to obtain the corresponding sequence to be optimized. A first dataset is constructed based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags. A second dataset is constructed based on all molecular descriptions and their corresponding inference chain tags. A third dataset is constructed based on all molecular descriptions and their corresponding sequence tags. Then, the post-processing model is trained based on the first dataset. When training the first large language model, it is first trained for inference based on the molecular generation instruction template and the second dataset, and then reinforced based on the GRPO mechanism using the molecular generation instruction template and the third dataset. After training the two types of models, a molecular generation model is constructed using the primary language model and the post-processing model as its core. This molecular generation model is then used to process the user's molecular generation tasks. The model processes the molecular generation instructions X input to the model and outputs the corresponding molecular sequences S. * When processing user tasks, the molecular description input by the user is substituted into the molecular generation instruction template for setting. The resulting molecular generation instruction X is then input into the molecular generation model for processing to obtain the molecular sequence S. * Provide feedback to the current user. This embodiment of the invention improves the model's chemical knowledge reasoning ability and enhances the chemical accuracy of the generated molecules. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of a molecular generation model processing method provided in Embodiment 1 of the present invention; Figure 2 This is a block diagram of the post-processing model provided in Embodiment 1 of the present invention; Figure 3 This is a block diagram of the molecular generation model provided in Embodiment 1 of the present invention; Figure 4 This is a module structure diagram of a molecular generation model processing device provided in Embodiment 2 of the present invention; Figure 5 This is a schematic diagram of the structure of an electronic device provided in Embodiment 3 of the present invention. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.

[0018] Embodiment 1 of the present invention provides a method for processing molecular generation models, such as... Figure 1 The schematic diagram shows a molecular generation model processing method provided in Embodiment 1 of the present invention. The method mainly includes the following steps: Step 1: Configure the molecular generation instruction template.

[0019] Here, the molecular generation instruction template of this invention consists of an instruction requirement section, a molecular description section, a reasoning step description section, and a formatting requirement section. Wherein: 1) Instruction request text: The instruction requires the text to be a fixed natural language text, which prompts the model to perform step-by-step analysis and reasoning based on the molecular description information given in the molecular description text, the step sequence given in the reasoning steps description text, and to generate a SELFIES molecular sequence that conforms to chemical laws based on the reasoning context.

[0020] It should be noted that the specific text content of the instruction requirement paragraph in the embodiments of the present invention can be customized based on application requirements or the developer's language habits. For example, "Based on the molecular description information provided below, perform step-by-step analysis according to the given reasoning steps, and finally generate a SELFIES molecular sequence that conforms to chemical laws, and output the obtained SELFIES molecular sequence based on the formatting requirements."

[0021] 2) Molecular description passage: A molecular description segment consists of a fixed description segment title and configurable molecular description text. The default description segment title is the string "Molecular Description:". The molecular description text is initialized to empty. When the molecular description text is not empty, it is a natural language description of the molecular properties, which may include chemical symbols, molecular formulas, chemical equations and expressions, and may also include fragment sequence information in SELFIES format.

[0022] In practical applications, molecular description text is usually set based on the molecular description information input by the user, such as "This molecule is an aromatic compound containing a benzene ring, with the molecular formula C6H6, all atoms being carbon and hydrogen, and all hydrogen atoms on the benzene ring being saturated".

[0023] 3) Explanation of the reasoning steps: The text for explaining the reasoning steps is a fixed natural language text, consisting of N text segments for reasoning steps, where N is the total number of preset reasoning steps; each text segment for a reasoning step is the step description text for one-step reasoning, used to prompt the model to analyze and reason according to the requirements of this step of reasoning based on the current reasoning context and use the result of this step of reasoning as the corresponding single-step reasoning text C i and output, where 1 ≤ index i ≤ N; the current reasoning context includes the molecular description information given by the molecular description text and the reasoning results of all historical steps before the current reasoning step; the single-step reasoning text C corresponding to the Nth step i=N is the corresponding SELFIES molecular sequence.

[0024] It should be noted that the specific text content of the text for explaining the reasoning steps in the embodiments of the present invention can be customized based on application requirements or the usage habits of developers. For example: The total number of reasoning steps N = 3, and the text for explaining the reasoning steps is set as: "Step 1: Carefully read the molecular description, identify the types and quantities of atoms, the atomic skeleton, and key structural units (such as the skeleton, side chain fragments, rings, functional groups, etc.) in the molecule; Step 2: Based on the analysis in Step 1, construct the two-dimensional structure of the molecule, including the connection relationships between atoms and the types of bonds; Step 3: Convert the molecular structure obtained in Step 2 into a SELFIES string, ensuring that the string can be correctly parsed and conforms to chemical rules".

[0025] 4) Formatting requirements text segment: The formatting requirements text segment is a fixed natural language text, used to prompt the model to perform text encapsulation and output on the generated SELFIES molecular sequence according to the preset molecular sequence output format.

[0026] Here, the molecular sequence output format in the embodiments of the present invention is defaultly formed by sequentially connecting the preset start marker text, the SELFIES molecular sequence generated by the model, and the preset end marker text.

[0027] It should be noted that the specific text content of the formatting requirements text segment in the embodiments of the present invention can be customized based on application requirements or the usage habits of developers.[[ID=二十一]] [[ID=二十二]]

[0028] [[ID=二十三]]For example, let the start marker text be "<molecular sequence>" and the end marker text be "< / molecular sequence>", and the formatting requirements text segment is "Molecular description formatting requirements: The generated molecular description text must be output in the following format: <molecular sequence>... < / molecular sequence>".[[ID=二十四]] [[ID=二十五]]

[0029] [[ID=二十六]]Step 2, select a general large language model that has completed pre-training of the large language model and pre-training of general NLP tasks as the corresponding first large language model; and configure a post-processing model for optimizing the molecular structure of the molecular sequence generated by the first large language model in combination with the molecular description.

[0030] Here, the first major language model in this embodiment of the invention includes at least the Qwen series models, the GPT series models, and the DeepSeek series models. The general NLP tasks mentioned in this embodiment of the invention include at least text generation, translation, question answering, and thought chain derivation tasks.

[0031] The post-processing model in this embodiment of the invention is used to optimize the molecular structure based on the molecular description D and molecular sequence S input to the model and output the optimized molecular sequence S. * .

[0032] like Figure 2 As shown in the module structure diagram of the post-processing model provided in Embodiment 1 of the present invention, the first model input terminal of the post-processing model is used to receive the molecular description D, the second model input terminal is used to receive the molecular sequence S, and the model output terminal is used to output the molecular sequence S. * .

[0033] like Figure 2 As shown, the post-processing model components include: a text encoder, a molecular conformation conversion module, a Uni-Mol model, a global feature fusion module, an atom pair feature gating module, an atom type feature gating module, a chemical bond prediction module, an atom coordinate prediction module, an atom type prediction module, and a molecular sequence conversion module.

[0034] like Figure 2 As shown, the connection relationships of the model components in the post-processing model are as follows: the input end of the text encoder is connected to the input end of the first model, and its output end is connected to the first input end of the global feature fusion module; the input end of the molecular conformation conversion module is connected to the input end of the second model, its first output end is connected to the first input end of the chemical bond prediction module, and its second output end is connected to the input end of the Uni-Mol model; the first output end of the Uni-Mol model is connected to the second input end of the global feature fusion module, its second output end is connected to the second input end of the atom pair feature gating module, and its third output end is connected to the second input end of the atom type feature gating module; the output end of the global feature fusion module is connected to the chemical bond prediction module, and its third output end is connected to the second input end of the chemical bond prediction module. The second input terminal of the measurement module, the first input terminal of the atom pair feature gating module, and the first input terminal of the atom type feature gating module are connected; the output terminal of the atom pair feature gating module is connected to the third input terminal of the chemical bond prediction module and the first input terminal of the atom coordinate prediction module, respectively; the output terminal of the atom type feature gating module is connected to the fourth input terminal of the chemical bond prediction module, the second input terminal of the atom coordinate prediction module, and the input terminal of the atom type prediction module, respectively; the output terminals of the chemical bond prediction module, the atom coordinate prediction module, and the atom type prediction module are connected to the first, second, and third input terminals of the molecular sequence conversion module, respectively; the output terminal of the molecular sequence conversion module is connected to the model output terminal.

[0035] The model component functionality of the post-processing model is shown below.

[0036] 1) Text encoder: The text encoder in this embodiment of the invention is implemented based on the encoder structure of the Transformer architecture.

[0037] The text encoder is used to encode the molecular description D into text to obtain the corresponding text feature vector H. D Send to the global feature fusion module.

[0038] Specifically, this includes: segmenting the molecular description D according to a pre-defined professional chemical glossary to obtain the corresponding current segmentation sequence; embedding the current segmentation sequence into text embedding vectors; performing feature encoding on the text embedding vectors to obtain the corresponding feature encoding vectors; and performing max pooling on each feature channel of the feature encoding vectors to obtain the corresponding text feature vectors H. D Send to the global feature fusion module.

[0039] Here, the word segmentation set of the specialized chemical vocabulary in this embodiment of the invention includes not only symbols, numbers, characters, and words from the natural language domain, but also symbols, numbers, characters, and words from the specialized chemical knowledge domain, and symbols, numbers, characters, and words from the molecular sequence characterization domain. The feature encoding vector in this embodiment of the invention has a shape of L×d. D L represents the total number of words corresponding to the molecular description D, and d D The preset text feature dimensions; feature vector H D The shape is 1×d D .

[0040] 2) Molecular conformation conversion module: The molecular conformation conversion module in this embodiment of the invention is used to identify the atomic type, atomic coordinates and chemical bonds according to the molecular sequence S to obtain the corresponding atomic type set A, atomic coordinate set P and chemical bond set E, and send them to the corresponding chemical bond prediction module and Uni-Mol model.

[0041] Specifically, the following steps are taken: using a preset cheminformatics tool to perform molecular conformation transformation on the molecular sequence S to obtain the corresponding current conformation; using the cheminformatics tool to identify the atom type and atom coordinates of each atom in the current conformation atom set and to identify the chemical bonds between the atoms in the current conformation to obtain the corresponding atom type set A, atom coordinate set P, and chemical bond set E; and sending the chemical bond set E to the chemical bond prediction module, and sending the atom type set A and atom coordinate set P to the Uni-Mol model.

[0042] Here, the cheminformatics tools in this embodiment of the invention include at least the RDKit tool. The total number of atoms in the current conformation is denoted as N.A Atom type set A includes N A Atom type a j 1 ≤ atomic index j ≤ N A The atomic coordinate set P includes N A Atom coordinates p j Atomic coordinates p j This is a three-dimensional coordinate system. The chemical bond set E includes multiple chemical bonds e. Each chemical bond e includes a corresponding atom pair index set and a chemical bond type. The atom pair index set consists of the atom indices j and k of the two atoms corresponding to the current chemical bond, where 1 ≤ atom index k ≤ N. A ,k≠j.

[0043] 3) Uni-Mol model: The Uni-Mol model in this embodiment of the invention is a large-scale model for atomic-level feature representation of molecules. Its model structure and pre-training mechanism can be understood through the publicly available technical document "Uni-Mol: A Universal 3D Molecular Representation Learning Framework". It should be noted that the Uni-Mol model in this embodiment of the invention has completed large-scale model pre-training. The pre-training tasks of the Uni-Mol model include at least masked atom prediction and atom coordinate prediction tasks.

[0044] The Uni-Mol model is used to perform atomic-level feature encoding and global molecular feature recognition on the current molecule based on the atom type set A and the atom coordinate set P, thereby obtaining the corresponding molecular feature vector H. cls Atom pair characteristic matrix H P Atomic eigenvectors H A And the molecular feature vector H cls Send the atomic pair feature matrix H to the global feature fusion module P and atomic eigenvectors H A Send the atomic feature vector H to the atomic pair feature gating module. A Send to the atomic type feature gating module.

[0045] Specifically, the process involves: generating corresponding atom sequences based on the atom type set A, and performing embedding encoding on the atom sequences to obtain corresponding atom embedding vectors; and setting the initialized atom pair feature matrix H based on the atom coordinate set P. P ; and combined with the atom pair feature matrix H P Feature encoding is performed on the atomic embedding vector to obtain the corresponding atomic feature vector H. A And during the encoding process, the feature matrix H of the atomic pairs is... P Perform iterative updates; and update the final atomic feature vector H. AAverage pooling is performed on each feature channel to obtain the corresponding molecular feature vector H. cls ; and the molecular feature vector H cls Send the atomic pair feature matrix H to the global feature fusion module. P and atomic eigenvectors H A Send the atomic feature vector H to the atomic pair feature gating module. A Send to the atomic type feature gating module.

[0046] Among them, the atomic eigenvector H A The shape is N A ×d A d A The atomic feature vector H is defined by the preset atomic type feature dimension. A By N A The vectors have a length of d. A For feature vectors Composition; Atom pair characteristic matrix H P The shape is N A ×N A ×3; Molecular eigenvector H cls The shape is 1×d A Atom pair characteristic matrix H P By N A ×N A Each feature vector has a length of 3. Composition, 1 ≤ atomic index k ’ ≤N A Each feature vector Used for their corresponding atom pairs (j,k) ’ The three-dimensional coordinate spacing is used for feature characterization.

[0047] 4) Global Feature Fusion Module: The global feature fusion module in this embodiment of the invention is used to perform attention-weighted fusion based on the text feature vector H. D and molecular eigenvector H cls Generate the corresponding global feature vector H G Send to the chemical bond prediction module, the atom pair feature gating module, and the atom type feature gating module.

[0048] Specifically: The text feature vector H D and molecular eigenvector H cls The two projection vectors H are obtained by projecting them onto a predefined global feature space. D-p H cls-p And for the two projection vectors H D-p H cls-p The corresponding two attention weights at D-p ,atcls-p Perform calculations; and based on two attention weights at D-p ,at cls-p For two projection vectors H D-p H cls-p The corresponding global feature vector H is obtained by performing feature weighting. G Send to the chemical bond prediction module, the atom pair feature gating module, and the atom type feature gating module.

[0049] Here, the two projection vectors H D-p H cls-p The calculation method is as follows: , ; Among them, W D-p b D-p W represents the text feature projection transformation matrix and bias vector of the model. cls-p b cls-p W represents the molecular feature projection transformation matrix and bias vector of the model; D-p The shape is d G ×d D W cls-p The shape is d G ×d A b D-p b cls-p The shape is 1×d G d G The feature dimension of the global feature space; the projection vector H D-p H cls-p The shape is 1×d G .

[0050] Two attention weights at D-p ,at cls-p The calculation method is as follows: ; Among them, W at1 W at2 Let b be the first and second attention transformation matrices of the model. at1 b at2 W represents the first and second attention bias vectors of the model. at1 The shape is d at ×2d G b at1 The shape is 1×d at W at2 The shape is 2×d at b at2 The shape is 1×2, d atis the preset attention feature dimension; concate() is the vector concatenation function, tanh() is the Tanh activation function, softmax() is the Softmax function; AT is the attention vector.

[0051] vector The shape is 1×2d G ; vector The shape is 1×d at ; vector The shape is 1×2; The attention vector AT has a shape of 1×2, and is composed of the corresponding attention weights at. D-p ,at cls-p Composition, at D-p +at cls-p =1.

[0052] Global eigenvector H G The calculation method is as follows: .

[0053] Among them, the global feature vector H G The shape is 1×d G .

[0054] 5) Atom Pair Feature Gating Module: The atom pair feature gating module in this embodiment of the invention is used to control the atom pair feature based on the global feature vector H. G Atom pair characteristic matrix H P and atomic eigenvectors H A Adding a global feature-gated component to each atom pair feature yields a new atom pair feature matrix. Send to the chemical bond prediction module and the atomic coordinate prediction module.

[0055] Specifically, based on the global feature vector H G Atom pair characteristic matrix H P and atomic eigenvectors H A For each atom pair (j,k) ’ Generate the corresponding gated scalar and candidate feature vectors ; and based on each atom pair (j,k) ’ The corresponding gated scalar Candidate feature vectors and eigenvectors Calculate the corresponding gated feature vector ; and from the obtained N A ×N A gated feature vectors Forming the corresponding atom pair feature matrix Send to the chemical bond prediction module and the atomic coordinate prediction module.

[0056] Here, the gated scalar The calculation method is as follows: ; Among them, W g1 b g1 Let the first gating transformation matrix and bias vector of the model be denoted as . For atomic eigenvectors H A The eigenvector of the k-th atom W g1 The shape is 1×(3+2d) A +d G ), b g1 The shape is 1×1; sigmoid() is the sigmoid activation function; vector The shape is 1×(3+2d) A +d G ).

[0057] Candidate feature vectors The calculation method is as follows: ; Among them, W g2 b g2 W represents the second gating transformation matrix and bias vector of the model. g2 The shape is 3×(3+2d) A +d G ), b g2 The shape is 1×3; candidate feature vector Shape and eigenvectors Maintain consistency.

[0058] Gated feature vectors The calculation method is as follows: ; Among them, the atom pair feature matrix The shape is N A ×N A ×3.

[0059] 6) Atom type feature gating module: The atom type feature gating module in this embodiment of the invention is used to determine the atom type feature based on the global feature vector H. G and atomic eigenvectors H A Adding a global feature-gated component to each atomic feature yields a new atomic feature vector. Send to the chemical bond prediction module, atomic coordinate prediction module, and atom type prediction module.

[0060] Specifically, based on the global feature vector H G and atomic eigenvectors H A Generate a corresponding gated scalar g for each atom j and candidate feature vectors ; and based on the gating scalar g corresponding to each atom j Candidate feature vectors and eigenvectors Calculate the corresponding gated feature vector ; and from the obtained N A gated feature vectors Form the corresponding atomic feature vectors Send to the chemical bond prediction module, atomic coordinate prediction module, and atom type prediction module.

[0061] Here, the gated scalar g j The calculation method is as follows: ; Among them, W g3 b g3 W represents the third gating transformation matrix and bias vector of the model. g3 The shape is 1×d A b g1 The shape is 1×1.

[0062] Candidate feature vectors The calculation method is as follows: ; Among them, W g4 b g4 W represents the fourth gating transformation matrix and bias vector of the model. g4 The shape is d A ×(d A +d G ), b g2 The shape is 1×d A ;vector The shape is 1×(d A +d G Candidate feature vectors Shape and eigenvectors Maintain consistency.

[0063] Gated feature vectors The calculation method is as follows: ; Among them, atomic feature vectors The shape is N A ×d A .

[0064] 7) Chemical bond prediction module: The chemical bond prediction module in this embodiment of the invention is used to predict chemical bonds based on the chemical bond set E and the global feature vector H. G Atom pair characteristic matrix and atomic eigenvectors Chemical bond prediction yields the corresponding chemical bond set E. * Send to the molecular sequence conversion module.

[0065] Specifically: First, set a shape of N. A ×N A ×N C The all-zero matrix is ​​used as the initial chemical bond characteristic matrix H. E N C The chemical bond feature matrix H represents the preset total number of chemical bond types. E By N A ×N A The length of each vector is N C eigenvectors Composition; then based on the eigenvectors of each chemical bond e in the chemical bond set E. Perform one-hot encoding; then index the two symmetric atom pairs (j,k) by row / column index of each matrix. ’ ), (k ’ (j) form a corresponding symmetric group, and the index k in each symmetric group is... ’ ≠j; and then based on atomic feature vectors Atom pair characteristic matrix Chemical bond characteristic matrix H E The two gated feature vectors corresponding to each symmetric group Two gated feature vectors Two eigenvectors and global feature vector H G Predict the corresponding chemical bond prediction vector c; then set the corresponding chemical bond e based on the chemical bond prediction vector c of each symmetry group. * Then, remove the invalid chemical bonds (e) from the list of invalid chemical bonds. * Cleared, by all remaining chemical bonds e * The corresponding chemical bond set E * Send to the molecular sequence conversion module.

[0066] Here, the chemical bond prediction vector c corresponding to the symmetry group is calculated as follows: , , , , ; Among them, W c b c W represents the chemical bond transformation matrix and bias vector of the model. c The shape is N C ×(2d A +3+d G +N C ), b c The shape is 1×N C ;vector , The shape is 1×(2d) A +3+d G +N C ); , For two atomic pairs (j,k) in the symmetry group ’ ), (k ’ The eigenvectors corresponding to each of the following are all of shape 1×N. C ; , For two atomic pairs (j,k) in the symmetry group ’ ), (k ’ The prediction vectors corresponding to each of the following are all of shape 1×N. C All are composed of N C Each prediction probability consists of a set of prediction probabilities, and each prediction probability corresponds to a type of chemical bond; the prediction vector c is composed of two corresponding prediction vectors. , The mean vector is also determined by N. C It consists of a number of predicted probabilities.

[0067] The chemical bond e corresponding to the symmetry group * The setup is as follows: the maximum predicted probability in the prediction vector c corresponding to the current symmetry group is used as the candidate probability; and it is determined whether the candidate probability is less than a preset effective probability threshold. If so, the chemical bond type corresponding to the current symmetry group is set as an invalid chemical bond type; otherwise, the chemical bond type corresponding to the candidate probability is used as the chemical bond type corresponding to the current symmetry group; and the atom indices j and k corresponding to the current symmetry group are used as the selection criteria. ’ A corresponding atom pair index group is formed; and the corresponding chemical bond e is formed by the chemical bond type corresponding to the current symmetry group and the atom pair index group. * .

[0068] Here, the effective probability threshold of this embodiment of the invention is a preset probability value.

[0069] 8) Atomic coordinate prediction module: The atomic coordinate prediction module of this invention is based on the task model implementation of the atomic coordinate prediction task of the Uni-Mol model, specifically an SE(3) equivariant graph neural network model.

[0070] The atomic coordinate prediction module is used to predict atomic coordinates based on atomic feature vectors. and the characteristic matrix of atomic pairs The 3D changes of all atomic coordinates are predicted to obtain the corresponding coordinate change set ΔP; and the atomic coordinate set P is corrected based on the coordinate change set ΔP to obtain a new atomic coordinate set P. * Send to the molecular sequence conversion module.

[0071] Among them, the atomic coordinate set P includes N A Atom coordinates p j The coordinate transformation set △P includes N A The coordinate change Δp j Atomic coordinate set P * Including N A atomic coordinates , .

[0072] 9) Atom type prediction module: The atom type prediction module in this embodiment of the invention is used to predict the atom type based on the atom feature vector. A new set of atom types, A, is obtained by performing atom type prediction. * Send to the molecular sequence conversion module.

[0073] Specifically, this refers to: atomic feature vectors Each gated feature vector A linear transformation yields a shape of 1×d AC eigenvectors d AC The total number of preset atom types; and based on the Softmax function according to each feature vector. Calculate the corresponding probability vector ; and each probability vector The atom type corresponding to the highest probability in the atom is used as the corresponding atom type. ; The obtained N A Atom types Form the corresponding atom type set A * Send to the molecular sequence conversion module.

[0074] Here, the feature vector probability vector The calculation method is as follows: , ; Among them, Wac b ac To predict the transformation matrix and bias vector for the model type, W ac The shape is d AC ×d A b ac The shape is 1×d AC probability vector The shape is 1×d AC , by d AC Each prediction probability consists of a set of predicted probabilities, and each predicted probability corresponds to a type of atom.

[0075] 10) Molecular sequence conversion module: The molecular sequence conversion module is used to convert chemical bond sets E * Atomic coordinate set P * and atomic type set A * The corresponding optimized molecular conformation was set; the optimized molecular conformation was then subjected to SELFIES molecular sequence conversion using cheminformatics tools to obtain the corresponding optimized molecular sequence; and the optimized molecular sequence was used as the corresponding molecular sequence S. * Output.

[0076] Step 3: Collect molecular sequences from publicly available molecular libraries, obtain molecular descriptions for each collected sequence by querying the molecular library, label the molecular sequence and inference chain tags for each collected sequence, modify each sequence tag according to preset structure tampering rules to obtain the corresponding sequence to be optimized, construct the first dataset based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, construct the second dataset based on all molecular descriptions and their corresponding inference chain tags, and construct the third dataset based on all molecular descriptions and their corresponding sequence tags.

[0077] The publicly disclosed molecular libraries in this embodiment of the invention include at least the PubChem database and the PDB database.

[0078] The structural modification rules in this invention include at least atomic substitution rules, chemical bond substitution rules, and functional group substitution rules. Wherein: 1) Atomic substitution rules: Atom substitution rules are used to configure one or more classes of specified types of atoms and to configure corresponding replacement atom types for each class of specified types of atoms; and to specify that when tampering with the molecular conformation, one or more atoms are randomly selected from the current conformation as replacement objects based on some or all of the specified types of atoms, and the current object is replaced based on the replacement atom type corresponding to each replacement object.

[0079] 2) Chemical bond substitution rules: Chemical bond substitution rules are used to configure one or more classes of specified chemical bonds and to configure corresponding substitution bond types for each class of specified chemical bonds; and to stipulate that when tampering with the molecular conformation, one or more chemical bonds are randomly selected from the current conformation as substitution objects based on some or all of the specified chemical bonds, and the current object is replaced based on the substitution bond type corresponding to each substitution object.

[0080] 3) Functional group replacement rules: Functional group substitution rules are used to configure one or more specified types of functional groups and to configure corresponding substitution functional group types for each specified type of functional group; and to stipulate that when tampering with the molecular conformation, one or more functional groups are randomly selected from the current conformation as substitution objects based on some or all of the specified types of functional groups, and the current object is replaced based on the substitution functional group type corresponding to each substitution object.

[0081] The first dataset in this embodiment of the invention includes multiple first data records; each first data record includes a first sequence to be optimized, a first molecular description, and a first tag sequence; the first sequence to be optimized and the first tag sequence are each a SELFIES molecular sequence, and the first training sequence is obtained by modifying the sequence information of the corresponding first tag sequence based on structural modification rules.

[0082] The second dataset in this embodiment of the invention includes multiple second data records; each second data record includes a second molecule description and a first label inference chain; the first label inference chain includes N single-step inference labels. .

[0083] The third dataset in this embodiment of the invention includes multiple third data records; each third data record includes a third molecular description and a second tag sequence; the second tag sequence is a SELFIES molecular sequence.

[0084] The current step 3 specifically includes: Step 31: Perform big data collection on the SMILES and SELFIES molecular sequences in the publicly available molecular library to obtain multiple collected sequences that form the corresponding first sequence set.

[0085] Here, the first sequence set includes multiple first sequences; each first sequence is a SMILES molecular sequence or a SELFIES molecular sequence.

[0086] Step 32: Each first sequence is taken as the current sequence; a molecular summary or comprehensive description corresponding to the current sequence is obtained by querying the molecular library and used as a set of corresponding first molecular description, second molecular description, and third molecular description; the sequence format of the current sequence is identified as SELFIES sequence format. If it is, the current sequence is used as a set of corresponding first tag sequence and second tag sequence; otherwise, cheminformatics tools are used to convert the current sequence to SELFIES molecular sequence and the conversion result is used as a set of corresponding first tag sequence and second tag sequence; a sequential traversal of all step description texts in the reasoning step description section of the molecular generation instruction template is performed; at the beginning of this traversal, the corresponding reasoning context is initialized to empty; during this traversal, the currently traversed step description text is used as the current step description, and according to the preset question construction rules, the current sequence, current step description, and reasoning context are combined to form a corresponding current question. The current question is then processed through a preset professional chemical question-and-answer interface, and the answer text obtained in this processing is used as a corresponding single-step reasoning tag. The current question and answer are combined to form a corresponding question-and-answer text context for inference; and at the end of this round of traversal, the N single-step inference tags obtained from this round of traversal are added. A corresponding first tag inference chain is formed; the current sequence is transformed into a molecular conformation using cheminformatics tools to obtain the corresponding current conformation, and the current conformation is randomly modified based on the structure tampering rules to obtain the corresponding current tampered conformation. The current tampered conformation is then transformed into a SELFIES molecular sequence using cheminformatics tools, and the transformation result is used as the corresponding first sequence to be optimized.

[0087] Here, the question construction rules of this invention are used to set analysis questions with the current sequence and reasoning context as reference context and the current step description as the current analysis target. The professional chemistry question-and-answer interface of this invention is a type of human question-and-answer task processing interface for professional chemistry experts, a type of system question-and-answer task processing interface for professional chemistry question-and-answer systems, or a type of model question-and-answer task processing interface for large-scale professional chemistry models.

[0088] Step 33: Each first sequence to be optimized and its corresponding first molecular description and first tag sequence form a corresponding first data record; and all the obtained first data records form a corresponding first dataset.

[0089] Step 34: Each second molecule description and its corresponding first label inference chain form a corresponding second data record; and all the obtained second data records form a corresponding second dataset.

[0090] Step 35: Each third molecule description and its corresponding second tag sequence form a corresponding third data record; and all the obtained third data records form a corresponding third dataset.

[0091] Step 4: Train the post-processing model based on the first dataset.

[0092] Specifically, it includes: Step 41: The model parameter set of the post-processing model, including the text encoder, global feature fusion module, atom pair feature gating module, atom type feature gating module, chemical bond prediction module, atom coordinate prediction module, and atom type prediction module, is used as the current model parameter set; the first dataset is divided into multiple first data batches based on the preset batch size B1; and the first first data batch is used as the current data batch.

[0093] Here, each first data batch includes B1 first data records; the first tag sequence of each first data record in each first data batch is denoted as the corresponding tag sequence. , 1≤indexq≤B1.

[0094] Here, the batch size B1 in this embodiment of the invention is a pre-set positive integer.

[0095] Step 42: Take each first data record of the current data batch as the current record; and input the first molecular description and the first sequence to be optimized of the current record as the corresponding molecular description D and molecular sequence S into the post-processing model for processing, and input the chemical bond set E generated by the model during this processing. * Atomic coordinate set P * and atomic type set A * As the corresponding chemical bond set Atomic coordinate set and atomic type set ; and use cheminformatics tools to analyze the currently recorded tag sequence. Perform molecular conformational transformation and use cheminformatics tools to analyze the chemical bond set corresponding to the current conformation. Atomic coordinate set and atomic type set Identification is performed; and the chemical bond set corresponding to the current record is used to... Atomic coordinate sets Atom type set pairs Form a corresponding first prediction-label group.

[0096] Step 43: Substitute the B1 first prediction-label groups of the current data batch into the preset first model loss function L. M1 The corresponding first loss value is obtained through calculation.

[0097] Here, the first model loss function L in this embodiment of the invention M1 for: ; Among them, the atomic type loss function L A Based on the cross-entropy loss function, the atomic coordinate loss function L... P Based on L1 or L2 loss functions, chemical bond loss function L E Implemented based on the cross-entropy loss function.

[0098] Step 44: Identify whether the first loss value meets the preset first loss value range; if not, then based on the preset first model optimizer, move towards making the first model loss function L... M1 The direction that reaches the minimum value is used to perform a round of parameter modulation on the current model parameter set, and the process returns to step 42 when the parameter adjustment is completed. If the condition is met, it is determined whether the current data batch is the last first data batch. If not, the next first data batch is used as the new current data batch and the process returns to step 42. If the condition is met, training is stopped and the post-processing model training is confirmed to be completed.

[0099] Here, the first loss value range in this embodiment of the invention is a set numerical range. The first model optimizer includes the Adam optimizer and the SGD optimizer.

[0100] Step 5: Perform inference training on the first large language model based on the molecular generation instruction template and the second dataset; after the inference training is completed, perform reinforcement training on the first large language model based on the group relative strategy optimization mechanism according to the molecular generation instruction template and the third dataset.

[0101] Specifically, it includes: Step 51: Train the first large language model for inference based on the molecular generation instruction template and the second dataset.

[0102] Specifically, it includes: Step 511: Divide the second dataset into multiple second data batches based on the preset batch size B2; and take the first second data batch as the current data batch.

[0103] Here, the batch size B2 in this embodiment of the invention is a pre-set positive integer. Each second data batch includes B2 second data records; the first tag inference chain of each second data record in each second data batch is denoted as the corresponding tag chain. 1 ≤ index g ≤ B2; each tag chain Each single-step reasoning label Record as the corresponding single-step label Each single-step label The total number of word segments is denoted as n. g,i Each single-step label Each word segment is recorded as the corresponding 1 ≤ index u ≤ n g,i .

[0104] Step 512: Substitute the second molecular description of each second data record in the current data batch into the molecular generation instruction template, and set the molecular description text of the template's molecular description segment to obtain the corresponding molecular generation instruction X. g ; and the molecular generation instruction X g The first language model is input for processing; the autoregressive text generation process of the first language model is recorded during this processing; and after completing B2 model processing, the second model loss function L is used as the basis for the processing. M2 Calculate the corresponding second loss value.

[0105] Here, the two-model loss function L in this embodiment of the invention M2 It is implemented based on the cross-entropy loss function, specifically as follows: .

[0106] in, The reasoning label sequence is formed by concatenating the reasoning labels from the previous i-1 steps. For single-step tags The word segmentation sequence preceding the u-th word; For the model in the autoregressive generation step of the inference text at step i, the corresponding molecular generation instruction X is used. g Inference label sequence and word segmentation sequence The u-th word generated for the context is the corresponding word. The probability of.

[0107] Step 513: Identify whether the second loss value meets the preset range of the second loss value; if not, then based on the preset second model optimizer, move towards making the second model loss function L... M2 The direction that reaches the minimum value is used to fine-tune the model parameters of the first large language model in one round, and after this round of fine-tuning is completed, return to step 512; if satisfied, identify whether the current data batch is the last second data batch; otherwise, take the next second data batch as the new current data batch and return to step 512; if yes, stop training and confirm that the inference training of the first large language model is over.

[0108] Here, the second loss value range in this embodiment of the invention is a set numerical range. The second model optimizer includes the Adam optimizer, the SGD optimizer, and the AdamW optimizer.

[0109] Step 52: After the inference training is completed, the first language model is reinforced and trained based on the molecular generation instruction template and the third dataset using the group relative strategy optimization mechanism.

[0110] Specifically, it includes: Step 52-1: Copy the first major language model to obtain two copied models, and denote the current first major language model as the corresponding new policy model M. new The two replication models are denoted as the corresponding old policy models M. old Reference Model M ref and the reference model M ref The model parameters are solidified; and the new strategy model M is then implemented. new Old strategy model M old Reference Model M ref The model parameters are denoted as the corresponding model parameters θ. new Model parameters θ old Model parameters θ ref The third dataset is divided into multiple third data batches based on the preset batch size B3, and the first third data batch is used as the current data batch.

[0111] Here, the batch size B3 in this embodiment of the invention is a pre-set positive integer. Each data batch includes B3 third data records; the second tag sequence of each third data record in each data batch is denoted as the corresponding tag sequence. , 1≤indexo≤B3.

[0112] Step 52-2: Take each third data record of the current data batch as the current record; and substitute the third molecular description of the current record into the molecular generation instruction template to set the molecular description text of the template's molecular description segment to obtain the corresponding molecular generation instruction X. o And continuously generate the molecular command X M times. o Input old policy model M old The process yields M corresponding predicted texts. And according to the formatting requirements of the molecular generation instruction template, the molecular sequence output format of the text segment is obtained from each predicted text. Extract the corresponding SELFIES molecular sequences as the corresponding predicted sequences. .

[0113] Here, the number of repetitions M in this embodiment of the invention is a preset positive integer, where 1 ≤ index m ≤ M. Each predicted text The total number of word segments is recorded as the corresponding Each predicted text Each word segment is recorded as the corresponding 1≤index t≤ Each segmentation The corresponding predicted probability is denoted as .

[0114] Step 52-3, for each predicted text The system identifies whether the text format meets the molecular sequence output format of the molecular generation instruction template; if it does, the corresponding format check result FM is set. o,m Set the value to 1; if not satisfied, set the corresponding format check result FM. o,m It is 0.

[0115] Step 52-4: Use cheminformatics tools to analyze each tag sequence. Predicted sequence The corresponding tag fingerprints are obtained by calculating the three types of molecular fingerprints. , , fingerprint prediction , , ; and used cheminformatics tools to analyze each tag sequence Predicted sequence The molecular side chains and functional groups are identified to obtain the corresponding tag side chain fragment set. , collection of tagged functional groups Predicted sidechain fragment set Predictive functional group set .

[0116] Here, the three types of molecular fingerprints in this embodiment of the invention include Morgan fingerprint, MACCS fingerprint, and RDKit fingerprint.

[0117] Tag sidechain fragment set of embodiments of the present invention When not empty, it consists of one or more tag sidechain fragments. Composition. A collection of tag functional groups. When not empty, it consists of one or more label functional groups. Composition, each tag functional group It consists of its corresponding functional group type and functional group fragments. Predicted sidechain fragment set. When not empty, it consists of one or more predictive sidechain fragments. Composition. Predicting the set of functional groups. When not empty, it is determined by one or more predictive functional groups. Composition, each predictive functional group It consists of its corresponding functional group type and functional group fragment.

[0118] Step 52-5, for each predicted sequence Its corresponding label sequence Sequence similarity fingerprint similarity Fragment similarity Functional group similarity The calculation is performed, and the average of the four similarities is used as the corresponding structural reward. ; and based on the format check results FM o,m and structural rewards Calculate the corresponding generated reward R o,m .

[0119] Here, the sequence similarity in the embodiments of the present invention Achieved through the BLEU evaluation algorithm: .

[0120] Fingerprint similarity in embodiments of the present invention This is achieved by averaging the similarity of three types of fingerprints, specifically: .

[0121] Among them, f s () represents a preset fingerprint similarity function; this fingerprint similarity function f s This includes the Jaccard similarity function and the cosine similarity function.

[0122] Fragment similarity in embodiments of the present invention The calculation method is as follows: .

[0123] in, For predicting the set of sidechain fragments With tag sidechain fragment set The total number of overlapping segments; For predicting the set of sidechain fragments With tag sidechain fragment set The total number of segments in the collection; For tag sidechain fragment set The total number of fragments. It should be noted that when identifying overlapping fragments, the similarity is determined by calculating the molecular fingerprint of the fragments. If the predicted sidechain fragment set... A set of predicted sidechain fragments and tag sidechain fragments If the molecular fingerprint similarity of a tag sidechain fragment exceeds a preset fingerprint similarity threshold, the two fragments are considered overlapping fragments. It should also be noted that overlapping fragments are only counted once when calculating the total number of fragments in the set.

[0124] Functional group similarity in embodiments of the present invention The calculation method is as follows: .

[0125] Where, N GC The total number of functional group types is preset, where 1 ≤ index gc ≤ N. GC ; For predicting functional group sets The statistical number of GC-class functional groups in the middle; For tag functional groups collection The statistical number of GC-class functional groups in the middle; It is a preset small constant that is greater than zero.

[0126] Structural rewards in embodiments of the present invention The calculation method is as follows: .

[0127] The generation reward R in this embodiment of the invention o,m The calculation method is as follows: .

[0128] Steps 52-6: Extract the label sequences from each data batch. The corresponding M prediction sequences Cluster them into groups; and calculate the average reward µ for each group. o and standard deviation σ o Perform calculations; and based on each predicted sequence in each group. The corresponding generation reward R o,m Average value µ o and standard deviation σ o Calculate the corresponding within-group advantage V o,m .

[0129] Here, the average value µ in the embodiments of the present invention o Standard deviation σ o and group advantages V o,m The calculation method is as follows: , ; ; Wherein, λ1 is a preset small constant used to prevent the denominator from being zero, and its value is greater than zero.

[0130] Steps 52-7 involve substituting the third molecular descriptions of each third data record in the current data batch into the molecular generation instruction template, setting the molecular description text of the template's molecular description segment, and obtaining the corresponding molecular generation instruction X. o And continuously generate the molecular command X M times. o Input reference model M ref Processing is performed; and during the m-th task processing corresponding to the o-th third data record, the word probability vector corresponding to the t-th segment generated in this step is compared with the corresponding predicted text. The t-th word The corresponding word segmentation probabilities are extracted and used as the corresponding prediction probabilities. .

[0131] Steps 52-8 involve substituting the third molecular descriptions of each third data record in the current data batch into the molecular generation instruction template, setting the molecular description text of the template's molecular description segment, and obtaining the corresponding molecular generation instruction X. o And continuously generate the molecular command X M times. o Input new policy model M new Processing is performed; and during the m-th task processing corresponding to the o-th third data record, the word probability vector corresponding to the t-th segment generated in this step is compared with the corresponding predicted text. The t-th word The corresponding word segmentation probabilities are extracted and used as the corresponding prediction probabilities. .

[0132] Steps 52-9 involve processing each predicted text. Each word Importance sampling ratio r o,m,t And truncation sampling ratio Perform the calculation.

[0133] Here, the importance sampling ratio r of the embodiments of the present invention o,m,t And truncation sampling ratio The calculation method is as follows: , .

[0134] Where λ2 is the preset truncation threshold, and Clip() is the Clip truncation function.

[0135] Steps 52-10: Based on the preset third model loss function L M3 The corresponding third loss value is obtained through calculation; Here, the third model loss function L in this embodiment of the invention M3 The objective function J based on the group relative strategy optimization algorithm GRPOThe objective function J of the group relative strategy optimization algorithm is implemented. GRPO Then, by the policy function term J policy , divergence function term J KL The composition is as follows: , , .

[0136] Where β is the preset divergence coefficient; Step 52-11: Identify whether the third loss value meets the preset range of the third loss value; if the third loss value does not meet the range of the third loss value, then based on the preset third model optimizer, move towards making the third model loss function L... M3 The direction that reaches the minimum value corresponds to the new strategy model M new Model parameters θ new Perform one round of modulation and return to step 52-2 at the end of this round of modulation; if the third loss value meets the range of the third loss value, then based on the model parameter θ new For the old strategy model M old Model parameters θ old Perform a reset and identify whether the current data batch is the last third data batch. If not, use the next third data batch as the new current data batch and return to step 52-2. If it is, stop training, confirm that the reinforcement training of the first major language model is complete, and set the new policy model M. new As the latest and largest language model; Here, the third loss value range in this embodiment of the invention is a set numerical range. The third model optimizer includes the Adam optimizer and the AdamW optimizer.

[0137] Step 6: After both types of models have been trained, construct the corresponding molecular generation model with the first language model and the post-processing model as the core.

[0138] Here, the molecular generation model in this embodiment of the invention is used to process molecular generation tasks according to the molecular generation instruction X input to the model and output the corresponding molecular sequence S. * Among them, the molecule generation instruction X is the instruction text generated based on the molecule generation instruction template, and its text structure is consistent with the molecule generation instruction template.

[0139] like Figure 3 As shown in the module structure diagram of the molecular generation model provided in Embodiment 1 of the present invention, the model input terminal of the molecular generation model is used to receive the molecular generation command X, and the model output terminal is used to output the molecular sequence S. * .

[0140] The molecular generation model consists of the following components: a task scheduling module, a primary language model, and a post-processing model.

[0141] The connection relationships of the model components in the molecular generation model are as follows: the input end of the task scheduling module is connected to the model input end, and the output end is connected to the model output end; the task scheduling module is also connected to the first language model and the post-processing model respectively.

[0142] The task scheduling module of the molecular generation model is used to send the received molecular generation instruction X to the first large language model; receive the formatted molecular sequence text returned by the first large language model; extract the molecular description segment from the molecular generation instruction X as the corresponding molecular description D; extract the model-generated SELFIES molecular sequence as the corresponding molecular sequence S from the formatted molecular sequence text according to the formatting requirements of the molecular generation instruction template; send the molecular description D and the molecular sequence S to the post-processing model; and receive the molecular sequence S returned by the post-processing model. * Output.

[0143] Step 7: Substitute the user-inputted molecular description into the molecular generation instruction template, set the molecular description text of the template's molecular description segment to obtain the corresponding molecular generation instruction X, and input the molecular generation instruction X into the molecular generation model for processing to obtain the corresponding molecular sequence S. * Provide feedback to the current user.

[0144] Figure 4 This is a block diagram of a molecular generation model processing device provided in Embodiment 2 of the present invention. This device can be a terminal device or server implementing the aforementioned method embodiments, or it can be a device that enables the aforementioned terminal device or server to implement the aforementioned method embodiments. For example, the device can be a device or chip system of the aforementioned terminal device or server. Figure 4 As shown, the device includes: an instruction template configuration module 201, a model selection and construction module 202, a dataset construction module 203, a post-processing model training module 204, a large language model training module 205, a generative model construction module 206, and a generative model application module 207.

[0145] The instruction template configuration module 201 is used to configure the molecular generation instruction template.

[0146] The model selection and configuration module 202 is used to select a general-purpose language model that has completed pre-training for both large-scale language models and general NLP tasks as the corresponding primary language model; and to configure a post-processing model for optimizing the molecular structure of the molecular sequences generated by the primary language model in conjunction with molecular descriptions; the primary language model includes at least the Qwen series models, GPT series models, and DeepSeek series models; the general-purpose NLP tasks include at least text generation, translation, question answering, and thought chain derivation tasks; the post-processing model is used to optimize the molecular structure based on the molecular description D and molecular sequence S input to the model and output the optimized molecular sequence S. * .

[0147] The dataset construction module 203 is used to collect molecular sequences from public molecular libraries, obtain molecular descriptions of each collected sequence by querying the molecular library, label the molecular sequence and inference chain tags of each collected sequence, and modify each sequence tag according to preset structure tampering rules to obtain the corresponding sequence to be optimized. The first dataset is constructed based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, the second dataset is constructed based on all molecular descriptions and their corresponding inference chain tags, and the third dataset is constructed based on all molecular descriptions and their corresponding sequence tags.

[0148] The post-processing model training module 204 trains the post-processing model based on the first dataset.

[0149] The large language model training module 205 performs inference training on the first large language model based on the molecular generation instruction template and the second dataset. After the inference training is completed, the first large language model is further enhanced by the group relative strategy optimization mechanism based on the molecular generation instruction template and the third dataset.

[0150] The generative model building module 206 is used to construct the corresponding molecular generation model based on the first language model and the post-processing model after both types of models have been trained. The molecular generation model is used to process the molecular generation task according to the molecular generation instructions X input to the model and output the corresponding molecular sequence S. * The molecular generation instruction X is the instruction text generated based on the molecular generation instruction template, and its text structure is consistent with the molecular generation instruction template.

[0151] The generative model application module 207 is used to substitute the molecular description input by the user into the molecular generation instruction template, set the molecular description text of the template's molecular description segment to obtain the corresponding molecular generation instruction X, and input the molecular generation instruction X into the molecular generation model for processing to obtain the corresponding molecular sequence S. * Provide feedback to the current user.

[0152] The molecular generation model processing device provided in this embodiment of the invention can execute the method steps in the above method embodiment. Its implementation principle and technical effect are similar, and will not be repeated here.

[0153] It should be noted that the division of the various modules in the above device is merely a logical functional division. In actual implementation, they can be fully or partially integrated into a single physical entity, or they can be physically separated. Furthermore, these modules can be implemented entirely in software via processing element calls; they can be fully implemented in hardware; or some modules can be implemented by processing element calls to software, while others are implemented in hardware. For example, the instruction template configuration module can be a separate processing element, or it can be integrated into a chip in the above device. Alternatively, it can be stored as program code in the memory of the above device, and called and executed by a processing element of the device. The implementation of other modules is similar. Moreover, these modules can be fully or partially integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each of the above modules can be completed through integrated logic circuits in the hardware of the processor element or through software instructions.

[0154] For example, these modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more Digital Signal Processors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs). As another example, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a System-on-a-Chip (SOC).

[0155] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the foregoing method embodiments are generated. The computer described above can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The aforementioned computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the aforementioned computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, Bluetooth, microwave, etc.) means. The aforementioned computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The aforementioned available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state disks (SSDs)).

[0156] Figure 5 This is a schematic diagram of an electronic device provided in Embodiment 3 of the present invention. This electronic device can be a terminal device or server implementing the methods of the aforementioned embodiments, or it can be a terminal device or server connected to the aforementioned terminal device or server implementing the methods of the aforementioned embodiments. Figure 5 As shown, the electronic device may include: a processor 301 (e.g., CPU), a memory 302, and a transceiver 303; the transceiver 303 is coupled to the processor 301, and the processor 301 controls the transmission and reception operations of the transceiver 303. The memory 302 may store various instructions for performing various processing functions and implementing the processing steps described in the foregoing embodiments. Preferably, the electronic device involved in the embodiments of the present invention further includes: a power supply 304, a system bus 305, and a communication port 306. The system bus 305 is used to realize communication connections between components. The communication port 306 is used for communication between the electronic device and other peripherals.

[0157] exist Figure 5The system bus 305 mentioned can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This system bus can be divided into address bus, data bus, control bus, etc. For ease of representation, it is represented by only one thick line in the figure, but this does not indicate that there is only one bus or one type of bus. The communication interface is used to enable communication between the database access device and other devices (e.g., clients, read-write libraries, and read-only libraries). Memory may include Random Access Memory (RAM) and may also include Non-Volatile Memory, such as at least one disk storage device.

[0158] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), graphics processing units (GPUs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0159] It should be noted that the embodiments of the present invention also provide a computer-readable storage medium storing instructions that, when run on a computer, cause the computer to perform the methods and processes provided in the above embodiments.

[0160] This invention provides a method, apparatus, electronic device, and computer-readable storage medium for processing molecular generation models. As described above, this invention first selects a general-purpose large language model as the first large language model and configures a post-processing model for optimizing the molecular structure of the generated molecular sequences from the first large language model by combining molecular descriptions. A corresponding molecular generation instruction template is also configured. Then, large-scale data collection of molecular sequences from publicly available molecular libraries is performed. Molecular descriptions for each collected sequence are obtained by querying the molecular library. The molecular sequences and inference chain tags of each collected sequence are labeled, and each sequence tag is modified according to preset structural tampering rules to obtain the corresponding sequence to be optimized. A first dataset is constructed based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags. A second dataset is constructed based on all molecular descriptions and their corresponding inference chain tags. A third dataset is constructed based on all molecular descriptions and their corresponding sequence tags. Then, the post-processing model is trained based on the first dataset. When training the first large language model, it is first trained for inference based on the molecular generation instruction template and the second dataset, and then reinforced based on the GRPO mechanism using the molecular generation instruction template and the third dataset. After training the two types of models, a molecular generation model is constructed using the primary language model and the post-processing model as its core. This molecular generation model is then used to process the user's molecular generation tasks. The model processes the molecular generation instructions X input to the model and outputs the corresponding molecular sequences S. * When processing user tasks, the molecular description input by the user is substituted into the molecular generation instruction template for setting. The resulting molecular generation instruction X is then input into the molecular generation model for processing to obtain the molecular sequence S. * Provide feedback to the current user. This embodiment of the invention improves the model's chemical knowledge reasoning ability and enhances the chemical accuracy of the generated molecules.

[0161] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0162] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for processing molecular generation models, characterized in that, The method includes: Configure the molecule generation instruction template; A general large language model that has completed large language model pre-training and general NLP task pre-training is selected as a corresponding first large language model; and a post-processing model for combining molecular description and optimizing the molecular structure of the generated molecular sequence of the first large language model is configured; the first large language model at least includes Qwen series model, GPT series model, DeepSeek series model; the general NLP task at least includes text generation task, translation task, question and answer task, thought chain derivation task; the post-processing model is used for molecular structure optimization according to the input of the model molecular description D and molecular sequence S and output the optimized molecular sequence S * ; We collect molecular sequences from publicly available molecular libraries, obtain molecular descriptions for each collected sequence by querying the library, and label the molecular sequence and inference chain tags for each collected sequence. Based on preset structural tampering rules, we tamper with each sequence tag to obtain the corresponding sequence to be optimized. We construct a first dataset based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, a second dataset based on all molecular descriptions and their corresponding inference chain tags, and a third dataset based on all molecular descriptions and their corresponding sequence tags. The post-processing model is trained based on the first dataset; The first large language model is trained for inference based on the molecular generation instruction template and the second dataset; after the inference training is completed, the first large language model is further trained for reinforcement based on the group relative strategy optimization mechanism according to the molecular generation instruction template and the third dataset. After both types of models have been trained, a corresponding molecular generation model is constructed using the first large language model and the post-processing model as the core. The molecular generation model is used to process molecular generation tasks according to the molecular generation instructions X input to the model and output the corresponding molecular sequence S. * The molecule generation instruction X is an instruction text generated based on the molecule generation instruction template, and its text structure is consistent with the molecule generation instruction template. The molecular description input by the user is substituted into the molecular generation instruction template to set the molecular description text of the template's molecular description segment, thereby obtaining the corresponding molecular generation instruction X. The molecular generation instruction X is then input into the molecular generation model for processing to obtain the corresponding molecular sequence S. * Provide feedback to the current user.

2. The method for processing molecular generation models according to claim 1, characterized in that, The molecule generation instruction template consists of an instruction requirement section, a molecule description section, a reasoning step description section, and a formatting requirement section; The instruction requires the text to be a fixed natural language text, which prompts the model to perform step-by-step analysis and reasoning based on the molecular description information given in the molecular description text, the step sequence given in the reasoning step description text, and to generate a SELFIES molecular sequence that conforms to chemical laws based on the reasoning context. The molecular description segment consists of a fixed description segment title and configurable molecular description text; the description segment title defaults to the string "Molecular Description:"; the molecular description text is initialized to empty; The inference step description is a fixed natural language text consisting of N inference step texts, where N is the preset total number of inference steps. Each inference step text is a step description text for one step of inference, used to prompt the model to analyze and reason according to the requirements of this step based on the current inference context, and to use the result of this step as the corresponding single-step inference text C. i And output, 1≤index i≤N; the current inference context includes the molecular description information given by the molecular description text, the inference results of all historical steps before the current inference step; the single-step inference text C corresponding to the Nth step. i=N The corresponding SELFIES molecular sequences; The formatting requirement text is a fixed natural language text used to prompt the model to encapsulate and output the generated SELFIES molecular sequences according to a preset molecular sequence output format; the molecular sequence output format is formed by connecting the preset start marker text, the model-generated SELFIES molecular sequences, and the preset end marker text in sequence by default. The publicly available molecular libraries include at least the PubChem database and the PDB database; The structural modification rules include at least atomic substitution rules, chemical bond substitution rules, and functional group substitution rules; The atomic replacement rules are used to configure one or more classes of specified types of atoms and to configure a corresponding replacement atom type for each class of specified types of atoms. It also stipulates that when altering the molecular conformation, one or more atoms are randomly selected from the current conformation as replacement objects based on some or all of the specified types of atoms, and the current object is replaced based on the type of replacement atom corresponding to each replacement object; The chemical bond substitution rules are used to configure one or more specified types of chemical bonds and to configure a corresponding substitution bond type for each specified type of chemical bond. It also stipulates that when altering the molecular conformation, one or more chemical bonds are randomly selected from the current conformation as replacement objects based on some or all of the specified types of chemical bonds, and the current object is replaced based on the type of replacement bond corresponding to each replacement object; The functional group replacement rule is used to configure one or more specified types of functional groups, and to configure a corresponding replacement functional group type for each specified type of functional group; It also stipulates that when altering the molecular conformation, one or more functional groups are randomly selected from the current conformation as replacement objects based on some or all of the specified functional groups, and the current object is replaced based on the type of the replacement functional group corresponding to each replacement object; The first dataset includes multiple first data records; each first data record includes a first sequence to be optimized, a first molecular description, and a first label sequence; the first sequence to be optimized and the first label sequence are each a SELFIES molecular sequence, and the first training sequence is obtained by modifying the sequence information of the corresponding first label sequence based on the structure modification rule; The second dataset includes multiple second data records; each second data record includes a second molecule description and a first label inference chain; the first label inference chain includes N single-step inference labels. ; The third dataset includes multiple third data records; each third data record includes a third molecular description and a second tag sequence; the second tag sequence is a SELFIES molecular sequence.

3. The method for processing molecular generation models according to claim 2, characterized in that, The post-processing model has a first model input terminal for receiving the molecular description D, a second model input terminal for receiving the molecular sequence S, and a model output terminal for outputting the molecular sequence S. * ; The post-processing model includes a text encoder, a molecular conformation conversion module, a Uni-Mol model, a global feature fusion module, an atom pair feature gating module, an atom type feature gating module, a chemical bond prediction module, an atom coordinate prediction module, an atom type prediction module, and a molecular sequence conversion module. The input end of the text encoder is connected to the input end of the first model, and the output end is connected to the first input end of the global feature fusion module; the input end of the molecular conformation conversion module is connected to the input end of the second model, the first output end is connected to the first input end of the chemical bond prediction module, and the second output end is connected to the input end of the Uni-Mol model; the first output end of the Uni-Mol model is connected to the second input end of the global feature fusion module, the second output end is connected to the second input end of the atom pair feature gating module, and the third output end is connected to the second input end of the atom type feature gating module; the output end of the global feature fusion module is connected to the second input end of the chemical bond prediction module, the second output end of the molecular conformation conversion module, and the third output end of the molecular conformation conversion module. The first input terminal of the atom pair feature gating module and the first input terminal of the atom type feature gating module are connected; the output terminal of the atom pair feature gating module is connected to the third input terminal of the chemical bond prediction module and the first input terminal of the atom coordinate prediction module, respectively; the output terminal of the atom type feature gating module is connected to the fourth input terminal of the chemical bond prediction module, the second input terminal of the atom coordinate prediction module, and the input terminal of the atom type prediction module, respectively; the output terminals of the chemical bond prediction module, the atom coordinate prediction module, and the atom type prediction module are connected to the first, second, and third input terminals of the molecular sequence conversion module, respectively; the output terminal of the molecular sequence conversion module is connected to the model output terminal. The text encoder is implemented based on the Transformer architecture; the text encoder is used to encode the molecular description D to obtain the corresponding text feature vector H. D Sending to the global feature fusion module specifically involves: segmenting the molecular description D according to a preset professional chemical vocabulary to obtain the corresponding current segmentation sequence; embedding the current segmentation sequence into an embedded vector; performing feature encoding on the text embedding vector to obtain the corresponding feature encoding vector; and performing max pooling on each feature channel of the feature encoding vector to obtain the corresponding text feature vector H. D Send to the global feature fusion module; The terminology set of the specialized chemical vocabulary includes symbols, numbers, characters, and words from the natural language domain, as well as symbols, numbers, characters, and words from the specialized chemical knowledge domain and the molecular sequence characterization domain; the feature encoding vector has a shape of L×d. D L represents the total number of word segments corresponding to the molecular description D, and d D The preset text feature dimensions; the feature vector H D The shape is 1×d D ; The molecular conformation conversion module is used to identify the atom type, atomic coordinates, and chemical bonds of the molecular sequence S to obtain the corresponding atom type set A, atom coordinate set P, and chemical bond set E, and then send them to the corresponding chemical bond prediction module and the Uni-Mol model. Specifically, it uses a preset cheminformatics tool to perform molecular conformation conversion on the molecular sequence S to obtain the corresponding current conformation; it uses the cheminformatics tool to identify the atom type and atomic coordinates of each atom in the current conformation atom set and to identify the chemical bonds between the atoms in the current conformation to obtain the corresponding atom type set A, atom coordinate set P, and chemical bond set E; and it sends the chemical bond set E to the chemical bond prediction module and sends the atom type set A and the atom coordinate set P to the Uni-Mol model. The cheminformatics tools include at least the RDKit tool; the total number of atoms in the current conformation is denoted as N. A The atom type set A includes N A Atom type a j 1 ≤ atomic index j ≤ N A The atomic coordinate set P includes N A Atom coordinates p j The atomic coordinates p j The coordinates are three-dimensional; the chemical bond set E includes multiple chemical bonds e, each chemical bond e including a corresponding atom pair index group and a chemical bond type; the atom pair index group consists of the atom indices j and k of the two atoms corresponding to the current chemical bond, where 1 ≤ atom index k ≤ N. A k≠j; The Uni-Mol model has completed large-scale pre-training. The pre-training tasks of the Uni-Mol model include at least masked atom prediction and atom coordinate prediction tasks. The Uni-Mol model is used to perform atomic-level feature encoding and global molecular feature recognition on the current molecule based on the atom type set A and the atom coordinate set P to obtain the corresponding molecular feature vector H. cls Atom pair characteristic matrix H P Atomic eigenvectors H A and the molecular feature vector H cls Send the atom pair feature matrix H to the global feature fusion module. P and the atomic eigenvector H A Send the atomic feature vector H to the atom pair feature gating module. A Sending to the atom type feature gating module specifically involves: generating a corresponding atom sequence based on the atom type set A, and performing embedding encoding on the atom sequence to obtain the corresponding atom embedding vector; and setting the initialized atom pair feature matrix H based on the atom coordinate set P. P ; and combined with the atomic pair feature matrix H P The atomic embedding vector is feature encoded to obtain the corresponding atomic feature vector H. A And during the encoding process, the feature matrix H of the atom pairs is... P Perform iterative updates; and update the final atomic feature vector H. A The molecular feature vector H is obtained by performing average pooling on each feature channel. cls ; and the molecular feature vector H cls Send the atom pair feature matrix H to the global feature fusion module. P and the atomic eigenvector H A Send the atomic feature vector H to the atomic pair feature gating module. A Send to the atom type feature gating module; Wherein, the atomic feature vector H A The shape is N A ×d A d A The atomic feature vector H is defined by a preset atomic type feature dimension. A By N A The vectors have a length of d. A For feature vectors Composition; the atom pair feature matrix H P The shape is N A ×N A ×3; the molecular feature vector H cls The shape is 1×d A The atom pair feature matrix H P By N A ×N A Each feature vector has a length of 3. Composition, 1 ≤ atomic index k ’ ≤N A Each of the feature vectors Used for their corresponding atom pairs (j,k) ’ The three-dimensional coordinate spacing is used for feature characterization; The global feature fusion module is used to perform attention-weighted fusion based on the text feature vector H. D and the molecular feature vector H cls Generate the corresponding global feature vector H G Sending the text feature vector H to the chemical bond prediction module, the atom pair feature gating module, and the atom type feature gating module specifically involves: sending the text feature vector H... D and the molecular feature vector H cls The two projection vectors H are obtained by projecting them onto a predefined global feature space. D-p H cls-p ; and for the two projection vectors H D-p H cls-p The corresponding two attention weights at D-p ,at cls-p Perform calculations; and based on the two attention weights at D-p ,at cls-p For the two projection vectors H D-p H cls-p The corresponding global feature vector H is obtained by performing feature weighting. G Send to the chemical bond prediction module, the atom pair feature gating module, and the atom type feature gating module; Among them, the two projection vectors H D-p H cls-p The calculation method is as follows: , ; W D-p b D-p W represents the text feature projection transformation matrix and bias vector of the model. cls-p b cls-p W represents the molecular feature projection transformation matrix and bias vector of the model; D-p The shape is d G ×d D W cls-p The shape is d G ×d A b D-p b cls-p The shape is 1×d G d G The feature dimension of the global feature space; the projection vector H D-p H cls-p The shape is 1×d G ; The two attention weights at D-p ,at cls-p The calculation method is as follows: ; W at1 W at2 Let b be the first and second attention transformation matrices of the model. at1 b at2 W represents the first and second attention bias vectors of the model. at1 The shape is d at ×2d G b at1 The shape is 1×d at W at2 The shape is 2×d at b at2 The shape is 1×2, d at AT represents the preset attention feature dimensions; concate() is the vector concatenation function, tanh() is the Tanh activation function, and softmax() is the Softmax function; AT represents the attention vector. vector The shape is 1×2d G ; vector The shape is 1×d at ; vector The shape is 1×2; The attention vector AT has a 1×2 shape and is composed of the corresponding attention weights at. D-p ,at cls-p Composition, at D-p +at cls-p =1; The global feature vector H G The calculation method is as follows: ; The global feature vector H G The shape is 1×d G ; The atom pair feature gating module is used to determine the global feature vector H. G The atom pair feature matrix H P and the atomic eigenvector H A Adding a global feature-gated component to each atom pair feature yields a new atom pair feature matrix. Sending to the chemical bond prediction module and the atom coordinate prediction module, specifically: based on the global feature vector H G The atom pair feature matrix H P and the atomic eigenvector H A For each atom pair (j,k) ’ Generate the corresponding gated scalar and candidate feature vectors ; and based on each atom pair (j,k) ’ The corresponding gated scalar The candidate feature vector and the feature vector Calculate the corresponding gated feature vector ; and from the obtained N A ×N A The gated feature vectors The corresponding atom pair feature matrix is ​​formed. Send to the chemical bond prediction module and the atomic coordinate prediction module; Among them, the gated scalar The calculation method is as follows: ; W g1 b g1 Let the first gating transformation matrix and bias vector of the model be denoted as . The atomic feature vector H A The eigenvector of the k-th atom W g1 The shape is 1×(3+2d) A +d G ), b g1 The shape is 1×1; sigmoid() is the sigmoid activation function; vector The shape is 1×(3+2d) A +d G ); The candidate feature vector The calculation method is as follows: ; W g2 b g2 W represents the second gating transformation matrix and bias vector of the model. g2 The shape is 3×(3+2d) A +d G ), b g2 The shape is 1×3; the candidate feature vector The shape and the feature vector Maintain consistency; The gated feature vector The calculation method is as follows: ; The atom pair feature matrix The shape is N A ×N A ×3; The atom type feature gating module is used to determine the global feature vector H. G and the atomic eigenvector H A Adding a global feature-gated component to each atomic feature yields a new atomic feature vector. Sending to the chemical bond prediction module, the atom coordinate prediction module, and the atom type prediction module, specifically: based on the global feature vector H G and the atomic eigenvector H A Generate a corresponding gated scalar g for each atom j and candidate feature vectors ; and based on the gate scalar g corresponding to each atom j The candidate feature vector and the feature vector Calculate the corresponding gated feature vector ; and from the obtained N A The gated feature vectors The corresponding atomic feature vectors are formed Send to the chemical bond prediction module, the atomic coordinate prediction module, and the atom type prediction module; Wherein, the gated scalar g j The calculation method is as follows: ; W g3 b g3 W represents the third gating transformation matrix and bias vector of the model. g3 The shape is 1×d A b g1 The shape is 1×1; The candidate feature vector The calculation method is as follows: ; W g4 b g4 W represents the fourth gating transformation matrix and bias vector of the model. g4 The shape is d A ×(d A +d G ), b g2 The shape is 1×d A ;vector The shape is 1×(d A +d G The candidate feature vector The shape and the feature vector Maintain consistency; The gated feature vector The calculation method is as follows: ; The atomic feature vector The shape is N A ×d A ; The chemical bond prediction module is used to predict chemical bonds based on the chemical bond set E and the global feature vector H. G The atom pair feature matrix and the atomic feature vector Chemical bond prediction yields the corresponding chemical bond set E. * Sending to the molecular sequence conversion module specifically involves: first setting a shape of N A ×N A ×N C The all-zero matrix is ​​used as the initial chemical bond characteristic matrix H. E N C The chemical bond feature matrix H represents the preset total number of chemical bond types. E By N A ×N A The length of each vector is N C eigenvectors Composition; then, based on each chemical bond e in the chemical bond set E and its corresponding feature vector Perform one-hot encoding; then index the two symmetric atom pairs (j,k) by row / column index of each matrix. ’ ), (k ’ (j) form a corresponding symmetric group, and the index k in each symmetric group ’ ≠j; then based on the atomic feature vector The atom pair feature matrix The chemical bond feature matrix H E The two gated feature vectors corresponding to each of the symmetric groups Two gated feature vectors Two eigenvectors and the global feature vector H G Predict the corresponding chemical bond prediction vector c; then set the corresponding chemical bond e based on the chemical bond prediction vector c of each symmetry group. * Then, the chemical bonds of the invalid chemical bond type e are... * Clear, by all remaining said chemical bonds e * The corresponding chemical bond set E * Send to the molecular sequence conversion module; The chemical bond prediction vector c corresponding to the symmetry group is calculated as follows: , , , , ; W c b c W represents the chemical bond transformation matrix and bias vector of the model. c The shape is N C ×(2d A +3+d G +N C ), b c The shape is 1×N C ;vector , The shape is 1×(2d) A +3+d G +N C ); , For the two atomic pairs (j,k) in the symmetry group ’ ), (k ’ The eigenvectors corresponding to each of the following are all of shape 1×N. C ; , For the two atomic pairs (j,k) in the symmetry group ’ ), (k ’ The prediction vectors corresponding to each of the following are all of shape 1×N. C All are composed of N C Each prediction probability consists of a set of prediction probabilities, and each prediction probability corresponds to a type of chemical bond; the prediction vector c is composed of two corresponding prediction vectors. , The mean vector is also determined by N. C Each predicted probability consists of; The chemical bond e corresponding to the symmetry group * The setting method is as follows: the maximum predicted probability in the prediction vector c corresponding to the current symmetry group is taken as the candidate probability; and it is identified whether the candidate probability is less than a preset effective probability threshold; if so, the chemical bond type corresponding to the current symmetry group is set as an invalid chemical bond type; if not, the chemical bond type corresponding to the candidate probability is taken as the chemical bond type corresponding to the current symmetry group; and the atomic indices j and k corresponding to the current symmetry group are used as the chemical bond type. ’ A corresponding atom pair index group is formed; and the corresponding chemical bond e is formed by the chemical bond type corresponding to the current symmetry group and the atom pair index group. * ; The atomic coordinate prediction module is implemented based on the task model of the atomic coordinate prediction task of the Uni-Mol model, specifically an SE(3) equivariant graph neural network model; the atomic coordinate prediction module is used to predict the atomic feature vectors. and the atom pair feature matrix The 3D changes of all atomic coordinates are predicted to obtain the corresponding coordinate change set ΔP; and the atomic coordinate set P is corrected based on the coordinate change set ΔP to obtain a new atomic coordinate set P. * Send to the molecular sequence conversion module; Wherein, the atomic coordinate set P includes N A The atomic coordinates p j The coordinate transformation set △P includes N A The coordinate change Δp j The atomic coordinate set P * Including N A atomic coordinates , ; The atom type prediction module is used to predict the atom type based on the atom feature vector. A new set of atom types, A, is obtained by performing atom type prediction. * Sending to the molecular sequence conversion module specifically involves: processing the atomic feature vectors. Each of the gated feature vectors A linear transformation yields a shape of 1×d AC eigenvectors d AC The total number of preset atom types; and based on the Softmax function according to each of the aforementioned feature vectors. Calculate the corresponding probability vector ; and each of the probability vectors The atom type corresponding to the highest probability in the atom is used as the corresponding atom type. ; The obtained N A The atom types The corresponding atom type set A is formed. * Send to the molecular sequence conversion module; Wherein, the feature vector The probability vector The calculation method is as follows: , ; W ac b ac To predict the transformation matrix and bias vector for the model type, W ac The shape is d AC ×d A b ac The shape is 1×d AC The probability vector The shape is 1×d AC , by d AC Each prediction probability consists of a class of atomic types; The molecular sequence conversion module is used to convert the chemical bond set E according to... * The atomic coordinate set P * and the set of atomic types A * Set the corresponding optimized molecular conformation; and use the cheminformatics tool to perform SELFIES molecular sequence conversion on the optimized molecular conformation to obtain the corresponding optimized molecular sequence; and use the optimized molecular sequence as the corresponding molecular sequence S. * Output.

4. The method for processing molecular generation models according to claim 3, characterized in that, The model input terminal of the molecular generation model is used to receive the molecular generation instruction X, and the model output terminal is used to output the molecular sequence S. * The molecular generation model includes a task scheduling module, a first large language model, and the post-processing model; the input end of the task scheduling module is connected to the input end of the model, and the output end is connected to the output end of the model; the task scheduling module is also connected to the first large language model and the post-processing model respectively. The task scheduling module is used to send the received molecular generation instruction X to the first large language model; receive the formatted molecular sequence text returned by the first large language model; extract the molecular description segment from the molecular generation instruction X as the corresponding molecular description D; extract the model-generated SELFIES molecular sequence from the formatted molecular sequence text according to the molecular sequence output format of the formatting requirement segment of the molecular generation instruction template as the corresponding molecular sequence S; send the molecular description D and the molecular sequence S to the post-processing model; and receive the molecular sequence S returned by the post-processing model. * Output.

5. The method for processing molecular generation models according to claim 2, characterized in that, The process involves large-scale data collection of molecular sequences from publicly available molecular libraries, obtaining molecular descriptions for each collected sequence by querying the libraries, labeling each collected sequence with its inference chain tag, modifying each sequence tag according to preset structural tampering rules to obtain the corresponding sequence to be optimized, constructing a first dataset based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, constructing a second dataset based on all molecular descriptions and their corresponding inference chain tags, and constructing a third dataset based on all molecular descriptions and their corresponding sequence tags. Specifically, this includes: A first sequence set is formed by collecting multiple sequences from the SMILES and SELFIES molecular sequences in the publicly available molecular library; the first sequence set includes multiple first sequences; each first sequence is a SMILES molecular sequence or a SELFIES molecular sequence. Each of the first sequences is taken as the current sequence; a molecular summary or comprehensive description corresponding to the current sequence is obtained by querying the molecular library and used as a set of corresponding first molecular description, second molecular description and third molecular description; the sequence format of the current sequence is identified as SELFIES sequence format. If it is, the current sequence is used as a set of corresponding first tag sequence and second tag sequence. Otherwise, a preset cheminformatics tool is used to convert the current sequence into a SELFIES molecular sequence and the conversion result is used as a set of corresponding first tag sequence and second tag sequence; all the step description texts of the reasoning step description section of the molecular generation instruction template are sequentially traversed once; at the beginning of this round of traversal, the corresponding reasoning context is initialized to empty; during this round of traversal, the step description text of the current traversal is used as the current step description, and a corresponding current question is formed by the current sequence, the current step description and the reasoning context according to the preset question construction rules. The current question is processed through a preset professional chemical question and answer interface, and the answer text obtained in this processing is used as a corresponding single-step reasoning tag. The current question and answer are combined to form a corresponding question-and-answer text pair, which is then added to the reasoning context. At the end of this round of traversal, the N single-step reasoning tags obtained from this round of traversal are... A corresponding first tag inference chain is formed; the current sequence is transformed into a molecular conformation using the cheminformatics tool to obtain the corresponding current conformation, and the current conformation is randomly modified based on the structure tampering rule to obtain the corresponding current tampered conformation. The current tampered conformation is then transformed into a SELFIES molecular sequence using the cheminformatics tool, and the transformation result is used as the corresponding first sequence to be optimized; wherein, the cheminformatics tool includes at least the RDKit tool; the question construction rule is used to set the analysis question with the current sequence and the inference context as the reference context and the current step description as the current analysis target; the professional chemistry question-answering interface is a type of manual question-answering task processing interface for professional chemistry experts, a type of system question-answering task processing interface for professional chemistry question-answering systems, or a type of model question-answering task processing interface for professional chemistry large models; Each of the first sequences to be optimized and its corresponding first molecular description and first tag sequence constitutes a corresponding first data record; and all the obtained first data records constitute the corresponding first dataset; Each second molecule description and its corresponding first label inference chain constitute a corresponding second data record; and all the obtained second data records constitute the corresponding second dataset; Each of the third molecule descriptions and its corresponding second tag sequence constitutes a corresponding third data record; and all the obtained third data records constitute the corresponding third dataset.

6. The method for processing molecular generation models according to claim 2, characterized in that, The step of training the post-processing model based on the first dataset specifically includes: Step 61: The model parameter set of the text encoder, global feature fusion module, atom pair feature gating module, atom type feature gating module, chemical bond prediction module, atom coordinate prediction module, and atom type prediction module of the post-processing model is taken as the current model parameter set; and the first dataset is divided into multiple first data batches based on a preset batch size B1; and the first first data batch is taken as the current data batch. Each of the first data batches includes B1 first data records; the first tag sequence of each first data record in each of the first data batches is denoted as the corresponding tag sequence. , 1 ≤ index q ≤ B1; Step 62: Take each of the first data records in the current data batch as the current record; and input the first molecular description and the first sequence to be optimized of the current record as the corresponding molecular description D and molecular sequence S into the post-processing model for processing, and input the chemical bond set E generated by the model during this processing into the post-processing model. * Atomic coordinate set P * and atomic type set A * As the corresponding chemical bond set Atomic coordinate set and atomic type set ; and use preset cheminformatics tools to analyze the currently recorded tag sequence. Perform molecular conformational transformation and use the cheminformatics tools to analyze the chemical bond set corresponding to the current conformation. Atomic coordinate set and atomic type set Identification is performed; and the chemical bond set corresponding to the current record is used to... Atomic coordinate sets Atom type set pairs Form a corresponding first prediction-label group; The cheminformatics tools include at least the RDKit tool; Step 63: Substitute the B1 first prediction-label groups of the current data batch into the preset first model loss function L. M1 The corresponding first loss value is obtained through calculation; Wherein, the first model loss function L M1 for: ; Atom type loss function L A Based on the cross-entropy loss function, the atomic coordinate loss function L... P Based on L1 or L2 loss functions, chemical bond loss function L E Implemented based on the cross-entropy loss function; Step 64: Identify whether the first loss value meets the preset first loss value range; if not, then based on the preset first model optimizer, move towards making the first model loss function L... M1 The direction that reaches the minimum value is used to perform a round of parameter modulation on the current model parameter set, and the process returns to step 62 when the parameter adjustment is completed. If the condition is met, it is identified whether the current data batch is the last first data batch. If not, the next first data batch is taken as the new current data batch and the process returns to step 62. If the condition is met, training is stopped and the post-processing model training is confirmed to be completed. The first model optimizer includes the Adam optimizer and the SGD optimizer.

7. The method for processing molecular generation models according to claim 2, characterized in that, The inference training of the first large language model based on the molecular generation instruction template and the second dataset specifically includes: Step 71: Divide the second dataset into multiple second data batches based on the preset batch size B2; and take the first second data batch as the current data batch; Each second data batch includes B2 second data records; the first tag inference chain of each second data record in each second data batch is denoted as the corresponding tag chain. , 1 ≤ index g ≤ B2; each of the stated tag chains Each of the aforementioned single-step reasoning tags Record as the corresponding single-step label Each of the aforementioned single-step labels The total number of word segments is denoted as n. g,i Each of the aforementioned single-step labels Each word segment is recorded as the corresponding 1 ≤ index u ≤ n g,i ; Step 72: Substitute the second molecular description of each second data record in the current data batch into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. g ; and the molecular generation instruction X g The first large language model is input for processing; the autoregressive text generation process of the first large language model is recorded during this processing; and after completing B2 model processing iterations, the second model loss function L is used as the basis for the processing. M2 Calculate the corresponding second loss value; Wherein, the second model loss function L M2 It is implemented based on the cross-entropy loss function, specifically as follows: ; The reasoning label sequence is formed by concatenating the reasoning labels from the previous i-1 steps. For the single-step label The word segmentation sequence preceding the u-th word; For the model in the autoregressive generation step of the inference text at step i, the corresponding molecular generation instruction X is used. g Inference label sequence and word segmentation sequence The u-th word generated for the context is the corresponding word. The probability of; Step 73: Identify whether the second loss value meets the preset second loss value range; if not, then based on the preset second model optimizer, move towards making the second model loss function L... M2 The model parameters of the first large language model are fine-tuned in the direction of reaching the minimum value, and the process returns to step 72 after the fine-tuning is completed. If the condition is met, it is identified whether the current data batch is the last second data batch. If not, the next second data batch is taken as the new current data batch and the process returns to step 72. If the condition is met, training is stopped and the inference training of the first large language model is confirmed to be completed. The second model optimizer includes the Adam optimizer, the SGD optimizer, and the AdamW optimizer.

8. The method for processing molecular generation models according to claim 2, characterized in that, The population-based relative strategy optimization mechanism enhances the training of the first large language model based on the molecular generation instruction template and the third dataset, specifically including: Step 8-1: Copy the first large language model to obtain two copied models, and denote the current first large language model as the corresponding new policy model M. new The two replication models are denoted as the corresponding old policy models M. old Reference Model M ref and the reference model M ref The model parameters are solidified; and the new strategy model M is then... new The old strategy model M old The reference model M ref The model parameters are denoted as the corresponding model parameters θ. new Model parameters θ old Model parameters θ ref The third dataset is divided into multiple third data batches based on a preset batch size B3, and the first third data batch is taken as the current data batch. Each data batch includes B3 third data records; the second tag sequence of each third data record in each data batch is denoted as the corresponding tag sequence. , 1 ≤ index o ≤ B3; Step 8-2: Take each of the third data records in the current data batch as the current record; and substitute the third molecular description of the current record into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. o And continuously send the molecule generation command X M times. o Input the old strategy model M old The process yields M corresponding predicted texts. ; and according to the formatting requirements of the molecular generation instruction template, the molecular sequence output format is obtained from each of the predicted texts. Extract the corresponding SELFIES molecular sequences as the corresponding predicted sequences. ; Wherein, the number of repetitions M is a preset positive integer, 1 ≤ index m ≤ M; each of the predicted texts The total number of word segments is recorded as the corresponding Each of the predicted texts Each word segment is recorded as the corresponding 1≤index t≤ Each word segmentation The corresponding predicted probability is denoted as ; Step 8-3, for each of the predicted texts The system identifies whether the text format meets the molecular sequence output format of the molecular generation instruction template; if it does, the corresponding format check result FM is set. o,m Set the value to 1; if not satisfied, set the corresponding format check result FM. o,m =0; Step 8-4: Use preset cheminformatics tools to analyze each of the stated tag sequences. The predicted sequence The corresponding tag fingerprints are obtained by calculating the three types of molecular fingerprints. , , fingerprint prediction , , ; and using the cheminformatics tools to analyze each of the tag sequences. The predicted sequence The molecular side chains and functional groups are identified to obtain the corresponding tag side chain fragment set. , collection of tagged functional groups Predicted sidechain fragment set Predictive functional group set ; The three types of molecular fingerprints include Morgan fingerprints, MACCS fingerprints, and RDKit fingerprints; The cheminformatics tools include at least the RDKit tool; The set of tag sidechain fragments When not empty, it consists of one or more tag sidechain fragments. composition; The set of label functional groups When not empty, it consists of one or more label functional groups. Composition, each of the stated tag functional groups It consists of its corresponding functional group type and functional group fragment; The predicted sidechain fragment set When not empty, it consists of one or more predictive sidechain fragments. composition; The predictive functional group set When not empty, it is determined by one or more predictive functional groups. Composition, each of the predicted functional groups It consists of its corresponding functional group type and functional group fragment; Step 8-5, for each of the predicted sequences The corresponding tag sequence Sequence similarity Fingerprint similarity Fragment similarity Functional group similarity The calculation is performed, and the average of the four similarities is used as the corresponding structural reward. ; and check the FM result according to the stated format. o,m and the structural reward Calculate the corresponding generated reward R o,m ; Wherein, the sequence similarity Achieved through the BLEU evaluation algorithm: ; fingerprint similarity This is achieved by averaging the similarity of three types of fingerprints: , f s () represents a preset fingerprint similarity function, f. s Including the Jaccard similarity function and the cosine similarity function; The similarity of the segments The calculation method is as follows: ; For the set of predicted sidechain fragments With the set of tag sidechain fragments The total number of overlapping segments; For the set of predicted sidechain fragments With the set of tag sidechain fragments The total number of segments in the collection; For the set of tag sidechain fragments The total number of fragments; when confirming overlapping fragments, the similarity of the fragment molecular fingerprint is calculated to determine if the predicted sidechain fragment set... One of the predicted sidechain fragments and the set of the tag sidechain fragments If the molecular fingerprint similarity of a tag sidechain fragment exceeds a preset fingerprint similarity threshold, the two are considered as overlapping fragments; when counting the total number of fragments in the set, overlapping fragments are only counted once; The functional group similarity The calculation method is as follows: ; N GC The total number of functional group types is preset, where 1 ≤ index gc ≤ N. GC ; The set of predictable functional groups The statistical number of GC-class functional groups in the middle; The set of tag functional groups The statistical number of GC-class functional groups in the middle; A preset small constant that is greater than zero; The structural reward The calculation method is as follows: ; The generated reward R o,m The calculation method is as follows: ; Step 8-6: The various tag sequences of the current data batch... The corresponding M predicted sequences Cluster them into groups; and calculate the average reward µ for each group. o and standard deviation σ o Perform calculations; and based on each of the predicted sequences in each group. The corresponding generated reward R o,m The average value µ o and the standard deviation σ o Calculate the corresponding within-group advantage V o,m ; Wherein, the average value µ o The standard deviation σ o and the aforementioned intra-group advantage V o,m The calculation method is as follows: , ; ; λ1 is a preset small constant used to prevent the denominator from being zero, and its value is greater than zero; Step 8-7: Substitute the third molecular description of each of the third data records in the current data batch into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. o And continuously send the molecule generation command X M times. o Input the reference model M ref Processing is performed; and during the m-th task processing corresponding to the o-th third data record, the probability vector of the word list corresponding to the t-th segment generated in this step is compared with the corresponding predicted text. The t-th segmentation The corresponding word segmentation probabilities are extracted and used as the corresponding prediction probabilities. ; Step 8-8: Substitute the third molecular description of each of the third data records in the current data batch into the molecular generation instruction template to set the molecular description text of the molecular description segment in the template to obtain the corresponding molecular generation instruction X. o And continuously send the molecule generation command X M times. o Input the new strategy model M new Processing is performed; and during the m-th task processing corresponding to the o-th third data record, the probability vector of the word list corresponding to the t-th segment generated in this step is compared with the corresponding predicted text. The t-th segmentation The corresponding word segmentation probabilities are extracted and used as the corresponding prediction probabilities. ; Steps 8-9: For each of the predicted texts Each of the aforementioned word segments Importance of sampling ratio r o,m,t And truncation sampling ratio Perform calculations; Wherein, the importance sampling ratio r o,m,t and the truncation sampling ratio The calculation method is as follows: , ; λ2 is the preset truncation threshold, and Clip() is the Clip truncation function; Steps 8-10: Based on the preset third model loss function L M3 The corresponding third loss value is obtained through calculation; Wherein, the third model loss function L M3 The objective function J based on the group relative strategy optimization algorithm GRPO To achieve this, the objective function J of the group relative strategy optimization algorithm is... GRPO Then, by the strategy function term J policy , divergence function term J KL The composition is as follows: , , ; β is the preset divergence coefficient; Steps 8-11 involve identifying whether the third loss value meets a preset range; if the third loss value does not meet the preset range, the third model optimizer is then used to optimize the third model loss function L. M3 The direction for reaching the minimum value corresponds to the new strategy model M. new The model parameters θ new Perform one round of modulation, and return to step 8-2 at the end of this round of modulation; if the third loss value meets the range of the third loss value, then based on the model parameter θ new For the old strategy model M old The model parameters θ old Perform a reset and identify whether the current data batch is the last third data batch. If not, use the next third data batch as the new current data batch and return to step 8-2. If yes, stop training and confirm that the reinforcement training of the first large language model is complete, and set the new policy model M. new As the latest and largest language model; The third model optimizer includes the Adam optimizer and the AdamW optimizer.

9. An apparatus for performing a processing method for a molecular generation model according to any one of claims 1-8, characterized in that, The device includes: an instruction template configuration module, a model selection and construction module, a dataset construction module, a post-processing model training module, a large language model training module, a generative model construction module, and a generative model application module; The instruction template configuration module is used to configure the molecule generation instruction template; The model selection and construction module is used to select a general-purpose language model that has completed pre-training for both large language models and general NLP tasks as the corresponding first large language model; and to configure a post-processing model for optimizing the molecular structure of the molecular sequences generated by the first large language model in conjunction with molecular descriptions; the first large language model includes at least the Qwen series models, GPT series models, and DeepSeek series models; the general-purpose NLP tasks include at least text generation tasks, translation tasks, question answering tasks, and thought chain derivation tasks; the post-processing model is used to optimize the molecular structure based on the molecular description D and molecular sequence S input to the model and output the optimized molecular sequence S. * ; The dataset construction module is used to collect molecular sequences from public molecular libraries, obtain molecular descriptions of each collected sequence by querying the molecular library, label the molecular sequence and inference chain tags of each collected sequence, modify each sequence tag according to preset structural tampering rules to obtain the corresponding sequence to be optimized, construct a first dataset based on all sequences to be optimized and their corresponding molecular descriptions and sequence tags, construct a second dataset based on all molecular descriptions and their corresponding inference chain tags, and construct a third dataset based on all molecular descriptions and their corresponding sequence tags. The post-processing model training module trains the post-processing model based on the first dataset; The large language model training module performs inference training on the first large language model based on the molecular generation instruction template and the second dataset; after the inference training is completed, the first large language model is further enhanced by the group relative strategy optimization mechanism based on the molecular generation instruction template and the third dataset. The generative model building module is used to construct a corresponding molecular generation model based on the first large language model and the post-processing model after both types of models have been trained. The molecular generation model is used to process molecular generation tasks according to the molecular generation instructions X input by the model and output the corresponding molecular sequence S. * The molecule generation instruction X is an instruction text generated based on the molecule generation instruction template, and its text structure is consistent with the molecule generation instruction template. The generative model application module is used to substitute the molecular description input by the user into the molecular generation instruction template, set the molecular description text of the template's molecular description segment to obtain the corresponding molecular generation instruction X, and input the molecular generation instruction X into the molecular generation model for processing to obtain the corresponding molecular sequence S. * Provide feedback to the current user.

10. An electronic device, characterized in that, include: Memory, processor, and transceiver; The processor is configured to be coupled to the memory, read and execute instructions in the memory to implement the method according to any one of claims 1-8; The transceiver is coupled to the processor, and the processor controls the transceiver to send and receive messages.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions that, when executed by a computer, cause the computer to perform the method described in any one of claims 1-8.