A blockchain-based hierarchical federated learning incentive method and system
The hierarchical federated learning incentive method designed using blockchain consensus mechanism and contract theory solves the problems of data security and insufficient incentive mechanism when the number of clients in the federated learning system increases, thereby improving training efficiency and model accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING UNIV OF SCI & TECH
- Filing Date
- 2024-01-12
- Publication Date
- 2026-07-24
Smart Images

Figure CN118052297B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of federated learning technology, and in particular relates to a blockchain-based hierarchical federated learning incentive method and system. Background Technology
[0002] As we all know, modern machine learning relies on massive amounts of data. How to effectively utilize this dispersed data to serve valuable artificial intelligence applications has become a pressing issue. However, in many cases, due to data privacy concerns, clients are unwilling to directly contribute their data. Therefore, federated learning technology has become a research hotspot in machine learning. Federated learning allows distributed clients to collaboratively train models. Clients do not need to upload their own raw data; they only need to upload the model parameters trained in each global round. This effectively avoids privacy leaks and also addresses the problem of insufficient training data to some extent.
[0003] However, as the number of participating clients increases to a certain extent, data security inevitably becomes a major challenge. The decentralization, tamper-proof nature, and auditing mechanisms of blockchain can effectively address the security issues of federated learning. The multi-party storage of model parameters on the blockchain effectively prevents system paralysis due to server failures and unfairness caused by malicious behavior from a single server. Furthermore, clients will not provide their data and computing power free of charge; incentives are necessary to encourage clients to actively train the model. Moreover, due to the heterogeneity of the clients themselves, a suitable incentive mechanism must be designed to maximize the benefits for all parties.
[0004] Currently, typical federated learning systems do not comprehensively measure client data contributions, and traditional model averaging algorithms are also ineffective. Common incentive mechanisms in federated learning include auction theory, contract theory, and game theory; however, accurately reflecting the utility goals of both parties remains a challenge. Furthermore, blockchain-based federated learning systems often lack efficient consensus mechanisms, resulting in the consensus process consuming significant computing power and time. Summary of the Invention
[0005] The purpose of this invention is to provide a blockchain-based hierarchical federated learning incentive method and system, which realizes an effective incentive mechanism to promote the enthusiasm of federated learning server and client training, and makes the federated learning system more lightweight and efficient through the consensus mechanism of blockchain.
[0006] The technical solution to achieve the purpose of this invention is as follows: On the one hand, this invention provides a blockchain-based hierarchical federated learning incentive method, the steps of which are as follows:
[0007] Step 1: In the lower layer of the federated learning system, the task requester based on the federated learning framework provides the total reward value and requests the federated learning system to perform the training task; according to the contribution of each server in the federated learning to the training task, the total reward value is distributed to each server proportionally.
[0008] Step 2: Each server formulates a federated learning task contract that conforms to the data quality type of each client.
[0009] Step 3: Each client selects a contract that matches its category and signs it. After the contract is signed, each client enters the federated learning model training phase.
[0010] Step 4: Each client, according to the requirements in the contract, submits the generated local model parameters to the respective server via wireless channel after local iteration;
[0011] Step 5: Each server determines whether each client is honestly fulfilling the contractual task based on the precision threshold corresponding to the contract content. Clients that pass the verification will receive the corresponding reward.
[0012] Step 6: On the upper blockchain layer of the federated learning system, the submitted local model is verified and published as a global model for learning transactions and aggregations, and is packaged into a block; according to the contribution-based consensus mechanism, the block-producing server is selected and the block is produced.
[0013] Step 7: The federated learning server distributes the global model from the blockchain to each federated learning client for global iteration, repeating steps 4 to 7 until the global model converges.
[0014] On the other hand, the present invention also provides a blockchain-based hierarchical federated learning incentive system, comprising:
[0015] Local data training module: Used to perform local iterative training on local data from the federated learning client to generate local model updates.
[0016] Local utility calculation module: Used to calculate the cost of federated learning clients and select the best contract terms based on the utility function.
[0017] Federated Aggregation Module: Used to aggregate local models collected by the federated learning server and generate a global model.
[0018] Contract generation module: Used to calculate the utility of the federated learning server and generate a series of contract terms.
[0019] Incentive Allocation Module: Used to allocate reward values between the federated learning server and block-producing nodes.
[0020] Blockchain consensus module: used to calculate the contribution and reputation values of the federated learning server and select block nodes to produce blocks.
[0021] Blockchain ledger module: Used to store local and global models generated during federated learning.
[0022] A computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the aforementioned hierarchical federated learning incentive method for blockchain.
[0023] Compared with the prior art, the significant progress of the present invention is as follows: (1) The present invention accurately reflects the data contribution of the client through the model federated learning aggregation algorithm based on client contribution, which effectively improves the accuracy of federated learning training model; (2) The present invention promotes the enthusiasm of all parties to participate in training through the designed federated learning incentive mechanism based on contract theory, which improves the training accuracy and training latency; (3) The present invention effectively reduces the consumption of computing power and improves the training accuracy through the designed consensus mechanism based on server contribution and reputation value.
[0024] To more clearly illustrate the functional characteristics and structural parameters of the present invention, further explanation is provided below in conjunction with the accompanying drawings and specific embodiments. Attached Figure Description
[0025] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this application, illustrate exemplary embodiments of the invention and, together with their description, serve to explain the invention and do not constitute an undue limitation thereof. In the drawings:
[0026] Figure 1 This is a flowchart illustrating the hierarchical federated learning system based on blockchain according to the present invention.
[0027] Figure 2 This is a utility diagram of the federated learning client of the present invention when selecting different contracts.
[0028] Figure 3 This is a total utility diagram of the federated learning server and federated learning client of the present invention when the client distribution types are different.
[0029] Figure 4 (a) and (b) are performance graphs of the actual model training of the present invention. Detailed Implementation
[0030] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0031] Combination Figure 1 This invention provides a blockchain-based hierarchical federated learning method, comprising:
[0032] Step 1: In the lower-level federated learning layer of the system, the requester of the federated learning task provides a total reward value, requesting the federated learning system to perform the training task. Based on the contribution of each federated learning server to the federated learning task, the total reward value is proportionally distributed among L servers.
[0033] Step 2: Each federated learning server collects N types of federated learning client nodes, and then analyzes the data quality type ε of the federated learning clients. n Develop a series of federal learning task contracts (D) that conform to the corresponding types. n R n ) is provided to the federated learning client, where D n To determine the required amount of data from the federated learning client, R... n The rewards provided to the federated learning server are implemented as follows:
[0034] Step 2-1: The utility function of the federated learning client, which is the difference between the task reward value and the cost of the training task, is expressed as:
[0035]
[0036] in and These are the client-side model training cost and the communication cost for model uploading, respectively. After simplification, we can obtain... Where C is the cost constant.
[0037] Step 2-2: The utility function of the federated learning server is the difference between the contribution to the training task and the reward paid. The contribution to the training task is represented by the contribution to the model quality and the contribution to the training time, expressed as...
[0038]
[0039] Where T max T represents the training time for the maximum tolerance of synchronous aggregation and a constant related to the training time, respectively, and w q and w tThese represent the preference weights for model quality and training time, respectively. For K clients, there are a total of N types, and the probability distribution for each type n is p. n ,and The total utility function of the cumulative federated learning server is
[0040] Steps 2-3: According to contract theory, the objective function is to maximize the total utility of the federated learning server, while also ensuring that the utility functions of the federated learning clients satisfy two constraints: individual rationality and incentive compatibility. Individual rationality means that each client will only participate in the federated learning task if its utility is not less than zero.
[0041]
[0042] Incentive compatibility means that each client, in order to maximize utility, can only choose the contract it designed for itself, and not other types of contracts.
[0043]
[0044] In summary, the optimization problem can be derived. Based on the feasibility conditions of the contract, the optimization problem is simplified and finally a series of contract terms are solved. For a fixed number of data points, the allocation is D1≤D2≤...≤DN N The contract, the only optimal reward distribution Given by the following formula
[0045]
[0046]
[0047] At the same time Then the optimization problem By maximizing G respectively n To achieve:
[0048]
[0049] Among them, Λ n G is the difference in cost between client n and the previous client. n This is a function to maximize the contract strategy for a single client.
[0050] Step 3: Due to individual rationality and incentive compatibility, the federated learning client will select and sign a contract corresponding to its own category. After signing, it will enter the model training phase.
[0051] Step 4: The federated learning client, according to the requirements in the contract, iterates a certain number of times locally, and the result is represented as E0log(1 / ε). n), where E0 is the baseline value for the local iteration number, ε n The overall data quality is considered to ignore the impact of poor data quality on local accuracy. Then, the local model parameters are submitted to the federated learning server via wireless channel.
[0052] Step 5: The federated learning server determines whether the federated learning client is honestly fulfilling the contractual task based on the precision threshold corresponding to the contract content. If the verification is successful, the corresponding reward is issued.
[0053] Step 6: In the upper blockchain layer of the federated learning system, the submitted local model is verified and published as a series of learning transactions and an aggregated global model, and packaged into a block. According to the contribution-based consensus mechanism, the block-producing server is selected and the block is produced.
[0054] The specific implementation method is as follows:
[0055] Step 6-1: All submitted model parameters are further validated by the smart contract using a public dataset and published as learning transactions by the federated learning server. The learning transaction TX between the federated learning server l and the federated learning client k... lk The format can be represented as
[0056] TX lk ={ADD k ||IM||ω lk ||ε lk ||ADD l ||timestamp||sig k ||sig l}
[0057] Among them, ADD k and ADD l These represent the wallet addresses of the data owner and the blockchain node, respectively. IM represents the incentive terms information for model training, and the model parameter is ω. lk The time of the transaction release is timestamp, sig k ||sig l A digital signature representing both parties.
[0058] Step 6-2: Aggregate all model updates using an aggregation algorithm based on server contributions. The weighted average parameter of the global aggregation in round t is expressed as:
[0059]
[0060] Among them, D k and These represent the dataset size and local model parameters of the k-th federated learning client, respectively, for a total of K clients.
[0061] Step 6-3: Each server adds the learned transactions and the global model to a single block. A concept of a federated learning server reputation value is proposed. The reputation value is calculated based on whether the federated learning server in the blockchain layer honestly publishes transactions and blocks, represented as...
[0062] r t =r t-1 (1+p1λ in -p2λ de -5p3λ de )
[0063] Where p1, p2, and p3 represent the percentages of completely honest transactions, partially honest transactions, and malicious block updates, respectively, and λ in , λ de These are the reward and punishment coefficients for honest and dishonest behavior, respectively. Using a consensus mechanism based on the server's reputation value and its contribution to the training task, the probability weight for each server to successfully produce a block is selected. Therefore, the probability of server l producing a block in the federated learning is:
[0064]
[0065] The total number of federated learning servers is L. It is the sum of the training tasks from a single server, r l It is a reputation value that blockchain nodes gain based on their behavior. Servers that successfully produce a block receive a reward value, and then all servers add the selected block to their own blockchain ledger.
[0066] Step 7: The federated learning server distributes the global model stored in the previous round from the blockchain to each federated learning client for the next round of global iteration. Since the establishment of the incentive process consumes resources, all rounds of global iteration share the same incentive process, and the above steps 4 to 7 are repeated continuously until the global model converges.
[0067] This invention also provides a blockchain-based hierarchical federated learning incentive system, comprising:
[0068] Local data training module: Used to perform local iterative training on local data from the federated learning client to generate local model updates.
[0069] Local utility calculation module: Used to calculate the cost of federated learning clients and select the best contract terms based on the utility function.
[0070] Federated Aggregation Module: Used to aggregate local models collected by the federated learning server and generate a global model.
[0071] Contract generation module: Used to calculate the utility of the federated learning server and generate a series of contract terms.
[0072] Incentive Allocation Module: Used to allocate reward values between the federated learning server and block-producing nodes.
[0073] Blockchain consensus module: used to calculate the contribution and reputation values of the federated learning server and select block nodes to produce blocks.
[0074] Blockchain ledger module: Used to store local and global models generated during federated learning.
[0075] The specific implementation methods of each module of the above system are the same as those of the aforementioned hierarchical federated learning incentive method, and will not be repeated here.
[0076] Example
[0077] In this embodiment, for the contract theory incentive method, we assume that a federated learning server has 40 federated learning clients, and the data quality is distributed in 10 different types with a specific distribution.
[0078] like Figure 2 As shown in the figure, the effectiveness of the contract is verified by simulation results. It can be seen from the figure that for a certain type of federated learning client, only by selecting a contract corresponding to the type can the maximum value of personal utility be obtained, which verifies the incentive compatibility property of the contract.
[0079] like Figure 3 As shown, we set four different data type distribution scenarios: uniform distribution, more large types (more high-quality types), more small types (more low-quality types), and normal distribution, and verified the total utility of the federated learning client and the federated learning server under these four different distribution scenarios. It can be observed that the federated learning server achieves the highest utility with more large types, but the federated learning client achieves the lowest total utility. This proves that improving the overall data quality of the federated learning client is beneficial to the federated learning task of the federated learning server, but will lead to a decrease in the overall utility of the federated learning client.
[0080] For a blockchain-based hierarchical federated learning system, 10 federated learning servers are simulated, each running blockchain nodes. Each server has approximately 10 federated learning clients, and a certain number of dishonest blockchain nodes exist. We assume that without effective oversight, the number of dishonest servers is 2, and the probability of a dishonest server publishing a bad model or a delayed publication in each round is 0.5; the number of servers publishing malicious blocks is 1, and its probability of publishing a malicious block is 0.1. Using popular image datasets FashionMnist and Cifar, this invention, a system using a traditional Proof-of-Quality (PoQ) mechanism under completely asymmetric information (CIA) (CIA+PoQ), and a system using PoQ under the incentive mechanism of this invention (IIAAT+PoQ) are compared to verify the effectiveness of the system of this invention in terms of latency and accuracy.
[0081] like Figure 4 As shown in (a) and (b), firstly, in the absence of a blockchain reputation mechanism and contribution auditing, the model accuracy and latency of the IIAAT+PoQ system are unsatisfactory compared to the present invention. Secondly, due to the lack of an effective incentive mechanism, the CIA+PoQ system performs the lowest in terms of model accuracy, but it takes less time than the present invention due to less training data. Therefore, compared with other systems, the proposed invention achieves higher model accuracy and lower latency for federated learning tasks due to effective incentives for all parties and the monitoring of malicious behavior.
[0082] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0083] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A blockchain-based hierarchical federated learning incentive method, characterized in that, Specifically, the following steps are included: Step 1: In the lower layer of the federated learning system, the task requester based on the federated learning framework provides the total reward value and requests the federated learning system to perform the training task. Based on the contributions of each server in the federated learning to the training task, the total reward value is distributed proportionally to each server. The server's contribution to the training task is the sum of the contributions of its subordinate clients, and the client's contribution is: in, These are the maximum tolerance training time for synchronous aggregation and constants related to the training time, respectively. and These represent the preference weights for model quality and training time, respectively. and These refer to the data quality and the amount of data required from the federated learning client, respectively. Step 2: Each server formulates a federated learning task contract that conforms to the data quality type of each client. Step 3: Each client selects a contract that matches its category and signs it. After the contract is signed, each client enters the federated learning model training phase. Step 4: Each client, according to the requirements in the contract, submits the generated local model parameters to the respective server via wireless channel after local iteration; Step 5: Each server determines whether each client is honestly fulfilling the contractual task based on the precision threshold corresponding to the contract content. Clients that pass the verification will receive the corresponding reward. Step 6: On the upper blockchain layer of the federated learning system, the submitted local model is verified and published as a global model for learning transactions and aggregations, and is packaged into a block; according to the contribution-based consensus mechanism, the block-producing server is selected and the block is produced. Step 7: The federated learning server distributes the global model from the blockchain to each federated learning client for global iteration, repeating steps 4 to 7 until the global model converges.
2. The blockchain-based hierarchical federated learning incentive method according to claim 1, characterized in that, The federated learning task contract described in step 2 is a contract concerning the amount of data and the reward value, which is jointly solved by the utility functions of the server and its subordinate clients. The utility functions for each server are as follows: in, For the number of federated learning clients, For federated learning client type, The data quality represented by each type, For probability distribution, , For payment to type The corresponding reward value, Contributions to the client; The utility functions for each client are: in, and These are the client-side model training cost and the communication cost for model uploading, respectively. For payment to type The corresponding reward value; Calculate reward distribution : in, It is a constant related to client costs. It refers to the amount of data on the client side; Calculation data volume : ; in, For maximizing the contract strategy of a single client, It is a client The cost difference with the previous client can be maximized. The optimal amount of data can then be determined. ; Finally, a federated learning task contract was obtained. .
3. The blockchain-based hierarchical federated learning incentive method according to claim 1, characterized in that, The local iteration mentioned in step 4 is as follows: in, This serves as the baseline value for the number of local iterations. For the overall data quality.
4. The blockchain-based hierarchical federated learning incentive method according to claim 1, characterized in that, Step 6 includes the following steps: Step 6-1: Upload the local model parameters to each server. Each client uploads the local model to its respective server. After verification by the smart contract, it is published as a learning transaction. The global model is generated using the aggregation algorithm and added to a block. Step 6-2: Use an aggregation algorithm based on model quality contribution to aggregate local model updates, generate a global model, and publish it. Step 6-3: Propose the concept of a reputation value for federated learning servers. The change in reputation value is determined by the verification results of model parameters, etc. Each server packages all local model updates and global model into a block. Through a consensus mechanism based on the server's task contribution and reputation value, the server that produces the block is selected to receive a reward value, and the generated block is stored in the blockchain ledger of each server.
5. The blockchain-based hierarchical federated learning incentive method according to claim 4, characterized in that, The learning of trading described in step 6-1 is as follows: Each server and various clients Learning to trade for: in, and These are the wallet addresses of the data owner and the blockchain node, respectively. Information on incentive terms for model training. For model parameters, For data quality, The time point at which the transaction was published. For digital signatures of both parties.
6. The blockchain-based hierarchical federated learning incentive method according to claim 4, characterized in that, In step 6-2, the local model updates are aggregated. The weighted average parameter of the global aggregation of the rounds is: in, and The first The size of the dataset and the local model parameters for each federated learning client. This refers to the number of clients.
7. The blockchain-based hierarchical federated learning incentive method according to claim 4, characterized in that, The credit score calculated in step 6-3 is as follows: in, These figures represent the percentages of completely honest exchanges, partially honest exchanges, and exchanges that maliciously update blocks. These are the reward and punishment coefficients for honest and dishonest behavior, respectively. The consensus mechanism uses the server's reputation value and training task contribution value as the probability weights for each server to successfully produce a block. This results in a federated learning server... The probability of producing a block is: in, The total number of federated learning servers. The total contribution to the training task of a single server. Reputation value that a blockchain node gains based on its behavior.
8. A blockchain-based hierarchical federated learning incentive system, characterized in that, To implement the method of any one of claims 1-7, comprising: Local data training module: used to perform local iterative training on local data from the federated learning client to generate local model updates; Local utility calculation module: used to calculate the cost of federated learning clients and select the best contract terms based on the utility function; Federated Aggregation Module: Used to aggregate local models collected by the federated learning server and generate a global model; Contract generation module: used to calculate the utility of the federated learning server and generate a series of contract terms; Incentive allocation module: Used to allocate reward values between the federated learning server and block-producing nodes; Blockchain consensus module: used to calculate the contribution and reputation values of the federated learning server and select block nodes to produce blocks; Blockchain ledger module: Used to store local and global models generated during federated learning.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the method as described in any one of claims 1-7.