Distributed model training method and device based on blockchain, and electronic device
By adopting a distributed model training method based on blockchain in the edge computing scenario, the privacy disputes and security risks in edge computing are solved, and the model training of local data does not leave the local area is achieved, ensuring the security and accuracy of the data.
Patent Information
- Application Number
- CN202111398959.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-19
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2041-11-19
AI Technical Summary
In the edge computing scenario, the existing technology has privacy disputes and security risks. Data may be tampered with during transmission, and model training requires a large amount of data, but users are unwilling to share, resulting in the inability to complete model training.
A distributed model training method based on blockchain is adopted to ensure that local data does not leave the local area for training, and the changes in model parameters are recorded on the blockchain to ensure the security and traceability of data.
It realizes model training without leaving the local device, ensures data security and accuracy, solves privacy disputes and security risks in edge computing scenarios, and improves the efficiency of model training.
Smart Images

Figure CN114202014B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a distributed model training method and device based on blockchain, an electronic device, and a computer-readable storage medium. Background Art
[0002] In edge computing scenarios, edge servers are deployed near the data source to provide computing and model training services for local devices that cannot complete large-scale training and computing. Edge computing applications are initiated at the edge of the data source. Compared with cloud computing, the process of data transfer on the network is reduced, so the resulting network services will be faster. It is very well used in real-time business, application intelligence, security and privacy protection in some industries. However, at this stage, edge computing still has privacy disputes. Although data can be calculated at the near end, it still leaves the local device. At the same time, there are security risks in edge computing scenarios, and data may be tampered with during transmission. The introduction of machine learning and artificial intelligence has enabled many tasks to be completed through model training, such as image recognition and speech recognition. However, model training requires a large amount of data, which is stored in the user's local device. In order to protect their privacy, users are unwilling to share data, but without data, model training cannot be completed to provide users with better and more convenient services. Therefore, it is urgent to solve this technical problem. Summary of the invention
[0003] In view of the above problems, this application is proposed to provide a distributed model training method and device based on blockchain, an electronic device and a computer-readable storage medium that overcome the above problems or at least partially solve the above problems. The technical solution is as follows:
[0004] In the first aspect, a distributed model training method based on blockchain is provided, which is applied to the publisher of training tasks, including:
[0005] Determine the task-related content and initial model structure corresponding to the model training task;
[0006] Send the task-related content and the initial model structure to all edge nodes participating in model training; wherein each edge node trains the initial parameters in the initial model structure based on local training data and the task-related content to obtain trained local model parameters, and then when data is exchanged between edge nodes, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain;
[0007] When all edge nodes have participated in the aggregation, the edge node that has participated in the aggregation the most times is calculated according to the aggregated local model parameters saved on the blockchain, and the edge node that has participated in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in the model training, so that the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the aggregation the most times.
[0008] In a possible implementation, after the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the largest number of aggregation times, the method further includes:
[0009] Receive evaluation results of the current model structure from all edge nodes participating in model training based on local model parameters;
[0010] Analyze whether the current model structure meets the task conditions according to the evaluation results;
[0011] If yes, the current model structure is deployed to each edge node for use;
[0012] If not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and the task-related content. After the training is completed, aggregation is performed again by relying on information interaction between edge nodes.
[0013] In the second aspect, a distributed model training method based on blockchain is provided, which is applied to edge nodes participating in model training, including:
[0014] Receive task-related content and initial model structure corresponding to the model training task sent by the training task publisher;
[0015] Based on the local training data and the task-related content, the initial parameters in the initial model structure are trained to obtain trained local model parameters;
[0016] When data is exchanged between edge nodes, local model parameters are carried in the transmitted data packets. The local model parameters are aggregated after passing through each edge node to obtain the aggregated local model parameters, which are then saved to the blockchain.
[0017] Receive instructions initiated by the publisher of the training task, in which the edge node that has participated in the largest number of aggregations broadcasts its local model parameters to other edge nodes that participate in the model training;
[0018] According to the instruction, the edge node that participates in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in model training, and the other edge nodes each update their own local model parameters to the local model parameters broadcast by the edge node that participates in the aggregation the most times.
[0019] In a possible implementation, when data is exchanged between edge nodes, local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, including:
[0020] Data interaction between edge nodes can be called data interaction between source nodes and destination nodes, and it passes through one or more relay nodes in the middle;
[0021] The transmitted data packets carry not only the interactive information data required for data interaction, but also the local model parameters trained by the source node;
[0022] Whenever a data packet passes through a relay node, the relay node receives the local model parameters in the data packet, and aggregates the local model parameters with the local model parameters of the relay node by calculating the average value of each dimension to obtain aggregated local model parameters; the aggregated local model parameters are then used to replace the local model parameters in the data packet and the local model parameters of the relay node; the data packet is then transmitted to the next relay node, and the above aggregation process is performed in the next relay node.
[0023] In a possible implementation, after the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the largest number of aggregation times, the method further includes:
[0024] All edge nodes participating in model training evaluate the current model structure based on local model parameters and send the evaluation results to the training task publisher; the training task publisher analyzes whether the current model structure meets the task conditions based on the evaluation results; if so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and the task-related content. After the training is completed, aggregation is performed again based on information interaction between edge nodes;
[0025] Receiving the training instructions sent by the publisher of the training task, each edge node trains the current model structure based on local training data and the task-related content. After the training is completed, aggregation is performed again by relying on information interaction between edge nodes.
[0026] In a third aspect, a distributed model training device based on blockchain is provided, which is applied to the publisher of training tasks, including:
[0027] A determination module, used to determine the task-related content and initial model structure corresponding to the model training task;
[0028] A sending module, used to send the task-related content and the initial model structure to all edge nodes participating in model training; wherein each edge node trains the initial parameters in the initial model structure based on local training data and the task-related content to obtain trained local model parameters, and then when data is exchanged between edge nodes, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain;
[0029] The calculation module is used to calculate the edge node that has participated in the aggregation the most times according to the aggregated local model parameters stored on the blockchain after all edge nodes have participated in the aggregation, and the edge node that has participated in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in the model training, so that the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the aggregation the most times.
[0030] In a possible implementation manner, the device further includes:
[0031] The evaluation module is used to receive the evaluation results of the current model structure evaluated by all edge nodes participating in the model training based on the local model parameters; analyze whether the current model structure meets the task conditions according to the evaluation results; if so, deploy the current model structure to each edge node for use; if not, use the local model parameters as the initial parameters, and each edge node trains the current model structure based on the local training data and the task-related content, and after the training is completed, it relies on the information interaction between the edge nodes for aggregation again.
[0032] In a fourth aspect, a distributed model training device based on blockchain is provided, which is applied to edge nodes participating in model training, including:
[0033] A receiving module, used to receive task-related content and an initial model structure corresponding to the model training task sent by the training task publisher;
[0034] A training module is used to train the initial parameters in the initial model structure based on local training data and the task-related content to obtain trained local model parameters; when data is exchanged between edge nodes, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain; an instruction initiated by the publisher of the training task to broadcast the local model parameters on the edge node that participates in the aggregation the most times to other edge nodes participating in the model training; according to the instruction, the edge node that participates in the aggregation the most times broadcasts the local model parameters on it to other edge nodes participating in the model training, and the other edge nodes each update their own local model parameters to the local model parameters broadcast by the edge node that participates in the aggregation the most times.
[0035] In a fifth aspect, an electronic device is provided, comprising a processor and a memory, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute any of the above-mentioned distributed model training methods based on blockchain.
[0036] In a sixth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program is configured to execute any of the above-mentioned blockchain-based distributed model training methods at runtime.
[0037] Through the above technical scheme, the distributed model training method and device based on blockchain, electronic device and computer-readable storage medium provided by the embodiments of the present application adopt a distributed method instead of a centralized method to train model parameters through the edge nodes participating in the model training, so that the model is trained on the basis of local data without leaving the local area, thereby ensuring the security of the data; and, the embodiments of the present application record the changes of model parameters on the blockchain, ensuring that the information can be traced and tamper-proof, and improving the accuracy of model training; in addition, the embodiments of the present application utilize the data transmission process in data interaction to transmit parameters and complete aggregation, which reduces the amount of communication data compared with transmitting the model and completing aggregation separately, and improves the transmission efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.
[0039] Figure 1 A flowchart of a distributed model training method based on blockchain and applied to a training task publisher according to an embodiment of the present application is shown;
[0040] Figure 2A flowchart of a distributed model training method based on blockchain applied to edge nodes participating in model training according to an embodiment of the present application is shown;
[0041] Figure 3 A flowchart of a distributed model training method based on blockchain in combination with a training task publisher and edge nodes participating in model training according to an embodiment of the present application is shown;
[0042] Figure 4 A structural diagram of a distributed model training device based on blockchain applied to a training task publisher according to an embodiment of the present application is shown;
[0043] Figure 5 A structural diagram of a distributed model training device based on blockchain applied to edge nodes participating in model training according to an embodiment of the present application is shown;
[0044] Figure 6 A structural diagram of an electronic device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0045] The exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0046] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that such use is interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the term "including" and its variants are to be interpreted as open-ended terms meaning "including but not limited to".
[0047] The present application embodiment provides a distributed model training method based on blockchain, which can be applied to the training task publisher, which can be a server, a personal computer, a smart phone, a tablet computer, a smart watch and other electronic devices, such as Figure 1 As shown, the distributed model training method based on blockchain may include the following steps S101 to S103:
[0048] Step S101, determining task-related content and an initial model structure corresponding to a model training task;
[0049] Step S102, sending the task-related content and the initial model structure to all edge nodes participating in the model training; wherein each edge node trains the initial parameters in the initial model structure based on the local training data and the task-related content to obtain the trained local model parameters, and then when data is exchanged between edge nodes, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated after each edge node to obtain the aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain;
[0050] Step S103, when all edge nodes have participated in the aggregation, the edge node that has participated in the aggregation the most times is calculated according to the aggregated local model parameters saved on the blockchain, and the edge node that has participated in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in the model training, so that the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the aggregation the most times.
[0051] The embodiment of the present application uses a distributed approach instead of a centralized approach to train model parameters through the edge nodes participating in model training, so that the model is trained without leaving the local data, thereby ensuring the security of the data; and, the embodiment of the present application records the changes in model parameters on the blockchain, thereby ensuring that the information is traceable and tamper-proof, thereby improving the accuracy of model training; in addition, the embodiment of the present application utilizes the data transmission process in data interaction to transmit parameters and complete aggregation, thereby reducing the amount of communication data compared to transmitting the model and completing aggregation separately, thereby improving transmission efficiency.
[0052] A possible implementation method is provided in an embodiment of the present application. After obtaining the aggregated local model parameters in the above step S102, the aggregated local model parameters are used to replace the local model parameters in the data packet and the local model parameters on the edge node where the aggregation processing is performed.
[0053] The embodiment of the present application provides a possible implementation method. After the other edge nodes in the above step S103 update their own local model parameters to the local model parameters broadcasted by the edge node participating in the aggregation the most times, the following steps A1 to A4 may also be included:
[0054] Step A1, receiving evaluation results of all edge nodes participating in model training on the current model structure based on local model parameters;
[0055] Step A2: Analyze whether the current model structure meets the task conditions according to the evaluation results; if yes, proceed to step A3; if no, proceed to step A4;
[0056] Step A3: deploy the current model structure to each edge node for use;
[0057] In step A4, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and task-related content. After the training is completed, aggregation is performed again by relying on information interaction between edge nodes.
[0058] In this embodiment, it is analyzed whether the current model structure meets the task conditions based on the evaluation results. If so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and task-related content. After the training is completed, the information interaction between the edge nodes is relied upon for aggregation again, which can improve the accuracy of the model training and meet the task requirements of the model training.
[0059] The embodiment of the present application provides a distributed model training method based on blockchain, which can be applied to edge nodes participating in model training. The edge nodes can specifically be electronic devices such as servers and personal computers, such as Figure 2 As shown, the distributed model training method based on blockchain may include the following steps S201 to S205:
[0060] Step S201, receiving task-related content and an initial model structure corresponding to a model training task sent by a training task publisher;
[0061] Step S202, training the initial parameters in the initial model structure based on the local training data and task-related content to obtain trained local model parameters;
[0062] Step S203: When data is exchanged between edge nodes, local model parameters are carried in the transmitted data packets. The local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved in the blockchain.
[0063] Step S204, receiving an instruction initiated by the publisher of the training task, in which the edge node that has participated in the largest number of aggregations broadcasts its local model parameters to other edge nodes that have participated in the model training;
[0064] Step S205, according to the instruction, the edge node that participates in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in model training, and the other edge nodes each update their own local model parameters to the local model parameters broadcast by the edge node that participates in the aggregation the most times.
[0065] The embodiment of the present application uses a distributed approach instead of a centralized approach to train model parameters through the edge nodes participating in model training, so that the model is trained without leaving the local data, ensuring the security of the data and solving the problems of privacy disputes and over-reliance on core servers in centralized model training in edge computing scenarios; moreover, the embodiment of the present application records the changes in model parameters on the blockchain, making it feasible to trace the trusted source of key data, ensuring the traceability and tamper-proofing of information, and improving the accuracy of model training; in addition, the embodiment of the present application utilizes the data transmission process in data interaction to transmit parameters and complete aggregation, which reduces the amount of communication data compared to transmitting the model and completing aggregation separately, and improves the transmission efficiency.
[0066] A possible implementation method is provided in an embodiment of the present application. After obtaining the aggregated local model parameters in step S203 above, the aggregated local model parameters can replace the local model parameters in the data packet and the local model parameters on the edge node where the aggregation processing is located respectively.
[0067] A possible implementation method is provided in the embodiment of the present application. In the above step S203, when data is exchanged between edge nodes, local model parameters are carried in the transmitted data packets. The local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain. Specifically, the following steps B1 to B3 may be included:
[0068] Step B1, data interaction between edge nodes, which may be referred to as data interaction between a source node and a destination node, and passing through one or more relay nodes in between;
[0069] Step B2, the transmitted data packet carries not only the interactive information data required for data interaction, but also the local model parameters obtained by training of the source node;
[0070] Step B3, whenever a data packet passes through a relay node, the relay node receives the local model parameters in the data packet, and aggregates the local model parameters with the local model parameters of the relay node to calculate the average value of each dimension, to obtain aggregated local model parameters; then, the aggregated local model parameters replace the local model parameters in the data packet and the local model parameters of the relay node; then, the data packet is transmitted to the next relay node, and the above aggregation process is performed in the next relay node.
[0071] The embodiment of the present application utilizes the data transfer process in data interaction to transmit parameters and complete aggregation, which reduces the amount of data communicated and improves transmission efficiency compared to transmitting the model and completing aggregation separately. In addition, the real-time update of local model parameters is ensured through aggregation, thereby improving the accuracy of the model.
[0072] The embodiment of the present application provides a possible implementation method. After the other edge nodes in the above step S205 update their own local model parameters to the local model parameters broadcasted by the edge node participating in the aggregation the most times, the following steps C1 to C2 may also be included:
[0073] Step C1, all edge nodes participating in model training evaluate the current model structure based on local model parameters, and send the evaluation results to the training task publisher; the training task publisher analyzes whether the current model structure meets the task conditions based on the evaluation results; if so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and task-related content. After the training is completed, aggregation is performed again based on information interaction between edge nodes;
[0074] Step C2, receiving the training instructions sent by the publisher of the training task, each edge node trains the current model structure based on local training data and task-related content, and after the training is completed, aggregation is performed again by relying on information interaction between edge nodes.
[0075] In this embodiment, it is analyzed whether the current model structure meets the task conditions based on the evaluation results. If so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and task-related content. After the training is completed, the information interaction between the edge nodes is relied upon for aggregation again, which can improve the accuracy of the model training and meet the task requirements of the model training.
[0076] The above introduces Figure 1 and Figure 2 The implementation methods of each link of the illustrated embodiment are described below in detail through a specific embodiment to introduce the distributed model training method based on blockchain in the embodiment of the present application.
[0077] Figure 3 A flowchart of a distributed model training method based on blockchain in combination with a training task publisher and edge nodes participating in model training according to an embodiment of the present application is shown, as shown in FIG. Figure 3 As shown, the distributed model training method based on blockchain may include the following steps S301 to S306:
[0078] In step S301, the training task publisher proposes a model training task, determines the task-related content and initial model structure corresponding to the model training task, and sends the task-related content and initial model structure to all edge nodes participating in the model training.
[0079] In this step, the model training task is, for example, a speech recognition task or an image recognition task, etc. According to the model training task, the initial model structure can be determined, which may include the number of layers of the model, the initial parameters of the model, etc.
[0080] In step S302, each edge node participating in the model training trains the initial parameters in the initial model structure based on the local training data and task-related content to obtain trained local model parameters.
[0081] In this step, the number of local training rounds and the amount of data sent in one training can be specified by the publisher of the training task, and the specific information can be obtained in the task-related content. The local training stops after completing the specified number of rounds of training as required.
[0082] Step S303, data interaction is performed between edge nodes, which may be referred to as data interaction between a source node and a destination node, and passes through one or more relay nodes in between; the transmitted data packet carries not only the interaction information data required for data interaction, but also the local model parameters trained by the source node; whenever a data packet passes through a relay node, the relay node receives the local model parameters in the data packet, and aggregates the local model parameters with the local model parameters of the relay node by calculating the average value of each dimension to obtain the aggregated local model parameters; and then replaces the local model parameters in the data packet and the local model parameters of the relay node with the aggregated local model parameters; the data packet is then transmitted to the next relay node, and the above aggregation process is performed in the next relay node.
[0083] In this step, information interaction may occur between edge nodes due to various needs, such as delivering emails, chat messages, text messages, etc. These information packets can carry some additional information when transmitted. In addition, when two edge nodes interact with data, other nodes may be passed from the source node to the destination node, which can be called relay nodes. Therefore, when two edge nodes interact with data, the information to be sent is sent from the source node and reaches the destination node through other nodes in the middle. The information packet sent not only carries the interactive information required for information transmission, but also carries the local model parameters trained by the source node. Each time the information packet passes through an edge node, it is aggregated with the local model parameters trained by the node. The aggregation method is to calculate the mean of the local model parameters carried in the data packet and the local model parameters of the relay node passed by, and save the obtained mean in the data packet. At the same time, the calculated mean will also overwrite the local model parameters of the relay node passed by to become the new local model parameters. The mean will also be saved on the chain to prevent tampering. After the parameter aggregation of the sent data packet is completed, it will continue to be sent to the next node to complete the same aggregation and update work. Once the data packet is sent from the source node to the destination node and the aggregation task of other relay nodes from the source node to the destination node is completed, the aggregation task is completed. Since each node will interact frequently, each node will participate in this distributed training process until all nodes participate in this aggregation process. Later, the node that has participated in the most aggregations will broadcast its parameters to all nodes, and all nodes will save the new parameters.
[0084] In step S304, each edge node will send interactive information regularly or irregularly, and data packets will be sent from different source nodes to the destination node; the data packet completes aggregation with all the nodes it passes through during the transmission process; when all participating nodes have participated in parameter aggregation, the aggregation task is stopped; at this time, the data packets forwarded by the transmission information between the nodes no longer carry parameter information.
[0085] Step S305: After all edge nodes have participated in the aggregation, the training task publisher calculates the edge node that has participated in the aggregation the most times based on the aggregated local model parameters saved on the blockchain. The edge node that has participated in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in the model training, so that the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the aggregation the most times.
[0086] In step S306, all edge nodes participating in model training evaluate the current model structure based on local model parameters and send the evaluation results to the training task publisher; the training task publisher then analyzes whether the current model structure meets the task conditions based on the evaluation results; if so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and task-related content. After the training is completed, aggregation is performed again based on information interaction between edge nodes, that is, the above steps S303 to S305 are repeated.
[0087] The embodiment of the present application uses a distributed method instead of a centralized method to train model parameters through the edge nodes participating in model training, so that the local data does not leave the local basis to train the model, ensuring the security of the data, and solving the problems of privacy disputes and over-reliance on core servers in centralized model training in edge computing scenarios; and, the embodiment of the present application records the changes of model parameters on the blockchain, making the trusted traceability of key data feasible, ensuring that the information can be traced and tampered, and improving the accuracy of model training; in addition, the embodiment of the present application utilizes the data transmission process in data interaction to transmit parameters and complete aggregation, which reduces the amount of data communicated compared with the model transmission and completion of aggregation alone, and mentions the transmission efficiency. Further, according to the evaluation results, analyze whether the current model structure meets the task conditions. If so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as the initial parameters, and each edge node trains the current model structure based on local training data and task-related content. After the training is completed, it is aggregated again by relying on the information interaction between edge nodes, which can improve the accuracy of model training and meet the task requirements of model training.
[0088] It should be noted that, in practical applications, all possible implementation methods described above can be arbitrarily combined to form possible embodiments of the present application, which will not be described one by one here.
[0089] Based on the blockchain-based distributed model training methods provided in the above embodiments, and based on the same inventive concept, the embodiments of the present application also provide a blockchain-based distributed model training device.
[0090] Figure 4 The structure diagram of a distributed model training device based on blockchain applied to a training task publisher according to an embodiment of the present application is shown. Figure 4 As shown, the blockchain-based distributed model training device may include a determination module 410, a sending module 420 and a calculation module 430.
[0091] A determination module 410, for determining task-related content and an initial model structure corresponding to a model training task;
[0092] The sending module 420 is used to send the task-related content and the initial model structure to all edge nodes participating in the model training; wherein each edge node trains the initial parameters in the initial model structure based on the local training data and the task-related content to obtain the trained local model parameters, and then when the edge nodes interact with each other, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated after each edge node to obtain the aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain;
[0093] The calculation module 430 is used to calculate the edge node that has participated in the aggregation the most times according to the aggregated local model parameters stored on the blockchain after all edge nodes have participated in the aggregation. The edge node that has participated in the aggregation the most times broadcasts its local model parameters to other edge nodes that have participated in the model training, so that the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the aggregation the most times.
[0094] A possible implementation method is provided in the embodiments of the present application. Figure 4 The displayed device may also include an evaluation module for receiving the evaluation results of all edge nodes participating in model training on the current model structure based on local model parameters; analyzing whether the current model structure meets the task conditions based on the evaluation results; if so, deploying the current model structure to each edge node for use; if not, using the local model parameters as initial parameters, and each edge node trains the current model structure based on local training data and task-related content, and after the training is completed, aggregation is performed again relying on information interaction between edge nodes.
[0095] Figure 5 The structure diagram of a distributed model training device based on blockchain applied to edge nodes participating in model training according to an embodiment of the present application is shown. Figure 5 As shown, the blockchain-based distributed model training device may include a receiving module 510 and a training module 520.
[0096] The receiving module 510 is used to receive the task-related content and the initial model structure corresponding to the model training task sent by the training task publisher;
[0097] The training module 520 is used to train the initial parameters in the initial model structure based on the local training data and task-related content to obtain the trained local model parameters; when data is exchanged between edge nodes, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain the aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain; an instruction initiated by the publisher of the training task to broadcast the local model parameters on the edge node that participates in the aggregation the most times to other edge nodes participating in the model training; according to the instruction, the edge node that participates in the aggregation the most times broadcasts the local model parameters on it to other edge nodes participating in the model training, and the other edge nodes each update their own local model parameters to the local model parameters broadcast by the edge node that participates in the aggregation the most times.
[0098] A possible implementation method is provided in an embodiment of the present application, where the training module 520 is further configured to:
[0099] Data interaction between edge nodes can be called data interaction between source nodes and destination nodes, and it passes through one or more relay nodes in the middle;
[0100] The transmitted data packets carry not only the interactive information data required for data interaction, but also the local model parameters trained by the source node;
[0101] Whenever a data packet passes through a relay node, the relay node receives the local model parameters in the data packet, and aggregates the local model parameters with the local model parameters of the relay node by calculating the average value of each dimension to obtain aggregated local model parameters; the aggregated local model parameters are then used to replace the local model parameters in the data packet and the local model parameters of the relay node; the data packet is then transmitted to the next relay node, and the above aggregation process is performed in the next relay node.
[0102] A possible implementation method is provided in an embodiment of the present application, where the training module 520 is further configured to:
[0103] After other edge nodes have updated their own local model parameters to the local model parameters broadcast by the edge node that has participated in the aggregation the most times, all edge nodes participating in the model training evaluate the current model structure based on the local model parameters and send the evaluation results to the training task publisher; the training task publisher analyzes whether the current model structure meets the task conditions based on the evaluation results; if so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as the initial parameters, and each edge node trains the current model structure based on local training data and task-related content. After the training is completed, aggregation is performed again based on information interaction between edge nodes;
[0104] After receiving the training instructions sent by the publisher of the training task, each edge node trains the current model structure based on local training data and task-related content. After the training is completed, it is aggregated again by relying on information interaction between edge nodes.
[0105] Based on the same inventive concept, an embodiment of the present application also provides an electronic device, including a processor and a memory, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the blockchain-based distributed model training method of any one of the above embodiments.
[0106] In an exemplary embodiment, an electronic device is provided, such as Figure 6 As shown, Figure 6 The electronic device 600 shown includes: a processor 601 and a memory 603. The processor 601 and the memory 603 are connected, such as through a bus 602. Optionally, the electronic device 600 may also include a transceiver 604. It should be noted that in actual applications, the transceiver 604 is not limited to one, and the structure of the electronic device 600 does not constitute a limitation on the embodiments of the present application.
[0107] Processor 601 may be a CPU (Central Processing Unit), a general purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 601 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0108] The bus 602 may include a path to transmit information between the above components. The bus 602 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 602 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0109] The memory 603 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to these.
[0110] The memory 603 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 601. The processor 601 is used to execute the application code stored in the memory 603 to implement the contents shown in the above method embodiment.
[0111] Among them, electronic devices include but are not limited to: mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 6 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0112] Based on the same inventive concept, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, wherein the computer program is configured to execute the blockchain-based distributed model training method of any one of the above embodiments when running.
[0113] Those skilled in the art can clearly understand that the specific working processes of the systems, devices, and modules described above can refer to the corresponding processes in the aforementioned method embodiments, and for the sake of brevity, they are not further described here.
[0114] Those skilled in the art can understand that the technical solution of the present application can be essentially or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, which includes a number of program instructions, so that an electronic device (such as a personal computer, a server, or a network device, etc.) executes all or part of the steps of the method described in each embodiment of the present application when running the program instructions. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc., various media that can store program codes.
[0115] Alternatively, all or part of the steps of implementing the aforementioned method embodiments may be accomplished by hardware associated with program instructions (such as electronic devices such as personal computers, servers, or network devices), and the program instructions may be stored in a computer-readable storage medium. When the program instructions are executed by a processor of an electronic device, the electronic device executes all or part of the steps of the methods described in the embodiments of the present application.
[0116] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that within the spirit and principles of the present application, they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not deviate from the protection scope of the present application.
Claims
1. A distributed model training method based on blockchain, applied to the publisher of training tasks, characterized in that: include: Determine the task-related content and initial model structure corresponding to the model training task; Send the task-related content and the initial model structure to all edge nodes participating in model training; wherein each edge node trains the initial parameters in the initial model structure based on local training data and the task-related content to obtain trained local model parameters, and then when data is exchanged between edge nodes, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain; When all edge nodes have participated in the aggregation, the edge node that has participated in the aggregation the most times is calculated according to the aggregated local model parameters saved on the blockchain, and the edge node that has participated in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in the model training, so that the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the aggregation the most times.
2. The distributed model training method based on blockchain according to claim 1 is characterized in that: After each of the other edge nodes updates its own local model parameters to the local model parameters broadcasted by the edge node that participates in the aggregation the most times, the method further includes: Receive evaluation results of the current model structure from all edge nodes participating in model training based on local model parameters; Analyze whether the current model structure meets the task conditions according to the evaluation results; If yes, the current model structure is deployed to each edge node for use; If not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and the task-related content. After the training is completed, aggregation is performed again by relying on information interaction between edge nodes.
3. A distributed model training method based on blockchain, applied to edge nodes participating in model training, characterized in that: include: Receive task-related content and initial model structure corresponding to the model training task sent by the training task publisher; Based on the local training data and the task-related content, the initial parameters in the initial model structure are trained to obtain trained local model parameters; When data is exchanged between edge nodes, local model parameters are carried in the transmitted data packets. The local model parameters are aggregated after passing through each edge node to obtain the aggregated local model parameters, which are then saved to the blockchain. Receive instructions initiated by the publisher of the training task, in which the edge node that has participated in the largest number of aggregations broadcasts its local model parameters to other edge nodes that participate in the model training; According to the instruction, the edge node that participates in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in model training, and the other edge nodes each update their own local model parameters to the local model parameters broadcast by the edge node that participates in the aggregation the most times.
4. The distributed model training method based on blockchain according to claim 3 is characterized in that: When data is exchanged between edge nodes, local model parameters are carried in the transmitted data packets. The local model parameters are aggregated after each edge node to obtain the aggregated local model parameters, including: Data interaction between edge nodes can be called data interaction between source nodes and destination nodes, and it passes through one or more relay nodes in the middle; The transmitted data packets carry not only the interactive information data required for data interaction, but also the local model parameters trained by the source node; Whenever a data packet passes through a relay node, the relay node receives the local model parameters in the data packet, and aggregates the local model parameters with the local model parameters of the relay node by calculating the average value of each dimension to obtain aggregated local model parameters; the aggregated local model parameters are then used to replace the local model parameters in the data packet and the local model parameters of the relay node; the data packet is then transmitted to the next relay node, and the above aggregation process is performed in the next relay node.
5. The distributed model training method based on blockchain according to claim 3 is characterized in that: After each of the other edge nodes updates its own local model parameters to the local model parameters broadcasted by the edge node that participates in the aggregation the most times, the method further includes: All edge nodes participating in model training evaluate the current model structure based on local model parameters and send the evaluation results to the training task publisher; the training task publisher analyzes whether the current model structure meets the task conditions based on the evaluation results; if so, the current model structure is deployed to each edge node for use; if not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and the task-related content. After the training is completed, aggregation is performed again based on information interaction between edge nodes; Receiving the training instructions sent by the publisher of the training task, each edge node trains the current model structure based on local training data and the task-related content. After the training is completed, aggregation is performed again by relying on information interaction between edge nodes.
6. A distributed model training device based on blockchain, applied to the publisher of training tasks, characterized in that: include: A determination module, used to determine the task-related content and initial model structure corresponding to the model training task; A sending module, used to send the task-related content and the initial model structure to all edge nodes participating in model training; wherein each edge node trains the initial parameters in the initial model structure based on local training data and the task-related content to obtain trained local model parameters, and then when data is exchanged between edge nodes, the local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain; The calculation module is used to calculate the edge node that has participated in the aggregation the most times according to the aggregated local model parameters stored on the blockchain after all edge nodes have participated in the aggregation, and the edge node that has participated in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in the model training, so that the other edge nodes each update their own local model parameters to the local model parameters broadcasted by the edge node that has participated in the aggregation the most times.
7. The distributed model training device based on blockchain according to claim 6, characterized in that: Also includes: An evaluation module is used to receive evaluation results of the current model structure evaluated by all edge nodes participating in model training based on local model parameters; Analyze whether the current model structure meets the task conditions according to the evaluation results; If yes, the current model structure is deployed to each edge node for use; If not, the local model parameters are used as initial parameters, and each edge node trains the current model structure based on local training data and the task-related content. After the training is completed, aggregation is performed again by relying on information interaction between edge nodes.
8. A distributed model training device based on blockchain, applied to edge nodes participating in model training, characterized in that: include: A receiving module, used to receive task-related content and an initial model structure corresponding to the model training task sent by the training task publisher; A training module, used for training the initial parameters in the initial model structure based on the local training data and the task-related content to obtain trained local model parameters; When data is exchanged between edge nodes, local model parameters are carried in the transmitted data packets, and the local model parameters are aggregated each time they pass through an edge node to obtain aggregated local model parameters, and the aggregated local model parameters are saved to the blockchain; an instruction initiated by the publisher of the training task to broadcast the local model parameters on the edge node that participates in the aggregation the most times to other edge nodes participating in the model training is received; according to the instruction, the edge node that participates in the aggregation the most times broadcasts its local model parameters to other edge nodes participating in the model training, and the other edge nodes each update their own local model parameters to the local model parameters broadcast by the edge node that participates in the aggregation the most times.
9. An electronic device, characterized in that: It comprises a processor and a memory, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the distributed model training method based on blockchain described in any one of claims 1 to 2 and / or the distributed model training method based on blockchain described in any one of claims 3 to 5.
10. A computer-readable storage medium, characterized in that: A computer program is stored in the computer-readable storage medium, wherein the computer program is configured to execute the distributed model training method based on blockchain described in any one of claims 1 to 2 and / or the distributed model training method based on blockchain described in any one of claims 3 to 4 during runtime.
Citation Information
Patent Citations
Artificial intelligence training method and device based on block chain and storage medium
CN111858752A
Model training method based on distributed learning, server and distributed system
CN113361598A