Multi-task federal learning client contribution degree measurement method based on model layering
By using model hierarchical calculation of the contribution of each client in multitasking federated learning, the problem of inability to accurately quantify client contributions in traditional methods is solved, a faster and more efficient training process is achieved, and data privacy is maintained.
Patent Information
- Application Number
- CN202411100711.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-08-12
AI Technical Summary
Traditional federated learning methods cannot accurately quantify the contribution of each client in multi-task federated learning, resulting in impairment of model performance and affecting the model performance obtained by the task initiator client.
Using a multi-task federated learning client contribution metric method based on model hierarchy, the model hierarchical gradient and contribution vector of each client are calculated through the central server to achieve accurate contribution metrics, and filter clients according to the contribution degree to optimize the training process. .
It realizes more accurate model aggregation and faster multi-task federated learning process, optimizes training time and model accuracy, while maintaining data privacy protection effect.
Smart Images

Figure CN119129704A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of federated learning and machine learning model stratification, and in particular to a multi-task federated learning client contribution measurement method based on model stratification. Background Art
[0002] With the continuous development of the Internet and the rapid improvement of hardware and storage capabilities, artificial intelligence and machine learning are based on massive multi-source data, and their applications and research are becoming more and more extensive. As data producers continue to improve their awareness of the protection of private information and private data security, and relevant government departments and legislative bodies gradually pay attention to data security and user privacy protection, data security has become a global concern. Traditional centralized machine learning methods require centralized collection and processing of data, and then train a global model based on this data, but this approach has a great risk of privacy leakage.
[0003] Federated learning, as a distributed computing framework to solve data silos, allows multiple clients to collaborate on training shared models without centralizing data, protecting privacy while utilizing decentralized data resources. It can capture common knowledge from multiple clients to generate a better performing global model. Taking deep learning classification algorithms as an example, federated learning can use a small amount of data on each client without leaking data to train a classification model with better generalization and accuracy, alleviating the problem of insufficient client data.
[0004] Multi-task federated learning requires the cooperation of all clients when jointly training models. In traditional federated learning, the contribution of each client is considered equal, and the model parameters of each local client are evenly aggregated. However, the data distribution on the client that initiates the task and other clients may be different. This difference will cause the performance of the model to be impaired when the contribution is the same, thereby affecting the performance of the model obtained by the client that initiates the task. Therefore, how to provide an effective method to measure the contribution of clients is an important difficulty in solving the application of multi-task federated learning. Summary of the invention
[0005] The purpose of the present invention is to provide a method for measuring client contribution in multi-task federated learning based on model stratification, which solves the problem of quantifying client contribution in multi-task federated learning in the prior art.
[0006] To solve the above problems, the present invention adopts the following technical problems:
[0007] A multi-task federated learning client contribution measurement method based on model stratification is applied to a distributed architecture including a central server and multiple client nodes, including the following steps:
[0008] S1. Configure the federated learning environment and prepare data, including:
[0009] The configuration of the federated learning environment includes configuring a central server and connecting N clients participating in the training to a private network;
[0010] Data preparation includes data sample acquisition and data preprocessing; specifically, each participant obtains their own sample data With data labels in represents the image sample data of the i-th participant, represents the data label of the i-th participant;
[0011] The central server establishes a connection with each federated client participating in the training. The client sends a task request to the central server, and the server generates a task queue Q. The client sends the data volume of the local sample to the server. in Represents the amount of data on client i; after the server obtains the data of all clients, it calculates the total amount of data
[0012] S2. The central server measures the contribution of each client under the existing federated tasks:
[0013] S2.1. Client x initiates a federated task. The central server selects K clients from N clients to participate in the training. The K clients participating in the training always include client x. Secondly, the collection round R, the local training round T on the local client, the training batch size B, and the client's local loss function f(·) are updated to initialize the model training.
[0014] S2.2, the central server initializes the model and distributes it to the participating K clients;
[0015] S2.3, the K clients participating in the training use batch B locally in their private local data Last training round T;
[0016] S2.4, based on the distributed gradient descent method, each edge node prepares to calculate the gradient value of the current round through its local data and the received model parameters;
[0017] S2.5. Based on the received loss function and model parameters, each client participating in the training randomly selects a certain amount of local data, and uses the back propagation algorithm to calculate the latest gradient value of the model parameters received in the current round using the selected local data. Where i represents the number of the edge node, θ i Indicates the model parameter value received in the current round, f irepresents the received model loss function, Represents the back-propagation algorithm, which computes the model x based on its local data i And the loss function f i The current round gradient value of the training client sends the locally trained parameters θ to the central server i ;
[0018] S3, the contribution measurement process includes the following steps:
[0019] S3.1, after receiving the parameters, the central server divides the model into layers and calculates the gradients of each layer of the model;
[0020] S3.2. For the clients participating in this round of training, the server calculates the model hierarchical similarity relative to client x, and after normalization, obtains the contribution vector α of the K participating training clients relative to client x x ;
[0021] S4, the central server sends the new model to the target task client;
[0022] S4.1. Calculate the new model parameters of the target task client based on the contribution vector and the amount of data on the client participating in the training as a joint vector
[0023] S4.2, the server according to the joint contribution vector Select K clients to participate in the next round of target task training;
[0024] S4.3, repeat steps S2 and S4 until the target task reaches the predetermined training round or the preset accuracy;
[0025] S5, update the task queue;
[0026] S5.1. Delete the task that has completed training from the current task queue Q, and select the next task to continue training;
[0027] S5.2, move the queue head pointer back to the next task. If the pointer points to null, all training tasks are completed;
[0028] S5.3. If a new task is added during the training process, the position to insert it into the queue is selected based on whether the task is a real-time task.
[0029] Furthermore, the specific operation method for calculating the gradient of each layer of the model is:
[0030] S3.1.1. The central server receives the latest gradient values uploaded by each client after training. After that, through the latest gradient value Update the model parameters of each client on the server, as shown below:
[0031]
[0032] Among them, η represents the learning rate;
[0033] S3.1.2. After the update, the server divides each client model into layers according to the structure of each layer of the model and calculates the gradient of each layer to the task initiator x. The gradient of the kth layer The calculation formula is:
[0034]
[0035] in, represents the model parameters of the k-th layer of client i, Represents the k-th layer parameters of the model parameters initialized in the first round;
[0036] Furthermore, the contribution vector α x The specific calculation method is as follows:
[0037] S3.2.1. Calculate the cosine similarity of client i relative to the model of each layer of client x. The calculation formula is as follows:
[0038]
[0039] in, It represents the cosine similarity of each layer model of client i relative to client x. and denote the gradients of the kth layer of client x and client i respectively;
[0040] S3.2.2. The calculated cosine similarity Added to the contribution vector of the specified layer, the final contribution matrix relative to client x is obtained, which is expressed as follows:
[0041]
[0042] in, represents the aggregate weight vector of the mth layer in client x, represents the aggregate weight vector of client i relative to client K at the mth layer; It is obtained by calculating the cosine similarity of the client x gradient relative to other client gradients and then performing weighted normalization;
[0043] Specifically, each row vector of the contribution matrix is multiplied by the corresponding client data volume Relative to the total amount of data The weighted contribution vector is obtained by calculating the ratio of . Each row of the weighted contribution vector is normalized using softmax so that the sum of the contribution of each layer is 1.
[0044] Furthermore, the new model parameters of the target task client The calculation process is as follows:
[0045] S4.1.1. Aggregate the same layer model parameters of the clients participating in the training into a K-dimensional vector represents the model parameters of the mth layer of client i;
[0046] S4.1.2. For L layers, aggregate them into The model hierarchy matrix of
[0047] S4.1.3. Calculate the aggregation model of client x. The aggregation calculation process is: After aggregation, the server will Sent to the task client.
[0048] Furthermore, step S4.2 is specifically as follows:
[0049] S4.2.1. Select the contribution vector of the top model in the contribution matrix, select k models with low contribution and discard them, and randomly select k clients from the remaining models as new clients.
[0050] S4.2.2. The newly joined client establishes a connection with the central server;
[0051] S4.2.3. The central server sends the newly constructed client group Start the next round of training.
[0052] Furthermore, the specific operation method of step S5.3 is as follows:
[0053] S5.3.1. If the newly added task is not a real-time task, the newly added task is added to the end of the task queue, and the tail pointer moves one position backward;
[0054] S5.3.2. If the newly added task is a real-time high-priority task, after the current round of client learning is completed, the central server saves the connection status information, the target task client saves the aggregated model, and the next round of training for the new task starts directly.
[0055] After adopting the above technical solution, the present invention has the following beneficial effects:
[0056] (1) During the training process, the present invention can accurately identify the contribution of each client of federated learning, and realize model aggregation under more accurate hierarchical contribution measurement through model stratification. At the same time, the privacy protection effect is the same as that of general federated learning, and can be naturally combined with other protection schemes.
[0057] (2) The solution of the present invention achieves a faster multi-task federated learning process by screening out the measured low contributors in each round, thereby achieving the purpose of optimizing the federated learning time and model accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 The figure is a flow chart of the overall training process of the present invention.
[0059] Figure 2 It is a schematic diagram of the measurement vector in the process of the present invention.
[0060] Figure 3 This is a schematic diagram of client selection in the process of the present invention. DETAILED DESCRIPTION
[0061] The purpose of the present invention is to provide a method for measuring client contribution in multi-task federated learning based on model stratification, which solves the problem of quantifying client contribution in multi-task federated learning in the prior art.
[0062] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below in conjunction with the implementation modes and the accompanying drawings.
[0063] See also Figure 1 For a given image recognition neural network model to be trained, the following steps are used to optimize the model parameters while compressing the communication volume: In order to make the purpose, technical solution and advantages of the present invention clearer, the present invention is further described in detail below in combination with the implementation methods and drawings.
[0064] S1. Configure the federated learning environment and prepare data, including:
[0065] The configuration of the federated learning environment includes configuring a central server and connecting N clients participating in the training to a private network;
[0066] Data preparation includes data sample acquisition and data preprocessing. The data sample acquisition and data preprocessing process are as follows:
[0067] Each participant obtains their own sample data With data labels in represents the image sample data of the i-th participant, Represents the data label of the i-th participant, sample data Contains sample images and sample categories. This embodiment obtains sample data by collecting user-generated local images and the categories of acquired images. With data labels
[0068] The central server establishes a connection with each federated client participating in the training. The client sends a task request to the central server, and the server generates a task queue Q. The amount of data that the client sends to the server for local samples in Represents the amount of data on client i. After the server obtains the data of all clients, it calculates the total amount of data
[0069] S2. The central server measures the contribution of each client under the existing federated tasks:
[0070] S2.1. Client x initiates a federated task, and the central server selects K clients from N clients to participate in the training, and the K participating clients always include client x. Secondly, update the collection round R, the local training round T on the local client, the training batch size B, and the client's local loss function f(·) to initialize the model training;
[0071] S2.2, the central server initializes the model and distributes it to the participating K clients;
[0072] S2.3, the K clients participating in the training use batch B as their local private data Last training round T.
[0073] S2.4, based on the distributed gradient descent algorithm, each edge node prepares to calculate the gradient value of the current round through its local data and the received model parameters;
[0074] S2.5. Based on the received loss function and model parameters, each client participating in the training randomly selects a certain amount of local data, and uses the back propagation algorithm to calculate the latest gradient value of the model parameters received in the current round using the selected local data. Where i represents the number of the edge node, θ i Indicates the model parameter value received in the current round, f i represents the received model loss function, Represents the back-propagation algorithm, which computes the model x based on its local data i And the loss function f i The current round gradient value of the training client sends the locally trained parameters θ to the central server i ;
[0075] S3. The measurement process includes the following steps:
[0076] S3.1. After receiving the parameters, the central server divides the model into layers and calculates the gradients of each layer of the model. The specific operation method is as follows:
[0077] S3.1.1. The central server receives the latest gradient values uploaded by each client after training. After that, through the latest gradient value Update the client models on the server. The specific formula can be expressed by formula (1);
[0078] η is the learning rate (1);
[0079] S3.1.2. After the update, the server divides each client model into layers according to the structure of each layer of the model and calculates the gradient of each layer to the task initiator x. The layered diagram is as follows Figure 2 As shown, the k-th layer gradient The calculation formula is represents the model parameters of the k-th layer of client i, Represents the k-th layer parameters of the model parameters initialized in the first round;
[0080] S3.2. For the clients participating in this round of training, the server calculates the model hierarchical similarity relative to client x, and after normalization, obtains the contribution vector α of the K participating training clients relative to client x x , the specific method is as follows:
[0081] S3.2.1. Calculate the cosine similarity of each layer model of client i relative to client x. The calculation formula is as follows: It represents the cosine similarity of each layer model of client i relative to client x. and denote the gradients of the kth layer of client x and client i respectively;
[0082]
[0083] S3.2.2. The calculated cosine similarity Added to the contribution vector of the specified layer, the contribution matrix relative to client x is finally obtained, which is expressed as formula (3);
[0084]
[0085] In S3.2.3 and S3.2.2, represents the aggregate weight vector of the mth layer in client x, and It represents the aggregate weight vector of client i relative to client K at the mth layer. It is obtained by calculating the cosine similarity of the client x gradient relative to other client gradients through formula (2), and then performing weighted normalization. For a deep neural network divided into m layers, formula (4) holds true.
[0086]
[0087] Specifically, each row vector of the contribution matrix is multiplied by the corresponding client data volume Relative to the total amount of data The weighted contribution vector is obtained by using the ratio of . Each row of the weighted contribution vector is normalized using softmax so that the sum of the contribution of each layer (i.e., the aggregate weight vector) is 1. The softmax normalization is expressed as formula (5).
[0088]
[0089] Furthermore, the temperature parameter temp in formula (5) controls the output of the softmax function. By scaling the softmax function input, the normalization degree can be controlled to be smooth or sharp. The larger the temp value, the smoother the output, and the smaller the normalized vector variance will be until it becomes uniformly distributed. The smaller the temp value, the sharper the output, and the larger the normalized vector variance will be until it becomes uniformly distributed. The value is 1.
[0090] S4, the central server sends the new model to the target task client;
[0091] S4.1. Calculate the new model parameters of the target task client based on the contribution vector and the amount of data on the client participating in the training as a joint vector The specific operation method is:
[0092] S4.1.1. Aggregate the same layer models of the clients participating in the training into a K-dimensional vector represents the model parameters of the mth layer of client i;
[0093] S4.1.2. For L layers, aggregate them into The model hierarchy matrix of
[0094] S4.1.3. Calculate the aggregation model of client x. The aggregation calculation process is: After aggregation, the server will Sent to the task client.
[0095] S4.2, the server according to the joint contribution vector Select K clients to participate in the next round of target task training; the specific operation method is:
[0096] S4.2.1. Select the contribution vector of the top model in formula (3), select k models with low contribution and discard them, and randomly select k clients from the remaining Nk models as new clients. The selection process is as follows: Figure 3 As shown;
[0097] S4.2.2. The newly joined client establishes a connection with the central server;
[0098] S4.2.3. The central server sends the newly constructed client group Start the next round of training.
[0099] S4.3. Repeat steps S2 and S4 until the predetermined training rounds or preset accuracy of the target task is reached.
[0100] S5. Update task queue
[0101] S5.1. Delete the task that has completed training from the current task queue Q, and select the next task to continue training;
[0102] S5.2, move the queue head pointer back to the next task. If the pointer points to null, all training tasks are completed;
[0103] S5.3. If a new task is added during the training process, select the position to insert it into the queue based on whether the task is a real-time task; the specific operation method is as follows:
[0104] S5.3.1. If the newly added task is not a real-time task, the newly added task is added to the end of the task queue, and the tail pointer moves one position backward;
[0105] S5.3.2. If the newly added task is a real-time high-priority task, after the current round of client learning is completed, the central server saves the connection status information, the target task client saves the aggregated model, and the next round of training for the new task starts directly.
[0106] In summary, the multi-task federated learning client contribution measurement method based on model stratification provided in this embodiment solves the problem that the prior art cannot accurately quantify the contribution of each client under multi-task learning. It also introduces the steps of screening low contributors and preemptive priority scheduling, and its training process takes less time than the traditional federated learning algorithm while ensuring the same security.
[0107] It is to be understood that the present invention is described by some embodiments, and it is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited by the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the scope of protection of the present invention.
Claims
1. A client contribution measurement method for multi-task federated learning based on model stratification, applied to a distributed architecture including a central server and multiple client nodes, It is characterized in that The method specifically comprises the following steps: S1. Configure the federated learning environment and prepare data, including: The configuration of the federated learning environment includes configuring a central server and connecting N clients participating in the training to a private network; Data preparation includes data sample acquisition and data preprocessing; specifically, each participant obtains their own sample data With data labels in represents the sample data of the i-th participant, represents the data label of the i-th participant; The central server establishes a connection with each federated client participating in the training. The client sends a task request to the central server, and the server generates a task queue Q. The client sends the data volume of the local sample to the server. in Represents the amount of data on client i; after the server obtains the data of all clients, it calculates the total amount of data S2. The central server measures the contribution of each client under the existing federated tasks: S2.
1. Client x initiates a federated task. The central server selects K clients from N clients to participate in the training. The K clients participating in the training always include client x. Secondly, the collection round R, the local training round T on the local client, the training batch size B, and the client's local loss function f(·) are updated to initialize the model training. S2.2, the central server initializes the model and distributes it to the participating K clients; S2.3, the K clients participating in the training use batch B locally in their private local data Last training round T; S2.4, based on the distributed gradient descent method, each edge node prepares to calculate the gradient value of the current round through its local data and the received model parameters; S2.
5. Based on the received loss function and model parameters, each client participating in the training randomly selects a certain amount of local data, and uses the back propagation algorithm to calculate the latest gradient value of the model parameters received in the current round using the selected local data. Where i represents the number of the edge node, θ i Indicates the model parameter value received in the current round, f i represents the received model loss function, Represents the back-propagation algorithm, which computes the model x based on its local data i And the loss function f i The current round gradient value of the training client sends the locally trained parameters θ to the central server i ; S3, the contribution measurement process includes the following steps: S3.1, after receiving the parameters, the central server divides the model into layers and calculates the gradients of each layer of the model; S3.
2. For the clients participating in the training in this round, the central server calculates the model hierarchical similarity relative to client x, and after normalization, obtains the contribution vector α of the K participating training clients relative to client x x ; S4, the central server sends the new model to the target task client; S4.
1. According to the contribution vector α x The data volume on the client participating in the training is used as a joint vector to calculate the new model parameters of the target task client S4.2, the server according to the joint contribution vector Select K clients to participate in the next round of target task training; S4.3, repeat steps S2 and S4 until the target task reaches the predetermined training round or the preset accuracy; S5, update the task queue; S5.
1. Delete the task that has completed training from the current task queue Q, and select the next task to continue training; S5.2, move the queue head pointer back to the next task. If the pointer points to null, all training tasks are completed; S5.
3. If a new task is added during the training process, the position to insert it into the queue is selected based on whether the task is a real-time task.
2. According to the method for measuring client contribution of multi-task federated learning based on model stratification in claim 1, It is characterized in that The specific operation method of the gradient of each layer of the calculation model is: S3.1.
1. The central server receives the latest gradient values uploaded by each client after training. After that, through the latest gradient value Update the model parameters of each client on the server, as shown below: Among them, η represents the learning rate; S3.1.
2. After the update, the server divides each client model into layers according to the structure of each layer of the model and calculates the gradient of each layer to the task initiator x. The gradient of the kth layer The calculation formula is: in, represents the model parameters of the k-th layer of client i, Represents the k-th layer parameters of the model parameters initialized in the first round.
3. According to the method for measuring client contribution of multi-task federated learning based on model stratification in claim 1, It is characterized in that The contribution vector α x The specific calculation method is as follows: S3.2.
1. Calculate the cosine similarity of client i relative to the model of each layer of client x. The calculation formula is as follows: in, It represents the cosine similarity of each layer model of client i relative to client x. and denote the gradients of the kth layer of client x and client i respectively; S3.2.
2. The calculated cosine similarity Added to the contribution vector of the specified layer, the final contribution matrix relative to client x is obtained, which is expressed as follows: in, represents the aggregate weight vector of the mth layer in client x, represents the aggregate weight vector of client i relative to client K at the mth level; It is obtained by calculating the cosine similarity of the client x gradient relative to the gradients of other clients, and then performing weighted normalization; Specifically, each row vector of the contribution matrix is multiplied by the corresponding client data volume Relative to the total amount of data The weighted contribution vector is obtained by calculating the ratio of . Each row of the weighted contribution vector is normalized using softmax so that the sum of the contribution of each layer is 1.
4. According to the method for measuring client contribution of multi-task federated learning based on model stratification in claim 1, It is characterized in that The target task client new model parameters The calculation process is as follows: S4.1.
1. Aggregate the same layer model parameters of the clients participating in the training into a K-dimensional vector represents the model parameters of the mth layer of client i; S4.1.
2. For L layers, aggregate them into The model hierarchy matrix of S4.1.
3. Calculate the aggregation model of client x. The aggregation calculation process is: After aggregation, the server will Sent to the task client.
5. According to the method for measuring client contribution of multi-task federated learning based on model stratification in claim 4, It is characterized in that The step S4.2 is specifically as follows: S4.2.
1. Select the contribution vector of the top model in the contribution matrix, select k models with low contribution and discard them, and randomly select k clients from the remaining models as new clients. S4.2.
2. The newly joined client establishes a connection with the central server; S4.2.
3. The central server sends the newly constructed client group Start the next round of training.
6. According to the method for measuring client contribution of multi-task federated learning based on model stratification in claim 5, It is characterized in that The specific operation method of step S5.3 is as follows: S5.3.
1. If the newly added task is not a real-time task, the newly added task is added to the end of the task queue, and the tail pointer moves one position backward; S5.3.
2. If the newly added task is a real-time high-priority task, after the current round of client learning is completed, the central server saves the connection status information, the target task client saves the aggregated model, and the next round of training for the new task starts directly.
Citation Information
Patent Citations
Fair privacy calculation method based on federated node contribution
CN116306910A
Fair federal learning method based on node contribution clustering
CN117196058A
Methods and systems for quantifying client contribution in federated learning
WO2023036184A1
Cited By
Longitudinal federal learning method and device combined with early leaving mechanism, and storage medium
CN120725100A
Federal learning contribution evaluation method and device
CN121303267A
Hierarchical federated learning-oriented privacy protection collaborative optimization method and related equipment
CN122508609A
