A blockchain federated learning secure aggregation framework based on hierarchical index screening
By implementing hierarchical index screening, client trust scoring, and weight allocation within the blockchain federated learning framework, the problems of Byzantine attacks and slow aggregation speed are solved, resulting in more efficient model aggregation and higher accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-06
- Publication Date
- 2026-03-27
AI Technical Summary
The federated learning and blockchain joint framework lacks defenses against Byzantine attacks, has a slow aggregation speed, and requires many convergence rounds.
A secure aggregation framework for blockchain federated learning based on hierarchical index screening is adopted, which includes a pre-training phase, a formal training phase, and an aggregation phase. By performing trust scoring and weight allocation on client models, malicious clients are excluded, and future loss values are predicted to accelerate the aggregation speed.
It effectively counters Byzantine attacks, improves the accuracy of the global model, reduces the number of convergence rounds, and accelerates the aggregation speed.
Smart Images

Figure CN116432774B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of federated learning, and particularly relates to a blockchain federated learning security aggregation framework based on hierarchical index screening. BACKGROUND
[0002] The federated learning (FL) system is an important machine learning system in the field of computer science. Compared with the traditional distributed learning system, the federated learning system has the characteristics of high security and high privacy, and can maximize the guarantee of information privacy and security while ensuring the accuracy of the machine learning model. The traditional federated learning system cooperatively trains on multiple devices, which can efficiently utilize the data resources of each client. With the in-depth research on data privacy and security, in order to break the limitation of the central server on federated learning, federated learning is gradually combined with blockchain to create a decentralized federated learning system. The function of the central server is replaced by the blockchain, and the BlockFL architecture is proposed. And in the subsequent research, the FLChain framework structure is constantly improved, the incentive mechanism is increased and improved, and the security and practicability of the FLChain framework are strengthened from all aspects.
[0003] The blockchain and federated learning framework break the limitation of the central server and have high security in preventing the model from being stolen and tampered by external attackers. However, the blockchain and federated learning combined framework still has obvious shortcomings in dealing with malicious clients, and the robustness against Byzantine attacks is weak. There are a large number of excellent Byzantine attack robust algorithms in the field of federated learning, most of which rely on the central server to specially process the uploaded local model parameters in the aggregation process. However, under the framework of combining blockchain and federated learning, since there is no central server, FLChain cannot simply use special algorithms in the aggregation process to improve the robustness against malicious client attacks. This leads to the fact that many excellent algorithms have robustness against Byzantine attacks and cannot be simply used in the FLChain framework.
[0004] On the other hand, efficiency is still an important problem that limits the application of federated learning. Since the clients participating in learning need to exchange a large amount of data with the server in the learning process, the communication cost is very large in the traditional federated learning framework. The FLTrust algorithm not only guarantees the security of the federated learning algorithm, but also to a certain extent reduces the aggregation efficiency of the algorithm in aggregating the global model.
[0005] Therefore, the skilled in the art is committed to developing a blockchain federated learning security aggregation framework based on hierarchical index screening. SUMMARY
[0006] In view of the above defects of the prior art, the technical problems to be solved by the present application are that the federated learning and blockchain joint framework lack defense means against possible Byzantine attacks, the aggregation speed is slow, and a large number of convergence rounds are required.
[0007] To achieve the above-mentioned purpose, the present application provides a blockchain federated learning security aggregation framework based on hierarchical index screening, characterized in that the framework comprises a pre-training phase, an official training phase and an aggregation phase, wherein:
[0008] The pre-training phase: the training client participates in pre-training and uploads the calculated loss value to the blockchain;
[0009] The official training phase: the trusted client trains the model and provides the scoring standard, the training client trains and uploads the local model parameter to the blockchain, the trusted client scores the local model and calculates the weight of the local model, and the trusted client uploads the model trust score and the weight;
[0010] The aggregation phase: model aggregation is performed according to the model trust score and the weight, the global model of this round is obtained, the global model is uploaded to the blockchain, and the next round of training is started.
[0011] Further, the pre-training phase comprises the following steps:
[0012] S101: all the training clients participate in pre-training, and the pre-training is performed for a predetermined number of rounds;
[0013] S103: the training client calculates the loss value in the pre-training of each round;
[0014] S105: the training client uploads the loss value to the blockchain.
[0015] Further, in the pre-training phase, the trend of loss reduction degree is fitted by statistically analyzing the historical loss reduction value of the training client, and the future loss reduction value trend of the training client is predicted.
[0016] Further, the official training phase comprises the following steps:
[0017] S201: the trusted client obtains the trusted model parameter by training, calculates the update distance between the trusted model parameter and the global model parameter, takes the update distance as the scoring standard, and uploads the scoring standard to the blockchain;
[0018] S203: All the training clients download the global model on the blockchain, train with local data sets, and upload local model update parameters obtained by training to the model pool in the blockchain;
[0019] S205: The trusted client downloads all the local model update parameters in the model pool, scores the local models according to the scoring standard and calculates the pruning value, and uploads the trust score and the pruning value to the blockchain;
[0020] S207: According to the loss value obtained by the training of the training client, the weight of the local model of the training client is calculated.
[0021] Further, in the step S203, after receiving the global model, the training client performs local training, calculates the loss reduction value of this round, uploads the local model obtained by training and the loss reduction value to the blockchain, and the loss reduction value will be added to the historical loss reduction value list of each training client.
[0022] Further, the local model update parameter is the model update parameter between the local model parameter and the global model, the local model parameter is the model parameter obtained by local training of the training client, and the model update parameter is calculated by the following formula:
[0023]
[0024] Wherein, is the model update parameter of the i-th training client in the t-th round, is the local model parameter obtained by local training of the i-th training client in the t-th round, gω t-1 is the current global model.
[0025] Further, in the step S205, the trusted client scores the local model according to the cosine similarity and calculates the pruning value, the trusted client normalizes the amplitude difference between the update parameters of the training clients, and the trust score and the pruning value are calculated by the following formula respectively:
[0026]
[0027]
[0028] Wherein, is the pruning value of the i-th training client in the t-th round, is the update parameter between the i-th training client in the t-th round and the global model, is the model update parameter between the trusted client and the global model in the tth round, is the trust score of the i th training client in the tth round.
[0029] Further, in the step S207, the future loss value is predicted according to the loss value trained by the training client, and the weight of the local model of the training client is calculated through the future loss value, specifically:
[0030]
[0031] wherein, is the weight of the i th local model of the training client in the tth round, is the average value of the multiple predicted future loss values of the i th training client in the tth round, and K is the number of clients participating in training.
[0032] Further, the aggregation stage comprises the following steps:
[0033] S301: all the training clients download the local model parameters, the trust score and the weight from the model pool;
[0034] S303: the training client aggregates parameters according to the trust score and the weight, and aggregates a brand new global model;
[0035] S305: the training client uploads the aggregated brand new global model to the blockchain.
[0036] Further, in the step S303, the parameter aggregation adopts the following algorithm:
[0037]
[0038] wherein, g t is the brand new global model aggregated in the tth round, is the trust score of the i th training client in the tth round, is the model update parameter of the i th training client in the tth round, is the weight of the i th local model of the training client in the tth round, and K is the number of clients participating in training.
[0039] In the preferred embodiment of the present application, compared with the prior art, the present application has the following beneficial effects:
[0040] 1. The FLTrust algorithm is implemented in the framework of federated learning and blockchain in the present application, the local models uploaded by each client are aggregated for trust scoring, malicious clients are excluded, Byzantine attacks are dealt with to a certain extent, and the accuracy of the finally obtained global model is ensured;
[0041] 2. This invention accelerates aggregation speed and reduces convergence rounds by using loss prediction and aggregation weight allocation. By pre-training and recording the loss, the future loss of the client is predicted, and the aggregation weights are adjusted based on the prediction results, accelerating the client's aggregation speed and achieving better global model results with fewer convergence rounds.
[0042] The following will further explain the concept, specific structure, and technical effects of the present invention in conjunction with the accompanying drawings, so as to fully understand the purpose, features, and effects of the present invention. Attached Figure Description
[0043] Figure 1 This is a main flowchart of the aggregation framework of a preferred embodiment of the present invention;
[0044] Figure 2 This is a flowchart of the loss prediction process for an aggregation framework according to a preferred embodiment of the present invention;
[0045] Figure 3 This is a schematic diagram of the FLTrust aggregation principle of a preferred embodiment of the aggregation framework of the present invention. Detailed Implementation
[0046] The following description, with reference to the accompanying drawings, illustrates several preferred embodiments of the present invention to make its technical content clearer and easier to understand. The present invention can be embodied in many different forms, and the scope of protection of the present invention is not limited to the embodiments mentioned herein.
[0047] In the accompanying drawings, components with the same structure are indicated by the same numerical designation, and components with similar structures or functions are indicated by similar numerical designations. The dimensions and thicknesses of each component shown in the drawings are arbitrary, and the present invention does not limit the dimensions and thicknesses of each component. To make the illustrations clearer, the thickness of some components has been appropriately exaggerated in the drawings.
[0048] like Figure 1 As shown in the figure, the blockchain federated learning security aggregation framework based on hierarchical index screening provided by this embodiment of the invention includes a pre-training stage, a formal training stage, and an aggregation stage, wherein:
[0049] Pre-training phase: All training clients involved in the training participate in pre-training and upload the calculated loss value to the blockchain.
[0050] The pre-training phase includes the following steps:
[0051] S101: All training clients participate in pre-training, which goes through a predetermined number of rounds;
[0052] S103: The training client calculates the loss value in each pre-training round.
[0053] S105: The training client uploads the loss value to the blockchain for storage.
[0054] In the pre-training phase, the trend of loss reduction is fitted by counting the historical loss reduction value of the training client, and the future loss reduction value trend of the training client is predicted.
[0055] In the preferred embodiment of the present application, all training clients participating in training are pre-trained for six rounds in pre-training, and the loss values in the above six rounds of training are calculated and counted.
[0056] The formal training phase: the trusted client trains the model and provides the scoring standard, the training client trains and uploads the local model parameters to the blockchain, the trusted client scores the uploaded local model and calculates the weight of the local model, and the trusted client uploads the model trust score and weight.
[0057] The formal training phase specifically includes the following steps:
[0058] S201: The trusted client obtains the trusted model parameters by training, calculates the update distance between the trusted model parameters and the global model parameters, takes the update distance as the scoring standard, and uploads the scoring standard to the blockchain;
[0059] S203: All training clients download the global model on the blockchain, train using the local data set, and upload the local model update parameters obtained by training to the model pool in the blockchain.
[0060] After receiving the global model, the training client performs local training, calculates the loss reduction value of the current round, uploads the local model obtained by training and the loss reduction value to the blockchain, and the loss reduction value will be added to the historical loss reduction value list of each training client. The local model update parameter is the model update parameter between the local model parameter and the global model, the local model parameter is the model parameter obtained by local training of the training client, and the model update parameter is calculated by the following formula:
[0061]
[0062] Wherein, is the model update parameter of the i-th training client in the t-th round, is the local model parameter obtained by local training of the i-th training client in the t-th round, gω t-1 is the current global model.
[0063] S205: The trusted client downloads all local model update parameters in the model pool, scores the local model according to the scoring standard and calculates the clipping value, and uploads the trust score and the clipping value to the blockchain.
[0064] The trusted client scores the local model according to the cosine similarity and calculates the clipping value. The trusted client normalizes the amplitude difference between the training client update parameters, and the trust score is calculated according to the following formula:
[0065]
[0066] The clipping value is calculated according to the following formula:
[0067]
[0068] wherein, is the clipping value of the i-th training client in the t-th round, is the update parameter between the i-th training client in the t-th round and the global model, is the update parameter between the trusted client in the t-th round and the global model, is the trust score of the i-th training client in the t-th round.
[0069] S207: Calculate the weight of the local model of the training client according to the loss value obtained by the training of the training client.
[0070] According to the loss value predicted by the training of the training client, the weight of the local model of the training client is calculated, which is specifically:
[0071]
[0072] wherein, is the weight of the local model of the i-th training client in the t-th round, is the average value of the predicted future loss value of the i-th training client in the t-th round, and K is the number of clients participating in the training.
[0073] Aggregation stage: model aggregation is performed according to the model trust score and the weight, and the global model of this round is obtained. The global model is uploaded to the blockchain, and the next round of training is started.
[0074] The aggregation stage specifically includes the following steps:
[0075] S301: All training clients download local model parameters, trust scores and weights from the model pool;
[0076] S303: The training client aggregates parameters according to the trust score and the weight, and aggregates a brand new global model;
[0077] S305: The trained client uploads the aggregated brand-new global model to the blockchain.
[0078] In step S303, the parameter aggregation adopts the following algorithm:
[0079]
[0080] wherein g t is the brand-new global model of the tth round of aggregation, is the trust score of the ith training client in the tth round, is the model update parameter of the ith training client in the tth round, is the weight of the local model of the ith training client in the tth round, and K is the number of clients participating in training.
[0081] In view of the problem that the federated learning and blockchain combined framework lacks defense means against possible Byzantine attacks, the preferred embodiment of the present application applies the FLTrust algorithm in the federated learning and blockchain framework, aggregates the trust scores of the local models uploaded by each client, and excludes malicious clients, so that the overall framework can cope with Byzantine attacks to some extent and ensure the accuracy of the final global model.
[0082] On the other hand, the current federated learning and blockchain combined framework still has deficiencies in aggregation efficiency, and the aggregation speed is slow and a large number of convergence rounds are required. The preferred embodiment of the present application accelerates the aggregation speed and reduces the convergence rounds by loss prediction and aggregation weight distribution, predicts the future loss of the client by pre-training the loss record, adjusts the aggregation weight according to the prediction result, accelerates the aggregation speed of the client, and finally the aggregation efficiency of the algorithm framework is improved, and a better global model result can be obtained with fewer convergence rounds.
[0083] The present application will be described in detail below in combination with the preferred embodiment of the present application.
[0084] As shown in the figure, the preferred embodiment of the present application provides a blockchain federated learning security aggregation framework based on hierarchical index screening, and the main process includes the following steps: Figures 1-2 Step 1: In the preparation stage of the framework, first, pre-training is performed for six rounds with all clients participating, the loss values of all clients in the past six rounds of training are found, and the loss values are uploaded and saved to the blockchain.
[0085]
[0086] In this phase, the framework will fit the trend of loss reduction by statistically analyzing the client's historical loss decline, predicting the future trend of loss reduction, and further predicting the client's future performance. The framework will select the client's loss decline over the past six rounds, average these values to form the final evaluation weights, and use these weights for model aggregation during the aggregation process.
[0087] Step 2: After uploading and saving the loss values, the framework first allows a trusted client to train the model, obtaining local parameters that can be used as scoring criteria. It then finds the update distance between the local and global model parameters and saves this update distance as the scoring criterion, uploading it to the blockchain. This trusted client uses a local dataset to train a trusted model. And calculate the reliable model. With the current global model gω t-1 Model update parameters The calculated model update parameters are used as the scoring criteria.
[0088] Step 3: During the formal training process, when the t-th round of training begins, all clients download the global model gω from the blockchain. t-1 Furthermore, the model is trained using a local dataset, and the updated parameters of the trained model are uploaded to the model pool.
[0089] In this process, after receiving the global model, the client performs local training, calculates the loss reduction value for the current round, and uploads the obtained local model and loss reduction value. The loss reduction value is added to each client's historical loss reduction list. The model update parameters obtained during training are uploaded to the model pool to await scoring. K participating clients perform local training to obtain local model parameters. And it will calculate the local model parameters and the current global model gω. t-1 Model update parameters Taking the i-th client as an example, the specific algorithm is as follows:
[0090]
[0091] in, Update the parameters of the model for the i-th training client in the t-th round. To obtain the local model parameters for the i-th training client in the t-th round, gω t-1 This is the current global model.
[0092] Step 4, as follows Figure 3As shown, the framework in the aggregation preparation stage, in the t round of training, let the trusted client download all local model update parameters in the model pool, and score the local model according to the cosine similarity and calculate the clipping value, and calculate the trust score TS t The clipping value c t is uploaded to the chain. In addition, the amplitude difference between the client update parameters is calculated, and the amplitude difference is normalized to ensure that the local update parameters of the client are within a certain range, and finally the aggregation will determine the aggregation weight of this part of the local model together with the clipping value and the trust score.
[0093] Take the i-th client as an example, the update parameters between the t-th round of trusted client and the global model are The update parameters between the i-th client and the global model are The clipping value c The trust score TS The specific algorithm is:
[0094]
[0095]
[0096] Wherein, is the clipping value of the i-th training client in the t-th round, is the update parameter between the i-th training client and the global model in the t-th round, is the update parameter between the t-th round of trusted client and the global model, is the trust score of the i-th training client in the t-th round.
[0097] Step 5, the framework in the t round, next will be according to the loss value of the local client i training Subtract the loss value of the global model Calculate the loss difference between each other Then the algorithm will predict the future loss value n times, respectively The n predicted values of The average value of these predicted values is taken as the final predicted value; Then calculate the weight of each client local model through the following formula:
[0098]
[0099] Wherein, is the weight of the i-th training client local model in the t-th round, is the average value of the i-th training client's multiple predicted future loss values in the t-th round, and K is the number of clients participating in training.
[0100] Step 6, the framework calculates the model aggregation weight according to the trust score and the weight calculated according to the loss value in the aggregation stage, and completes the global model according to the aggregation weight, and starts the next round.
[0101] In this process, a plurality of local models download a plurality of model parameters from the model pool according to the trust score and the loss value to predict the aggregation weight Each aggregation obtains the same global model, and adds the new global model after aggregation to the blockchain. The specific algorithm for aggregating parameters is as follows:
[0102]
[0103] Wherein, g t is the new global model of the tth round of aggregation, is the trust score of the ith training client in the tth round, is the model update parameter of the ith training client in the tth round, is the weight of the local model of the ith training client in the tth round, and K is the number of clients participating in training.
[0104] The above describes the preferred embodiments of the present application in detail. It should be understood that those skilled in the art can make many modifications and changes without creative labor according to the concept of the present application. Therefore, any technical solution obtained by logical analysis, reasoning or limited experiment on the basis of the prior art according to the concept of the present application shall be within the protection scope determined by the claims.
Claims
1. A secure aggregation method for blockchain federated learning based on hierarchical index screening, characterized in that, The method includes a pre-training phase, a formal training phase, and an aggregation phase, wherein: The pre-training phase: The training client participates in pre-training and uploads the calculated loss value to the blockchain; The formal training phase involves: a trusted client training the model and providing a scoring standard; the training client training and uploading local model parameters to the blockchain; the trusted client scoring the local model and calculating the weights of the local model; and the trusted client uploading the model trust score and the weights. The aggregation phase involves aggregating models based on their trust scores and weights to obtain the global model for this round, uploading the global model to the blockchain, and starting the next round of training. During the formal training phase: The trusted client scores the local model based on cosine similarity and calculates a pruning value. The trusted client normalizes the magnitude difference between the updated parameters of the training client. The trust score and the pruning value are calculated using the following formulas: , , in, This is the pruning value for the i-th training client in the t-th round. Let i be the update parameters between the i-th training client in round t and the global model. For the update parameters between the trusted client and the global model in round t, Let be the trust score of the i-th training client in the t-th round; Predict future loss values based on the loss values trained on the training client, and calculate the weights of the local model on the training client using the future loss values, specifically as follows: , in, Let be the weights of the i-th training client-side local model in round t. Let K be the average of the multiple future prediction loss values of the i-th training client in the t-th round, and K be the number of clients participating in the training.
2. The secure aggregation method for blockchain federated learning as described in claim 1, characterized in that, The pre-training phase includes the following steps: S101: All the training clients participate in pre-training, which is carried out in a predetermined number of rounds; S103: In each round of pre-training, the training client calculates the loss value for that round of training; S105: The training client uploads the loss value to the blockchain.
3. The secure aggregation method for blockchain federated learning as described in claim 2, characterized in that, During the pre-training phase, the trend of loss reduction is fitted by statistically analyzing the historical loss reduction values of the training client, thereby predicting the future trend of loss reduction values of the training client.
4. The secure aggregation method for blockchain federated learning as described in claim 1, characterized in that, The formal training phase includes the following steps: S201: The trusted client obtains trusted model parameters through training, calculates the update distance between the trusted model parameters and the global model parameters, uses the update distance as the scoring standard, and uploads the scoring standard to the blockchain; S203: All the training clients download the global model on the blockchain, train it using the local dataset, and upload the updated parameters of the local model obtained from the training to the model pool in the blockchain; S205: The trusted client downloads all the local model update parameters in the model pool, scores the local models according to the scoring criteria and calculates the pruning value, and the trusted client uploads the trust score and the pruning value to the blockchain; S207: Calculate the weights of the local model on the training client based on the loss value obtained by the training client.
5. The secure aggregation method for blockchain federated learning as described in claim 4, characterized in that, In step S203, after receiving the global model, the training client performs local training, calculates the loss reduction value for this round, uploads the trained local model and the loss reduction value to the blockchain, and the loss reduction value is added to the historical loss reduction value list of each training client.
6. The secure aggregation method for blockchain federated learning as described in claim 5, characterized in that, The local model update parameters are the model update parameters between the local model parameters and the global model. The local model parameters are the model parameters obtained by the training client through local training. The model update parameters are calculated using the following formula: , in, Update the parameters of the model for the i-th training client in the t-th round. To obtain the local model parameters for the i-th training client in the t-th round, This is the current global model.
7. The secure aggregation method for blockchain federated learning as described in claim 1, characterized in that, The aggregation phase includes the following steps: S301: All training clients download the local model parameters, the trust score, and the weights from the model pool; S303: The training client aggregates parameters based on the trust score and the weights to generate a new global model; S305: The training client uploads the aggregated, new global model to the blockchain.
8. The secure aggregation method for blockchain federated learning as described in claim 7, characterized in that, In step S303, the parameter aggregation uses the following algorithm: , in, For the new global model of aggregation in round t, Let be the trust score of the i-th training client in round t. Update the parameters of the model for the i-th training client in the t-th round. Let K be the weight of the local model of the i-th training client in the t-th round, and K be the number of clients participating in the training.
Citation Information
Patent Citations
Bockchain enabling asynchronous federal learning method
CN113902127A
Method and apparatus for training traffic flow prediction model, electronic device, and storage medium
WO2022116424A1