A model optimization method, device and medium based on federated learning

By grouping and injecting random noise in federated learning, the global model accuracy in non-independent and identically distributed data scenarios is optimized, communication overhead is reduced, and the problems of low accuracy and high communication overhead in existing technologies are solved.

CN121257783BActive Publication Date: 2026-04-10银联数据服务有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-05
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

Existing federated learning optimization schemes have low global model accuracy in scenarios with non-independent and identically distributed data, and their communication overhead is too high.

Method used

By selecting clients with high data distribution similarity on the server side and grouping them, and injecting random noise into each group of clients to generate a mutation model, the client performs local training and then aggregates the model, reducing the number of communications. The model is optimized by dynamically adjusting the noise intensity and clustering algorithm.

Benefits of technology

It improves the global model accuracy in scenarios with non-independent and identically distributed data, while reducing communication overhead, reducing mutation redundancy, and enhancing the model's generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121257783B_ABST
    Figure CN121257783B_ABST
Patent Text Reader

Abstract

The application discloses a model optimization method and device based on federated learning and a medium, relates to the technical field of artificial intelligence, and is used for improving the accuracy of a global model in a non-independent and identically distributed data scene and reducing communication overhead in an optimization process. The method comprises the following steps: in the optimization process of the tth round, N groups of clients are selected from a client resource pool; random noise is injected into the model parameters of a first global model for each group of clients to generate a first variation model and the first variation model is delivered; a first aggregation model corresponding to each of the N groups of clients is received and a second global model is obtained by aggregation, the first aggregation model being obtained by aggregating local models obtained by training the first variation model by the clients in each group; if the second global model does not satisfy a first preset condition, the second global model is taken as the first global model in the optimization process of the t+1th round for continuous optimization until the first preset condition is satisfied; and therefore, the accuracy of the global model is improved and the communication overhead in the optimization process is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of artificial intelligence, and in particular to a model optimization method based on federated learning, a device and a medium. BACKGROUND

[0002] In the core mechanism of federated learning, multiple clients train a model based on a local data set without sharing the original data. Each client uploads the trained model to a central server. The central server aggregates the models uploaded by each client to generate a global model. The central server then distributes the global model to multiple clients for iterative optimization to solve the data privacy and data island problems. However, the global model obtained by the current mainstream federated learning optimization scheme has low accuracy in a non-independent and identically distributed (Non-IID) data scenario, and the communication overhead between the central server and each client in the global model optimization process is too high. SUMMARY

[0003] The embodiments of the present application provide a model optimization method based on federated learning, a device and a medium, which are used to improve the accuracy of the global model optimized in a non-independent and identically distributed data scenario while reducing the communication overhead in the optimization process.

[0004] In a first aspect, the present application provides a model optimization method based on federated learning, applied to a server, the method comprising: in the optimization process of the tthround, for a first global model to be optimized, performing the following operations: selecting multiple clients from a client resource pool for activation, and dividing them into N groups of clients, the data distribution corresponding to the local data of the multiple clients being greater than or equal to a first threshold; the local data of each client in the client resource pool being in a non-independent and identically distributed state; for each group of clients in the N groups of clients, performing: injecting random noise into the model parameters of the first global model to generate a first variation model; sending the first variation model and first indication information to the group of clients, the first indication information being used to instruct each client in the group of clients to perform local training on the first variation model based on the local data, and aggregate the local training results within the group; receiving a first aggregated model sent by a target client in the group of clients, the first aggregated model being obtained by the target client based on the local models of each client in the group, each client's local model being obtained by performing local training on the first variation model based on the local data of the client; aggregating the first aggregated models corresponding to the N groups of clients to obtain a second global model; if the second global model obtained in the optimization process of the tthround does not satisfy a first preset condition, taking the second global model obtained in the optimization process of the tthround as the first global model to be optimized in the optimization process of the t+1thround for continuous optimization until the second global model satisfies the first preset condition. t is a positive integer.

[0005] In the above scheme, in the optimization process of the tth round, the server selects multiple clients with a distribution similarity greater than or equal to a first threshold from the client resource pool to activate and group, for the first global model to be optimized, so that the intra-group gradient of the local model of each client in each group of clients is reduced, and the aggregation efficiency is improved. Then, at the granularity of each group of clients, random noise is injected into the model parameters of the first global model to generate a first variant model, and the first variant model and the first indication information are issued, which can effectively alleviate the problem of model generalization caused by data heterogeneity, improve the accuracy of the finally generated global model, and each client in each group of clients shares the same variant model, which can reduce the variation redundancy. After each client in each group of clients trains a local model based on local data, a target client in the group uploads a first aggregation model obtained by aggregating all local models in the group, that is, each group of clients uploads a first aggregation model, compared with the way that each client uploads a local model to the server, the communication overhead between the server and the multiple clients can be reduced.

[0006] Optionally, the method further includes: when t satisfies a second preset condition, dividing the clients in the client resource pool into M candidate groups based on the local data of each client in the client resource pool through a clustering algorithm, each candidate group including clients whose local data corresponds to a distribution similarity greater than or equal to a first threshold, and M is an integer greater than 1; selecting multiple clients from the client resource pool to group to obtain N groups of clients, including: selecting a target candidate group from the M candidate groups, and dividing the clients in the target candidate group into N groups of clients.

[0007] Optionally, the mutation strength of the random noise injected into the first global model in the tth round of optimization process is dynamically adjusted based on the gradient variance corresponding to the second global model obtained in the t-1th round of optimization process, wherein the gradient variance corresponding to the second global model obtained in the t-1th round of optimization process is calculated based on the gradient between each model parameter of the second global model obtained in the t-1th round of optimization process and each model parameter of the second global model obtained in the t-2th round of optimization process.

[0008] Optionally, the first aggregation models corresponding to the N groups of clients are aggregated to obtain a second global model, including: for any group of clients in the N groups of clients, determining a weight corresponding to the group of clients according to the proportion of the total data amount corresponding to the group of clients in the total data amount corresponding to the N groups of clients, and the model accuracy corresponding to the first aggregation model corresponding to the group of clients; and aggregating the first aggregation models corresponding to the N groups of clients respectively according to the weights corresponding to the N groups of clients to obtain the second global model.

[0009] Optionally, the first aggregation model corresponding to the N groups of clients is aggregated according to the weights corresponding to the N groups of clients respectively, to obtain a second global model, including: if the gradient loss of the second global model obtained in the tth optimization process relative to the second global model obtained in the (t-1) th optimization process decreases by less than a second threshold, a retraining instruction is issued to the N groups of clients, the retraining instruction being used to instruct each group of clients in the N groups of clients to retrain the first variant model received by the group based on local data, to obtain a new local model; receiving the second aggregation model sent by the N groups of clients respectively, the second aggregation model sent by each group of clients being obtained by aggregating the new local model obtained by each client in the group based on the retraining; and the second aggregation model corresponding to the N groups of clients is aggregated according to the weights corresponding to the N groups of clients respectively, to obtain the second global model.

[0010] Optionally, before the first aggregation model corresponding to the N groups of clients is aggregated to obtain the second global model, it further includes: receiving the third aggregation model sent by at least one group of clients respectively, and aggregating the first aggregation model corresponding to the N groups of clients to obtain the second global model, including: aggregating the third aggregation model corresponding to at least one group of clients and the first aggregation model corresponding to other groups of clients in the N groups of clients except at least one group of clients to obtain the second global model; wherein the third aggregation model corresponding to any group of clients is obtained by re-aggregating the local model of the client with dirty data after retraining and the local model of the client without dirty data in the group, or the third aggregation model is obtained by triggering re-aggregation of the local model corresponding to the normal clients in the group when there is an abnormal client in the group.

[0011] In a second aspect, the application provides a model optimization method based on federated learning, applied to a target client, the target client belonging to a first group of clients, and the data distribution similarity of the local data of each client in the first group of clients being greater than or equal to a first threshold; the method comprising: in the optimization process of the t th round, t being a positive integer, performing the following operations: receiving a first variant model and first indication information sent by a server, the first indication information being used to instruct each client in the first group of clients to perform local training on the first variant model based on local data, and aggregate the local training results within the group; in response to the first indication information, performing local training on the first variant model based on the local data of the target client to obtain a local model corresponding to the target client; sending the first variant model and second indication information to other clients in the first group of clients except the target client, the second indication information being used to instruct the other clients in the first group of clients to perform local training on the first variant model based on local data; receiving the local models obtained by the other clients in the first group of clients except the target client in response to the second indication information; aggregating the local models corresponding to each client in the first group of clients to obtain a first aggregated model; and sending the first aggregated model to the server, the first aggregated model being used to aggregate the first aggregated models corresponding to other groups of clients to obtain a second global model.

[0012] Optionally, aggregating the local models corresponding to each client in the first group of clients to obtain the first aggregated model comprises: for any client in the first group of clients, determining a weight corresponding to the client according to the proportion of the local data amount of the client in the total data amount of the first group of clients; performing weighted summation on the first model parameters of the local models corresponding to each client in the first group of clients according to the weights corresponding to each client in the first group of clients to obtain second model parameters; and generating the first aggregated model according to the second model parameters.

[0013] Optionally, performing weighted summation on the first model parameters of the local models corresponding to each client in the first group of clients according to the weights corresponding to each client in the first group of clients to obtain second model parameters comprises: identifying abnormal parameters in the first model parameters of the local models corresponding to each client in the first group of clients, and eliminating the abnormal parameters; and performing weighted summation on the first model parameters after eliminating the abnormal parameters according to the weights corresponding to each client in the first group of clients to obtain the second model parameters.

[0014] Optionally, before sending the first aggregated model to the server, further comprising: if there is dirty data in the first group of clients, the target client aggregates the re-aggregated results of the re-trained local model of the client with dirty data and the local model of the client without dirty data as the first aggregated model; or if there is an abnormal client in the first group of clients, the target client aggregates the local models corresponding to the other clients in the first group of clients except the abnormal client as the first aggregated model.

[0015] In a third aspect, the application provides a model optimization device based on federated learning, comprising a grouping module, a model mutation module, a communication module, an aggregation module and a control module; in the optimization process of the tth round, t is a positive integer, for the first global model to be optimized, wherein:

[0016] The grouping module is configured to select a plurality of clients from the client resource pool for activation and divide them into N groups of clients, wherein the data distribution similarity of the local data of the plurality of clients is greater than or equal to a first threshold; and the local data of each client in the client resource pool is in a non-independent and identically distributed manner.

[0017] The model mutation module is configured to inject random noise into the model parameters of the first global model to generate a first mutated model for each group of clients in the N groups of clients.

[0018] The communication module is configured to send the first mutated model and first indication information to the group of clients, wherein the first indication information is used to instruct each client in the group of clients to perform local training on the first mutated model based on the local data, and aggregate the local training results within the group; and receive the first aggregated model sent by a target client in the group of clients, wherein the first aggregated model is obtained by the target client based on the local models corresponding to each client in the group, and the local model corresponding to each client is obtained by performing local training on the first mutated model based on the local data of the client.

[0019] The aggregation module is configured to aggregate the first aggregated models corresponding to the N groups of clients to obtain a second global model.

[0020] The control module is configured to, if the second global model obtained in the optimization process of the tth round does not satisfy the first preset condition, continue to optimize the second global model obtained in the optimization process of the tth round as the first global model in the optimization process of the t+1th round until the second global model obtained satisfies the first preset condition.

[0021] In a fourth aspect, the application provides a model optimization device based on federated learning, applied to a target client, the target client belonging to a first group of clients, and data distributions corresponding to local data of each client in the first group of clients having a similarity greater than or equal to a first threshold value; the model optimization device based on federated learning comprises a communication module, a training module, and an aggregation module; in a t-th round of optimization process, t being a positive integer:

[0022] The communication module is configured to receive a first variant model and first indication information sent by a server, the first indication information being used to instruct each client in the first group of clients to perform local training on the first variant model based on local data, and aggregate local training results within the group.

[0023] The training module is configured to, in response to the first indication information, perform local training on the first variant model based on local data of the target client, to obtain a local model corresponding to the target client.

[0024] The communication module is further configured to send the first variant model and second indication information to other clients in the first group of clients except the target client, respectively, the second indication information being used to instruct the other clients in the first group of clients to perform local training on the first variant model based on local data; and receive local models obtained by the other clients in the first group of clients except the target client in response to the second indication information.

[0025] The aggregation module is configured to aggregate the local models corresponding to each client in the first group of clients, respectively, to obtain a first aggregated model.

[0026] The communication module is further configured to send the first aggregated model to the server, the first aggregated model being used to aggregate first aggregated models corresponding to other groups of clients to obtain a second global model.

[0027] In a fifth aspect, the application further provides a computing device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor executes the program to implement the method described in any of the possible designs of the first aspect.

[0028] In a sixth aspect, the application further provides a computer-readable storage medium, the computer-readable storage medium storing a computer program or instructions, and the computer program or instructions are executed by a processor to implement the method described in any of the possible designs of the first aspect.

[0029] In a seventh aspect, the application further provides a computer program product, when the computer program product is executed on a computer, the computer program product causes the computer to execute the method of the first aspect or any of the possible designs of the first aspect. BRIEF DESCRIPTION OF DRAWINGS

[0030] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the description of the embodiments will be briefly introduced. Obviously, the drawings in the following description only constitute some embodiments of the present application.

[0031] Figure 1 The schematic diagram of the system architecture provided for the embodiments of the present application;

[0032] Figure 2 The flowchart of the model optimization method based on federated learning provided for the embodiments of the present application;

[0033] Figure 3 The structural block diagram of the model optimization device based on federated learning provided for the embodiments of the present application;

[0034] Figure 4 Another structural block diagram of the model optimization device based on federated learning provided for the embodiments of the present application;

[0035] Figure 5 The structural schematic diagram of the computing device provided for the embodiments of the present application. DETAILED DESCRIPTION

[0036] In order to make the purposes, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments described in the present application document, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of protection of the present application technical solutions.

[0037] The current mainstream federated learning optimization scheme includes the following three types:

[0038] (1) Federated averaging (FedAvg) algorithm, the process is: the client performs a multi-round optimization process on the local data set, and then uploads the parameter update to the server; the server is weighted and aggregated according to the proportion of the local data volume of the client (N i / N, N i is the data volume of the client i, and N is the total data volume) to generate a global model. This algorithm is suitable for data distribution uniform (IID) scene, but depends on parameter compression and asynchronous communication to optimize communication efficiency. In the non-independent and identically distributed (Non-IID) data scene

[0039] (2) Proximal Federated Learning (FedProx) algorithm, which introduces a proximal term (μ ω-ωt 2, μ is a hyperparameter) to constrain local updates, reduce the deviation of client models from the global model, and mitigate the "model drift" caused by data heterogeneity. The core is to reduce the deviation of the local optimization direction by conservative constraint, which is suitable for mild Non-IID scenarios.

[0040] (3) Random mutation federated learning (FedMut) algorithm, aiming at the decline of model generalization caused by data heterogeneity, introduces a random mutation strategy: inject controllable noise in gradient update to generate diversified model variants, guide the model to jump out of the sharp optimal solution and converge to the flat optimal region. The algorithm improves the test accuracy by 12.09% compared with FedAvg under the CIFAR-10 extreme heterogeneous environment (μ = 0.1), but needs to generate multiple mutant models to distribute to multiple clients, and the communication overhead between the server and multiple clients is large. delta

[0041] The above mainstream federated learning optimization schemes have low model accuracy in non-independent and identically distributed (Non-IID) data scenarios and high communication overhead.

[0042] In view of this, the inventors of the present application provide a model optimization method based on federated learning, which is used to improve the accuracy of the global model optimized under the non-independent and identically distributed data scenario while reducing the communication overhead in the optimization process.

[0043] Figure 1 A system architecture diagram provided by an embodiment of the present application is shown. As shown in the figure, the system architecture can include a server and a client resource pool, wherein the client resource pool includes a large number of clients, and the server is connected with each client in the client resource pool. Figure 1

[0044] The federated learning optimization process provided by the present application is an iterative optimization process, including multiple rounds of optimization processes, and one round of optimization process includes: optimizing the global model to be optimized to obtain an optimized global model; if the optimized global model meets a first preset condition, the optimized global model is the final global model and no longer continues to be optimized; if the optimized global model does not meet the first preset condition, the global model optimized in the current round of optimization is taken as the global model to be optimized in the next round of optimization process, and the next round of optimization process is continued until the optimized global model obtained in a certain round of optimization process meets the first preset condition.

[0045] ​​In an embodiment of the present application, the global model to be optimized in the tth optimization process can be the initialized global model or the global model obtained by performing the optimization process of the last round, and t is a positive integer. When t is equal to 1, the global model to be optimized in the 1st optimization process is the initialized global model M0, that is, the 1st optimization process is performed on the initialized global model M0. When t is greater than 1, the global model to be optimized in the tth optimization process is the global model Mt-1 shown in Figure 1 , that is, the tth optimization process is performed on the global model Mt-1 optimized in the (t-1)th optimization process.

[0046] The following describes the tth optimization process by taking t greater than 1 as an example.

[0047] The server can select multiple clients from the client resource pool to activate and group into N groups of clients, for example Figure 1 , the server selects multiple clients (n N clients) from the client resource pool to group, to obtain client group 1, client group 2, …, and client group N, each client group includes n clients, for example, client group 1 includes client 11, client 12, …, and client 1n; client group 2 includes client 21, client 22, …, and client 2n; and client group N includes client N1, client N2, …, and client Nn.

[0048] The server injects random noise into the global model Mt-1 to obtain a mutated model, which is the mutation shown in Figure 1 . The server injects random noise into the global model Mt-1 to obtain a mutated model for each group of clients in the N groups of clients, to generate a mutated model, and the N groups of clients correspond to the generation of N mutated models, for example Figure 1 , the mutated models m1, m2, …, and mN in the mutation model m1, the mutation model m2, …, and the mutation model mN in the mutation model mN. Since random noise is injected into the global model each time, the noise injected into the global model each time is different, so that the mutated models generated for different groups of clients are different. For any group of clients, all clients in the group share the same mutated model. Then, the server respectively sends different mutated models to the N groups of clients; for example, the server sends the mutated model m1 to the client group 1, the mutated model m2 to the client group 2, …, and the mutated model mN to the client group N. The server also sends first indication information to each group of clients, to instruct each client in each group of clients to perform local training on the first mutated model based on local data, and aggregate the local training results in the group.

[0049] Each of the N client groups can include a master client and multiple slave clients. Each client group constructs a star topology, with the master client connecting to multiple slave clients. The server can send a mutation model and a first instruction message to the master client in each client group. In response to the first instruction message, the master client sends the mutation model and the first instruction message to all slave clients in the group. In response to the first instruction message, the master client sends a mutation model and a second instruction message to all slave clients in the group. The second instruction message is used to instruct other clients in the group to train the mutation model locally based on local data.

[0050] The master client can receive local models trained separately by all slave clients within the group. The master client then aggregates these local models with the individual local models trained by each slave client to obtain an aggregated model. For example, a group of clients may consist of n clients. Figure 1 Taking client group 1 as an example, with client 11 as the primary client, after receiving the mutation model m1 and the first instruction information from the server, client 11 distributes the mutation model m1 and the second instruction information to all clients from client 12 to client 1n in response to the first instruction information. Client 11 then trains the mutation model m1 based on its own local data to obtain a local model 11. Each client from client 12 to client 1n trains the mutation model m1 based on its own local data in response to the second instruction information. For example, client 12 trains the mutation model m1 to obtain a local model 12, and client 1n trains the mutation model m1 to obtain a local model 1n. Client 11 receives the local models 12 to 1n sent by each client, and then aggregates its own trained local model 11 with all the local models 12 to 1n sent by the clients to obtain an aggregated model M1. Similarly, in client group 2, each client trains the mutation model m2 based on its own local data to obtain a local model, and then aggregates them to obtain an aggregate model M2; in client group N, each client trains the mutation model mN based on its own local data to obtain a local model, and then aggregates them to obtain an aggregate model MN.

[0051] The main client in each client group can also upload the aggregated model to the server, for example... Figure 1Client 11 in client group 1 uploads aggregate model M1 to the server, client 21 in client group 2 uploads aggregate model M2 to the server, and client N1 in client group N uploads aggregate model MN to the server. Thus, N groups of clients upload a total of N aggregate models to the server, namely aggregate models M1 to MN.

[0052] After receiving N aggregated models uploaded by N clients, the server aggregates the N aggregated models to obtain an optimized global model, as shown below. Figure 1 In the aggregation model Mt, if the optimized global model obtained in the t-th round of optimization satisfies the first preset condition, then the optimized global model obtained in the t-th round of optimization is taken as the final global model, that is... Figure 1 The aggregated model Mt is used as the final global model. If the optimized global model obtained in the t-th round of optimization does not meet the first preset condition, then the optimized global model obtained in the t-th round of optimization is used as the global model to be optimized in the next round (i.e., the t+1-th round), and the next round (i.e., the t+1-th round of optimization) continues. Figure 1 For example, if Figure 1 If the aggregated model Mt does not meet the first preset condition, then Mt is taken as the global model to be optimized, and the next round of optimization is performed on Mt until the optimized global model meets the first preset condition, at which point the optimization process ends. The first preset condition in this application can be that the number of rounds of optimization reaches a preset number of rounds, or that the loss reduction of the second global model obtained by the continuous optimization process of y rounds is less than a preset threshold, where y is a positive integer. This application does not impose any restrictions on the specific value of y, nor on the various thresholds mentioned in the text, which will not be elaborated further below.

[0053] based on Figure 1 The system architecture shown is as follows: Figure 2 This document provides an exemplary flowchart of a model optimization method based on federated learning, as illustrated in an embodiment of this application. The following description uses the interaction between a server and multiple groups of clients as an example to illustrate this process. Specifically, the interaction can occur between the server and the client. For any group of clients, the target client can be the primary client within that group. The process includes the following steps:

[0054] Step 201: In the optimization process of the t-th round, for the first global model to be optimized, the server selects multiple clients from the client resource pool for activation and divides the multiple clients into N groups of clients. The data distribution similarity corresponding to the local data of the multiple clients is greater than or equal to the first threshold.

[0055] Where t is a positive integer.

[0056] When t is equal to 1, that is, the first round of the optimization process, a round of optimization process is performed for the initialized global model.

[0057] When t is greater than 1, the server performs a round of optimization process on the second global model obtained in the (t-1)th round of optimization process, that is, the tth round of optimization process.

[0058] The local data of each client in the client resource pool in the above step 201 is non-identically distributed data, that is, the local data of each client in the client resource pool is non-identically distributed (for example, the Dirichlet distribution coefficient δ is less than 0.5), the local data of different clients is different, the local data of different clients is not shared, and the local data of each client is not uploaded to the server. The server groups the clients in the client resource pool according to the data distribution characteristics of the local data of each client in the client resource pool.

[0059] In an optional embodiment of the present application, the server in the above step 201 selects multiple clients from the client resource pool for activation, and divides the multiple clients into N groups of clients. This can be achieved in the following way: based on the local data of each client in the client resource pool, the clients in the client resource pool are divided into M candidate groups by a clustering algorithm, each candidate group including clients whose local data has a data distribution similarity greater than or equal to a first threshold, and M is an integer greater than 1; then, a target candidate group is selected from the M candidate groups, and the clients in the target candidate group are divided into N groups of clients. In this way, the gradient conflict within the group can be reduced. That is, in each round of optimization process, the server will perform a process of dividing multiple candidate groups. The local data of each client in the client resource pool is dynamically changing, and the distribution similarity of the previously divided candidate groups may decrease. Through the above implementation, it can be ensured that the distribution similarity of the local data of each group of clients selected by the server in each round of optimization process is high.

[0060] In another optional embodiment of the present application, when t satisfies a second preset condition, the server divides the clients in the client resource pool into M candidate groups based on the local data of each client in the client resource pool through a clustering algorithm, each candidate group includes clients whose local data correspond to a data distribution similarity greater than or equal to a first threshold, and M is an integer greater than 1. The second preset condition includes that t is a multiple of i, where i can be a positive integer. When i is equal to 1, the server performs the process of dividing candidate groups once in each round of optimization. When i is greater than 1, the server performs the process of dividing candidate groups once after i rounds of optimization, for example, i is equal to 10, that is, the server performs the process of dividing candidate groups once after 10 rounds of optimization. In this way, the process of dividing multiple candidate groups can be performed again after i rounds of optimization, and i can be pre-set or changed in real time as needed. For example, when the local data of each client in the client resource pool changes slightly, 10 rounds of re-division of candidate groups can be set, and when the local data of each client changes frequently, 5 rounds of optimization process can be set to re-divide the candidate groups. Further, the server in step 201 of the above embodiment selects multiple clients from the client resource pool for activation and divides the multiple clients into N groups of clients, which can be achieved by the following method: selecting a target candidate group from the M candidate groups and dividing the clients in the target candidate group into N groups of clients. That is, the process of selecting a candidate group from the M candidate groups for re-grouping is performed once in each round of optimization.

[0061] In any of the above embodiments, the clustering algorithm is, for example, a K-means algorithm. Taking an example in which the client resource pool includes L clients and the number of activated clients in each round is K, the server can divide the L clients into M candidate groups based on the category distribution of the local data of the clients through the K-means algorithm, where M is the ratio of the total number of clients L to the number of activated clients K in each round. The server can select a target candidate group from the M candidate groups, and divide the K clients in the target candidate group into N groups of clients, where N is equal to .

[0062] The server can construct a star communication topology for each group of N groups of clients, each group of clients including a master client and multiple slave clients, and the master client can communicate with the server and multiple slave clients respectively. It should be noted that in a group of clients, if the master client is offline, a new master client can be determined in the group, for example, by election or randomly, and the present application does not limit the way of determining the new master client. In the present application, the master client can also be referred to as a target client, which will not be described below.

[0063] Step 202, for the first group of clients in the N groups of clients, the server injects random noise into the model parameters of the first global model to be optimized to generate a first mutated model; the first group of clients is any group of clients in the N groups of clients.

[0064] In the embodiment of the application, in the optimization process of the tthround, the server will execute steps 202-203 for each group of clients in the N groups of clients. The embodiment of the application takes the first group of clients as an example for description. Other groups of clients except the first group of clients can refer to the related description of steps 202-203, which will not be repeated hereinafter.

[0065] In an optional embodiment of the application, the mutation strength of the random noise injected into the first global model in the optimization process of the tthround is dynamically adjusted based on the gradient variance corresponding to the second global model obtained in the optimization process of the t-1thround, wherein the gradient variance corresponding to the second global model obtained in the optimization process of the t-1thround is calculated based on the gradient between each model parameter of the second global model obtained in the optimization process of the t-1thround and each model parameter of the second global model obtained in the optimization process of the t-2thround.

[0066] Taking the second global model obtained in the optimization process of the t-1thround as an example, and taking the second global model obtained in the optimization process of the t-2thround as an example, the server calculates the gradient according to the following formula:

[0067] = -

[0068] The gradient variance of all gradients is calculated Var ( ), and then the mutation strength is dynamically updated based on the gradient variance α g The mutation strength can be calculated by the following formula α g :

[0069]

[0070] wherein, β is a control coefficient, β the larger the control coefficient is, the stronger the exploratory is, β=1 and the mutation strength will be adaptively adjusted. When Var ( ) is large (the model is far away from the optimal solution), α g the mutation strength is increased to promote model exploration; whenVar ) small (close to the optimal solution), α g decrease, avoid destroying the current optimal state.

[0071] In the mainstream federated learning scheme, the performance of FedProx is highly dependent on the value of the hyperparameter mu , mu overly large inhibits local optimization flexibility, and too small cannot constrain drift, and it usually needs 5-10 experiments to determine the optimal value; the mutation range of FedMut α g is sensitive, α g overly large leads to training failure, which needs manual repeated debugging, and the engineering landing cost is high. In the embodiment of the application, the mutation strength of the random noise injected into the first global model in the optimization process of the tthround is dynamically adjusted based on the gradient variance corresponding to the second global model obtained in the optimization process of the t-1thround, which is an adaptive adjustment strategy, does not need manual intervention, and can avoid hyperparameter sensitivity. It can stably converge under different data sets (such as CIFAR-10 / MNIST) and global models (such as CNN / DNN / ResNet18), and the debugging cost is greatly reduced.

[0072] In the above step 202, the server injects α g Gaussian noise of order of magnitude N(0,α g 2 ) into the model parameters of the first global model for each group of clients, generating a mutation matrix, that is, N groups of clients correspond to N mutation matrices, wherein each mutation matrix corresponds to a first mutation model of a group of clients. In this way, it can be ensured that the same group of clients uses the same mutation model, reduces mutation redundancy, and the first mutation model corresponding to different groups of clients is different.

[0073] Step 203, the server sends the first mutation model and the first indication information to the target client in the first group of clients, and the first indication information is used to instruct each client in the group of clients to perform local training on the first mutation model based on local data, and aggregate the local training results within the group.

[0074] Correspondingly, the target client in the first group of clients receives the first mutation model and the first indication information sent by the server.

[0075] ​It should be understood that the first variant model and the first indication information can be sent in one message or separately, which is not limited in the present application.

[0076] In step 204, the target client in the first group of clients sends the first variant model and the second indication information to other clients in the first group of clients respectively in response to the first indication information, and locally trains the first variant model based on local data of the target client to obtain a local model corresponding to the target client. The second indication information is used to instruct other clients in the first group of clients to locally train the first variant model based on local data.

[0077] It should be understood that the first variant model and the second indication information can be sent in one message or separately, which is not limited in the present application.

[0078] Each client in the first group of clients locally trains the first variant model based on local data of the client to obtain a local model corresponding to the client.

[0079] Taking the target client as an example, the first variant model is locally trained based on local data of the target client to obtain a local model corresponding to the target client. After receiving the first variant model and the second indication information, other clients in the first group of clients except the target client locally train the first variant model based on local data of the other clients in response to the second indication information. The local data of different clients in the first group of clients is different, and different clients locally train the same first variant model to obtain a local model corresponding to each client, and the local models corresponding to different clients are different. The present application does not limit the specific implementation of the local training of each client. The local model training on any client can be multi-batch training based on local data, for example, learning rate eta = 0.001, batch size 32.

[0080] In step 205, the target client in the first group of clients receives the local models trained by other clients in the first group of clients in response to the second indication information.

[0081] The target client is a master client in the first group of clients.

[0082] In step 206, the target client in the first group of clients aggregates the local models corresponding to each client in the first group of clients to obtain a first aggregated model.

[0083] In this embodiment of the application, the target client in each of the N groups of clients performs intra-group aggregation on the local model trained by each client in the group, thereby obtaining the first aggregated model corresponding to each group of clients.

[0084] In one optional embodiment of this application, for any client in the first group of clients, the target client in the first group of clients determines the weight of the client based on the proportion of the local data volume corresponding to the client in the total data volume corresponding to the first group of clients; the target client in the first group of clients performs a weighted summation of the first model parameters of the local models corresponding to each client in the first group of clients based on the weights of each client in the first group of clients, to obtain the second model parameters; then the target client in the first group of clients generates a first aggregate model based on the second model parameters.

[0085] Taking the first group of clients, consisting of 5 clients (client 1, client 2, client 3, client 4, and client 5), as an example, the local data volume corresponding to client 1 is... S 1 The local data volume corresponding to client 2 is S 2 The local data volume corresponding to client 3 is S 3 The local data volume corresponding to client 4 is S 4 The local data volume corresponding to client 5 is S 5 The total data volume corresponding to the first group of clients S total for S 1 , S 2 , S 3 , S 4 as well as S 5 The sum of all weights. The weight w corresponding to client 1. 1 for S 1 / S total The weight w corresponding to client 2 2 for S 2 / S total The weight w corresponding to client 3 3 for S 3 / S total The weight w corresponding to client 44 For S 4 / S total , the weight w 5 For S 5 / S total .

[0086] The first model parameter of the local model includes a plurality of parameters, and the parameters are respectively parameter 1, parameter 2, and parameter 3. For example, the parameter 1 of the local model corresponding to the client 1 is denoted as x11, the parameter 1 of the local model corresponding to the client 2 is denoted as x12, the parameter 1 of the local model corresponding to the client 3 is denoted as x13, the parameter 1 of the local model corresponding to the client 4 is denoted as x14, and the parameter 1 of the local model corresponding to the client 5 is denoted as x15. According to the weight corresponding to each client, the parameter 1 of the local model corresponding to each client is weighted and summed to obtain the aggregation result X1 of the parameter 1, that is, w 1 x11+ w 2 x12+ w 3 x13+ w 4 x14+ w 5 x15; similarly, the aggregation result X2 of the parameter 2 and the aggregation result X3 of the parameter 3 are calculated respectively. The second model parameter includes the aggregation result X1 of the parameter 1, the aggregation result X2 of the parameter 2, and the aggregation result X3 of the parameter 3. Then, the first aggregation model is generated according to the second model parameter.

[0087] In another optional embodiment of the present application, for any client in the first group of clients, the target client in the first group of clients determines the weight corresponding to the client according to the proportion of the local data amount corresponding to the client in the total data amount corresponding to the first group of clients; the target client in the first group of clients identifies the abnormal parameters in the first model parameter of the local model corresponding to each client in the first group of clients, and eliminates the abnormal parameters; the target client in the first group of clients weights and sums the first model parameter after eliminating the abnormal parameters according to the weight corresponding to each client in the first group of clients to obtain the second model parameter. The target client in the first group of clients generates the first aggregation model according to the second model parameter.

[0088] Taking the previous five clients as an example, for example, the parameter 1 of the local model corresponding to the client 2~client 3 is an abnormal parameter, and the parameters 2 and 3 of the local model corresponding to the five clients are all normal, that is, x12 and x13 are abnormal parameters, x12 is first removed, and then the parameter 1 of the local model corresponding to the client 1, the client 3~the client 5 is weighted and summed to obtain the aggregation result X1 of the parameter 1 after removing the abnormal parameter , that is, w 1 x11+ w 4 x14+ w 5 x15;the aggregation result X2 of the parameter 2 and the aggregation result X3 of the parameter 3 follow the previous example, and the second model parameter includes the aggregation result X1 of the parameter 1 after removing the abnormal parameter , the aggregation result X2 of the parameter 2 and the aggregation result X3 of the parameter 3. Then, the first aggregation model is generated according to the second model parameter.

[0089] In step 207, the target client in the first group of clients sends the first aggregation model to the server.

[0090] The first aggregation model sent by the target client of the first group of clients is used to aggregate the first aggregation models corresponding to the other groups of clients in the N groups of clients except the first group of clients to obtain the second global model.

[0091] In step 208, each target client of the other groups of clients in the N groups of clients except the first group of clients sends the first aggregation model corresponding to the other groups of clients to the server.

[0092] For each group of clients in the N groups of clients, the steps performed after receiving the first variation model and the first indication information sent by the server can refer to steps 204~207 performed by the target client in the first group of clients, which will not be described here. It should be understood that the model parameters in the first variation model received by the target client in different groups of clients are different, and the first aggregation models sent by different groups of clients to the server are also different.

[0093] Through the above steps 207~208, the server can receive the first aggregation models corresponding to the N groups of clients.

[0094] In step 209, the server aggregates the first aggregation models corresponding to the N groups of clients to obtain the second global model.

[0095] In one manner in which step 209 can be implemented, for any one of the N groups of clients, taking the first group of clients as an example, a weight value corresponding to the first group of clients is determined according to a proportion of a total data amount corresponding to the first group of clients in total data amounts corresponding to the N groups of clients, and a model accuracy corresponding to a first aggregation model corresponding to the first group of clients. After obtaining the weights corresponding to the N groups of clients respectively, the first aggregation models corresponding to the N groups of clients respectively are aggregated according to the weights corresponding to the N groups of clients respectively, to obtain a second global model.

[0096] Taking the first group of clients as an example, the proportion of the total data amount corresponding to the first group of clients in the total data amounts corresponding to the N groups of clients is denoted as N cluster N total The proportion of the total data amount corresponding to the first group of clients in the total data amounts corresponding to the N groups of clients is denoted as N cluster / N total The weight corresponding to the first group of clients is denoted as w c1 The model accuracy corresponding to the first aggregation model corresponding to the first group of clients is denoted as Acc cluster The weight corresponding to the first aggregation model corresponding to the first group of clients is denoted as w c2 The weight value corresponding to the first group of clients is w cluster The weight value corresponding to the first group of clients can be calculated by the following formula:

[0097] w cluster = w c1 × N cluster / N total + w c2 × Acc cluster

[0098] wherein, the values of w c1 and w c2 may be set according to actual needs, for example, w c1 is set to 0.6, and w c2 is set to 0.4.

[0099] In the embodiments of the present application, the weight corresponding to each group of clients is calculated by setting the weight of the proportion of the data amount in the cluster and the model accuracy respectively. w cluster This double-weight distribution aggregation weight manner can avoid the deviation caused by the “data amount dominance”.

[0100] ​Based on the above, the manner in which the step 209 can be implemented, after obtaining the weights corresponding to the N groups of clients respectively, the first aggregation model corresponding to the N groups of clients respectively is aggregated according to the weights corresponding to the N groups of clients respectively to obtain the second global model, which can be implemented in the following manner: the same model parameter in the first aggregation model corresponding to the N groups of clients respectively is weighted and summed according to the weights corresponding to the N groups of clients respectively, and then the second global model is obtained. In other embodiments, if the loss decrease amplitude of the second global model obtained by the t-th round of optimization process with respect to the second global model obtained by the t-1-th round of optimization process is less than the second threshold value, the weights corresponding to the N groups of clients respectively are adjusted; the first aggregation model corresponding to the N groups of clients respectively is aggregated according to the adjusted weights corresponding to the N groups of clients respectively to obtain the second global model.

[0101] The present application does not limit the value of the second threshold value, and the second threshold value can be set according to actual needs, for example, the second threshold value is set to 0.5%.

[0102] In some embodiments, after the above step 206 and before the above step 207, the target client in the first group of clients can also identify whether there is dirty data in each client in the group, if there is dirty data in the first group of clients, the target client in the first group of clients takes the result of re-aggregating the local model of the client with dirty data after re-training and the local model of the client without dirty data as the first aggregation model; and then sends the first aggregation model to the server.

[0103] Taking the first group of clients including 5 clients, client 1, client 2, client 3, client 4 and client 5, and the target client being client 1 as an example, client 1 trains a local model 1 based on its own local data, client 2 trains a local model 2 based on its own local data, client 3 trains a local model 3 based on its own local data, client 4 trains a local model 4 based on its own local data, and client 5 trains a local model 5 based on its own local data. Client 1 aggregates the local model 1, the local model 2, the local model 3, the local model 4 and the local model 5 to obtain an aggregation model 1. Then client 1 identifies whether there is dirty data in each client in the group; if the identification result is that client 2 has dirty data and other clients do not have dirty data, client 1 instructs client 2 to re-train the local model, and client 2 re-trains a local model after re-training based on the data other than the dirty data in its own local data . Client 1, client 3, client 4 and client 5 do not need to re-train the local model. Client 1 aggregates the local model 1 and the local model after re-training sent by client 2 to obtain a local model 6 , and the local model 3 corresponding to the client 3, the local model 4 corresponding to the client 4, and the local model 4 corresponding to the client 5 are re-aggregated to obtain an aggregated model ; then, the aggregated model is uploaded to the server. In this way, only the client with dirty data needs to retrain the local model, and the clients without dirty data in the group do not need to retrain the local model, and then the local models of the clients are re-aggregated. Compared with the prior art in which it is found that a certain client has dirty data, the server issues a retraining instruction to instruct all clients to retrain the local model, the computing overhead can be greatly reduced, and the optimization process time of a single round is greatly reduced.

[0104] In some embodiments, after the above step 206 and before the above step 207, the target client in the first group of clients can also identify whether there is an abnormal client in the group. The application does not limit the specific identification method. The abnormal client is, for example, a certain client in the group is in an offline state, or a certain client has dirty data, such as a client being attacked maliciously to generate dirty data. If there is an abnormal client in the first group of clients, the target client aggregates the local models corresponding to the other clients in the first group of clients except the abnormal client to obtain a first aggregated model. In this way, the abnormal client is removed from the first group of clients, and the local models of the clients in the group do not need to be retrained, and only the previously trained local models need to be re-aggregated.

[0105] Taking the first group of clients including five clients, i.e., the client 1, the client 2, the client 3, the client 4, and the client 5, and the target client being the client 1 as an example, the client 1 trains the local model 1 based on the local data of the client 1, the client 2 trains the local model 2 based on the local data of the client 2, the client 3 trains the local model 3 based on the local data of the client 3, the client 4 trains the local model 4 based on the local data of the client 4, and the client 5 trains the local model 5 based on the local data of the client 5. The client 1 aggregates the local model 1, the local model 2, the local model 3, the local model 4, and the local model 5 to obtain an aggregated model 2. Then, if it is identified that the client 4 is an abnormal client and the other clients are normal clients, the client 1 re-aggregates the local model 1, the local model 2, the local model 3, and the local model 5 to obtain an aggregated model ; then, the aggregated model is uploaded to the server.

[0106] In one way of identifying abnormal clients, if the gradient variance threshold corresponding to the local model is greater than or equal to the third threshold corresponding to the first group of clients, and the model accuracy corresponding to the local model is less than or equal to the fourth threshold, then the client corresponding to the local model is an abnormal client. For example, the third threshold is set to 3σ of the group mean, and the fourth threshold is set to 10% of the group mean.

[0107] In an optional implementation, if the target client in the first group of clients identifies the existence of dirty data in the group after step 207, the target client in the first group of clients re-aggregates the local models of the clients with dirty data after retraining and the local models of the clients without dirty data to obtain a third aggregated model, and then sends the third aggregated model to the server. If at least one group of clients in the N groups of clients has dirty data, the server receives the third aggregated models sent by the at least one group of clients respectively. Alternatively, if the target client in the first group of clients identifies the existence of abnormal clients in the group after step 207, the target client in the first group of clients re-aggregates the local models corresponding to the other group clients in the group except the abnormal clients to obtain a third aggregated model, and then sends the third aggregated model to the server. If at least one group of clients in the N groups of clients has abnormal clients, the server receives the third aggregated models sent by the at least one group of clients respectively.

[0108] In an optional implementation, before aggregating the first aggregated models uploaded by each group of clients, the server receives the third aggregated models sent by the at least one group of clients (i.e., each group of clients with abnormal clients, which will not be described below) respectively, so that step 209 can be replaced by: aggregating the third aggregated models corresponding to the at least one group of clients respectively and the first aggregated models corresponding to the other group clients in the N groups of clients except the at least one group of clients to obtain a second global model. The third aggregated model corresponding to any group of clients is obtained by re-aggregating the local models of the clients with dirty data after retraining and the local models of the clients without dirty data in the group, or the third aggregated model is obtained by re-aggregating the local models corresponding to the normal clients in the group when there is an abnormal client in the group.

[0109] In another optional implementation, after step 209, that is, after the server aggregates the first aggregation models corresponding to the N groups of clients respectively to obtain the second global model, if the server receives a third aggregation model respectively sent by at least one group of clients (that is, each group of clients in which there is an abnormal client, which will not be described below), the server re-aggregates the third aggregation model corresponding to the at least one group of clients and the first aggregation model corresponding to the other groups of clients in the N groups of clients except the at least one group of clients to obtain a fourth aggregation model; and then the fourth aggregation model is taken as the second global model. The third aggregation model corresponding to any group of clients is obtained by re-aggregating the local model retrained by the client with dirty data and the local model of the client without dirty data in the group, or the third aggregation model is obtained by re-aggregating the local model corresponding to the normal client in the group when the abnormal client in the group triggers re-aggregation.

[0110] Based on the second global model obtained in the optimization process of the tthround according to any of the above implementations, it is determined whether the second global model satisfies a first preset condition. If the second global model obtained in the optimization process of the tthround satisfies the first preset condition, the second global model in the optimization process of the tthround is the final global model, and optimization is not continued. Or, if the second global model does not satisfy the first preset condition, step 210 is performed.

[0111] In step 210, if the second global model obtained in the optimization process of the tthround does not satisfy the first preset condition, the server takes the second global model obtained in the optimization process of the tthround as a first global model to be optimized, and performs an optimization process of a (t+1) thround until a second global model obtained in the optimization process satisfies the first preset condition.

[0112] The first preset condition can be that the number of times of performing the first optimization operation reaches a preset number, or the loss reduction amplitude of the second global model obtained by the first optimization operation for y consecutive times is less than a sixth threshold value, for example, 0.1%.

[0113] In the above embodiments, the server or the target client can include a processor, a communication interface, and a memory. The processor in the server is configured to perform steps 201-202 and steps 209-210, and perform steps 203 and 207 through the communication interface. The memory in the server is configured to store data (such as the first aggregation model, the first global model, and the second global model). The processor in the target client in any group of clients is configured to perform steps 204-206, and perform step 207 through the communication interface. The memory in the target client is configured to store data (such as the first indication information, the first variation model, and the local model of the other client in the group).

[0114] It should be noted that in any of the above embodiments, the data transmission between the server and any group of clients can be performed in an encrypted manner, for example, using homomorphic encryption or differential privacy. The corresponding decryption is also implemented using the same encryption technology, for example, the target client in each group of clients uploads encrypted parameters (such as an aggregated model or model adoption number in the group) using homomorphic encryption, and the server directly aggregates the encrypted parameters. In this way, it can adapt to multiple scene requirements and be compatible with existing secure aggregation mechanisms (such as homomorphic encryption and differential privacy), for example, it can be applied to financial risk control, medical data collaboration, intelligent terminal collaborative training, and other scenarios that require privacy protection and distributed modeling. The embodiments of the present application can be applied to the privacy protection system of financial institutions. The privacy data is always saved locally on the client side. For example, multiple financial institutions can perform joint modeling without exchanging user personal information, and then upload the iteratively optimized aggregated model or model parameters to the server to obtain a global model for financial risk assessment. The embodiments of the present application support dynamic clients, for example, when some clients are offline, the number of groups can be automatically adjusted. The embodiments of the present application can also adapt to unstable network environments of intelligent terminals (such as mobile phones and IoT devices).

[0115] The following describes the application of the model optimization method based on federated learning provided by the present application to the field of financial risk identification. Each client in the client resource pool is, for example, each financial institution, such as a bank. The local data of each financial institution is, for example, a plurality of image data, each of which includes a user's certificate image. The user's certificate image is an image of a certificate used to prove the user's identity, including but not limited to an ID card, a driver's license, etc. In each round of optimization process, the server selects a plurality of financial institutions from each financial institution and groups them into N groups. Each financial institution in each group uses a plurality of image data with labels stored locally as a training set to train a first variation model issued by the server to obtain a local model. Each image data in the training set includes a user's certificate image, and the label attached is a real label or a fake label. The real label is used to indicate that the certificate image in the image data is the user's real certificate image, and the fake label is used to indicate that the certificate image in the image data is a fake certificate image, such as a retouched, synthesized, or fake certificate image. Then the local models trained by each financial institution in the group are aggregated and uploaded to the server. The server aggregates the first aggregated models uploaded by each group of financial institutions to obtain a second global model. The final global model obtained after multiple rounds of optimization process is used to identify the authenticity of the certificate image in the to-be-detected image, for example, the to-be-detected image is input into the above final global model to obtain a detection result output by the model. The detection result includes the probability that the to-be-detected image is a real certificate image and the probability that the to-be-detected image is a fake certificate image, so as to determine whether the to-be-detected image has a risk of being synthesized or fake based on the identification result of the model.

[0116] In an embodiment of the present application, in the optimization process of the tth round, for the first global model to be optimized, the server selects multiple clients with a distribution similarity greater than or equal to a first threshold from the client resource pool to activate and group, so that the intra-group gradient of the local model of each client in each group can be reduced, and the aggregation efficiency can be improved. Then, a first variation model is generated by injecting random noise into the model parameters of the first global model with each group of clients as the granularity, and the first variation model and the first indication information are issued, which can effectively alleviate the problem of model generalization caused by data heterogeneity and improve the accuracy of the finally generated global model. Moreover, each client in each group of clients shares the same variation model, which can reduce variation redundancy. After each client in each group of clients trains a local model based on local data, a first aggregation model obtained by aggregating all local models in the group is uploaded by a target client in the group, that is, each group of clients uploads a first aggregation model. Compared with the way in which each client uploads a local model to the server, the communication overhead between the server and the multiple clients can be reduced.

[0117] The final global model generated by the federated learning-based model optimization method provided in the embodiments of the present application has a significantly improved accuracy in a non-independent and identically distributed scenario. For example, taking a ResNet18 model as an initial model, the final global model obtained by using the method provided in the present application has a test accuracy of 87.69% in an extreme heterogeneous scenario of a CIFAR-10 data set ( delta =0.1). Compared with the FedAvg with an accuracy of 24.00%, the accuracy is improved by 63.69%. Compared with the FedProx with an accuracy of 27.60%, the accuracy is improved by 60.09%. Compared with the FedMut with an accuracy of 83.23%, the accuracy is improved by 4.46%. For another example, taking a DNN model as an initial model, the final global model obtained by using the method provided in the present application has a test accuracy of 98.50% in a scenario of a MNIST ( delta =0.1) data set, which can meet the high-precision requirements of financial risk control and medical diagnosis.

[0118] Based on the same inventive concept, an embodiment of the present application provides a federated learning-based model optimization device. The federated learning-based model optimization device can be a hardware structure, a software module, or a hardware structure plus a software module. The federated learning-based model optimization device can be implemented by a chip system, which can be composed of a chip or can include a chip and other discrete devices.

[0119] When the model optimization apparatus based on federated learning performs the steps performed by the server in the foregoing method embodiments, please refer to Figure 3 , a structural schematic diagram of a model optimization apparatus based on federated learning provided by an embodiment of the present application is shown, as shown in Figure 3 , the model optimization apparatus based on federated learning 300 includes a grouping module 301, a model mutation module 302, a communication module 303, an aggregation module 304, and a control module 305. When the model optimization apparatus based on federated learning is a hardware structure, the functions of the grouping module 301, the model mutation module 302, the aggregation module 304, and the control module 305 can be performed by a processor in the model optimization apparatus based on federated learning, the function of the communication module 303 can be performed by a communication interface in the model optimization apparatus based on federated learning, and the data (such as the first indication information, the first mutated model) sent to the client side, the data (such as the first aggregated model sent by each client) received from the client side, the first global model, and the second global model, etc. can be stored in the memory in the model optimization apparatus based on federated learning. In the optimization process of the t th round, t is a positive integer, for the first global model to be optimized, wherein:

[0120] The grouping module 301 is configured to select a plurality of clients from a client resource pool for activation and divide them into N groups of clients, and the data distribution similarity corresponding to the local data of the plurality of clients is greater than or equal to a first threshold; the local data of each client in the client resource pool is in a non-independent and identically distributed manner;

[0121] The model mutation module 302 is configured to inject random noise into the model parameters of the first global model to generate a first mutated model for each group of clients in the N groups of clients; the communication module 303 is configured to send the first mutated model and first indication information to the group of clients, the first indication information being used to instruct each client in the group of clients to perform local training on the first mutated model based on the local data, and aggregate the local training results within the group; and receive the first aggregated model sent by a target client in the group of clients, the first aggregated model being obtained by the target client based on the local models corresponding to each client in the group, each client corresponding to a local model obtained by performing local training on the first mutated model based on the local data of the client;

[0122] The aggregation module 304 is configured to aggregate the first aggregated models corresponding to the N groups of clients to obtain a second global model;

[0123] The control module 305 is configured to, if the second global model obtained in the tth optimization process does not satisfy the first preset condition, continue to optimize the second global model obtained in the tth optimization process as the first global model in the (t+1)th optimization process until the second global model obtained satisfies the first preset condition.

[0124] In a possible implementation, the grouping module 301 is further configured to, when t satisfies the second preset condition, divide the clients in the client resource pool into M candidate groups based on the local data of the clients in the client resource pool by using a clustering algorithm, each candidate group including clients whose local data correspond to a data distribution similarity greater than or equal to a first threshold, and M being an integer greater than 1; and the grouping module 301 is specifically configured to select a target candidate group from the M candidate groups, and divide the clients in the target candidate group into N groups of clients.

[0125] In a possible implementation, the mutation strength of the random noise injected into the first global model in the tth optimization process is dynamically adjusted based on a gradient variance corresponding to the second global model obtained in the (t-1)th optimization process, where the gradient variance corresponding to the second global model obtained in the (t-1)th optimization process is calculated based on gradients between model parameters of the second global model obtained in the (t-1)th optimization process and model parameters of the second global model obtained in the (t-2)th optimization process.

[0126] In a possible implementation, the aggregation module 304 is specifically configured to, for any one of the N groups of clients, determine a weight corresponding to the group of clients according to a proportion of a total amount of data corresponding to the group of clients in total amounts of data corresponding to the N groups of clients, and a model accuracy corresponding to a first aggregation model corresponding to the group of clients; and aggregate the first aggregation models corresponding to the N groups of clients respectively according to the weights corresponding to the N groups of clients respectively to obtain the second global model.

[0127] In a possible implementation, the aggregation module 304 is specifically configured to, if a gradient loss decrease amplitude of the second global model obtained in the tth optimization process relative to the second global model obtained in the (t-1)th optimization process is less than a second threshold, issue a retraining instruction to the N groups of clients, the retraining instruction being used to instruct each group of clients in the N groups of clients to retrain a first mutated model received by the group of clients based on local data to obtain a new local model; receive second aggregation models respectively sent by the N groups of clients, the second aggregation model sent by each group of clients being an aggregation of new local models respectively obtained by target clients in the group of clients by retraining the first mutated model; and aggregate the second aggregation models corresponding to the N groups of clients respectively according to the weights corresponding to the N groups of clients respectively to obtain the second global model.

[0128] In a possible implementation, the aggregation module 304 is further configured to receive third aggregation models respectively sent by at least one group of clients, and aggregate the third aggregation models respectively corresponding to the at least one group of clients and the first aggregation models respectively corresponding to other groups of clients except the at least one group of clients in the N groups of clients to obtain a second global model. The third aggregation model corresponding to any group of clients is obtained by retraining a local model of a client with dirty data and re-aggregating local models of clients in the group without dirty data, or the third aggregation model is obtained by triggering re-aggregation of local models of normal clients in the group when there is an abnormal client in the group.

[0129] When the model optimization apparatus based on federated learning performs the steps performed by the target client in the foregoing method embodiments, refer to Figure 4 , which shows a structural schematic diagram of a model optimization apparatus based on federated learning provided by an embodiment of the present application. As shown in Figure 4 , the model optimization apparatus based on federated learning 400 includes a communication module 401, a training module 402, and an aggregation module 403. When the model optimization apparatus based on federated learning is a hardware structure, the functions of the training module 402 and the aggregation module 403 can be performed by a processor in the model optimization apparatus based on federated learning, and the function of the communication module 401 can be performed by a communication interface in the model optimization apparatus based on federated learning. The data received from the server (such as the first indication information or the first variant model), the data received from other clients (such as the local model), and the data sent to the server (such as the first aggregation model) can be stored in a memory in the model optimization apparatus based on federated learning. In the optimization process of the tthround, t is a positive integer, wherein:

[0130] The communication module 401 is configured to receive the first variant model and the first indication information sent by the server, and the first indication information is used to instruct each client in the first group of clients to perform local training on the first variant model based on local data and aggregate the local training results within the group. In response to the first indication information, the first variant model and the second indication information are respectively sent to other clients in the first group of clients except the target client, and the second indication information is used to instruct other clients in the first group of clients to perform local training on the first variant model based on local data. The first variant model is obtained by injecting random noise into the model parameters of the first global model.

[0131] The training module 402 is configured to perform local training on the first variant model based on the local data of the target client in response to the first indication information to obtain a local model corresponding to the target client, and perform local training on the first variant model based on the local data of the target client to obtain a local model corresponding to the target client.

[0132] The communication module 401 is further configured to receive local models obtained by performing local training on the first variant model by other clients in the first group of clients respectively in response to the second indication information;

[0133] The aggregation module 403 is configured to aggregate the local models respectively corresponding to the clients in the first group of clients to obtain a first aggregated model.

[0134] The communication module 401 is further configured to send the first aggregated model to the server, and the first aggregated model is used to aggregate first aggregated models corresponding to other groups of clients to obtain a second global model.

[0135] In a possible implementation, the aggregation module 403 is specifically configured to: for any client in the first group of clients, determine a weight corresponding to the client according to a proportion of a local data amount corresponding to the client in a total data amount corresponding to the first group of clients; perform weighted summation on first model parameters of the local models respectively corresponding to the clients in the first group of clients according to the weights respectively corresponding to the clients in the first group of clients to obtain second model parameters; and generate the first aggregated model according to the second model parameters.

[0136] In a possible implementation, the aggregation module 403 is specifically configured to: identify abnormal parameters in the first model parameters of the local models respectively corresponding to the clients in the first group of clients, and eliminate the abnormal parameters; and perform weighted summation on the first model parameters after eliminating the abnormal parameters according to the weights respectively corresponding to the clients in the first group of clients to obtain the second model parameters.

[0137] In a possible implementation, the aggregation module 403 is further configured to: if there is dirty data in the first group of clients, take, as the first aggregated model, a result of re-aggregating the local models of the clients with dirty data and the local models of the clients without dirty data by the target client after re-training the local models of the clients with dirty data; or if there is an abnormal client in the first group of clients, take, as the first aggregated model, a result of aggregating the local models respectively corresponding to the other clients in the first group of clients except the abnormal client.

[0138] The foregoing embodiments of the model optimization method based on federated learning involve all related contents of the steps, which can be referred to the function description of the function modules of the model optimization apparatus based on federated learning in the embodiments of the present application, and will not be repeated here.

[0139] The division of the modules in the embodiments of the present application is illustrative, and is merely a logical function division. Actual implementation can have another division manner. In addition, each function module in each embodiment of the present application can be integrated in one processor, or can be a separate physical existence, or two or more modules can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software function module.

[0140] Based on the same inventive concept, the embodiments of the present application also provide a computing device. As shown in the Figure 5 computing device in the embodiments of the present application includes at least one processor 501, and a memory 502 and a communication interface 503 connected with the at least one processor 501. The embodiments of the present application do not limit the specific connection medium between the processor 501 and the memory 502, Figure 5 for example, the connection between the processor 501 and the memory 502 through the bus 500. The bus 500 is represented by a thick line in Figure 5 the description, and the connection mode between other components is only schematically illustrated and is not limited. The bus 500 can be divided into an address bus, a data bus, a control bus, etc. For convenience of representation, Figure 5 only one thick line is used in the description, but it does not mean that there is only one bus or only one type of bus.

[0141] In the embodiments of the present application, the memory 502 stores instructions executable by the at least one processor 501. The at least one processor 501 can execute the steps performed by the server or any client in the foregoing model optimization method based on federated learning by executing the instructions stored in the memory 502.

[0142] The processor 501 is the control center of the computing device, can connect each part of the entire computing device through various interfaces and lines, and can monitor the entire computing device by running or executing the instructions stored in the memory 502 and calling the data stored in the memory 502. Various functions and processing data of the computing device, thereby overall monitoring the computing device. Optionally, the processor 501 can include one or more processing modules. The processor 501 can integrate an application processor and a modem processor. The processor 501 mainly processes the operating system, user interface and application programs, etc. The modem processor mainly processes wireless communication. It can be understood that the foregoing modem processor can also not be integrated into the processor 501. In some embodiments, the processor 501 and the memory 502 can be implemented on the same chip. In some embodiments, they can also be respectively implemented on independent chips.

[0143] The processor 501 can be a general processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic, a discrete hardware component, and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of the present application can be directly embodied as execution completed by a hardware processor, or executed by a combination of hardware and software modules in the processor.

[0144] The memory 502 is a non-volatile computer readable storage medium, and can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 502 can include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card type memory, random access memory (RAM), static random access memory (SRAM), programmable read only memory (PROM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. The memory 502 is any other medium capable of carrying or storing desired program code in the form of instructions or data structures and capable of being accessed by a computer, but is not limited thereto. The memory 502 in the embodiments of the present application can also be a circuit or any other device capable of realizing a storage function, used to store program instructions and / or data.

[0145] The communication interface 503 is a transmission interface capable of communication, and can receive or send data through the communication interface 503, for example, the computing device is a server, the communication interface 503 can receive data sent by any client, and for example, the computing device is any client, the communication interface 503 can receive data sent by a server or other clients.

[0146] According to various embodiments of the present application, the computing device package can also be connected to a remote computer on a network through a network such as the Internet. That is, the computing device can be connected to a network (not shown) through the communication interface 503 connected to the system bus 500.

[0147] Based on the same inventive concept, the embodiment of the present application also provides a computer readable storage medium storing computer instructions, when the computer instructions run on a computer, the computer instructions cause the computer to execute the steps in the model optimization method based on federated learning as described above.

[0148] In some possible implementation manners, various aspects of the model optimization method based on federated learning provided by the embodiment of the present application can also be implemented in the form of a program product, which includes program codes for causing a computer to execute the steps in the model optimization method based on federated learning according to various example embodiments of the present application as described above when the program product runs on the computer.

[0149] Those skilled in the art should understand that the embodiments of the present application can be provided in the form of a method, a system, or a computer program product. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage, etc.) containing computer-usable program codes.

[0150] The present application is described with reference to the flowcharts and / or block diagrams of the method, device (system), and computer program product according to the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing apparatus to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing apparatus produce a device implemented in accordance with the flowcharts and / or block diagrams. Figure 1 The function specified in one or more flows and / or blocks Figure 1 The function specified in one or more flows and / or blocks

[0151] These computer program instructions can also be stored in a computer readable storage medium capable of guiding the computer or other programmable data processing apparatus to work in a specific manner, so that the instructions stored in the computer readable storage medium produce a product including instruction apparatus, which implements the functions specified in one or more flows and / or blocks. Figure 1 The function specified in one or more flows and / or blocks Figure 1 The function specified in one or more flows and / or blocks

[0152] These computer program instructions can also be loaded into a computer or other programmable data processing devices, so that a series of operational steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide processes for implementing the functions specified in the flowchart Figure 1 flow or multiple flows and / or blocks Figure 1 flow or multiple flows and / or blocks

[0153] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.

Claims

1. A model optimization method based on federated learning, characterized in that, Applied to a server, the method includes: During the t-th round of optimization, for the first global model to be optimized, perform the following operations: Multiple clients are selected from the client resource pool for activation and divided into N groups of clients. The data distribution similarity of the local data of the multiple clients is greater than or equal to a first threshold. The local data of each client in the client resource pool is non-independent and identically distributed. For each of the N groups of clients, execute: Random noise is injected into the model parameters of the first global model to generate the first variant model; Send a first mutation model and a first instruction message to the group clients. The first instruction message is used to instruct each client in the group to train the first mutation model locally based on local data and aggregate the local training results within the group. The system receives a first aggregated model sent by a target client in the group of clients. The first aggregated model is obtained by the target client based on the local models corresponding to each client in the group. The local model corresponding to each client is obtained by training the first variant model locally based on the client's local data. The first aggregation model corresponding to the N groups of clients is aggregated to obtain the second global model; If the second global model obtained in the optimization process of the t-th round does not meet the first preset condition, then the second global model obtained in the optimization process of the t-th round is used as the first global model to be optimized in the optimization process of the (t+1)-th round until the obtained second global model meets the first preset condition, where t is a positive integer.

2. The method as described in claim 1, characterized in that, The method further includes: When t satisfies the second preset condition, based on the local data of each client in the client resource pool, the clients in the client resource pool are divided into M candidate groups by a clustering algorithm. The data distribution similarity of the local data of the clients included in each candidate group is greater than or equal to the first threshold, where M is an integer greater than 1. The step of selecting multiple clients from the client resource pool and grouping them into N groups of clients includes: Select a target candidate group from the M candidate groups, and divide the clients in the target candidate group into the N groups of clients.

3. The method as described in claim 1, characterized in that, The abrupt change intensity of random noise injected into the first global model during the t-th round of optimization is dynamically adjusted based on the gradient variance of the second global model obtained in the (t-1)-th round of optimization. The gradient variance of the second global model obtained in the (t-1)-th round of optimization is calculated as the gradient between the model parameters of the second global model obtained in the (t-1)-th round of optimization and the model parameters of the second global model obtained in the (t-2)-th round of optimization.

4. The method as described in claim 1, characterized in that, The step of aggregating the first aggregation models corresponding to the N groups of clients to obtain the second global model includes: For any one of the N groups of clients, the weight corresponding to the group of clients is determined based on the proportion of the total data volume corresponding to the group of clients in the total data volume corresponding to the N groups of clients, and the model accuracy corresponding to the first aggregation model corresponding to the group of clients. Based on the weights corresponding to the N groups of clients, the first aggregation model corresponding to the N groups of clients is aggregated to obtain the second global model.

5. The method as described in claim 4, characterized in that, The step of aggregating the first aggregation model corresponding to each of the N groups of clients according to their respective weights to obtain the second global model includes: If the gradient loss of the second global model obtained in the t-th round of optimization decreases less than the second global model obtained in the (t-1)-th round of optimization, a retraining instruction is sent to the N groups of clients. The retraining instruction is used to instruct each group of clients in the N groups of clients to retrain the first mutated model they received based on local data to obtain a new local model. The system receives the second aggregated model sent by the N groups of clients respectively. The second aggregated model sent by each group of clients is obtained by aggregating the new local models retrained by each client in the group based on the new local models obtained by the target client in the group. Based on the weights corresponding to the N groups of clients, the second aggregation models corresponding to the N groups of clients are aggregated to obtain the second global model.

6. The method according to any one of claims 1-5, characterized in that, Before aggregating the first aggregation models corresponding to the N groups of clients to obtain the second global model, the process further includes: Received at least one set of third aggregation models sent by clients respectively; The step of aggregating the first aggregation models corresponding to the N groups of clients to obtain the second global model includes: The third aggregation model corresponding to each of the at least one group of clients is aggregated with the first aggregation model corresponding to each of the other groups of clients in the N groups of clients, excluding the at least one group of clients, to obtain the second global model; wherein, the third aggregation model corresponding to any group of clients is obtained by re-aggregating the local model of the client with dirty data after retraining with the local model of the client in the group without dirty data, or the third aggregation model is obtained by re-aggregating the local model corresponding to the normal client in the group when there is an abnormal client in the group.

7. A model optimization method based on federated learning, characterized in that, Applied to a target client, the target client belonging to a first group of clients, wherein the data distribution similarity of the local data of each client in the first group of clients is greater than or equal to a first threshold; the method includes: During the t-th round of optimization, where t is a positive integer, perform the following operations: The system receives a first mutation model and a first instruction information sent by the server. The first instruction information is used to instruct each client in the first group of clients to train the first mutation model locally based on local data and to aggregate the local training results within the group. In response to the first indication information, the first mutation model and the second indication information are sent to other clients in the first group of clients, excluding the target client, respectively. The first mutation model is trained locally based on the local data of the target client to obtain the local model corresponding to the target client. The second indication information is used to instruct other clients in the first group of clients to train the first mutation model locally based on the local data. The local model is trained by receiving responses to the second instruction information from the other clients in the first group of clients, excluding the target client. The local models corresponding to each client in the first group of clients are aggregated to obtain the first aggregated model; The first aggregated model is sent to the server, and the first aggregated model is used to aggregate with the first aggregated models corresponding to other groups of clients to obtain a second global model.

8. The method as described in claim 7, characterized in that, The step of aggregating the local models corresponding to each client in the first group of clients to obtain the first aggregated model includes: For any client in the first group of clients, the weight of the client is determined based on the proportion of the local data volume of the client in the total data volume of the first group of clients. Based on the weights corresponding to each client in the first group of clients, the first model parameters of the local models corresponding to each client in the first group of clients are weighted and summed to obtain the second model parameters; The first aggregation model is generated based on the second model parameters.

9. The method as described in claim 8, characterized in that, The step of weighted summing of the first model parameters of the local model corresponding to each client in the first group of clients, based on the weights of each client in the first group of clients, to obtain the second model parameters includes: Identify and remove abnormal parameters from the first model parameters of the local model corresponding to each client in the first group of clients; Based on the weights corresponding to each client in the first group of clients, the first model parameters after removing abnormal parameters are weighted and summed to obtain the second model parameters.

10. The method according to any one of claims 7-9, characterized in that, Before sending the first aggregation model to the server, the method further includes: If dirty data exists in the first group of clients, the target client will use the result of re-aggregating the local models of the clients with dirty data and the local models of the clients without dirty data as the first aggregated model; or, if there are abnormal clients in the first group of clients, the target client will use the result of aggregating the local models of the other clients in the first group (excluding the abnormal clients) as the first aggregated model.

11. A computing device, characterized in that, The computing device includes: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the steps included in any of the methods described in claims 1-10 according to the obtained program instructions.

12. A storage medium, characterized in that, The storage medium stores computer-executable instructions for causing a computer to perform the steps included in any of the methods described in claims 1-10.

Citation Information

Patent Citations

  • Industry classification model training method and device, industry classification model classification method and device

    CN113918709A

  • Federal learning method for non-independent identically distributed heterogeneous data

    CN115879542A