Federal learning client selection method based on client tuple
By dividing federated learning clients into tuples and combining and selecting them according to accuracy, the problem of difficult to balance client selection efficiency and accuracy in the existing technology is solved, and flexible client selection and accuracy optimization are achieved, reducing the model Training rounds.
Patent Information
- Application Number
- CN202411175562.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-24
AI Technical Summary
The existing federated learning client selection method is difficult to balance between improving sampling accuracy and reducing time overhead, and there is a ‘barrel effect’ when randomly selecting clients, affecting efficiency.
Divide the client into tuples, sort and combine according to the accuracy of each tuple, select the tuple combination with the smallest average accuracy as the target combination, and adjust the number of clients to optimize model training.
It realizes effective reduction of model training rounds under considerable time consumption, improves the flexibility and accuracy of client selection, and avoids the uncertainty of random selection.
Smart Images

Figure CN119180350A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of federated learning, and in particular to a method for selecting a federated learning client based on a client tuple. Background Art
[0002] With the development of technologies such as artificial intelligence and big data, the decentralization of computing power has led to a distributed trend in machine learning. Federated learning, which does not directly transmit client data, has become a focus of research in recent years due to its security advantages as a type of privacy-preserving computing. In federated learning, due to the consideration of communication volume, only a part of the clients will be selected to participate in each round of training. In real scenarios, different clients are often in very different scenarios, with different objective conditions such as data volume, computing resources, and communication capabilities. Client selection has become a crucial factor affecting the convergence efficiency and model accuracy of federated learning.
[0003] Existing client selection schemes have different focuses, and the methods proposed so far can be mainly divided into three directions.
[0004] The first direction focuses on methods that form fixed groups of clients. This type of method stratifies clients based on client time or resources, selects a tier for each training, and extracts clients from it for training. A typical example is TiFL (TiFL: A Tier-based Federated Learning System). This method of using fixed tiers ignores a large number of clients with similar resources in adjacent tiers, and has poor sampling accuracy.
[0005] The second direction focuses on clustering clients into different clusters based on different criteria. Each training has different clustering results, and clients are proportionally extracted from different clusters. A typical representative of this method is CFL (Clustered Federated Learning: Model-Agnostic Distributed Multitask Optimization), which makes up for the shortcomings of the first direction in sampling accuracy, but it still does not focus on reducing the time cost during training.
[0006] The third direction focuses on the number of clients participating in each round of training. The number of clients is continuously adjusted during the training process, so that the number of clients is increased only in a small number of rounds, and the number of clients is reduced in most other rounds to reduce communication overhead. The representative of this direction is CriticalFL (CriticalFL: ACritical Learning Periods Augmented Client Selection Framework for Efficient Federated Learning, a client selection framework based on key learning cycle enhancement for efficient federated learning). This method still randomly extracts clients, and the "barrel effect" still has a great impact on it. Summary of the invention
[0007] In order to solve the above problems existing in the prior art, the present invention provides a method for selecting a federated learning client based on client tuples.
[0008] According to a first aspect of an embodiment of the present invention, a method for selecting a federated learning client based on a client tuple is provided, the method comprising:
[0009] S1, screening the clients to obtain N screened clients;
[0010] S2, sorting the N screened clients according to processing time and dividing them into M tuples;
[0011] S3, determine the number of tuples m required for the current training round;
[0012] S4, calculate the average accuracy of each tuple combination according to the accuracy of each of the M tuples, and select the tuple combination with the smallest average accuracy as the target tuple combination; wherein the accuracy of each tuple is obtained according to the previous round of training; the tuple combination includes m consecutive tuples, m <M;
[0013] S5, after selecting n clients from the target tuple combination for local training, perform model aggregation to obtain aggregation results, and calculate the accuracy of the current training round;
[0014] S6, determining whether the cumulative number of training rounds reaches a preset number of training rounds;
[0015] If not, return to S3; if so, execute S7 to obtain the target model according to the aggregation result.
[0016] Optionally, S1 includes:
[0017] Randomly generate an initial global model and send it to N' clients;
[0018] Pre-train the received initial global model, and exclude clients that do not meet the preset conditions to obtain the N screened clients; wherein the preset conditions include that the initial global model of the client times out without response and the training time is greater than the pre-processing time threshold δ pre .
[0019] Optionally, pre-training the received initial global model and excluding clients that do not meet preset conditions to obtain the N screened clients includes:
[0020] Through the local data sets D of the N' clients i Training the initial global model;
[0021] After each training, a training completion signal is sent to the server to indicate that the current round of model training is complete;
[0022] After a set round of training, the training time of each of the N' clients is counted according to the training completion signal;
[0023] N screened clients are obtained according to the training time consumptions of the N' clients and the preset conditions.
[0024] Optionally, the M tuples are represented by reference as follows:
[0025] Tuple 1 ,Tuple 2 ,…,Tuple M-1 ,Tuple M ;
[0026] Among them, Tuple represents a tuple, Indicates rounding down, the jth tuple Tuple j The number of clients is N%M means N modulo M.
[0027] Optionally, the relationship between n clients selected from the target tuple combination and the number of tuples m required for the current training round is as follows:
[0028]
[0029] Among them, l is the subscript of the first tuple in the target tuple combination of the current training round.
[0030] Optionally, the average accuracy rate refers to the following formula:
[0031]
[0032] Among them, Ac krepresents the average accuracy of the k-th tuple combination, 1≤k≤M-m+1, E j is the client index set of the jth tuple, A j is the accuracy of the jth tuple, D i is the local dataset of the i-th client, a i represents the accuracy of the global model of the current training round of the i-th client, E j Represents the client index set of the j-th tuple.
[0033] Optionally, S5 includes:
[0034] Obtaining n target clients with the largest L2 norm of the gradient in the target tuple combination during the previous training round, and performing local training on the n target clients;
[0035] Send the model parameters, accuracy, and gradient of the global model of the current training round obtained after local training to the server;
[0036] Model aggregation is performed according to the model parameters of the global model of the current training round to obtain an aggregation result.
[0037] Optionally, the aggregation result is as follows:
[0038]
[0039] Where θ represents the aggregation result, C represents the set of the n target client subscripts, i is the client serial number, and D i is the local dataset of the i-th client, θ i is the model parameter of the i-th client.
[0040] Optionally, the accuracy of the current training round is as follows:
[0041]
[0042] Among them, Acc r It represents the accuracy rate when the training round is r.
[0043] The technical solution provided by the present invention may include the following beneficial effects:
[0044] The present invention proposes for the first time to divide federated learning clients into tuples, and then extract clients from the tuple combination, cleverly limiting the client selection to a flexible range of adjustable size and position, turning the originally random and chaotic client selection into a time-guaranteed selection. In addition, the present invention makes full use of the accuracy of model training, using the accuracy as a criterion for selecting groups and adjusting the number of clients, which can effectively reduce the number of model training rounds while consuming considerable time.
[0045] Other features and advantages of the present invention will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present invention but do not constitute a limitation of the present invention. In the accompanying drawings:
[0047] Figure 1 The present invention is a flowchart of a method for selecting a client for federated learning based on a client tuple according to an exemplary embodiment.
[0048] Figure 2 The figure is a flowchart showing a client sorting method according to an exemplary embodiment.
[0049] Figure 3 It is a schematic diagram showing a client extraction process according to an exemplary embodiment. DETAILED DESCRIPTION
[0050] In order to facilitate the understanding of the scheme of the present invention, the relevant state of the prior art and the inventive concept of the present invention are first briefly described.
[0051] The first direction focuses on methods that form fixed groups of clients. This type of method stratifies clients based on client time or resources, selects a layer for each training, and extracts clients from it for training. A typical example is TiFL (ATier-based Federated Learning System). This method of using fixed layers ignores a large number of clients with similar resources in adjacent layers, and has poor sampling accuracy.
[0052] The second direction focuses on clustering clients into different clusters based on different criteria. Each training has different clustering results, and clients are proportionally extracted from different clusters. A typical representative of this method is CFL (Clustered Federated Learning: Model-Agnostic Distributed Multitask Optimization), which makes up for the shortcomings of the first direction in sampling accuracy, but it still does not focus on reducing the time cost during training.
[0053] The third direction focuses on the number of clients participating in each round of training. The number of clients is continuously adjusted during the training process, so that the number of clients is increased only in a small number of rounds and reduced in most other rounds to reduce communication overhead. The representative of this direction is CriticalFL (A Critical Learning Periods Augmented Client Selection Framework for Efficient Federated Learning). This method still randomly extracts clients, and the "barrel effect" still has a great impact on it.
[0054] Therefore, the present invention proposes a client selection method for federated learning based on client tuples to solve the above technical problems.
[0055] Figure 1 is a flowchart of a method for selecting a client for federated learning based on a client tuple according to an exemplary embodiment. Figure 1 As shown, the method includes the following steps.
[0056] S1, screening the clients to obtain N screened clients.
[0057] Optionally, S1 includes:
[0058] Randomly generate an initial global model and send it to N' clients;
[0059] Pre-train the received initial global model, and exclude clients that do not meet the preset conditions to obtain the N screened clients; wherein the preset conditions include that the initial global model of the client times out without response and the training time is greater than the pre-processing time threshold δ pre .
[0060] Pre-training the received initial global model and excluding clients that do not meet preset conditions to obtain the N screened clients, including:
[0061] Through the local data sets D of the N' clients i Training the initial global model;
[0062] After each training, a training completion signal is sent to the server to indicate that the current round of model training is complete;
[0063] After a set round of training, the training time of each of the N' clients is counted according to the training completion signal;
[0064] N screened clients are obtained according to the training time consumptions of the N' clients and the preset conditions.
[0065] It is understandable that first the server will coordinate all clients to participate in pre-training, which is used for client sorting and determines some initial model parameters for subsequent training.
[0066] Specifically, Figure 2 is a flowchart showing a client sorting method according to an exemplary embodiment. Figure 2 As shown, the Server randomly generates initial model parameters to obtain the initial global model Model, and sends the Model to each client. i , which first converts the local model Model i Modify to Model and use each client Client i The local dataset D i Train the model for R′ rounds (set number of rounds), then send a signal to the Server indicating that the current round of training is complete. After training R′ rounds, the Server counts the number of clients. i The total time taken is T i After each round of training, the server will exclude the cases where the model training time is greater than the preprocessing time threshold δ. pre Finally, the remaining clients are sorted from small to large according to the consumption time to form a new client sequence:
[0067] Client 1 ,Client 2 ,…,Client N-1 ,Client N ;
[0068] Each client i satisfy:
[0069] T 1 ≤T 2 ≤,…,≤T N-1 ≤T N .
[0070] S2, sorting the N screened clients according to processing time and dividing them into M tuples.
[0071] Optionally, the M tuples divided are represented as follows:
[0072] Tuple 1 ,Tuple 2 ,…,Tuple M-1 ,TupleM ;
[0073] Among them, Tuple represents a tuple, Indicates rounding down, the jth tuple Tuple j The number of clients is N%M means N modulo M. If the result of N modulo M is ≥ j, the value in the brackets is 1. If the result of N modulo M is < j, the value in the brackets is 0. The client subscript set of the jth tuple is:
[0074] E j ={n 1 +n 2 +…+n j-1 +1,n 1 +n 2 +…+n j-1 +2,…,n 1 +n 2 +…+
[0075] n j-1 +n j};
[0076] It is understandable that there are j-1 tuples before the j-th tuple, that is, there are n tuples before the j-th tuple. 1 +n 2 +n 3 +…+n j-1 clients, so the client index of the jth tuple starts from n 1 +n 2 +n 3 +…+n j-1 +1 starts, total n j That is, from n 1 +n 2 +n 3 +…+n j-1 +1 to n 1 +n 2 +n 3 +…+n j-1 +n j .
[0077] It is worth mentioning that assigning M to The reason for not directly refining it to a tuple with each client is that the number of clients actually used in each round of federated learning is of a certain order of magnitude. Too demanding pursuit of the accuracy of the tuple to each client will have little significance for model training and will inevitably lead to a waste of time.
[0078] S3, determine the number m of tuples required for the current training round.
[0079] The server starts the global R rounds of training and maintains the training information for each round. At the beginning of each round of training, the number of tuples extracted in each round needs to be calculated in order to select the tuples from which to extract the client.
[0080] To prevent the model training from falling into a vicious cycle during federated learning, which leads to a continuous decrease in the accuracy of model testing, the relationship between the number of tuples m required for the current training round and the number of clients n selected from the target tuple combination is as follows:
[0081]
[0082] Among them, l is the index of the first tuple in the target tuple combination of the current training round, n j Tuple is the jth tuple j The number of clients in the system.
[0083] In order to reduce the time consumption as much as possible while maintaining the accuracy of the model, the present invention defines the change of m as follows:
[0084] (1). Exponential increase: If Acc r-4 -Acc r-3 >δ dec &&Acc r-3 -Acc r-2 >δ dec &&Acc r-2 -Acc r-1 >δ dec (&& means "and", the following operation will be performed only when the three inequalities are established at the same time), the lowering threshold δ dec If it drops to 50% of the original value every 5 rounds, then the number of clients n extracted in the current round should be increased quickly to increase the cardinality to prevent further decrease in accuracy. This can be achieved by increasing the number of tuples m extracted in this round to 150% of the previous round.
[0085] (2) Exponential reduction: If Acc r-3 -Acc r-4 >δ inc &&Acc r-2 -Acc r-3 >δ inc &&Acc r-1 -Acc r-2 >δ inc , where the rising threshold δ inc It drops to 50% of the original value every 5 rounds, indicating that the accuracy of the current model training is increasing rapidly. The number of clients n can be appropriately reduced to reduce communication consumption. This can be achieved by reducing the number of tuples m extracted in this round to 70% of the previous round.
[0086] (3) Linear maintenance: If it does not fall into the above two extreme cases, then the current training accuracy is in a stable period, and the number of clients can be slowly reduced to reduce the communication overhead. This can be achieved by reducing the number of tuples m extracted in this round by 2% of the total number of tuples.
[0087] S4, calculate the average accuracy of each tuple combination according to the accuracy of each of the M tuples, and select the tuple combination with the smallest average accuracy as the target tuple combination; wherein the accuracy of each tuple is obtained according to the previous round of training; the tuple combination includes m consecutive tuples, m <M。
[0088] Optionally, an ordered sequence of tuples Tuple 1 ,Tuple 2 ,…,Tuple M-1 ,Tuple M And the number of tuples required for the current round is m. Each m consecutive tuples is regarded as a combination and an average accuracy is calculated. The average accuracy of the kth tuple combination is referred to the following formula:
[0089]
[0090] Among them, Ac k represents the average accuracy of the k-th tuple combination, 1≤k≤M-m+1, E j is the client index set of the jth tuple, A j is the accuracy of the jth tuple, D i is the local dataset of the i-th client, a i The accuracy of the global model of the current training round for the i-th client.
[0091] Figure 3 is a schematic diagram showing a client extraction process according to an exemplary embodiment. Figure 3 As shown, in each round of training, the M-m+1 tuple combinations are sorted from small to large according to the average accuracy, and the tuple combination with the smallest average accuracy is selected as the range of clients to be extracted in this round of training.
[0092] S5, after selecting n clients from the target tuple combination for local training, perform model aggregation, obtain the aggregation result, and calculate the accuracy of the current training round.
[0093] Optionally, S5 includes:
[0094] Obtaining n target clients with the largest L2 norm of the gradient in the target tuple combination during the previous training round, and performing local training on the n target clients;
[0095] Send the model parameters, accuracy, and gradient of the global model of the current training round obtained after local training to the server;
[0096] Model aggregation is performed according to the model parameters of the global model of the current training round to obtain an aggregation result.
[0097] Optionally, the server receives each client i The returned parameter θ i Afterwards, the global model is aggregated by weighted averaging based on the size of the client dataset, and the aggregated results are as follows:
[0098]
[0099] Among them, θ represents the aggregation result, C represents the set of n target client subscripts, i is the client serial number, D i is the local dataset of the i-th client, θ i is the model parameter of the i-th client.
[0100] Optionally, the server receives each client i The accuracy of the returned i After that, you need to calculate the accuracy of the current training round. The accuracy of the current training round is as follows:
[0101]
[0102] Among them, Acc r It represents the accuracy rate when the training round is r.
[0103] Afterwards, the accuracy of each tuple can be updated: for each i∈C, assuming i∈E j ,So
[0104] Among them, Δa i is the change in accuracy of the i-th client compared to its last training.
[0105] S6, determining whether the cumulative number of training rounds reaches a preset number of training rounds.
[0106] If not, return to S3; if so, execute S7 to obtain the target model according to the aggregation result.
[0107] Through the above scheme, the initial global model is randomly generated and sent to a total of N' clients. The client uses the local data set to train the local training for R' rounds. In each round of local training, the client returns a signal to the server that the training is completed. The server eliminates some unresponsive and timed-out clients through the client's signal. After the global training is set, the server sorts the N clients selected from small to large according to the time consumed, and divides them into M tuples as evenly as possible. The server determines the number of tuples m required for this round of training based on the test accuracy of the previous round of training. Each continuous m tuples is regarded as a tuple combination, and the average accuracy of the tuple combination is calculated. The tuple combination with the smallest average accuracy is selected as the range of client selection in this round, thus completing the transformation of the client selection range from all N clients to m tuples. Select the n clients with the largest L2 norm of the gradient in the last training in the tuple combination, send the global model, and the client updates the global model locally. The server aggregates the model parameters from different clients through weighted average to obtain a new global model, and updates the accuracy to facilitate the next round of training. After R rounds of training, the target model is obtained.
[0108] The present invention proposes for the first time to divide federated learning clients into tuples, and then extract clients from the tuple combination, cleverly limiting the client selection to a flexible range of adjustable size and position, turning the originally random and chaotic client selection into a time-guaranteed selection. In addition, the present invention makes full use of the accuracy of model training, using the accuracy as a criterion for selecting groups and adjusting the number of clients, which can effectively reduce the number of model training rounds while consuming considerable time.
[0109] The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, a variety of simple modifications can be made to the technical solution of the present invention, and these simple modifications all belong to the protection scope of the present invention.
[0110] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present invention will not further describe various possible combinations.
[0111] In addition, various embodiments of the present invention may be arbitrarily combined, and as long as they do not violate the concept of the present invention, they should also be regarded as the contents disclosed by the present invention.
Claims
1. A method for selecting a client for federated learning based on client tuples, characterized in that: The method comprises: S1, screening the clients to obtain N screened clients; S2, sorting the N screened clients according to processing time and dividing them into M tuples; S3, determine the number of tuples m required for the current training round; S4, calculate the average accuracy of each tuple combination according to the accuracy of each of the M tuples, and select the tuple combination with the smallest average accuracy as the target tuple combination; wherein the accuracy of each tuple is obtained according to the previous round of training; the tuple combination includes m consecutive tuples, m <M; S5, after selecting n clients from the target tuple combination for local training, perform model aggregation to obtain aggregation results, and calculate the accuracy of the current training round; S6, determining whether the cumulative number of training rounds reaches a preset number of training rounds; If not, return to S3; if so, execute S7 to obtain the target model according to the aggregation result.
2. The method for selecting a client for federated learning based on client tuples according to claim 1, characterized in that: S1 includes: Randomly generate an initial global model and send it to N' clients; Pre-train the received initial global model, and exclude clients that do not meet the preset conditions to obtain the N screened clients; wherein the preset conditions include that the initial global model of the client times out without response and the training time is greater than the pre-processing time threshold δ pre .
3. The method for selecting a client for federated learning based on client tuples according to claim 2, characterized in that: The pre-training of the received initial global model and excluding clients that do not meet preset conditions to obtain the N screened clients includes: Through the local data sets D of the N' clients i Training the initial global model; After each training, a training completion signal is sent to the server to indicate that the current round of model training is complete; After a set round of training, the training time of each of the N' clients is counted according to the training completion signal; N screened clients are obtained according to the training time consumptions of the N' clients and the preset conditions.
4. The method for selecting a client for federated learning based on client tuples according to claim 1, characterized in that: The M tuples are represented as follows: Tuple1,Tuple2,...,Tuple M -1,Tuple M ; Among them, Tuple represents a tuple, Indicates rounding down, the jth tuple Tuple j The number of clients is N%M means N modulo M.
5. The method for selecting a client for federated learning based on client tuples according to claim 4, characterized in that: The relationship between selecting n clients from the target tuple combination and the number of tuples m required for the current training round is as follows: Among them, l is the subscript of the first tuple in the target tuple combination of the current training round.
6. The method for selecting a client for federated learning based on client tuples according to claim 4, characterized in that: The average accuracy rate refers to the following formula: Among them, Ac k represents the average accuracy of the k-th tuple combination, 1≤k≤M-m+1, E j is the client index set of the jth tuple, A j is the accuracy of the jth tuple, D i is the local dataset of the i-th client, a i represents the accuracy of the global model of the current training round of the i-th client, E j Represents the client index set of the j-th tuple.
7. The method for selecting a client for federated learning based on client tuples according to claim 1, characterized in that: S5, including: Obtaining n target clients with the largest L2 norm of the gradient in the target tuple combination during the previous training round, and performing local training on the n target clients; Send the model parameters, accuracy, and gradient of the global model of the current training round obtained after local training to the server; Model aggregation is performed according to the model parameters of the global model of the current training round to obtain an aggregation result.
8. The method for selecting a client for federated learning based on client tuples according to claim 7, characterized in that: The aggregation results are as follows: Where θ represents the aggregation result, C represents the set of the n target client subscripts, i is the client serial number, and D i is the local dataset of the i-th client, θ i is the model parameter of the i-th client.
9. The method for selecting a client for federated learning based on client tuples according to claim 8, characterized in that: The accuracy of the current training round is as follows: Among them, Acc r It represents the accuracy rate when the training round is r.
