A distributed storage method, device, equipment and medium for federated learning

Decentralized model aggregation is achieved in federated learning through distributed storage systems and PoA consensus mechanism, which solves the privacy leakage and computing power consumption problems of traditional federated learning, and improves model aggregation efficiency and data security.

CN114610813BActive Publication Date: 2024-12-20GUANGDONG UNIV OF TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210248089.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-14
Publication Date
2024-12-20
Estimated Expiration
2042-03-14

AI Technical Summary

Technical Problem

Traditional federated learning has problems such as single-point server failure, centralized server parameter privacy leakage, and model vulnerability to poisoning attacks. In the process of blockchain consensus, node computing power is consumed too much, resulting in increased storage pressure.

Method used

Adopting a distributed storage system and PoA consensus mechanism, a training task is released on the blockchain through smart contracts, the federated learning nodes train the model locally and generate hash values, and the authoritative nodes vote for aggregation model through voting, and the hash values ​​are in the blockchain. Store to reduce storage pressure and computing power consumption, and supervise authoritative node behavior to prevent illegal operations.

Benefits of technology

Effectively alleviate the pressure on blockchain storage, reduce the consumption of computing power resources in the consensus process, improve model aggregation efficiency, and ensure data privacy and security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114610813B_ABST
    Figure CN114610813B_ABST
Patent Text Reader

Abstract

The present application discloses a distributed storage method, device, equipment and medium for federated learning, the method comprising: receiving a training task issued by a task publisher on a smart contract; after obtaining an initial model through the smart contract, the federated learning node uses local data to train the initial model to obtain a local model, and determines the hash value of the local model; the federated learning node stores the hash value of the local model and the local model in a distributed storage system, and trades the hash value of the local model to the smart contract; after determining the authoritative node for this round of training by voting in the PoA consensus mechanism, the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model of this round in the smart contract; the authoritative node aggregates the local model to obtain a global model. The present application can reduce the computing power consumption of each node in the consensus process and the storage pressure of the blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of blockchain and federated learning, and in particular to a distributed storage method, apparatus, device and medium for federated learning. Background Art

[0002] With the rapid development and widespread application of artificial intelligence, the scale of neural network models is increasing, and ordinary hardware devices can no longer support large-scale neural network training. Therefore, as a distributed machine learning framework, federated learning is proposed to horizontally expand the scale of model training and overcome the problem of data silos. However, traditional federated learning has problems such as single-point server failure, centralized server parameter privacy leakage, and model vulnerability to poisoning attacks. On the one hand, when a single-point server is maliciously attacked or downtime occurs, the security and privacy of data and models will be threatened. On the other hand, the trained model is vulnerable to malicious tampering by the client, which greatly affects the training efficiency of the model.

[0003] In order to solve the above problems, a common method is to combine blockchain technology with the federated learning architecture, replacing the central aggregation of traditional federated learning with blockchain consensus technology to achieve decentralized federated learning.

[0004] Blockchain technology is a new distributed architecture and computing paradigm deployed on computer systems. Smart contracts can be deployed in blockchain systems to meet different business needs. A smart contract is a piece of program code running on the blockchain, and nodes can interact with smart contracts by sending transactions. In the business scenario of federated learning, the task publisher can declare the specific information of the training task on the smart contract and start the training task by publishing the contract.

[0005] At present, most blockchain-based federated learning systems use a consensus mechanism based on PoW (proof of work). In each round of consensus, mathematical tasks are issued first. In order to obtain accounting rights and block rewards, blockchain nodes will solve mathematical tasks through continuous enumeration and attempts, resulting in a large amount of computing power being consumed in the blockchain consensus process. Summary of the invention

[0006] The present application provides a distributed storage method, apparatus, device and medium for federated learning, which can not only reduce the consumption of node computing power in the consensus process, but also alleviate the storage pressure of the blockchain.

[0007] In order to achieve the above purpose, this application adopts the following technical solutions:

[0008] In a first aspect, the present application provides a distributed storage method for federated learning, including:

[0009] S1. Receive a training task published by a task publisher on a smart contract, wherein the smart contract is deployed on a blockchain;

[0010] S2. After obtaining the initial model through the smart contract, the federated learning node uses local data to train the initial model to obtain a local model, and determines the hash value of the local model;

[0011] S3. The federated learning node stores the hash value of the local model and the local model in a distributed storage system, and trades the hash value of the local model to the smart contract, wherein the hash value of the local model and the local model are in a key-value relationship;

[0012] S4. After each ordinary node determines the authoritative node for this round of training by voting in the PoA consensus mechanism, the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model of this round in the smart contract;

[0013] S5. The authoritative node aggregates the local models found to obtain the global model for this round of training, and after determining the hash value of the global model, stores the hash value of the global model and the global model in the distributed storage system.

[0014] By adopting the above technical solution, in the scenario where blockchain technology is introduced into federated learning, this solution first deploys smart contracts on the blockchain and writes the training tasks and basic models of federated learning into the smart contracts. Each federated learning node can use local data to train the basic model received through the smart contract, thereby realizing the integration and utilization of data scattered in various federated learning nodes under the premise of meeting data privacy requirements. After each federated learning node uses local data to train the basic model to obtain a local model, it will generate a corresponding hash value, and store the local model and the hash value in the distributed storage system through the key-value relationship, and at the same time trade the hash value to the smart contract. Storing hash values ​​in smart contracts in the blockchain, and then finding the corresponding model from the distributed storage system through the hash values, can effectively alleviate the storage pressure of the blockchain; when selecting authoritative nodes, each ordinary node can determine the voting object based on the recognition of other ordinary nodes, and then elect the authoritative node as the node responsible for the aggregation model. Since the recognition between ordinary nodes can be determined in advance, it is only necessary to record the voting objects of each ordinary node to determine the authoritative node. This can not only prevent ordinary nodes from consuming a lot of computing power to obtain accounting rights, but also reduce the consensus time and increase the speed of block generation, further reducing the consumption of computing power resources in the consensus process.

[0015] According to an implementation method of the first aspect of the present application, the method further includes:

[0016] Ordinary nodes monitor the behavior of authoritative nodes and determine whether the behavior of authoritative nodes is illegal;

[0017] If the behavior of the authoritative node is illegal, the ordinary nodes will vote again to determine the new authoritative node in this round of training.

[0018] According to an achievable method of the first aspect of the present application, the authoritative node aggregates the local models found to obtain a global model for this round of training, including:

[0019] The authoritative node verifies the local model it has found and obtains the accuracy of the local model;

[0020] The local model with accuracy higher than the threshold is used as the target local model, and all target local models are aggregated through the authoritative node to obtain the global model of this round of training.

[0021] According to an achievable method of the first aspect of the present application, the authoritative node aggregates the local models found to obtain a global model for this round of training, including:

[0022] The authoritative node verifies the local model found and obtains the accuracy of the local model;

[0023] After determining the weighted value of each local model according to its accuracy, the authoritative node weights and aggregates all local models according to the weighted value of each local model to obtain the global model for this round of training.

[0024] According to an achievable manner of the first aspect of the present application, after determining the hash value of the global model, the method further includes:

[0025] S6. The authoritative node trades the hash value of the global model to the smart contract;

[0026] S7. The federated learning node searches for the global model stored in the distributed storage system according to the hash value of the global model;

[0027] S8. Repeat steps S2-S8 using the global model as a new initial model until the global model meets the target conditions in the training task.

[0028] In a second aspect, the present application also provides a distributed storage device for federated learning, including:

[0029] A receiving module, used to receive a training task published by a task publisher on a smart contract, wherein the smart contract is deployed on a blockchain;

[0030] A training module, which is used for, after obtaining the initial model through the smart contract, the federated learning node to train the initial model using local data to obtain a local model, and to determine the hash value of the local model;

[0031] A storage module, used to control the federated learning node to store the hash value of the local model and the local model in a distributed storage system, and to trade the hash value of the local model to the smart contract, wherein the hash value of the local model and the local model are in a key-value relationship;

[0032] A consensus module, which is used to determine the authoritative node for this round of training by voting by ordinary nodes in the PoA consensus mechanism, and then the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model of this round in the smart contract;

[0033] The aggregation module is used to control the authoritative node to aggregate the local models found to obtain the global model of this round of training, and after determining the hash value of the global model, store the hash value of the global model and the global model in the distributed storage system.

[0034] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein the processor implements any step of the above-mentioned distributed storage method for federated learning when executing the computer program.

[0035] In a fourth aspect, an embodiment of the present application provides a storage medium, in which a computer program is stored. When the computer program is executed by a processor, the steps of any one of the above-mentioned distributed storage methods for federated learning are implemented.

[0036] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:

[0037] 1. Use the distributed storage system as the main storage container to store the local model obtained by the client after local training, as well as the global model aggregated by the authoritative node. The main storage hash value in the blockchain can effectively alleviate the storage pressure of the blockchain by finding the corresponding model from the distributed storage system through the hash value.

[0038] 2. This application uses PoA (proof of authority) as the consensus mechanism of the blockchain. Each ordinary node can determine the voting object based on the degree of recognition of other ordinary nodes, and then elect an authoritative node as the node responsible for the aggregation model. This can not only prevent ordinary nodes from consuming a large amount of computing power to prove their own workload in order to obtain aggregation capabilities, but also speed up the rate of determining authoritative nodes and increase the speed of block production, further reducing the consumption of computing resources in the consensus process.

[0039] 3. The ordinary nodes in this application have the right to supervise and elect, and can always monitor the behavior of the authoritative nodes. When the authoritative nodes have illegal behaviors that affect the aggregation of the model, new ordinary nodes will be elected through the PoA consensus mechanism to take over the work of the original authoritative nodes. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 A flow chart of a distributed storage method for federated learning provided in the first preferred embodiment of the present application;

[0041] Figure 2 A flow chart of a distributed storage method for federated learning provided in a second preferred embodiment of the present application;

[0042] Figure 3 A structural block diagram of a distributed storage device for federated learning provided in the third preferred embodiment of the present application;

[0043] Figure 4 A schematic diagram of the interaction between intelligent saving and task publisher, blockchain, federated learning node, and authoritative node in a distributed storage method for federated learning provided in a preferred embodiment of the present application;

[0044] Figure 5 A schematic diagram of the interaction between the distributed storage system, the federated learning node and the authoritative node in the distributed storage method for federated learning provided in the preferred embodiment of the present application;

[0045] Figure 6 A schematic diagram of the interaction between a federated learning node and a smart contract, a blockchain, and a distributed storage system in a distributed storage method for federated learning provided in a preferred embodiment of the present application;

[0046] Figure 7 An overall flow chart of a distributed storage method for federated learning provided in a preferred embodiment of the present application. DETAILED DESCRIPTION

[0047] 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 application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0048] The term "comprise" and any variations thereof in the specification and claims of the present application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.

[0049] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.

[0050] like Figure 1 As shown, the first preferred embodiment of the present application discloses a distributed storage method for federated learning, the method comprising:

[0051] S1. Receive a training task published by a task publisher on a smart contract, wherein the smart contract is deployed on a blockchain;

[0052] Specifically, Figure 4 As shown in the figure, a smart contract is a contract program deployed on a blockchain system that can be automatically executed when certain conditions are met. The task publisher can declare training task information such as training task requirements, initial model, and verification data set in the smart contract; the task publisher publishes the smart contract and deploys it on the blockchain to run, and can also broadcast the instructions to start or stop the task to the system by calling the function of the smart contract. Other nodes have no right to call the start task function and stop task function in the smart contract; the blockchain node corresponding to the blockchain consists of three parts, namely ordinary nodes, authoritative nodes, and federated learning nodes, among which ordinary nodes, authoritative nodes, and federated learning nodes are not limited to various personal computers, laptops, smart phones, tablets, portable wearable devices, etc.; the task publisher can also stipulate the token issuance system of the blockchain through the smart contract. For example, when the federated learning node uploads a model with qualified accuracy, it can get a certain token reward; when the authoritative node does not commit illegal behavior in the process of aggregating the model, it can also get a certain token reward.

[0053] The main functions of ordinary nodes are:

[0054] (1) In each round of training, vote to elect the authoritative node;

[0055] (2) Monitor whether the behavior of the authoritative node is illegal. If the authoritative node behaves illegally, the ordinary nodes can vote to remove the authoritative node from the system, and can vote again to elect a new authoritative node as the authoritative node for this round of training;

[0056] The main functions of the authority node are:

[0057] (1) Obtain the hash values ​​of all local models in this round by calling the function of the smart contract, and obtain the specific parameters of the local model from the distributed storage system through the hash value;

[0058] (2) Using the validation data set, observe the performance of the local model on the validation data set, determine whether the local model has converged, verify the accuracy of the local model, select the local model with qualified accuracy, perform model aggregation, and generate a global model;

[0059] (3) By calling the function of the smart contract, the hash value of the global model is uploaded to the smart contract, the status of the smart contract is updated, and the specific parameters of the global model are pushed to the distributed storage system.

[0060] Federated learning nodes:

[0061] (1) Receive token rewards from the blockchain. When a federated learning node uploads a legal model and it is packaged into the blockchain, it can receive certain token rewards.

[0062] (2) By calling the function on the smart contract, upload the hash value of the locally trained local model and obtain the hash value of the global model;

[0063] (3) The specific parameters of the trained local model are pushed to the distributed storage system, and the specific parameters of the global model are obtained in the distributed storage system through the hash value of the global model.

[0064] S2. After obtaining the initial model through the smart contract, the federated learning node uses local data to train the initial model to obtain a local model, and determines the hash value of the local model;

[0065] Specifically, federated learning nodes are not limited to various personal computers, laptops, smartphones, tablets, and portable wearable devices. The interaction between federated learning nodes and blockchains, smart contracts, and distributed storage systems is as follows: Figure 6 As shown in the figure, when the federated learning node uses local data to train the model and uploads the trained legal model to the blockchain, it can obtain token rewards from the blockchain.

[0066] Specifically, local data can be understood as the training data set used to train the model. The local data in each federated learning is different, so the local models trained by different federated learning nodes are different. The local model refers to the specific parameters of the local model. The model structure of the initial model is the same as the model structure of the local model. The difference between the initial model and the local model lies in the specific parameters in the model. The hash value of the local model is obtained by hashing the specific parameters of the local model. Different hash values ​​correspond to different parameters. Therefore, the corresponding model parameters can be found through the hash value of the model parameters.

[0067] S3. The federated learning node stores the hash value of the local model and the local model in a distributed storage system, and trades the hash value of the local model to the smart contract, wherein the hash value of the local model and the local model are in a key-value relationship;

[0068] Specifically, it can be understood as storing the hash value and the specific parameters of the corresponding local model in the distributed storage system in the form of key and value; since the distributed storage system is addressed based on content, and according to the nature of the hash function, without knowing the specific parameters of the model, there is no efficient way to calculate the specific parameters of the model from the hash value of the model, thus ensuring that privacy is not leaked. Among them, the interactive relationship between the authoritative node, the federated learning node and the distributed storage system is as follows: Figure 5 shown.

[0069] S4. After each ordinary node determines the authoritative node for this round of training by voting in the PoA consensus mechanism, the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model of this round in the smart contract;

[0070] Specifically, each ordinary node has the right to vote and the right to be elected (that is, it has the power to elect other ordinary nodes as authoritative nodes and the right to be elected as authoritative nodes). Each ordinary node cannot vote for itself. When voting, an ordinary node will determine the voting object based on its own recognition of other ordinary nodes. Different ordinary nodes have different recognition of the same ordinary node. The recognition of each ordinary node for other ordinary nodes is determined by multiple influencing factors, including: communication delay between two ordinary nodes, hardware factors of ordinary nodes (server CPU, memory, queue buffer size and performance, etc.), and network factors of ordinary nodes (server bandwidth, network delay, server vulnerability tracking, data set backlog, etc.).

[0071] Specifically, the method of searching for local models stored in the distributed storage system through hash values ​​is content-based addressing; the authoritative node only searches for the local model obtained in this round, and the local model of the previous round is not within the search range of the authoritative node this time.

[0072] S5. The authoritative node aggregates the local models found to obtain the global model for this round of training, and after determining the hash value of the global model, stores the hash value of the global model and the global model in the distributed storage system.

[0073] Specifically, the local models found by the authoritative node are all local models obtained in this round of training (i.e., specific parameters of the local models). The authoritative node aggregates these specific parameters of the local models to obtain the global model of this training.

[0074] Specifically, since each federated learning node uses different data for model training locally, the specific parameters of the local models obtained through training are also different. In order to fully utilize the local data of each federated learning node while ensuring data security, in each round of training, each node uses local data to train a local model, and then the authoritative node is responsible for aggregating the local models to obtain a new round of global models.

[0075] In one embodiment, the authoritative node aggregates the local models found to obtain a global model for this round of training, including:

[0076] The authoritative node verifies the local model it has found and obtains the accuracy of the local model;

[0077] The local model with accuracy higher than the threshold is used as the target local model, and all target local models are aggregated through the authoritative node to obtain the global model of this round of training.

[0078] Specifically, the authoritative node uses the verification data set to test the local model of this round, and judges whether the local model converges by observing the performance of the local model of this round on the verification data set, thereby obtaining the accuracy of the local model; the threshold is set in advance, and the local model with an accuracy higher than the threshold is the model with qualified accuracy. The models with qualified accuracy are screened out as the target local models, and these target local models are aggregated to obtain the global model of this round.

[0079] In this embodiment, the authoritative node will screen out models with qualified accuracy from the local models of this round, and only use the models with qualified accuracy for aggregation, which can further improve the accuracy of the aggregated model.

[0080] In one embodiment, the authoritative node aggregates the local models found to obtain a global model for this round of training, including:

[0081] The authoritative node verifies the local model found and obtains the accuracy of the local model;

[0082] After determining the weighted value of each local model according to its accuracy, the authoritative node weights and aggregates all local models according to the weighted value of each local model to obtain the global model for this round of training.

[0083] In this embodiment, the authoritative node verifies the local model uploaded in this round by verifying the data set to obtain the accuracy of the local model. After the authoritative node verifies the accuracy of the local model, it assigns weights to the local model according to the accuracy. The higher the accuracy, the higher the weight assigned to the local model. Through the weighted values ​​of each local model, the authoritative node performs weighted aggregation on the local model to obtain the global model of this round of training. Specifically, when the authoritative node uses the verification data set to verify the local model uploaded in this round, the accuracy of each local model is determined by observing the performance of the verification data set on all local models in this round. For example, the verification data set contains 100 labeled data. These 100 data are input into the local model to obtain 100 output results. The output results of these 100 data are compared with the corresponding labels respectively to determine the number of data whose output results of these 100 data are the same as the corresponding labels. If the number is 60, the accuracy of the model is 60 / 100 (i.e. 60%). The accuracy of each local model is used as the weighted value of each local model. The authoritative node weights and aggregates all local models according to the weighted values ​​of each local model to obtain the global model of this round of training. Through weighted aggregation, the generalization ability of the global model can be enhanced, and at the same time, the training results of each federated learning node can be fully utilized to reduce the waste of computing resources.

[0084] In one embodiment, after determining the hash value of the global model, the method further includes:

[0085] S6. The authoritative node trades the hash value of the global model to the smart contract;

[0086] S7. The federated learning node searches for the global model stored in the distributed storage system according to the hash value of the global model;

[0087] S8. Repeat steps S2-S8 using the global model as a new initial model until the global model meets the target conditions in the training task.

[0088] Specifically, the global model here refers to the specific parameters of the global model, wherein the model structures of the global model and the local model are the same, and the difference between the global model and the local model lies in the different specific parameters in the model.

[0089] Specifically, the method of searching for the global model stored in the distributed storage system through hash values ​​is content-based addressing. The authoritative node only searches for the global model obtained in this round. The global model of the previous round is not within the search range of the authoritative node this time. Only one global model is obtained in one round, and the global model obtained in this round can be used as the initial model for the next round of cyclic training.

[0090] Specifically, since the newly generated global model is continuously trained, the task publisher will set the training task of the global model in the smart contract at the same time as publishing the training task. For example, it can be the training accuracy of the global model, the number of training times of the global model, etc. If the training task is the training accuracy of the global model, then only when the trained global model reaches this training accuracy can the global model be used as the final output global model. Otherwise, the accuracy of the global model will continue to be improved through cyclic training.

[0091] In this embodiment, ordinary nodes vote to elect authoritative nodes as nodes of the aggregation model, which not only prevents ordinary nodes from consuming a large amount of computing power to prove their own workload in order to obtain aggregation capabilities, but also speeds up the rate of determining authoritative nodes and increases the speed of block generation.

[0092] The inventors discovered during the implementation of the present application that an authoritative node may experience poor communication status during operation, resulting in downtime. If this is not discovered in time, it will affect the working efficiency of the entire system.

[0093] In order to solve the technical problem that when the authoritative node is working, the communication status is poor, resulting in downtime and affecting the efficiency of the entire system, Figure 2 A distributed storage method for federated learning is provided in the second preferred embodiment of the present application. Figure 1 The first preferred embodiment shown is further improved, and the main steps of the method are described as follows:

[0094] S11. Receive a training task published by a task publisher on a smart contract, wherein the smart contract is deployed on a blockchain;

[0095] S22. After obtaining the initial model through the smart contract, the federated learning node trains the initial model using local data to obtain a local model, and determines a hash value of the local model;

[0096] S33. The federated learning node stores the hash value of the local model and the local model in a distributed storage system, and trades the hash value of the local model to the smart contract, wherein the hash value of the local model and the local model are in a key-value relationship.

[0097] S44, after each common node determines the authoritative node for this round of training by voting in the PoA consensus mechanism, the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model for this round in the smart contract, wherein the common node supervises the behavior of the authoritative node and determines whether the behavior of the authoritative node is illegal. If the behavior of the authoritative node is illegal, the common node will again determine the new authoritative node for this round of training by voting;

[0098] S55. The authoritative node aggregates the local models found to obtain the global model of this round of training, and after determining the hash value of the global model, stores the hash value of the global model and the global model in the distributed storage system.

[0099] Specifically, when the authoritative node is selected, the ordinary nodes will always monitor the behavior of the authoritative node. When the authoritative node has illegal operations, or the communication status of the authoritative node is poor and causes downtime, the ordinary nodes will judge the behavior of the authoritative node as illegal. At the same time, the ordinary nodes will again elect a new authoritative node from the ordinary nodes through voting to participate in the model aggregation work. Once the behavior of a node is determined to be illegal, it will be removed from the system and no longer have the right to be elected (that is, it will not have the right to be elected as an authoritative node again).

[0100] In this embodiment, through real-time supervision of the authoritative nodes by ordinary nodes, it is possible to promptly discover the problem of central server (authoritative node) downtime and select a new authoritative node to take over the work of the original authoritative node, thereby avoiding the impact of problems with the central server on the work efficiency of the entire system.

[0101] By adopting the above technical solutions, this solution introduces blockchain technology in the scenario of federated learning, such as Figure 7As shown in the figure, first, by deploying smart contracts on the blockchain and writing the training tasks and basic models of federated learning into the smart contracts, each federated learning node can use local data to train the basic model received through the smart contract, thereby realizing the integration and utilization of data scattered in various federated learning nodes under the premise of meeting data privacy requirements; after each federated learning node uses local data to train the basic model to obtain a local model, it will generate a corresponding hash value, and store the local model and the hash value in the distributed storage system through the key-value relationship, and at the same time trade the hash value to the smart contract, store the hash value in the smart contract in the blockchain, and then find the corresponding model from the distributed storage system through the hash value, which can effectively alleviate the storage pressure of the blockchain; when selecting the authoritative node, each ordinary node can determine it according to the recognition of other ordinary nodes The voting object is used to elect the authoritative node as the node responsible for the aggregation model. Since the recognition between ordinary nodes can be determined in advance, it is only necessary to record the voting objects of each ordinary node to determine the authoritative node. This can not only prevent ordinary nodes from consuming a lot of computing power to prove their own workload in order to obtain aggregation capabilities, but also reduce the consensus time and increase the speed of block generation, further reducing the consumption of computing power resources in the consensus process; ordinary nodes will also monitor the behavior of authoritative nodes at all times, and then when the authoritative nodes have illegal behaviors that affect the aggregation of the model, new ordinary nodes will be elected through the PoA consensus mechanism to take over the work of the original authoritative nodes; before aggregating the model, the authoritative node will screen out models with qualified accuracy from the local models of this round, and only use models with qualified accuracy for aggregation, which can further improve the accuracy of the aggregation model.

[0102] like Figure 3 The present application also discloses a distributed storage device for federated learning, the device comprising:

[0103] A receiving module 301 is used to receive a training task started by a task publisher by publishing a smart contract, wherein the smart contract is deployed on a blockchain;

[0104] A training module 302 is used for, after obtaining the initial model through the smart contract, the federated learning node uses local data to train the initial model to obtain a local model, and determines the hash value of the local model;

[0105] The storage module 303 is used to control the federated learning node to store the hash value of the local model and the local model in the distributed storage system, and trade the hash value of the local model to the smart contract, wherein the hash value of the local model and the local model are in a key-value relationship;

[0106] The consensus module 304 is used to determine the authoritative node for this round of training by voting in the PoA consensus mechanism through the ordinary nodes, and the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model of this round in the smart contract;

[0107] The aggregation module 305 is used to control the authoritative node to aggregate the local models found to obtain the global model of this round of training, and after determining the hash value of the global model, store the hash value of the global model and the global model in the distributed storage system.

[0108] The device also includes:

[0109] The ordinary node supervision module is used to control the ordinary nodes to supervise the behavior of the authoritative nodes and determine whether the behavior of the authoritative nodes is illegal; if the behavior of the authoritative nodes is illegal, the ordinary nodes will again determine the new authoritative nodes in this round of training through voting.

[0110] The aggregation module 305 further includes:

[0111] A verification unit is used to control the authoritative node to verify the local model found to obtain the accuracy of the local model;

[0112] The global model aggregation unit is used to take the local model with accuracy higher than the threshold as the target local model, aggregate all the target local models through the authoritative node, and obtain the global model of this round of training.

[0113] The device also includes:

[0114] A hash value-based search module is used for a hash value-based search method that is a content-based addressing method.

[0115] The device also includes:

[0116] A global model hash value transaction module, used to trade the hash value of the global model to the smart contract through the authoritative node;

[0117] A global model search module, used to search the global model stored in the distributed storage system according to the hash value of the global model through the federated learning node;

[0118] A loop module is used to repeat steps S2-S8 using the global model as a new initial model until the global model satisfies the training task in the smart contract.

[0119] In one embodiment, an electronic device is provided, specifically a computer device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, and when the processor executes the computer program, the steps of any one of the above-mentioned distributed storage methods for federated learning are implemented.

[0120] In one embodiment, a storage medium is provided, specifically a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, any step of the above-mentioned distributed storage method for federated learning is performed.

[0121] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications are also considered to be within the scope of protection of the present application.

[0122] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a ROM (Read-Only Memory) or a RAM (Random Access Memory), etc.

Claims

1. A distributed storage method for federated learning, characterized in that: include: S1. Receive a training task published by a task publisher on a smart contract, wherein the smart contract is deployed on a blockchain; S2. After obtaining the initial model through the smart contract, the federated learning node uses local data to train the initial model to obtain a local model, and determines the hash value of the local model; S3. The federated learning node stores the hash value of the local model and the local model in a distributed storage system, and trades the hash value of the local model to the smart contract, wherein the hash value of the local model and the local model are in a key-value relationship; S4. After each ordinary node determines the authoritative node for this round of training by voting in the PoA consensus mechanism, the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model of this round in the smart contract; S5. The authoritative node verifies the local model found to obtain the accuracy of the local model; after determining the weighted value of each local model according to the accuracy of each local model, the authoritative node weights and aggregates all local models according to the weighted value of each local model to obtain the global model of this round of training, or takes the local model with an accuracy higher than the threshold as the target local model, aggregates all the target local models through the authoritative node to obtain the global model of this round of training; after determining the hash value of the global model, the hash value of the global model and the global model are stored in the distributed storage system.

2. The distributed storage method for federated learning according to claim 1, characterized in that: The method further comprises: Ordinary nodes monitor the behavior of authoritative nodes and determine whether the behavior of authoritative nodes is illegal; If the behavior of the authoritative node is illegal, the ordinary nodes will vote again to determine the new authoritative node in this round of training.

3. The distributed storage method for federated learning according to claim 1, characterized in that: After determining the hash value of the global model, it also includes: S6. The authoritative node trades the hash value of the global model to the smart contract; S7. The federated learning node searches for the global model stored in the distributed storage system according to the hash value of the global model; S8. Repeat steps S2-S8 using the global model as a new initial model until the global model meets the target conditions in the training task.

4. A distributed storage device for federated learning, characterized in that: include: A receiving module, used to receive a training task published by a task publisher on a smart contract, wherein the smart contract is deployed on a blockchain; A training module, which is used for, after obtaining the initial model through the smart contract, the federated learning node to train the initial model using local data to obtain a local model, and to determine the hash value of the local model; A storage module, used to control the federated learning node to store the hash value of the local model and the local model in a distributed storage system, and to trade the hash value of the local model to the smart contract, wherein the hash value of the local model and the local model are in a key-value relationship; A consensus module, which is used to determine the authoritative node for this round of training by voting by ordinary nodes in the PoA consensus mechanism, and then the authoritative node searches for the local model stored in the distributed storage system according to the hash value of the local model of this round in the smart contract; The aggregation module is used to control the authoritative node to test the local models found to obtain the accuracy of the local models; after determining the weighted value of each local model according to the accuracy of each local model, the authoritative node weightedly aggregates all local models according to the weighted value of each local model to obtain the global model of this round of training, or, takes the local model with an accuracy higher than the threshold as the target local model, aggregates all the target local models through the authoritative node to obtain the global model of this round of training; after determining the hash value of the global model, the hash value of the global model and the global model are stored in the distributed storage system.

5. A computer device, characterized in that It includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor. When the processor executes the computer program, the steps of the distributed storage method for federated learning as described in any one of claims 1 to 3 are implemented.

6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the distributed storage method for federated learning as described in any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Federated learning system and method based on block chain

    CN111212110A

  • Federal learning data tamper-proof monitoring method and related device

    CN113094761A