Model training method and device, data processing method and device, equipment and storage medium

By constructing a method that combines the loss functions of two models, and using the predicted output value of the first model and the supervision relationship of the second model for data processing, the problem of insufficient overall accuracy when the neural network model is trained independently in the existing technology is solved, and more efficient training effect and stronger model generalization ability are achieved.

CN121920456APending Publication Date: 2026-04-24HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HUAWEI TECH CO LTD
Filing Date
2024-10-22
Publication Date
2026-04-24

AI Technical Summary

Technical Problem

In existing technologies, when two neural network models are trained independently, although the accuracy of a single model is high, the overall accuracy cannot be guaranteed, and the supervision relationship cannot be effectively utilized to improve the overall training effect.

Method used

By constructing a method that combines the loss functions of two models, the predicted output value of the first model and the supervision relationship of the second model are used for data processing to update the parameters of the first model, reflecting the supervision relationship between the two and improving the overall training accuracy.

Benefits of technology

It enhances the overall training accuracy of two supervised models, reduces the workload of data collection and preprocessing, improves training efficiency, and enhances the generalization ability and robustness of the models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121920456A_ABST
    Figure CN121920456A_ABST
Patent Text Reader

Abstract

The invention discloses a model training method and device, a data processing method and device, equipment and a storage medium, and relates to the technical field of machine learning. The method comprises the steps of calling a first model to perform loss function calculation based on first sample data to obtain a first loss function value; based on a first prediction output value of the first model for the first sample data, a second model is called for loss function calculation, a second loss function value is obtained, and the first model and the second model have a supervision relation. And performing data processing on the first loss function value and the second loss function value to obtain a third loss function value. And updating model parameters of the first model based on the third loss function value to obtain the trained first model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of machine learning technology, and in particular to model training methods, data processing methods, apparatus, devices and storage media. Background Technology

[0002] With the continuous development of neural network technology, the application scenarios of neural network models are becoming increasingly widespread. In some application scenarios, it may be necessary to use two neural network models simultaneously, and the two models have a supervision relationship. The supervision signal of one neural network model can be used to train the other neural network model. For example, in the scenario of medical record-assisted generation, one neural network model is used to generate medical records, and another neural network model is used to perform quality inspection on the medical records generated by the other neural network model.

[0003] In related technologies, when training two neural network models, it is necessary to first collect the sample datasets corresponding to each of the two neural network models, and then train the two neural network models independently based on the sample datasets corresponding to each of the two neural network models.

[0004] However, in related technologies, training two neural network models independently often focuses on the training accuracy of a single neural network model. Although the accuracy of each neural network model can be relatively high through training, the accuracy of the two neural network models as a whole cannot be guaranteed. Summary of the Invention

[0005] This application provides model training methods, data processing methods, apparatus, devices, and storage media, which improve the overall training accuracy of multiple supervised models.

[0006] To achieve the above objectives, this application adopts the following technical solution:

[0007] Firstly, a model training method is provided, which is used to train a first model, wherein the first model and a second model have a supervised relationship, and the method includes:

[0008] Based on the first sample data, the first model is invoked to calculate the loss function, resulting in a first loss function value. Based on the first model's first predicted output value for the first sample data, the second model is invoked to calculate the loss function, resulting in a second loss function value. The first and second loss function values ​​are then processed to obtain a third loss function value. Based on the third loss function value, the model parameters of the first model are updated to obtain the trained first model.

[0009] The solution provided in this application, when constructing the loss function for training the first model, processes the loss functions corresponding to the first and second models with a supervision relationship, and then uses the constructed loss function to update the model parameters of the first model, resulting in the trained first model. This constructed loss function combines the loss functions of both models, reflecting their supervision relationship information. This allows the second model, which has a supervision relationship with the first model, to intervene in the training process of the first model, thereby ensuring the training accuracy of the two supervised models as a whole.

[0010] One possible implementation, the model training method provided in this application, further includes: configuring labeled data for the first sample data, whereby the labeled data indicates the true value corresponding to the execution of the function of the first model on the first sample data. Based on the first sample data, the first model is invoked to calculate the loss function to obtain the first loss function value. Specifically, this can be implemented as follows: based on the first sample data, the first model is invoked to make a prediction and output a first predicted output value. Based on the first predicted output value and the labeled data, the first loss function value is calculated. By predicting the first sample data and calculating the loss function based on the first predicted output value output by the first model and the labeled data, a quantitative indicator reflecting the difference between the first predicted output value and the true value is finally obtained, which is the first loss function value. This first loss function value, as a parameter in the loss function value for training the first model, reflects the influence of the first model itself on the training result during the training process of the first model.

[0011] The labeled data can be manually labeled based on the first sample data.

[0012] One possible implementation, the model training method provided in this application, involves processing the first and second loss function values ​​to obtain a third loss function value. Specifically, this can be achieved by: determining the first weight of the first loss function value and the second weight of the second loss function value based on the first sample data; and obtaining the third loss function value based on the first loss function value, the first weight, the second loss function value, and the second weight.

[0013] Among them, the first weight and the second weight have an inverse relationship.

[0014] One possible implementation, the model training method provided in this application, further includes: configuring first normed data for the first sample data, the first normed data being used to indicate the true value corresponding to the function of the second model applied to the first predicted output value. Based on the first predicted output value of the first sample data by the first model, the second model is called to calculate the loss function, obtaining a second loss function value. Specifically, this can be implemented as follows: based on the first predicted output value, the second model is called to obtain the second predicted output value. Based on the second predicted output value and the first normed data, the second loss function value is calculated. After obtaining the first predicted output value output by the first model, the first predicted output value is used as input, and the second model, which has a supervised relationship with the first model, is used to make a prediction, obtaining the second predicted output value. By predicting the result output by the first model through the second model, and calculating the loss function based on the second predicted output value output by the second model and the first normed data, a quantitative index reflecting the difference between the second predicted output value and the true value is finally obtained, that is, the second loss function value. This second loss function value serves as another parameter in the loss function value for training the first model. By adding the second loss function, the second model, which has a supervised relationship with the first model, influences the training result of the first model, thereby improving the overall training accuracy of the model.

[0015] One possible implementation of the model training method provided in this application further includes: calling a third model to make predictions based on the first sample data, and using the predicted output value of the third model as the second sample data; calculating a loss function based on the second sample data to obtain a fourth loss function value; and updating the model parameters of the second model based on the fourth loss function value. In this implementation, the training data used by the second model, which has a supervised relationship with the first model, is obtained by processing the first sample data used to train the first model. That is, the training data for both the first and second models are obtained from the same data. By using the same data to support the training of two supervised models, it is possible to avoid collecting two independent datasets, reducing the workload of data collection and preprocessing, and improving efficiency. At the same time, it also avoids the problem of poor overall model training accuracy caused by data differences between two collected independent datasets.

[0016] One possible implementation, the model training method provided in this application, further includes: configuring second normed data for the second sample data, the second normed data indicating the true value corresponding to the execution of the second model's function on the second sample data. Based on the second sample data, the second model is invoked to calculate the loss function, obtaining a fourth loss function value. Specifically, this can be implemented as follows: based on the second sample data, the second model is invoked to obtain a third predicted output value. Based on the third predicted output value and the second normed data, the fourth loss function value is calculated. By predicting the second sample data and calculating the loss function based on the third predicted output value of the second model and the second normed data, a quantitative index reflecting the difference between the third predicted output value and the true value is finally obtained, that is, the fourth loss function value. Based on the fourth loss function value, the model parameters of the second model are updated to obtain the trained second model.

[0017] One possible implementation, the model training method provided in this application, further includes: acquiring first sample data to be predicted; calling a trained first model to generate data from the first sample data to obtain predicted generated data; and calling a trained second model to perform data quality checks on the predicted generated data to obtain predicted quality-checked data. In the two models with a supervised relationship, the first model is used for data generation, and the second model is used for quality checks on the generated data. By utilizing the supervised relationship between the two models, the second model can identify abnormal data in the data generated by the first model, thereby enhancing the model's generalization ability.

[0018] One possible implementation involves using doctor-patient dialogues as the first sample data, a first model to predict and generate medical records based on these dialogues, and a second model to perform quality checks on the medical records predicted by the first model.

[0019] One possible implementation is that the first sample data is an article fragment, the first model is used to predict and generate an article based on the article fragment, and the second model is used to perform quality checks on the article predicted and generated by the first model.

[0020] One possible implementation is that the first sample data is code description text, the first model is used to predict and generate code based on the code description text, and the second model is used to perform quality inspection on the code predicted and generated by the first model.

[0021] Secondly, a data processing method is provided, which includes: acquiring raw data; calling a first model to generate predicted data from the raw data; and calling a second model to perform data quality checks on the predicted data to obtain predicted quality-checked data. The first model is trained based on a target loss function, which is determined by the loss functions of the first and second models.

[0022] The solution provided in this application uses two models to generate and inspect data sequentially. Based on the supervision relationship between the two models, the second model can identify abnormal or redundant data in the data generated by the first model, thereby ensuring the stability of the model output and enhancing the model's generalization ability and robustness.

[0023] One possible implementation involves using doctor-patient dialogues as the raw data, a first model to predict and generate medical records based on these dialogues, and a second model to perform quality checks on the medical records generated by the first model.

[0024] One possible implementation involves using article fragments as the raw data, employing a first model to predict and generate articles based on these fragments, and a second model to perform quality checks on the articles predicted by the first model.

[0025] One possible implementation involves using code description text as the raw data, a first model to predict and generate code based on the code description text, and a second model to perform quality checks on the code predicted and generated by the first model.

[0026] Thirdly, a model training apparatus is provided, in which a first model and a second model with a supervised relationship are deployed. The apparatus includes: a calling module, a computation module, and a training module. Wherein:

[0027] The calling module is used to call the first model to calculate the loss function based on the first sample data, and obtain the first loss function value.

[0028] The calling module is also used to call the second model to calculate the loss function based on the first predicted output value of the first model on the first sample data, and obtain the second loss function value. The first model and the second model have a supervision relationship.

[0029] The calculation module is used to process the first and second loss function values ​​to obtain the third loss function value.

[0030] The training module is used to update the model parameters of the first model based on the value of the third loss function, so as to obtain the trained first model.

[0031] In one possible implementation, the model training device is further configured with labeled data for the first sample data. This labeled data indicates the true values ​​corresponding to the execution of the first model's function on the first sample data. Accordingly, the aforementioned calling module is specifically used to: call the first model to make a prediction based on the first sample data, and output a first predicted output value; and calculate a first loss function value based on the first predicted output value and the labeled data.

[0032] In one possible implementation, the calculation module is further configured to determine a first weight for the first loss function value and a second weight for the second loss function value based on the first sample data. A third loss function value is then obtained based on the first loss function value, the first weight, the second loss function value, and the second weight.

[0033] Among them, the first weight and the second weight have an inverse relationship.

[0034] In one possible implementation, the model training device is further configured with first normed data of the first sample data, which is used to indicate the true value corresponding to the function of the second model applied to the first predicted output value.

[0035] The aforementioned calling module is also used to call the second model based on the first predicted output value to obtain the second predicted output value; and to calculate the second loss function value based on the second predicted output value and the first standardized data.

[0036] One possible implementation is that the calling module is also used to call the third model for prediction based on the first sample data, and use the predicted output value of the third model as the second sample data.

[0037] The aforementioned calling module is also used to call the second model to calculate the loss function based on the second sample data, thereby obtaining the fourth loss function value.

[0038] The training module described above is also used to update the model parameters of the second model based on the value of the fourth loss function, so as to obtain the trained second model.

[0039] In one possible implementation, the model training device is further configured with second normed data for the second sample data, which refers to the true values ​​corresponding to the function of the second model applied to the second sample data.

[0040] The aforementioned calling module is also used to call the second model based on the second sample data to obtain the third predicted output value; and to calculate the fourth loss function value based on the third predicted output value and the second standardized data.

[0041] In another possible implementation, the model training device further includes an acquisition module. The acquisition module is used to acquire the first sample data to be processed for prediction.

[0042] The aforementioned calling module is also used to call the trained first model to generate data from the first sample data, thereby obtaining the predicted generated data.

[0043] The aforementioned calling module is also used to call the trained second model to perform data quality checks on the predicted data and obtain the predicted quality check data.

[0044] One possible implementation is as follows: the first sample data is a doctor-patient dialogue; the first model is used to predict and generate medical records based on the doctor-patient dialogue; and the second model is used to perform quality checks on the medical records predicted by the first model. Alternatively, the first sample data is an article fragment; the first model is used to predict and generate an article based on the article fragment; and the second model is used to perform quality checks on the article predicted by the first model. Or, the first sample data is code description text; the first model is used to predict and generate code based on the code description text; and the second model is used to perform quality checks on the code predicted by the first model.

[0045] The technical effects of any implementation method in the third aspect can be found in the technical effects of any implementation method in the first aspect mentioned above, and will not be repeated here.

[0046] Fourthly, a data processing apparatus is provided, in which a first model and a second model with a supervisory relationship are deployed. The apparatus includes: an acquisition module and an invocation module. Wherein:

[0047] The acquisition module is used to acquire raw data.

[0048] The calling module is used to call the first model to generate data from the original data and obtain the predicted data.

[0049] The calling module is also used to call the second model to perform data quality checks on the predicted data, obtaining predicted quality check data. The first model is trained based on a target loss function, which is determined by the loss functions of both the first and second models.

[0050] One possible implementation involves using doctor-patient dialogue as the raw data, a first model to predict and generate medical records based on the doctor-patient dialogue, and a second model to perform quality checks on the medical records predicted by the first model.

[0051] One possible implementation involves using article fragments as the raw data, employing a first model to predict and generate articles based on these fragments, and a second model to perform quality checks on the articles predicted by the first model.

[0052] One possible implementation involves using code description text as the raw data, a first model to predict and generate code based on the code description text, and a second model to perform quality checks on the code predicted and generated by the first model.

[0053] The technical effects of any implementation method in the fourth aspect can be found in the technical effects of any implementation method in the second aspect above, and will not be repeated here.

[0054] Fifthly, a computer device is provided, comprising: a processor and a memory, wherein the memory stores at least one computer program, the at least one computer program being loaded and executed by the processor to implement the model training method as described above, or the data processing method as described above.

[0055] In a sixth aspect, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, the at least one computer program being loaded and executed by a processor to implement the model training method as described above, or the data processing method as described above.

[0056] In a seventh aspect, a computer program product is provided, comprising a computer program or instructions, which, when executed by a processor, implement the model training method or the data processing method described above.

[0057] Eighthly, embodiments of this application provide a chip system including at least one processor and at least one interface circuit. The at least one interface circuit is used to perform transceiver functions and send instructions to the at least one processor. When the at least one processor executes the instructions, the at least one processor performs to implement the model training method as described above, or the data processing method as described above.

[0058] The solutions provided in aspects five through eight above are used to implement the methods provided in aspect one or two above, and their specific implementations will not be described in detail here. The technical effects corresponding to any implementation method of the solutions provided in aspects five through eight above can be found in the technical effects corresponding to any implementation method of aspect one or two above, and will not be described in detail here.

[0059] It should be noted that any of the possible implementations of any of the above aspects can be combined, provided that the solutions do not contradict each other. Attached Figure Description

[0060] Figure 1 This is a schematic diagram of an adversarial training method provided in an exemplary embodiment;

[0061] Figure 2 This is a schematic diagram of the architecture of a computer device provided in an exemplary embodiment of this application;

[0062] Figure 3 This is a flowchart of a model training method provided in an exemplary embodiment of this application;

[0063] Figure 4 This is a flowchart of a model training method provided in an exemplary embodiment of this application;

[0064] Figure 5 This is a schematic diagram illustrating a data configuration provided in an exemplary embodiment of this application;

[0065] Figure 6 This is a schematic diagram of training sample data provided in an exemplary embodiment of this application;

[0066] Figure 7 This is a schematic diagram of a model training method provided in an exemplary embodiment of this application;

[0067] Figure 8 This is a flowchart of a data processing method provided in an exemplary embodiment of this application;

[0068] Figure 9 This is a schematic diagram of the structure of a model training apparatus provided in an exemplary embodiment of this application;

[0069] Figure 10 This is a schematic diagram of the structure of a data processing apparatus provided in an exemplary embodiment of this application;

[0070] Figure 11 This is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation

[0071] In the embodiments of this application, in order to clearly describe the technical solutions of the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different. The technical features described by "first" and "second" have no sequential or size order.

[0072] In the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is an example, illustration, or description. Any embodiment or design that is described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner to facilitate understanding.

[0073] In the embodiments of this application, at least one can also be described as one or more, and multiple can be two, three, four or more, and this application does not impose any restrictions.

[0074] Furthermore, the network architecture and scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0075] To facilitate understanding, the following explanations are provided for several terms used in this application.

[0076] Artificial intelligence (AI) refers to the theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence in order to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.

[0077] Model: An artificial intelligence model refers to a mathematical model constructed using artificial intelligence technology. It can learn patterns and rules from data and be used for tasks such as prediction, classification, regression, and clustering. For example, the AI ​​model described in this application can be a neural network or other deep learning model; this application does not limit the specific form of the model.

[0078] Generative models refer to a type of AI model application that is not strongly related to the model algorithm. It mainly refers to the application scenarios of the model, which tend to generate and create scenarios, such as generating code, generating text, generating images, and generating medical records.

[0079] Quality control model: This refers to a type of AI model application that is not strongly related to the model algorithm. It mainly refers to the application scenario of the model and is inclined to perform quality control on the generated or created content to find unreasonable and incorrect parts, such as code inspection, text inspection, security review, medical record quality inspection, etc.

[0080] It should be noted that all information (including but not limited to device information, personal information of the subject), data (including but not limited to data used for analysis, stored data, and displayed data), and signals involved in this application have been authorized by the subject or by all parties in full, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the first sample data, labeled data, first standard data, second standard data, doctor-patient dialogue, article excerpts, code description text, and second sample data in the prompt information involved in this application were all obtained with full authorization.

[0081] For example, commonly used model training methods in the industry include reinforcement learning from human feedback (RLHF) and adversarial training, which will be briefly described below.

[0082] Method 1: RLHF is a machine learning method that combines reinforcement learning and human feedback. The core idea of ​​RLHF is to use human feedback to guide the learning algorithm of the reinforcement generative model, thereby enabling the generative model to better achieve the predetermined output target. The implementation steps of RLHF include: Step 1: Pre-training the generative model. Typically, a large amount of sample data is used to pre-train the generative model, enabling it to understand and process the relevant task. Step 2: Human feedback. Based on the pre-trained generative model, human evaluators provide feedback to guide the model's output. This feedback can be positive or negative, specific guidance, or general preference indications for the model's output. For example, by configuring a separate evaluation model, human scoring of the data generated by the pre-trained generative model (human feedback), organizing the relevant dataset, and training the evaluation model based on this dataset. Step 3: Reinforcement learning. Using the evaluation model as feedback, the pre-trained generative model is retrained. Step 4: Iterative optimization. The pre-trained generative model undergoes multiple iterations of optimization based on human feedback, continuously improving its performance on the specific task.

[0083] However, this RLHF approach requires a separate evaluation model, and the evaluation model is merely an intermediate process or auxiliary means in model training; the ultimate goal of model training is still to generate a model. Furthermore, the generative model and the evaluation model in this approach are trained independently, and the training datasets are also different.

[0084] Method 2: Adversarial training is based on Generative Adversarial Networks (GANs). Its core idea is to use two neural network models to compete against each other, that is, to use a generator and a discriminator to train and learn the distribution of data, thereby generating new sample data.

[0085] In a GAN model, the generator's task is to generate sample data that closely approximates the real data distribution, while the discriminator's task is to distinguish whether the input samples come from real data or fake data generated by the generator. During training, the generator attempts to "deceive" the discriminator into believing that the generated sample data is real; while the discriminator strives not to be "deceived" by the generator, continuously improving its ability to distinguish between real and generated sample data. This adversarial process allows both neural network models to continuously optimize during iterative training, ultimately enabling the generator to produce high-quality sample data that is difficult to distinguish from real data.

[0086] Figure 1 As a schematic diagram of the adversarial training method, the process can be specifically implemented as follows: a) Initialize the network parameters of generator 20 and discriminator 50. b) Generator 20 receives random noise 10 as input and generates fake sample data 30. c) Mix the fake sample data 30 generated by generator 20 with real sample data 40 and input it to discriminator 50. d) Based on the input fake sample data 30 and real sample data 40, discriminator 50 outputs a discrimination result 60, which includes a realism score for each sample data. e) Update the network parameters of generator 20 and discriminator 50 according to the score of discriminator 50. f) Repeat steps b and c until generator 20 and discriminator 50 reach a certain equilibrium state, that is, generator 20 can generate sample data that discriminator 50 has difficulty distinguishing.

[0087] The specific steps for updating the network parameters of generator 20 and discriminator 50 are as follows: First, fix the network parameters of generator 20 and adjust the network parameters of discriminator 50 to obtain the trained discriminator. The goal of updating the network parameters at this point is to make discriminator 50 as effective as possible in identifying the fake sample data 30 generated by generator 20 as fake data. Next, fix the network parameters of discriminator 50 and adjust the network parameters of generator 20 to obtain the trained generator. The goal of updating the network parameters at this point is to make generator 20 generate fake sample data that is "good enough to fool the discriminator 50," making it difficult for discriminator 50 to distinguish them. The above two training steps are executed alternately until the training termination condition is met.

[0088] However, in this adversarial training method, although there are two models and the parameters of discriminator 50 and generator 20 are adjusted during parameter updates, the final training result is generator 20, with discriminator 50 serving only as an intermediate result, and there is no correlation between discriminator 50 and generator 20. Secondly, the training processes for generator 20 and discriminator 50 are also conducted independently in stages. Thirdly, discriminator 50 is a binary classification model, capable only of determining the authenticity of data, and cannot perform content or format quality checks.

[0089] Therefore, the two model training methods mentioned above are not applicable to improving the overall training accuracy when training two models with a supervised relationship.

[0090] Based on this, this application provides a model training method applied to a first model and a second model with a supervised relationship. Based on first sample data, the first model is called to calculate the loss function, obtaining a first loss function value. Based on the first model's first predicted output value for the first sample data, the second model is called to calculate the loss function, obtaining a second loss function. Based on the weighted result of the first and second loss function values, the model parameters of the first model are updated, resulting in the trained first model. The scheme provided in this application, when constructing the loss function for training the first model, processes the loss functions corresponding to the two supervised models (first and second models) and then uses the constructed loss function to update the model parameters of the first model, obtaining the trained first model. This constructed loss function combines the loss functions of both models, reflecting the supervision relationship information between them. This allows the second model, which has a supervisory relationship with the first model, to intervene in the training process of the first model, thereby ensuring the training accuracy of the two supervised models as a whole.

[0091] The solutions provided by the embodiments of this application will be described in detail below with reference to the accompanying drawings.

[0092] The solution provided in this application can be applied to Figure 2 In the illustrated computer equipment. For example... Figure 2 The diagram shows the architecture of a computer device. The computer device has a first model 100 and a second model 200 with a supervisory relationship. However, the number of models deployed is not limited to two models with a supervisory relationship, but can also be multiple models with a supervisory relationship.

[0093] Computer devices can train the first model 100 and the second model 200 using the model training method provided in this application. For example, the computer device acquires first sample data as training sample data, and trains the first model 100 and the second model 200 based on the first sample data, thereby obtaining the trained first model 100 and the second model 200.

[0094] Computer devices can also execute the data processing method provided in this application based on the first model 100 and the second model 200. For example, taking the generation of medical records from doctor-patient dialogue as an example, the doctor-patient dialogue is input into the first model 100, and the first model 100 performs forward prediction based on the first sample data to generate medical records. After obtaining the medical records output by the first model 100, the medical records are input into the second model 200 for forward prediction to obtain medical record quality inspection data.

[0095] In some embodiments, the computer device may be a server, which may be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and other basic cloud computing services such as big data.

[0096] Figure 3 This is a flowchart of a model training method provided in an exemplary embodiment of this application. The method can be executed by a computer device. Figure 3 The illustrated method is used to train the first model, and the first model and the second model have a supervision relationship.

[0097] In this context, the supervision relationship means that the second model supervises the output of the first model; that is, the output of the first model is the input of the second model. The first and second models perform different functions.

[0098] For example, in a medical record generation scenario, the first model is used to predict and generate medical records, and the second model is used to perform quality checks on the medical records predicted and generated by the first model, such as checking the writing style, content, and medication usage.

[0099] In the context of article writing, the first model is used to predict and generate articles, while the second model is used to perform content and / or format quality checks on the articles predicted and generated by the first model.

[0100] In a code generation scenario, the first model is used to predict and generate code, while the second model is used to perform quality checks on the code predicted and generated by the first model in terms of content, format, or logic.

[0101] Optionally, the first model and the second model include, but are not limited to, at least one of the following: Residual Network (ResNet) model, Convolutional Neural Network (CNN) model, Recurrent Neural Network (RNN) model, and Transformer model, but are not limited thereto. The embodiments of this application do not specifically limit this.

[0102] The first and second models provided in this application embodiment can be applied to various scenarios. The above scenarios are only examples and are not intended to limit the specific application scenarios of the models provided in this application embodiment.

[0103] The model training method provided in this application describes a single training process of a model. In practical applications, the process described in the following embodiments can be executed multiple times until the loss function converges, or until the number of training iterations reaches a threshold, ultimately resulting in a fully trained model.

[0104] like Figure 3 As shown, the model training method provided in this application embodiment may include:

[0105] Step 302: The computer device acquires the first sample data.

[0106] Here, the first sample data refers to the sample data used to train the first model. When training the first model, the first sample data is used as the input of the first model.

[0107] Optionally, the first sample data may take the form of a question-and-answer pair or other forms, and this embodiment of the application does not specifically limit this. The first sample data in the question-and-answer pair form includes two parts: a question and an answer, such as a doctor-patient dialogue or a chat dialogue.

[0108] Optionally, the first sample data can be selected in different content or form depending on the application scenario. For example, in a medical record generation scenario, the first sample data can be doctor-patient dialogue. In an article writing scenario, the first sample data can be article excerpts. In a code generation scenario, the first sample data can be code description text.

[0109] Step 304: The computer device uses the first sample data to call the first model to calculate the loss function and obtain the first loss function value.

[0110] Specifically, in step 304, the first sample data is input into the first model for forward prediction. The output data of the forward prediction is then compared with the corresponding real data to construct the first loss function. In other words, calling a model means inputting data into that model; for example, calling the first model means inputting data into the first model. Similarly, calling a model for prediction means inputting the input data into the first model for prediction and obtaining the output of the first model. Calculating the loss function by calling the first model involves inputting the input data into the first model, obtaining the output, and then constructing the loss function based on the output and the real values.

[0111] In some embodiments, after obtaining the first sample data, labeled data for the first sample data is configured. The computer device, based on the first sample data, invokes a first model to perform prediction and outputs a first predicted output value. The computer device calculates a first loss function value based on the first predicted output value and the labeled data.

[0112] The labeled data is used to indicate the true value corresponding to the function of the first model applied to the first sample data. Alternatively, the labeled data is used to indicate the true value corresponding to the output of the first model based on the first sample data. The labeled data is used to verify the deviation between the predicted output of the first model on the first sample data and the true value.

[0113] The first loss function value is used to measure the difference between the first predicted output value of the first model and the labeled data. Optionally, the loss function includes at least one of the mean squared error loss function, the mean absolute error loss function, and the cross-entropy loss function, but is not limited thereto, and the embodiments of this application do not specifically limit it.

[0114] Step 306: The computer device, based on the first predicted output value of the first model for the first sample data, calls the second model to calculate the loss function and obtain the second loss function value.

[0115] The first predicted output value refers to the output data obtained by inputting the first sample data into the first model and making a forward prediction by the first model.

[0116] Specifically, in step 306, the first sample data is input into the first model for forward prediction. The first predicted output value from the forward prediction is then input into the second model, which performs forward prediction to obtain the output value. This output value is then compared with the true value to construct the second loss function.

[0117] In some embodiments, after obtaining a first predicted output value predicted by a first model based on first sample data, first normalized data for the first predicted output value is configured. The computer device invokes a second model based on the first predicted output value to obtain a second predicted output value. The computer device calculates a second loss function value based on the second predicted output value and the first normalized data.

[0118] The first standardized data is used to indicate the true value corresponding to the function of the second model applied to the first predicted output value. The first standardized data is also used to verify the deviation between the predicted output of the second model and the true value of the first predicted output value.

[0119] For example, such as Figure 5 The diagram shows the data configuration, where the computer device configures the data through a data processing console. The computer device acquires the first sample data 501.

[0120] Step 308: After processing the first loss function value and the second loss function value, the computer device updates the model parameters of the first model to obtain the trained first model.

[0121] For example, the computer device weights the first loss function value and the second loss function value to obtain a third loss function value. Based on the third loss function value, the computer device updates the model parameters of the first model to obtain the trained first model.

[0122] The weighting process can involve calculating a weighted sum. The weight values ​​of the model can be configured according to actual needs; this embodiment of the application does not limit this.

[0123] In some embodiments, the computer device determines a first weight for a first loss function value and a second weight for a second loss function value based on first sample data. A third loss function value is then obtained based on the first loss function value, the first weight, the second loss function value, and the second weight.

[0124] Among them, the first weight and the second weight have an inverse relationship.

[0125] For example, the computer device determines the amount of training sample data based on the first sample data currently used for training, and obtains a first weight for the first loss function value based on the amount of training sample data corresponding to the first sample data and the total amount of sample data. Based on the first weight of the first loss function value, a second weight for the second loss function value is obtained.

[0126] For example, based on the first loss function value loss1 and the first weight The second loss function value (loss2) and the second weight. The resulting third loss function, loss3, can satisfy the following expression:

[0127]

[0128] Where N is the total number of sample data for this model training, n is the number of sample data for the current training, and T is a constant.

[0129] In some embodiments, during the training of the model, as the amount of sample data involved in the training increases, n gradually increases, causing the first weight to gradually decrease. The first weight exhibits a monotonically decreasing trend, that is, as the number of training iterations increases, the first weight gradually decreases. The value range is from 1 to 1. Since the first weight and the second weight have an inverse relationship, the first weight... Monotonically decreasing the weight of the first loss function value means gradually decreasing the weight of the second loss function value during training, while gradually increasing the weight of the second loss function value. The first weight... Minimum is By adjusting the first weight The loss function is monotonically decreased to achieve dynamic adjustment of the third loss function, loss3.

[0130] For the first weight The purpose of dynamic adjustment is as follows: taking the first model as a generative model and the second model as a quality control model as an example, during the model training process, the prediction output accuracy of the first model becomes higher and higher, while the quality control problems detected by the second model become fewer and fewer. Therefore, the weight parameters are dynamically adjusted along with the training process, so that the proportion of the first loss function in the third loss function decreases and the proportion of the second loss function in the third loss function increases, thereby enabling the first model to converge faster and improving the model training efficiency.

[0131] For example, the value of T ranges from [1, 5]. The value of T can be set according to the application scenario or training conditions. A smaller value of T indicates that the first loss function value is more important, and the training result of the first model is more biased towards the labeled data; that is, the second model has a smaller impact on the first model. A larger value of T indicates that the second loss function value is more important, and the training result of the first model is more biased towards the output result of the second model; that is, the second model has a larger impact on the first model.

[0132] In one possible implementation, there can be one or more second models. The example above only describes the scheme for calculating the third loss function in a scenario with only one second model. In practical applications, when there are multiple second models, weight values ​​can be configured for the first model and each second model, and then the loss functions of each model can be weighted and used as the third loss function. The detailed process will not be elaborated here.

[0133] In some embodiments, during the training process of the overall model (first model and second model), the network parameters in the model are updated based on the loss function value as a training metric until the loss function value converges, thereby obtaining the trained model.

[0134] For example, convergence of the loss function value means that the loss function value no longer changes, or that the error difference between two adjacent iterations during model training is less than a preset value, or that the number of training iterations of the model reaches a preset number, but is not limited thereto, and the embodiments of this application do not limit this.

[0135] Optionally, the target condition for training can be that the model reaches a target number of training iterations, which can be preset by the technician. Alternatively, the target condition for training can be that the loss value meets a target threshold condition, but it is not limited thereto, and the embodiments of this application do not limit it in this way.

[0136] In summary, the solution provided in this embodiment proposes a model training method. When constructing the loss function for training the first model, the loss functions corresponding to the first and second models with a supervision relationship are weighted and then the constructed loss function is used to update the model parameters of the first model. This constructed loss function combines the loss functions of the two models, reflecting the supervision relationship information between them. This allows the second model, which has a supervision relationship with the first model, to intervene in the training process of the first model, thereby ensuring the training accuracy of the two supervised models as a whole.

[0137] Furthermore, steps 302 to 308 described above describe the training process of the first model. In practical applications, the second model, which has a supervised relationship with the first model, also needs to be trained to improve its accuracy, such as... Figure 4 The flowchart shown illustrates the model training method. The model training method provided in this embodiment of the application is... Figure 3 Based on the model training method shown, steps 310 to 312 may also be included.

[0138] In the following steps, the execution order of steps 304 and 310 can be sequential, interleaved, or simultaneous, but is not limited thereto. This application embodiment does not specifically limit the execution order of steps 304 and 310. For example, step 304 can be executed first, followed by step 310; or step 310 can be executed first, followed by step 304; or steps 304 and 310 can be executed simultaneously; or step 304 can be executed for a first time period first, followed by step 310.

[0139] Step 310: The computer device uses the second sample data to call the second model to calculate the loss function and obtain the fourth loss function value.

[0140] The second sample data refers to the sample data used to train the second model. When training the second model, the second sample data is used as the input of the second model.

[0141] For example, the computer device uses a third model to make a prediction based on the first sample data, and uses the predicted output value of the third model as the second sample data. Optionally, the third model can be the first model, or it can be another model with the same or similar function as the first model.

[0142] Specifically, in step 310, the second sample data is input into the second model for forward prediction. The data output from the forward prediction is then compared with the actual data corresponding to the second sample data to construct a fourth loss function.

[0143] For example, when the second sample data is obtained by the prediction process of the first model, the second sample data is the first predicted output value. That is, when the second sample data is the first predicted output value, the second model is called to calculate the loss function based on the first predicted output value to obtain the fourth loss function value.

[0144] For example, if the second sample data is obtained by prediction processing of other models with the same or similar functions, the computer device calls the second model to calculate the loss function based on the second sample data, and obtains the fourth loss function value.

[0145] For example, after obtaining the second sample data, second normative data is configured for the second sample data. Based on the second sample data, the computer device invokes the second model to obtain a third predicted output value. Based on the third predicted output value and the second normative data, a fourth loss function value is calculated.

[0146] The second canonical data is used to indicate the true values ​​corresponding to the function of the second model applied to the second sample data. The second canonical data is used to verify the deviation between the predicted output of the second model and the true values ​​for the second sample data.

[0147] Step 312: The computer device updates the model parameters of the second model based on the fourth loss function value to obtain the trained second model.

[0148] For example, the computer device updates the model parameters of the second model based on the value of the fourth loss function to obtain the trained second model.

[0149] In summary, the solution provided in this embodiment proposes a model training method that simultaneously trains a second model that has a supervised relationship with the first model. When training the second model, it uses second sample data obtained from the prediction processing of the first sample data. This avoids collecting the dataset again, improving training efficiency, and also avoids the problem of poor overall model training accuracy caused by the data difference resulting from collecting two independent datasets.

[0150] For example, before training the first model and the second model, it is necessary to configure the training sample data corresponding to the first model and the second model respectively.

[0151] like Figure 5The diagram illustrates the data configuration. A computer device acquires first sample data 501 and performs forward prediction processing on the first sample data 501 using a third model to obtain second sample data 502. Based on the first sample data 501, labeled data 503 corresponding to the first sample data 501 is configured. Labeled data 503 is used to verify the prediction output deviation of the first model for the first sample data 501; that is, it is used to verify the deviation between the first predicted output value output by the first model based on the first sample data 501 and the labeled data 503. Optionally, the third model can be the first model or another model with the same or similar functions as the first model. When the third model is the first model, the second sample data 502 is the first predicted output value, and the configured standardized data 504 is used to verify the prediction output deviation of the second model for the first predicted output value; that is, it is used to verify the deviation between the second predicted output value output by the second model based on the first predicted output value and the standardized data 504. When the third model is not the first model, the second sample data 502 represents the predicted output value obtained by other models based on the first sample data 501. The configured canonical data 504 is used to verify the deviation of the second model's predicted output from the second sample data 502; that is, it is used to verify the deviation between the third predicted output value of the second model based on the second sample data 502 and the canonical data 504. The first sample data 501, labeled data 503, and canonical data 504 are combined into a data set to obtain the first training sample data 505 for training the first model. The second sample data 502 and canonical data 504 are combined into a data set to obtain the second training sample data 506 for training the second model. Figure 5 As can be seen, the first training sample data 505 and the second training sample data 506 are obtained from the same first sample data 501. By using the same first sample data 501 to support the training of two models with a supervised relationship, it is possible to avoid collecting two independent datasets, reduce the workload of data collection and preprocessing, and improve efficiency.

[0152] The following example illustrates the training sample data required for model training. Figure 6 As shown.

[0153] Taking a medical record-assisted generation scenario as an example, the computer device acquires the first sample data 601. For instance, the first sample data 601 is a doctor-patient dialogue, including:

[0154] "Doctor-Patient Dialogue"

[0155] "Hello, are you feeling unwell?"

[0156] I have a sore throat and a slight cough.

[0157] How long has it been?

[0158] 23 days, I guess.

[0159] Do you have phlegm?

[0160] have.

[0161] Do you have a lot of phlegm? What color is it?

[0162] It's a lot of thick, yellow phlegm.

[0163] Can you cough it up?

[0164] It's a bit sticky, so it's not easy to cough.

[0165] Do you have a fever?

[0166] It seems not. My temperature was 37°C last night.

[0167] Do you have a stuffy nose or runny nose?

[0168] No.

[0169] Do you have a headache? Is your body aching? Do your muscles ache all over?

[0170] No, I just feel quite tired.

[0171] Do you experience chest tightness, chest pain, or shortness of breath?

[0172] No.

[0173] Do you experience nausea, vomiting, abdominal pain, or diarrhea?

[0174] No.

[0175] Have you taken any medication?

[0176] Yeah, I've tried those pharyngitis tablets and cough syrup, but they didn't seem to work very well.

[0177] Have you caught a cold recently?

[0178] I took a shower a few days ago, so I might have caught a chill.

[0179] The first sample data 601 is processed using a third model to generate the second sample data 602, which is the outpatient medical record. The second sample data 602 includes:

[0180] {Outpatient Medical Record: {Chief Complaint: Sore throat with cough for 23 days. Present Illness: The patient reports a sore throat accompanied by cough 23 days ago. The cough produces yellow, sticky phlegm that is difficult to expectorate. The patient denies fever, but has had a temperature of 37.2°C. The patient denies nasal congestion, runny nose, headache, or muscle discomfort. The patient reports fatigue. The patient has not experienced chest tightness, chest pain, shortness of breath, nausea, vomiting, abdominal pain, or diarrhea. The patient has taken pharyngitis tablets and cough syrup without improvement. The patient recalls catching a cold after showering a few days prior.}}

[0181] Based on the first sample data 601, configure the expert annotation result 603 corresponding to the first sample data 601. Expert annotation result 603 includes:

[0182] {Outpatient Medical Record: {Chief Complaint: Sore throat with cough for 23 days. Present Illness: The patient developed a sore throat 23 days ago, accompanied by a cough with yellow purulent sputum that was difficult to expectorate. Since the onset of the illness, the body temperature has risen to 37.2°C. The patient denies chills, runny nose, headache, and general muscle aches. The patient feels fatigued. The patient denies chest tightness, chest pain, shortness of breath, nausea, vomiting, abdominal pain, and diarrhea. The patient has taken throat lozenges and cough syrup on their own, but the effect was not good. The patient recalls that the illness may have been caused by catching a cold after taking a bath a few days ago. Physical Examination: Not mentioned}}

[0183] The computer device generates first training sample data 604 for training the first model by combining the first sample data 601 and the expert annotation results 603 into a data set. The first training sample data 604 includes:

[0184] {Input:{Please generate a medical record based on the following doctor-patient dialogue: "Hello, what's wrong? I have a sore throat and a bit of a cough, how long has it been? About 23 days. Do you have phlegm?..."}

[0185] Output: {"The patient developed a sore throat and cough 23 days ago. The cough produced yellow purulent sputum that was difficult to expectorate. Since the onset of the illness, the patient's temperature has risen to 37.2°C. The patient denies chills, runny nose, headache, and general muscle aches. The patient reports fatigue and denies chest tightness, chest pain, shortness of breath, nausea, vomiting, abdominal pain, and diarrhea. The patient has self-medicated with pharyngitis tablets and cough syrup, but with little effect. The patient recalls that the chill may have been caused by catching a cold after taking a bath a few days prior."}}

[0186] By combining the second sample data 602 and the expert annotation results 603 into a data set, the second training sample data 605 for training the second model is obtained. The second training sample data 605 includes:

[0187] {Input: {Please conduct quality control on the following medical record content: "The patient reports a sore throat accompanied by a cough 23 days ago. The cough produces yellow, sticky phlegm that is difficult to expectorate. The patient denies fever, but has had a temperature rise to 37.2°C. The patient denies nasal congestion, runny nose, headache, or muscle discomfort. The patient reports fatigue. The patient has not experienced chest tightness, chest pain, shortness of breath, nausea, vomiting, abdominal pain, or diarrhea. The patient has taken pharyngitis tablets and cough syrup on their own, but with little effect. The patient recalls that the illness may have been caused by catching a cold after taking a bath a few days prior."}

[0188] Output: {"1. Writing standard category: (1) The description of muscle discomfort is unclear (2) The description of "I did not feel chest tightness, chest pain, shortness of breath, nausea, vomiting, abdominal pain, or diarrhea" is not standard"}}.

[0189] Once you have the training sample data required for model training, you can begin training the model.

[0190] Figure 7 This is a schematic diagram of a model training method provided in an exemplary embodiment of this application. The method can be executed by a computer device.

[0191] The computer device acquires first sample data 701 and inputs it into a first model 703 for forward prediction, obtaining a first predicted output value 705. Based on the first predicted output value 705 and labeled data, the computer device calculates a first loss function value 706. Simultaneously, after obtaining the first predicted output value 705, the computer device inputs it into a second model 704 for forward prediction, obtaining a second predicted output value 707. The first model 703 and the second model 704 have a supervised relationship. Based on the second predicted output value 707 and the first labeled data, the computer device calculates a second loss function value 708. The computer device weights the first loss function value 706 and the second loss function value 708 to obtain a third loss function value 711. Based on the third loss function value 711, the computer device updates the model parameters of the first model 703. Furthermore, the computer device uses the third model to predict the first sample data 701, obtaining second sample data 702. The second sample data 702 is input into the second model 704 for forward prediction, resulting in a third predicted output value 709. Based on the third predicted output value 709 and the second normalized data, the computer device calculates a fourth loss function value 710. Based on the fourth loss function value 710, the computer device updates the model parameters of the second model 704.

[0192] The model training method provided in this application will be described in detail below with specific examples.

[0193] Taking the scenario of medical record-assisted generation as an example, then Figure 7The corresponding parameters are as follows: the first sample data 701 is a doctor-patient dialogue; the first model 703 is used to predict and generate medical records based on the doctor-patient dialogue; and the second model 704 is used to perform quality checks on the medical records predicted by the first model 703. Specifically, the first prediction output value 705 is the first predicted medical record, the second prediction output value 707 is the first medical record quality check data, and the third prediction output value 709 is the second medical record quality check data. The specific steps for model training are as follows: the doctor-patient dialogue is input into the first model 703 for prediction to obtain the first predicted medical record. The computer device calculates the first loss function value 706 based on the first predicted medical record and the labeled data. Simultaneously, after obtaining the first predicted medical record, the computer device inputs the first predicted medical record into the second model 704 for prediction to obtain the first medical record quality check data. The computer device calculates the second loss function value 708 based on the first medical record quality check data and the first standardized data. The computer device weights and processes the first loss function value 706 and the second loss function value 708 to obtain a third loss function value 711. Based on the third loss function value 711, the computer device updates the model parameters of the first model 703. Furthermore, the computer device performs predictive processing on the doctor-patient dialogue to obtain a second predicted medical record. This second predicted medical record is input into the second model 704 for prediction, resulting in second medical record quality inspection data. Based on the second medical record quality inspection data and the second standardized data, the computer device calculates a fourth loss function value 710. Based on the fourth loss function value 710, the computer device updates the model parameters of the second model 704. This completes the training of the first model 703 and the second model 704.

[0194] Taking the writing scenario of an article as an example, then Figure 7 The corresponding parameters are as follows: the first sample data 701 is an article fragment; the first model 703 is used to predict and generate an article based on the article fragment; and the second model 704 is used to perform quality checks on the article predicted and generated by the first model 703. Specifically, the first prediction output value 705 is the first predicted article, the second prediction output value 707 is the quality check data for the first article, and the third prediction output value 709 is the quality check data for the second article. The specific steps for model training are the same as those in the medical record-assisted generation scenario, the only difference being the change in sample data; therefore, the training steps will not be elaborated upon here.

[0195] Taking code generation as an example, then Figure 7The corresponding parameters are as follows: the first sample data 701 is the code description text; the first model 703 is used to predict and generate code based on the code description text; and the second model 704 is used to perform quality checks on the code predicted and generated by the first model 703. Specifically, the first prediction output value 705 is the first predicted code, the second prediction output value 707 is the first code quality check data, and the third prediction output value 709 is the second code quality check data. The specific steps for model training are the same as those in other scenarios, the only difference being the change in sample data; therefore, the training steps will not be elaborated upon here.

[0196] The above embodiments illustrate the model training method. The following will further describe the method of data processing based on the trained model.

[0197] Furthermore, after the aforementioned training of the model is completed, i.e., after the loss function converges, the model can be used for data processing. Embodiments of this application provide a data processing method. This data processing method can be used alone or in combination with the above-described methods. Figure 3 or Figure 4 The model training method described herein is not limited in this application.

[0198] like Figure 8 The flowchart shown illustrates a data processing method applied to a data processing system. The system includes a first model and a second model with a supervised relationship. The first and second models are trained using the model training method described in the above embodiments. Specifically, the first model is trained based on a target loss function, which is determined by the loss functions of the first and second models. The data processing method provided in this application includes:

[0199] Step 802: The data processing system acquires the raw data.

[0200] Raw data refers to the data that is to be processed.

[0201] Optionally, in the medical record generation scenario, the raw data is doctor-patient dialogue. In the article writing scenario, the raw data is article fragments. In the code generation scenario, the raw data is code description text. However, these are not the only scenarios.

[0202] Step 804: The data processing system calls the first model to generate data from the original data, and obtains the predicted data.

[0203] Here, the predicted generated data refers to the result of the forward prediction output of the first model based on its functions.

[0204] For example, after obtaining the raw data, the raw data is input into the first model to generate data, and the predicted generated data corresponding to the raw data is obtained.

[0205] For example, in a medical record generation scenario, the first model predicts and generates medical records based on doctor-patient dialogue. In an article writing scenario, the first model predicts and generates articles based on article fragments. In a code generation scenario, the first model predicts and generates code based on code description text.

[0206] Step 806: The data processing system calls the second model to perform data quality inspection on the predicted data, and obtains the predicted quality inspection data.

[0207] Among them, the predicted quality inspection data refers to the results of the forward prediction output of the second model based on its functions.

[0208] For example, after obtaining the prediction generation data output by the first model, the prediction generation data is input into the second model for data quality inspection to obtain prediction quality inspection data.

[0209] For example, in a medical record generation scenario, the second model performs quality checks on the medical records predicted and generated by the first model, outputting issues such as writing style, treatment safety, and medication compliance. In an article writing scenario, the second model performs quality checks on the articles predicted and generated by the first model, outputting issues such as writing errors and illogical sentences. In a code generation scenario, the second model performs quality checks on the code predicted and generated by the first model, outputting issues such as code style, logical errors, and parts of the code that need optimization.

[0210] In summary, the solution provided in this embodiment proposes a data processing method that uses two models to generate and inspect data sequentially. Based on the supervision relationship between the two models, the second model can identify abnormal or redundant data in the data generated by the first model, thereby improving the quality of data generation.

[0211] The foregoing mainly describes the solution provided in this application. Accordingly, this application also provides a model training apparatus for implementing the above-described method embodiments.

[0212] In some embodiments, the model training apparatus includes hardware structures and / or software modules corresponding to the execution of each function in order to achieve the above-described functions. Those skilled in the art will readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0213] This application embodiment can divide the model training device into functional modules according to the above method embodiment. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0214] In some embodiments, this application provides a model training apparatus for implementing the functions of the model training apparatus in the above-described model training method embodiments. For example... Figure 9 The diagram shows the structure of the model training device. The model training device may include a calling module 901, a calculation module 902, and a training module 903.

[0215] Among them, module 901 is used to execute Figure 3 The operation in step 304 or step 306 of the illustrated method, or... Figure 4 The illustrated method includes step 310. The calculation module 902 is used to execute... Figure 3 or Figure 4 The illustrated method includes step 308, which involves weighting the loss functions to obtain the third loss function value. Training module 903 is used to execute this operation. Figure 3 or Figure 4 In the illustrated method, step 308 involves updating the model parameters of the first model based on the value of the third loss function, or... Figure 4 The illustrated method involves updating the model parameters of the second model in step 312.

[0216] In some embodiments, this application provides a data processing apparatus for implementing the functions of the data processing apparatus in the above-described data processing method embodiments. For example... Figure 10 The diagram shows the structure of the data processing device. The data processing device may include an acquisition module 1001 and a calling module 1002.

[0217] Module 1001 is used for execution Figure 8 The illustrated method includes step 802. Module 1002 is called to execute... Figure 8 The illustrated method includes steps 804 and 806.

[0218] like Figure 11As shown, the computer device provided in this application embodiment may include a processor 1101, a bus 1102, a communication interface 1103, and a memory 1104. The processor 1101, the memory 1104, and the communication interface 1103 communicate with each other via the bus 1102. It should be understood that this application does not limit the number of processors and memories in the computer device.

[0219] Bus 1102 can be a PCI bus, an Extended Industry Standard Architecture (EISA) bus, or a UB bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 11 The bus 1102 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 1102 may include a path for transmitting information between various components of a computer device (e.g., memory 1104, processor 1101, communication interface 1103).

[0220] Processor 1101 may include any one or more processors such as CPU, graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).

[0221] The memory 1104 may include volatile memory, such as random access memory (RAM). The processor 1101 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).

[0222] The communication interface 1103 uses transceiver modules, such as, but not limited to, network interface cards and transceivers, to enable communication between computer devices and other devices or communication networks.

[0223] The memory 1104 stores executable program code, which the processor 1101 executes to implement the functions of the model training device, data processing device, or CPU core in the aforementioned method embodiments. That is, the memory 1104 stores instructions for executing the aforementioned model training method or data processing method.

[0224] In another aspect, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is loaded and executed by a processor to implement the model training method or data processing method provided in the above-described method embodiments.

[0225] On the other hand, a computer program product is provided, which includes a computer program or instructions that, when executed by a processor, implement the model training method or data processing method described above.

[0226] In another aspect, a chip system is provided, including at least one processor and at least one interface circuit, wherein the at least one interface circuit is used to perform transceiver functions and send instructions to the at least one processor, wherein when the at least one processor executes instructions, the at least one processor performs to implement the model training method as described above, or the data processing method as described above.

[0227] The method steps in this embodiment can be implemented in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, portable hard disks, CD-ROMs, or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Alternatively, the ASIC can reside in a computer device. Of course, the processor and storage medium can also exist as discrete components in the computer device.

[0228] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When the computer program or instructions are loaded and executed on a computer, the processes or functions described in the embodiments of this application are performed entirely or partially. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user equipment, or other programmable device. The computer program or instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, the computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via wired or wireless means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; it can also be an optical medium, such as a digital video disc (DVD); or it can be a semiconductor medium, such as a solid-state drive (SSD). The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A model training method, characterized in that, The method includes: Based on the first sample data, the first model is called to calculate the loss function and obtain the first loss function value; Based on the first predicted output value of the first model for the first sample data, the second model is called to calculate the loss function and obtain the second loss function value. The first model and the second model have a supervision relationship. The first loss function value and the second loss function value are processed to obtain the third loss function value; Based on the value of the third loss function, the model parameters of the first model are updated to obtain the trained first model.

2. The method according to claim 1, characterized in that, The method further includes: configuring labeled data for the first sample data, wherein the labeled data is used to indicate the true value corresponding to performing the function of the first model on the first sample data; The step of calculating the loss function based on the first sample data and calling the first model to obtain the first loss function value includes: Based on the first sample data, the first model is invoked to make a prediction, and the first predicted output value is output. The first loss function value is calculated based on the first predicted output value and the labeled data.

3. The method according to claim 1 or 2, characterized in that, The first loss function value and the second loss function value are processed to obtain the third loss function value, including: Based on the first sample data, determine the first weight of the first loss function value and the second weight of the second loss function value; The third loss function value is obtained based on the first loss function value, the first weight, the second loss function value, and the second weight.

4. The method according to claim 3, characterized in that, The first weight and the second weight are inversely related.

5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: configuring first normative data for the first predicted output value, wherein the first normative data is used to indicate the true value corresponding to the function of the second model applied to the first predicted output value; The step of calculating the second loss function value by calling the second model based on the first predicted output value of the first model for the first sample data, and obtaining the second loss function value, includes: Based on the first predicted output value, the second model is invoked to obtain the second predicted output value; The second loss function value is calculated based on the second predicted output value and the first standardized data.

6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: Based on the first sample data, the third model is invoked to make a prediction, and the predicted output value of the third model is used as the second sample data. Based on the second sample data, the second model is invoked to calculate the loss function, and the fourth loss function value is obtained; Based on the value of the fourth loss function, the model parameters of the second model are updated to obtain the trained second model.

7. The method according to claim 6, characterized in that, The method further includes: configuring second normative data for the second sample data, wherein the second normative data is used to indicate the true value corresponding to the function of the second model applied to the second sample data; The step of calculating the fourth loss function value by calling the second model based on the second sample data includes: Based on the second sample data, the second model is invoked to obtain the third predicted output value; The fourth loss function value is calculated based on the third predicted output value and the second standardized data.

8. The method according to any one of claims 1 to 7, characterized in that, The first sample data is a doctor-patient dialogue; the first model is used to predict and generate medical records based on the doctor-patient dialogue; and the second model is used to perform quality control on the medical records predicted and generated by the first model. Alternatively, the first sample data is an article fragment, the first model is used to predict and generate an article based on the article fragment, and the second model is used to perform quality checks on the article predicted and generated by the first model. Alternatively, the first sample data may be code description text, the first model may be used to predict and generate code based on the code description text, and the second model may be used to perform quality checks on the code predicted and generated by the first model.

9. A data processing method, characterized in that, The method is applied to a data processing system, the system comprising a first model and a second model having a supervision relationship; the method includes: Obtain the raw data; The first model is invoked to generate data from the original data, resulting in predicted data. The second model is invoked to perform data quality inspection on the predicted generated data, resulting in predicted quality inspection data. The first model is trained based on a target loss function, which is determined by the loss function of the first model and the loss function of the second model.

10. The method according to claim 9, characterized in that, The original data is doctor-patient dialogue. The first model is used to predict and generate medical records based on the doctor-patient dialogue. The second model is used to perform quality inspection on the medical records predicted and generated by the first model. Alternatively, the original data is an article fragment, the first model is used to predict and generate an article based on the article fragment, and the second model is used to perform quality checks on the article predicted and generated by the first model; Alternatively, the original data is code description text, the first model is used to predict and generate code based on the code description text, and the second model is used to perform quality inspection on the code predicted and generated by the first model.

11. A model training device, characterized in that, The device includes: The calling module is used to call the first model to calculate the loss function based on the first sample data, and obtain the first loss function value; The calling module is used to call the second model to calculate the loss function based on the first predicted output value of the first model for the first sample data, and obtain the second loss function value. The first model and the second model have a supervision relationship. The calculation module is used to process the first loss function value and the second loss function value to obtain the third loss function value; The training module is used to update the model parameters of the first model based on the value of the third loss function, so as to obtain the trained first model.

12. A data processing apparatus, characterized in that, The device includes: The acquisition module is used to acquire raw data; The calling module is used to call the first model to generate data from the original data and obtain the predicted generated data. The calling module is used to call the second model to perform data quality inspection on the predicted generated data, and obtain the predicted quality inspection data; The first model is trained based on a target loss function, which is determined by the loss function of the first model and the loss function of the second model.

13. A computer device, characterized in that, The computer device includes a processor and a memory, wherein the memory stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the model training method as described in any one of claims 1 to 8, or the data processing method as described in claim 9 or 10.

14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to implement the model training method as described in any one of claims 1 to 8, or the data processing method as described in claim 9 or 10.

15. A computer program product, characterized in that, The computer program product includes a computer program or instructions that, when executed by a processor, implement the model training method as described in any one of claims 1 to 8, or the data processing method as described in claim 9 or 10.