A method, apparatus, electronic device, and storage medium for model training.

By dividing samples into cross-samples and non-cross-samples in a federated learning system, using the initial model to determine auxiliary labels and perform distillation learning, the problem of low model training efficiency and accuracy caused by sample data gaps is solved. This enables the training of an accurate target model even when sample data gaps are large, thus improving model training efficiency and accuracy.

CN117093862BActive Publication Date: 2025-11-14ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310983254.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-04
Publication Date
2025-11-14
Estimated Expiration
2043-08-04

AI Technical Summary

Technical Problem

In federated learning systems, the large differences between the sample data stored in each worker node result in low model training efficiency and accuracy.

Method used

By dividing cross samples and non-cross samples in a federated learning system, auxiliary labels for cross samples are determined using a pre-trained initial model. The samples are then input into the classification layer of the target model. The target model is trained by combining the original and auxiliary labels of the cross samples and using a hybrid expert network structure for distillation learning.

Benefits of technology

Even with significant differences in sample data, an accurate target model can still be trained, improving model training efficiency and accuracy while ensuring model security and privacy protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117093862B_ABST
    Figure CN117093862B_ABST
Patent Text Reader

Abstract

This specification discloses a method, apparatus, electronic device, and storage medium for model training. Based on the concept of federated learning, it identifies cross-samples and non-cross-samples in the first sample. Then, using an initial model trained on the first and second samples, it determines the auxiliary labels for the cross-samples. The first sample is then input into the classification layer of the target model. Based on the classification result of the first sample and the prediction layers corresponding to each preset classification in the target model, the predicted classification result of the first sample is obtained. Finally, the target model is trained based on the labels of the cross-samples, the auxiliary labels, and the labels of the non-cross-samples. When the first and second samples contain few cross-samples, an accurate target model can also be trained based on the knowledge of the second sample in the pre-trained initial model and the first samples stored in the first node. This ensures both the privacy of the data and the accuracy of the trained target model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to the field of computer technology, and in particular to a method, apparatus, electronic device, and storage medium for model training. Background Technology

[0002] With the development of computer technology and people's increasing concern for their own privacy data, federated learning has been widely used in the field of model training.

[0003] Federated learning systems typically consist of a parameter server and multiple worker nodes. Each worker node stores different sample data, while the parameter server stores model parameters. When a model training task is required, the parameter server sends the model parameters and model structure to each worker node. The worker nodes then deploy the model based on these parameters and structure, determine the model gradient using their stored sample data, and return the gradient to the parameter server. The parameter server updates its stored model parameters based on the received gradients from the worker nodes and sends the updated parameters back to the worker nodes, thus completing the model training task.

[0004] However, when there is a large difference between the sample data stored on each working node, there may be situations where an accurate model cannot be trained, resulting in low model training efficiency and accuracy.

[0005] Based on this, this specification provides a model training method. Summary of the Invention

[0006] This specification provides a method, apparatus, electronic device, and storage medium for model training to improve model training efficiency and the accuracy of the trained model.

[0007] The following technical solution is adopted in this specification:

[0008] This specification provides a method for model training applied to a first node in a federated learning system. The system includes a first node and a second node. The first node stores first samples, and the second node stores second samples. At least a portion of the first samples and at least a portion of the second samples correspond to the same user. The method includes:

[0009] From each of the first samples, cross samples and non-cross samples are determined, wherein the cross samples are used to characterize the existence of a second sample that corresponds to the same user as the cross sample;

[0010] An initial model is determined based on each of the first samples and each of the second samples, and the auxiliary annotations of the cross samples are determined using the initial model;

[0011] For each first sample, the first sample is input into the classification layer of the target model to be trained, and the classification result output by the classification layer is obtained. The classification result is used to characterize whether the first sample is a cross sample.

[0012] Based on the classification results and the prediction layers corresponding to each preset category in the target model, the target prediction result of the first sample is determined, wherein each preset category includes cross-type and non-cross-type.

[0013] The target model is trained based on the target prediction results of the cross samples, the annotations and auxiliary annotations of the cross samples, and the target prediction results and annotations of the non-cross samples.

[0014] This specification provides an apparatus for model training, the apparatus being applied to a first node in a federated learning system, the system comprising a first node and a second node, the first node storing each first sample, the second node storing each second sample, at least a portion of the first samples and at least a portion of the second samples corresponding to the same user, the apparatus comprising:

[0015] A sample determination module is used to determine cross samples and non-cross samples from the first samples, wherein the cross samples are used to characterize the existence of a second sample that corresponds to the same user as the cross sample;

[0016] The annotation determination module is used to determine the initial model trained based on each first sample and each second sample, and to determine the auxiliary annotations for each cross sample through the initial model;

[0017] The classification module is used to input each first sample into the classification layer of the target model to be trained, and obtain the classification result output by the classification layer. The classification result is used to characterize whether the first sample is a cross sample.

[0018] The prediction module is used to determine the target prediction result of the first sample based on the classification result and the prediction layer corresponding to each preset classification in the target model, wherein each preset classification includes at least cross-type and non-cross-type.

[0019] The training module is used to train the target model based on the target prediction results of the cross samples, the annotations and auxiliary annotations of the cross samples, and the target prediction results and annotations of the non-cross samples.

[0020] This specification provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the above-described method for training the model.

[0021] This specification provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method for training the aforementioned model.

[0022] The above-mentioned technical solutions adopted in this specification can achieve the following beneficial effects:

[0023] In the model training method provided in this specification, the first sample stored in the first node is divided into cross samples and non-cross samples. Then, the auxiliary labels of the cross samples are determined by the initial model trained based on the first sample and the second sample. The first sample is input into the classification layer of the target model. Based on the classification result of the first sample and the prediction layer corresponding to each preset classification in the target model, the predicted classification result of the first sample is obtained. Finally, the target model is trained based on the labels of the cross samples, the auxiliary labels, and the labels of the non-cross samples.

[0024] Even when the first and second samples contain few cross samples, an accurate target model can still be trained based on the knowledge of the second sample in the pre-trained initial model and the first samples stored in the first node, thus ensuring the training efficiency and the accuracy of the trained target model. Attached Figure Description

[0025] The accompanying drawings, which are included to provide a further understanding of this specification and form part of this specification, illustrate exemplary embodiments and their descriptions, serving to explain this specification and do not constitute an undue limitation thereof.

[0026] In the picture:

[0027] Figure 1 This is a flowchart illustrating one of the model training methods described in this specification.

[0028] Figure 2 This is a schematic diagram of the structure of one target model in this specification;

[0029] Figure 3 A schematic diagram of a model training device provided in this specification;

[0030] Figure 4 This specification provides a corresponding Figure 1 A schematic diagram of an electronic device. Detailed Implementation

[0031] To make the objectives, technical solutions, and advantages of this specification clearer, the technical solutions of this specification will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this specification.

[0032] It should be noted that all actions involving the acquisition of signals, information, or data in this manual are performed in accordance with the relevant data protection laws and regulations of the locality and with authorization from the owner of the relevant device.

[0033] Currently, with the development of computer technology and people's increasing attention to their own privacy data, how different institutions can share data and achieve win-win cooperation at the model level while ensuring the information security of the user data they store is one of the technical problems that needs to be solved.

[0034] One of the most common methods to solve the above-mentioned technical problems is to train the model through federated learning. Federated learning can enable multi-party joint modeling under the premise that the local data stored by each party participating in the federated learning is not separate, and the joint training of the model is achieved by exchanging intermediate model results among different parties.

[0035] Based on this, this specification provides a model training method. Based on the idea of ​​federated learning, a target model with a hybrid expert model structure is deployed in the first node. Then, based on the initial model trained using the knowledge from the first and second nodes, the target model undergoes distillation training. This allows for the training of an accurate target model using the samples stored in the first node, even when there are significant differences between the sample data stored in each worker node. Specifically, the significant differences between the sample data stored in each worker node mean that the number of sample data corresponding to the same user stored in each worker node is relatively small.

[0036] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.

[0037] Figure 1 This is a flowchart illustrating a model training method described in this specification, which specifically includes the following steps:

[0038] S100: From each of the first samples, determine cross samples and non-cross samples, wherein the cross samples are used to characterize the existence of a second sample that corresponds to the same user as the cross sample.

[0039] In one or more embodiments provided in this specification, the model training method can be applied to the first node in a federated learning system. Therefore, the execution of this model training method can be performed by the first node used to train the model. The first node can be an electronic device such as a server or a smart terminal.

[0040] Furthermore, after the target model has been trained, to ensure the security of the model structure and parameters, the node using the target model to predict the data to be predicted can be the first node or other nodes trusted by the first node. The specific node on which the trained target model is deployed to perform the prediction task can be set as needed; this specification does not impose any restrictions on this.

[0041] For ease of description, the following explanations will use the execution process of the model training method at the first node and the process of using the trained target model to perform tasks as examples.

[0042] Generally, privacy-preserving computation and data security are required in various scenarios. Typically, the characteristics of data stored by a single data holder are constrained by the type of business transactions between that data holder and the users. Therefore, even if a data holder has a relatively large user base, the data it stores may still suffer from a lack of unique characteristics. In other words, for each data holder, the sample data stored by that data holder may correspond to the same users as the sample data stored by other data holders, but the feature dimensions of the sample data stored by that data holder will differ from those of the sample data stored by other data holders.

[0043] In this case, federated learning can be used to determine the cross samples corresponding to the same user among the data holders based on the sample data stored by multiple data holders. Then, based on the feature enhancement brought about by the cross samples, a more accurate model can be trained.

[0044] In the model training method provided in this specification, both the first node and the second node can be data holders storing sample data. The functionality of the target model trained using this method can vary depending on the scenario in which it is applied. For example, when applied to a risk control scenario, the sample data stored in the first node could be the verification method used when a user logs into the platform, while the sample data stored in the second node could be user data used when performing business transactions. Similarly, when applied to a text evaluation scenario, the sample data stored in the first node could be text data written by the user, while the sample data stored in the second node could be user profile information or similar data.

[0045] It is evident that data held by different data holders may differ in terms of data feature dimensions, but overlap in terms of the user they correspond to. In other words, the sample data stored by each node in this model training system may correspond to the same user, but to different data feature dimensions. As mentioned earlier, a more accurate model can be trained based on the cross-samples between nodes corresponding to the same user.

[0046] Specifically, let's take an example where this federated learning system contains only one first node and one second node. Both the first and second nodes can receive model training requests.

[0047] The second node can then determine the sample features corresponding to each of its stored second samples based on the model training request, and send the determined sample features of each second sample to the first node.

[0048] The first node can receive the sample features of each second sample sent by the second node and determine the sample identifier of each second sample.

[0049] Then, based on the sample identifier of each second sample, the first node whose sample identifier is the same as the sample identifier of the second sample is determined from the first samples stored by the first node itself, that is, the first sample and the second sample corresponding to the same user are determined.

[0050] Finally, the first node can determine that the first sample corresponding to the same user as the second sample is a cross sample, and the first sample not corresponding to the same user as the second sample is a non-cross sample. That is, a cross sample is used to characterize the existence of a second sample corresponding to the same user as the cross sample, and a non-cross sample is used to characterize the absence of a second sample corresponding to the same user as the cross sample.

[0051] S102: Determine an initial model trained based on each of the first samples and each of the second samples, and determine the auxiliary annotations for the cross samples using the initial model.

[0052] In one or more embodiments provided in this specification, to avoid network failures during model deployment that prevent different parts of the model from being deployed in the first and second nodes, the initial model can be deployed only in the first node. However, because a large gap exists between the first and second nodes, an accurate initial model cannot be trained. Therefore, in this specification, a hybrid expert network structure is used to construct the target model, and distillation learning is performed on the trained initial model to enable the first node to train an accurate target model based on the knowledge of the first and second samples.

[0053] Therefore, the first node can determine the pre-trained initial model and use the initial model to determine the auxiliary labels for the cross samples.

[0054] Specifically, the first node may pre-store an initial model trained based on each first sample in the first node and each second sample in the second node. This initial model may be trained based on cross-samples between the first and second samples.

[0055] Therefore, after determining the cross sample, the first node can use the cross sample as input to the initial model to obtain the auxiliary label of the cross sample.

[0056] Therefore, for each first sample in the first node, if the first sample is a cross sample, then the first sample has two labels: the original label and the auxiliary label. If the first sample is a non-cross sample, then the first sample only has one label: the original label.

[0057] S104: For each first sample, input the first sample into the classification layer of the target model to be trained, and obtain the classification result output by the classification layer. The classification result is used to characterize whether the first sample is a cross sample.

[0058] In one or more embodiments provided in this specification, as described above, the target model deployed in the first node may be a hybrid expert network structure. Therefore, the target model may at least include a classification layer and prediction layers corresponding to each preset classification, such as... Figure 2 As shown.

[0059] Figure 2 This is a schematic diagram of the target model provided in this specification. The target model includes a classification layer, a prediction layer corresponding to preset classification 1, and a classification layer corresponding to preset classification 2. Therefore, the first node can take each first sample as input and input it into the classification layer of the target model to be trained, obtaining the classification result output by that classification layer.

[0060] The classification result can be used to indicate whether the first sample is a cross-category sample. The classification result can be the sample type corresponding to the first sample: that is, a cross-category sample or a non-cross-category sample. It can also be the probability that the first sample belongs to each preset category. Taking the preset categories as including cross-category and non-cross-category types as an example, the classification result can be the probability that the first sample belongs to the cross-category type and the probability that it belongs to the non-cross-category type.

[0061] S106: Based on the classification results and the prediction layers corresponding to each preset classification in the target model, determine the target prediction result of the first sample, wherein each preset classification includes cross-type and non-cross-type.

[0062] In one or more embodiments provided in this specification, after determining the classification result, the first node can determine the target prediction result of the first sample based on the classification result and the prediction layers corresponding to each preset classification in the target model.

[0063] Specifically, let's take the classification result as an example to indicate whether the first sample is a cross sample.

[0064] When the first sample is a cross-sample, the first node can determine the sample features of the first sample and use these features as input to the prediction layer corresponding to the cross-type in the target model. The output of the prediction layer corresponding to the cross-type is then used as the target prediction result for the first sample.

[0065] Similarly, when the first sample is a non-crossing sample, the first node can determine the sample features of the first sample and use these features as input to the prediction layer corresponding to the non-crossing type in the target model. The output of the prediction layer corresponding to the non-crossing type is then used as the target prediction result for the first sample.

[0066] Of course, the classification result can be the probability that the first sample belongs to each preset category. Therefore, after determining the classification result, the first node can determine the sample features of the first sample and use these features as input, inputting them into the prediction layers corresponding to each preset category in the target model, respectively, to obtain the prediction results output by each prediction layer. Then, based on the probability that the first sample belongs to each preset category and the prediction results output by the prediction layers of each preset category, the first node can determine the target prediction result of the first sample (e.g., ...). Figure 2 ).

[0067] The specific method for determining the target prediction result of the first sample based on the classification results and the prediction layers corresponding to each predicted category in the target model can be set as needed, and this manual does not impose any restrictions on it.

[0068] S108: Train the target model based on the target prediction results of the cross samples, the annotations and auxiliary annotations of the cross samples, and the target prediction results and annotations of the non-cross samples.

[0069] In one or more embodiments provided in this specification, after determining and processing the training samples, the first node can train the model based on the annotations of the training samples.

[0070] Specifically, for each first sample, if the first sample is a cross sample, the first node can determine the difference between the target prediction result and the annotation of the first sample, as the first difference. It can also determine the difference between the target prediction result and the auxiliary annotation of the first sample, as the second difference. Finally, it determines the sum of the first difference and the second difference, as the first loss.

[0071] Meanwhile, if the first sample is a non-cross sample, the first node can determine the second loss based on the difference between the target prediction result of the first sample and the label of the first sample.

[0072] Finally, the first node can determine the total loss based on the first loss and the second loss, and train the target model with the goal of minimizing the total loss.

[0073] Taking l1 as the first loss and l2 as the second loss as an example, the total loss can be l. z =l1+l2, where l1=l τ=1 (Y A ,f)+l τ=1 (Y B ,f), τ=1 is used to characterize that the first sample is a crossover sample, Y A The original label used to characterize this first sample, Y B The auxiliary label is used to characterize the first sample, f is used to characterize the target prediction result of the first sample, and l is used to characterize the loss function. Similarly, l2 = l τ=0 (Y A ,f), where τ=0 is used to characterize the first sample as a non-crossover sample, Y A The original label is used to characterize the first sample, f is used to characterize the target prediction result of the first sample, and l is used to characterize the loss function.

[0074] After the target model is trained, since the target model itself is deployed on the first node, the first node can directly make predictions on the data to be predicted based on the trained target model, thus avoiding the need to transmit the trained target model and preventing the leakage of the target model's structure and parameters.

[0075] The method of predicting data based on the target model can be as follows: input the data to be predicted into the target model, determine the classification result of the data to be predicted through the classification layer of the target model, and then determine the target prediction result of the data to be predicted through the prediction layers corresponding to each preset classification in the target model and the classification result of the data to be predicted.

[0076] based on Figure 1The described model training method involves dividing the first samples stored in the first node into cross-samples and non-cross-samples. Then, using an initial model pre-trained based on the first and second samples, auxiliary labels for the cross-samples are determined. The first samples are then input into the classification layer of the target model to be trained. The predicted classification result of the first sample is obtained by combining the classification result of the first sample with the prediction layers corresponding to each preset classification in the target model. Finally, the target model is trained using distillation based on the original and auxiliary labels of the cross-samples, as well as the original labels of the non-cross-samples. Even when the first and second samples contain few cross-samples, an accurate target model can be trained based on the knowledge of the second samples in the pre-trained initial model and the first samples stored in the first node, ensuring both training efficiency and the accuracy of the trained target model.

[0077] In other words, the training method involves pre-training an initial model based on the first samples stored in the first node and the second samples stored in the second node. This initial model is then subjected to distillation learning to obtain the target model with a hybrid expert network structure. Even when the number of cross-samples in the first and second samples is small, accurate cross-samples can still be trained based on the knowledge of the first samples and the initial model regarding the second samples. This solves the technical problem that training a hybrid expert network structure model based only on data of the same dimension would prevent the training of a target model incorporating knowledge of both the first and second samples. It also addresses the technical problem that when only the initial model is distilled to obtain the target model without considering the model structure itself, the trained model structure cannot accurately learn the knowledge of the second samples because only a portion of the first samples have auxiliary annotations.

[0078] Furthermore, the initial model in step S102 can be trained in the following manner:

[0079] Specifically, the first node can be deployed with a complete initial model, and the second node can be deployed with a feature extraction layer of the initial model.

[0080] Therefore, the first node can determine the sample features of each first sample through the feature extraction layer of the initial model.

[0081] Meanwhile, the second node can determine the sample features of each second sample through the feature extraction layer of the initial model.

[0082] Then, the second node can send the sample features of each determined second sample to the first node.

[0083] The first node can receive the sample features of each second sample and determine the sample identifier corresponding to each second sample.

[0084] Next, the first node can determine the first and second samples corresponding to the same user from each first sample and each second sample based on the sample flags of each second sample and the sample flags of each first sample, and use them as the first cross sample and the second cross sample.

[0085] Then, the first node can use the label of the first cross sample as the label of the second cross sample. Thus, the first node can store the labeled first sample and the labeled second cross sample.

[0086] Finally, the first node can use each first sample and each second cross sample as samples in the training set for training the initial model. For each sample in the training set, the sample features of that sample are input into the prediction layer of the initial model to obtain the initial prediction result output by the initial model. Based on the initial prediction results and their labels corresponding to each sample in the training set, the loss is determined, and the model parameters of the initial model are adjusted according to the loss. At the same time, the first node can send the determined loss to the second node, which then adjusts the model parameters of its stored feature extraction layer according to the loss.

[0087] The above process is repeated until the preset iteration termination condition is reached, and the initial model that has been trained can be obtained.

[0088] Furthermore, the target model in this specification may also include feature extraction layers corresponding to each preset category.

[0089] Specifically, the first node can take each first sample as input and input it into the feature extraction layer corresponding to each preset category in the target model to obtain the features of the first sample output by each feature extraction layer.

[0090] Then, the first node can combine the determined features and input the combination result into the classification layer of the target model to obtain the classification result output by the classification layer.

[0091] Finally, based on the classification result and the features of the first sample, the sample features of the first sample are determined. For example, taking the probability that the first sample belongs to each preset category as the classification result, the first node can, for each preset category, use the probability of the first sample belonging to that preset category as the weight of the first sample corresponding to that preset category, and then perform a weighted average based on the features corresponding to each preset category and the weight of each preset category, and use the result as the sample features of the first sample. Of course, the first node can also determine the sample type corresponding to the first sample based on the classification result, and use the features output by the feature extraction layer corresponding to that sample type as the sample features of the first sample. The specific method for determining the sample features of the first sample can be set as needed, and this specification does not impose any restrictions on it.

[0092] Furthermore, when determining the loss, to avoid excessive differences between the labeled and auxiliary labels of the cross samples, which could lead to an overly large first loss, the first node can assign weights to the first and second differences. Therefore, l1 = αl τ=1 (Y A ,f)+(1-α)l τ=1 (Y B ,f), where α is used to characterize the weight of the first gap, and 1-α is used to characterize the weight of the second gap. The specific values ​​of the weights of the first gap and the weights of the second gap can be set as needed, and this specification does not impose any restrictions on them.

[0093] Furthermore, in this specification, for each first sample, if the classification result of the first sample differs significantly from its corresponding sample type, then the difference between its corresponding target prediction result and its original label will also be significant. Therefore, when determining the total loss of the target model, the first node can also determine the total loss based on the difference between the classification result and the sample type.

[0094] Specifically, the first node can determine the sample type of each first sample based on whether it is a cross sample. The sample type can include cross type and non-cross type.

[0095] Then, the first node can determine the third loss based on the gap between the sample type of the first sample and the classification result of the first sample.

[0096] Finally, based on the aforementioned determined first losses, second losses, and third losses, the total loss can be determined at this first node. Let the total loss be l. z Taking l1 + l2 + l3 as an example. Where l3 = -[1 τ=1 logP A +1 τ=0 log(1-PA )], P A Let 1-P be the probability that the first sample belongs to the crossover type. A This represents the probability that the first sample belongs to a non-crossover type.

[0097] Furthermore, the target model trained using the model training method described in this specification can be used to predict the data to be predicted.

[0098] Specifically, the first node can receive a prediction request and determine the data to be predicted carried in the prediction request. This data to be predicted is similar to the first sample. In other words, the target model can accurately predict data similar to the first sample.

[0099] Next, the first node can use the data to be predicted as input to the classification layer of the pre-trained target model to obtain the target classification result of the data to be predicted.

[0100] Then, the first node can obtain the target prediction result of the data to be predicted based on the target classification result and the prediction layer corresponding to each preset classification in the target model.

[0101] Finally, the first node can return the prediction result for the target based on the prediction request.

[0102] The above describes a model training method provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a model training apparatus, such as... Figure 3 As shown.

[0103] Figure 3 This is a schematic diagram of a model training apparatus provided in this specification. The apparatus is applied to a first node in a federated learning system. The system includes a first node and a second node. The first node stores each first sample, and the second node stores each second sample. At least a portion of the first samples and at least a portion of the second samples correspond to the same user, wherein:

[0104] The sample determination module 200 is used to determine cross samples and non-cross samples from the first samples, wherein the cross samples are used to characterize the existence of a second sample that corresponds to the same user as the cross sample.

[0105] The annotation determination module 202 is used to determine the initial model trained based on each first sample and each second sample, and to determine the auxiliary annotations of each cross sample through the initial model.

[0106] The classification module 204 is used to input each first sample into the classification layer of the target model to be trained, and obtain the classification result output by the classification layer. The classification result is used to characterize whether the first sample is a cross sample.

[0107] The prediction module 206 is used to determine the target prediction result of the first sample based on the classification result and the prediction layer corresponding to each preset classification in the target model, wherein each preset classification includes at least cross-type and non-cross-type.

[0108] The training module 208 is used to train the target model based on the target prediction results of the cross samples, the annotations and auxiliary annotations of the cross samples, and the target prediction results and annotations of the non-cross samples.

[0109] Optionally, the annotation determination module 202 is configured to receive the sample features of each second sample sent by the second node, and determine, based on the sample identifiers of each first sample and each second sample, a first sample and a second sample corresponding to the same user from the first sample and the second sample, as the first cross sample and the second cross sample, and use the annotation of the first cross sample as the annotation of the second cross sample. The initial model is then trained using the first sample and its annotation, as well as the second cross sample and its annotation, to obtain the trained initial model.

[0110] Optionally, the prediction module 206 is used to determine the sample features of the first sample, and input the sample features into the prediction layers corresponding to each preset category in the target model to obtain the prediction results of the first sample output by each prediction layer, and determine the target prediction result of the first sample based on the classification results and the prediction results of the first sample, wherein the classification results are used to characterize the probability that the first sample belongs to each preset category.

[0111] Optionally, the prediction module 206 is used to obtain the features of the first sample output by each feature extraction layer through the feature extraction layers corresponding to each preset classification in the target model, and to determine the sample features of the first sample based on the classification results and the features of the first sample, wherein the target model further includes the feature extraction layers corresponding to each preset classification.

[0112] Optionally, the training module 208 is configured to, for each first sample, if the first sample is a cross sample, determine a first loss based on the difference between the target prediction result and the annotation of the first sample, and the difference between the target prediction result and the annotation of the first sample; if the first sample is a non-cross sample, determine a second loss based on the difference between the target prediction result and the annotation of the first sample; determine the total loss based on the determined first loss and second loss, and train the target model with the minimum total loss as the optimization objective.

[0113] Optionally, the training module 208 is configured to, for each first sample, determine the sample type of the first sample based on whether the first sample is a cross sample, determine the third loss based on the difference between the sample type of the first sample and the classification result of the first sample, and determine the total loss based on the determined first loss, second loss and third loss.

[0114] Optionally, the prediction module 206 is configured to receive a prediction request, determine the data to be predicted carried in the prediction request, input the data to be predicted into the classification layer of a pre-trained target model to obtain the target classification result of the data to be predicted, obtain the target prediction result of the data to be predicted based on the target classification result and the prediction layer corresponding to each preset classification in the target model, and return the target prediction result according to the prediction request.

[0115] The specification also provides a computer-readable storage medium storing a computer program that can be used to execute the above-described method for training the model.

[0116] This instruction manual also provides Figure 4 The diagram shows a schematic structural representation of the electronic device. Figure 4 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, memory, and non-volatile memory, and may also include other hardware required for business operations. The processor reads the corresponding computer program from the non-volatile memory into memory and then runs it to implement the above-mentioned model training method. Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of hardware and software, etc. That is to say, the execution subject of the following processing flow is not limited to individual logic units, but can also be hardware or logic devices.

[0117] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program and "integrate" a digital system onto a PLD themselves, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0118] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0119] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0120] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware components.

[0121] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0122] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0123] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0124] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0125] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0126] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0127] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0128] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0129] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0130] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing nodes connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage nodes.

[0131] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0132] The above description is merely an embodiment of this specification and is not intended to limit this specification. Various modifications and variations can be made to this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims of this specification.

Claims

1. A method for training a model, the method being applied to a first node in a federated learning system, the system comprising a first node and a second node, the first node storing each first sample, the second node storing each second sample, at least a portion of the first samples and at least a portion of the second samples corresponding to the same user, the method comprising: From each of the first samples, cross samples and non-cross samples are determined, wherein the cross samples are used to characterize the existence of a second sample that corresponds to the same user as the cross sample; An initial model is determined based on each of the first samples and each of the second samples, and the auxiliary annotations of the cross samples are determined using the initial model; For each first sample, the first sample is input into the classification layer of the target model to be trained, and the classification result output by the classification layer is obtained. The classification result is used to characterize whether the first sample is a cross sample. Based on the classification results and the prediction layers corresponding to each preset category in the target model, the target prediction result of the first sample is determined, wherein each preset category includes cross-type and non-cross-type. The target model is trained based on the target prediction results of the cross samples, the annotations and auxiliary annotations of the cross samples, and the target prediction results and annotations of the non-cross samples.

2. The method as described in claim 1, wherein determining the initial model trained based on each of the first samples and each of the second samples specifically includes: Receive the sample features of each second sample sent by the second node; Based on the sample identifiers of each first sample and each second sample, a first sample and a second sample corresponding to the same user are determined from the first sample and the second sample, and are used as the first cross sample and the second cross sample, and the label of the first cross sample is used as the label of the second cross sample. The initial model is trained using the first samples and their annotations, as well as the second cross samples and their annotations, to obtain the trained initial model.

3. The method as described in claim 1, wherein the target prediction result of the first sample is determined based on the classification result and the prediction layer corresponding to each preset classification in the target model, specifically including: The sample features of the first sample are determined, and the sample features are respectively input into the prediction layers corresponding to each preset classification in the target model to obtain the prediction results of the first sample output by each prediction layer. Based on the classification results and the prediction results of the first sample, the target prediction result of the first sample is determined, wherein the classification results are used to characterize the probability that the first sample belongs to each preset category.

4. The method as described in claim 3, wherein the target model further includes feature extraction layers corresponding to each preset category; The sample characteristics of the first sample are determined, specifically including: The features of the first sample are obtained by the feature extraction layers corresponding to each preset category in the target model. Based on the classification results and the characteristics of the first sample, the sample characteristics of the first sample are determined.

5. The method as described in claim 1, wherein the target model is trained based on the target prediction results of the cross-samples, the annotations and auxiliary annotations of the cross-samples, and the target prediction results and annotations of the non-cross-samples, specifically including: For each first sample, if the first sample is a cross sample, the first loss is determined based on the difference between the target prediction result of the first sample and the label of the first sample, and the difference between the target prediction result of the first sample and the label of the first sample. If the first sample is a non-cross sample, then the second loss is determined based on the difference between the target prediction result of the first sample and the label of the first sample; Based on the determined first loss and second loss, the total loss is determined, and the target model is trained with the goal of minimizing the total loss.

6. The method as described in claim 5, wherein the total loss is determined based on the determined first losses and second losses, specifically including: For each first sample, determine the sample type of the first sample based on whether it is a crossover sample; The third loss is determined based on the difference between the sample type of the first sample and the classification result of the first sample; The total loss is determined based on the identified first, second, and third losses.

7. The method of claim 1, further comprising: Receive a prediction request and determine the data to be predicted carried in the prediction request; The data to be predicted is input into the classification layer of the pre-trained target model to obtain the target classification result of the data to be predicted. Based on the target classification result and the prediction layer corresponding to each preset classification in the target model, the target prediction result of the data to be predicted is obtained; Based on the prediction request, return the target prediction result.

8. An apparatus for training a model, the apparatus being applied to a first node in a federated learning system, the system comprising a first node and a second node, the first node storing each first sample, the second node storing each second sample, at least a portion of the first samples and at least a portion of the second samples corresponding to the same user, the apparatus comprising: A sample determination module is used to determine cross samples and non-cross samples from the first samples, wherein the cross samples are used to characterize the existence of a second sample that corresponds to the same user as the cross sample; The annotation determination module is used to determine an initial model trained based on each first sample and each second sample, and to determine the auxiliary annotations of the cross samples through the initial model; The classification module is used to input each first sample into the classification layer of the target model to be trained, and obtain the classification result output by the classification layer. The classification result is used to characterize whether the first sample is a cross sample. The prediction module is used to determine the target prediction result of the first sample based on the classification result and the prediction layer corresponding to each preset classification in the target model, wherein each preset classification includes cross-type and non-cross-type. The training module is used to train the target model based on the target prediction results of the cross samples, the annotations and auxiliary annotations of the cross samples, and the target prediction results and annotations of the non-cross samples.

9. A computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in any one of claims 1 to 7.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Modeling method and device, electronic equipment and readable medium

    CN112862057A

  • Detection model training method and device, equipment and storage medium

    CN116052250A