Multilayer asynchronous federated learning method and system based on block chain
By introducing the multi-layer asynchronous method of blockchain into federated learning, and using masks, differential privacy and security aggregation mechanisms, Byzantine attacks and privacy security issues in federated learning are solved, the robustness and efficiency of the system are improved, and the Problems of consensus and aggregation optimization in the existing technology.
Patent Information
- Application Number
- CN202410982773.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-07-22
AI Technical Summary
Existing blockchain-based federated learning frameworks face Byzantine attacks, privacy security, and consensus and aggregation optimization problems in practical engineering applications, especially system compatibility due to the inconsistency between the time requirements of synchronous federated learning and the blockchain consensus mechanism. Problems and low training efficiency.
It adopts a multi-layer asynchronous federated learning method based on the blockchain, protects local updates of training nodes through masks and differential privacy, prevents Byzantine attacks through a secure aggregation mechanism based on model accuracy, and uses a committee consensus mechanism to tolerate a certain number of malicious nodes. Improve system robustness.
It effectively prevents attacks from malicious nodes, ensures that privacy protection does not affect global model performance, improves the robustness and efficiency of federated learning, and reduces the impact of malicious server attacks.
Smart Images

Figure CN118569359A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of asynchronous federated learning protocols and communication security technologies, and in particular to a blockchain-based multi-layer asynchronous federated learning method, system, electronic device, non-transitory computer-readable storage medium, and computer program product. Background Art
[0002] Federated learning can solve the data island problem while protecting the privacy of user data in machine learning. Therefore, federated learning is widely used in scenarios such as transportation systems, the Internet of Things, and medical image generation, and solves problems in the corresponding scenarios; for example, in transportation system scenarios, such as real-time computing, traffic management, and vehicle resource allocation.
[0003] At present, the center-based federated learning still has problems such as single point failure, model pollution, and privacy leakage. Therefore, technicians use blockchain technology to improve the data privacy, data security, data credibility, and model training efficiency of federated learning. However, the existing blockchain-based federated learning framework with committee consensus mechanism still faces problems such as Byzantine attacks, privacy security, and consensus and aggregation optimization in actual engineering applications. Summary of the invention
[0004] The present invention provides a blockchain-based multi-layer asynchronous federated learning method, system, electronic device, non-transitory computer-readable storage medium, and computer program product to at least solve one of the defects in the prior art.
[0005] The present invention provides a multi-layer asynchronous federated learning method based on blockchain, comprising: In response to receiving the initialization configuration instruction, the task publisher is used to execute the blockchain, the interplanetary file system IPFS, the coordination server CS and the node initialization, and the smart contract SC is published to the blockchain and the interplanetary file system, and the system parameters and the initial global model are uploaded; wherein the node includes a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, and the plurality of training nodes are divided into a plurality of groups, and each group corresponds to one of the head nodes; For each group, based on the training node, the head node and the initial global model, a local update model corresponding to each group is determined using a preset update rule; Based on a preset screening rule, determining a main committee node and a committee node from the multiple committee nodes; wherein the committee node is a node other than the main committee node among the multiple committee nodes; Based on the master node and the committee nodes, the local update model of each group is verified by consensus using the preset consensus rules to obtain the verification result; In response to the verification result being a passed verification, based on the master committee node, the local update models of each group are aggregated using a preset security aggregation rule to obtain a new global model; In response to the main committee node determining that the new global model converges, the new global model is stored as a federated learning result.
[0006] The present invention also provides a multi-layer asynchronous federated learning system based on blockchain, comprising: The initialization module is configured to: in response to receiving the initialization configuration instruction, use the task publisher to execute the blockchain, the interplanetary file system IPFS, the coordination server CS and the node initialization, and publish the smart contract SC to the blockchain and the interplanetary file system, and upload the system parameters and the initial global model; wherein the node includes a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, and the plurality of training nodes are divided into a plurality of groups, and each group corresponds to one of the head nodes; The update aggregation module is configured to: for each group, based on the training node, the head node and the initial global model, determine a local update model corresponding to each group using a preset update rule; The committee node determination module is configured to: determine a main committee node and a committee node from the plurality of committee nodes based on a preset screening rule; wherein the committee node is a node other than the main committee node in the plurality of committee nodes; The scoring and consensus module is configured to: perform consensus verification on the local update model of each group based on the master committee node and the committee node using preset consensus rules to obtain a verification result; The security aggregation module is configured as follows: In response to the verification result being a passed verification, based on the master committee node, the local update models of each group are aggregated using a preset security aggregation rule to obtain a new global model; In response to the main committee node determining that the new global model converges, the new global model is stored as a federated learning result.
[0007] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the multi-layer asynchronous federated learning method based on blockchain as described in any one of the above-mentioned methods is implemented.
[0008] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described multi-layer asynchronous federated learning methods based on blockchain.
[0009] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned multi-layer asynchronous federated learning methods based on blockchain.
[0010] As described above, using the blockchain-based multi-layer asynchronous federated learning method provided by the embodiment of the present invention, first, by using masking and differential privacy, it can be ensured that the local updates uploaded by the training node will not leak the privacy of the local data set of the training node; and the mask conforms to the characteristics of balanced noise, so that the privacy protection process will not affect the performance of the global model. Secondly, the security aggregation mechanism based on model accuracy can effectively prevent Byzantine attacks from malicious nodes and reduce the impact of outdated models on the global model. Finally, based on the consensus mechanism of the committee, a certain number of malicious nodes among the committee members can be tolerated, thereby improving the system robustness of federated learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0012] Figure 1 This is one of the flowcharts of the multi-layer asynchronous federated learning method based on blockchain provided by an embodiment of the present invention; Figure 2 It is a timing flow diagram of a multi-layer asynchronous federated learning method based on blockchain provided by an embodiment of the present invention; Figure 3 It is a flowchart of the “consensus execution process” in the multi-layer asynchronous federated learning method based on blockchain provided by an embodiment of the present invention; Figure 4 This is the second flow chart of the multi-layer asynchronous federated learning method based on blockchain provided by an embodiment of the present invention; Figure 5 It is a structural diagram of a multi-layer asynchronous federated learning system based on blockchain provided by an embodiment of the present invention; Figure 6 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0013] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0014] Summary of the invention concept: The reasons for the problems in the prior art are that the Byzantine attack mainly includes two methods: malicious device attack and malicious server attack. Among them, malicious devices can pollute the global model by uploading wrong models or parameters; or malicious devices can also pollute local data sets through label flipping attacks, signal flipping attacks, and backdoor attacks. Malicious servers can manipulate the training process of federated learning by disguise or collusion, destroying the correctness and robustness of the federated learning system. Although the existing technology uses a secure aggregation method to ensure convergence and Byzantine fault tolerance. However, the secure aggregation method cannot provide effective defense against malicious server attacks. Although federated learning has the characteristics of immobile models and dynamic data, the models uploaded by training nodes still pose a threat to the privacy and security of users, resulting in privacy and security issues. Synchronous federated learning requires that the data of all participants must be uploaded to the central server for aggregation at the same time. However, the consensus mechanism of blockchain has its specific time beats in engineering applications. The inconsistency between the two may cause system compatibility problems and reduce the training efficiency of federated learning, resulting in consensus and aggregation optimization problems.
[0015] In view of this, in the present invention, considering that based on blockchain, the Byzantine attack problem caused by malicious server attacks can be solved through decentralization and consensus mechanism; and differential privacy (DP) can be used to deal with privacy security issues during user incentive reasoning attacks; wherein DP has very low computing and communication requirements while meeting privacy protection performance; for optimization problems, asynchronous solutions can be introduced to reduce delays, so that the system can perform better when equipment fails or the network is unstable. Based on this, the present invention provides a multi-layer asynchronous federated learning solution based on blockchain as described in the following embodiment.
[0016] Example: The following describes the implementation details of the blockchain-based multi-layer asynchronous federated learning solution of the present invention in conjunction with the accompanying drawings.
[0017] Figure 1 1 is a flowchart of a multi-layer asynchronous federated learning method based on blockchain provided by an exemplary embodiment of the present invention. This embodiment can be applied to electronic devices (for example, servers or cloud computing platforms), such as Figure 1 As shown in the figure, the multi-layer asynchronous federated learning method based on blockchain includes the following steps: S110, in response to receiving the initialization configuration instruction, using the task publisher to execute the blockchain, InterPlanetary File System (IPFS), trusted coordinating server (CS) and node initialization, and publishing a smart contract (SC) to the blockchain and InterPlanetary File System, and uploading system parameters and an initial global model.
[0018] The nodes include multiple training nodes, multiple head nodes and multiple committee nodes. The multiple training nodes are divided into multiple groups, and each group includes one head node.
[0019] The initialization configuration instruction may be set by a technician or user according to needs and sent to the task publisher through a corresponding terminal.
[0020] It should be noted that the present invention does not limit the task publisher, and may include but is not limited to a computer that executes the configuration task based on the preset instructions of the technician.
[0021] Among them, the initialization configuration instruction may include task parameters that characterize the tasks to be configured; the tasks to be configured include initialization tasks of blockchain, IPFS, CS and nodes.
[0022] The implementation details of the specific initialization will be described below and will not be repeated here.
[0023] S120, for each group, based on the training node, the head node and the initial global model, using a preset update rule, determine a local update model corresponding to each group; The training node is used to locally update the initial global model; the head node is used to average and aggregate the local updates.
[0024] Among them, the head node can be based on the coordination server CS, and ensure that the local updates uploaded by the training node will not leak the privacy of the local data set of the training node by using masking and differential privacy; the specific implementation details will be described below and will not be repeated here.
[0025] S130: Determine a main committee node and committee nodes from the multiple committee nodes based on a preset screening rule.
[0026] The committee nodes are nodes other than the main committee node among the multiple committee nodes.
[0027] S140, based on the master committee node and the committee nodes, using the preset consensus rules, performing consensus verification on the local update model of each group to obtain a verification result; S150. In response to the verification result being passed, based on the main committee node, the local update models of each group are aggregated using preset security aggregation rules to obtain a new global model; in response to the main committee node judging that the new global model converges, the new global model is stored as a federated learning result.
[0028] As described above, using the blockchain-based multi-layer asynchronous federated learning method provided by the embodiment of the present invention, first, by using masking and differential privacy, it can be ensured that the local updates uploaded by the training node will not leak the privacy of the local data set of the training node; and the mask conforms to the characteristics of balanced noise, so that the privacy protection process will not affect the performance of the global model. Secondly, the security aggregation mechanism based on model accuracy can effectively prevent Byzantine attacks from malicious nodes and reduce the impact of outdated models on the global model. Finally, based on the consensus mechanism of the committee, a certain number of malicious nodes among the committee members can be tolerated, thereby improving the robustness of federated learning.
[0029] exist Figure 1 Based on the embodiment, as an optional implementation, the system parameters include: the maximum number of rounds of federated learning , the minimum number of local training iterations of the training node And the maximum number of iterations of local training , global hash function, global test set .
[0030] Among them, as an optional example, in response to the initialization configuration instruction of the task publisher, the Hash function can be compiled and the corresponding initialization parameters can be uploaded to the blockchain, and the Hash function interface can also be uploaded.
[0031] exist Figure 1 Based on the embodiment, as an optional implementation, the multi-layer asynchronous federated learning method further includes: In response to the main committee node determining that the new global model does not converge, iterating the step of determining the local update model corresponding to each group to the step of obtaining the new global model until the new global model converges, and / or the number of iterations is greater than the maximum number of rounds of the federated learning .
[0032] exist Figure 1Based on the embodiment, as an optional implementation, in step S110, "in response to receiving the initialization configuration instruction, using the task publisher to execute the blockchain, the interplanetary file system IPFS, the coordination server CS and the node initialization" can be implemented as follows: Step 1), in response to the initialization configuration instruction, create a consortium chain and compile the smart contract.
[0033] Optionally, in response to the initialization configuration instruction, the task publisher may download or build the alliance chain source code, build the alliance chain and compile the SC.
[0034] Step 2), based on the alliance chain, determine and publish the IP address of the blockchain, the smart contract, the interplanetary file system IPFS and the coordination server CS.
[0035] Optionally, the task publisher determines and publishes the IP addresses of the blockchain, the smart contract, the interplanetary file system IPFS, and the coordination server CS.
[0036] Furthermore, based on the above-initialized "blockchain, the smart contract, the interplanetary file system IPFS and the IP address of the coordination server CS", the task publisher can set and upload the system parameters mentioned in the above-mentioned implementation. Specifically, for example, the task publisher can create an initial global model , the initial block , the initial global model The system parameters are stored in IPFS, and the initial global model is generated using the public key of the task publisher. Unique identifier , and the unique identifier Pack and store in the initial block , and sign it using the private key.
[0037] Step 3), activating the plurality of training nodes, the plurality of head nodes and the plurality of committee nodes registered in the blockchain, wherein the training node has a local data set.
[0038] As an optional example, step 3) may include the following steps: Step 31), terminal devices in the Internet of Things (IoT) and vehicle terminals in the Internet of Vehicles (IoV) can be used as training nodes Register your identity on the blockchain and get the public and private key pair on the chain; the public key is published on the chain and the training node The public key is used to encrypt data, the private key is used to sign and serve as the secure hash key of IPFS, and the training node has a local data set .
[0039] Step 32), the gateway (getway) in the Internet of Things (IoT) and the roadside unit (RSU) in the Internet of Vehicles (IoV) can register their identities with the blockchain as head nodes and obtain the public and private key pairs on the chain; the public key is made public on the chain, and the head node uses the public key to encrypt data, and the private key is used for signing and used as the secure hash key of IPFS. The head node does not participate in local training, but collects local updates uploaded by the training nodes in the group, verifies and aggregates them, and uploads them.
[0040] Step 33), idle nodes are registered as committee nodes through the alliance chain, and the authorized committee nodes will be allowed to participate in the federated learning training. The committee nodes start from the initial block Get the global test set from , verify the group local update uploaded by the head node , and perform verification aggregation.
[0041] Step 4), based on the coordination server CS, using the verification model uploaded by the training node, the multiple training nodes are divided to obtain the multiple groups.
[0042] The verification model is obtained by the training node using the local data set to train the initial global model.
[0043] As an optional example, step 4) may include the following steps: Step 41), the coordination server CS (i.e., as a trusted third-party server) receives the activation signal sent by the smart contract, participates in the alliance chain and registers, obtains its public and private key pair, and sends the encrypted mask to the training node .
[0044] Step 42), training nodes from the initial block Get the minimum number of iterations for local training And the maximum number of iterations of local training , the initial global model Unique identifier of , and then based on the unique identifier , get the initial global model from IPFS .
[0045] Step 43), training node Set the number of local training iterations , batchsize of each local dataset, learning rate , using a local dataset For the initial global model Conduct a total Mini-batch SGD training, the learning rate of each model parameter iteration is ,go through Local iterations, get the training node Validation Model .
[0046] Step 44), training node Will Upload to the coordination server CS, CS uses the global test set verify After the performance of the training node is determined, the training node will be trained according to the upload time. Divide into groups, each group Training nodes within Possess similar computing and communication capabilities.
[0047] Reference Figure 2 , the plurality of groups may include, for example ,..., ,..., Each group may include multiple training nodes and a head node, for example Can include c 0 , c 1 , c 2 ,..., c i It should be noted that the training node is a terminal with computing capabilities, including but not limited to desktop computers, tablet computers (such as IPads) and smart phones.
[0048] exist Figure 1 Based on the embodiment, as an optional implementation, step S120 "for each group, based on the training node, the head node and the initial global model, using the preset update rule, determining the local update model corresponding to each group" can be implemented by the following steps I to II: As an optional example, step I may further include: Step I1) Each training node in each group obtains the initial global model from the blockchain and the interplanetary file system IPFS. Step I2) Each training node in each group, in response to receiving a training signal sent by the coordination server CS, uses local training parameters and a local training data set to iteratively train the initial global model to obtain a first local updated model.
[0049] Optionally, first, assume that in the tth round of federated learning training, the group Training nodes within Get the global model of the current training round from the blockchain Unique identifier of , and based on the unique identifier Get the global model from IPFS It should be noted that, since it is a multi-round federated learning training, the initial global model uploaded during the system initialization phase is used in the first training. , the subsequent training rounds will successively use the global model of the previous training round as the initial global model. Therefore, when the tth round of training is performed, the global model of the previous round (i.e., the t-1th round) is used as the initial global model.
[0050] Then, the group Training nodes Start waiting for the mask from the coordination server CS With the training signal, CS will record the group The time when the generated group is updated locally , and based on the average time Remaining time with federated learning For comparison, if , then to the nodes in the group Send a training signal.
[0051] Finally, the group Internal training node After receiving the training signal, according to the set training parameters H, batchsize, Parameters such as optimizer type, loss function, whether to cross-iterate, etc., use local datasets For the global model Perform H local iterations to obtain local updates of the training node ; That is, the first local update model.
[0052] Step I3) In response to receiving the mask sent by the coordination server CS, each training node in each group uses the mask to add noise to the first local update model, generates a second local update model, and uploads it to the blockchain and the interplanetary file system IPFS.
[0053] Optionally, in step I3), first, the training node completes local training to obtain a first local update model After that, the following calculation formula (1) can be used to perform noise addition calculation to obtain the second local update model.
[0054] (1) in, represents the second local update model; Indicates that for the group Internal training node 's mask; Represents the first local update model.
[0055] Then, the training node of each group can upload the second local updated model to IPFS and obtain a unique identifier ; Then the unique identifier Packing into blocks And sign; group Internal Head Node Obtain the corresponding second local update model from IPFS and blockchain .
[0056] As an optional example, step II may further include: Optionally, in step II1), the head node in each group uses the blockchain and the Interstellar File System IPFS to obtain the second local update model corresponding to each training node in the group, and performs average aggregation to obtain a third local update model.
[0057] Alternatively, optionally, in step II1'), the head node in each group uses the blockchain and the interplanetary file system IPFS to obtain the second local update model corresponding to the training node in the group, and determines the number of second local update models obtained. Step II2') In response to the number of models being less than the number of members of the group to which the head node belongs, the head node sends a fault recovery request to the coordination server CS to obtain the corresponding mask of the offline training node; Specifically, the group For example, the head node After a fixed time interval, the number of collected second local update models is used to determine whether there is a training node offline. If the number of received second local update models is less than the size of the group, , the head node performs noise recovery.
[0058] In step II3'), the head node uses the corresponding mask and the obtained second local update model to perform average aggregation to obtain a third local update model; in step II4'), the third local update model is uploaded to the blockchain and the InterPlanetary File System IPFS and signed as the local update model.
[0059] Specifically, first, if the group The training node is offline, the head node Send offline training nodes to CS ; After receiving the offline training node information, CS communicates with the offline training node. If the communication is established, it notifies the head node to wait and notifies the offline training node to repeat sending the second local update model If communication is not established, the head node Send the corresponding mask of the offline training node , divide the training nodes into online training nodes And offline training nodes .
[0060] Second, in the group Internal Head Node Can collect the corresponding mask of offline training nodes sent by CS , the second local update model uploaded by each training node in the group Then, the third local update model is calculated using the following calculation formulas (2) to (3) according to the situation.
[0061] In the absence of an offline training node, the third local update model can be calculated using formula (2): (2) in, represents the third local update model, namely the local update model; Represents the head node mask; i Representation Group The serial number of the internal training node; represents the second local update model; Representation Group The number of training nodes included.
[0062] In the case of an offline training node, the third local update model can be calculated using formula (3): (3) in, Indicates the mask corresponding to the offline training node; Indicates the number of online training nodes; Indicates the number of offline training nodes.
[0063] exist Figure 1 Based on the embodiment, as an optional implementation mode, step S130 "determining the main committee node and the committee nodes from the multiple committee nodes based on the preset screening rule" can be implemented as follows: Step (1), each of the committee nodes, in the current learning round, obtains the corresponding block data and the global hash function from the blockchain through the smart contract, and uses the global hash function to determine the main committee node serial number and the committee node serial number.
[0064] Among them, assuming that the current learning round is t, the committee node can collect blocks With the initial block data; and from the initial block The global hash function is obtained from
[0065] Then, the committee node can use the global hash function to calculate the block The hash value of the master node can then be determined using the following calculation formula (4): q .
[0066] (4) Where M represents the number of committee nodes.
[0067] Step (2): Based on the preset main committee consensus rule, the committee node performs the main committee consensus verification on the main committee node number within the committee to obtain the committee consensus verification result.
[0068] Committee Node Broadcasting messages within the committee .in, Represents a committee node address; Indicates the serial number of the chairman; Indicates the signature for the broadcast message; Represents a committee node selection signal.
[0069] Committee Node Determine the messages broadcast by other committee nodes. If the number of broadcast messages that are the same as the message sent by itself reaches M / 2, which is half the number of committee nodes, then broadcast it within the committee. ;in, Indicates confirmation of consensus.
[0070] Step (3): In response to the consensus verification result of the committee being that the number of verified members is greater than a preset number threshold, the chief committee member registers his identity with the blockchain and broadcasts a confirmation signal within the committee.
[0071] The confirmation signal includes the master node serial number, the master node address and the signature of the master node on the confirmation signal.
[0072] The preset number threshold may be, for example, M / 2, ie, half of the number of committee nodes.
[0073] Specifically, the main committee node Receive broadcast messages from other committee nodes After that, the broadcast message is verified. If the number of identical broadcast messages received is greater than M / 2, the main committee node registers its identity with the blockchain. After completing the registration, broadcast a confirmation signal within the committee ;in, Election Indicates confirmation parameters.
[0074] Reference Figure 2 ,The committee may include multiple committee nodes, e.g. u 0 , u 1 ,..., u i ,..., u M ; Among them, the node that can be used as the main committee member can be u i , and the remaining nodes can serve as committee nodes. It should be noted that the main committee node and / or committee nodes can be terminals with computing capabilities; for example, including but not limited to desktop computers, tablet computers (such as IPads) and smart phones.
[0075] Continue to refer to Figure 2 The middle box area includes the blockchain, the Interplanetary File System IPFS, and the smart contract. In the process of interaction between the training node and the committee node and the blockchain and IPFS, it is necessary to upload a unique identifier (for example, ) and signature ( ).
[0076] exist Figure 1 Based on the embodiment, as an optional implementation method, refer to Figure 4 Step S140 "Based on the master node and the committee nodes, using the preset consensus rules, consensus verification is performed on the local update model of each group to obtain a verification result" can be achieved as follows: Step S1410: The main committee node obtains the local update model of each group through the blockchain and the InterPlanetary File System IPFS.
[0077] As an optional example, Specifically, the main committee node Collect groups from blockchain and IPFS The uploaded local update model , verify the corresponding signature of the local update model and the upload head node If the public key of the local update model is confirmed to be corresponding, the next step is carried out. If it is confirmed not to be corresponding, the local update model is judged to be forged data. Deprecate the local update model , and then collect the initial global model corresponding to the current learning round .
[0078] Step S1420: The main committee node scores each local update model using the global test set to obtain a first score corresponding to each local update model.
[0079] As an optional example, first, the main committee node Global test suite available , calculate the current initial global model Accuracy With the group Uploaded group local update model Accuracy Then, the main committee node The accuracy obtained from the test and Compute local update model The corresponding score , that is, as the first score; specifically, it can be expressed by the following calculation formula (5): (5) It should be noted that the main committee node In the current learning round t, a total of Local update model, calculation The corresponding first score.
[0080] Step S1430: The main committee node broadcasts a pre-preparation signal within the committee.
[0081] The pre-preparation signal includes the identity authentication information of the main committee node, the unique identifier UID of each local update model and the corresponding first score.
[0082] As an optional example, exhibitors Figure 3 , first, the main committee node Collect the calculated scores , the set of scores can be expressed as ; Main committee node Collect the corresponding group local update model and the corresponding unique identifier , where the set of unique identifiers is represented as .
[0083] Then, the main committee node Computable pre-prepared signals , and broadcast the pre-preparation signal within the committee. The pre-preparation signal can be expressed as , M represents the number of member nodes in the committee, Represents the signature of the main committee node, Indicates the identity authentication information of the node master. Indicates the identifier of a prepared signal.
[0084] Step S1440: In response to receiving the broadcast pre-preparation signal, the committee node verifies each of the local update models based on the committee internal scoring verification rule to obtain an internal scoring verification result.
[0085] As an alternative example, refer to Figure 3 , taking the current learning round as the tth round as an example, step S1440 may further include the following steps: Step 1: Committee Node Receive the pre-preparation signal from the master node , verify signatures, and get group data from the blockchain The uploaded local update model Unique identifier of ; and compared with the pre-prepared signal from the main committee node, if the verification is passed, the pre-prepared signal is used according to Field, get the corresponding local update model from the Interstellar File System IPFS .
[0086] Step 2: Committee members Get the local update model Then, use the global test set For the collected Local update models are scored and the current global model is tested Accuracy The accuracy of the local updated model uploaded by each group. For example, we can use the following formula (6) to calculate the group The uploaded local update model The corresponding score .
[0087] (6) in, Representation Group Uploaded local update model accuracy.
[0088] Step ③: Committee Node After calculating this round After the corresponding scores of the local updated models are compared with those from the main committee node In the pre-prepared signal The fields are compared and verified. If they are the same, the verification passes and the parameters are set. Calculation ready signal The preparation signal is then broadcasted within the committee, where To judge the result, if the judgment fails, select an earlier block , re-elect the chairperson and repeat the consensus process.
[0089] The preparation signal can be expressed as ; Prep represents the prepare signal identifier.
[0090] Step ④: Committee Node Receive readiness signals from other committee members , verify the signature of the received preparation signal and determine the received The number of ready signals. If the number reaches 2M / 3, it is judged to pass. If it fails, an earlier block is selected. , re-elect the chairperson and repeat the consensus process.
[0091] Step ⑤: Committee Node If the judgment is passed, set the parameters Calculate commit signal ; then broadcast the preparation signal within the committee, where is the judgment result of the submission phase. Among them, the submission signal can be expressed as , Comm represents the commit signal identifier.
[0092] Step ⑥: Committee Node Receive commit signals from other committee nodes , verify the signature of the received submission signal and determine the received The number of submission signals. If the number reaches 2M / 3, it is judged to be passed. If it fails, an earlier block is selected. , re-elect the chairperson and repeat the consensus process.
[0093] Step S1450: In response to the internal scoring verification result being a passed verification, secure aggregation is performed using the smart contract, and a reply signal is generated.
[0094] As an optional example, in step S1450, first, the committee node Aggregation operations can be performed based on smart contracts (SC); then based on the score field in the submission signal , using the following calculation formula (7), the new global model is calculated.
[0095] (7) in, represents the new global model; represents the aggregation weight parameter; Indicates the number of local update models; k indicates the sequence number of the group; Representation Group The uploaded local update model score.
[0096] Secondly, the committee node After performing security aggregation operations, set the parameters , and calculate the reply signal ; then broadcast the preparation signal within the committee, where This is the judgment result of the response phase.
[0097] The reply signal can be expressed as , where Re represents the identifier of the recovery signal.
[0098] Step S1460, in response to the main committee node determining that the consensus verification is passed based on the received reply signal, the local update model of each group in the current learning round, the corresponding first score, and the signature of the block containing the local update model of each group are used as the verification result.
[0099] As an optional example, in step S1460, the main committee node Receive from committee nodes The reply signal is received, the signature is verified, and the received reply signal is judged. If the number reaches M / 2, the consensus is passed and the global model of this round is prepared to be recorded; if it fails, an earlier blockchain is selected. , re-elect the chairperson and repeat the consensus process.
[0100] exist Figure 1 Based on the embodiment, as an optional implementation, step S150 "in response to the verification result being verification passed, based on the main committee node, the local update models of each group are aggregated using a preset security aggregation rule to obtain a new global model" can be implemented as follows: First, the local updated model of each group in the current learning round, the corresponding first score, and the signature of the block containing the local updated model of each group are obtained.
[0101] As an optional example, For example, the main committee node Collectible Group Uploaded local update model The first score corresponding to , and contains each local update model The corresponding signature of the block .
[0102] Secondly, the main committee node aggregates the local update model of each group using smart contracts to obtain the new global model, and uploads it to the blockchain and the Interstellar File System IPFS.
[0103] As an optional example, first the main committee node A security aggregation operation can be performed based on a smart contract (SC); then based on the first score set Aggregate local update model Specifically, the new global model can be calculated using the above formula (7): ; and the new global model Upload to IPFS. Then, the main committee node can be used The private key generates the new global model The corresponding unique identifier Finally, the unique identifier , collected signatures Packing into blocks And sign the block.
[0104] exist Figure 1 Based on the embodiment, as an optional implementation, step S150 "in response to the main committee node determining that the new global model converges, storing the new global model as a federated learning result" may include: The main committee node uses the global test set , performing convergence judgment on the new global model; in response to the new global model converging, storing the new global model in the blockchain.
[0105] In response to the main committee node determining that the new global model does not converge, iterating the step of determining the local update model corresponding to each group to the step of obtaining the new global model until the new global model converges, and / or the number of iterations is greater than the maximum number of rounds of the federated learning .
[0106] As described above, using the blockchain-based multi-layer asynchronous federated learning method provided by the embodiment of the present invention, first, by using masking and differential privacy, it can be ensured that the local updates uploaded by the training node will not leak the privacy of the local data set of the training node; and the mask conforms to the characteristics of balanced noise, so that the privacy protection process will not affect the performance of the global model. Secondly, the security aggregation mechanism based on model accuracy can effectively prevent Byzantine attacks from malicious nodes and reduce the impact of outdated models on the global model. Finally, based on the consensus mechanism of the committee, a certain number of malicious nodes among the committee members can be tolerated, thereby improving the robustness of the federated learning system.
[0107] The following is a description of the blockchain-based multi-layer asynchronous federated learning device provided by the present invention. The blockchain-based multi-layer asynchronous federated learning device described below and the blockchain-based multi-layer asynchronous federated learning method described above can refer to each other.
[0108] Figure 5 Schematic diagram of the structure of a multi-layer asynchronous federated learning device based on blockchain provided by an exemplary embodiment of the present invention. Figure 5 As shown, the multi-layer asynchronous federated learning device based on blockchain includes: The initialization module 510 is configured to: in response to receiving the initialization configuration instruction, use the task publisher to execute the blockchain, the interplanetary file system IPFS, the coordination server CS and the node initialization, and publish the smart contract SC to the blockchain and the interplanetary file system, and upload the system parameters and the initial global model; wherein the node includes a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, and the plurality of training nodes are divided into a plurality of groups, each group corresponding to one of the head nodes; the update aggregation module 520 is configured to: for each group, based on the training nodes, the head nodes and the initial global model, using the preset update rules, determine the local update model corresponding to each group; the committee node determination module 530 is configured to: based on According to the preset screening rules, the main committee node and the committee nodes are determined from the multiple committee nodes; wherein the committee nodes are nodes other than the main committee node in the multiple committee nodes; the scoring and consensus module 540 is configured to: based on the main committee node and the committee nodes, use the preset consensus rules to perform consensus verification on the local update model of each group to obtain a verification result; the security aggregation module 550 is configured to: in response to the verification result being a passed verification, based on the main committee node, use the preset security aggregation rules to aggregate the local update models of each group to obtain a new global model; in response to judging that the new global model converges based on the main committee node, the new global model is stored as a federated learning result.
[0109] Figure 6An example of a physical structure diagram of an electronic device is shown in FIG. Figure 6 As shown, the electronic device may include: a processor 610, a communication interface 620, a memory 630 and a communication bus 640, wherein the processor 610, the communication interface 620 and the memory 630 communicate with each other through the communication bus 640. The processor 610 may call the logic instructions in the memory 630 to execute a multi-layer asynchronous federated learning method based on blockchain, the method comprising: in response to receiving an initialization configuration instruction, using a task publisher to execute blockchain, interplanetary file system IPFS, coordination server CS and node initialization, and publishing a smart contract SC to the blockchain and interplanetary file system, and uploading system parameters and an initial global model; wherein the nodes include a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, the plurality of training nodes are divided into a plurality of groups, each group corresponding to one of the head nodes; for each group, based on the training nodes, the head nodes and the initial global model, using a preset update rule , determine the local update model corresponding to each group; based on the preset screening rules, determine the main committee node and the committee node from the multiple committee nodes; wherein the committee node is the node other than the main committee node in the multiple committee nodes; based on the main committee node and the committee node, using the preset consensus rule, perform consensus verification on the local update model of each group to obtain a verification result; in response to the verification result being a passed verification, based on the main committee node, use the preset security aggregation rule to aggregate the local update models of each group to obtain a new global model; in response to judging that the new global model converges based on the main committee node, the new global model is stored as a federated learning result.
[0110] In addition, the logic instructions in the above-mentioned memory 630 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0111] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the blockchain-based multi-layer asynchronous federated learning method provided by the above methods, the method comprising: in response to receiving an initialization configuration instruction, using a task publisher to execute blockchain, interstellar file system IPFS, coordination server CS and node initialization, and publishing a smart contract SC to the blockchain and interstellar file system, and uploading system parameters and an initial global model; wherein the node includes a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, the plurality of training nodes are divided into a plurality of groups, each group corresponding to one of the head nodes; for Each group, based on the training node, the head node and the initial global model, uses the preset update rules to determine the local update model corresponding to each group; based on the preset screening rules, determines the main committee node and the committee node from the multiple committee nodes; wherein the committee node is the node other than the main committee node among the multiple committee nodes; based on the main committee node and the committee node, uses the preset consensus rules to perform consensus verification on the local update model of each group to obtain a verification result; in response to the verification result being a passed verification, based on the main committee node, uses the preset security aggregation rules to aggregate the local update models of each group to obtain a new global model; in response to the new global model being judged to have converged based on the main committee node, the new global model is stored as a federated learning result.
[0112] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the blockchain-based multi-layer asynchronous federated learning method provided by the above methods, the method comprising: in response to receiving an initialization configuration instruction, using a task publisher to execute blockchain, interplanetary file system IPFS, coordination server CS and node initialization, and publishing a smart contract SC to the blockchain and interplanetary file system, and uploading system parameters and an initial global model; wherein the node includes a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, the plurality of training nodes are divided into a plurality of groups, each group corresponding to one of the head nodes; for each group, based on the training nodes, the head nodes, The method comprises the following steps: first, determining a master committee node and a committee member node from the plurality of committee nodes based on a preset screening rule; second, determining a master committee node and a committee member node from the plurality of committee nodes except the master committee node; third, performing consensus verification on the local update model of each group based on the master committee node and the committee member nodes using a preset consensus rule to obtain a verification result; in response to the verification result being a passed verification, based on the master committee node, using a preset security aggregation rule to aggregate the local update models of each group to obtain a new global model; and in response to the judgment based on the master committee node that the new global model converges, storing the new global model as a federated learning result.
[0113] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0114] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A multi-layer asynchronous federated learning method based on blockchain, characterized in that: include: In response to receiving the initialization configuration instruction, the task publisher is used to execute the blockchain, the interplanetary file system IPFS, the coordination server CS and the node initialization, and the smart contract SC is published to the blockchain and the interplanetary file system, and the system parameters and the initial global model are uploaded; wherein the node includes a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, and the plurality of training nodes are divided into a plurality of groups, and each group corresponds to one of the head nodes; For each group, based on the training node, the head node and the initial global model, a local update model corresponding to each group is determined using a preset update rule; Based on a preset screening rule, determining a main committee node and a committee node from the multiple committee nodes; wherein the committee node is a node other than the main committee node among the multiple committee nodes; Based on the master node and the committee nodes, the local update model of each group is verified by consensus using the preset consensus rules to obtain the verification result; In response to the verification result being a passed verification, based on the master committee node, the local update models of each group are aggregated using a preset security aggregation rule to obtain a new global model; In response to the main committee node determining that the new global model converges, the new global model is stored as a federated learning result.
2. The multi-layer asynchronous federated learning method according to claim 1, characterized in that: The system parameters include: The maximum number of rounds of federated learning, the minimum number of local training iterations and the maximum number of local training iterations of the training node, the global hash function, and the global test set.
3. The multi-layer asynchronous federated learning method according to claim 2, characterized in that: The multi-layer asynchronous federated learning method further includes: In response to the main committee node determining that the new global model does not converge, iterating the step of determining the local update model corresponding to each group to the step of obtaining the new global model until the new global model converges, or the number of iterations is greater than the maximum number of rounds of the federated learning.
4. The multi-layer asynchronous federated learning method according to claim 2, characterized in that: In response to receiving the initialization configuration instruction, the task publisher is used to execute the blockchain, the interplanetary file system IPFS, the coordination server CS and the node initialization, including: In response to the initialization configuration instruction, create a consortium chain and compile the smart contract; Based on the alliance chain, determine and publish the blockchain, the smart contract, the interplanetary file system IPFS and the IP address of the coordination server CS; Activating the plurality of training nodes, the plurality of head nodes, and the plurality of committee nodes registered in the blockchain; wherein the training node has a local data set; Based on the coordination server CS, the multiple training nodes are divided using the verification model uploaded by the training node to obtain the multiple groups; wherein the verification model is obtained by the training node using the local data set to train the initial global model.
5. The multi-layer asynchronous federated learning method according to claim 2, characterized in that: For each group, based on the training node, the head node and the initial global model, a local update model corresponding to each group is determined using a preset update rule, including: Each training node in each group obtains the initial global model from the blockchain and the InterPlanetary File System IPFS; Each training node in each group, in response to receiving a training signal sent by the coordination server CS, iteratively trains the initial global model using local training parameters and a local training data set to obtain a first local updated model; Each training node in each group, in response to receiving the mask sent by the coordination server CS, uses the mask to add noise to the first local update model, generates a second local update model, and uploads it to the blockchain and the interplanetary file system IPFS; The head node in each group uses the blockchain and the InterPlanetary File System IPFS to obtain the second local update model corresponding to each training node in the group, and performs average aggregation to obtain a third local update model; or, The head node in each group uses the blockchain and the interplanetary file system IPFS to obtain the second local update model corresponding to the training node in the group, and determines the number of second local update models obtained; In response to the number of models being less than the number of members of the group to which the head node belongs, the head node sends a fault recovery request to the coordination server CS to obtain a corresponding mask of an offline training node; The head node uses the corresponding mask and the obtained second local update model to perform average aggregation to obtain a third local update model; The third local update model is uploaded to the blockchain and the InterPlanetary File System IPFS and signed as the local update model.
6. The multi-layer asynchronous federated learning method according to claim 2, characterized in that: Based on a preset screening rule, determining a main committee node and committee nodes from the plurality of committee nodes includes: Each of the committee nodes, in the current learning round, obtains the corresponding block data and the global hash function from the blockchain through the smart contract, and uses the global hash function to determine the main committee node serial number and the committee node serial number; Based on the preset main committee consensus rules, the committee node performs the main committee consensus verification on the main committee node serial number within the committee to obtain the committee consensus verification result; In response to the committee consensus verification result being that the number of verifications passed is greater than a preset threshold, the chief committee member registers his identity with the blockchain and broadcasts a confirmation signal within the committee; wherein the confirmation signal includes the chief committee member node serial number, the chief committee member node address, and the chief committee member node's signature on the confirmation signal.
7. The multi-layer asynchronous federated learning method according to claim 2, characterized in that: Based on the master node and the committee nodes, the local update model of each group is verified by consensus using the preset consensus rules to obtain verification results, including: The main committee node obtains the local update model of each group through the blockchain and the interplanetary file system IPFS; The main committee node scores each local update model using the global test set to obtain a first score corresponding to each local update model; The master committee node broadcasts a pre-preparation signal within the committee; wherein the pre-preparation signal includes the identity authentication information of the master committee node, the unique identifier UID of each local update model, and the corresponding first score; In response to receiving the broadcast pre-preparation signal, the committee node verifies each of the local update models based on the committee internal scoring verification rule to obtain an internal scoring verification result; In response to the internal scoring verification result being a passed verification, using the smart contract to perform security aggregation and generate a reply signal; In response to the main committee node determining that the consensus verification is passed based on the received reply signal, the local update model of each group in the current learning round, the corresponding first score, and the signature of the block containing the local update model of each group are used as the verification result.
8. The multi-layer asynchronous federated learning method according to claim 7, characterized in that: In response to the verification result being that the verification is passed, based on the main committee node, the local update models of each group are aggregated using a preset security aggregation rule to obtain a new global model, including: Obtaining the local updated model of each group in the current learning round, the corresponding first score, and the signature of the block containing the local updated model of each group; The main committee node aggregates the local update model of each group using smart contracts to obtain the new global model, and uploads it to the blockchain and the Interstellar File System IPFS.
9. The multi-layer asynchronous federated learning method according to claim 8, characterized in that: In response to judging that the new global model converges based on the master committee node, storing the new global model as a federated learning result, including: The main committee node uses the global test set to judge the convergence of the new global model; In response to the new global model converging, the new global model is stored in the blockchain.
10. A multi-layer asynchronous federated learning system based on blockchain, characterized in that: include: The initialization module is configured to: in response to receiving the initialization configuration instruction, use the task publisher to execute the blockchain, the interplanetary file system IPFS, the coordination server CS and the node initialization, and publish the smart contract SC to the blockchain and the interplanetary file system, and upload the system parameters and the initial global model; wherein the node includes a plurality of training nodes, a plurality of head nodes and a plurality of committee nodes, and the plurality of training nodes are divided into a plurality of groups, and each group corresponds to one of the head nodes; The update aggregation module is configured to: for each group, based on the training node, the head node and the initial global model, determine a local update model corresponding to each group using a preset update rule; The committee node determination module is configured to: determine a main committee node and a committee node from the plurality of committee nodes based on a preset screening rule; wherein the committee node is a node other than the main committee node in the plurality of committee nodes; The scoring and consensus module is configured to: perform consensus verification on the local update model of each group based on the master committee node and the committee node using preset consensus rules to obtain a verification result; The security aggregation module is configured as follows: In response to the verification result being a passed verification, based on the master committee node, the local update models of each group are aggregated using a preset security aggregation rule to obtain a new global model; In response to the main committee node determining that the new global model converges, the new global model is stored as a federated learning result.
Citation Information
Patent Citations
Trusted federated learning method, system and device based on block chain and medium
CN111966698A
Federal learning differential privacy protection method based on model difference sparsification
CN115146313A
Decentralized federated learning data sharing method based on block chain
CN117521151A
Federal learning method based on adaptive differential privacy
CN117874829A
Block chain data sharing method under assistance of asynchronous federated learning
CN118069607A
