A blockchain-based asynchronous federated learning method, system, device, and medium
By leveraging blockchain decentralization and asynchronous federated learning, the problems of data leakage and slow model convergence in federated learning are solved, enabling secure and efficient model training and credible contribution evaluation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- GRG BANKING EQUIPMENT CO LTD
- Filing Date
- 2022-01-20
- Publication Date
- 2026-07-31
AI Technical Summary
Existing federated learning systems pose a security risk of central data leakage, and the varying computational efficiency of nodes leads to slow model convergence, failing to fully leverage the advantages of asynchronous systems.
It adopts an asynchronous federated learning method based on blockchain, realizes decentralization through blockchain, uses the latency coefficient to reflect the model influence of different nodes, independently calculates the global model, detects and traces malicious nodes, and allows nodes to flexibly access training tasks.
This improves the security and efficiency of federated learning, prevents data leakage, makes full use of the computing power of each node, and achieves rapid model convergence and credible contribution incentive evaluation.
Smart Images

Figure CN114418133B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, and in particular to an asynchronous federated learning method, system, device and storage medium based on blockchain. Background Technology
[0002] Currently, existing federated learning systems typically require a central entity for model aggregation. This central entity needs to acquire the models trained by each node in each round of learning and training, and wait for all or most participating nodes to complete training before aggregating the models. However, this method of using a central entity for model aggregation risks inferring local data from the models. If nodes themselves or their communication in federated learning are attacked maliciously, there is a risk of local data leakage. Furthermore, the computational efficiency of nodes in the network varies. If there are nodes with insufficient computing power, a significant amount of time must be spent waiting for these nodes to complete their model training before model aggregation can begin, resulting in slow model convergence and significantly reducing the efficiency of federated learning.
[0003] To address the issues caused by centralized systems, existing technologies also employ blockchain to implement asynchronous federated learning. For example, patent document CN 112949868 A discloses "A Blockchain-Based Asynchronous Federated Learning Method, Device, and Electronic Equipment." This patent document describes a technical solution where, when multiple new models (referred to as "second global models") are trained using local data based on the same model (i.e., the "first global model"), the solution "selects a target global model from the multiple second global models according to the target conditions and stores the target global model as a new first global model in the blockchain." This means that unselected models are discarded, resulting in a loss of computing power and data, and failing to fully leverage the advantages of asynchronous systems. Summary of the Invention
[0004] To overcome the aforementioned technical problems, one of the objectives of this invention is to provide an asynchronous federated learning method based on blockchain.
[0005] The second objective of this invention is to provide an asynchronous federated learning system based on blockchain.
[0006] The third objective of this invention is to provide an electronic device.
[0007] The fourth objective of this invention is to provide a computer-readable storage medium.
[0008] One of the objectives of this invention is achieved through the following technical solution:
[0009] An asynchronous federated learning method based on blockchain includes:
[0010] Receive the original model uploaded by any blockchain node, mark the original model with a serial number with a value of 0, and save the original model and its corresponding serial number on the blockchain;
[0011] The participating nodes sequentially receive the original models with the sequence numbers on the blockchain, calculate the corresponding delay coefficients based on the sequence numbers, and aggregate the delay coefficients and the corresponding original models locally to calculate and obtain the global model.
[0012] The global model is trained using the local data of the participating nodes until a stopping condition is met, at which point the training task is stopped to obtain a local model. The sequence number corresponding to the local model is incremented, and the local model parameters and their corresponding sequence number are stored on the blockchain.
[0013] Furthermore, before the controlling participating node receives the original model with the sequence number on the blockchain, the process also includes:
[0014] The participating nodes are authenticated to ensure that each participating node is allowed to receive the model with the sequence number on the blockchain only after it has been authenticated.
[0015] Furthermore, the method for calculating and obtaining the global model is as follows:
[0016] X t ←(1-α t )X t-1 +α t x new ;
[0017] Among them, X t The global model represents the sequence number t; X t-1 The global model represents the sequence at index t-1; α t This represents the time delay coefficient, which is related to time; x new Represents X t-1 The model is a local model trained using local data.
[0018] Furthermore, the method for calculating the time delay coefficient is as follows:
[0019] α t ←α×f(t-τ);
[0020] f(t-τ)=(t-τ+1) -1 ;
[0021] Where, α trepresents the time delay coefficient, α represents the hyperparameter, with a value between (0,1), t-τ represents the difference between the latest index and the global model index used by the local model, and f() represents the time delay function.
[0022] Furthermore, the method for determining whether the stopping condition is met is as follows:
[0023] Determine whether the global model has converged during training; if it has converged, the stopping condition is met; or,
[0024] Determine if the execution time of the training task exceeds the preset time; if it does, the stopping condition is met; or...
[0025] Determine whether the number of blockchain nodes participating in training within a preset time is less than a preset value; if so, the stopping condition is met.
[0026] Furthermore, if it is determined that the execution time exceeds a preset time, or the number of blockchain nodes participating in training within the preset time is less than the preset value, a task failure message is generated and pushed.
[0027] Furthermore, when the stopping condition is met, the following is also included:
[0028] The system retrieves preset incentive policies and generates and pushes corresponding reward resources based on the participation status of each node recorded in the blockchain.
[0029] The second objective of this invention is achieved by the following technical solution:
[0030] A blockchain-based asynchronous federated learning system executes the blockchain-based asynchronous federated learning method described above, and the system is applied on a blockchain containing target nodes and participating nodes.
[0031] The target node is used to upload the original model according to the task requirements, mark the original model with a serial number with a value of 0, and store the original model and its corresponding serial number on the blockchain;
[0032] The participating node is used to receive the original model with the sequence number on the blockchain, calculate the corresponding latency coefficient according to the sequence number, and use the latency coefficient and the corresponding original model to aggregate locally to calculate a global model; train the global model using the local data of the current participating node to obtain a local model, increment the sequence number corresponding to the local model, and save the local model parameters and the corresponding sequence number on the blockchain until the current node's participation status meets the stopping condition before stopping the training task.
[0033] The third objective of this invention is achieved by the following technical solution:
[0034] An electronic device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a blockchain-based asynchronous federated learning method.
[0035] The fourth objective of this invention is achieved by the following technical solution:
[0036] A storage medium storing a computer program that, when executed, implements the aforementioned blockchain-based asynchronous federated learning method.
[0037] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0038] (1) This invention implements the federated learning process based on blockchain technology, realizes decentralized federated learning, and improves the security of the federated learning system;
[0039] (2) Asynchronous federated learning is used, and the impact of the model on the global model at different times is reflected by the time delay coefficient. This avoids the waiting and blocking of other nodes in the system, and can also solve the problem of slow model convergence caused by different training efficiencies of each node, thus improving the overall efficiency of federated learning.
[0040] (3) Record the model update history of each node to achieve traceability and provide a reliable contribution incentive evaluation mechanism for participating nodes. Attached Figure Description
[0041] Figure 1 This is a flowchart illustrating the asynchronous federated learning method based on blockchain of the present invention. Detailed Implementation
[0042] The present invention will now be further described in conjunction with the accompanying drawings and specific embodiments. It should be noted that, without conflict, the various embodiments or technical features described below can be arbitrarily combined to form new embodiments.
[0043] Existing federated learning systems often require a central entity to aggregate models. During this process, the central entity obtains the models from all nodes for each round, potentially allowing it to infer local data from the models, posing a security risk. Furthermore, due to varying training efficiencies among nodes, direct model aggregation requires waiting for all (or most) participating nodes to complete training in each round. If nodes in the network lack sufficient computing power, this can lead to slow model convergence, significantly reducing the efficiency of the federated learning system. In addition, existing blockchain-based asynchronous federated learning processes discard unselected models, failing to fully utilize the computing power of each node, resulting in some loss of computing power and data, and hindering the full realization of the advantages of asynchronous systems.
[0044] Based on the above-mentioned problems, this embodiment provides an asynchronous federated learning method based on blockchain. By utilizing blockchain to achieve decentralization, it ensures that information is not tampered with, can detect and trace malicious nodes, effectively prevents malicious attacks that may be suffered by the nodes themselves and during their communication in federated learning, improves security, and can also effectively utilize the computing power of each participating node to significantly improve the efficiency of federated learning.
[0045] like Figure 1 As shown, the asynchronous federated learning method based on blockchain in this embodiment specifically includes the following steps:
[0046] Step S1: Receive the original model uploaded by any blockchain node, assign a serial number with a value of 0 to the original model, and save the original model and its corresponding serial number on the blockchain;
[0047] Step S2: Control the participating nodes to sequentially receive the original models with the sequence number on the blockchain, calculate the corresponding delay coefficient according to the sequence number, and use the delay coefficient and the corresponding original model to aggregate locally to calculate and obtain the global model;
[0048] Step S3: Use the local data of the participating nodes to train the global model to obtain a local model, increment the sequence number corresponding to the local model, and save the local model parameters and the corresponding sequence number on the blockchain;
[0049] Step S4: Determine whether the participation status of the current node meets the stopping condition. If not, jump to step S2 to continue the training task. If it does meet the condition, stop the training task.
[0050] In this embodiment, the task initiator provides the original model through any blockchain node, including the model structure and model parameters, and stores the original model and its sequence number (set to 0) on the blockchain. Before a participating node receives the original model with a sequence number from the blockchain, its identity must be verified. Only when a participating node passes its authorization and identity verification can it obtain the original model with a sequence number from the blockchain, thereby improving system security and enabling traceability.
[0051] Participating nodes obtain the original model with an ordered sequence number from the chain, and calculate the corresponding delay coefficient based on the sequence number. The formula for calculating the delay coefficient is as follows:
[0052] α t ←α×f(t-τ);
[0053] f(t-τ)=(t-τ+1) -1 ;
[0054] In this formula, α t Let f(t) represent the time delay coefficient, α represent the hyperparameter (value between 0 and 1), and t-τ represent the difference between the latest index and the global model index used by the local model. f() represents the time delay function, which can be calculated using other functions that meet the following requirements: 1. When t = τ, f() = 1; 2. f() is always greater than 0; 3. As t-τ increases, f() monotonically decreases. Other functions could be: f(t-τ) = 2*(1+e^(-τ / t)). t-τ ) -1 .
[0055] After calculating the latency coefficient based on the sequence number, the participating nodes use the latency coefficient and the corresponding original model to aggregate locally to calculate the global model. The specific formula is as follows:
[0056] X t ←(1-α t )X t-1 +α t x new ;
[0057] Among them, X t The global model represents the sequence number t; X t-1 The global model represents the sequence at index t-1; α t This represents the time delay coefficient, which is related to time; x new Represents X t-1 The model is a local model trained using local data.
[0058] For example, the formula for calculating the global model X2 with index 2 from the global model X0 with index 0 is as follows:
[0059] X1←(1-α1)X0+α1x1
[0060] X2←(1-α2)X1+α2x2=(1-α1-α2+α1α2)X0+(α1-α1α2)x1+α2x2;
[0061] ...
[0062] Among them, the initialization model X0, and the local model x for each iteration. new The corresponding sequence number t is stored on the chain.
[0063] Participating nodes use local data to train the global model to obtain a local model. After training, the local model's index is incremented by one, and the model parameters and index corresponding to the new local model are stored on the blockchain.
[0064] When a new participating node is added, it is necessary to authorize and verify the identity of the new participating node before repeating steps S2 to S4 until the current node's participation status meets the stopping condition before the training task ends.
[0065] In this embodiment, the method for determining whether the current node's participation status meets the stopping condition includes:
[0066] a. Determine whether the global model mentioned above has converged during the training process. If it has converged, the stopping condition is met, and the training task is considered to have ended normally. At this time, the preset incentive policy can be retrieved, and the corresponding reward resources can be generated and pushed based on the participation status of each node recorded in the blockchain. For example, rewards can be distributed based on the number of times a node uploads its local model.
[0067] b. Determine if the execution time of the training task exceeds the preset time. If it does, the stop condition is met. If a timeout occurs, the training task fails. At this point, the task ends and a task failure message is generated and pushed to inform the user of the reason for the training failure.
[0068] c. Determine whether the number of blockchain nodes participating in training within a preset time is less than a preset value. If so, the stopping condition is met. If the number of participating nodes is too small, it can also be regarded as a task failure. At this time, the task ends and a task failure prompt message is generated and pushed to inform the user of the reason for the training failure.
[0069] When determining the stopping condition, if any of the above stopping conditions are met, the current training task is considered. If none of the above stopping conditions are met during the determination process, the task training in steps S2 to S4 continues to be executed in a loop.
[0070] Example 2
[0071] This embodiment provides a blockchain-based asynchronous federated learning system that executes the blockchain-based asynchronous federated learning method as described in Embodiment 1. The system is applied on a blockchain that includes target nodes and participating nodes.
[0072] The target node is used to upload the original model according to the task requirements, mark the original model with a serial number with a value of 0, and store the original model and its corresponding serial number on the blockchain;
[0073] The participating node is used to receive the original model with the sequence number on the blockchain, calculate the corresponding latency coefficient according to the sequence number, and use the latency coefficient and the corresponding original model to aggregate locally to calculate a global model; train the global model using the local data of the current participating node until the stopping condition is met to stop the training task and obtain a local model after training is completed, increment the sequence number corresponding to the local model, and save the local model parameters and the corresponding sequence number on the blockchain.
[0074] This embodiment utilizes blockchain technology to achieve decentralization, ensuring information integrity and enabling the detection and tracing of malicious nodes. This effectively prevents malicious attacks that may occur to nodes themselves and during their communication within federated learning. Decentralization means that each node independently calculates the latest global model using information stored on the chain. Global models calculated at the same time are identical. Therefore, a specific central node is not needed to provide model aggregation, thus avoiding problems caused by untrusted central parties. Ensuring information integrity means that all information required to update the model is stored on the chain. Due to the inherent characteristics of blockchain (modifying a large number of blocks is extremely costly, making it virtually impossible), data cannot be tampered with once published. The ability to detect and trace malicious nodes means that users / systems can use other means to detect model information on the chain and determine whether a node is malicious. A malicious node is a node with malicious attack behavior, aiming to intrude into, control, or even destroy the entire network, such as using noise as a local model to affect model convergence. Because every transaction record in the blockchain is bound to the transacting party's information, it can be completely recorded and traced, and cannot be destroyed or tampered with.
[0075] This embodiment employs asynchronous federated learning, allowing participating nodes to independently obtain the latest global model without waiting for a certain number of nodes to be ready before updating the model. This eliminates waiting time and prevents congestion. Another advantage of asynchronous federated learning is that it allows nodes to flexibly access training tasks, resulting in higher node utilization, and allows for flexible disconnection from training tasks without affecting other nodes. The latency coefficient α is used because different nodes have different computational efficiencies and model freshness, thus affecting the global model differently during aggregation. For example, if nodes A and B are both training on model f based on index t-1, node A, with its superior computing power and faster computation, will complete model f first. A Train and update the chain, and update the sequence number to t; at this time, node C is added, and model f is based on sequence number t. C Local training is performed, the model is trained, and the sequence number t+1 is updated on the blockchain; meanwhile, node B's training speed is slow, and it has just completed model f. B And update it on the chain, at which point model f B The sequence number is t; at this time, the sequence number t of node B is less than the latest sequence number t+1 on the chain, and it is regarded as an old node. During model aggregation, f B The weight should be less than f C The weighting is equivalent to setting a delay coefficient α, which makes the coefficient of older node models lower when merged in the global model. This effectively utilizes node devices with different computing efficiencies and fully leverages the advantages of asynchronous systems.
[0076] Example 3
[0077] This embodiment provides an electronic device, which includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the blockchain-based asynchronous federated learning method in Embodiment 1. In addition, this embodiment also provides a storage medium storing a computer program thereon. When the computer program is executed, it implements the above-mentioned blockchain-based asynchronous federated learning method.
[0078] The device and storage medium in this embodiment are two aspects of the method in the foregoing embodiments, based on the same inventive concept. The implementation process of the method has been described in detail above, so those skilled in the art can clearly understand the structure and implementation process of the device and storage medium in this embodiment based on the foregoing description. For the sake of brevity, it will not be described again here.
[0079] The above embodiments are merely preferred embodiments of the present invention and should not be construed as limiting the scope of protection of the present invention. Any non-substantial changes and substitutions made by those skilled in the art based on the present invention shall fall within the scope of protection claimed by the present invention.
Claims
1. A blockchain-based asynchronous federated learning method, characterized in that, include: Receive the original model uploaded by any blockchain node, mark the original model with a serial number with a value of 0, and save the original model and its corresponding serial number on the blockchain; The participating nodes sequentially receive the original model with the sequence number from the blockchain, and calculate the corresponding latency coefficient based on the sequence number. The latency coefficient is calculated using the following method: a t ← a x f(t - τ); f(t - τ) = (t - τ + 1) -1 ; Where, α t represents the time delay coefficient, α represents the hyperparameter, with a value between (0,1), t-τ represents the difference between the latest index and the global model index used by the local model; f() represents the time delay function; The global model is calculated locally using the aforementioned delay coefficients and the corresponding original model; wherein the method for calculating the global model is as follows: X t ←(1-α t )X t-1 +α t x new ; Among them, X t The global model represents the sequence number t; X t-1 Represents the global model at index t-1; α t This represents the time delay coefficient, which is related to time; x new Represents X t-1 The model is a local model trained using local data; The global model is trained using the local data of the participating nodes until a stopping condition is met, at which point the training task is stopped to obtain a local model. The sequence number corresponding to the local model is incremented, and the parameters of the local model and its corresponding sequence number are stored on the blockchain.
2. The blockchain-based asynchronous federated learning method of claim 1, wherein, Before controlling participating nodes to receive the original model with the serial number on the blockchain, the method further includes: authenticating participating nodes to ensure that each participating node is allowed to receive the model with the serial number on the blockchain only after it has been authenticated.
3. The blockchain-based asynchronous federated learning method of claim 1, wherein, The method for determining whether the stopping condition is met is as follows: determine whether the global model converges during the training process; if it converges, the stopping condition is met; or, determine whether the execution time of the training task exceeds a preset time; if it exceeds, the stopping condition is met; or, determine whether the number of blockchain nodes participating in the training within the preset time is less than a preset value; if so, the stopping condition is met.
4. The asynchronous federated learning method based on blockchain according to claim 3, characterized in that, If it is determined that the execution time exceeds a preset time, or the number of blockchain nodes participating in training within the preset time is less than the preset value, a task failure message is generated and pushed.
5. The blockchain-based asynchronous federated learning method of claim 1, wherein, When the stopping condition is met, the process also includes: retrieving a preset incentive policy, generating and pushing corresponding reward resources based on the participation status of each node recorded in the blockchain.
6. A blockchain-based asynchronous federated learning system, characterized in that, The asynchronous federated learning method based on blockchain as described in any one of claims 1 to 5 is applied on a blockchain containing target nodes and participating nodes. The target node is used to upload the original model according to the task requirements, mark the original model with a serial number with a value of 0, and store the original model and its corresponding serial number on the blockchain; The participating node is used to receive the original model with the sequence number on the blockchain, and calculate the corresponding latency coefficient according to the sequence number, wherein the latency coefficient is calculated as follows: a t ←α×f(t-τ); f(t - τ) = (t - τ + 1) -1 ; Where, α t represents the time delay coefficient, α represents the hyperparameter, with a value between (0,1), t-τ represents the difference between the latest index and the global model index used by the local model; f() represents the time delay function; The global model is calculated locally using the aforementioned delay coefficients and the corresponding original model; wherein the method for calculating the global model is as follows: X t ←(1-α t )X t-1 +α t x new ; Among them, X t The global model represents the sequence number t; X t-1 The global model represents the sequence at index t-1; α t This represents the time delay coefficient, which is related to time; x new Represents X t-1 The model is a local model trained using local data; The global model is trained using the local data of the participating nodes until a stopping condition is met, at which point the training task is stopped to obtain a local model. The sequence number corresponding to the local model is incremented, and the parameters of the local model and its corresponding sequence number are stored on the blockchain.
7. An electronic device, comprising: The computer program is stored on the memory and is executable on the processor, and the processor executes the computer program to implement the blockchain-based asynchronous federated learning method in any one of claims 1-5.
8. A storage medium, characterized by The computer program is stored on the memory and is executable on the processor, and the processor executes the computer program to implement the blockchain-based asynchronous federated learning method in any one of claims 1-5.