Federated learning methods and systems based on blockchain parallel voting consensus and multiple attached sidechains
Through the blockchain parallel voting consensus and the federated learning method of multiple additional side chains, the problems of low utilization efficiency and vulnerability of computing and storage resources in the existing technology are solved, and higher system security and throughput are achieved.
Patent Information
- Application Number
- CN202410851938.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-06-28
AI Technical Summary
Existing technologies lack flexibility and scalability in financial transactions, information communication and storage processes, have low utilization efficiency of computing and storage resources, and are vulnerable to poisoning attacks, resulting in high server overhead.
Adopting a federated learning method based on blockchain parallel voting consensus and multiple additional side chains, the local model is trained, verified and consensus uploaded to the chain through client nodes and committee nodes, and parameters are aggregated through the blockchain network to reduce server computing and communication volume, improving system security and decentralization.
Effectively reduce server computing and communication volume, improve system security, stability and throughput, reduce the risk of poisoning attacks, and improve the efficiency of global model data uploading and storage.
Smart Images

Figure CN118400382B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information processing technology, and in particular to a federated learning method and system based on blockchain parallel voting consensus and multiple additional side chains. Background Art
[0002] With the development of current Internet information technology and blockchain technology, most companies generally use blockchain technology and artificial intelligence technology (for example, federated learning algorithm) to improve the security and stability of financial transactions, information communication and storage processes in various industries. However, the processing methods currently adopted by most companies lack flexibility and scalability, the utilization efficiency of computing and storage resources is low, and they are prone to the risk of poisoning attacks, resulting in high computing, communication and storage costs for enterprise servers.
[0003] Therefore, a federated learning method and system based on blockchain parallel voting consensus and multiple additional side chains is currently provided, which can effectively reduce the computing and communication volume of the server, relieve node pressure, lower the threshold for joining the network, improve the security, stability and decentralization of the system, and effectively resist poisoning attacks while improving the efficiency of global model data on-chain storage, thereby improving system throughput and processing capabilities. Summary of the invention
[0004] The present invention provides a method and system for federated learning based on blockchain parallel voting consensus and multiple additional side chains, which can effectively reduce the computing and communication volume of the server, improve the security, stability and decentralization of the system, and effectively resist poisoning attacks while improving the efficiency of global model data on-chain storage, thereby improving system throughput and processing capabilities.
[0005] In order to solve the above technical problems, the first aspect of the present invention discloses a federated learning method based on blockchain parallel voting consensus and multiple attached side chains, the method comprising:
[0006] Connect to the federated learning system and publish training tasks based on the task requirements of the demand side;
[0007] Initializing the training parameters of the training task according to the demand information of the training task, and building a local model according to the training parameters, wherein the demand information includes: a consensus node set, a committee node set, a client node set, and a demand party set of the blockchain network;
[0008] Performing model training and parameter updating on the local model through at least one client node in the client node set to obtain an updated model and updated parameters corresponding to each client node;
[0009] Verifying the update model and the update parameters through at least one committee node of the committee node set to obtain the verified update model and update parameters, and performing consensus on the verified update model and update parameters;
[0010] Aggregating the update parameter through at least one committee node in the committee node set to obtain an aggregated aggregate parameter, and verifying the aggregate parameter through a consensus node of the blockchain network to obtain a verified aggregate parameter;
[0011] Setting the consensus node roles in each consensus cycle according to the consensus nodes of the blockchain network;
[0012] A parallel voting consensus is performed according to the consensus node roles to obtain a voting result, and the voting result is uploaded to the chain, wherein the voting result includes the verified aggregation parameter.
[0013] As an optional implementation, in the first aspect of the present invention, the training parameters include: a training data set, a training model parameter, and a training requirement parameter, the consensus node set of the blockchain network includes at least one consensus node, the blockchain network includes a main chain network and a side chain network, the client node set includes at least one client set, and the demander set includes at least one demander;
[0014] After initializing the model parameters of the training task according to the requirement information of the training task and constructing the local model according to the model parameters, the method further includes:
[0015] According to the consensus node information of the blockchain network, at least one consensus node is selected to form a committee node set, and the committee node set is used for task consensus;
[0016] Creating a training channel for the training task and creating the training task, wherein the channel information of the training channel includes: a client node set, a committee node set and a channel identifier that participate in the training task;
[0017] Publishing the training task to the blockchain network, and updating the local task list according to the training task;
[0018] When it is detected that any target client node in the client node set selects any target training task in the local task list, the target training task is connected to the training task matching the target training task in the blockchain network, the contract corresponding to the training task is signed, and the target client node is added to the training channel corresponding to the training task.
[0019] As an optional implementation, in the first aspect of the present invention, the performing model training and parameter updating on the local model by at least one client node in the client node set to obtain an updated model and updated parameters corresponding to each client node includes:
[0020] Performing a preset round of model training and parameter update on the local model through at least one client node in the client node set, to obtain an updated model and updated parameters of each round corresponding to each client node;
[0021] And, the updating model and the updating parameters are verified by at least one committee node of the committee node set to obtain the updated model and the updated parameters after verification, and the operation of consensus chaining the updated model and the updated parameters after verification includes:
[0022] Performing a correctness check on the update model and the update parameters by at least one committee node of the committee node set to obtain an update model and update parameters that pass the correctness check;
[0023] Performing quality assessment on the updated model and updated parameters that have passed the correctness check to obtain quality assessment scores corresponding to the updated model and the updated parameters, and determining whether the quality assessment scores corresponding to the updated model and the updated parameters are greater than or equal to a preset score threshold;
[0024] When it is determined that the quality assessment scores corresponding to the updated model and the updated parameters are greater than or equal to a preset score threshold, determining that the updated model and the updated parameters pass the quality assessment;
[0025] A consensus of a preset consensus type is performed on the client nodes corresponding to the updated model that has passed the quality assessment, and after the consensus is completed, the updated model and the updated parameters are uploaded to the side chain network.
[0026] As an optional implementation manner, in the first aspect of the present invention, aggregating the update parameter by at least one committee node in the committee node set to obtain the aggregated aggregate parameter includes:
[0027] Aggregating, by at least one committee node in the committee node set, the updated parameters obtained by at least one client node in each round according to an aggregation algorithm and based on the model parameters stored in the local ledger, to obtain aggregated parameters of at least one client node in each round after aggregation;
[0028] And, verifying the aggregation parameter through the consensus node of the blockchain network to obtain the verified aggregation parameter includes:
[0029] Calculating a hash value of an aggregation parameter of at least one client node in each round through the committee node, and sending the hash value of the aggregation parameter to the committee node network where the committee node is located;
[0030] Determining, through the committee node network, whether the hash value of the aggregation parameter calculated by other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node;
[0031] When it is determined that the hash value of the aggregation parameter calculated by any target committee node among the other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node, marking the target committee node;
[0032] Determine the number of times the target committee node is marked in each round, and sort the number of times marked to obtain the aggregation parameter corresponding to the largest number of times marked;
[0033] The aggregation parameter corresponding to the maximum number of marking times is checked for correctness through the main chain network to obtain a target aggregation parameter that passes the correctness check.
[0034] As an optional implementation, in the first aspect of the present invention, setting the consensus node role in each consensus cycle according to the consensus node of the blockchain network includes:
[0035] Calculate the corresponding accounting weight according to the available resources corresponding to the consensus node of the blockchain network;
[0036] Determine the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm, and set the consensus node roles in each consensus cycle according to the accounting nodes;
[0037] The step of calculating the corresponding accounting weight according to the available resources corresponding to the consensus nodes of the blockchain network includes:
[0038] For each consensus node in the blockchain network, calculating computing resource parameters, storage resource parameters, and communication resource parameters corresponding to the consensus node;
[0039] Calculate the accounting weight of the consensus node according to the computing resource parameter, the storage resource parameter and the communication resource parameter;
[0040] Normalizing the accounting weights corresponding to all consensus nodes of the blockchain network to obtain a set of accounting weights corresponding to all consensus nodes after normalization;
[0041] Determining the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm includes:
[0042] Generate the key pair used for consensus operations in each consensus cycle based on the preset key length;
[0043] Input the accounting weight set and the key pair used for consensus operation in each consensus cycle into the verifiable random function for calculation to obtain the output parameters and proof parameters of the accounting weight set;
[0044] Calculate the randomness index of the accounting weight set according to the output parameters and proof parameters of the accounting weight set and a preset linear or nonlinear function;
[0045] Based on the randomness indicator, the accounting nodes in each consensus cycle are extracted through a lottery algorithm, and the extracted accounting nodes in each consensus cycle are verified.
[0046] As an optional implementation, in the first aspect of the present invention, extracting the accounting nodes in each consensus cycle through a lottery algorithm based on the randomness indicator includes:
[0047] Calculate the probability of drawing lots for each consensus node based on the randomness index ;
[0048] Initialize the number of winning numbers for each consensus node is 0;
[0049] With the probability of drawing lots As the initial input parameter, the number of winning numbers is A Bernoulli test with a number of iterations and an actual number of successes being k, and determining whether the preset Bernoulli test conditions are met, and determining whether the output result of the Bernoulli test meets the preset Bernoulli test conditions;
[0050] When it is determined that the preset Bernoulli test condition is met, the number of iterations is accumulated once, and the operation of the Bernoulli test is repeatedly performed;
[0051] When it is determined that the preset Bernoulli test conditions are not met, the operation of the Bernoulli test is stopped, and the output result set of each consensus node is obtained. ;
[0052] According to the output result set of each consensus node, a set of winning numbers of all consensus nodes is obtained, the winning numbers corresponding to all consensus nodes in the set of winning numbers are sorted, and the first z nodes with the largest number of winning numbers are selected as accounting nodes in each consensus cycle;
[0053] Among them, the Represented as the output parameter, the Denoted as the proof parameter.
[0054] As an optional implementation, in the first aspect of the present invention, the role type of the consensus node role includes: at least one of: an accounting node, a leadership node, a potential accounting node, and a voting node.
[0055] The second aspect of the present invention discloses a federated learning system based on blockchain parallel voting consensus and multiple additional side chains, the system comprising:
[0056] The access and release module is used to access the federated learning system and release training tasks according to the task requirements of the demand side;
[0057] An initialization construction module, used to initialize the model parameters of the training task according to the demand information of the training task published by the access publishing module, and to build a local model according to the model parameters, wherein the demand information includes: a consensus node set, a committee node set, a client node set and a demand party set of the blockchain network;
[0058] A training and updating module, configured to perform model training and parameter updating on the local model constructed by the initialization construction module through at least one client node in the client node set, and obtain an updated model and updated parameters corresponding to each client node;
[0059] A verification module, used to verify the update model and the update parameters obtained by the training and updating of the training and updating module through at least one committee node of the committee node set, to obtain the updated model and the updated parameters that have passed the verification;
[0060] A consensus chain module is used to perform consensus chain operations on the update model and update parameters verified by the verification module;
[0061] an aggregation module, used for aggregating the update parameters updated by the training update module through at least one committee node in the committee node set to obtain aggregated aggregation parameters;
[0062] The verification module is further used to verify the aggregation parameters aggregated by the aggregation module through the consensus node of the blockchain network to obtain the verified aggregation parameters;
[0063] A setting module, used to set the consensus node role in each consensus cycle according to the consensus node of the blockchain network in the demand information of the training task published by the access publishing module;
[0064] The consensus on-chain module is also used to perform parallel voting consensus according to the consensus node role set by the setting module, obtain voting results, and perform on-chain operations on the voting results, wherein the voting results include the verified aggregation parameters.
[0065] As an optional implementation, in the second aspect of the present invention, the training parameters include: a training data set, a training model parameter, and a training requirement parameter, the consensus node set of the blockchain network includes at least one consensus node, the blockchain network includes a main chain network and a side chain network, the client node set includes at least one client set, and the demander set includes at least one demander;
[0066] The device also includes:
[0067] A selection module, configured to select at least one consensus node to form a committee node set according to the consensus node information of the blockchain network after the initialization construction module initializes the model parameters of the training task according to the requirement information of the training task and builds a local model according to the model parameters, wherein the committee node set is used for task consensus;
[0068] A creation module, used to create a training channel for the training task published by the access publishing module, and create the training task, wherein the channel information of the training channel includes: a client node set, a committee node set and a channel identifier participating in the training task;
[0069] A publishing and updating module, used to publish the training task created by the creation module to the blockchain network, and update the local task list according to the training task;
[0070] A connection module, configured to connect to a training task matching the target training task in the blockchain network according to the target training task when it is detected that any target client node in the client node set selects any target training task in the local task list updated by the publishing update module;
[0071] A signing module, used to sign the contract corresponding to the training task connected to the connection module;
[0072] An adding module is used to add the target client node to the training channel corresponding to the training task connected to the connecting module.
[0073] As an optional implementation, in the second aspect of the present invention, the training update module performs model training and parameter update on the local model through at least one client node in the client node set, and obtains the updated model and updated parameters corresponding to each client node in a specific manner as follows:
[0074] Performing a preset round of model training and parameter update on the local model through at least one client node in the client node set, to obtain an updated model and updated parameters of each round corresponding to each client node;
[0075] Furthermore, the verification module verifies the update model and the update parameter through at least one committee node of the committee node set, and the specific manner of obtaining the verified update model and update parameter is:
[0076] Performing a correctness check on the update model and the update parameters by at least one committee node of the committee node set to obtain an update model and update parameters that pass the correctness check;
[0077] Performing quality assessment on the updated model and updated parameters that have passed the correctness check to obtain quality assessment scores corresponding to the updated model and the updated parameters, and determining whether the quality assessment scores corresponding to the updated model and the updated parameters are greater than or equal to a preset score threshold;
[0078] When it is determined that the quality assessment scores corresponding to the updated model and the updated parameters are greater than or equal to a preset score threshold, determining that the updated model and the updated parameters pass the quality assessment;
[0079] The specific operation method of the consensus chain module for performing consensus chain operation on the updated model and updated parameters after verification is as follows:
[0080] A consensus of a preset consensus type is performed on the client nodes corresponding to the updated model that has passed the quality assessment, and after the consensus is completed, the updated model and the updated parameters are uploaded to the side chain network.
[0081] As an optional implementation, in the second aspect of the present invention, the aggregation module aggregates the update parameter through at least one committee node in the committee node set, and the specific manner of obtaining the aggregated aggregation parameter after aggregation is:
[0082] Aggregating, by at least one committee node in the committee node set, the updated parameters obtained by at least one client node in each round according to an aggregation algorithm and based on the model parameters stored in the local ledger, to obtain aggregated parameters of at least one client node in each round after aggregation;
[0083] And, the verification module verifies the aggregation parameter through the consensus node of the blockchain network, and the specific method of obtaining the verified aggregation parameter is:
[0084] Calculating a hash value of an aggregation parameter of at least one client node in each round through the committee node, and sending the hash value of the aggregation parameter to the committee node network where the committee node is located;
[0085] Determining, through the committee node network, whether the hash value of the aggregation parameter calculated by other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node;
[0086] When it is determined that the hash value of the aggregation parameter calculated by any target committee node among the other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node, marking the target committee node;
[0087] Determine the number of times the target committee node is marked in each round, and sort the number of times marked to obtain the aggregation parameter corresponding to the largest number of times marked;
[0088] The aggregation parameter corresponding to the maximum number of marking times is checked for correctness through the main chain network to obtain a target aggregation parameter that passes the correctness check.
[0089] As an optional implementation, in the second aspect of the present invention, the specific manner in which the setting module sets the consensus node role in each consensus cycle according to the consensus node of the blockchain network is:
[0090] Calculate the corresponding accounting weight according to the available resources corresponding to the consensus node of the blockchain network;
[0091] Determine the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm, and set the consensus node roles in each consensus cycle according to the accounting nodes;
[0092] The specific method of calculating the corresponding accounting weight according to the available resources corresponding to the consensus node of the blockchain network is:
[0093] For each consensus node in the blockchain network, calculating computing resource parameters, storage resource parameters, and communication resource parameters corresponding to the consensus node;
[0094] Calculate the accounting weight of the consensus node according to the computing resource parameter, the storage resource parameter and the communication resource parameter;
[0095] Normalizing the accounting weights corresponding to all consensus nodes of the blockchain network to obtain a set of accounting weights corresponding to all consensus nodes after normalization;
[0096] The specific method of determining the accounting nodes in each consensus cycle based on the accounting weight and the preset algorithm is:
[0097] Generate the key pair used for consensus operations in each consensus cycle based on the preset key length;
[0098] Input the accounting weight set and the key pair used for consensus operation in each consensus cycle into the verifiable random function for calculation to obtain the output parameters and proof parameters of the accounting weight set;
[0099] Calculate the randomness index of the accounting weight set according to the output parameters and proof parameters of the accounting weight set and a preset linear or nonlinear function;
[0100] Based on the randomness indicator, the accounting nodes in each consensus cycle are extracted through a lottery algorithm, and the extracted accounting nodes in each consensus cycle are verified.
[0101] As an optional implementation, in the second aspect of the present invention, the specific manner in which the setting module extracts the accounting nodes in each consensus cycle through a lottery algorithm based on the randomness indicator is:
[0102] Calculate the probability of drawing lots for each consensus node based on the randomness index ;
[0103] Initialize the number of winning numbers for each consensus node is 0;
[0104] With the probability of drawing lots As the initial input parameter, the number of winning numbers is The number of iterations and the actual number of successes are k times of Bernoulli trials, and it is determined whether the preset Bernoulli trial conditions are met;
[0105] When it is determined that the preset Bernoulli test condition is met, the number of iterations is accumulated once, and the operation of the Bernoulli test is repeatedly performed;
[0106] When it is determined that the preset Bernoulli test conditions are not met, the operation of the Bernoulli test is stopped, and the output result set of each consensus node is obtained. ;
[0107] According to the output result set of each consensus node, a set of winning numbers of all consensus nodes is obtained, the winning numbers corresponding to all consensus nodes in the set of winning numbers are sorted, and the first z nodes with the largest number of winning numbers are selected as accounting nodes in each consensus cycle;
[0108] Among them, the Represented as the output parameter, the Denoted as the proof parameter.
[0109] As an optional implementation, in the second aspect of the present invention, the role type of the consensus node role includes: at least one of: an accounting node, a leadership node, a potential accounting node, and a voting node.
[0110] The third aspect of the present invention discloses another federated learning system based on blockchain parallel voting consensus and multiple additional side chains, the system comprising:
[0111] A memory storing executable program code;
[0112] a processor coupled to the memory;
[0113] The processor calls the executable program code stored in the memory to execute the federated learning method based on blockchain parallel voting consensus and multiple additional side chains disclosed in the first aspect of the present invention.
[0114] The fourth aspect of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute the federated learning method based on blockchain parallel voting consensus and multiple additional side chains disclosed in the first aspect of the present invention.
[0115] Compared with the prior art, the embodiments of the present invention have the following beneficial effects:
[0116] The present invention provides a federated learning method and system based on blockchain parallel voting consensus and multiple additional side chains. The method includes: accessing a federated learning system and publishing training tasks according to the task requirements of a demander, initializing training parameters of the training tasks according to the requirement information of the training tasks, building a local model according to the training parameters, performing model training, parameter updating and verification on the local model, consensus-uploading the updated model and updated parameters after verification, aggregating and verifying the updated parameters, consensus-uploading the aggregated parameters after verification, and finally determining an accounting node according to the consensus node of the blockchain network, setting a consensus node role according to the accounting node, performing parallel voting consensus on all consensus node roles, and uploading the final voting result to the chain. It can be seen that the implementation of the present invention can build a local model according to the training parameters corresponding to the published training tasks, perform model training, parameter update and verification, and consensus on the chain for the local model through the client node, and aggregate and verify the updated parameters through the committee node, and consensus on the verified aggregated parameters on the chain, which is beneficial to reduce the calculation and communication volume of the server, effectively reduce the overhead of ledger storage and consensus communication, and improve the security and stability of the system; set the consensus node role according to the consensus node of the blockchain network, perform parallel voting consensus on all consensus node roles, and upload the final voting results to the chain, which can effectively resist malicious network attacks while improving the efficiency of global model data on-chain storage and improving system throughput and processing capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0117] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0118] Figure 1 It is a flow chart of a federated learning method based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention;
[0119] Figure 2 It is a general architecture diagram of a federated learning system based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention;
[0120] Figure 3 It is a diagram of an attachable side chain data structure of a federated learning system based on blockchain parallel voting consensus and multiple attached side chains disclosed in an embodiment of the present invention;
[0121] Figure 4 It is a flow chart of another federated learning method based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention;
[0122] Figure 5 It is a structural diagram of a federated learning system based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention;
[0123] Figure 6 It is a structural diagram of another federated learning system based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention;
[0124] Figure 7 This is a structural diagram of another federated learning system based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention. DETAILED DESCRIPTION
[0125] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only 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.
[0126] The terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish different objects rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or terminal including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or terminals.
[0127] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0128] The present invention discloses a federated learning method and system based on blockchain parallel voting consensus and multiple additional side chains, which can build a local model according to the training parameters corresponding to the published training tasks, perform model training, parameter update and verification and consensus chain on the local model through the client node, and aggregate and verify the updated parameters through the committee node, and consensus chain the aggregated parameters after verification, which is conducive to reducing the calculation and communication volume of the server, effectively reducing the overhead of account book storage and consensus communication, and improving the security and stability of the system; setting the consensus node role according to the consensus node of the blockchain network, performing parallel voting consensus on all consensus node roles, and chaining the final voting results, which can effectively resist malicious network attacks while improving the efficiency of global model data chain storage, and improving system throughput and processing capacity. The following are detailed descriptions.
[0129] Embodiment 1
[0130] See also Figure 1 , Figure 1 This is a flow chart of a federated learning method based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention. Figure 1 The described federated learning method based on blockchain parallel voting consensus and multiple additional side chains can be applied to a federated learning system based on blockchain parallel voting consensus and multiple additional side chains. The system can be applied to an enterprise data management system, which is not limited by the embodiments of the present invention. Optionally, the system can be applied to a local terminal device (e.g., a PC terminal, a local server, etc.) or a mobile terminal device (e.g., a smart phone, a tablet computer, a PDA, a mobile Internet device, etc.), which is not limited by the embodiments of the present invention. Figure 1 As shown, the federated learning method based on blockchain parallel voting consensus and multiple attached side chains may include the following operations:
[0131] 101. Connect to the federated learning system and publish training tasks according to the task requirements of the demand side, initialize the training parameters of the training tasks according to the demand information of the training tasks, and build a local model based on the training parameters.
[0132] In the embodiment of the present invention, optionally, the federated learning system is a computing platform constructed using a federated learning algorithm, which is a distributed machine learning algorithm that can use encrypted model parameters to perform collaborative learning among multiple participants without sharing original data. It solves the problems of data privacy and centralization and improves the performance and accuracy of the model.
[0133] In the embodiment of the present invention, optionally, the demand information may include: at least one of a consensus node set, a committee node set, a client node set and a demand party set of the blockchain network, the training parameters include: a training data set, a training model parameter and a training requirement parameter, the consensus node set of the blockchain network includes at least one consensus node, the blockchain network may include a main chain network and multiple side chain networks, the client node set may include at least one client set, and the demand party set may include at least one demand party (detailed architecture such as Figure 2 , Figure 3 As shown in the example of the present invention, this is not limited. Further, the consensus node set of the blockchain network can be expressed as , contains l consensus nodes, and the client node can be represented as , containing m nodes, the demand side set can be expressed as , including n demand parties. The criteria for selecting the committee consensus node include: high prediction difficulty, high credibility, and strong stability. Among them, the training model parameters may include: at least one of the following information: parameter w, loss function LF, activation function AF, learning rate η, number of layers m, etc. The training requirements may include: at least one of the following information: training time t, number of clients k, reward r, etc. Each demand party can be represented as , Represented as the public key of the demander, Represents the task list published by the demand side.
[0134] In this way, dedicated consensus nodes are responsible for the release, verification and storage of all tasks through the main chain network, which is conducive to improving the flexibility and scalability of the federated learning system; the committee nodes of the side chain are selected by the task demanders from the main chain consensus nodes. For each consensus node, maintaining and storing the main chain ledger, as well as the side chain ledger corresponding to the training tasks, can effectively reduce the overhead of ledger storage and consensus communication.
[0135] 102. Perform model training and parameter update on the local model through at least one client node in the client node set to obtain an updated model and updated parameters corresponding to each client node, verify the updated model and updated parameters through at least one committee node in the committee node set to obtain the verified updated model and updated parameters, and perform consensus on the chain for the verified updated model and updated parameters.
[0136] In an embodiment of the present invention, performing model training and parameter updating on a local model by at least one client node in a client node set to obtain an updated model and updated parameters corresponding to each client node may include:
[0137] The local model is trained and parameter updated for a preset k rounds through at least one client node in the client node set to obtain an updated model, gradient value and updated parameter of each round corresponding to each client node.
[0138] The calculation formula of the gradient value is expressed as , the calculation formula for updating parameters is , i represents the update of the i-th round.
[0139] In the embodiment of the present invention, the update model and update parameters are verified by at least one committee node of the committee node set to obtain the updated model and update parameters that have passed the verification, and the operation of consensus chaining the updated model and update parameters that have passed the verification may include:
[0140] The update model and update parameters are verified for correctness by at least one client node of the committee node to obtain the updated model and update parameters that pass the correctness verification.
[0141] Perform quality assessment on the updated model and updated parameters after correctness verification to obtain the quality assessment scores corresponding to the updated model and updated parameters , and determine whether the quality assessment score corresponding to the updated model and the updated parameters is greater than or equal to a preset score threshold.
[0142] When it is determined that the quality evaluation scores corresponding to the updated model and the updated parameters are greater than or equal to the preset score threshold, it is determined that the updated model and the updated parameters pass the quality evaluation.
[0143] The client nodes corresponding to the updated models that have passed the quality assessment will reach a consensus of the preset consensus type, and after the consensus is completed, the updated model and update parameters will be uploaded to the sidechain network. Among them, the preset consensus type can be BFT type consensus (Byzantine Fault Tolerant Consensus Algorithm), PBFT type consensus (Practical Byzantine Fault Tolerant Consensus Algorithm) or RBFT type consensus (Highly Robust Byzantine Fault Tolerant Algorithm).
[0144] In this way, the side chain of the blockchain network adopts an appendable block structure to better adapt to the participating clients participating in local training to upload multiple rounds of model training process information to the chain. When the client completes a round of model training, the side chain committee consensus node verifies and evaluates the local updated model, and packages the verified model update information into an additional data block and appends it to the block to which the corresponding client belongs. This can prevent poor quality or malicious models from entering the aggregation stage, improve the quality of the global model, and effectively reduce storage and communication overhead, lower the threshold for joining the network, and improve the degree of decentralization.
[0145] 103. Aggregate the update parameters through at least one committee node in the committee node set to obtain aggregated aggregate parameters, and verify the aggregate parameters through the consensus node of the blockchain network to obtain verified aggregate parameters.
[0146] In the embodiment of the present invention, aggregating the update parameter by at least one committee node in the committee node set to obtain the aggregated aggregate parameter may include:
[0147] At least one committee node in the committee node set uses an aggregation algorithm (e.g., FedAvg algorithm) and the model parameters stored in the local ledger to update the parameters obtained by at least one client node in each round. Perform aggregation to obtain the aggregation parameters of at least one client node in each round after aggregation The aggregation parameters are calculated as .
[0148] In an embodiment of the present invention, verifying the aggregation parameter through the consensus node of the blockchain network to obtain the verified aggregation parameter may include:
[0149] The committee node calculates the hash value of the aggregate parameter of at least one client node in each round , and sends the hash value of the aggregation parameter to the committee node network where the committee node is located.
[0150] The committee node network determines whether the hash value of the aggregation parameter calculated by other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node.
[0151] When it is determined that the hash value of the aggregation parameter calculated by any target committee node among other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node, the target committee node is marked.
[0152] Determine the number of times the target committee node is marked in each round, sort the number of times marked, and obtain the aggregation parameter corresponding to the maximum number of times marked.
[0153] The aggregation parameters corresponding to the maximum number of marking times are checked for correctness through the main chain network to obtain the target aggregation parameters that have passed the correctness check.
[0154] In an embodiment of the present invention, optionally, in the main chain network, the aggregation parameters of other nodes in the main chain network that do not participate in the committee role of the corresponding training task can be verified, and the aggregation parameters corresponding to the committee nodes can be reached and uploaded to the main chain network.
[0155] In this way, the client node model contribution calculation and training incentive mechanism are introduced. The main chain consensus node calculates the corresponding contribution value of the client participating in the training for the aggregated global model submitted in each round, which can effectively enhance the enthusiasm of users to participate in the training while ensuring the fairness of the training process.
[0156] 104. Set the consensus node role in each consensus cycle according to the consensus node of the blockchain network, conduct parallel voting consensus according to the consensus node role, obtain the voting results, and upload the voting results to the chain.
[0157] In the embodiment of the present invention, optionally, the voting result includes the verified aggregation parameter.
[0158] In an embodiment of the present invention, the consensus node role in each consensus cycle is set according to the consensus node of the blockchain network, including:
[0159] The corresponding accounting weight is calculated based on the available resources corresponding to the consensus nodes of the blockchain network.
[0160] Based on the accounting weight and the preset algorithm, the accounting nodes in each consensus cycle are determined, and the consensus node roles in each consensus cycle are set according to the accounting nodes.
[0161] In an embodiment of the present invention, optionally, calculating the corresponding accounting weight according to the available resources corresponding to the consensus nodes of the blockchain network may include:
[0162] For each consensus node in the blockchain network, the computing resource parameters, storage resource parameters, and communication resource parameters corresponding to the consensus node are calculated.
[0163] The accounting weight of the consensus node is calculated based on the computing resource parameters, storage resource parameters and communication resource parameters.
[0164] Among them, computing resources , Indicates the clock frequency, Indicates the number of cores, Indicates the average number of instructions executed per cycle.
[0165] Storage resources , Expressed as memory bandwidth, Expressed as memory clock frequency, Indicates the hard disk read and write rate.
[0166] Communications Resources , Expressed as network bandwidth, Represented as network delay, Expressed as network throughput.
[0167] Bookkeeping weight , Expressed as the weight coefficient of computing resources, Expressed as the weight coefficient of storage resources, Expressed as the weight coefficient of communication resources.
[0168] Normalize the accounting weights corresponding to all consensus nodes in the blockchain network and map them to the range of [0,1] to obtain the normalized accounting weight set corresponding to all consensus nodes. .
[0169] In the embodiment of the present invention, optionally, determining the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm may include:
[0170] Generate the key pair used for consensus operations in each consensus cycle based on the preset key length .
[0171] The accounting weight set and the key pair used for consensus operations in each consensus cycle are input into the verifiable random function for calculation to obtain the output parameters of the accounting weight set. With proof parameters .
[0172] According to the output parameters and proof parameters of the accounting weight set, as well as the preset linear or nonlinear function, the randomness index of the accounting weight set is calculated.
[0173] The calculation formula can be expressed as , m represents the shape coefficient of the control probability distribution.
[0174] Based on the randomness indicator, the accounting nodes in each consensus cycle are extracted through the lottery algorithm, and the extracted accounting nodes in each consensus cycle are verified (verifying the election results, based on , which can be verified by RSA-VRF The correctness of , the lottery algorithm can be used to verify whether the corresponding node is selected).
[0175] In the embodiment of the present invention, further optionally, based on the randomness indicator, extracting the accounting nodes in each consensus cycle through a lottery algorithm may include:
[0176] Calculate the probability of drawing lots for each consensus node based on the randomness indicator .
[0177] Initialize the number of winning numbers for each consensus node is 0.
[0178] By lottery probability As the initial input parameter, the number of winning numbers is The number of iterations and the actual number of successes are k times of Bernoulli trials, and it is determined whether the output result of the Bernoulli trial meets the preset Bernoulli trial conditions (ie: ). Among them, Bernoulli experiment is a random experiment that is repeated and independently conducted under the same conditions, B is the Bernoulli experiment algorithm, and y is the output parameter of the accounting weight set (i.e. ), Represented as the update parameter for each consensus node, Expressed as The binary length value of .
[0179] When it is determined that the preset Bernoulli test conditions are met, the number of iterations is accumulated once and the Bernoulli test operation is repeated.
[0180] When it is determined that the preset Bernoulli test conditions are not met, the Bernoulli test operation is stopped and the output result set of each consensus node is obtained. .
[0181] The winning number set of all consensus nodes is obtained based on the output result set of each consensus node, the winning numbers corresponding to all consensus nodes in the winning number set are sorted, and the top z nodes with the largest number of winning numbers are selected as the accounting nodes in each consensus cycle.
[0182] in, Represented as an output parameter, Denoted as proof parameter.
[0183] In this way, the computing, storage, and communication resources available to the nodes are quantified, the accounting rights are linked to the resources owned by the nodes, the corresponding network accounting weight is calculated, and the accounting weight is used as the input of the verifiable random function. The corresponding output is used as a random selection indicator. This can resist witch attacks while improving the efficiency of global model data on-chain storage, improve system throughput and processing capabilities, and thus achieve fast and efficient consensus.
[0184] In an optional embodiment, after executing step 101, the method further includes the following operations:
[0185] According to the consensus node information of the blockchain network, at least q consensus nodes are selected to form a committee node set, which is used for task consensus.
[0186] Create a training channel for the training task and create the contract corresponding to the training task , and create a training task.
[0187] Publish the training task to the blockchain network and update the local task list according to the training task.
[0188] When it is detected that any target client node in the client node set selects any target training task in the local task list, the client node qualifications are reviewed by the demander to check whether the client node has the training capability and historical reliability.
[0189] If the check passes, a confirmation message is returned and the client list of the training channel is updated.
[0190] According to the target training task, connect to the training task that matches the target training task in the blockchain network, sign the contract corresponding to the training task, and add the target client node to the training channel corresponding to the training task.
[0191] The training channel is represented as The channel information of the training channel includes: channel identifier chid, the set of client nodes participating in the training task (initialized to an empty set), committee node set , the training task is expressed as , the contract corresponding to the training task The corresponding address is , the confirmation message is , , the update calculation method of the client list of the training channel is: .
[0192] In this optional embodiment, optionally, the demander can select a group of consensus nodes of the blockchain network as the committee node set according to the specific requirements of the training model and its own preferences.
[0193] It can be seen that this optional embodiment can be responsible for the release, verification and evidence storage of all tasks through the consensus node of the main chain network, and establish a corresponding dedicated channel network for each training task, which is composed of trusted nodes selected from the main chain consensus node and client nodes participating in the training, and is responsible for maintaining the dedicated side chain ledger corresponding to the task, ensuring the decentralization of local model aggregation and global model download process; the main and side chain fully distributed network structure formed in this way can effectively reduce the possibility of nodes doing evil.
[0194] Embodiment 2
[0195] See also Figure 4 , Figure 4 This is a flow chart of a federated learning method based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention. Figure 4The described federated learning method based on blockchain parallel voting consensus and multiple additional side chains can be applied to a federated learning system based on blockchain parallel voting consensus and multiple additional side chains. The system can be applied to an enterprise data management system, which is not limited by the embodiments of the present invention. Optionally, the system can be applied to a local terminal device (e.g., a PC terminal, a local server, etc.) or a mobile terminal device (e.g., a smart phone, a tablet computer, a PDA, a mobile Internet device, etc.), which is not limited by the embodiments of the present invention. Figure 4 As shown, the federated learning method based on blockchain parallel voting consensus and multiple attached side chains may include the following operations:
[0196] 201. Set the consensus node role in each consensus cycle according to the consensus node of the blockchain network.
[0197] In the embodiment of the present invention, optionally, the role type of the consensus node role intentionally includes: at least one of: an accounting node, a leadership node, a potential accounting node, a voting node, etc.
[0198] Among them, the accounting node It is composed of accounting nodes selected in this cycle, used to package transactions and generate pre-blocks, which are published to the main chain network.
[0199] Leader Node It is represented as the node with the largest probability value among the accounting nodes, which is used to distribute tasks and count votes, and to generate proof of voting results with signatures.
[0200] Potential accounting nodes Indicates that the node failed the election in this cycle and is waiting for the next election.
[0201] Voting Node Represented by all online nodes in the network, responsible for voting.
[0202] 202. The leader node organizes the received transactions, generates corresponding target tasks, and assigns the target tasks to the accounting nodes.
[0203] In the embodiment of the present invention, the target task includes the aggregation parameters of at least one client node in each round after verification.
[0204] 203. When it is detected that the accounting node has received the target task, the transaction is packaged to generate a pre-block, and a signature corresponding to the accounting node is generated, and the target task, pre-block and signature corresponding to the accounting node are published to the main chain network.
[0205] 204. Verify the received pre-block through the voting node to determine whether the target task and the transaction are correct and correspond to each other and whether the signature of the accounting node is correct.
[0206] In an embodiment of the present invention, when it is determined that the target task and the transaction are correct and correspond to each other and the signature of the accounting node is correct, step 205 can be executed.
[0207] 205. Generate corresponding voting information through the voting node and publish the voting information to the main chain network. The voting information includes: target task, transaction and signature corresponding to the voting node.
[0208] 206. The leader node counts the number of votes based on the voting information to determine whether the number of votes exceeds 2 / 3 of the total number of all current nodes.
[0209] In the embodiment of the present invention, when it is determined that the number of votes exceeds 2 / 3 of the total number of all currently online nodes, step 207 may be executed.
[0210] 207. Generate a final voting certificate based on the number of votes and publish it to the main chain network. When it is detected that the online node has received the voting certificate, perform consistency verification on the final voting certificates received by all online nodes to determine whether the final voting certificates received by all online nodes are the same.
[0211] In the embodiment of the present invention, when it is determined that the final voting proofs received by all online nodes are the same, step 208 may be executed. Optionally, the final voting proof includes: target task, transaction, number of votes, voting signature set and signature corresponding to the leader node.
[0212] 208. The voting certificate issued by the leader node is encapsulated into the block header through the accounting node to generate the final block, and the final block is published to the main chain network. When it is detected that the leader node has received the block, the information of the target task is updated, the target task is marked as completed, and the updated target task is published to the main chain network.
[0213] In the embodiment of the present invention, for other descriptions of step 201, please refer to the detailed description of step 104 in the first embodiment, and the embodiment of the present invention will not be repeated.
[0214] It can be seen that the implementation of the embodiment of the present invention can set multiple consensus node roles in each consensus cycle according to the consensus nodes of the blockchain network main chain, and adopt a fast parallel voting consensus algorithm for voting and election. It can effectively resist witch attacks while optimizing the voting consensus process to achieve fast and efficient consensus.
[0215] It can be seen that the implementation Figure 4The described federated learning method based on blockchain parallel voting consensus and multiple attached side chains can build a local model according to the training parameters corresponding to the published training tasks, perform model training, parameter update and verification and consensus on the local model through the client node, and aggregate and verify the updated parameters through the committee node, and consensus on the verified aggregated parameters, which is conducive to reducing the calculation and communication volume of the server, effectively reducing the overhead of ledger storage and consensus communication, and improving the security and stability of the system; setting the consensus node role according to the consensus node of the blockchain network, using a fast parallel voting consensus algorithm to conduct parallel voting consensus on all consensus node roles, and chaining the final voting results, which can effectively resist malicious network attacks while improving the efficiency of global model data on-chain storage, improving system throughput and processing capacity, and optimizing the voting consensus process and meeting the security, autonomy and controllability of the election process, and achieving fast and efficient consensus.
[0216] Embodiment 3
[0217] See also Figure 5 , Figure 5 It is a structural diagram of a federated learning system based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention. Figure 5 The described federated learning method system based on blockchain parallel voting consensus and multiple additional side chains can execute the federated learning method based on blockchain parallel voting consensus and multiple additional side chains. The system can be applied to enterprise data management systems, which is not limited by the embodiments of the present invention. Optionally, the system can be applied to local terminal devices (such as PC terminals, local servers, etc.) or mobile terminal devices (such as smart phones, tablet computers, PDAs, mobile Internet devices, etc.), which is not limited by the embodiments of the present invention. Figure 5 As shown, the federated learning system based on blockchain parallel voting consensus and multiple additional side chains may include: access publishing module 301, initialization construction module 302, training update module 303, verification module 304, consensus chain module 305, aggregation module 306, setting module 307, wherein:
[0218] The access and release module 301 is used to access the federated learning system and release training tasks according to the task requirements of the demander.
[0219] The initialization construction module 302 is used to initialize the model parameters of the training task according to the demand information of the training task released by the access publishing module 301, and to build a local model according to the model parameters, wherein the demand information includes: the consensus node set, committee node set, client node set and demand party set of the blockchain network.
[0220] The training update module 303 is used to perform model training and parameter update on the local model constructed by the initialization construction module 302 through at least one client node in the client node set, and obtain an updated model and updated parameters corresponding to each client node.
[0221] The verification module 304 is used to verify the update model and update parameters obtained by the training and updating module 303 through at least one committee node of the committee node set, and obtain the updated model and update parameters that have passed the verification.
[0222] The consensus chain module 305 is used to perform consensus chain operations on the update model and update parameters verified by the verification module 304.
[0223] The aggregation module 306 is used to aggregate the update parameters updated by the training update module 303 through at least one committee node in the committee node set to obtain aggregated aggregation parameters.
[0224] The verification module 304 is also used to verify the aggregation parameters aggregated by the aggregation module 306 through the consensus nodes of the blockchain network to obtain the verified aggregation parameters.
[0225] The setting module 307 is used to set the consensus node role in each consensus cycle according to the consensus node of the blockchain network in the demand information of the training task released by the access release module 301.
[0226] The consensus on-chain module 305 is also used to perform parallel voting consensus according to the consensus node roles set by the setting module 307, obtain voting results, and perform on-chain operations on the voting results, which include verified aggregation parameters.
[0227] It can be seen that the implementation Figure 5 The described federated learning system based on blockchain parallel voting consensus and multiple attached side chains can build a local model according to the training parameters corresponding to the published training tasks, perform model training, parameter update and verification and consensus on the chain for the local model through the client node, and aggregate and verify the updated parameters through the committee node, and consensus on the verified aggregated parameters on the chain, which is conducive to reducing the server's computing and communication volume, effectively reducing the overhead of ledger storage and consensus communication, while improving the security and stability of the system; setting the consensus node role according to the consensus node of the blockchain network, performing parallel voting consensus on all consensus node roles, and chaining the final voting results, which can effectively resist malicious network attacks while improving the efficiency of global model data on-chain storage and improving system throughput and processing capabilities.
[0228] In an optional embodiment, the training parameters include: a training data set, training model parameters and training requirement parameters, the consensus node set of the blockchain network includes at least one consensus node, the blockchain network includes a main chain network and a side chain network, the client node set includes at least one client set, and the demander set includes at least one demander.
[0229] As well as Figure 6 As shown, the device also includes:
[0230] The selection module 308 is used to select at least one consensus node to form a committee node set according to the consensus node information of the blockchain network after the initialization construction module 302 initializes the model parameters of the training task according to the requirement information of the training task and builds the local model according to the model parameters. The committee node set is used for task consensus.
[0231] The creation module 309 is used to create a training channel for the training task released by the access release module 301 and create a training task. The channel information of the training channel includes: a set of client nodes participating in the training task, a set of committee nodes and a channel identifier.
[0232] The publishing update module 310 is used to publish the training task created by the creation module 309 to the blockchain network and update the local task list according to the training task.
[0233] The connection module 311 is used to connect to the training task matching the target training task in the blockchain network according to the target training task when it is detected that any target client node in the client node set selects any target training task in the local task list updated by the publishing update module 310.
[0234] The signature module 312 is used to sign the contract corresponding to the training task connected to the connection module 311.
[0235] The adding module 313 is used to add the target client node to the training channel corresponding to the training task connected to the connecting module 311.
[0236] It can be seen that the implementation Figure 6 The described federated learning system based on blockchain parallel voting consensus and multiple additional side chains can be responsible for the release, verification and evidence storage of all tasks through the consensus nodes of the main chain network, and establish a corresponding dedicated channel network for each training task, which is composed of trusted nodes selected from the main chain consensus nodes and client nodes participating in the training. It is responsible for maintaining the dedicated side chain ledger corresponding to the task and ensuring the decentralization of local model aggregation and global model downloading process; the fully distributed network structure of the main and side chains formed in this way can effectively reduce the possibility of nodes doing evil.
[0237] In another optional embodiment, Figure 6 As shown, the training update module 303 performs model training and parameter update on the local model through at least one client node in the client node set, and obtains the updated model and updated parameters corresponding to each client node in the specific manner as follows:
[0238] A preset round of model training and parameter updating is performed on the local model by at least one client node in the client node set to obtain an updated model and updated parameters of each round corresponding to each client node.
[0239] Furthermore, the verification module 304 verifies the update model and update parameters through at least one committee node of the committee node set, and obtains the verified update model and update parameters in a specific manner as follows:
[0240] The update model and the update parameters are corrected by at least one committee node of the committee node set to obtain the update model and the update parameters that pass the correctness check.
[0241] Perform quality assessment on the updated model and updated parameters that have passed the correctness check to obtain quality assessment scores corresponding to the updated model and updated parameters, and determine whether the quality assessment scores corresponding to the updated model and updated parameters are greater than or equal to a preset score threshold.
[0242] When it is determined that the quality evaluation scores corresponding to the updated model and the updated parameters are greater than or equal to the preset score threshold, it is determined that the updated model and the updated parameters pass the quality evaluation.
[0243] The specific method of consensus chaining module 305 for performing consensus chaining on the updated model and updated parameters after verification is as follows:
[0244] The client nodes corresponding to the updated models that have passed the quality assessment will reach a consensus of the preset consensus type, and after the consensus is completed, the updated model and update parameters will be uploaded to the sidechain network.
[0245] It can be seen that the implementation Figure 6 The described federated learning system based on blockchain parallel voting consensus and multiple additional side chains can, after the client completes a round of model training, have the side chain committee consensus node verify and evaluate the local updated model, and package the verified model update information into an additional data block and append it to the block to which the corresponding client belongs. This can prevent poor quality or malicious models from entering the aggregation stage, improve the quality of the global model, and effectively reduce storage and communication overhead, lower the threshold for joining the network, and improve the degree of decentralization.
[0246] In yet another optional embodiment, Figure 6As shown, the aggregation module 306 aggregates the update parameters through at least one committee node in the committee node set, and the specific method of obtaining the aggregated aggregate parameters is:
[0247] Aggregate the updated parameters obtained by at least one client node in each round according to the aggregation algorithm and based on the model parameters stored in the local ledger through at least one committee node in the committee node set to obtain the aggregated parameters of at least one client node in each round after aggregation.
[0248] And, the verification module 304 verifies the aggregation parameters through the consensus node of the blockchain network, and the specific method of obtaining the verified aggregation parameters is:
[0249] The committee node calculates the hash value of the aggregation parameter of at least one client node in each round, and sends the hash value of the aggregation parameter to the committee node network where the committee node is located.
[0250] The committee node network determines whether the hash value of the aggregation parameter calculated by other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node.
[0251] When it is determined that the hash value of the aggregation parameter calculated by any target committee node among other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node, the target committee node is marked.
[0252] Determine the number of times the target committee node is marked in each round, sort the number of times marked, and obtain the aggregation parameter corresponding to the maximum number of times marked.
[0253] The aggregation parameters corresponding to the maximum number of marking times are checked for correctness through the main chain network to obtain the target aggregation parameters that have passed the correctness check.
[0254] It can be seen that the implementation Figure 6 The described federated learning system based on blockchain parallel voting consensus and multiple attached side chains can introduce client node model contribution calculation and training incentive mechanism. The main chain consensus node calculates the corresponding contribution value of the client participating in the training for the aggregated global model submitted in each round, which can effectively enhance the enthusiasm of users to participate in the training while ensuring the fairness of the training process.
[0255] In yet another optional embodiment, Figure 6 As shown, the specific manner in which the setting module 307 sets the consensus node role in each consensus cycle according to the consensus node of the blockchain network is:
[0256] The corresponding accounting weight is calculated based on the available resources corresponding to the consensus nodes of the blockchain network.
[0257] Based on the accounting weight and the preset algorithm, the accounting nodes in each consensus cycle are determined, and the consensus node roles in each consensus cycle are set according to the accounting nodes.
[0258] Among them, the specific method of calculating the corresponding accounting weight according to the available resources corresponding to the consensus nodes of the blockchain network is:
[0259] For each consensus node in the blockchain network, the computing resource parameters, storage resource parameters, and communication resource parameters corresponding to the consensus node are calculated.
[0260] The accounting weight of the consensus node is calculated based on the computing resource parameters, storage resource parameters and communication resource parameters.
[0261] The accounting weights corresponding to all consensus nodes of the blockchain network are normalized to obtain a set of accounting weights corresponding to all consensus nodes after normalization.
[0262] The specific method of determining the accounting nodes in each consensus cycle based on the accounting weight and the preset algorithm is as follows:
[0263] Generate the key pair used for consensus operations in each consensus cycle based on the preset key length.
[0264] The accounting weight set and the key pair used for consensus operations in each consensus cycle are input into the verifiable random function for calculation to obtain the output parameters and proof parameters of the accounting weight set.
[0265] According to the output parameters and proof parameters of the accounting weight set, as well as the preset linear or nonlinear function, the randomness index of the accounting weight set is calculated.
[0266] Based on the randomness indicator, the accounting nodes in each consensus cycle are extracted through a lottery algorithm, and the extracted accounting nodes in each consensus cycle are verified.
[0267] It can be seen that the implementation Figure 6 The described federated learning system based on blockchain parallel voting consensus and multiple attached side chains can quantify the computing, storage, and communication resources available to nodes, link the accounting rights with the resources owned by the nodes, calculate the corresponding network accounting weight, and use the accounting weight as the input of a verifiable random function, and the corresponding output as a random selection indicator. It can resist witch attacks while meeting the security, autonomy, and controllability of the election process, improve the efficiency of global model data on-chain storage, and improve system throughput and processing capabilities.
[0268] In yet another optional embodiment, Figure 6As shown, the specific method of setting module 307 to extract the accounting nodes in each consensus cycle through the lottery algorithm based on the randomness indicator is:
[0269] Calculate the probability of drawing lots for each consensus node based on the randomness indicator .
[0270] Initialize the number of winning numbers for each consensus node is 0.
[0271] By lottery probability As the initial input parameter, the number of winning numbers is A Bernoulli trial with k iterations and actual successes is performed, and it is determined whether the preset Bernoulli trial conditions are met, and whether the output result of the Bernoulli trial meets the preset Bernoulli trial conditions.
[0272] When it is determined that the preset Bernoulli test conditions are met, the number of iterations is accumulated once and the Bernoulli test operation is repeated.
[0273] When it is determined that the preset Bernoulli test conditions are not met, the Bernoulli test operation is stopped and the output result set of each consensus node is obtained. .
[0274] The winning number set of all consensus nodes is obtained based on the output result set of each consensus node, the winning numbers corresponding to all consensus nodes in the winning number set are sorted, and the top z nodes with the largest number of winning numbers are selected as the accounting nodes in each consensus cycle.
[0275] in, is represented as the output parameter, Denoted as the proof parameter.
[0276] It can be seen that the implementation Figure 6 The described federated learning system based on blockchain parallel voting consensus and multiple additional side chains can use the accounting weight as the input of a verifiable random function and the corresponding output as a random selection indicator. It can resist witch attacks while meeting the security, autonomy and controllability of the election process, improve the efficiency of global model data on-chain storage, and improve system throughput and processing capabilities.
[0277] In yet another optional embodiment, the role type of the consensus node role includes at least one of: an accounting node, a leadership node, a potential accounting node, and a voting node.
[0278] It can be seen that the implementation Figure 6The described federated learning system based on blockchain parallel voting consensus and multiple additional side chains can set multiple consensus node roles in each consensus cycle according to the consensus nodes of the blockchain network main chain, and adopt a fast parallel voting consensus algorithm for voting and election. It can optimize the voting consensus process and meet the security, autonomy and controllability of the election process, and achieve fast and efficient consensus.
[0279] Embodiment 4
[0280] See also Figure 7 , Figure 7 Schematic diagram of another structure of a federated learning system based on blockchain parallel voting consensus and multiple additional side chains disclosed in an embodiment of the present invention. Figure 7 As shown, the federated learning system based on blockchain parallel voting consensus and multiple additional side chains may include:
[0281] A memory 401 storing executable program codes;
[0282] a processor 402 coupled to the memory 401;
[0283] The processor 402 calls the executable program code stored in the memory 401 to execute the steps of the federated learning method based on blockchain parallel voting consensus and multiple additional side chains described in the first embodiment of the present invention or the second embodiment of the present invention.
[0284] Embodiment 5
[0285] An embodiment of the present invention discloses a computer storage medium, which stores computer instructions. When the computer instructions are called, they are used to execute the steps of the federated learning method based on blockchain parallel voting consensus and multiple additional side chains described in Embodiment 1 or Embodiment 2 of the present invention.
[0286] Embodiment 6
[0287] An embodiment of the present invention discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to enable a computer to execute the steps of the federated learning method based on blockchain parallel voting consensus and multiple additional side chains described in Example 1 or Example 2.
[0288] The system embodiment described above is only illustrative, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without paying creative labor.
[0289] Through the specific description of the above embodiments, 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 such an understanding, the above technical solution can be 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, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electronically erasable rewritable read-only memory (EEPROM), a compact disc (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0290] Finally, it should be noted that the federated learning method and system based on blockchain parallel voting consensus and multiple additional side chains disclosed in the embodiments of the present invention are only preferred embodiments of the present invention, which are only used to illustrate the technical solutions of the present invention, rather than to limit them. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features therein can be replaced by equivalents. 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 various embodiments of the present invention.
Claims
1. A federated learning method based on blockchain parallel voting consensus and multiple attached side chains, It is characterized in that The method comprises: Connect to the federated learning system and publish training tasks based on the task requirements of the demand side; Initializing the training parameters of the training task according to the demand information of the training task, and building a local model according to the training parameters, wherein the demand information includes: a consensus node set, a committee node set, a client node set, and a demand party set of the blockchain network; Performing model training and parameter updating on the local model through at least one client node in the client node set to obtain an updated model and updated parameters corresponding to each client node; Verifying the update model and the update parameters through at least one committee node of the committee node set to obtain the verified update model and update parameters, and performing consensus on-chain operations on the verified update model and update parameters; Aggregating the update parameter through at least one committee node in the committee node set to obtain an aggregated aggregate parameter, and verifying the aggregate parameter through a consensus node of the blockchain network to obtain a verified aggregate parameter; Setting the consensus node roles in each consensus cycle according to the consensus nodes of the blockchain network; Performing parallel voting consensus according to the consensus node roles to obtain voting results, and uploading the voting results to the chain, wherein the voting results include the verified aggregation parameters; The consensus node set of the blockchain network includes at least one consensus node, and the blockchain network includes a main chain network and a side chain network; The setting of the consensus node role in each consensus cycle according to the consensus node of the blockchain network includes: Calculate the corresponding accounting weight according to the available resources corresponding to the consensus node of the blockchain network; Determine the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm, and set the consensus node roles in each consensus cycle according to the accounting nodes; The step of calculating the corresponding accounting weight according to the available resources corresponding to the consensus nodes of the blockchain network includes: For each consensus node in the blockchain network, calculating computing resource parameters, storage resource parameters, and communication resource parameters corresponding to the consensus node; Calculate the accounting weight of the consensus node according to the computing resource parameter, the storage resource parameter and the communication resource parameter; Normalizing the accounting weights corresponding to all consensus nodes of the blockchain network to obtain a set of accounting weights corresponding to all consensus nodes after normalization; Determining the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm includes: Generate the key pair used for consensus operations in each consensus cycle based on the preset key length; Input the accounting weight set and the key pair used for consensus operation in each consensus cycle into a verifiable random function for calculation to obtain the output parameters and proof parameters of the accounting weight set; Calculate the randomness index of the accounting weight set according to the output parameters and proof parameters of the accounting weight set and a preset linear or nonlinear function; Based on the randomness indicator, the accounting nodes in each consensus cycle are extracted through a lottery algorithm, and the extracted accounting nodes in each consensus cycle are verified.
2. According to the federated learning method based on blockchain parallel voting consensus and multiple attached side chains as described in claim 1, It is characterized in that The training parameters include: a training data set, a training model parameter and a training requirement parameter, the client node set includes at least one client set, and the demander set includes at least one demander; After initializing the model parameters of the training task according to the requirement information of the training task and constructing the local model according to the model parameters, the method further includes: According to the consensus node information of the blockchain network, at least one consensus node is selected to form a committee node set, and the committee node set is used for task consensus; Creating a training channel for the training task and creating the training task, wherein the channel information of the training channel includes: a client node set, a committee node set and a channel identifier that participate in the training task; Publishing the training task to the blockchain network, and updating the local task list according to the training task; When it is detected that any target client node in the client node set selects any target training task in the local task list, the target training task is connected to the training task matching the target training task in the blockchain network, the contract corresponding to the training task is signed, and the target client node is added to the training channel corresponding to the training task.
3. According to the federated learning method based on blockchain parallel voting consensus and multiple additional side chains as described in claim 2, It is characterized in that The performing model training and parameter updating on the local model by at least one client node in the client node set to obtain an updated model and updated parameters corresponding to each client node includes: Performing a preset round of model training and parameter update on the local model through at least one client node in the client node set, to obtain an updated model and updated parameters of each round corresponding to each client node; And, the operation of verifying the update model and the update parameters by at least one committee node of the committee node set, and performing consensus on the verified update model and update parameters on the chain includes: Performing a correctness check on the update model and the update parameters by at least one committee node of the committee node set to obtain an update model and update parameters that pass the correctness check; Performing quality assessment on the updated model and updated parameters that have passed the correctness check to obtain quality assessment scores corresponding to the updated model and the updated parameters, and determining whether the quality assessment scores corresponding to the updated model and the updated parameters are greater than or equal to a preset score threshold; When it is determined that the quality assessment scores corresponding to the updated model and the updated parameters are greater than or equal to a preset score threshold, determining that the updated model and the updated parameters pass the quality assessment; A consensus of a preset consensus type is performed on the update model that has passed the quality assessment, and after the consensus is completed, the update model and the update parameters are uploaded to the side chain network.
4. The federated learning method based on blockchain parallel voting consensus and multiple attached side chains according to claim 2, It is characterized in that The step of aggregating the update parameter by at least one committee node in the committee node set to obtain an aggregated parameter includes: Aggregating, by at least one committee node in the committee node set, the updated parameters obtained by at least one client node in each round according to an aggregation algorithm and based on the model parameters stored in the local ledger, to obtain aggregated parameters of at least one client node in each round after aggregation; And, verifying the aggregation parameter through the consensus node of the blockchain network to obtain the verified aggregation parameter includes: Calculating a hash value of an aggregation parameter of at least one client node in each round through the committee node, and sending the hash value of the aggregation parameter to the committee node network where the committee node is located; Determining, through the committee node network, whether the hash value of the aggregation parameter calculated by other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node; When it is determined that the hash value of the aggregation parameter calculated by any target committee node among the other committee nodes is the same as the hash value of the aggregation parameter calculated by the committee node, marking the target committee node; Determine the number of times the target committee node is marked in each round, and sort the number of times marked to obtain the aggregation parameter corresponding to the largest number of times marked; The aggregation parameter corresponding to the maximum number of marking times is checked for correctness through the main chain network to obtain a target aggregation parameter that passes the correctness check.
5. The federated learning method based on blockchain parallel voting consensus and multiple attached side chains according to claim 1, It is characterized in that Based on the randomness indicator, the accounting nodes in each consensus cycle are extracted, including: Calculate the probability of drawing lots for each consensus node based on the randomness index ; Initialize the number of winning numbers for each consensus node is 0; With the probability of drawing lots As the initial input parameter, the number of winning numbers is The number of iterations and the actual number of successes are k times of Bernoulli trials, and it is determined whether the preset Bernoulli trial conditions are met; When it is determined that the preset Bernoulli test condition is met, the number of iterations is accumulated once, and the operation of the Bernoulli test is repeatedly performed; When it is determined that the preset Bernoulli test conditions are not met, the operation of the Bernoulli test is stopped, and the output result set of each consensus node is obtained. ; According to the output result set of each consensus node, a set of winning numbers of all consensus nodes is obtained, the winning numbers corresponding to all consensus nodes in the set of winning numbers are sorted, and the first z nodes with the largest number of winning numbers are selected as accounting nodes in each consensus cycle; Among them, the Represented as the output parameter, the Denoted as the proof parameter.
6. The federated learning method based on blockchain parallel voting consensus and multiple attached side chains according to claim 1, It is characterized in that The role type of the consensus node role includes: at least one of an accounting node, a leadership node, a potential accounting node, and a voting node.
7. A federated learning system based on blockchain parallel voting consensus and multiple attached side chains, It is characterized in that The system comprises: The access and release module is used to access the federated learning system and release training tasks according to the task requirements of the demand side; An initialization construction module, used to initialize the model parameters of the training task according to the demand information of the training task published by the access publishing module, and to build a local model according to the model parameters, wherein the demand information includes: a consensus node set, a committee node set, a client node set and a demand party set of the blockchain network; A training and updating module, configured to perform model training and parameter updating on the local model constructed by the initialization construction module through at least one client node in the client node set, and obtain an updated model and updated parameters corresponding to each client node; A verification module, used to verify the update model and the update parameters obtained by the training and updating of the training and updating module through at least one committee node of the committee node set, to obtain the updated model and update parameters that have passed the verification; A consensus chain module is used to perform consensus chain operations on the update model and update parameters verified by the verification module; an aggregation module, used for aggregating the update parameters updated by the training update module through at least one committee node in the committee node set to obtain aggregated aggregation parameters; The verification module is further used to verify the aggregation parameters aggregated by the aggregation module through the consensus node of the blockchain network to obtain the verified aggregation parameters; A setting module, used to set the consensus node role in each consensus cycle according to the consensus node of the blockchain network in the demand information of the training task published by the access publishing module; The consensus on-chain module is further used to perform parallel voting consensus according to the consensus node roles set by the setting module, obtain voting results, and perform on-chain operations on the voting results, wherein the voting results include the verified aggregation parameters; The consensus node set of the blockchain network includes at least one consensus node, and the blockchain network includes a main chain network and a side chain network; The specific manner in which the setting module sets the consensus node role in each consensus cycle according to the consensus node of the blockchain network is: Calculate the corresponding accounting weight according to the available resources corresponding to the consensus node of the blockchain network; Determine the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm, and set the consensus node roles in each consensus cycle according to the accounting nodes; The step of calculating the corresponding accounting weight according to the available resources corresponding to the consensus nodes of the blockchain network includes: For each consensus node in the blockchain network, calculating computing resource parameters, storage resource parameters, and communication resource parameters corresponding to the consensus node; Calculate the accounting weight of the consensus node according to the computing resource parameter, the storage resource parameter and the communication resource parameter; Normalizing the accounting weights corresponding to all consensus nodes of the blockchain network to obtain a set of accounting weights corresponding to all consensus nodes after normalization; Determining the accounting nodes in each consensus cycle based on the accounting weight and a preset algorithm includes: Generate the key pair used for consensus operations in each consensus cycle based on the preset key length; Input the accounting weight set and the key pair used for consensus operation in each consensus cycle into a verifiable random function for calculation to obtain the output parameters and proof parameters of the accounting weight set; Calculate the randomness index of the accounting weight set according to the output parameters and proof parameters of the accounting weight set and a preset linear or nonlinear function; Based on the randomness indicator, the accounting nodes in each consensus cycle are extracted through a lottery algorithm, and the extracted accounting nodes in each consensus cycle are verified.
8. A federated learning system based on blockchain parallel voting consensus and multiple attached side chains, It is characterized in that The system comprises: A memory storing executable program code; a processor coupled to the memory; The processor calls the executable program code stored in the memory to execute the federated learning method based on blockchain parallel voting consensus and multiple additional side chains as described in any one of claims 1 to 6.
9. A computer storage medium, It is characterized in that The computer storage medium stores computer instructions, which, when called, are used to execute the federated learning method based on blockchain parallel voting consensus and multiple additional side chains as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Model training method and device, electronic equipment and storage medium
CN114169387A
Credit behavior evidence storage method and system based on block chain and federal learning
CN115082180A
