A Blockchain-Enabled Asynchronous Federated Learning Method
Through the asynchronous federated learning method empowered by blockchain, the problems of uneven computing power among nodes and insufficient attack resistance in traditional synchronous federated learning are solved, and efficient resource utilization and information transmission are achieved.
Patent Information
- Application Number
- CN202111182862.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-11
- Publication Date
- 2025-06-17
- Estimated Expiration
- 2041-10-11
AI Technical Summary
In traditional synchronous federated learning, uneven computing power among nodes leads to waste of resources from high computing power nodes, and due to frequent data interactions and the exposure of central servers, its attack resistance is weak.
The asynchronous federated learning method empowered by blockchain is adopted to share training tasks through the primary and secondary nodes, and the distributed storage and consensus mechanism of blockchain is used to ensure the reliability of data transmission and the ability to resist attacks. The secondary node can undergo multiple local training, while the primary node can continue to conduct local training while waiting for the secondary node model to update to make full use of resources.
It effectively avoids resource waste, improves the system's ability to resist attacks, and avoids blockchain forking risks through reputation value mechanisms, ensuring the security and reliability of information transmission.
Smart Images

Figure CN113902127B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of communication technology and relates to an asynchronous federated learning method enabled by blockchain. Background Art
[0002] Thanks to the rapid development of machine learning, algorithms can discover "patterns and insights" that may be very complex for humans from the data accumulated in business processes faster and more accurately than humans. However, one of the important conditions that determines whether a learning algorithm is accurate and efficient is whether the amount of training data is sufficient. In order to complete a complex learning task, it is often necessary for multiple parties to collaborate to build a model, and the confidentiality of the data cannot be guaranteed.
[0003] Federated learning enables collaborative model learning without sharing raw data, and is increasingly attracting the attention of technology giants and industries that require privacy protection. Data is located at multiple data owners, and the overlap of public entities between data is high while the overlap of features is low. This is called vertically distributed data. Due to conflicts of interest between data owners or legal and regulatory restrictions, data cannot be shared directly. For example, multiple financial institutions (banks, e-commerce companies, and insurance companies, etc.) provide different services to customers and have different aspects of customer data, but the customer groups they serve have a large overlap. Since the raw data between customers is not interacted, FL protects the privacy of users and decouples the machine learning process of data collection, training, and model storage to a central server.
[0004] Although federated learning can solve the data privacy problem between data owners, its anti-attack ability faces great challenges due to the frequent interaction between data and the exposure of central servers. The immutability brought by distributed storage in blockchain technology and malicious node identification technology can well solve the problems of data reliability transmission and resistance to malicious attacks. Federated learning, as a distributed learning architecture, can provide a good foundation for the integration of blockchain technology.
[0005] In view of the waste of high-computing-power node resources caused by uneven computing power among nodes in traditional synchronous federated learning, the present invention provides an asynchronous global aggregation method, in which the high-computing-power nodes at the secondary node end can perform local training multiple times, and the main node can continue local training while waiting for the local model of the secondary node, thereby making full use of effective resources. Summary of the invention
[0006] In view of this, the object of the present invention is to provide an asynchronous federated learning method enabled by blockchain.
[0007] In order to achieve the above object, the present invention provides the following technical solutions:
[0008] First, according to the data requirements of nodes for other nodes in the network and the requirements for data security during transmission, the present invention provides an asynchronous federated learning method empowered by blockchain. The execution process of this method is as follows:
[0009] S1: The primary node in the network serves as the task initiator, and other secondary nodes are task collaborators. The primary node uploads the latest global model to the blockchain network, and the secondary nodes download the global model from the blockchain network for local update;
[0010] S2: After completing the local update, the secondary nodes send status query information to the status server to determine whether to continue local training;
[0011] S3: When the secondary nodes enter the consensus process, the secondary node with the highest reputation value in the previous round of iteration serves as the leader. The secondary nodes perform cross-validation to determine the correctness of the locally updated model, thereby reaching a consensus;
[0012] S4: Based on step S3, the secondary nodes calculate their own reputation values according to the information of the other secondary nodes they obtain, and send them to the leader. The leader collects the model updates and reputation value information of all secondary nodes, and packs and uploads them to the blockchain network;
[0013] S5: After receiving the model updates from the secondary nodes, the coordinator sends a message to the primary node to notify the primary node to perform a global aggregation operation;
[0014] S6: The primary node aggregates the updated models of the secondary nodes received with the local model, and packs and uploads the aggregated global model and the reputation values of the secondary nodes to the blockchain network.
[0015] Second, in step S1, the network nodes are divided into primary nodes and secondary nodes according to their roles in the task. There is only one primary node in the network, and the rest of the nodes are secondary nodes. The primary node contains some data features and labels required for task training, and the secondary nodes only have some data features available for training. In the task initialization stage, the primary node and the secondary nodes will first use the homomorphic encryption algorithm to exchange the data features they need for local model update. After the primary node uploads the aggregated global model to the blockchain network, it performs local model update until it receives the global aggregation signal sent by the coordinator.
[0016] Third, in step S2, a semi-asynchronous local model update method is provided. The secondary node k sends a query message with its current state (k, i k , r k , c k , t k ) to the status server. The status response message will guide the secondary node k to perform the corresponding operation ak. If ak If = 1, the secondary node k enters the next round of local iteration and continues local training. Otherwise, the secondary node k will receive a k = 0, thereby minimizing the overall waiting time, that is, the idle time d of all secondary nodes wait . At this time, the remaining idle time of the secondary node k is not enough for the next local iteration, otherwise the overall waiting time d wait will increase. Therefore, the secondary node k should immediately enter the consensus process. Where k represents the secondary node k, i k represents the local iteration count, r k represents the round count, c k represents the computation time of the local iteration and the timestamp t k (timestamp) when sending the message.
[0017] Fourth, in step S3, a PBFT-based consensus algorithm is provided. In the first round of training for each task, a leader is randomly selected, and in subsequent training, the node with the highest reputation value in the previous round of training acts as the leader.
[0018] Fifth, in step S4, a consensus-based reputation value update method is provided. Based on all the secondary node information obtained in the consensus phase (including the local updated model, the number of local iterations, and the reputation value in the previous round), the node reputation value R is calculated, and R is a real number from 0 to 100. The entropy weight method is used to update the reputation value. Assuming there are K secondary nodes, represents the normalized value of the i-th index of the secondary node k, and we can get The proportion of is:
[0019]
[0020] Among them, i = 1 represents the reputation value of the secondary node k in the previous round, and i = 2 represents the number of local iterations ik in the secondary node k. And is normalized using a positive index, that is, the higher its value, the better. Its calculation formula is:
[0021]
[0022] i = 3 represents the similarity between the local model of the secondary node k and the local models of the other secondary nodes . The cosine similarity is used to represent the similarity between models, which can be expressed as:
[0023]
[0024] Negative indicators are used for standardization, that is, the lower the value, the better. The calculation formula is as follows:
[0025]
[0026] Therefore, the entropy weight value of index i is:
[0027]
[0028] Among them, The larger the entropy weight value of the index, the greater the contribution of the index to the reputation value of node k.
[0029] Therefore, the reputation value (full score 100) of node k can be obtained as:
[0030]
[0031] Step 6: In step S5, a global model asynchronous aggregation method is provided. After the master node uploads the latest global model to the blockchain network, it starts local training and waits for the aggregation message from the coordinator. After the coordinator receives the packaged block from the secondary node, it sends an aggregation message to the master node. The master node downloads the secondary node information and aggregates the local model with the downloaded model. The aggregation formula is:
[0032]
[0033] Among them,
[0034] Step 7: In step S6, the master node uploads the aggregated global model to the blockchain network for the secondary node to download, and starts a new round of local training until the model update of the next secondary node is completed.
[0035] The beneficial effects of the present invention are as follows: The present invention designs an asynchronous federated learning method empowered by blockchain. In this method, the master node and the secondary node are responsible for different stages of the training task, and jointly maintain a public blockchain to ensure the reliability of information transmission and the anti-attack ability of the overall system. In addition, the leader selection of this solution is based on the reputation value, and there is only one leader in one consensus, effectively avoiding the fork risk of block upload.
[0036] Other advantages, objectives, and features of the present invention will be described to some extent in the subsequent specification, and to some extent, will be obvious to those skilled in the art based on the study of the following text, or can be taught from the practice of the present invention. The objectives and other advantages of the present invention can be achieved and obtained through the following specification. Description of the Drawings
[0037] To make the objectives, technical solutions and advantages of the present invention more clear, the present invention will be described in detail preferably with reference to the accompanying drawings, where:
[0038] Figure 1 It is a schematic structural diagram of the method according to an embodiment of the present invention;
[0039] Figure 2 It is a schematic diagram of the data within a blockchain block in an embodiment of the present invention;
[0040] Figure 3 It is a schematic flow diagram provided by an embodiment of the present invention. Specific Embodiments
[0041] The following uses specific specific examples to illustrate the embodiments of the present invention. Those skilled in the art can easily understand other advantages and effects of the present invention from the content disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments. The details in this specification can also be modified or changed based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the diagrams provided in the following embodiments only illustrate the basic concept of the present invention in a schematic manner. Without conflict, the following embodiments and the features in the embodiments can be combined with each other.
[0042] Among them, the accompanying drawings are only for illustrative purposes, showing only schematic diagrams, not physical diagrams, and cannot be understood as a limitation to the present invention; in order to better illustrate the embodiments of the present invention, some components in the accompanying drawings will be omitted, enlarged or reduced, and do not represent the dimensions of actual products; for those skilled in the art, it is understandable that some well-known structures and their descriptions in the accompanying drawings may be omitted.
[0043] In the accompanying drawings of the embodiments of the present invention, the same or similar reference numerals correspond to the same or similar components; in the description of the present invention, it should be understood that if there are terms such as "upper", "lower", "left", "right", "front", "rear", etc. indicating the orientation or positional relationship, they are based on the orientation or positional relationship shown in the accompanying drawings. It is only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, the terms describing the positional relationship in the accompanying drawings are only for illustrative purposes and cannot be understood as a limitation to the present invention. For those of ordinary skill in the art, the specific meanings of the above terms can be understood according to specific circumstances.
[0044] Figure 1 Shows a possible application scenario of the structure involved in the embodiments of the present invention. As Figure 1As shown, the nodes in this network are divided into primary nodes and secondary nodes. The primary node is a single institutional node, which is the task initiator and plays a leading role in the task. The secondary nodes consist of multiple institutional nodes and provide modeling assistance to the task initiator. There may be malicious nodes among the secondary nodes, and the screening of malicious nodes is determined by the reputation value. Institutional nodes with a reputation value lower than the threshold will be excluded in the next round of iteration. In addition, all institutions jointly maintain a blockchain network, and model updates and reputation value updates will be recorded in block transactions to ensure information security and immutability.
[0045] 1. Computational Model
[0046] The time required for institution k to complete local training is:
[0047]
[0048] where c k represents the number of CPU cycles required to train a data sample in institution k; D k represents the number of data samples in the local dataset of institution k; represents the CPU cycle frequency that institution k can provide. Since the size of the data samples (x, y) after sample alignment operation is the same, the number of CPU cycles required for institution k to train the local model can be expressed as c k D k The CPU energy consumption of institution k in one iteration of training is:
[0049]
[0050] where β is the effective capacitance coefficient of the computer group chips of institution k.
[0051] 2. Communication Model
[0052] In this network scenario, two communication overheads are considered, including the time overhead of secondary node consensus and the leader uploading the block.
[0053] Blockchain consensus is divided into two parts: block propagation and block verification.
[0054] In the block propagation stage, the leader broadcasts the block to the remaining secondary nodes. If institution k is the leader, its data transmission rate (bits / s) can be expressed using the Shannon formula:
[0055]
[0056] where B represents the bandwidth, p k represents the transmission power of institution k, h k→k' represents the channel gain from institution k to another secondary node, and n0 represents the noise power. Thus, in the cross-validation stage, the block propagation delay of institution k is:
[0057]
[0058] where δ b is the block size.
[0059] In the block verification stage, each institution confirms the content of the block broadcast by the leader, and the confirmation delay can be expressed as:
[0060]
[0061] where represents the number of CPU cycles required for block verification, represents the computing frequency of the secondary node k' for verifying the block.
[0062] The delay for the leader to upload the block can be expressed as:
[0063]
[0064] where s k→p represents the transmission rate from institution k to the master node.
[0065] Then, the energy consumption of leader k for uploading the block is:
[0066]
[0067] 3. Election of the Leader
[0068] To determine the leader in the consensus stage and screen out malicious nodes, the present invention uses the reputation value of the institution to represent its credibility, and the reputation value ranges from 0 to 100. The higher the reputation value of the institution, the higher its credibility. Therefore, having the institution with the highest credibility as the leader can ensure the relative credibility of the result. According to the level of the reputation value, the trust status can be classified as follows:
[0069] Great: R ∈ (ν, 100], the institutional nodes in this state are candidate leader nodes, and the priorities are arranged from high to low according to the scores;
[0070] Average: R ∈ (μ, ν], the institutional nodes in this state are ordinary nodes, responsible for local update and cross-verification, and do not participate in the leader election;
[0071] Poor: R ∈ (0, μ], the institutional nodes in this state are determined to be malicious nodes and will be removed from the task training queue.
[0072] According to the reputation value among the candidate leader nodes, the probability that institution k is elected as the leader is as follows:
[0073]
[0074] 4. Intra-block Data
[0075] Figure 2 The figure shows a schematic diagram of the data within a blockchain block in an embodiment of the present invention. The block packaging method is divided into two types. First, the primary node is responsible for packaging and uploading the block, and the transaction content includes the global model and the reputation value of the secondary nodes. Second, the leader in the secondary nodes packages and uploads the blockchain, and the transaction content includes the local model update and the reputation value of the secondary nodes. The blockchain consists of two types of blocks alternating in a cycle, and all institutions (including the primary node) jointly maintain this blockchain.
[0076] 5. Optimization Objective Modeling
[0077] The present invention proposes an asynchronous federated learning method empowered by blockchain. To minimize the total delay, including the local model update delay of the secondary nodes, the consensus delay, and the leader block upload delay, the optimization function can be expressed as:
[0078]
[0079] Among them, the constraint condition C1 means that the computing resources allocated for model calculation and block verification cannot exceed the effective resources of the node; the constraint condition C2 means that the block confirmation time cannot exceed the maximum tolerable delay; the constraint condition C3 is the node transmission power constraint; the constraint condition C4 means the computing resource limit; the constraint conditions C5 and C6 mean the power consumption limits for local model update and block confirmation.
[0080] 6. Flowchart of Asynchronous Federated Learning Empowered by Blockchain
[0081] Figure 3 The figure shows the flowchart of the asynchronous federated learning empowered by blockchain proposed by the present invention, and its specific steps are as follows:
[0082] S301: System initialization;
[0083] S302: The primary node aligns samples with the secondary nodes;
[0084] S303: The primary node uploads the global model and starts local training;
[0085] S304: The secondary nodes download the global model;
[0086] S305: The secondary nodes use local data for model training;
[0087] S306: After the secondary nodes complete one round of local iteration, they send a query to the status server and request the next action. If the returned action information is 0, they enter the consensus stage. If the returned action information is 1, they repeat step S305;
[0088] S307: The secondary node with the highest reputation value in the previous round serves as the leader;
[0089] S308 - S311: The secondary nodes reach a consensus;
[0090] S308: Pre - prepare;
[0091] S309: Prepare;
[0092] S310: Commit;
[0093] S311: Reply;
[0094] S312: Determine the consensus result. If the number of consistent votes exceeds 2 / 3, proceed to the next step; otherwise, enter the view replacement process and repeat step S308;
[0095] S313: The secondary nodes update their respective reputation values using formula (6) based on the information of other institutional nodes received during the consensus phase;
[0096] S314: The leader collects the reputation values of all secondary nodes, packages them together with the model update to generate a block, and uploads it to the blockchain;
[0097] S315: After receiving the upload data from the secondary nodes, the status server sends a global aggregation message to the primary node, notifying the primary node to prepare for the aggregation operation;
[0098] S316: The primary node downloads the data information of the secondary nodes from the blockchain and aggregates the model update therein with its own local update;
[0099] S317: Determine whether the global model converges. If it converges, proceed to the next step; otherwise, repeat step S303;
[0100] S318: The operation ends.
[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit. Although the present invention has been described in detail with reference to the preferred embodiments, those of ordinary skill in the art should understand that the technical solutions of the present invention can be modified or equivalently replaced without departing from the purpose and scope of the present technical solution, and they should all be covered within the scope of the claims of the present invention.
Claims
1. A blockchain - empowered asynchronous federated learning method, characterized in that: The method includes the following steps: S1: The primary node in the network acts as the task initiator, and other secondary nodes are task collaborators. The primary node uploads the latest global model to the blockchain network, and the secondary nodes download the global model from the blockchain network for local update; S2: After completing the local update, the secondary nodes send status query information to the status server to determine whether to continue local training; S3: When the secondary nodes enter the consensus process, the secondary node with the highest reputation value in the previous round of iteration serves as the leader. The secondary nodes perform cross-validation to determine the correctness of the locally updated model, thereby reaching a consensus; S4: Based on S3, the secondary nodes calculate their own reputation values according to the information of the other secondary nodes they obtain, and send them to the leader. The leader collects the model updates and reputation value information of all secondary nodes, and packages and uploads them to the blockchain network; S5: After receiving the model update from the secondary nodes, the coordinator sends a message to the primary node to notify the primary node to perform a global aggregation operation; S6: The primary node aggregates the updated models of the secondary nodes received with the local model, and packages and uploads the aggregated global model and the secondary node reputation values to the blockchain network.
2. The blockchain - empowered asynchronous federated learning method according to claim 1, characterized in that: In S1, there is only one primary node, and the rest of the nodes are secondary nodes; the primary node contains some data features and labels required for task training, and the secondary nodes only have some data features available for training; In the task initialization stage, the primary node and the secondary nodes will first use the homomorphic encryption algorithm to exchange the data features they need for local model update; after the primary node uploads the aggregated global model to the blockchain network, it performs local model update until it receives the global aggregation signal sent by the coordinator.
3. The blockchain - empowered asynchronous federated learning method according to claim 2, characterized in that: In S2, the secondary node k sends a query message with its current status to the status server; the status response message will guide the secondary node k to perform the corresponding operation ak; the secondary node k decides whether to continue local training or enter the consensus process according to the operation instruction.
4. The blockchain - empowered asynchronous federated learning method according to claim 3, characterized in that: In S3, in the first round of training of each task, a leader is randomly selected, and in subsequent training, the node with the highest reputation value in the previous round of training serves as the leader.
5. The blockchain - empowered asynchronous federated learning method according to claim 4, characterized in that: In S4, based on all the secondary node information obtained in the consensus stage, including the locally updated model, the local iteration times, and the reputation value of the previous round; the entropy weight method is used to calculate the node reputation value R, and R is a real number between 0 and 100.
6. The blockchain - empowered asynchronous federated learning method according to claim 5, characterized in that: In S5, after uploading the latest global model to the blockchain network, the primary node starts local training and waits for the aggregation message from the coordinator; after receiving the packaged block from the secondary nodes, the coordinator sends an aggregation message to the primary node. The primary node downloads the secondary node information and aggregates the local model with the downloaded model.
7. The blockchain - empowered asynchronous federated learning method according to claim 6, characterized in that: In S6, the primary node uploads the aggregated global model to the blockchain network for the secondary nodes to download, and starts a new round of local training until the model update of the next secondary node is completed.