Blockchain-based federated learning incentive allocation method and device

By using a blockchain-based incentive allocation method, and leveraging consensus nodes and smart contracts for model aggregation and contribution value calculation, the problems of incentive unfairness and reliability in federated learning are solved. This improves model generalization and security, reduces communication overhead, and enhances system scalability and stability.

CN116451806BActive Publication Date: 2026-04-17SUN YAT SEN UNIV +2
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUN YAT SEN UNIV
Filing Date
2023-04-18
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing federated learning suffers from unfair incentive mechanisms and low reliability and scalability, especially unfair to clients with small amounts of heterogeneous data. Furthermore, traditional federated learning relies on a central server, which presents security and scalability issues.

Method used

A blockchain-based incentive allocation method is adopted, which downloads global and local models through consensus nodes, uses smart contracts to aggregate models and calculate contribution values, and allocates incentives based on model generalization and contribution values. The decentralized federated learning framework reduces communication overhead and improves security.

Benefits of technology

It enables fair evaluation of client contributions in heterogeneous environments, improves model generalization and robustness, reduces communication overhead, enhances security and scalability, avoids single point of failure risks, and ensures privacy protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116451806B_ABST
    Figure CN116451806B_ABST
Patent Text Reader

Abstract

This invention discloses a blockchain-based method and apparatus for allocating incentives in federated learning. The method includes: each client participating in federated learning downloads a first global model and a first local model set from the consensus node of the blockchain; each client trains the first global model using its local training dataset to obtain a trained local model and uploads it; based on the trained local model and the first local model set, estimates a second local model set and uploads it; after all clients have uploaded their models, all trained local models are aggregated to obtain a second global model, and the second local model sets are aggregated to obtain local models; the consensus node broadcasts all models, and each client verifies the accuracy of each model and calculates its contribution value; based on a preset total incentive and contribution value, the incentive value for each client is calculated and the incentive is allocated. This invention can improve the generalization and robustness of the model, improve the efficiency and accuracy of model training, and enhance the security and scalability of federated learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine learning technology, and in particular to a blockchain-based federated learning incentive allocation method and apparatus. Background Technology

[0002] With the accelerating digitalization of society, massive amounts of data have been generated. Machine learning technology can automatically extract rich information hidden within this data, and machine learning models trained on large datasets are widely used in various application fields. However, due to constraints on data privacy and security, such as laws and regulations, policy oversight, trade secrets, and personal privacy, multiple data sources cannot directly exchange data, creating "data silos" that hinder the further improvement of artificial intelligence model capabilities. Federated learning was developed to address this problem.

[0003] Federated learning is a distributed machine learning technique designed to enable efficient machine learning across multiple participants or computing nodes while ensuring information security during big data exchange, protecting terminal and personal data privacy, and guaranteeing legal compliance. Federated learning typically employs a parameter server architecture, where clients train local models distributed by the parameter server. Therefore, federated learning requires an incentive mechanism to evaluate and reward client contributions. Existing incentive mechanisms primarily evaluate client contributions based on data volume, data quality, or computational impact, but this is unfair to clients with limited or heterogeneous data.

[0004] Furthermore, traditional federated learning requires a central server to aggregate the global model, which raises security and scalability issues. Summary of the Invention

[0005] The purpose of this invention is to provide a blockchain-based method and apparatus for allocating incentives in federated learning, in order to solve the technical problems of unfairness, low reliability, and low scalability of existing incentive mechanisms in federated learning.

[0006] The objective of this invention can be achieved through the following technical solutions:

[0007] A blockchain-based federated learning incentive allocation method includes:

[0008] Each client participating in federated learning downloads the first global model and the corresponding first local model set from the consensus node of the blockchain. Each client trains the first global model using the local training dataset to obtain a trained local model. Based on the trained local model and the first local model set, an approximate estimate is made to obtain the corresponding second local model set. The trained local model and the second local model set are then uploaded to the consensus node.

[0009] The first global model is obtained by aggregating all trained local models uploaded by clients in the previous training round, the first local model set is any set of local models not uploaded by clients in the previous training round, and the second local model set is an estimated model set of any set of local models uploaded by clients in the current training round.

[0010] After all clients upload the trained local models and the second local model set to the consensus node, the smart contract is used to aggregate all the trained local models to obtain the second global model, and to aggregate all the models in the second local model set to obtain the corresponding local model.

[0011] The consensus node broadcasts the second global model and the local model to all clients. Each client uses a local test set and a preset first formula to verify the accuracy of each model. Based on the accuracy and the preset second formula, the contribution value of each client is calculated. The contribution value can reflect the improvement of the client's generalization of the model in heterogeneous scenarios.

[0012] The incentive value for each client is calculated based on the preset total incentive of federated learning and the contribution value, and the incentive is allocated to each client based on the incentive value.

[0013] Optionally, obtaining the corresponding second local model set by approximating the trained local model and the first local model set includes:

[0014] use Approximate estimation is performed to obtain the corresponding second local model set;

[0015] Where 1≤i≤N, N is the number of clients participating in federated learning, the client set C={1,2,…N}, S is any subset of C containing client i, and CS is the complement of subset S in C; This is the trained local model obtained by client i in the t-th training round; Let be the first local model set, representing any set of local models obtained in the (t-1)th round of training that does not include the models uploaded by client i; Let be the second local model set, representing the estimated model set of any set of local models uploaded by client i itself during the t-th round of training.

[0016] Optionally, the second global model is obtained by aggregating all the trained local models using a smart contract, including:

[0017] Smart contract utilization All trained local models are aggregated to obtain the second global model;

[0018] Among them, w t This is the second global model. Let C be the trained local model uploaded by client i in the t-th training round, and let D be the set of clients that upload local models in federated learning. i Let |D be the local training dataset owned by client i. i |For dataset D i The number of samples in the sample.

[0019] Optionally, the preset second formula is:

[0020]

[0021] Among them, u i Let (t) be the contribution value of client i in the t-th round of training, and C{i} be the set of clients other than client i. Let K denote that set K is a subset of set C{i}, |K| represent the number of clients contained in set K, ! denotes a factorial element, and W K To train a model using the local training datasets of clients in set K, acc(W) K D test ) is model W K In test dataset D test The accuracy rate on W K∪{i} To add client i to the model after setting K, acc(W) K∪{i} D test ) is model W K∪{i} In test dataset D test The accuracy on the acc(W) K∪{i} D test )-acc(W K D test (Model W) K∪{i} With model W K In test dataset D test The difference in accuracy.

[0022] Optionally, acc(W K∪{i} D test )-acc(WK D test () is a quantitative indicator of the improvement in model generalization by client i in heterogeneous scenarios.

[0023] Optionally, calculating the incentive value for each client based on the preset total incentive of federated learning and the contribution value includes:

[0024] Using formula Determine the incentive values ​​available to each client;

[0025] in, Let u be the activation value obtained by client i in the t-th round of training. i (t) is the contribution value of client i in the t-th round of training, u k (t) represents the contribution value of client k in the t-th round of training, ∑ k∈C u k B(t) represents the sum of contributions from all clients in the t-th round of training, and B(t) represents the preset total incentive.

[0026] Optionally, the contribution of each client can be measured based on the Shapley value.

[0027] The present invention also provides a blockchain-based federated learning incentive allocation device, comprising:

[0028] The model download and update module involves each client participating in federated learning downloading the first global model and the corresponding first local model set from the consensus node of the blockchain. Each client trains the first global model using its local training dataset to obtain a trained local model. Based on the trained local model and the first local model set, an approximate estimate is made to obtain the corresponding second local model set. The trained local model and the second local model set are then uploaded to the consensus node.

[0029] The first global model is obtained by aggregating all trained local models uploaded by clients in the previous training round, the first local model set is any set of local models not uploaded by clients in the previous training round, and the second local model set is an estimated model set of any set of local models uploaded by clients in the current training round.

[0030] The model aggregation module is used to aggregate all the trained local models to obtain the second global model and aggregate all the models in the second local model set to obtain the corresponding local model after all clients upload the trained local model and the second local model set to the consensus node using a smart contract.

[0031] The contribution value determination module is used by the consensus node to broadcast the second global model and the local model to all clients. Each client uses a local test set and a preset first formula to verify the accuracy of each model. The contribution value of each client is calculated based on the accuracy and the preset second formula. The contribution value can reflect the improvement of the client's generalization of the model in heterogeneous scenarios.

[0032] The incentive determination and allocation module is used to calculate the incentive value corresponding to each client based on the preset total incentive of federated learning and the contribution value, and to allocate incentives to each client based on the incentive value.

[0033] This invention provides a blockchain-based method and apparatus for allocating incentives for federated learning. The method includes: each client participating in federated learning downloads a first global model and a corresponding first local model set from the consensus node of the blockchain; each client trains the first global model using a local training dataset to obtain a trained local model; approximates the training local model and the first local model set to obtain a corresponding second local model set; and uploads the trained local model and the second local model set to the consensus node. The first global model is obtained by aggregating all trained local models uploaded by all clients in the previous training round; the first local model set is any set of local models from the previous training round excluding those uploaded by individual clients; and the second local model set is any set of local models from the current training round including those uploaded by individual clients. An estimated model set for any set of models; after all clients upload the trained local models and the second local model set to the consensus node, the smart contract aggregates all the trained local models to obtain the second global model, and aggregates all models in the second local model set to obtain the corresponding local models; the consensus node broadcasts the second global model and the local models to all clients, and each client uses its local test set and a preset first formula to verify the accuracy of each model. Based on the accuracy and the preset second formula, the contribution value of each client is calculated, which reflects the client's improvement in the generalization of the model in heterogeneous scenarios; the incentive value corresponding to each client is calculated based on the preset total incentive of federated learning and the contribution value, and incentives are allocated to each client based on the incentive value.

[0034] In view of this, the beneficial effects of this invention are:

[0035] In this invention, each client uses its local training dataset to train the previous round's global model, obtaining a trained local model which is then uploaded to the consensus node. Clients do not need to communicate directly with other clients, significantly reducing communication overhead. This invention uses the client's improvement in model generalization as the contribution evaluation standard. In heterogeneous environments, it can accurately estimate each client's contribution to the model and fairly allocate incentives based on client contributions. This allows for the inclusion of more clients with heterogeneous data in the federated model training, thereby improving the model's generalization and robustness. This invention derives a second local model set based on the trained local model and existing models. Therefore, when measuring the contribution value of each client, it is not necessary to retrain the model, and it can eliminate the influence of clients joining the federated learning in different orders, greatly improving the efficiency and accuracy of model training.

[0036] This invention utilizes blockchain for decentralized federated learning, ensuring secure training, open participation, fair allocation, and privacy protection in the federated learning incentive mechanism. It avoids the risks caused by single-point server failures in traditional federated learning, improves the reliability and stability of the model training process, and enhances the security and scalability of federated learning. Attached Figure Description

[0037] Figure 1 This is a schematic flowchart of the method of the present invention;

[0038] Figure 2 This is a schematic diagram of the blockchain-based decentralized federated learning framework in this invention;

[0039] Figure 3 This is a schematic diagram of the training process for the client in this invention;

[0040] Figure 4 This is a schematic diagram of the structure of an embodiment of the device of the present invention. Detailed Implementation

[0041] Terminology Explanation:

[0042] Federated learning, in the context of distributed machine learning, allows participating parties to jointly model and use models by leveraging data from other participants. Participants do not need to transfer or share original data resources, and model parameters are protected. This means that data can be jointly trained and applied without leaving the local machine, enabling the creation of legal and compliant machine learning models. Depending on the distribution of data sources among the participating parties, federated learning can be further divided into three categories: horizontal federated learning, vertical federated learning, and federated transfer learning.

[0043] Blockchain: Essentially, it's a public, trusted, and shared distributed ledger operating on a peer-to-peer network. The key idea behind the blockchain concept is decentralization, meaning that data on the blockchain is not controlled by any single entity. Instead, all blockchain nodes have equal rights to verify and manage the data stored in the blockchain, enabled by a consensus mechanism. This decentralized nature makes the blockchain resistant to data modification or attacks. Furthermore, removing a central server avoids the risk of single points of failure, thus improving the reliability and stability of the blockchain system.

[0044] Heterogeneity: Heterogeneity mainly consists of two aspects: data heterogeneity, referring to significant differences in the distribution of local training datasets across different clients; and system heterogeneity, referring to differences in computing power among clients. Both types of heterogeneity pose challenges to the federated training process. Due to significant differences in client data, different local data may optimize the global model in different directions, causing the aggregated global optimization direction to deviate from the optimal direction, thus reducing the overall model's performance and convergence speed. Furthermore, due to differences in client computing power, the model version uploaded by a client may be outdated. In such cases, including the outdated model in the aggregation process will significantly reduce the performance of the aggregated model.

[0045] Incentive Mechanism: Federated learning typically employs a parameter server architecture, where clients train local models distributed by the parameter server. When a client participates in federated learning, it inevitably consumes its device resources, including computing, communication, and energy. Therefore, without sufficient compensation, clients may be unwilling to participate or share their models. Federated learning requires an incentive mechanism to compensate for these costs, either numerically or in terms of the model itself. Incentive mechanisms are usually based on game theory or auction theory, using some metric to measure each client's contribution to the training process in federated learning, thereby achieving reasonable resource allocation and incentivizing clients to honestly and actively participate in training.

[0046] This invention provides a blockchain-based method and apparatus for allocating incentives in federated learning, addressing the technical problems of unfairness, low reliability, and low scalability in existing incentive mechanisms in federated learning.

[0047] To facilitate understanding of the present invention, a more complete description will be given below with reference to the accompanying drawings. Preferred embodiments of the invention are shown in the drawings. However, the invention can be implemented in many different forms and is not limited to the embodiments described herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete.

[0048] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein in the description of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.

[0049] The success of deep learning in fields such as image classification and text recognition relies heavily on large-scale datasets. However, collecting and labeling data requires significant time and effort. This makes training neural networks on large datasets extremely computationally expensive, limiting most individuals and groups to training on small datasets. Furthermore, increasing security awareness and growing concern for user privacy and data security, coupled with the improvement of laws and regulations governing data management and use, makes it increasingly difficult for different organizations, and even different departments within the same company, to collect and share data, ultimately creating the real-world problem of data silos.

[0050] The data silo problem can be addressed using federated learning. Federated learning allows clients to contribute model parameters or gradients, thus protecting client privacy by eliminating the need to collect their data. Federated learning enables multiple clients to collaboratively learn a shared global machine learning problem without compromising their privacy, resulting in better performance on specific tasks.

[0051] For the federated ecosystem to function properly, the benefits generated by the model need to be distributed fairly among each client. If the rewards received by a client are mismatched with their efforts, it will severely dampen their enthusiasm for participating in federated learning, leading to a lack of new clients joining or existing clients dropping out, ultimately resulting in a decline in the performance of the federated learning-trained model. Therefore, it is crucial to incentivize clients to actively participate in federated learning. This requires a fair incentive mechanism to evaluate client contributions and reward them accordingly. Rewards can take the form of money, business reputation, or well-trained models. Only when participants receive rewards commensurate with their contributions will they be likely to continue participating in federated learning.

[0052] Meanwhile, traditional federated learning requires a trusted centralized server to aggregate the global model. However, centralized servers pose risks of covert operations and privacy breaches, leading to security and scalability issues. Blockchain, as a decentralized technology, can solve these problems by implementing a transparent model training and reward distribution process. Specifically, blockchain possesses the following fundamental characteristics: decentralization, openness, immutability, and anonymity, which respectively guarantee secure training, open participation, fair allocation, and privacy protection in the federated learning incentive mechanism.

[0053] Traditional federated learning involves two roles: server and client. There can be multiple clients, but only one server. Clients do not communicate directly with each other; each client communicates only with the server. However, a single-node server is prone to single-point failure and suffers from trust issues with that node. Therefore, decentralized federated learning has attracted researchers' attention. Decentralized federated learning removes the server and, through the design of corresponding protocols, enables direct communication between clients. This is equivalent to building a peer-to-peer network, resulting in higher communication overhead.

[0054] In recent years, there has been some research on incentive mechanisms for federated learning. This research mainly focuses on how to evaluate client contributions, with clients contributing more and receiving greater incentives. Current evaluation methods determine the amount of data collected by each client.

[0055] Hierarchical fair federated learning uses the amount of data from each client as a shared evaluation criterion. Its basic idea is to divide participating clients into different tiers based on their contributions, with higher contributions resulting in higher tiers. Clients at each tier jointly train a model, and ultimately, different tiers aggregate different models, with higher-tier models performing better. Research shows that using more data to train the model is more likely to achieve a specific level of accuracy. However, the incentive mechanism in hierarchical fair federated learning is unfair to clients with heterogeneous data.

[0056] Incentive mechanisms have attracted significant attention from businesses and research institutions, and many excellent mechanisms have emerged. However, these mechanisms primarily evaluate client contributions based on data volume, data quality, or computational impact. Data quality is difficult to predict in advance, so most evaluations rely on data volume. Research has shown that model accuracy and the amount of training data are not linearly related, as malicious clients can use large amounts of invalid data to fraudulently claim higher rewards. Currently, these incentive mechanisms all suffer from the potential unfairness to clients with limited and heterogeneous data.

[0057] For example, for a movie, most users give it positive ratings, but a small group of users have critical opinions. This small group's data might be concentrated on a single client. This results in a significant difference between the data from the client representing this small group and that from other clients. Evaluating this client's contribution based on data volume or influence might result in its contribution being zero or even negative, greatly impacting its willingness to participate in federated learning. However, this client's data is crucial for improving model generalization and robustness. Therefore, this invention incorporates model generalization into the incentive mechanism design to attract clients with good generalization performance—that is, those that perform well on datasets from multiple clients—to join federated learning.

[0058] The purpose of this invention is to propose an incentive mechanism that uses model generalization as the contribution evaluation criterion. It considers the improvement in model generalization brought about by a client's data as that client's contribution, and distributes rewards to each client based on this. This incentive mechanism is reasonable and effective, rather than simply evaluating each client's contribution based on data volume or influence.

[0059] Furthermore, traditional federated learning requires a central server to aggregate the global model, which raises security and scalability concerns. Blockchain's distributed ledger technology offers a solution, offering features such as distribution, immutability, and traceability. Using a decentralized blockchain eliminates the need for a central server in federated training. Specifically, a shared, immutable ledger is used to aggregate the global model and distribute global updates to learning clients for direct computation on the device. This decentralized model aggregation not only reduces the risk of single points of failure and improves training reliability but also alleviates the burden on the central server in global model aggregation; furthermore, removing the central server lowers communication costs and attracts more users to participate in training, thereby improving network scalability.

[0060] Please see Figure 1 This invention provides an embodiment of a blockchain-based federated learning incentive allocation method, comprising:

[0061] S100: Each client participating in federated learning downloads the first global model and the corresponding first local model set from the consensus node of the blockchain. Each client trains the first global model using the local training dataset to obtain a trained local model. Based on the trained local model and the first local model set, an approximate estimate is made to obtain the corresponding second local model set. The trained local model and the second local model set are then uploaded to the consensus node.

[0062] The first global model is obtained by aggregating all trained local models uploaded by clients in the previous training round, the first local model set is any set of local models not uploaded by clients in the previous training round, and the second local model set is an estimated model set of any set of local models uploaded by clients in the current training round.

[0063] S200: After all clients upload the trained local models and the second local model set to the consensus node, the smart contract is used to aggregate all the trained local models to obtain the second global model, and to aggregate all the models in the second local model set to obtain the corresponding local model.

[0064] S300: The consensus node broadcasts the second global model and the local model to all clients. Each client uses a local test set and a preset first formula to verify the accuracy of each model. Based on the accuracy and the preset second formula, the contribution value of each client is calculated. The contribution value can reflect the client's improvement of the model's generalization ability in heterogeneous scenarios.

[0065] S400: Calculate the incentive value corresponding to each client based on the preset total incentive of federated learning and the contribution value, and allocate incentives to each client based on the incentive value.

[0066] The blockchain-based federated learning incentive allocation method provided in this embodiment employs decentralized federated learning. In a decentralized environment, since there is no server for aggregating the global model, each client is essentially a peer node, and using a protocol similar to Gossip would significantly increase communication overhead. Therefore, this embodiment designs a blockchain-based federated learning system that can reduce communication overhead even in a decentralized environment. Its learning framework is as follows: Figure 2 As shown.

[0067] In one embodiment of the present invention, in step S100, each local client participating in federated learning downloads the global model and the corresponding first local model set obtained from the consensus node of the blockchain before starting to train the model. Each client uses the local training dataset to train the global model of the previous round to obtain the trained local model. Based on the trained local model and the first local model set, an approximate estimation is performed to obtain the corresponding second local model set, and the trained local model and the second local model set are uploaded to the consensus node.

[0068] Then, the local model uploaded by the client is packaged into a block and uploaded to the blockchain through the consensus nodes of the blockchain, and consensus is reached on all consensus nodes of the blockchain.

[0069] Specifically, in the t-th round of training of federated learning, each client participating in federated learning downloads the global model w from the consensus node corresponding to the blockchain. t-1 and the corresponding local model set Client i trains a global model w using the local training dataset. t-1 Obtain the trained local model according to and estimate And and Upload to the consensus node.

[0070] Where 1≤i≤N, N is the number of clients participating in federated learning, the client set C={1,2,…N}, S is any subset of C containing client i, and CS is the complement of subset S in C; This is the trained local model obtained by client i in the t-th training round; Let be the first local model set, representing any set of local models obtained in the (t-1)th round of training that does not include the models uploaded by client i; Let be the second local model set, representing the estimated model set of any set of local models uploaded by client i itself during the t-th round of training.

[0071] It should be noted that, in this embodiment, during the t-th round of training in federated learning, each client participating in federated learning downloads the global model w from the consensus node corresponding to the blockchain. t-1 You also need to download the corresponding first local model set. This is to approximate the second local model set. For example, if there are 3 clients participating in federated learning, i.e., N = 3, C = {1, 2, 3}, then for the first client, i.e., when i = 1, S = {{1}, {1, 2}, {1, 3}, {1, 2, 3}}, CS = {{2}, {3}, {2, 3}}. in, and It is a single local model uploaded by the second and third clients. It uses smart contracts to The aggregated model is obtained by aggregating these two local models.

[0072] When one or more local clients upload their trained local models to the consensus node of the blockchain, the consensus node first temporarily stores the uploaded local models. After all local clients have uploaded their trained local models, the smart contract is used to aggregate the models to obtain the global model, and the aggregated global model overwrites the previous global model.

[0073] It should be noted that a blockchain consensus node is a node that runs the blockchain. There can be multiple consensus nodes, and each local client only needs to communicate with one of them. The blockchain consensus node will reach a consensus on the workload with other consensus nodes through the consensus mechanism configured in the blockchain. In this embodiment, all parameters of the local model trained by each local client are treated as a single transaction.

[0074] In this embodiment, client i is responsible for training the local model, and its training objective is:

[0075]

[0076] In formula (1), F is the loss function to be optimized, which is generally the cross-entropy loss function. i Let X be the local training dataset possessed by client i, and w be the local model of the client. The purpose of this formula is to utilize the local training dataset X possessed by client i. i Train the local model w so that it minimizes the loss function.

[0077] In this embodiment, gradient descent is used to optimize formula (1), and the update formula for the local model is:

[0078]

[0079] Where η is the learning rate. The loss function F(w; X) represents the loss function. i The partial derivative with respect to the model parameter w.

[0080] After local model training is completed on the local client, model aggregation is required to consolidate client information. In a decentralized environment, this embodiment uses blockchain to achieve decentralized federated training and smart contracts to implement local model uploading and aggregation.

[0081] Please see Figure 3 The flowchart for client i training a local model is as follows: Figure 3 As shown:

[0082] 1) The client downloads the first global model obtained after aggregating all local models from the previous round via a smart contract;

[0083] 2) Use gradient descent to optimize formula (1), and the optimization rule is formula (2);

[0084] 3) Upload the trained local model w through a smart contract. The upload parameters include the client number i, the current round t, and the current model w.

[0085] 4) Jump to 1 until convergence.

[0086] When aggregating models, considering that smart contracts cannot perform high-precision floating-point operations, this embodiment uses a basic federated average. It is assumed that the model uploaded by client i is w. i Let the set of clients uploading models be C, and i∈C. Then, the model aggregation formula is:

[0087]

[0088] Among them, w t D is the second global model obtained after aggregation. i For the local training dataset owned by client number i, |D i | represents D i The number of samples in the sample.

[0089] In this embodiment, the corresponding second local model set is obtained by approximate estimation based on the trained local model and the first local model set. Specifically, the corresponding second local model set can be obtained by approximate estimation using formula (4).

[0090]

[0091] Where 1≤i≤N, N is the number of clients participating in federated learning, the client set C={1,2,…N}, S is any subset of C containing client i, and CS is the complement of subset S in C; This is the trained local model obtained by client i in the t-th training round; Let be the first local model set, representing any set of local models obtained in the (t-1)th round of training that does not include the models uploaded by client i; Let be the second local model set, representing the estimated model set of any set of local models uploaded by client i itself during the t-th round of training.

[0092] In step S200, after all clients upload the trained local models and the second local model set to the consensus node, the smart contract is used to aggregate all the trained local models to obtain the second global model, and to aggregate all the models in the second local model set to obtain the corresponding local model.

[0093] This embodiment measures the contribution of each client based on the Shapley value. The Shapley value, originating from game theory, can be used for contribution evaluation and benefit allocation in federated learning. Each client's contribution can be calculated using... To quantify it, the calculation formula is equation (5):

[0094]

[0095] in, Let K represent any set of clients other than client i, v(S) represent the utility of the model trained by the clients in set K, v(K∪{i})-v(K) represent the difference between the utility of the model trained with client i and the utility of the model trained without client i, |K| represents the size of set K, and ! represents the factorial operator.

[0096] It is understandable that K = CS.

[0097] As can be seen, v(K∪{i})-v(K) is the utility gain when participant i joins set K. Equation (5) can be rewritten as:

[0098]

[0099] In the formula, Represents the reciprocal of the combination number, i.e. ∪ represents the union of two sets.

[0100] According to equation (6), the Shapley value of participant i, i.e., client i, is actually the average of the marginal benefit gain of participant i when joining any subset that does not contain i. In this embodiment, the use of the Shapley value can effectively avoid the inconsistency in contribution calculation caused by clients joining the federated training process in different orders, thereby better evaluating the contribution of the clients.

[0101] Because client-side local datasets are heterogeneous, models trained on different local datasets exhibit varying generalization abilities. Therefore, a model trained on a client may perform well on its own dataset but poorly on other clients' datasets. Thus, this embodiment considers model generalization when evaluating client contributions in heterogeneous scenarios, viewing generalization as a positive characteristic, and models with good generalization should receive more incentives. Therefore, this embodiment employs a model generalization evaluation method specific to heterogeneous scenarios.

[0102] In this embodiment, the utility in equation (6) can be measured using model testing accuracy. Assume the set of participants before client i participates in learning is K, i.e. After adding client i to set K, model W K∪{i} and W K The difference in accuracy on the test set, g(i,K), serves as a quantitative indicator of the improvement in model generalization by client i, and its calculation formula is Equation (7):

[0103] g(i,K)=acc(W K∪{i} D test )-acc(W K D test (7)

[0104] In formula (7), W K To train a model using the local training datasets of clients in set K, acc(W) K D test (Model W) K In test dataset D test Accuracy on; W K∪{i} To add client i to set K, and then train the model using the local training dataset of the clients in K∪{i}, acc(W K D twst This indicates that model W was trained using only data from clients K. K In test dataset D test The accuracy on the acc(W) K∪{i} D test (Model W) K∪{i} In test dataset D test The accuracy on the test dataset D test It consists of the local test dataset D from all clients. i Together they form a whole.

[0105] Understandably, acc(W K∪{i} D test )-acc(W K D test ) is model W K∪{i} With model W K In test dataset D test The difference in accuracy, acc(W) K∪{i} D test )-acc(W K D test () is a quantitative indicator of the improvement in model generalization by client i in heterogeneous scenarios.

[0106] Considering that clients join the federated learning process in different orders, a Shapley value needs to be calculated to quantify generalization more fairly. That is, for client i, its improvement in generalization to any subset S of N{i} is calculated, and then the average value is calculated as its contribution, which is expressed by equation (8):

[0107]

[0108] From formula (8), it can be seen that in order to calculate the Shapley value, client i needs to participate in all W... s∪{i} For training, 2 needs to be maintained on the blockchain. |N| Having multiple models puts a significant strain on storage. Therefore, this embodiment proposes a multi-model coexistence strategy to avoid the pressure caused by multiple models.

[0109] To alleviate the storage pressure on the blockchain and avoid clients training multiple models, this embodiment proposes a multi-model coexistence strategy, ensuring that each client only participates in training one global model w. t+1 Then, the local model set is obtained by using the local model uploaded in the previous training round. Other local models can be approximated using equation (4). Then, the smart contract is invoked to perform model aggregation.

[0110] From the global model w and the local model w S As can be seen from the update process, their difference lies in the inconsistent starting point of optimization. For example, under normal circumstances, updating the global model w requires client i to update w. t Starting from this point, gradient descent is performed to update the result. w S Then it is necessary to start from Initially, training resulted in... Therefore, based on this observation, this embodiment uses an estimation method to estimate... This approximates the estimated value, thereby reducing the training pressure on the client. In the (t+1)th training round, each client i only needs to use w t As a starting point, local training yields... And use equation (4) to approximate estimate The value of .

[0111] Where S is any subset of N containing i. Let be the second local model set, representing the estimated model set of any set including the local models uploaded by client i during the t-th training round. On the blockchain, only maintenance is required. The model will be downloaded on the client side. Model and aggregated model w t Together, they are sent to the clients in set S. The client receives model w. t and After that, you only need to deal with w t To train and obtain Then, using formula (4), we obtain... The approximate value, client i will Uploaded to the consensus node, when all clients will... After all data is uploaded to the consensus node, it is then aggregated through a smart contract to obtain the corresponding local model.

[0112] It should be noted that only maintenance is required on the blockchain. The model will be downloaded on the client side. Model and aggregated model wt They are then distributed together to the clients in set S.

[0113] In step S300, the consensus node broadcasts the second global model and the local model to all clients. Each client uses its local test set and the preset first formula to verify the accuracy of each model and calculates the contribution value of each client based on the accuracy and the preset second formula.

[0114] Specifically, the consensus node will w t and The data is broadcast to all clients, and each client uses its local test set and a pre-defined first formula to verify the accuracy of each model. Based on the accuracy and a pre-defined second formula, the contribution value of each client is calculated.

[0115] Specifically, the first preset formula is shown in equation (9):

[0116]

[0117] Among them, acc(w,D test ) is model w in D test The accuracy on the test dataset D test It is the set of test datasets for all clients, w is the model broadcast by the consensus node to all clients, acc(w,D) i Model w in D i The accuracy rate on D i Let |D be the local test dataset for client i. i |For the local test dataset D i The number of samples in the sample.

[0118] In step S400, the incentive value that each client can obtain is determined according to the preset total incentive of federated learning and the contribution value, and incentives are allocated to each client according to the incentive value.

[0119] Specifically, determining the incentive value available to each client based on the preset total incentive and contribution value of federated learning includes: using formula (10) to determine the incentive value available to each client:

[0120]

[0121] in, Let u be the activation value obtained by client i in the t-th round of training. i (t) is the contribution value of client i in the t-th round of training, u k (t) represents the contribution value of client k in the t-th round of training, ∑ k∈C u k B(t) represents the sum of contributions from all clients in the t-th round of training, and B(t) represents the preset total incentive.

[0122] To ensure a more reasonable contribution calculation and to prevent it from being affected by the order in which clients join, this embodiment uses the Shapley value as the client's contribution.

[0123] In this embodiment, the blockchain-based federated learning incentive mechanism in a heterogeneous scenario is designed as follows: The incentive allocation contract designed in this embodiment is as follows:

[0124] 1) Initialization phase:

[0125] At this stage, the global model w needs to be initialized. 0 The initialization rule used in this embodiment is to randomly initialize the model parameters, and for any model in the model set W... Initialize it to w 0 ,Right now

[0126] 2) Model Download:

[0127] When the client needs to perform the (t+1)th round of training, download the global model w from the client. t as well as in, This represents the set of models obtained by excluding the model uploaded by the i-th client. For example, when N=3 and C={0,1,2}, Then use local data to perform w t The training is performed, and each aggregation model is updated using formula (4), thereby updating... A new set of aggregation models is obtained.

[0128] 3) Model aggregation:

[0129] After a client uploads a model, the model is temporarily stored. Once all clients have successfully uploaded their trained local models, the models are aggregated according to formula (3), the second global model is updated, and w is obtained. t+1 and using the received Update all models stored by the blockchain consensus nodes.

[0130] 4) Profit Calculation:

[0131] Since calculating revenue requires determining the model's accuracy, this solution broadcasts the second global model and local models to all clients. Clients then validate the models using local test data and upload their accuracy information. For a given model, the accuracy calculation formula is:

[0132]

[0133] After obtaining the accuracy information of each model, the contribution of each client will be calculated using formula (8), and incentives will be allocated according to the contribution using formula (10).

[0134] This example provides a blockchain-based federated learning incentive allocation method. To attract more clients with heterogeneous data to join the federated learning process and improve model generalization, the method uses the client's contribution to model generalization as the evaluation standard. To eliminate the impact of clients joining the federation in different orders, the Shapley value of each client is calculated as the final quantified contribution. To avoid retraining the model when calculating the Shapley value, this embodiment proposes a multi-model coexistence strategy, using existing models to derive other models. This embodiment utilizes blockchain technology to implement a decentralized federated learning framework, avoiding a series of problems caused by centralized servers in traditional federated learning. Using blockchain avoids the problem of single points of failure on the server side. When a consensus node on the blockchain fails, the client can communicate with other master nodes without affecting the entire model training process, thereby enhancing scalability and security.

[0135] The blockchain-based federated learning incentive allocation method provided by this invention, compared to traditional decentralized federated learning systems, significantly reduces client communication overhead because decentralization is achieved through the blockchain. Clients only need to send their local models to blockchain nodes using smart contracts, eliminating the need for direct communication with other clients. This embodiment introduces a contribution measurement mechanism based on Shapley values, which accurately estimates each client's contribution to the model in heterogeneous environments and allocates incentives based on these contributions. This attracts clients to actively participate in federated model training, improving model performance.

[0136] This example provides a blockchain-based federated learning incentive allocation method. Each client uses its local training dataset to train the previous round's global model, obtaining a trained local model which is then uploaded to the consensus node. Clients do not need to communicate directly with other clients, significantly reducing communication overhead. This invention uses the client's improvement in model generalization as the contribution evaluation standard. In heterogeneous environments, it can accurately estimate each client's contribution to the model and fairly allocate incentives based on client contributions. This allows for the inclusion of more clients with heterogeneous data in federated model training, thereby improving the model's generalization and robustness. This invention derives a second local model set based on the trained local model and existing models. Therefore, when measuring the contribution value of each client, it is not necessary to retrain the model, and it can eliminate the influence of clients joining the federated learning in different orders, greatly improving the efficiency and accuracy of model training.

[0137] This example provides a blockchain-based federated learning incentive allocation method that utilizes blockchain for decentralized federated learning. This ensures secure training, open participation, fair allocation, and privacy protection in the federated learning incentive mechanism. It avoids the risks caused by single-point server failures in traditional federated learning, improves the reliability and stability of the model training process, and enhances the security and scalability of federated learning.

[0138] Please see Figure 4 The present invention also provides an embodiment of a blockchain-based federated learning incentive allocation device, comprising:

[0139] The model download and update module 11 is used for each client participating in federated learning to download the first global model and the corresponding first local model set from the consensus node of the blockchain. Each client trains the first global model using the local training dataset to obtain a trained local model, performs an approximate estimation based on the trained local model and the first local model set to obtain the corresponding second local model set, and uploads the trained local model and the second local model set to the consensus node.

[0140] The first global model is obtained by aggregating all trained local models uploaded by clients in the previous training round, the first local model set is any set of local models not uploaded by clients in the previous training round, and the second local model set is an estimated model set of any set of local models uploaded by clients in the current training round.

[0141] The model aggregation module 22 is used to aggregate all the trained local models to obtain the second global model and aggregate all the models in the second local model set to obtain the corresponding local model after all clients upload the trained local model and the second local model set to the consensus node using a smart contract.

[0142] The contribution value determination module 33 is used for the consensus node to broadcast the second global model and the local model to all clients. Each client uses a local test set and a preset first formula to verify the accuracy of each model. The contribution value of each client is calculated based on the accuracy and the preset second formula. The contribution value can reflect the client's improvement of the model's generalization in heterogeneous scenarios.

[0143] The incentive determination and allocation module 44 is used to calculate the incentive value corresponding to each client based on the preset total incentive of federated learning and the contribution value, and to allocate incentives to each client based on the incentive value.

[0144] This example provides a blockchain-based federated learning incentive allocation device. Each client uses its local training dataset to train the previous round of the global model, obtaining a trained local model which is then uploaded to the consensus node. Clients do not need to communicate directly with other clients, significantly reducing communication overhead. This invention uses the client's improvement in model generalization as the contribution evaluation standard. In heterogeneous environments, it can accurately estimate each client's contribution to the model and fairly allocate incentives based on client contributions. This allows for the inclusion of more clients with heterogeneous data in federated model training, thereby improving the model's generalization and robustness. This invention derives a second local model set based on the trained local model and existing models. Therefore, when measuring the contribution value of each client, it is not necessary to retrain the model, and it can eliminate the influence of clients joining the federated learning in different orders, greatly improving the efficiency and accuracy of model training.

[0145] The blockchain-based federated learning incentive allocation device provided in this example utilizes blockchain for decentralized federated learning, ensuring secure training, open participation, fair allocation, and privacy protection in the federated learning incentive mechanism. It can avoid the risks caused by single-point server failures in traditional federated learning, improve the reliability and stability of the model training process, and enhance the security and scalability of federated learning.

[0146] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0147] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between devices or units through some interfaces, and may be electrical, mechanical, or other forms.

[0148] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0149] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0150] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0151] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A blockchain-based federated learning incentive allocation method, characterized in that, include: Each client participating in federated learning downloads the first global model and the corresponding first local model set from the consensus node of the blockchain. Each client trains the first global model using the local training dataset to obtain a trained local model. Based on the trained local model and the first local model set, an approximate estimate is made to obtain the corresponding second local model set. The trained local model and the second local model set are then uploaded to the consensus node. The first global model is obtained by aggregating all trained local models uploaded by clients in the previous training round, the first local model set is any set of local models not uploaded by clients themselves in the previous training round, and the second local model set is the estimated model set of any set of local models uploaded by clients themselves in the current training round. After all clients upload the trained local models and the second local model set to the consensus node, the smart contract is used to aggregate all the trained local models to obtain the second global model, and to aggregate all the models in the second local model set to obtain the corresponding local model. The consensus node broadcasts the second global model and the local model to all clients. Each client uses a local test set and a preset first formula to verify the accuracy of each model. Based on the accuracy and the preset second formula, the contribution value of each client is calculated. The contribution value can reflect the improvement of the client's generalization of the model in heterogeneous scenarios. The incentive value for each client is calculated based on the preset total incentive of federated learning and the contribution value, and the incentive is allocated to each client based on the incentive value. The preset first formula is: ; in, For the model exist Accuracy on the test dataset It is a collection of test datasets from all clients. It is a model where consensus nodes broadcast to all clients. Model exist The accuracy rate For client i's local test dataset, For local test dataset The number of samples in the sample; The preset second formula is: ; in, Let i be the contribution of client i in the t-th round of training. Let i be the set of clients excluding client i. Let set K be a set a subset of Let K be the number of clients contained in set K, and ! denotes a factorial element. To train a model using the local training datasets of clients in set K, For the model In the test dataset The accuracy rate To add client i to set K in the model, For the model In the test dataset The accuracy rate For the model With model In the test dataset The difference in accuracy.

2. The blockchain-based federated learning incentive allocation method according to claim 1, characterized in that, The second local model set is obtained by approximating the trained local model and the first local model set, including: use Approximate estimation is performed to obtain the corresponding second local model set; Where 1≤i≤N, N is the number of clients participating in federated learning, and the client set is... ={1,2,…N}, where S is any subset of C containing client i, and CS is the complement of subset S in C; This is the trained local model obtained by client i in the t-th training round; Let be the first local model set, representing any set of local models obtained in the (t-1)th round of training that does not include the models uploaded by client i; Let be the second local model set, representing the estimated model set of any set of local models uploaded by client i itself during the t-th round of training.

3. The blockchain-based federated learning incentive allocation method according to claim 1, characterized in that, The second global model is obtained by aggregating all the trained local models using smart contracts, including: Smart contract utilization All trained local models are aggregated to obtain the second global model; in, This is the second global model. Let C be the trained local model uploaded by client i in the t-th training round, and let C be the set of clients that upload local models in federated learning. The local training dataset owned by client i. For dataset The number of samples in the sample.

4. The blockchain-based federated learning incentive allocation method according to claim 1, characterized in that, This is a quantitative indicator of the improvement in model generalization by client i in heterogeneous scenarios.

5. The blockchain-based federated learning incentive allocation method according to claim 1, characterized in that, The incentive value for each client is calculated based on the preset total incentive for federated learning and the contribution value, including: Using formula Determine the incentive value available to each client; in, Let be the activation value obtained by client i in the t-th round of training. The contribution of client i in the t-th round of training. Let k be the contribution value of client k in the t-th round of training. The sum of the contributions of all clients in the t-th round of training. This is the preset total incentive.

6. The blockchain-based federated learning incentive allocation method according to claim 1, characterized in that, The contribution of each client is measured based on the Shapley value.

7. A blockchain-based federated learning incentive allocation device, characterized in that, include: The model download and update module is used for each client participating in federated learning to download the first global model and the corresponding first local model set from the consensus node of the blockchain. Each client trains the first global model using the local training dataset to obtain a trained local model. Based on the trained local model and the first local model set, an approximate estimate is made to obtain the corresponding second local model set. The trained local model and the second local model set are then uploaded to the consensus node. The first global model is obtained by aggregating all trained local models uploaded by clients in the previous training round, the first local model set is any set of local models not uploaded by clients themselves in the previous training round, and the second local model set is the estimated model set of any set of local models uploaded by clients themselves in the current training round. The model aggregation module is used to aggregate all the trained local models to obtain the second global model and aggregate all the models in the second local model set to obtain the corresponding local model after all clients upload the trained local model and the second local model set to the consensus node using a smart contract. The contribution value determination module is used by the consensus node to broadcast the second global model and the local model to all clients. Each client uses a local test set and a preset first formula to verify the accuracy of each model. The contribution value of each client is calculated based on the accuracy and the preset second formula. The contribution value can reflect the improvement of the client's generalization of the model in heterogeneous scenarios. The incentive determination and allocation module is used to calculate the incentive value corresponding to each client based on the preset total incentive of federated learning and the contribution value, and to allocate incentives to each client based on the incentive value; The preset first formula is: ; in, For the model exist Accuracy on the test dataset It is a collection of test datasets from all clients. It is a model where consensus nodes broadcast to all clients. Model exist The accuracy rate For client i's local test dataset, For local test dataset The number of samples in the sample; The preset second formula is: ; in, Let i be the contribution of client i in the t-th round of training. Let i be the set of clients excluding client i. Let set K be a set a subset of Let K be the number of clients contained in set K, and ! denotes a factorial element. To train a model using the local training datasets of clients in set K, For the model In the test dataset The accuracy rate To add client i to set K in the model, For the model In the test dataset The accuracy rate For the model With model In the test dataset The difference in accuracy.

8. The blockchain-based federated learning incentive allocation device according to claim 7, characterized in that, The model download and update module performs approximate estimation based on the trained local model and the first local model set to obtain the corresponding second local model set, including: The model download and update module utilizes Approximate estimation is performed to obtain the corresponding second local model set; Where 1≤i≤N, N is the number of clients participating in federated learning, and the client set is... ={1,2,…N}, where S is any subset of C containing client i, and CS is the complement of subset S in C; This is the trained local model obtained by client i in the t-th training round; Let be the first local model set, representing any set of local models obtained in the (t-1)th round of training that does not include the models uploaded by client i; Let be the second local model set, representing the estimated model set of any set of local models uploaded by client i itself during the t-th round of training.

Citation Information

Patent Citations

  • Fair and trusted federal learning method based on block chain

    CN115640305A