Training Method, Device, Electronic Device, and Storage Medium of Machine Learning Model

Through distributed training of machine learning models, the coordinated training of target nodes and distributed nodes is solved, and the model training difficulties under unknown data distribution and privacy protection are improved, and the model training efficiency and convergence are improved.

CN115146787BActive Publication Date: 2025-08-01BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210768781.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-30
Publication Date
2025-08-01
Estimated Expiration
2042-06-30

AI Technical Summary

Technical Problem

During the model training process, due to the unknown data distribution, data privacy protection and data decentralized storage, the model is difficult to effectively train and converge.

Method used

The machine learning model is trained in a distributed manner, and the target node is trained based on local data and sent model parameters to the distributed node, combined with the accuracy of the distributed node, model parameters and weight coefficient adjustment, and the final model parameters ensure that the model converges under unknown data distribution and privacy protection conditions.

Benefits of technology

It realizes effective training of the model under the premise of unknown data distribution and privacy protection, and improves the efficiency and convergence of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115146787B_ABST
    Figure CN115146787B_ABST
Patent Text Reader

Abstract

The present application provides a training method, apparatus, electronic device, and storage medium for a machine learning model. The training method for the machine learning model includes: training the machine learning model based on sample data stored locally until the machine learning model meets a first preset training condition and obtaining first model parameters; sending the first model parameters to a plurality of distributed nodes so that each distributed node trains a machine learning model based on the first model parameters and obtains a first accuracy of the machine learning model, and other steps. The present application trains the model in a distributed manner, which can overcome the technical problems such as unknown distribution of training data, data privacy protection, and decentralized storage of data during the model training process, and thus effectively train the model. At the same time, the present application is also used to solve the technical problem that the model is difficult to converge during the process of distributed training of the model. On the other hand, the present application can also improve the model training efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of machine learning. Specifically, it relates to a method, device, electronic device, and storage medium for training a machine learning model. Background Art

[0002] Currently, during model training, due to limitations such as unknown data distribution, data privacy protection, and decentralized data storage, it is difficult to effectively train the model, and the model has the defect of being difficult to converge. Summary of the Invention

[0003] The purpose of this application is to provide a method, device, electronic device, and storage medium for training a machine learning model, which is used to train the model in a distributed manner to overcome the technical problems of unknown training data distribution, data privacy protection, and decentralized data storage during the model training process, thereby realizing effective training of the model. At the same time, this application is also used to solve the technical problem that the model is difficult to converge during the process of distributed training of the model.

[0004] To this end, the first aspect of this application discloses a method for training a machine learning model. The method is applied to a target node in a distributed system, where the distributed system includes a target node and several distributed nodes. The method includes:

[0005] Training the machine learning model based on the sample data stored locally until the machine learning model meets the first preset training condition and obtains the first model parameters;

[0006] Sending the first model parameters to several distributed nodes, so that each distributed node tests the machine learning model based on the first model parameters and local test data and obtains the first accuracy of the machine learning model, and each distributed node trains the machine learning model based on the first model parameters and local training data and obtains the second model parameters when the machine learning model meets the fourth preset training condition;

[0007] Receiving the first accuracy of each distributed node and the second model parameters of each distributed node;

[0008] Training the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficient until the machine learning model meets the second preset training condition.

[0009] In this application, the target node can train a machine learning model based on the sample data stored locally. When the machine learning model meets the first preset training condition, the first model parameters are obtained. Furthermore, the first model parameters can be sent to a number of distributed nodes, so that each of the distributed nodes can test the machine learning model based on the first model parameters and local test data and obtain the first accuracy of the machine learning model, and each of the distributed nodes can train the machine learning model based on the first model parameters and local training data and obtain the second model parameters when the machine learning model meets the fourth preset training condition. At the same time, through the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, the machine learning model can be trained to make the machine learning model meet the second preset training condition. In this way, when the target node trains the model, it does not need to obtain the local data owned by other nodes from other nodes, so that the training of the model can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0010] At the same time, since the weight coefficients of the distributed nodes are adopted in the process of training the model in this application, the influence of the first accuracy determined by each distributed node and the second model parameters of each distributed node on model training can be adjusted, so that the proportion of the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node in the final model parameters increases, while the proportion of the model parameters obtained by training the distributed nodes not similar to the data characteristics and distribution of the target node in the final model parameters decreases. Furthermore, the influence of the data of the distributed nodes with large differences in data characteristics and distribution from the target node on the final model can be effectively suppressed, and the influence of the data of the nodes similar to the data distribution of the target node on the target model can be enhanced, thereby ensuring that the final model has better convergence.

[0011] On the other hand, this application adopts distributed training of the model, which can improve the efficiency of model training.

[0012] In the first aspect of this application, as an optional implementation manner, training the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients until the machine learning model meets the second preset training condition includes:

[0013] Determine the third model parameters of the machine learning model based on the first accuracy determined by each distributed node, the second model parameters of each distributed node, and the weight coefficients;

[0014] Update the machine learning model based on the third model parameters of the machine learning model;

[0015] Train the machine learning model based on the locally stored sample data until the machine learning model meets the second preset training condition.

[0016] In this alternative embodiment, based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, the third model parameters of the machine learning model can be determined. Furthermore, the machine learning model can be updated based on the third model parameters of the machine learning model, so that the machine learning model can be trained based on the locally stored sample data until the machine learning model meets the second preset training condition.

[0017] In a first aspect of the present application, as an alternative embodiment, the calculation formula for determining the third model parameters of the machine learning model based on the first accuracy determined for each of the distributed nodes, the second model parameters of each of the distributed nodes, and the weight coefficients is:

[0018]

[0019] where θ j represents the third model parameters, β represents the weight coefficients, 0 < β < 1, j represents the current training cycle of the machine learning model, i represents the subscript of each distributed node, M represents the total number of several distributed nodes, and P ij represents the first accuracy of each distributed node, and θ ij represents the second model parameters of each distributed node.

[0020] Through the above calculation formula in this alternative embodiment, the influence of the data of the nodes with large differences in data characteristics and distributions from the target node on the final model can be effectively suppressed, the influence of the data of the nodes with data distributions similar to the target node on the final model can be enhanced, and the convergence of the final model can be ensured.

[0021] In a first aspect of the present application, as an alternative embodiment, for the training of the machine learning model based on the locally stored sample data until the machine learning model meets the second preset training condition, the method further includes:

[0022] Train the machine learning model based on the locally stored sample data until the machine learning model meets the third preset training condition;

[0023] When the machine learning model meets the third preset training condition, test the machine learning model and obtain the second accuracy of the machine learning model;

[0024] Based on the second accuracy, determine whether the machine learning model meets the second preset training condition;

[0025] When the second accuracy does not meet the second preset training condition, the machine learning model is iteratively trained within multiple training cycles until the machine learning model meets the second preset training condition.

[0026] In this alternative embodiment, when the machine learning model meets the third preset training condition, by testing the machine learning model, the second accuracy of the machine learning model can be obtained. Furthermore, based on the second accuracy, it can be determined whether the machine learning model meets the second preset training condition. Then, when the second accuracy does not meet the second preset training condition, the machine learning model can be iteratively trained within multiple training cycles until the machine learning model meets the second preset training condition.

[0027] In the first aspect of this application, as an alternative embodiment, the third preset training condition is that the machine learning model converges or the number of training iterations of the machine learning model reaches a first preset threshold.

[0028] In this alternative embodiment, based on the condition that the machine learning model converges or the number of training iterations of the machine learning model reaches a first preset threshold, it is determined that the machine learning model meets the third preset training condition.

[0029] In the first aspect of this application, as an alternative embodiment, the determination of whether the machine learning model meets the second preset training condition based on the second accuracy includes:

[0030] Determine whether the second accuracy is greater than or equal to a second preset threshold. If the second accuracy is greater than or equal to the second preset threshold, it is determined that the machine learning model meets the second preset training condition.

[0031] In this alternative embodiment, by determining whether the second accuracy is greater than or equal to a second preset threshold, it can be further determined that the machine learning model meets the second preset training condition when the second accuracy is greater than or equal to the second preset threshold.

[0032] In the first aspect of this application, as an alternative embodiment, the determination of whether the machine learning model meets the second preset training condition based on the second accuracy includes:

[0033] Determine whether the second accuracy converges. If the second accuracy converges, it is determined that the machine learning model meets the second preset training condition.

[0034] In this alternative embodiment, by determining whether the second accuracy converges, it can be further determined that the machine learning model meets the second preset training condition when the second accuracy converges.

[0035] The second aspect of the present application discloses a training device for a machine learning model. The device is applied to a target node in a distributed system. The distributed system includes a target node and a plurality of distributed nodes. The device includes:

[0036] A first training module, configured to train the machine learning model based on locally stored sample data until the machine learning model meets a first preset training condition and obtain first model parameters;

[0037] A sending module, configured to send the first model parameters to a plurality of distributed nodes, so that each distributed node tests the machine learning model based on the first model parameters and local test data and obtains a first accuracy of the machine learning model, and each distributed node trains the machine learning model based on the first model parameters and local training data and obtains second model parameters when the machine learning model meets a fourth preset training condition;

[0038] A receiving module, configured to receive the first accuracy of each distributed node and the second model parameters of each distributed node;

[0039] A second training module, configured to train the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and weight coefficients until the machine learning model meets a second preset training condition.

[0040] In the present application, the target node can train a machine learning model based on locally stored sample data, and when the machine learning model meets the first preset training condition, obtain first model parameters, and then can send the first model parameters to a plurality of distributed nodes, so that each distributed node tests the machine learning model based on the first model parameters and local test data and obtains the first accuracy of the machine learning model, and each distributed node trains the machine learning model based on the first model parameters and local training data and obtains second model parameters when the machine learning model meets the fourth preset training condition. At the same time, through the first accuracy of each distributed node, the second model parameters of each distributed node, and weight coefficients, the machine learning model can be trained to meet the second preset training condition. In this way, when the target node trains the model, it does not need to obtain the local data owned by other nodes from other nodes, so that the training of the model can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0041] Meanwhile, since the present application adopts the weight coefficients of distributed nodes in the process of training the model, it is possible to adjust the influence of the first accuracy determined by each of the distributed nodes and the second model parameters of each of the distributed nodes on model training, so that the proportion of the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node in the final model parameters increases, while the proportion of the model parameters obtained by training the distributed nodes dissimilar to the data characteristics and distribution of the target node in the final model parameters decreases. Furthermore, it is possible to effectively suppress the influence of the data of the distributed nodes with large differences in data characteristics and distribution from the target node on the final model, and enhance the influence of the data of the nodes similar to the data distribution of the target node on the target model, thereby ensuring that the final model has better convergence.

[0042] On the other hand, the present application adopts a distributed training model, which can improve the efficiency of model training.

[0043] A third aspect of the present application discloses an electronic device, which includes:

[0044] a processor; and

[0045] a memory configured to store machine-readable instructions, which, when executed by the processor, execute the training method of the machine learning model according to the first aspect of the present application.

[0046] By executing the training method of the machine learning model, the electronic device of the present application can train the machine learning model based on the sample data stored locally, and obtain the first model parameters when the machine learning model meets the first preset training condition. Furthermore, it can send the first model parameters to a plurality of distributed nodes, so that each of the distributed nodes tests the machine learning model based on the first model parameters and the local test data and obtains the first accuracy of the machine learning model, and each of the distributed nodes trains the machine learning model based on the first model parameters and the local training data and obtains the second model parameters when the machine learning model meets the fourth preset training condition. Meanwhile, through the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, the machine learning model can be trained to make the machine learning model meet the second preset training condition. In this way, when the target node trains the model, it does not need to obtain the local data owned by other nodes from other nodes, so that the training of the model can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0047] Meanwhile, since the present application uses the weight coefficients of distributed nodes in the process of training the model, it is possible to adjust the influence of the first accuracy determined by each of the distributed nodes and the second model parameters of each of the distributed nodes on model training, so that the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node have an increased proportion in the final model parameters, while the model parameters obtained by training the distributed nodes not similar to the data characteristics and distribution of the target node have a decreased proportion in the final model parameters. Furthermore, it is possible to effectively suppress the influence of the data of the distributed nodes with a large difference in data characteristics and distribution from the target node on the final model, and enhance the influence of the data of the nodes similar to the data distribution of the target node on the target model, thereby ensuring that the final model has better convergence.

[0048] On the other hand, the present application uses a distributed training model, which can improve the efficiency of model training.

[0049] A fourth aspect of the present application discloses a storage medium, which stores a computer program, and the computer program is executed by a processor to implement the training method of the machine learning model according to the first aspect of the present application.

[0050] By executing the training method of the machine learning model, the storage medium of the present application can train the machine learning model based on the sample data stored locally, and when the machine learning model meets the first preset training condition, obtain the first model parameters. Furthermore, it can send the first model parameters to a number of distributed nodes, so that each of the distributed nodes tests the machine learning model based on the first model parameters and local test data and obtains the first accuracy of the machine learning model, and each of the distributed nodes trains the machine learning model based on the first model parameters and local training data and obtains the second model parameters when the machine learning model meets the fourth preset training condition. Meanwhile, through the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, the machine learning model can be trained to make the machine learning model meet the second preset training condition. In this way, when the target node trains the model, it does not need to obtain the local data owned by other nodes from other nodes, so that the model training can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0051] Meanwhile, since the present application adopts the weight coefficients of distributed nodes during the process of training the model, it is possible to adjust the influence of the first accuracy determined by each of the distributed nodes and the second model parameters of each of the distributed nodes on model training, so that the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node have an increased proportion in the final model parameters, while the model parameters obtained by training the distributed nodes not similar to the data characteristics and distribution of the target node have a decreased proportion in the final model parameters. Furthermore, it is possible to effectively suppress the influence of the data of the distributed nodes with a large difference in data characteristics and distribution from the target node on the final model, and enhance the influence of the data of the nodes similar to the data distribution of the target node on the target model, thereby ensuring that the final model has better convergence.

[0052] On the other hand, the present application adopts a distributed training model, which can improve the efficiency of model training. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, without creative efforts, other relevant drawings can also be obtained based on these drawings.

[0054] Figure 1 is a schematic flowchart of a method for training a machine learning model disclosed in an embodiment of the present application;

[0055] Figure 2 is a schematic structural diagram of a device for training a machine learning model disclosed in an embodiment of the present application;

[0056] Figure 3 is a schematic structural diagram of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0057] The following will describe the technical solutions in the embodiments of the present application in conjunction with the drawings in the embodiments of the present application.

[0058] Embodiment 1

[0059] Please refer to Figure 1 , Figure 1 which is a schematic flowchart of a method for training a machine learning model disclosed in an embodiment of the present application. Among them, the method is applied to a target node in a distributed system, and the distributed system includes a target node and several distributed nodes. As Figure 1 shown, the method in the embodiment of the present application includes the following steps:

[0060] 101. Train a machine learning model based on the sample data stored locally until the machine learning model meets the first preset training condition and obtain the first model parameters;

[0061] 102. Send the first model parameters to a number of distributed nodes, so that each distributed node tests the machine learning model based on the first model parameters and local test data and obtains the first accuracy of the machine learning model, and each distributed node trains the machine learning model based on the first model parameters and local training data and obtains the second model parameters when the machine learning model meets the fourth preset training condition;

[0062] 103. Receive the first accuracy of each distributed node and the second model parameters of each distributed node;

[0063] 104. Train the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficient until the machine learning model meets the second preset training condition.

[0064] In the embodiment of the present application, for step 101, the number of sample data stored locally by the target node can be 1000 or 10000. The embodiment of the present application does not limit the number of sample data stored locally by the target node.

[0065] In the embodiment of the present application, for step 101, the target node refers to the distributed node that needs to train the model. For example, assuming that there are 6 distributed nodes in the distributed system, and among them, the distributed node A needs to train the model, then the distributed node A is the target node.

[0066] In the embodiment of the present application, for step 101, the machine learning model can be one of other neural network models such as an RNN (Recurrent Neural Network) model, an LSTM (Long Short-Term Memory) model, or a Transformer model.

[0067] In the embodiment of the present application, for step 101, the machine learning model meeting the first preset training condition means that the number of training times of the machine learning model reaches the preset threshold, or it means that the machine learning model meets the convergence condition. For example, when the number of training times of the machine learning model reaches 100 times, the machine learning model meets the first preset training condition.

[0068] In the embodiment of the present application, for step 101, the first model parameter refers to the parameter of the machine learning model when it meets the first preset training condition. For example, when the machine learning model is trained 100 times, the obtained parameter is the first model parameter. Further, the first model parameter may include parameters such as the learning rate, regularization parameter, number of layers of the neural network, and number of neurons in each hidden layer.

[0069] In the embodiment of the present application, for step 102, several distributed nodes refer to at least one distributed node. For example, the target node may send the first model parameter to one distributed node or send the first model parameter to two distributed nodes.

[0070] In the embodiment of the present application, for step 102, the first accuracy of the machine learning model refers to the evaluation result of the distributed node on the training result of the target node. Among them, the training data locally stored in each distributed node includes data that can test the training result of the target node, so that the distributed node can test the training result of the target node.

[0071] In the embodiment of the present application, for step 102, specifically, in the jth (j >= 1) training cycle, each distributed node receives the first model parameter sent by the target node, updates the parameters of the local machine learning model based on the first model parameter, and then uses the local test data to test the machine learning model and obtain the first accuracy P of the machine learning model ij , where i is the subscript of the distributed node, and its value is equal to the number of distributed nodes.

[0072] In the embodiment of the present application, for step 102, specifically, after each distributed node updates the parameters of the local machine learning model based on the first model parameter, it trains the local machine learning model based on the local training data, so that the local machine learning model meets the fourth preset training condition and uses the parameter when the machine learning model meets the fourth preset training condition as the second model parameter. Among them, in the jth training cycle, the second model parameter returned by each distributed node to the target node is represented by θ ij is represented.

[0073] In the embodiments of the present application, for step 102, specifically, the fourth preset training condition means that the local machine learning model of the distributed node converges, or that the number of iterations for the distributed node to train the machine learning model reaches I times. Preferably, I = 5. In the embodiments of the present application, for step 104, the weight coefficient of each distributed node represents the influence degree of the distributed node on the target node, which is determined based on the similarity between the data of the distributed node and the data of the target node. Among them, the higher the similarity between the data characteristics and distribution of the distributed node and the target node, the higher its weight coefficient, while the lower the similarity between the data characteristics and distribution of the distributed node and the target node, the lower its weight coefficient.

[0074] In the embodiments of the present application, for step 104, optionally, training the machine learning model based on the locally stored sample data until the machine learning model meets the second preset training condition includes:

[0075] Training the machine learning model based on the locally stored sample data until the machine learning model meets the third preset training condition;

[0076] When the machine learning model meets the third preset training condition, testing the machine learning model and obtaining the second accuracy of the machine learning model;

[0077] Judging whether the machine learning model meets the second preset training condition based on the second accuracy;

[0078] When the second accuracy does not meet the second preset training condition, then iteratively training the machine learning model within multiple training cycles until the machine learning model meets the second preset training condition.

[0079] In some scenarios, for step 104, further optionally, the third preset training condition is that the machine learning model converges or the number of training iterations of the machine learning model reaches the first preset threshold.

[0080] In this alternative embodiment, the first preset threshold can be represented by I, and based on training the machine learning model with the locally stored sample data I times, it can be determined that the machine learning model meets the third preset training condition. Preferably, I = 5.

[0081] In some scenarios, for step 104, further optionally, judging whether the machine learning model meets the second preset training condition based on the second accuracy includes:

[0082] Judging whether the second accuracy is greater than or equal to the second preset threshold. If the second accuracy is greater than or equal to the second preset threshold, it is determined that the machine learning model meets the second preset training condition.

[0083] In this alternative embodiment, by determining whether the second accuracy is greater than or equal to the second preset threshold, it is possible to determine that the machine learning model meets the second preset training condition when the second accuracy is greater than or equal to the second preset threshold. As an example, let P j represent the second accuracy obtained by testing the machine learning model in the j-th training cycle. Then, when P j >P TH , it can be determined that the machine learning model meets the second preset training condition, where P TH represents the second preset threshold. Preferably, P TH = 0.9.

[0084] In some scenarios, for step 103, further optionally, determining whether the machine learning model meets the second preset training condition based on the second accuracy includes:

[0085] Determining whether the second accuracy converges. If the second accuracy converges, it is determined that the machine learning model meets the second preset training condition.

[0086] In this alternative embodiment, by determining whether the second accuracy converges, it is possible to determine that the machine learning model meets the second preset training condition when the second accuracy converges. As an example, when the second accuracy P j compared to the past T = 5 training cycles, the value of the second accuracy P j shows no obvious increase, it is determined that the second accuracy converges, and thus it is determined that the machine learning model meets the second preset training condition.

[0087] In some scenarios, for step 103, further optionally, when the training cycle of the machine learning model reaches the third preset threshold, it can also be determined that the machine learning model meets the second preset training condition. For example, when the training cycle j = 100, it can be determined that the machine learning model meets the second preset training condition and the training of the machine learning model is terminated.

[0088] In this alternative embodiment, steps 102 and 103 constitute a training cycle. For example, after executing step 103, when it is determined that the machine learning model does not meet the second preset training condition, it enters the next training cycle, that is, steps 102 and 103 are repeated.

[0089] In the embodiments of the present application, for step 103, the second model parameters of the distributed node refer to the model parameters of the machine learning model when the machine learning model is trained by the distributed node based on the sample data stored locally by it under satisfied conditions.

[0090] In summary, in the embodiment of the present application, the target node can train a machine learning model based on the sample data stored locally. When the machine learning model meets the first preset training condition, the first model parameters can be obtained. Furthermore, the first model parameters can be sent to a plurality of distributed nodes, so that each of the distributed nodes can test the machine learning model based on the first model parameters and the local test data and obtain the first accuracy of the machine learning model, and each of the distributed nodes can train the machine learning model based on the first model parameters and the local training data and obtain the second model parameters when the machine learning model meets the fourth preset training condition. At the same time, through the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, the machine learning model can be trained to make the machine learning model meet the second preset training condition. In this way, when training the model, the target node does not need to obtain the local data owned by other nodes from other nodes, so that the training of the model can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0091] At the same time, since the embodiment of the present application adopts the weight coefficients of the distributed nodes during the process of training the model, the influence of the first accuracy of each distributed node and the second model parameters of each distributed node on the model training can be adjusted, so that the proportion of the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node in the final model parameters increases, while the proportion of the model parameters obtained by training the distributed nodes not similar to the data characteristics and distribution of the target node in the final model parameters decreases. Furthermore, the influence of the data of the distributed nodes with large differences in data characteristics and distribution from the target node on the final model can be effectively suppressed, and the influence of the data of the nodes similar to the data distribution of the target node on the target model can be enhanced, thereby ensuring that the final model has better convergence.

[0092] On the other hand, the embodiment of the present application adopts a distributed training model, which can improve the efficiency of model training.

[0093] In the embodiment of the present application, as an optional implementation manner, training the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients until the machine learning model meets the second preset training condition includes the following sub-steps:

[0094] Determine the third model parameters of the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients;

[0095] Update the machine learning model based on the third model parameters of the machine learning model;

[0096] Train a machine learning model based on the sample data stored locally until the machine learning model meets the second preset training condition.

[0097] In this alternative embodiment, based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, the third model parameters of the machine learning model can be determined. Furthermore, the machine learning model can be updated based on the third model parameters of the machine learning model, so that the machine learning model can be trained based on the sample data stored locally until the machine learning model meets the second preset training condition.

[0098] In an embodiment of the present application, as an alternative embodiment, the calculation formula for determining the third model parameters of the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients is:

[0099]

[0100] where θ j represents the third model parameters, β represents the weight coefficient, 0 < β < 1, j represents the current training cycle of the machine learning model, i represents the subscript of each distributed node, M represents the total number of several distributed nodes, and P ij represents the first accuracy of each distributed node, and θ ij represents the second model parameters of each distributed node.

[0101] Through the above calculation formula, this alternative embodiment can effectively suppress the influence of the data of the nodes with large differences in data characteristics from the target node on the final model, enhance the influence of the data of the nodes with similar data distributions to the target node on the final model, and ensure the convergence of the final model.

[0102] In an embodiment of the present application, as an alternative embodiment, before training the machine learning model based on the sample data stored locally until the machine learning model meets the first preset training condition, the method of the embodiment of the present application further includes the following steps:

[0103] Initialize the parameters of the machine learning model based on the Gaussian random initialization method.

[0104] In this alternative embodiment, the parameters of the machine learning model can be initialized based on the Gaussian random initialization method.

[0105] In an embodiment of the present application, as an alternative embodiment, training the machine learning model includes:

[0106] Use the sample data stored locally as the input of the machine learning model, and iteratively train the machine learning model based on the stochastic gradient descent algorithm.

[0107] In this alternative embodiment, by using the sample data stored locally as the input of the machine learning model, the machine learning model can be iteratively trained based on the stochastic gradient descent algorithm.

[0108] It should be noted that iteratively training the machine learning model based on the stochastic gradient descent algorithm means repeatedly training the machine learning model until the machine learning model meets the first preset training condition.

[0109] It should be noted that the method of the embodiments of this application can be applied to the scenario of email content classification. For example, the target node D initializes the parameters of the adopted deep neural network model (such as RNN, LSTM, Transformer models, etc.) using the Gaussian random initialization method. Then, the target node D uses the email body content sample data stored locally as the training data set and iteratively trains the current model using the stochastic gradient descent algorithm. When the model converges or the number of training iterations reaches 100 times, the training stops.

[0110] Furthermore, in the j-th training cycle, the target node D sends the current parameter values of its deep neural network model to all other distributed nodes, and all distributed nodes update the parameters of their respective local deep neural network models with the received model parameter values.

[0111] Furthermore, each distributed node C i tests the accuracy P of the current model on the local email body content sample data set ij .

[0112] Furthermore, each distributed node C i uses the email body content sample data stored locally as the training data set and iteratively trains the current model using the stochastic gradient descent algorithm. When the model converges or the number of training iterations reaches I = 5 times, the training stops.

[0113] Furthermore, each distributed node C i sends the accuracy P of the model before local training ij and the model parameters θ after local training ij back to the target node D.

[0114] Furthermore, in the j-th training cycle, the target node D uses the accuracy P of the model received from other distributed nodes ij and the model parameters θ ij , and uses the following formula to complete the update of the local model parameters θ j , where β = 0.3 and M = 10.

[0115]

[0116] Further, the target node D uses the sample data of the email body content stored locally as the training data set, and iteratively trains the current local model using the stochastic gradient descent algorithm. When the model converges or the number of training iterations reaches I = 5 times, the training stops. The target node D tests the accuracy P of the current model on the local email body content sample data set j , if P j ≥P TH = 0.9 or P j converges or the training cycle j > E TH = 100, then all training processes are terminated; otherwise, the local model continues to be trained in a loop.

[0117] Embodiment 2

[0118] Please refer to Figure 2 , Figure 2 which is a schematic structural diagram of a training device for a machine learning model disclosed in an embodiment of the present application. Among them, the device is applied to a target node in a distributed system, and the distributed system includes a target node and several distributed nodes. As Figure 2 shown, the device of the embodiment of the present application includes the following functional modules:

[0119] The first training module 201 is used to train the machine learning model based on the sample data stored locally until the machine learning model meets the first preset training condition and obtains the first model parameters;

[0120] The sending module 202 is used to send the first model parameters to several distributed nodes, so that each distributed node tests the machine learning model based on the first model parameters and local test data and obtains the first accuracy of the machine learning model, and each distributed node trains the machine learning model based on the first model parameters and local training data and obtains the second model parameters when the machine learning model meets the fourth preset training condition. The first model parameters are the parameters when the machine learning model meets the first preset training condition;

[0121] The receiving module 203 is used to receive the first accuracy of each distributed node and the second model parameters of each distributed node;

[0122] The second training module 204 is used to train the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficient until the machine learning model meets the second preset training condition.

[0123] In the embodiment of the present application, the target node can train a machine learning model based on the sample data stored locally. When the machine learning model meets the first preset training condition, the first model parameters can be obtained. Furthermore, the first model parameters can be sent to a plurality of distributed nodes, so that each of the distributed nodes can test the machine learning model based on the first model parameters and the local test data and obtain the first accuracy of the machine learning model, and each of the distributed nodes can train the machine learning model based on the first model parameters and the local training data and obtain the second model parameters when the machine learning model meets the fourth preset training condition. At the same time, the machine learning model can be trained through the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, so that the machine learning model meets the second preset training condition. In this way, when training the model, the target node does not need to obtain the local data owned by other nodes from other nodes, so that the training of the model can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0124] At the same time, since the weight coefficients of the distributed nodes are adopted in the process of training the model in the embodiment of the present application, the influence of the first accuracy of each distributed node and the second model parameters of each distributed node on the model training can be adjusted, so that the proportion of the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node in the final model parameters increases, while the proportion of the model parameters obtained by training the distributed nodes not similar to the data characteristics and distribution of the target node in the final model parameters decreases. Furthermore, the influence of the data of the distributed nodes with large differences in data characteristics and distribution from the target node on the final model can be effectively suppressed, and the influence of the data of the nodes similar to the data distribution of the target node on the target model can be enhanced, so as to ensure that the final model has better convergence.

[0125] On the other hand, the present application adopts distributed training of the model, which can improve the efficiency of model training.

[0126] It should be noted that for other descriptions of the embodiment of the present application, please refer to the relevant descriptions of Embodiment 1 of the present application, and the embodiment of the present application will not elaborate on this.

[0127] Embodiment 3

[0128] Please refer to Figure 3 , Figure 3 which is a schematic structural diagram of an electronic device disclosed in the embodiment of the present application. As Figure 3 shown, the electronic device in the embodiment of the present application includes:

[0129] A processor 301; and

[0130] A memory 302, configured to store machine-readable instructions, which, when executed by a processor 301, execute the training method of the machine learning model according to the embodiments of the present application.

[0131] By executing the training method of the machine learning model, the electronic device according to the embodiments of the present application can train the machine learning model based on the sample data stored locally, and when the machine learning model meets the first preset training condition, obtain the first model parameters, and then can send the first model parameters to a plurality of distributed nodes, so that each of the distributed nodes can test the machine learning model based on the first model parameters and the local test data and obtain the first accuracy of the machine learning model, and enable each of the distributed nodes to train the machine learning model based on the first model parameters and the local training data and obtain the second model parameters when the machine learning model meets the fourth preset training condition. At the same time, through the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficients, the machine learning model can be trained to make the machine learning model meet the second preset training condition. In this way, when the target node trains the model, it does not need to obtain the local data owned by other nodes from other nodes, so that the training of the model can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0132] At the same time, since the weight coefficients of the distributed nodes are adopted in the process of training the model in the present application, the influence of the first accuracy of each distributed node and the second model parameters of each distributed node on the model training can be adjusted, so that the proportion of the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node in the final model parameters increases, while the proportion of the model parameters obtained by training the distributed nodes not similar to the data characteristics and distribution of the target node in the final model parameters decreases. Furthermore, the influence of the data of the distributed nodes with large differences in data characteristics and distribution from the target node on the final model can be effectively suppressed, and the influence of the data of the nodes similar to the data distribution of the target node on the target model can be enhanced, so as to ensure that the final model has better convergence.

[0133] On the other hand, the embodiments of the present application adopt a distributed training model, which can improve the efficiency of model training.

[0134] Embodiment 4

[0135] The embodiments of the present application disclose a storage medium storing a computer program, and the computer program is executed by a processor to execute the training method of the machine learning model according to the embodiments of the present application.

[0136] By executing the training method of the machine learning model, the storage medium according to the embodiment of the present application can train the machine learning model based on the sample data stored locally, and obtain the first model parameters when the machine learning model meets the first preset training condition. Furthermore, the first model parameters can be sent to a plurality of distributed nodes, so that each of the distributed nodes can test the machine learning model based on the first model parameters and the local test data and obtain the first accuracy of the machine learning model, and each of the distributed nodes can train the machine learning model based on the first model parameters and the local training data and obtain the second model parameters when the machine learning model meets the fourth preset training condition. At the same time, through the first accuracy of each distributed node, the second model parameters of each distributed node, and the weight coefficient, the machine learning model can be trained to make the machine learning model meet the second preset training condition. In this way, when the target node trains the model, it is not necessary to obtain the local data owned by other nodes from other nodes, so that the training of the model can be completed on the premise of unknown data distribution, data privacy protection, and decentralized data storage.

[0137] At the same time, since the weight coefficient of the distributed node is adopted in the process of training the model according to the embodiment of the present application, the influence of the first accuracy of each distributed node and the second model parameters of each distributed node on the model training can be adjusted, so that the proportion of the model parameters obtained by training the distributed nodes similar to the data characteristics and distribution of the target node in the final model parameters increases, while the proportion of the model parameters obtained by training the distributed nodes not similar to the data characteristics and distribution of the target node in the final model parameters decreases. Furthermore, the influence of the data of the distributed nodes with large differences in data characteristics and distribution from the target node on the final model can be effectively suppressed, and the influence of the data of the nodes similar to the data distribution of the target node on the target model can be enhanced, so as to ensure that the final model has better convergence.

[0138] On the other hand, the embodiment of the present application adopts a distributed training model, which can improve the efficiency of model training.

[0139] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the displayed or discussed coupling or direct coupling or communication connection between each other can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be in an electrical, mechanical or other form.

[0140] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0141] Furthermore, in each embodiment of the present application, the various functional modules may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0142] It should be noted that if a function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

[0143] In this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.

[0144] The above description is only for the embodiments of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A training method for a machine learning model, characterized in that, The method is applied to a target node in a distributed system, where the distributed system is a distributed system for training a machine learning model. The distributed system includes a target node and several distributed nodes. The method includes: Training the machine learning model based on locally stored sample data until the machine learning model meets a first preset training condition and obtaining first model parameters, where the locally stored sample data is sample data of email body content stored locally; Sending the first model parameters to several distributed nodes, so that each distributed node tests the machine learning model based on the first model parameters and local test data and obtains a first accuracy of the machine learning model, and each distributed node trains the machine learning model based on the first model parameters and local training data and obtains second model parameters when the machine learning model meets a fourth preset training condition; Receiving the first accuracy of each distributed node and the second model parameters of each distributed node; Training the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and a weight coefficient until the machine learning model meets a second preset training condition; Classifying email content based on the machine learning model.

2. The method according to claim 1, wherein The training of the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and a weight coefficient until the machine learning model meets a second preset training condition includes: Determining third model parameters of the machine learning model based on the first accuracy determined by each distributed node, the second model parameters of each distributed node, and the weight coefficient; Updating the machine learning model based on the third model parameters of the machine learning model; Training the machine learning model based on the locally stored sample data until the machine learning model meets a second preset training condition.

3. The method according to claim 2, characterized in that, The calculation formula for determining the third model parameters of the machine learning model based on the first accuracy determined by each distributed node, the second model parameters of each distributed node, and the weight coefficient is: ; Among them, represents the third model parameter, represents the weight coefficient, , represents the current training cycle of the machine learning model, represents the subscript of each distributed node, and M represents the total number of the distributed nodes, represents the first accuracy of each distributed node, represents the second model parameter of each distributed node.

4. The method according to claim 2, characterized in that, The training of the machine learning model based on the locally stored sample data until the machine learning model meets a second preset training condition includes: Training the machine learning model based on the locally stored sample data until the machine learning model meets a third preset training condition; When the machine learning model meets the third preset training condition, testing the machine learning model and obtaining a second accuracy of the machine learning model; Judging whether the machine learning model meets the second preset training condition based on the second accuracy; When the second accuracy does not meet the second preset training condition, iteratively training the machine learning model in multiple training cycles until the machine learning model meets the second preset training condition.

5. The method according to claim 4, wherein The third preset training condition is that the machine learning model converges or the number of training iterations of the machine learning model reaches a first preset threshold.

6. The method according to claim 4, wherein Based on the second accuracy, determining whether the machine learning model meets a second preset training condition includes: Determining whether the second accuracy is greater than or equal to a second preset threshold. If the second accuracy is greater than or equal to the second preset threshold, it is determined that the machine learning model meets the second preset training condition.

7. The method according to claim 4, wherein Based on the second accuracy, determining whether the machine learning model meets a second preset training condition includes: Determining whether the second accuracy converges. If the second accuracy converges, it is determined that the machine learning model meets the second preset training condition.

8. A training device for a machine learning model, characterized in that, The device is applied to a target node in a distributed system, where the distributed system is a distributed system for training a machine learning model. The distributed system includes a target node and several distributed nodes. The device includes: A first training module, configured to train the machine learning model based on locally stored sample data until the machine learning model meets a first preset training condition and obtain first model parameters, where the locally stored sample data is sample data of email body content stored locally; A sending module, configured to send the first model parameters to several distributed nodes, so that each distributed node tests the machine learning model based on the first model parameters and local test data and obtains a first accuracy of the machine learning model, and each distributed node trains the machine learning model based on the first model parameters and local training data and obtains second model parameters when the machine learning model meets a fourth preset training condition; A receiving module, configured to receive the first accuracy of each distributed node and the second model parameters of each distributed node; A second training module, configured to train the machine learning model based on the first accuracy of each distributed node, the second model parameters of each distributed node, and a weight coefficient until the machine learning model meets a second preset training condition; The device is further configured to classify email content based on the machine learning model.

9. An electronic device, characterized in that, The electronic device includes: A processor; and A memory, configured to store machine-readable instructions, which when executed by the processor, execute the training method of the machine learning model according to any one of claims 1-7.

10. A storage medium, characterized in that, The storage medium stores a computer program, and the computer program is executed by a processor to perform the training method of the machine learning model according to any one of claims 1-7.

Citation Information

Patent Citations

  • Distributed data identification method and distributed data identification system

    CN106874941A

  • Federal learning-based model training method and device, and federal learning system

    CN112862011A