Training method and prediction method of chemical reaction prediction model, device and medium

By optimizing the large language model through multi-stage training and multi-dimensional reward functions, the problems of insufficient accuracy and interpretability in chemical reaction prediction are solved, and high-quality reasoning analysis of the chemical reaction prediction model is achieved.

CN122290768APending Publication Date: 2026-06-26INST OF AUTOMATION CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INST OF AUTOMATION CHINESE ACAD OF SCI
Filing Date
2026-04-10
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Large language models suffer from insufficient accuracy and limited interpretability in chemical reaction prediction tasks due to inadequate pre-training knowledge and understanding of reaction principles in the chemical field.

Method used

The chemical reaction prediction model is optimized by using a multi-stage training method, including initial sample generation, supervised fine-tuning and reinforcement learning of the first large language model, selection of the first target sample, merging of the second target sample, supervised fine-tuning of the second large language model and reinforcement learning of the model to be strengthened, combined with a multi-dimensional reward function and dynamic weight adjustment.

Benefits of technology

It improves the prediction accuracy and interpretability of the reasoning process of the chemical reaction prediction model, ensuring that the model can generate logically sound and accurate reasoning analysis in chemical reaction prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122290768A_ABST
    Figure CN122290768A_ABST
Patent Text Reader

Abstract

This invention relates to the field of artificial intelligence technology, and provides a training method, prediction method, device, and medium for a chemical reaction prediction model. The method includes generating initial samples containing the chemical reaction reasoning process based on initial chemical reaction data; performing supervised fine-tuning and reinforcement learning on a first large language model based on the initial samples to select first target samples whose prediction results meet preset conditions; constructing second target samples based on the first target samples and the initial samples, and performing supervised fine-tuning on a second large language model based on the second target samples to obtain a model to be reinforced; and training the model to be reinforced using reinforcement learning based on a reward function to obtain a chemical reaction prediction model. The reward function includes at least a perfect match index and a reaction rationality index. The weight ratio between the indices is adjusted based on a preset training progress threshold, and the weights are updated based on the proportion of reaction rationality in the training batch. This improves the prediction accuracy and interpretability of the reasoning process of the chemical reaction prediction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a training method, prediction method, device and medium for a chemical reaction prediction model. Background Technology

[0002] Large language models possess rich pre-trained text knowledge, good instruction compliance, and excellent learning generalization ability, making them suitable for solving problems in scientific research fields. By fine-tuning the model on a text-based chemical reaction prediction dataset, the model can predict products based on given reaction inputs, or predict reaction inputs based on given target products.

[0003] Large language models can be used for text-based chemical reaction prediction tasks, but due to insufficient pre-training knowledge of the chemical field and insufficient understanding of reaction principles, their accuracy is inadequate and their interpretability is limited. Summary of the Invention

[0004] This invention provides a training method, prediction method, device, and medium for a chemical reaction prediction model, which addresses the technical problem that current large language models used for chemical reaction prediction tasks suffer from insufficient accuracy and limited interpretability due to inadequate pre-training knowledge of the chemical field and insufficient understanding of reaction principles.

[0005] This invention provides a training method for a chemical reaction prediction model, comprising the following steps: Acquire initial chemical reaction data containing chemical reaction conditions, and based on the initial chemical reaction data, generate initial samples containing chemical reaction reasoning processes for the current training task; Based on the initial samples, the first language model is subjected to supervised fine-tuning and reinforcement learning, and the first target samples whose prediction results meet the preset conditions are selected during the reinforcement learning process. Based on the first target sample and the initial sample, a second target sample is constructed, and the second language model is supervised and fine-tuned based on the second target sample to obtain the model to be strengthened; Construct a reward function that matches the current training task, and perform reinforcement learning training on the model to be reinforced based on the reward function to obtain a chemical reaction prediction model under the current training task. The reward function includes multi-dimensional evaluation metrics, which include at least a perfect match metric and a response rationality metric. During the iterative process of reinforcement learning training, the weight ratio between the perfect match metric and the response rationality metric is adjusted according to a preset training progress threshold. The weight of the response rationality metric is updated based on the proportion of samples that meet the response rationality metric in each training batch, and the weight is constrained by the upper limit threshold corresponding to the weight of the perfect match metric.

[0006] According to a training method for a chemical reaction prediction model provided by the present invention, the step of generating initial samples containing chemical reaction reasoning processes under the current training task based on the initial chemical reaction data includes: Based on the task type of the current training task, call the preset inference template that matches the current training task; Based on the preset reasoning template and the initial chemical reaction data, an initial sample containing the chemical reaction reasoning process is generated for the current training task; Wherein, if the task type is forward reaction prediction, the preset inference template includes a prompt for analyzing the structural characteristics of the reaction input, a prompt for retrieving the reaction type and similar cases, a prompt for predicting the reaction mechanism and potential reaction sites, and a prompt for predicting the reaction path and possible products; if the task type is retrosynthesis prediction, the preset inference template includes a prompt for analyzing the structural characteristics of the target product, a prompt for retrieving the reaction type and similar cases, a prompt for predicting the reaction mechanism and potential bond breaking sites, and a prompt for predicting the reaction path and required reaction input.

[0007] According to a training method for a chemical reaction prediction model provided by the present invention, the step of constructing a second target sample based on the first target sample and the initial sample includes: Extract the target molecule characterization corresponding to the data to be processed, and determine the corresponding target reaction category based on the target molecule characterization; wherein, the data to be processed includes the first target sample or the initial sample; Identify chemical reaction case data from a pre-built similar case knowledge base that match the target reaction category and have the closest molecular characterization distance; The chemical reaction case data is spliced ​​with the data to be processed to construct a second target sample.

[0008] According to the training method of a chemical reaction prediction model provided by the present invention, the reward function is constructed in the following manner: Based on the task type of the current training task, the matching cross-validation model is invoked to determine the reasonableness of the current prediction data and obtain a response reasonableness index; wherein, when the task type is positive response prediction, the cross-validation model is an inverse synthesis prediction validation model; when the task type is inverse synthesis prediction, the cross-validation model is a positive response prediction validation model. By comparing the current predicted data with the corresponding standard answer data, a perfect match index is obtained; The reward function is constructed based on the response rationality index and the perfect match index.

[0009] According to the training method of a chemical reaction prediction model provided by the present invention, the multi-dimensional evaluation index further includes an inference length index and a chemical validity index. The step of constructing the reward function based on the reaction validity index and the perfect match index includes: The inference length index is obtained based on the inference process generation length corresponding to the current prediction data; The molecular expression corresponding to the current predicted data is chemically validated to obtain the chemical legality index. The reward function is constructed based on the inference length index, the chemical legitimacy index, the reaction rationality index, and the perfect match index.

[0010] According to a training method for a chemical reaction prediction model provided by the present invention, updating the weight of the reaction rationality index based on the proportion of samples satisfying the reaction rationality index in each training batch includes: Determine the percentage of samples in the current training batch that meet the aforementioned reaction rationality index; Based on the inverse mapping relationship and the sample proportion of the current training batch, the weight of the response rationality index of the current training batch is updated; wherein, when the sample proportion is 100%, the weight is updated to zero; when the sample proportion is zero, the weight is updated to the weight corresponding to the perfect match index.

[0011] According to a training method for a chemical reaction prediction model provided by the present invention, adjusting the weight ratio between the perfect match index and the reaction rationality index based on a preset training progress threshold includes: When the number of iterations in reinforcement learning training is not less than a preset training progress threshold, the second weight of the response rationality index is reduced, and the first weight of the perfect match index is increased.

[0012] This invention also provides a method for predicting chemical reactions, comprising: Acquire the chemical reaction data to be predicted and determine the prediction task type corresponding to the chemical reaction data to be predicted; Based on the prediction task type, the target molecule characterization corresponding to the chemical reaction data to be predicted is extracted, and the target case knowledge is retrieved from the pre-constructed similar case knowledge base based on the target molecule characterization. A preset reasoning template matching the prediction task type is invoked to concatenate the chemical reaction data to be predicted with the target case knowledge to obtain the target prediction input data; The target prediction input data is input into a pre-trained chemical reaction prediction model to obtain the chemical reaction reasoning process and final prediction result output by the chemical reaction prediction model. The chemical reaction prediction model is trained based on the training method of the chemical reaction model described above.

[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor executes the program to implement the training method or the prediction method of the chemical reaction prediction model as described above.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the training method or the prediction method of the chemical reaction prediction model as described above.

[0015] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the training method or the prediction method of any of the above-described chemical reaction prediction models.

[0016] The chemical reaction prediction model training method, prediction method, device, and medium provided by this invention employ a multi-stage training process: initial sample generation, supervised fine-tuning and reinforcement learning of the first large language model, screening of the first target sample, merging and constructing the second target sample, supervised fine-tuning of the second large language model, and reinforcement learning training of the model to be strengthened. On the one hand, by merging the initial sample and the first target sample to construct the second target sample, the scale of training data is expanded while introducing high-quality samples verified by reward signals, enabling the second large language model to obtain high-quality training data support during the supervised fine-tuning stage. On the other hand, a multi-dimensional reward function containing a perfect match index and a reaction rationality index is constructed. Combined with a multi-stage weight adjustment based on a preset training progress threshold and a dynamic weight update mechanism based on the batch pass ratio, the model can accumulate perfect match rewards while also obtaining positive feedback from chemically reasonable prediction results. This guides the model to focus on accurately predicting the standard answer, thereby improving the prediction accuracy and interpretability of the reasoning process of the chemical reaction prediction model. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating the training method for the chemical reaction prediction model provided in this embodiment of the invention.

[0019] Figure 2 This is a schematic diagram of the structure of the training device for the chemical reaction prediction model provided in this embodiment of the invention.

[0020] Figure 3 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

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

[0022] It should be noted that in the description of this invention, the terms "comprising," "including," or any other variations thereof are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element. The terms "upper," "lower," etc., indicating orientation or positional relationships based on the orientation or positional relationships shown in the accompanying drawings, are only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the system or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0023] The terms "first," "second," etc., used in this invention are used to distinguish similar objects, not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0024] It should be noted that the execution subject in each embodiment of the present invention can be an electronic device with data processing capabilities, such as a server, personal computer, workstation, or distributed computing cluster. Considering that the training process of chemical reaction prediction models usually requires large-scale computing power, the execution subject is preferably a computing device with accelerated computing units such as graphics processing units or tensor processors, or a distributed computing system composed of multiple computing nodes. The following embodiments are all described using the processor in the above-mentioned electronic device as the execution subject, but the present invention does not limit the specific execution subject. Any device with corresponding data processing and model training capabilities can be used as the execution subject in each embodiment of the present invention.

[0025] Large language models, with their rich pre-trained text knowledge, strong instruction-following ability, and excellent learning generalization capabilities, have shown application potential in the field of text-based chemical synthesis prediction. By fine-tuning large language models based on chemical reaction data, they can predict products from given reaction inputs or predict desired reaction inputs from given target products. However, existing methods suffer from insufficient understanding of chemical reaction principles, and a severe lack of high-quality domain-specific inference training data, resulting in significant shortcomings in both prediction accuracy and inference interpretability.

[0026] This invention provides a training method for a chemical reaction prediction model, which effectively solves the above problems by organically combining a multi-stage inference data construction strategy with a multi-dimensional dynamic reward mechanism.

[0027] The technical solution of the present invention will be described in detail below with reference to specific embodiments. The specific embodiments below can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0028] This invention provides a training method for a chemical reaction prediction model. Figure 1 This is a flowchart illustrating the training method for the chemical reaction prediction model provided by the present invention, as shown below. Figure 1 As shown, the method includes the following steps 110, 120, 130 and 140.

[0029] Step 110: Obtain initial chemical reaction data containing chemical reaction conditions, and based on the initial chemical reaction data, generate initial samples containing chemical reaction reasoning processes for the current training task.

[0030] Chemical reaction prediction tasks typically fall into two main categories: forward reaction prediction and retrosynthetic prediction. Forward reaction prediction involves predicting the corresponding reaction products given a reaction input; retrosynthetic prediction involves inferring the precursors and reaction conditions required to synthesize a target product.

[0031] The current training task can be either of the two types of tasks mentioned above, and the training method in this embodiment is applicable to both types of tasks. The chemical reaction reasoning process under the current training task in this embodiment refers to the complete thought process of the model to analyze and infer chemical reactions step by step under the background of the current task. This process includes several reasoning steps such as analyzing molecular structure, judging reaction type, deducing reaction mechanism, and inferring final result.

[0032] Initial chemical reaction data is structured data containing complete information about a chemical reaction. The chemical reaction conditions it includes must cover at least one or more of the reaction input information and corresponding reaction result information. The reaction input information may include, but is not limited to, molecular formulas of reactants, catalyst information, solvent information, and reaction temperature and other conditional parameters; the reaction result information may include, but is not limited to, the molecular formulas of the corresponding reaction products. Initial chemical reaction data can be derived from publicly available chemical reaction databases to ensure the authenticity and chemical validity of the data, providing a reliable knowledge base for the generation of subsequent initial samples. For example, initial chemical reaction data can be derived from publicly available chemical reaction datasets such as Open Reaction Database.

[0033] In this embodiment, based on the initial chemical reaction data, a large language model with strong text understanding and generation capabilities is invoked to generate structured chemical reaction reasoning process text and final prediction results, which are used as initial samples.

[0034] When generating initial samples, the large language model being invoked can be provided with input containing complete chemical reaction information. The large language model is explicitly required to generate a step-by-step reasoning process, assuming the final answer is unknown, to ensure that the generated reasoning has substantial logical deductive value, rather than being a simple restatement of a known answer. For example, the large language model used to generate initial samples can be a large language model with strong reasoning generation capabilities.

[0035] The generated initial samples typically consist of two parts: the inference process text and the final prediction result. Their format should meet the input requirements of the subsequent supervised fine-tuning stage. For example, the molecular expression of the final prediction can be specified to be enclosed between specific markers, facilitating automated extraction and comparison of the final prediction result during training and evaluation.

[0036] Step 120: Based on the initial samples, supervised fine-tuning and reinforcement learning are performed on the first large language model, and the first target samples whose prediction results meet the preset conditions are selected during the reinforcement learning process.

[0037] The first large language model is a pre-trained large language model with a certain number of parameters. The selection of its parameter size needs to be balanced between training efficiency and model capability. For example, the first large language model can be a pre-trained large language model with 14 bytes of parameters.

[0038] Here, the initial samples are used as labeled supervised training data. The parameters of the first language model are updated in a supervised manner, enabling it to learn to generate progressive reasoning analysis content and the final prediction result according to a predetermined format for chemical reaction problems. Supervised fine-tuning can employ a full-parameter fine-tuning mode, where all parameters of the first language model participate in gradient calculation and weight updates. During training, the cross-entropy loss function is typically used to measure the difference between the model-generated content and the target sample text, and the model parameters are iteratively optimized using a corresponding optimizer. For example, when supervising fine-tuning the first language model, a full-parameter fine-tuning mode can be used, with a learning rate set to 1e-5 and three training epochs.

[0039] After supervised fine-tuning, the first language model was further trained using reinforcement learning. During the reinforcement learning phase, reward signals guided the first language model to autonomously explore and optimize its reasoning strategies within the chemical reaction reasoning space, thereby generating higher-quality chemical reaction prediction results.

[0040] In the reinforcement learning phase, efficient parameter fine-tuning can be employed to reduce memory overhead during the training of models with a large number of parameters; the policy optimization algorithm can employ algorithms based on group relative policy optimization, etc. For example, reinforcement learning can adopt the LoRA model, with a learning rate set to 1e-5 and a training epoch of 1.

[0041] The preset conditions are the criteria for screening candidate inference samples generated by the first language model in the reinforcement learning stage. The purpose is to retain samples with high inference quality from the large number of candidate samples generated in the reinforcement learning process, so as to use them for the construction of higher quality training data in the future.

[0042] In this embodiment, the preset conditions include at least the requirement of correctness of the final prediction result. That is, the final prediction result corresponding to the reasoning process text generated by the first language model for a certain chemical reaction problem during reinforcement learning meets the correctness judgment criteria compared with the standard answer to the reaction problem. For example, the predicted product molecule expression or reaction input molecule expression is consistent with the corresponding standard answer. Reasoning samples that meet the preset conditions are selected as the first target samples.

[0043] Since the first target sample is generated under the condition of reinforcement learning reward signal screening, the rationality of its reasoning logic and the correctness of the final prediction have been verified, thus it has higher reasoning quality than the initial sample.

[0044] Step 130: Based on the first target sample and the initial sample, construct a second target sample, and perform supervised fine-tuning of the second large language model based on the second target sample to obtain the model to be strengthened.

[0045] The first target sample is merged with the initial sample to obtain the second target sample for training the second large language model. This merging considers both the quantity and quality of the training data. The initial sample is generated by a large language model with strong generative capabilities based on a large amount of raw data, resulting in a wide range of samples and a sufficient quantity, but the inference quality of some samples is inconsistent. The first target sample comes from correct inference processes verified by reward signals during the reinforcement learning phase, resulting in relatively higher inference quality, but its quantity is relatively limited due to selection constraints. By merging the two to construct the second target sample, the overall inference quality of the training dataset is effectively improved while ensuring the quantity of training data meets the needs of subsequent training. This lays a higher-quality data foundation for supervised fine-tuning of the second large language model.

[0046] In one example, the second largest language model is a pre-trained large language model with more parameters than the first largest language model. This embodiment uses a model with a larger number of parameters as the base model for final training, which helps to achieve stronger language understanding and knowledge generalization capabilities in the chemical reaction prediction task, thereby further improving the upper limit of prediction performance. For example, the second largest language model can be a pre-trained large language model with 32 bytes of parameters.

[0047] The second language model is fine-tuned under supervision based on the second target sample. The training method can adopt the full parameter fine-tuning mode. The difference between the model output text and the target sample text is measured by the cross-entropy loss function, and the model parameters are iteratively optimized by the optimizer.

[0048] For example, when performing supervised fine-tuning on the second language model, a full-parameter fine-tuning mode can be used, with the learning rate set to 1e-5 and the number of training epochs set to 1. After the above supervised fine-tuning, the second language model has initially acquired the ability to perform stepwise reasoning analysis and prediction for chemical reactions, and this model is now the model to be strengthened.

[0049] Step 140: Construct a reward function that matches the current training task, and perform reinforcement learning training on the model to be reinforced based on the reward function to obtain a chemical reaction prediction model under the current training task.

[0050] Here, the reward function is used to evaluate the quality of the inference samples generated by the model to be reinforced from multiple perspectives during reinforcement learning training, providing guidance for the optimization of model parameters. The reward function matched to the current training task refers to constructing an evaluation index and corresponding reward calculation method that are suitable for the characteristics of the current training task.

[0051] In this embodiment, the reward function includes multi-dimensional evaluation metrics, which at least include a perfect match metric and a reaction rationality metric. Compared to a reward function that uses only a single evaluation dimension, multi-dimensional evaluation metrics can provide the model with richer and more granular training signals, effectively alleviating the problem of sparse reward signals in chemical reaction prediction tasks.

[0052] The perfect match metric measures the exact consistency between the final prediction of the model to be strengthened for the current chemical reaction problem and the standard answer. Specifically, the final prediction output of the model to be strengthened is compared with the corresponding standard answer: when they are completely consistent, the perfect match metric corresponds to a higher reward value; when they are inconsistent, the perfect match metric corresponds to a lower reward value or zero reward value.

[0053] The reaction rationality index is used to evaluate the reasonableness of the prediction results of the model to be strengthened from a chemical validity perspective. Chemical reactions often have a certain degree of pleiotropy, meaning that the same reaction input may produce multiple chemically reasonable products under different conditions, and the same target product may also be obtained through multiple reasonable synthetic routes. This embodiment introduces the reaction rationality index, which can provide appropriate positive rewards for prediction results that are chemically reasonable but do not completely match the standard answer, thereby effectively enriching the density of the training signal and guiding the model to fully explore the reasonable chemical reaction space.

[0054] During the iterative process of reinforcement learning training, the weight ratio between the perfect match metric and the response rationality metric is adjusted according to a preset training progress threshold to achieve phased optimization of the training objective. The preset training progress threshold can be the iteration step threshold for reinforcement learning training, dividing the training process into two stages: a pre-threshold stage and a post-threshold stage. In the pre-threshold stage, the model to be reinforced is still in the initial stage of establishing chemical reaction reasoning ability, and the reward signal corresponding to the perfect match metric is relatively sparse. At this time, both the perfect match metric and the response rationality metric are assigned certain weights, allowing the model to accumulate perfect match rewards while also receiving positive feedback from chemically reasonable prediction results. In the post-threshold stage, the model to be reinforced has acquired basic chemical reaction reasoning ability. At this time, the weight corresponding to the perfect match metric is increased, and the weight corresponding to the response rationality metric is correspondingly decreased, guiding the model to focus on accurate prediction of the standard answer, thereby further improving prediction accuracy.

[0055] It should be noted that the weight corresponding to the response rationality index is constrained by the upper limit of the weight corresponding to the perfect match index. Specifically, within the reward function framework jointly constituted by the perfect match index and the response rationality index, the perfect match objective always plays a dominant role. At any given time, the dynamic weight of the response rationality index must not exceed the weight value corresponding to the perfect match index, thereby preventing the model to be reinforced from excessively pursuing chemical rationality during training and neglecting the ability to accurately predict the standard answer.

[0056] The model to be reinforced is trained using the aforementioned reward function, and its parameters are iteratively optimized to obtain a chemical reaction prediction model for the current training task. When given an input of a chemical reaction problem, the resulting chemical reaction prediction model can generate a structured output containing a step-by-step reasoning analysis process and the final prediction result. It possesses good prediction accuracy while its reasoning process is also highly interpretable.

[0057] The training method for the chemical reaction prediction model in this invention employs a multi-stage training process: initial sample generation, supervised fine-tuning and reinforcement learning of the first large language model, screening of the first target sample, merging and constructing the second target sample, supervised fine-tuning of the second large language model, and reinforcement learning training of the model to be reinforced. On one hand, by merging the initial sample and the first target sample to construct the second target sample, the scale of training data is expanded while introducing high-quality samples verified by reward signals, enabling the second large language model to obtain high-quality training data support during the supervised fine-tuning stage. On the other hand, a multi-dimensional reward function containing a perfect match index and a reaction rationality index is constructed. Combined with a multi-stage weight adjustment based on a preset training progress threshold and a dynamic weight update mechanism based on the batch pass ratio, the model can accumulate perfect match rewards while also obtaining positive feedback from chemically reasonable prediction results. This guides the model to focus on accurately predicting the standard answer, thereby improving the prediction accuracy and interpretability of the reasoning process of the chemical reaction prediction model.

[0058] It should be noted that each implementation method of this application can be freely combined, rearranged, or executed individually, and does not need to rely on or depend on a fixed execution order.

[0059] In some embodiments, generating initial samples containing chemical reaction reasoning processes for the current training task based on the initial chemical reaction data includes: Based on the task type of the current training task, call the preset inference template that matches the current training task; Based on the preset reasoning template and the initial chemical reaction data, an initial sample containing the chemical reaction reasoning process is generated for the current training task; Wherein, if the task type is forward reaction prediction, the preset inference template includes a prompt for analyzing the structural characteristics of the reaction input, a prompt for retrieving the reaction type and similar cases, a prompt for predicting the reaction mechanism and potential reaction sites, and a prompt for predicting the reaction path and possible products; if the task type is retrosynthesis prediction, the preset inference template includes a prompt for analyzing the structural characteristics of the target product, a prompt for retrieving the reaction type and similar cases, a prompt for predicting the reaction mechanism and potential bond breaking sites, and a prompt for predicting the reaction path and required reaction input.

[0060] In this embodiment, when generating initial samples containing chemical reaction reasoning processes based on the initial chemical reaction data of the current training task, a preset reasoning template matching the current training task is invoked. The preset reasoning template is a structured task guidance template used to standardize the order of analysis steps and reasoning levels that the large language model should follow when generating chemical reaction reasoning processes, that is, a step-by-step analysis process starting from molecular structure, through type judgment and mechanism deduction, and finally arriving at the prediction conclusion.

[0061] Here, by designing corresponding preset reasoning templates for different task types, the large language model can be effectively guided to generate a structured reasoning process with inherent chemical logic consistency. This avoids the model jumping directly to the final prediction result and skipping necessary intermediate analysis steps, thereby improving the interpretability of reasoning and reducing the probability of logical errors in the final prediction result due to the lack of reasoning process.

[0062] Specifically, when the task type of the current training task is positive response prediction, the preset inference template invoked includes the following inference cue bits: The first reasoning prompt is for analyzing the structural characteristics of the reaction input, guiding the large language model to systematically analyze the molecular structure and physicochemical properties of the given reaction input. Specific analysis content may include, but is not limited to: the type and number of functional groups in each molecule, the electron cloud distribution characteristics of the molecule, the spatial configuration of the molecule, and the nucleophilic or electrophilic chemical properties that each molecule may exhibit in the reaction. A thorough analysis of the molecular structure of the reaction input lays the foundation for predicting the reaction type and deducing the reaction mechanism in subsequent steps. The second reasoning prompt is the reaction type and similar case retrieval prompt, which is used to guide the large language model to predict the most likely reaction type of the current reaction input based on the results of the above molecular structure analysis, and to further verify or correct the reaction type judgment by combining the similar chemical reaction cases obtained by retrieval. The third reasoning prompt is the reaction mechanism and potential reaction site prediction prompt. It is used to guide the large language model to further deduce the specific reaction mechanism of the current reaction based on the determination of the reaction type, and to identify the potential reaction sites in the reactant molecules that participate in the reaction, that is, the specific atomic or functional group positions that may form or break chemical bonds during the reaction process. The fourth inference prompt is the reaction path and possible product prediction prompt. It is used to guide the large language model to integrate the analysis conclusions of the previous steps, infer the complete reaction path, and predict the molecular structure of the product that may be formed in the final reaction, and give the molecular expression of the product.

[0063] When the task type of the current training task is inverse synthetic prediction, the preset inference template invoked includes the following inference cue bits: The first reasoning prompt is the target product structural characteristic analysis prompt, which is used to guide the large language model to systematically analyze the molecular structure and physicochemical properties of the given target product; The second reasoning prompt is the reaction type and similar case retrieval prompt, which is used to guide the large language model to predict the reaction type that may be used to synthesize the target product based on the structural features of the target product, and to refer to the similar synthesis reaction cases obtained by retrieval to assist in the judgment of the reaction type. The third reasoning prompt is a prompt for predicting reaction mechanisms and potential bond-breaking positions. It is used to guide the large language model to infer the corresponding reaction mechanism in retrosynthetic analysis based on the determined synthetic reaction type, and to identify the key bond positions in the target product molecule that may be broken during retrosynthetic cleavage, i.e. potential bond-breaking positions. The fourth inference prompt is a prediction prompt for the reaction path and required reaction input. It is used to guide the large language model to synthesize the above analysis, infer the complete synthetic path that can synthesize the target product, and give the molecular expression of each precursor molecule based on the predicted reaction input.

[0064] The training method of the chemical reaction prediction model in this embodiment of the invention designs corresponding preset reasoning templates for two types of tasks: forward reaction prediction and retrosynthesis prediction. This enables the large language model to follow a chemical logic chain that is compatible with the task type when generating initial samples containing chemical reaction reasoning processes based on initial chemical reaction data, thereby improving the quality of the reasoning process of the initial samples.

[0065] In some embodiments, constructing a second target sample based on the first target sample and the initial sample includes: Extract the target molecule characterization corresponding to the data to be processed, and determine the corresponding target reaction category based on the target molecule characterization; wherein, the data to be processed includes the first target sample or the initial sample; Identify chemical reaction case data from a pre-built similar case knowledge base that match the target reaction category and have the closest molecular characterization distance; The chemical reaction case data is spliced ​​with the data to be processed to construct a second target sample.

[0066] First, the target molecule characterization corresponding to the data to be processed is extracted. The target molecule characterization is a structured vector representation of the core molecule in the data to be processed. This vector representation needs to have the ability to effectively encode the molecular structure and its chemical properties to support subsequent chemical similarity retrieval based on vector distance. Specifically, for the forward reaction prediction task, the core molecule is the reactant molecule in the reaction input; for the retrosynthesis prediction task, the core molecule is the target product molecule.

[0067] The target molecule characterization can be obtained by forward inference of the pre-encoded information of the corresponding molecule through a pre-trained reaction type classification model. The output vector of a specific intermediate layer in the reaction type classification model is extracted as the target molecule characterization. The output vector of the intermediate layer has learned rich chemical structural semantic information related to the reaction type during the supervised training of the reaction type classification task, so it can effectively support the measurement of chemical similarity between molecules.

[0068] Secondly, based on the aforementioned target molecule characterization, the corresponding target reaction category is determined. The target reaction category is determined by inputting pre-encoded molecular information into a reaction type classification model, and the reaction type prediction result given by the model's output layer represents the most likely chemical reaction type corresponding to the current data to be processed.

[0069] In one example, for the forward reaction prediction task, the reaction category with the highest output probability from the reaction type classification model can be selected as the target reaction category; for the retrosynthesis prediction task, considering that the same target product may correspond to multiple reasonable synthetic reaction types, the top K reaction categories with the highest output probability from the reaction type classification model (K is a positive integer greater than 1) can be selected as the target reaction category set.

[0070] Based on this, chemical reaction case data that matches the target reaction category and has the closest molecular representation distance are identified in a pre-constructed similar case knowledge base. Here, the similar case knowledge base is a structured knowledge storage pre-built based on the chemical reaction training dataset, storing the complete reaction equations, corresponding reaction category labels, and target molecular representation vectors for each chemical reaction data in the training set. During retrieval, the vector distance between the target molecular representation vector of the data to be processed and each stored molecular representation vector in the similar case knowledge base with the same target reaction category is calculated. The complete chemical reaction equations corresponding to the closest stored molecular representation vectors are selected as chemical reaction case data based on distance ranking. The L2 norm can be used to measure the vector distance, and the number N of selected chemical reaction cases can be set according to actual needs.

[0071] Finally, the retrieved chemical reaction case data is appended to the question input part of the data to be processed in a structured manner. That is, it is appended after the text that poses the chemical reaction prediction question to the large language model and before the instruction that asks the model to output the reasoning process. This way, the second target sample contains not only the original chemical reaction reasoning process annotation information, but also relevant chemical reaction reference case information.

[0072] The training method of the chemical reaction prediction model in this embodiment of the invention adds chemical reaction case data retrieved from a similar case knowledge base to the input part of each training sample. This allows the second language model to learn historical reaction cases with similar structures to the current chemical reaction problem during the supervised fine-tuning training process, thereby improving the prediction accuracy of the chemical reaction prediction model on unknown chemical reaction problems and the chemical rationality of the reasoning process.

[0073] In some embodiments, the reward function is constructed as follows: Based on the task type of the current training task, the matching cross-validation model is invoked to determine the reasonableness of the current prediction data and obtain a response reasonableness index; wherein, when the task type is positive response prediction, the cross-validation model is an inverse synthesis prediction validation model; when the task type is inverse synthesis prediction, the cross-validation model is a positive response prediction validation model. By comparing the current predicted data with the corresponding standard answer data, a perfect match index is obtained; The reward function is constructed based on the response rationality index and the perfect match index.

[0074] Specifically, the cross-validation model is a pre-trained, specialized small-scale chemical reaction prediction model used to independently verify the chemical plausibility of the predictions given by the model to be reinforced. Cross-validation leverages the inherent reciprocity between forward reaction prediction and retrosynthetic prediction: if a forward reaction prediction is chemically plausible, then the corresponding reaction input should be reconstructed through retrosynthetic analysis based on the predicted product; conversely, if a retrosynthetic prediction is chemically plausible, then the target product should be predicted through forward reaction analysis based on the predicted reaction input. Through this mutual verification of forward and retrosynthetic approaches, the chemical plausibility of the prediction results can be effectively judged, rather than being limited to a precise string comparison with a single standard answer.

[0075] In this embodiment, when the current training task is forward reaction prediction, the cross-validation model is an retrosynthetic prediction validation model. The retrosynthetic prediction validation model receives the product molecule expression predicted by the model to be reinforced as input, performs retrosynthetic prediction inference under given reaction conditions, and determines whether it can inversely deduce a precursor molecule that matches or is highly similar to the original reaction input molecule from the predicted product. If the retrosynthetic prediction validation model can infer the molecule corresponding to the original reaction input from the predicted product, the current forward reaction prediction result is determined to meet the reaction rationality index, and a corresponding positive reward is given; otherwise, the current prediction result is determined not to meet the reaction rationality index, and the corresponding reward value is zero or a low value.

[0076] When the current training task is retrosynthetic prediction, the cross-validation model is a forward reaction prediction validation model. The forward reaction prediction validation model receives the reaction input molecular expression predicted by the model to be reinforced as input, performs forward reaction prediction inference under given reaction conditions, and determines whether the predicted reaction input can forward generate a product molecule that matches or is highly similar to the target product. If the forward reaction prediction validation model can infer the molecule corresponding to the target product from the predicted reaction input, the current retrosynthetic prediction result is deemed to meet the reaction rationality index, and a corresponding positive reward is given; otherwise, the current prediction result is deemed not to meet the reaction rationality index.

[0077] It should be noted that both the inverse synthesis prediction validation model and the forward response prediction validation model are dedicated small models that have been trained independently in advance. Their model parameters remain fixed during the reinforcement learning training of the model to be reinforced, do not participate in gradient updates, and are only used as evaluation tools.

[0078] In this embodiment, based on the judgment results of the above-mentioned response rationality index and the evaluation results of the perfect match index, a reward function containing the above two dimensions is constructed.

[0079] The training method of the chemical reaction prediction model in this invention introduces a reaction rationality index based on a cross-validation model, which enables the reward function to give appropriate positive rewards to chemically reasonable prediction results that are not completely consistent with the unique standard answer. This effectively expands the coverage of positive reward signals in reinforcement learning training and overcomes the problem of excessively sparse reward signals when relying solely on the perfect match index.

[0080] In some embodiments, the multi-dimensional evaluation metrics further include an inference length metric and a chemical legitimacy metric. The construction of the reward function based on the reaction rationality metric and the perfect match metric includes: The inference length index is obtained based on the inference process generation length corresponding to the current prediction data; The molecular expression corresponding to the current predicted data is chemically validated to obtain the chemical legality index. The reward function is constructed based on the inference length index, the chemical legitimacy index, the reaction rationality index, and the perfect match index.

[0081] In this embodiment, the reward function includes multi-dimensional evaluation metrics in addition to perfect matching and response rationality metrics, as well as inference length and chemical legitimacy metrics, providing more comprehensive and fine-grained training signals for reinforcement learning training of the model to be reinforced.

[0082] Here, the inference length metric is used to evaluate whether the length of the inference process generated by the model to be strengthened is within a reasonable range. Inference length can be measured by the number of characters, tokens, or sentences in the generated text. By introducing the inference length metric, lower reward values ​​are given to generated results that are too short or too long, thereby constraining the model to generate inference processes of appropriate length and rich content. The reasonable length range for the inference length metric can be determined based on the task type and the actual length distribution of the inference processes in the training data.

[0083] The chemical validity metric is used to evaluate whether the molecular expression predicted by the model to be strengthened is chemically valid, that is, whether the predicted molecular expression conforms to the basic specifications of chemical structure and can be parsed into a legal molecular structure. Chemical molecules are usually represented by strings in SMILES format, which has strict requirements on the syntax and the chemical structure described. If the molecular expression predicted by the model to be strengthened does not meet the syntax rules of SMILES format, or meets the syntax rules but the described chemical structure is chemically invalid, the prediction result is deemed not to meet the chemical validity metric, and the corresponding reward value is zero or a low value; conversely, if the predicted molecular expression can be successfully parsed into a legal molecular structure, the chemical validity metric is deemed to meet the chemical validity metric, and the corresponding positive reward is given. Here, the verification of chemical validity can be achieved by calling the molecular parsing function in cheminformatics tool libraries such as RDKit.

[0084] In this embodiment, a multi-dimensional reward function is constructed based on inference length, chemical validity, reaction rationality, and perfect match metrics. The reward values ​​corresponding to each metric can be combined using a weighted summation method. The reward weight for each metric can be set and dynamically adjusted according to the importance of each metric in the current training phase. The total reward value serves as the target signal for policy optimization during reinforcement learning training.

[0085] The training method for the chemical reaction prediction model in this invention incorporates the inference length index and the chemical legitimacy index into the reward function, enabling the reward function to comprehensively guide the output of the model to be reinforced at different levels of reinforcement learning training.

[0086] In some embodiments, updating the weight of the response rationality index based on the proportion of samples satisfying the response rationality index in each training batch includes: Determine the percentage of samples in the current training batch that meet the aforementioned reaction rationality index; Based on the inverse mapping relationship and the sample proportion of the current training batch, the weight of the response rationality index of the current training batch is updated; wherein, when the sample proportion is 100%, the weight is updated to zero; when the sample proportion is zero, the weight is updated to the weight corresponding to the perfect match index.

[0087] In each training batch of reinforcement learning training, first count the number of samples that can meet the reasonableness index of the response among all the prediction results generated by the model to be reinforced in the current training batch, and calculate the proportion of this number in the total number of samples in the current training batch. This proportion is recorded as the pass rate of the current training batch.

[0088] Next, based on the inverse mapping relationship and the pass rate of the current training batch, the weight of the response rationality index for the current training batch is updated. Here, the inverse mapping relationship means that the weight of the response rationality index and the pass rate have an inverse relationship: the higher the pass rate, the lower the weight; the lower the pass rate, the higher the weight.

[0089] Specifically, when the pass rate of the current training batch is 100%, the weight of the reaction rationality index is updated to zero, and at this time, the contribution of the reaction rationality index to the training gradient of the current batch in the reward function is zero; when the pass rate of the current training batch is 0%, the weight of the reaction rationality index is updated to the weight value corresponding to the perfect match index, that is, the weight of the perfect match index is used as the upper limit constraint threshold; when the pass rate of the current training batch is between 0% and 100%, the weight of the reaction rationality index is between zero and the upper limit constraint threshold, and decreases as the pass rate increases according to the inverse mapping relationship.

[0090] It should be noted that the aforementioned weight updates are completed after samples are generated in each training batch and before policy gradient updates are performed. This constitutes a dynamic adjustment within each batch, independent of the static weight settings for each stage by the multi-stage weight adjustment mechanism. When both multi-stage weight adjustment and dynamic weight updates exist simultaneously, the two mechanisms work together: multi-stage weight adjustment determines the baseline weights of the rationality indicators for each stage at a macro level, while dynamic weight updates further adjust the baseline weights at the micro level of each batch based on the actual pass rate. This ensures that the reward function maintains a reasonable perception and effective guidance of the current capability state of the model to be reinforced across different training batches.

[0091] The training method of the chemical reaction prediction model in this embodiment of the invention introduces a dynamic update mechanism for the reaction rationality index weights based on the batch pass rate, so that the reward function can adaptively adjust the relative weights of each evaluation dimension as the capabilities of the model to be strengthened evolve.

[0092] In some embodiments, adjusting the weight ratio between the perfect match metric and the response rationality metric according to a preset training progress threshold includes: When the number of iterations in reinforcement learning training is less than a preset training progress threshold, the reward function is constrained by the perfect match index, the first weight corresponding to the perfect match index, the response rationality index, and the second weight corresponding to the response rationality index. When the number of iterations in reinforcement learning training is not less than a preset training progress threshold, the second weight of the response rationality index is reduced, and the first weight of the perfect match index is increased.

[0093] Here, the preset training progress threshold is the iteration step threshold A for reinforcement learning training, where A is a pre-defined positive integer. The iteration step count for reinforcement learning training refers to the cumulative number of policy gradient update rounds executed since the start of reinforcement learning training.

[0094] When the current iteration step of reinforcement learning training is less than the preset training progress threshold A, it is in the pre-threshold stage. In the pre-threshold stage, the perfect match metric and the reaction rationality metric simultaneously constrain the reward function with non-zero weights, meaning that both metrics influence the optimization direction of the model parameters.

[0095] When the current iteration step of reinforcement learning training is not less than the preset training progress threshold A, it is in the post-threshold stage. In the post-threshold stage, the first weight corresponding to the perfect match metric is increased, while the second weight corresponding to the reaction rationality metric is decreased, so that the perfect match metric occupies a more dominant position in the reward function.

[0096] The training method of the chemical reaction prediction model in this embodiment of the invention divides the reinforcement learning training process into a pre-threshold stage and a post-threshold stage, and configures different reward weight ratios for the two stages, thereby realizing a training strategy of exploration first and then precision.

[0097] Based on the above embodiments, this invention also provides a chemical reaction prediction method. Specifically, the chemical reaction prediction method in this invention includes the following steps: Acquire the chemical reaction data to be predicted and determine the prediction task type corresponding to the chemical reaction data to be predicted; Based on the prediction task type, the target molecule characterization corresponding to the chemical reaction data to be predicted is extracted, and the target case knowledge is retrieved from the pre-constructed similar case knowledge base based on the target molecule characterization. A preset reasoning template matching the prediction task type is invoked to concatenate the chemical reaction data to be predicted with the target case knowledge to obtain the target prediction input data; The target prediction input data is input into a pre-trained chemical reaction prediction model to obtain the chemical reaction reasoning process and final prediction result output by the chemical reaction prediction model. Here, the chemical reaction data to be predicted refers to the input of the chemical reaction problem that needs to be predicted, and its specific content varies depending on the type of prediction task. Prediction task types include forward reaction prediction and retrosynthesis prediction. When the prediction task type is forward reaction prediction, the chemical reaction data to be predicted must at least include the molecular expressions of the reactants and reaction condition information, used to predict the corresponding reaction products; when the prediction task type is retrosynthesis prediction, the chemical reaction data to be predicted must at least include the molecular expression of the target product, used to predict the reaction input required to synthesize the target product.

[0098] After acquiring the chemical reaction data to be predicted, the prediction task type corresponding to the chemical reaction data is determined. Based on the prediction task type, the target molecule characterization corresponding to the chemical reaction data to be predicted is extracted. The extraction method of the target molecule characterization is the same as that in the training phase, and will not be described again here.

[0099] Next, a preset inference template matching the prediction task type is invoked to concatenate the chemical reaction data to be predicted with the target case knowledge to obtain the target prediction input data. Specifically, if the prediction task type is forward reaction prediction, the preset inference template includes prompts for reaction input structural characteristics analysis, reaction type and similar case retrieval, reaction mechanism and potential reaction site prediction, and reaction pathway and possible product prediction. If the prediction task type is retrosynthesis prediction, the preset inference template includes prompts for target product structural characteristics analysis, reaction type and similar case retrieval, reaction mechanism and potential bond breaking position prediction, and reaction pathway and required reaction input prediction.

[0100] Finally, the target prediction input data is fed into the pre-trained chemical reaction prediction model to obtain the chemical reaction reasoning process and final prediction result output by the chemical reaction prediction model. It should be understood that this pre-trained chemical reaction prediction model is trained using the chemical reaction model training method described above, which will not be elaborated upon further here.

[0101] The chemical reaction prediction method of this invention, through the above-described manner, enables the output to be a structured response that combines the interpretability of stepwise reasoning with the accuracy of the final result prediction. This helps relevant personnel to judge the credibility of the prediction results and, when necessary, to check for potential prediction errors based on the prompts of the reasoning process.

[0102] The training apparatus for the chemical reaction prediction model provided in the embodiments of the present invention will be described below. The training apparatus for the chemical reaction prediction model described below and the training method for the chemical reaction prediction model described above can be referred to in correspondence with each other.

[0103] The training device for the chemical reaction prediction model in this embodiment of the invention, such as... Figure 2 As shown, it includes the following modules: The acquisition module 210 is used to acquire initial chemical reaction data containing chemical reaction conditions, and based on the initial chemical reaction data, generate an initial sample containing the chemical reaction reasoning process under the current training task. The first training module 220 is used to perform supervised fine-tuning and reinforcement learning on the first large language model based on the initial samples, and to select the first target samples whose prediction results meet the preset conditions during the reinforcement learning process. The second training module 230 is used to construct a second target sample based on the first target sample and the initial sample, and to perform supervised fine-tuning of the second large language model based on the second target sample to obtain the model to be strengthened. The third training module 240 is used to construct a reward function that matches the current training task, and to perform reinforcement learning training on the model to be reinforced based on the reward function to obtain a chemical reaction prediction model under the current training task. The reward function includes multi-dimensional evaluation metrics, which include at least a perfect match metric and a response rationality metric. During the iterative process of reinforcement learning training, the weight ratio between the perfect match metric and the response rationality metric is adjusted according to a preset training progress threshold. The weight of the response rationality metric is updated based on the proportion of samples that meet the response rationality metric in each training batch, and the weight is constrained by the upper limit threshold corresponding to the weight of the perfect match metric.

[0104] The training device for the chemical reaction prediction model in this invention employs a multi-stage training process: initial sample generation, supervised fine-tuning and reinforcement learning of the first large language model, screening of the first target sample, merging and constructing the second target sample, supervised fine-tuning of the second large language model, and reinforcement learning training of the model to be reinforced. On one hand, by merging the initial sample and the first target sample to construct the second target sample, the scale of training data is expanded while introducing high-quality samples verified by reward signals, enabling the second large language model to obtain high-quality training data support during the supervised fine-tuning stage. On the other hand, a multi-dimensional reward function containing a perfect match index and a reaction rationality index is constructed. Combined with a multi-stage weight adjustment based on a preset training progress threshold and a dynamic weight update mechanism based on the batch pass ratio, the model can accumulate perfect match rewards while also obtaining positive feedback from chemically reasonable prediction results. This guides the model to focus on accurately predicting the standard answer, thereby improving the prediction accuracy and interpretability of the reasoning process of the chemical reaction prediction model.

[0105] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3As shown, the electronic device may include: a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, the communications interface 320, and the memory 330 communicate with each other via the communication bus 340. The processor 310 can call logical instructions in the memory 330 to execute a training method for a chemical reaction prediction model, the method including: Acquire initial chemical reaction data containing chemical reaction conditions, and based on the initial chemical reaction data, generate initial samples containing chemical reaction reasoning processes for the current training task; Based on the initial samples, the first language model is subjected to supervised fine-tuning and reinforcement learning, and the first target samples whose prediction results meet the preset conditions are selected during the reinforcement learning process. Based on the first target sample and the initial sample, a second target sample is constructed, and the second language model is supervised and fine-tuned based on the second target sample to obtain the model to be strengthened; Construct a reward function that matches the current training task, and perform reinforcement learning training on the model to be reinforced based on the reward function to obtain a chemical reaction prediction model under the current training task. The reward function includes multi-dimensional evaluation metrics, which include at least a perfect match metric and a response rationality metric. During the iterative process of reinforcement learning training, the weight ratio between the perfect match metric and the response rationality metric is adjusted according to a preset training progress threshold. The weight of the response rationality metric is updated based on the proportion of samples that meet the response rationality metric in each training batch, and the weight is constrained by the upper limit threshold corresponding to the weight of the perfect match metric.

[0106] Processor 310 can also invoke logic instructions in memory 330 to execute a chemical reaction prediction method, the method including: Acquire the chemical reaction data to be predicted and determine the prediction task type corresponding to the chemical reaction data to be predicted; Based on the prediction task type, the target molecule characterization corresponding to the chemical reaction data to be predicted is extracted, and the target case knowledge is retrieved from the pre-constructed similar case knowledge base based on the target molecule characterization. A preset reasoning template matching the prediction task type is invoked to concatenate the chemical reaction data to be predicted with the target case knowledge to obtain the target prediction input data; The target prediction input data is input into a pre-trained chemical reaction prediction model to obtain the chemical reaction reasoning process and final prediction result output by the chemical reaction prediction model.

[0107] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc., each of which can store program code.

[0108] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, wherein when the computer program is executed by a processor, the computer is capable of executing a training method for the chemical reaction prediction model provided by each of the above methods, the method comprising: Acquire initial chemical reaction data containing chemical reaction conditions, and based on the initial chemical reaction data, generate initial samples containing chemical reaction reasoning processes for the current training task; Based on the initial samples, the first language model is subjected to supervised fine-tuning and reinforcement learning, and the first target samples whose prediction results meet the preset conditions are selected during the reinforcement learning process. Based on the first target sample and the initial sample, a second target sample is constructed, and the second language model is supervised and fine-tuned based on the second target sample to obtain the model to be strengthened; Construct a reward function that matches the current training task, and perform reinforcement learning training on the model to be reinforced based on the reward function to obtain a chemical reaction prediction model under the current training task. The reward function includes multi-dimensional evaluation metrics, which include at least a perfect match metric and a response rationality metric. During the iterative process of reinforcement learning training, the weight ratio between the perfect match metric and the response rationality metric is adjusted according to a preset training progress threshold. The weight of the response rationality metric is updated based on the proportion of samples that meet the response rationality metric in each training batch, and the weight is constrained by the upper limit threshold corresponding to the weight of the perfect match metric.

[0109] When the computer program is executed by the processor, the computer can also execute a chemical reaction prediction method, which includes: Acquire the chemical reaction data to be predicted and determine the prediction task type corresponding to the chemical reaction data to be predicted; Based on the prediction task type, the target molecule characterization corresponding to the chemical reaction data to be predicted is extracted, and the target case knowledge is retrieved from the pre-constructed similar case knowledge base based on the target molecule characterization. A preset reasoning template matching the prediction task type is invoked to concatenate the chemical reaction data to be predicted with the target case knowledge to obtain the target prediction input data; The target prediction input data is input into a pre-trained chemical reaction prediction model to obtain the chemical reaction reasoning process and final prediction result output by the chemical reaction prediction model.

[0110] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a training method for a chemical reaction prediction model provided by each of the above methods, the method comprising: Acquire initial chemical reaction data containing chemical reaction conditions, and based on the initial chemical reaction data, generate initial samples containing chemical reaction reasoning processes for the current training task; Based on the initial samples, the first language model is subjected to supervised fine-tuning and reinforcement learning, and the first target samples whose prediction results meet the preset conditions are selected during the reinforcement learning process. Based on the first target sample and the initial sample, a second target sample is constructed, and the second language model is supervised and fine-tuned based on the second target sample to obtain the model to be strengthened; Construct a reward function that matches the current training task, and perform reinforcement learning training on the model to be reinforced based on the reward function to obtain a chemical reaction prediction model under the current training task. The reward function includes multi-dimensional evaluation metrics, which include at least a perfect match metric and a response rationality metric. During the iterative process of reinforcement learning training, the weight ratio between the perfect match metric and the response rationality metric is adjusted according to a preset training progress threshold. The weight of the response rationality metric is updated based on the proportion of samples that meet the response rationality metric in each training batch, and the weight is constrained by the upper limit threshold corresponding to the weight of the perfect match metric.

[0111] When executed by a processor, the computer program is implemented to perform the chemical reaction prediction method provided by each of the above methods, the method comprising: Acquire the chemical reaction data to be predicted and determine the prediction task type corresponding to the chemical reaction data to be predicted; Based on the prediction task type, the target molecule characterization corresponding to the chemical reaction data to be predicted is extracted, and the target case knowledge is retrieved from the pre-constructed similar case knowledge base based on the target molecule characterization. A preset reasoning template matching the prediction task type is invoked to concatenate the chemical reaction data to be predicted with the target case knowledge to obtain the target prediction input data; The target prediction input data is input into a pre-trained chemical reaction prediction model to obtain the chemical reaction reasoning process and final prediction result output by the chemical reaction prediction model.

[0112] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0113] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0114] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in each of the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of each embodiment of the present invention.

Claims

1. A training method for a chemical reaction prediction model, characterized in that, include: Acquire initial chemical reaction data containing chemical reaction conditions, and based on the initial chemical reaction data, generate initial samples containing chemical reaction reasoning processes for the current training task; Based on the initial samples, the first language model is subjected to supervised fine-tuning and reinforcement learning, and the first target samples whose prediction results meet the preset conditions are selected during the reinforcement learning process. Based on the first target sample and the initial sample, a second target sample is constructed, and the second language model is supervised and fine-tuned based on the second target sample to obtain the model to be strengthened; Construct a reward function that matches the current training task, and perform reinforcement learning training on the model to be reinforced based on the reward function to obtain a chemical reaction prediction model under the current training task. The reward function includes multi-dimensional evaluation metrics, which include at least a perfect match metric and a response rationality metric. During the iterative process of reinforcement learning training, the weight ratio between the perfect match metric and the response rationality metric is adjusted according to a preset training progress threshold. The weight of the response rationality metric is updated based on the proportion of samples that meet the response rationality metric in each training batch, and the weight is constrained by the upper limit threshold corresponding to the weight of the perfect match metric.

2. The training method for the chemical reaction prediction model according to claim 1, characterized in that, The step of generating initial samples containing chemical reaction reasoning processes for the current training task based on the initial chemical reaction data includes: Based on the task type of the current training task, call the preset inference template that matches the current training task; Based on the preset reasoning template and the initial chemical reaction data, an initial sample containing the chemical reaction reasoning process is generated for the current training task; Wherein, if the task type is forward reaction prediction, the preset inference template includes a prompt for analyzing the structural characteristics of the reaction input, a prompt for retrieving the reaction type and similar cases, a prompt for predicting the reaction mechanism and potential reaction sites, and a prompt for predicting the reaction path and possible products; if the task type is retrosynthesis prediction, the preset inference template includes a prompt for analyzing the structural characteristics of the target product, a prompt for retrieving the reaction type and similar cases, a prompt for predicting the reaction mechanism and potential bond breaking sites, and a prompt for predicting the reaction path and required reaction input.

3. The training method for the chemical reaction prediction model according to claim 1, characterized in that, The step of constructing a second target sample based on the first target sample and the initial sample includes: Extract the target molecule characterization corresponding to the data to be processed, and determine the corresponding target reaction category based on the target molecule characterization; wherein, the data to be processed includes the first target sample or the initial sample; Identify chemical reaction case data from a pre-built similar case knowledge base that match the target reaction category and have the closest molecular characterization distance; The chemical reaction case data is spliced ​​with the data to be processed to construct a second target sample.

4. The training method for the chemical reaction prediction model according to claim 1, characterized in that, The reward function is constructed in the following way: Based on the task type of the current training task, the matching cross-validation model is invoked to determine the reasonableness of the current prediction data and obtain a response reasonableness index; wherein, when the task type is positive response prediction, the cross-validation model is an inverse synthesis prediction validation model; when the task type is inverse synthesis prediction, the cross-validation model is a positive response prediction validation model. By comparing the current predicted data with the corresponding standard answer data, a perfect match index is obtained; The reward function is constructed based on the response rationality index and the perfect match index.

5. The training method for the chemical reaction prediction model according to claim 4, characterized in that, The multi-dimensional evaluation metrics also include inference length and chemical legitimacy metrics. The reward function, constructed based on the reaction rationality metric and the perfect match metric, includes: The inference length index is obtained based on the inference process generation length corresponding to the current prediction data; The molecular expression corresponding to the current predicted data is chemically validated to obtain the chemical legality index. The reward function is constructed based on the inference length index, the chemical legitimacy index, the reaction rationality index, and the perfect match index.

6. The method according to claim 1, characterized in that, The step of updating the weight of the response rationality index based on the proportion of samples that meet the response rationality index in each training batch includes: Determine the percentage of samples in the current training batch that meet the aforementioned reaction rationality index; Based on the inverse mapping relationship and the sample proportion of the current training batch, the weight of the response rationality index of the current training batch is updated; wherein, when the sample proportion is 100%, the weight is updated to zero; when the sample proportion is zero, the weight is updated to the weight corresponding to the perfect match index.

7. The training method for the chemical reaction prediction model according to claim 1, characterized in that, The step of adjusting the weight ratio between the perfect match index and the response rationality index according to a preset training progress threshold includes: When the number of iterations in reinforcement learning training is not less than a preset training progress threshold, the second weight of the response rationality index is reduced, and the first weight of the perfect match index is increased.

8. A method for predicting chemical reactions, characterized in that, include: Acquire the chemical reaction data to be predicted and determine the prediction task type corresponding to the chemical reaction data to be predicted; Based on the prediction task type, the target molecule characterization corresponding to the chemical reaction data to be predicted is extracted, and the target case knowledge is retrieved from the pre-constructed similar case knowledge base based on the target molecule characterization. A preset reasoning template matching the prediction task type is invoked to concatenate the chemical reaction data to be predicted with the target case knowledge to obtain the target prediction input data; The target prediction input data is input into a pre-trained chemical reaction prediction model to obtain the chemical reaction reasoning process and final prediction result output by the chemical reaction prediction model. The chemical reaction prediction model is trained based on the training method of the chemical reaction model as described in any one of claims 1 to 7.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the training method of the chemical reaction prediction model as described in any one of claims 1 to 7 or the chemical reaction prediction method as described in claim 8.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the training method of the chemical reaction prediction model as described in any one of claims 1 to 7 or the chemical reaction prediction method as described in claim 8.