Methods, apparatus, media and electronic devices for training horizontal federated learning models

By calculating the deviation value of client model parameters on the main server, potential clients that may be subject to poisoning attacks are screened out and their model parameter information is removed. This solves the problem of horizontal federated learning being vulnerable to poisoning attacks and achieves more accurate model aggregation and training.

CN116306916BActive Publication Date: 2026-05-26BEIJING TOPSEC NETWORK SECURITY TECH +2

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING TOPSEC NETWORK SECURITY TECH
Filing Date
2023-03-17
Publication Date
2026-05-26

AI Technical Summary

Technical Problem

Traditional horizontal federated learning is vulnerable to poisoning attacks, which can lead to global model training failure or performance degradation. Existing technologies are unable to effectively defend against poisoning attacks.

Method used

By calculating the deviation value of client model parameters on the main server, potential clients to be poisoned are screened out, their model parameter information is removed, and the information of the remaining clients is aggregated to improve the accuracy of the aggregated information.

Benefits of technology

It effectively resists poisoning attacks, enhances the anti-interference capability of the global model training process, and ensures the accuracy and reliability of aggregated information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116306916B_ABST
    Figure CN116306916B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, medium, and electronic device for training a horizontal federated learning model. The method includes: in any training round, obtaining initial aggregation information based on the model parameter information of the local model sent by each client, and calculating a deviation value based on the model parameter information of each client and the initial aggregation information to obtain a single deviation value set for all clients, wherein the deviation value is used to characterize the degree of deviation of the model parameter information of each client relative to the aggregated values ​​of the model parameter information of other clients; selecting a portion of clients from all clients based on the cumulative deviation values ​​of each client; and obtaining updated aggregation information for this training round based on the model parameter information of the selected clients. Using this application embodiment can enhance the anti-interference and poisoning attack resistance capabilities of the global model training process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of model training, and more specifically, the embodiments of this application relate to methods, apparatus, media, and electronic devices for training horizontal federated learning models. Background Technology

[0002] Currently, with the rapid development of artificial intelligence (AI) technology, its applications are becoming increasingly widespread, including image analysis, speech recognition, text processing, intelligent recommendation, and security detection. Privacy-preserving computing technologies, such as federated learning, have become a new cutting-edge and popular area. However, traditional federated learning, especially traditional horizontal federated learning, is vulnerable to poisoning attacks, leading to global model training failure or model unavailability.

[0003] Lateral federated learning, also known as sample-partitioned federated learning, can be applied to scenarios where the datasets of the various participants in a federated learning process share the same feature space but have different sample spaces. If a machine learning model is trained on data from potentially untrusted sources, attackers can easily manipulate the training data distribution by inserting carefully crafted samples into the training set to alter model behavior and reduce performance; this type of attack is known as a poisoning attack.

[0004] Some related technical solutions can only detect some poisoning attacks, but not all poisoning attacks have significant clustering characteristics in terms of neuron activation values; some related technical solutions prune local models, which can only reduce the attacker's attack effect, but cannot completely prevent the attacker from poisoning the model, and attackers can easily bypass model pruning to carry out poisoning attacks. Summary of the Invention

[0005] The purpose of this application is to provide a method, apparatus, medium, and electronic device for training a horizontal federated learning model. The use of this application's embodiments can enhance the anti-interference and anti-poisoning attack capabilities of the global model training process.

[0006] In a first aspect, embodiments of this application provide a method for training a horizontal federated learning model, applied to a master server. The method includes: in any training round, obtaining initial aggregation information based on the model parameter information of the local model sent by each client, and calculating deviation values ​​based on the model parameter information of each client and the initial aggregation information to obtain a single deviation value set for all clients, wherein the deviation value is used to characterize the degree of deviation of the model parameter information of each client relative to the aggregated values ​​of the model parameter information of other clients; selecting a portion of clients from all clients based on the cumulative deviation values ​​of each client, wherein the cumulative deviation is obtained through multiple deviation values ​​obtained from multiple training rounds; and obtaining updated aggregation information for this training round based on the model parameter information of the selected clients.

[0007] Some embodiments of this application filter out a subset of clients from all clients by determining the difference between the aggregated values ​​of each client's model parameter information and those of other clients on the main server. Then, the aggregated information is updated based on the model parameter information of the filtered clients. This allows the main server to exclude model parameter information provided by clients that are subject to poisoning attacks, thereby improving the accuracy of the obtained aggregated information.

[0008] In some embodiments, the model parameter information is the updated gradient value, the initial aggregation information includes at least the initial aggregated gradient value of the global model, and the deviation value is obtained by the updated gradient value, the initial aggregated gradient value, and the number of samples for each client.

[0009] In some embodiments of this application, the model parameter information sent by the client to the main server includes the updated gradient value of the local model. The deviation value is obtained by updating the gradient value and the initial aggregation information, thereby improving the accuracy of the obtained deviation value.

[0010] In some embodiments, the step of selecting a subset of clients from all clients based on the cumulative deviation values ​​of each client includes: calculating the cumulative deviation value of the i-th client based on the single deviation value of the i-th client obtained in each round of training; selecting the subset of clients from all clients based on the cumulative deviation values ​​of all clients; and obtaining the update aggregation information for this round of training based on the model parameter information of the subset of clients includes: aggregating the update gradient values ​​of each client in the subset of clients to obtain the update aggregation information.

[0011] Some embodiments of this application select a subset of clients for aggregation from all clients based on cumulative deviation values. This can eliminate the adverse effects of model parameter information from clients potentially subjected to poisoning attacks on the aggregation results, thereby improving the accuracy of the aggregation information.

[0012] In some embodiments, calculating the cumulative deviation value of the i-th client based on the single deviation value of the i-th client obtained from each round of training includes: weighting and summing the n single deviation values ​​obtained from n rounds of training to obtain the cumulative deviation value of the i-th client.

[0013] Some embodiments of this application can improve the ability to identify clients potentially targeted by poisoning attacks by calculating a cumulative deviation value from each individual deviation value obtained in the current round and before the current round.

[0014] In some embodiments, the step of selecting a subset of clients from all clients based on the cumulative deviation values ​​of each client includes: sorting the k cumulative deviation values ​​of all k clients in order of magnitude to obtain an ordered queue; selecting m clients corresponding to the first m cumulative deviation values ​​of the ordered queue as the subset of clients, or selecting m clients corresponding to the last m cumulative deviation values ​​of the ordered queue as the subset of clients, wherein the first m cumulative deviation values ​​or the last m cumulative deviation values ​​are all less than all other cumulative deviation values ​​in the ordered queue, and m is an integer less than k.

[0015] Some embodiments of this application sort the cumulative deviation values ​​of all clients and select several clients with smaller deviation values ​​as a subset of clients that can be aggregated. Since the possibility of these aggregated clients being poisoned is very small, the accuracy of the aggregated information can be improved, avoiding the problem of inaccurate aggregation results caused by using data from clients that have been poisoned.

[0016] In some embodiments, the model parameter information is an update gradient value, wherein obtaining the initial aggregation information based on the model parameter information of the local model sent by each client includes: obtaining the training data distribution adjustment value based on the data volume of the local sample dataset of each client; and obtaining the initial aggregation gradient value through the training data distribution adjustment value of each client and the update gradient value.

[0017] Some embodiments of this application also correct the total amount of data for each client, thereby avoiding the impact of hybrid attacks on the aggregation results and improving the accuracy of the obtained initial aggregation gradient values.

[0018] In some embodiments, obtaining the training data distribution adjustment value based on the amount of data in the local sample dataset of each client includes: performing an nth-fold power operation on the amount of data in the local sample dataset of each client to obtain a value to be accumulated corresponding to each client; and accumulating the values ​​to be accumulated to obtain the training data distribution adjustment value.

[0019] Some embodiments of this application can reduce the impact of excessively large amounts of data on the aggregation results by performing an nth-fold power operation on the amount of data in the local datasets of each client, thus avoiding the impact of hybrid attacks on the accuracy of the aggregation results.

[0020] In some embodiments, the initial aggregation gradient value is calculated using the following formula:

[0021]

[0022] in, Characterizing the initial aggregation gradient value, |D T | is the adjustment value for the training data distribution, N c The total number of all clients, It represents the updated gradient value of any client during this training.

[0023] Some embodiments of this application provide a formula for calculating an initial aggregate gradient value, thereby improving the accuracy of the value calculation.

[0024] In some embodiments, the updated aggregation information includes a target aggregate gradient value, wherein the target aggregate gradient value is obtained based on the updated gradient values ​​of a subset of clients, the subset of clients is obtained by filtering all clients based on the cumulative deviation value of each client, and the cumulative deviation value is obtained based on the single deviation value obtained in each round of training.

[0025] In some embodiments, the target aggregate gradient value is calculated using the following formula:

[0026]

[0027]

[0028] in, Characterizing the target aggregate gradient value, A p Representing the set of clients, |D i | Represents the number of elements contained in the local storage sample dataset of the i-th client. This represents the updated gradient value of the i-th client in the k-th round of training.

[0029] Embodiments of this application provide a formula for calculating the aggregate gradient value of a quantified target, thereby improving the accuracy and objectivity of the value.

[0030] In some embodiments, the updated aggregation information includes the global model parameter values ​​of the current training round, wherein the global model parameter values ​​of the current training round are obtained based on the global parameter values ​​and learning rate of the previous training round.

[0031] Some embodiments of this application provide a calculation formula for updating global model parameter values, thereby improving the accuracy of these values.

[0032] In some embodiments, the formula for calculating the global model parameter values ​​in this round of training is:

[0033]

[0034] Where, Δ k Δ represents the global model parameter values ​​in the k-th training round. k-1 The global model parameter values ​​represent the (k-1)th training round, and η represents the learning rate. Characterizes the target aggregate gradient value.

[0035] Some embodiments of this application provide a formula for calculating the value of a global model parameter, thereby improving the accuracy and objectivity of the obtained value.

[0036] In some embodiments, after obtaining the update aggregation information for the current training round based on the model parameter information of the partial clients, the method further includes: sending the update aggregation information to each client, wherein each client starts the next round of local model training and global model parameter update based on the update aggregation information.

[0037] Some embodiments of this application obtain the target model through multiple rounds of training.

[0038] In some embodiments, after obtaining the update aggregation information for this round of training based on the model parameter information of the partial client, the method further includes: if it is confirmed that the training termination condition is met, then terminating the training process to obtain the target model.

[0039] Secondly, some embodiments of this application provide a training method for a horizontal federated learning model, applied to a client, the method comprising: performing the next round of local model training based on the updated aggregate information of the current training round obtained as in any embodiment of the first aspect.

[0040] Thirdly, some embodiments of this application provide a deviation value acquisition module, configured to acquire initial aggregation information based on the model parameter information of the local model sent by each client in any training round, and calculate deviation values ​​based on the model parameter information of each client and the initial aggregation information to obtain a single deviation value set for all clients, wherein the deviation value is used to characterize the degree of deviation of the model parameter information of each client relative to the initial aggregation information; a client filtering module, configured to filter out a portion of clients from all clients based on the cumulative deviation values ​​of each client, wherein the cumulative deviation is obtained by multiple deviation values ​​obtained through multiple training rounds; and an aggregation information update module, configured to obtain updated aggregation information for the current training round based on the model parameter information of the portion of clients.

[0041] Fourthly, some embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the methods described in any of the embodiments of the first or second aspect.

[0042] Fifthly, some embodiments of this application provide an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the program, can implement the methods described in any embodiment of the first or second aspect. Attached Figure Description

[0043] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0044] Figure 1 An architecture diagram of a system for training a horizontal federated learning model provided in an embodiment of this application;

[0045] Figure 2 One of the flowcharts for a method of training a horizontal federated learning model provided in the embodiments of this application;

[0046] Figure 3 A second flowchart illustrating the method for training a horizontal federated learning model provided in this application embodiment;

[0047] Figure 4 A block diagram illustrating the components of an apparatus for training a horizontal federated learning model, as provided in an embodiment of this application.

[0048] Figure 5This is a schematic diagram illustrating the composition of an electronic device provided in an embodiment of this application. Detailed Implementation

[0049] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0050] It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this application, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0051] To address the aforementioned issues, some embodiments of this application propose a training method for a horizontal federated learning model that can defend against poisoning attacks. This method proportionally removes a portion of the model parameter information (e.g., gradients to be updated) reported by each client to the main server during the current training round from the aggregated gradient (e.g., initial gradient), and then aggregates the remaining model parameter information to obtain the aggregated gradient for the current round. This enhances the anti-interference and poisoning attack resistance capabilities of the global model training process.

[0052] For example, some embodiments of this application innovatively propose a cumulative anomaly evaluation method (i.e., cumulative deviation value), which can effectively resist long-term, covert poisoning attacks. Some embodiments of this application innovatively propose a gradient deviation measurement method (i.e., deviation value), which can effectively assess the anomaly degree of poisoning attack behavior. Some embodiments of this application introduce a training data distribution adjustment strategy (i.e., training data distribution adjustment value) during the training process, which can reduce the impact of poisoning attack behavior on the global model. Some embodiments of this application innovatively propose a novel lateral federated learning model training process, which can defend against multiple poisoning attacks using only user-uploaded update data.

[0053] Please refer to Figure 1 , Figure 1 The system for training a horizontal federated learning model includes a server 100 and multiple clients (or multiple participants). The master server is used to aggregate the model information received from each client. Each client uses the training data in its local dataset to train its local model, sends model information to the server, and receives aggregated model information from the master server.

[0054] like Figure 2 As shown, Figure 1 The system's model training process includes:

[0055] S101, Local model initialization.

[0056] In some embodiments, participants build local models based on their own datasets. In some embodiments, the master server may also provide the models to be trained to each participant.

[0057] The initial parameters for local model initialization can be provided by the host server.

[0058] S102, train the local model.

[0059] Each client trains its local model using training data from its local dataset, and then sends the trained model information to the main server.

[0060] For example, participants send model information from their local models to the main server.

[0061] S103, Model parameters updated.

[0062] The master server performs secure aggregation based on the model information of the participants. Common secure aggregation algorithms include the Federated Averaging algorithm (FedAvg) and the Federated Optimization in Heterogeneous Network (FedProx) algorithm for heterogeneous federated models.

[0063] The master server broadcasts the aggregated information to all participants, who then update their local models accordingly.

[0064] It should be noted that the feature spaces of the multi-party datasets in horizontal federated learning are similar. Therefore, during the training of the federated model, there is no need for the participants to exchange intermediate computation results. Instead, the master server aggregates the models, and each party updates its local model based on the latest aggregated model information. This allows for knowledge exchange among the parties without knowing the source data of other participants. Therefore, preventing poisoning attacks on the local training data of each client becomes a major technical problem. Some embodiments of this application can exclude the model information of clients attempting poisoning attacks through relevant programs executed on the master server, thereby improving the aggregation effect.

[0065] The following is combined Figure 3 Example parameters are provided by Figure 1 The method for training a horizontal federated learning model is executed by the master server.

[0066] like Figure 3 As shown in the embodiment of this application, a method for training a horizontal federated learning model is provided and applied to a master server. The method includes:

[0067] S201, In any training round, initial aggregation information is obtained based on the model parameter information of the local model sent by each client, and deviation values ​​are calculated based on the model parameter information of each client and the initial aggregation information to obtain a single deviation value set for all clients, wherein the deviation value is used to characterize the degree of deviation of the model parameter information of each client relative to the aggregated values ​​of the model parameter information of other clients.

[0068] It is understood that the model parameter information of each client's local model is the data obtained by each client after completing local model training. This model parameter information is provided to the main server by each client. The main server will aggregate this data based on this model parameter information and the aggregation algorithm provided by related technologies to obtain initial aggregation information. Unlike related technologies, the embodiments of this application do not provide this initial specific information to each client for the next round of local model training. Instead, it uses this value to filter clients with poor performance, as shown in S102 below.

[0069] S202, the cumulative deviation value of each client is selected from all clients to select a portion of clients, wherein the cumulative deviation is obtained by multiple deviation values ​​obtained through multiple rounds of training.

[0070] Because the embodiments of this application screen clients, clients that have received poisoning attacks can be excluded from subsequent aggregation, reducing the impact of this client data on the model aggregation results. It is understood that some embodiments of this application infer whether the client's training data has been poisoned based on the deviation value on the main server.

[0071] S203, based on the model parameter information of the aforementioned clients, obtain the update aggregation information for this round of training.

[0072] It is understood that the embodiments of this application do not directly aggregate the model parameter information received from each client as in related technologies, but instead select a portion of the results from the evaluated clients for aggregation to improve the accuracy of the obtained aggregation results.

[0073] It should be noted that, in some embodiments of this application, the model parameter information is the updated gradient value, and the initial aggregation information includes at least the initial aggregated gradient value of the global model. The deviation value is obtained through the updated gradient value, the initial aggregated gradient value, and the number of samples for each client. It is understood that those skilled in the art can include other information besides the initial aggregated gradient value in the initial aggregation information as needed.

[0074] It is understood that some embodiments of this application filter out a subset of clients from all clients by determining the differences between the model parameter information and aggregated information of the client's current model in each training round on the main server. Then, updated aggregated information is obtained based on the model parameter information of the filtered clients. This allows the main server to exclude model parameter information provided by clients susceptible to poisoning attacks, thereby improving the accuracy of the obtained aggregated information. In some embodiments of this application, the model parameter information sent by the client to the main server includes the updated gradient values ​​of the local model. The deviation value is obtained by combining the updated gradient values ​​and the aggregated gradient values, thus improving the accuracy of the obtained deviation value.

[0075] The implementation process of each of the above steps is illustrated below.

[0076] In some embodiments of this application, the model parameter information is the updated gradient value, wherein S201 includes, for example:

[0077] The first step is to obtain the training data distribution adjustment value based on the amount of data in the local sample dataset of each client.

[0078] For example, in some embodiments of this application, the first step typically includes: performing an nth-fold power operation on the data volume of the local sample dataset of each client to obtain a value to be accumulated corresponding to each client; and accumulating the values ​​to be accumulated to obtain the training data distribution adjustment value. It is understood that some embodiments of this application, by performing an nth-fold power operation on the data volume of the local dataset of each client, can reduce the impact of excessively large amounts of data on the aggregation result and avoid the impact of hybrid attacks on the accuracy of the aggregation result.

[0079] The second step is to obtain the initial aggregated gradient value by adjusting the training data distribution of each client and the updated gradient value.

[0080] Some embodiments of this application also correct the total amount of data for each client, thereby avoiding the impact of hybrid attacks on the aggregation results and improving the accuracy of the obtained initial aggregation gradient values.

[0081] For example, in some embodiments of this application, the initial aggregation gradient value described in the second step is calculated using the following formula:

[0082]

[0083] in, Characterizing the initial aggregation gradient value, |D T | is the adjustment value for the training data distribution, N c The total number of all clients, It represents the updated gradient value of any client during this training.

[0084] Some embodiments of this application provide a formula for calculating an initial aggregate gradient value, thereby improving the accuracy of the value calculation.

[0085] The implementation process of S202 is illustrated below.

[0086] In some embodiments of this application, S202 includes, for example:

[0087] The first step is to calculate the cumulative deviation value of the i-th client based on the single deviation value of the i-th client obtained from each round of training.

[0088] Some embodiments of this application can improve the ability to identify clients potentially targeted by poisoning attacks by calculating a cumulative deviation value from each individual deviation value obtained in the current round and before the current round.

[0089] For example, the cumulative deviation value of the i-th client can be obtained by weighted summing of the n single deviation values ​​obtained from n rounds of training.

[0090] The second step involves filtering out a subset of clients from all clients based on their cumulative deviation values. For example, in some embodiments of this application, this second step may include: sorting the k cumulative deviation values ​​of all k clients by size to obtain an ordered queue; selecting the m clients corresponding to the first m cumulative deviation values ​​of the ordered queue as the subset of clients, or selecting the m clients corresponding to the last m cumulative deviation values ​​of the ordered queue as the subset of clients, wherein the first m or last m cumulative deviation values ​​are all less than all other cumulative deviation values ​​in the ordered queue, and m is an integer less than k. Some embodiments of this application sort the cumulative deviation values ​​of all clients and select multiple clients with smaller deviation values ​​as the subset of clients that can be aggregated. Since these aggregated clients are unlikely to be subjected to poisoning attacks, the accuracy of the aggregated information can be improved, avoiding the problem of inaccurate aggregation results caused by aggregating data from clients subjected to poisoning attacks.

[0091] Accordingly, S203 includes, for example, aggregating the update gradient values ​​of each client in the subset of clients to obtain the update aggregation information.

[0092] Some embodiments of this application select a subset of clients for aggregation from all clients based on cumulative deviation values. This can eliminate the adverse effects of model parameter information from clients potentially subjected to poisoning attacks on the aggregation results, thereby improving the accuracy of the aggregation information.

[0093] It should be noted that the updated aggregation information of S203 includes the target aggregate gradient value and the global model parameter values ​​of this round of training. The calculation formulas for these two parameter values ​​are illustrated below.

[0094] In some embodiments of this application, the updated aggregation information includes a target aggregation gradient value, wherein the target aggregation gradient value is obtained based on the updated gradient values ​​of a subset of clients, the subset of clients is obtained by filtering all clients based on the cumulative deviation value of each client, and the cumulative deviation value is obtained based on the single deviation value obtained in each round of training.

[0095] For example, the formula for calculating the target aggregate gradient value is as follows:

[0096]

[0097]

[0098] in, Characterizing the target aggregate gradient value, A p Representing the set of clients, |D i | Represents the number of elements contained in the local storage sample dataset of the i-th client. This represents the updated gradient value of the i-th client in the k-th round of training.

[0099] Embodiments of this application provide a formula for calculating the aggregate gradient value of a quantified target, thereby improving the accuracy and objectivity of the value.

[0100] In some embodiments of this application, the updated aggregation information includes the global model parameter values ​​of the current training round, wherein the global model parameter values ​​of the current training round are obtained based on the global parameter values ​​and learning rate of the previous training round.

[0101] For example, the formula for calculating the global model parameter values ​​in this round of training is:

[0102]

[0103] Where, Δ k Δ represents the global model parameter values ​​in the k-th training round. k-1 The global model parameter values ​​represent the (k-1)th training round, and η represents the learning rate. Characterizes the target aggregate gradient value.

[0104] Some embodiments of this application provide a calculation formula for updating global model parameter values, thereby improving the accuracy of these values. Some embodiments of this application also provide a formula for quantifying the calculation of global model parameter values, improving the accuracy and objectivity of the obtained values.

[0105] It is understood that, in some embodiments of this application, after S203, the method further includes: sending the update aggregation information to each client, wherein each client starts the next round of local model training and global model parameter update according to the update aggregation information. In some embodiments of this application, after S203, the method further includes: if it is confirmed that the training termination condition is met, then terminating the training process to obtain the target model.

[0106] The following is combined Figure 2 The process of local model initialization, local model training, and model parameter updating (the above-mentioned method for training the horizontal federated learning model is performed in this process) is described in detail, illustrating the method for training the horizontal federated learning model in this application.

[0107] Some embodiments of this application provide a training method for a lateral federated learning model that can defend against poisoning attacks, including the following steps:

[0108] Step 1, Model Initialization

[0109] Assume that the node corresponding to the master server in horizontal federated learning is S, and the node corresponding to any client in horizontal federated learning is C. i Where i is the client node number, N C Let i be the total number of client nodes in the horizontal federated learning (i.e., the total number of clients), where 0 < i ≤ N. C , i and N c All are positive integers.

[0110] Model initialization includes two steps: model parameter initialization and model parameter distribution.

[0111] The “model parameter initialization” example includes: the server node S uses a Gaussian random initialization method to initialize the parameters of the deep neural network model.

[0112] The “model parameter distribution” example includes: the server node S sends the parameter initialization value Δ0 of the deep neural network model to all horizontal federated learning client nodes to start the first round of local model training and global model parameter update.

[0113] The second step is local model training.

[0114] The initial training of the model mainly includes two steps: model training and parameter uploading.

[0115] Example of "model training": During the k-th round of local model training (k≥1, k is a positive integer), each horizontal federated learning client node C i Using the global model parameters Δ received from server node S k-1To update the local model, use all locally stored sample data as the training dataset, train the local model for one epoch using the stochastic gradient descent algorithm, and calculate the loss function and model parameters to update the gradient.

[0116] Example of "parameter upload": During the k-th round of local model training, each horizontal federated learning client node C... i Update gradient values ​​of the local model (As an example of model parameter information for the local model) is sent to server node S.

[0117] The third step is to update the model parameters.

[0118] Model parameter updates mainly include four steps: gradient aggregation, parameter evaluation, parameter update, and parameter distribution.

[0119] The aforementioned "gradient aggregation" includes, for example, the node S calculating the aggregated gradient of the global model during the k-th round of global model parameter updates. (That is, the initial aggregation gradient value, as an example of initial aggregation information, is calculated using the following formula), where D i For the client's node C i Local storage of sample datasets, | i |For set D i The number of elements contained, n is a hyperparameter determined based on empirical values ​​(n is a positive integer). |D T | represents the sum of the nth roots of the sample data of all client nodes (i.e., the formula for calculating the adjustment value of the training data distribution), and the specific calculation formula is as follows.

[0120]

[0121]

[0122] The "parameter evaluation" example includes: during the k-th round of global model parameter update, server node S calculates each update gradient value. Relative deviation B ik (i.e., the deviation value, which is calculated using the following formula), and the cumulative deviation index for each client node. (That is, the cumulative deviation value, which is calculated using the following formula). θ i for The relative deviation angle.

[0123]

[0124]

[0125]

[0126] The aforementioned "parameter update" includes, for example, during the k-th round of global model parameter update, the master server's node S updates all... Sort by value. The smallest value of N p The index numbers of the client nodes constitute a set A. p (i.e., a collection of some clients), for The smallest value of N p The update gradients of each client node are aggregated to generate the corrected aggregated gradient of the global model. (i.e., the aggregated gradient value of the target, the formula for calculating this value) and the global model parameter Δ k , where η is the learning rate, 0 < η < 1, and η is a real number. |D′ T |for The smallest value of N p The sum of the nth roots of the sample data of each client node.

[0127]

[0128]

[0129]

[0130] The aforementioned "parameter distribution" includes, for example, if the global model's parameter Δ k Convergence or k≥E TH If the training fails, the training process will terminate; otherwise, Δ will be applied. k Distribute to all client nodes, repeat all sub-steps including the local model training in step two and the model parameter update in step three, and begin the (k+1)th round of local model training and global model parameter update, E TH It is a positive integer.

[0131] The following example, using an online spam detection system as a specific application scenario, illustrates the method for training a horizontal federated learning model according to an embodiment of this application. The following examples can be applied to security hardening of an online spam detection system based on federated learning.

[0132] (1) Assume that the master server node of the horizontal federated learning is S, and the client node of the horizontal federated learning is C. i Where i is the client node number, N c=10000 represents the total number of client nodes in the horizontal federated learning. Server node S uses a Gaussian random initialization method to initialize the parameters of the adopted neural network model (such as RNN, LSTM, CNN model, etc.), and sends the parameter initialization value Δ0 of the deep neural network model to all horizontal federated learning client nodes to start the first round of local model training and global model parameter update.

[0133] (2) During the k-th round of local model training, each horizontal federated learning client node C i Using the global model parameters Δ received from server node S k-1 To update the local model, use all locally stored sample data as the training dataset, train the local model for one epoch using the stochastic gradient descent algorithm, and calculate the cross-entropy loss function and model parameter update gradients. During the k-th round of local model training, each lateral federated learning client node C i Update gradients using local model parameters. Send to server node S.

[0134] (3) During the k-th round of global model parameter update, server node S will calculate the aggregate gradient of the global model. Where D i For client node C i Local storage of sample datasets, | i |For set D i The number of elements contained, n=2.

[0135]

[0136]

[0137] During the k-th round of global model parameter updates, server node S calculates the update gradient for each model parameter. Relative deviation B ik and the cumulative deviation index of each client node.

[0138]

[0139]

[0140]

[0141] During the k-th round of global model parameter updates, server node S updates all... Sort by value. The smallest value of N p =The index numbers of the 9000 client nodes constitute a set Ap ,right The smallest value of N p =The update gradients of 9000 client nodes are aggregated to generate the aggregated gradient of the global model. and global model parameters Δ k , where η = 0.05 is the learning rate.

[0142]

[0143]

[0144]

[0145] If the parameters of the global model converge or k ≥ E TH If Δ = 100, the training process terminates; otherwise, Δ will be used. k Send the instructions to all client nodes and repeat steps (2) and (3) to begin the (k+1)th round of local model training and global model parameter update.

[0146] Some embodiments of this application provide a method for training a horizontal federated learning model, applied to a client, the method comprising: performing the next round of local model training based on the updated aggregate information of the current training round obtained as in any of the above embodiments.

[0147] To avoid repetition, I will not elaborate too much on obtaining the updated aggregate information of this training round. For details, please refer to the implementation method described above.

[0148] Please refer to Figure 4 , Figure 4 The apparatus for training a lateral federated learning model provided in an embodiment of this application is illustrated. It should be understood that this apparatus is similar to the one described above. Figure 3 Corresponding to the method embodiments, it is capable of executing the various steps involved in the above method embodiments. The specific functions of the device can be found in the description above; to avoid repetition, detailed descriptions are appropriately omitted here. The device includes at least one software functional module that can be stored in memory or embedded in the device's operating system in the form of software or firmware. The device for training the lateral federated learning model includes: a deviation value acquisition module 401, a client filtering module 402, and an aggregation information update module 403.

[0149] The deviation value acquisition module is configured to obtain initial aggregation information based on the model parameter information of the local model sent by each client in any training round, and calculate the deviation value based on the model parameter information of each client and the initial aggregation information to obtain a single deviation value set for all clients, wherein the deviation value is used to characterize the degree of deviation of the model parameter information of each client relative to the initial aggregation information.

[0150] The client filtering module is configured to filter out a subset of clients from all clients based on all deviation values ​​in the single deviation value set obtained from each round of training.

[0151] The aggregation information update module is configured to obtain the updated aggregation information for this round of training based on the model parameter information of the client.

[0152] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the device described above can be referred to the corresponding process in the aforementioned method, and will not be elaborated further here.

[0153] Some embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, can implement the method described in any of the embodiments of the above-described method for training a lateral federated learning model.

[0154] like Figure 5 As shown, some embodiments of this application provide an electronic device 500, including a memory 510, a processor 520, and a computer program stored in the memory 510 and executable on the processor 520, wherein when the processor 520 reads the program from the memory 510 via a bus 530 and executes the program, it can implement the method described in any of the embodiments of the above-described method for training a lateral federated learning model.

[0155] Processor 520 can process digital signals and can include various computing architectures. For example, it can be a complex instruction set computer architecture, a reduced instruction set computer architecture, or an architecture that implements multiple instruction set combinations. In some examples, processor 520 can be a microprocessor.

[0156] The memory 510 can be used to store instructions executed by the processor 520 or data related to the execution of instructions. These instructions and / or data may include code used to implement some or all of the functions of one or more modules described in the embodiments of this application. The processor 520 of the embodiments of this disclosure can be used to execute the instructions in the memory 510 to implement… Figure 2 The method shown. Memory 510 includes dynamic random access memory, static random access memory, flash memory, optical memory, or other memory well known to those skilled in the art.

[0157] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0158] In addition, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0159] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0160] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application. It should be noted that similar reference numerals and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.

[0161] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0162] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, 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 limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

Claims

1. A method of trans-federal learning model training, applied to a master server, comprising: The method includes: In any training round, initial aggregation information is obtained based on the model parameter information of the local model sent by each client, and the deviation value is calculated based on the model parameter information of each client and the initial aggregation information to obtain the single deviation value set of all clients. The deviation value is used to characterize the degree of deviation of the model parameter information of each client relative to the aggregated value of the model parameter information of other clients. A subset of clients are selected from all clients based on the cumulative deviation value of each client, wherein the cumulative deviation is obtained by multiple deviation values ​​obtained through multiple rounds of training; The updated aggregate information for this round of training is obtained based on the model parameter information of the aforementioned clients; The model parameter information is the updated gradient value, the initial aggregation information includes at least the initial aggregated gradient value of the global model, and the deviation value is obtained by the updated gradient value, the initial aggregated gradient value, and the number of samples for each client. The model parameter information is used to update gradient values, where, The step of obtaining initial aggregation information based on the model parameter information of the local model sent by each client includes: The training data distribution adjustment value is obtained based on the amount of data in the local sample dataset of each client; The initial aggregate gradient value is obtained by adjusting the training data distribution of each client and the updated gradient value; The step of obtaining the training data distribution adjustment value based on the amount of local sample datasets of each client includes: The nth root of the local sample dataset of each client is calculated to obtain the value to be accumulated for each client. The training data distribution adjustment value is obtained by accumulating the values ​​to be accumulated.

2. The method as described in claim 1, characterized in that, The step of selecting a subset of clients from all clients based on the cumulative deviation value of each client includes: The cumulative deviation value of the i-th client is calculated based on the single deviation value of the i-th client obtained from each round of training. The selected clients are chosen from all the clients based on the cumulative deviation value of all the clients. The step of obtaining the updated aggregate information for this round of training based on the model parameter information of the aforementioned clients includes: The update gradient values ​​of each client in the aforementioned client subset are aggregated to obtain the update aggregation information.

3. The method of claim 2, wherein, The step of calculating the cumulative deviation value of the i-th client based on the single deviation value of the i-th client obtained from each round of training includes: The cumulative deviation value of the i-th client is obtained by weighted summing of the n single deviation values ​​obtained from n rounds of training.

4. The method of claim 2, wherein, The step of selecting a subset of clients from all clients based on the cumulative deviation value of each client includes: Sort the k cumulative deviation values ​​of all k clients in order of size to obtain an ordered queue; The m clients corresponding to the first m cumulative deviation values ​​of the ordered queue are selected as the partial clients, or the m clients corresponding to the last m cumulative deviation values ​​of the ordered queue are selected as the partial clients, wherein the first m cumulative deviation values ​​or the last m cumulative deviation values ​​are all less than all other cumulative deviation values ​​in the ordered queue, and m is an integer less than k.

5. The method of claim 1, wherein, The initial aggregation gradient value is calculated using the following formula: in, Characterizing the initial aggregation gradient value, Adjust the value for the training data distribution. The total number of all clients, It represents the updated gradient value of any client during this training.

6. The method as described in claim 5, characterized in that, The updated aggregation information includes a target aggregation gradient value, wherein the target aggregation gradient value is obtained based on the updated gradient values ​​of a subset of clients, the subset of clients is obtained by filtering all clients based on the cumulative deviation value of each client, and the cumulative deviation value is obtained based on the single deviation value obtained in each round of training.

7. The method as described in claim 6, characterized in that, The formula for calculating the target aggregation gradient value is as follows: in, Characterizes the target aggregate gradient value, Characterizes the aforementioned set of clients. The number of elements contained in the locally stored sample dataset of the i-th client. This represents the updated gradient value of the i-th client in the k-th round of training.

8. The method as described in claim 7, characterized in that, The updated aggregate information includes the global model parameter values ​​of the current training round, wherein the global model parameter values ​​of the current training round are obtained based on the global parameter values ​​and learning rate of the previous training round.

9. The method as described in claim 8, characterized in that, The formula for calculating the global model parameter values ​​in this round of training is as follows: in, The global model parameter values ​​represent the values ​​from the k-th training round. The global model parameter values ​​represent the values ​​from the (k-1)th training round. Characterizing the learning rate, Characterizes the target aggregate gradient value.

10. The method as described in claim 1, characterized in that, After obtaining the updated aggregation information for this round of training based on the model parameter information of the aforementioned clients, the method further includes: The update aggregation information is sent to each client, wherein each client starts the next round of local model training and global model parameter update based on the update aggregation information.

11. The method as described in claim 1, characterized in that, After obtaining the updated aggregation information for this round of training based on the model parameter information of the aforementioned clients, the method further includes: If the training termination condition is confirmed to be met, the training process is terminated and the target model is obtained.

12. A training method for a horizontal federated learning model, applied to a client, characterized in that, The method includes: The next round of local model training is performed based on the updated aggregated information obtained from the current training round as described in any one of claims 1-11.

13. A master server for a horizontal federated learning model, characterized in that, The main server includes: The deviation value acquisition module is configured to obtain initial aggregation information based on the model parameter information of the local model sent by each client in any training round, and calculate the deviation value based on the model parameter information of each client and the initial aggregation information to obtain a single deviation value set for all clients, wherein the deviation value is used to characterize the degree of deviation of the model parameter information of each client relative to the initial aggregation information. The client filtering module is configured to filter out a portion of clients from all clients based on the cumulative deviation value of each client, wherein the cumulative deviation is obtained by multiple deviation values ​​obtained through multiple rounds of training; The aggregation information update module is configured to obtain the updated aggregation information for this round of training based on the model parameter information of the aforementioned clients; The model parameter information is the updated gradient value, the initial aggregation information includes at least the initial aggregated gradient value of the global model, and the deviation value is obtained by the updated gradient value, the initial aggregated gradient value, and the number of samples for each client. The model parameter information is used to update gradient values, where, The deviation value acquisition module is configured to obtain the training data distribution adjustment value based on the amount of data in the local sample dataset of each client; and to obtain the initial aggregate gradient value through the training data distribution adjustment value of each client and the update gradient value. The deviation value acquisition module is configured to perform an nth-fold power operation on the amount of data in the local sample dataset of each client to obtain a value to be accumulated corresponding to each client; and to accumulate the values ​​to be accumulated to obtain the training data distribution adjustment value.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by a processor, it can implement the method described in any one of claims 1-12.

15. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, When the processor executes the program, it can implement the method described in any one of claims 1-12.