Model training method, device, storage medium, system and blockchain node
By dynamically selecting master nodes in the blockchain network and using trusted execution environment encryption processing, the problems of insufficient samples and privacy leakage in medical AI training are solved, and safe and efficient model training effects are achieved.
Patent Information
- Application Number
- CN202111583160.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2025-09-19
- Estimated Expiration
- 2041-12-22
AI Technical Summary
During the training process of medical AI, there are issues of data security and data privacy leakage, and insufficient training samples may lead to centralization and security risks.
By setting up multiple blockchain nodes in the blockchain network, using description parameters to select the master node for model training, interacting with model parameters instead of sample data, dynamically selecting nodes with higher performance for training, and combining encryption processing with a trusted execution environment, sample data leakage can be avoided and security can be improved.
It solves the problem of insufficient training samples, avoids the privacy leakage of sample data, improves the model training effect and avoids centralization problems, thereby improving security and data credibility.
Smart Images

Figure CN114254360B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular, to a model training method, device, storage medium, system, and blockchain node. Background Art
[0002] With the rise of artificial intelligence (AI), medical AI (artificial intelligence) has become a hot field. Medical AI can be trained based on medical data and can perform functions such as CT (computed tomography) image recognition and data recognition.
[0003] However, there are still many difficulties in the training process of medical AI, such as data security issues, data privacy leakage issues, etc. Summary of the Invention
[0004] The purpose of this disclosure is to provide a model training method, device, storage medium, system and blockchain node to solve the above-mentioned related technical problems.
[0005] To achieve the above objectives, according to a first aspect of an embodiment of the present disclosure, a model training method is provided, which is applied to a target blockchain node in a blockchain network, where the target blockchain node is any node among multiple blockchain nodes. The method includes:
[0006] In response to receiving the master node selection request, obtaining description parameters of each blockchain node, the description parameters including one or more of the number of training samples, historical training contribution, and node operation status parameters;
[0007] Determine a master node from the plurality of blockchain nodes according to description parameters of each blockchain node;
[0008] Perform the following steps until the initial model converges and the target model is obtained:
[0009] Calculate model training parameters based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node;
[0010] Sending the model training parameters to the master node, and performing model training through the master node;
[0011] Obtaining updated model parameters generated by the master node, and updating the initial model corresponding to the target blockchain node based on the updated model parameters;
[0012] The master node is used to obtain the model training parameters of each blockchain node, and update the model parameters of the initial model corresponding to the master node according to the model training parameters of each blockchain node to obtain updated model parameters.
[0013] Optionally, the description parameters include the number of training samples, historical training contribution, and node operation status parameters, and determining the master node from the multiple blockchain nodes based on the description parameters of each blockchain node includes:
[0014] For each blockchain node, the selection weight value of the blockchain node is calculated based on the number of training samples, historical training contribution, node operation status parameters of the blockchain node, and the parameter weight values corresponding to the number of training samples, the historical training contribution, and the node operation status parameters respectively;
[0015] A blockchain node with a weight value greater than a preset threshold is selected as the master node.
[0016] Optionally, a master node selection smart contract is deployed in the blockchain network, and determining the master node from the multiple blockchain nodes according to the description parameters of each blockchain node includes:
[0017] The master node selection smart contract is executed to determine the master node from the multiple blockchain nodes according to the description parameters of each blockchain node.
[0018] Optionally, the target blockchain node is further provided with a corresponding first trusted execution environment, and the calculating of model training parameters based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node includes:
[0019] Sending the initial model corresponding to the target blockchain node and the training sample of the target blockchain node to the first trusted execution environment;
[0020] Receive model training parameters sent by the first trusted execution environment, where the model training parameters are calculated by the first trusted execution environment based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node.
[0021] Optionally, the receiving the model training parameters sent by the first trusted execution environment includes:
[0022] Receiving encrypted model training parameters sent by the first trusted execution environment, where the encrypted model training parameters are obtained by encrypting the model training parameters by the first trusted execution environment using a first private key, where the first private key is a private key of the first trusted execution environment;
[0023] The sending the model training parameters to the master node includes:
[0024] Sending the encryption model training parameters to the master node;
[0025] Among them, the master node is used to obtain the first public key of the first trusted execution environment from the blockchain, and decrypt the encrypted model training parameters through the first public key to obtain the model training parameters of the target blockchain node.
[0026] Optionally, the master node is further provided with a corresponding second trusted execution environment. The master node is used to send the initial model and the model training parameters of each blockchain node to the second trusted execution environment, and obtain the encrypted updated model parameters sent by the second trusted execution environment. The encrypted updated model parameters are obtained by encrypting the updated model parameters by the second trusted execution environment using a second private key. The second private key is the private key of the second trusted execution environment. Obtaining the updated model parameters generated by the master node includes:
[0027] Receiving the encrypted updated model parameters sent by the master node;
[0028] Obtain a second public key of the second trusted execution environment from the blockchain of the blockchain network;
[0029] The encrypted updated model parameters are decrypted using the second public key to obtain the updated model parameters.
[0030] According to a second aspect of an embodiment of the present disclosure, a model training device is provided, which is applied to a target blockchain node in a blockchain network, wherein the target blockchain node is any node among a plurality of blockchain nodes, and the device includes:
[0031] A first acquisition module is configured to, in response to receiving a master node selection request, acquire description parameters of each blockchain node, wherein the description parameters include one or more of the number of training samples, historical training contribution, and node operation status parameters;
[0032] A first determination module is configured to determine a master node from the plurality of blockchain nodes based on description parameters of each blockchain node;
[0033] The model training module is used to perform training steps until the initial model converges to obtain the target model. The model training module includes:
[0034] A first calculation submodule is configured to calculate model training parameters based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node;
[0035] A first sending submodule is used to send the model training parameters to the master node and perform model training through the master node;
[0036] A first execution submodule is configured to obtain update model parameters generated by the master node, and update the initial model corresponding to the target blockchain node based on the update model parameters;
[0037] The master node is used to obtain the model training parameters of each blockchain node, and update the model parameters of the initial model corresponding to the master node according to the model training parameters of each blockchain node to obtain updated model parameters.
[0038] Optionally, the description parameters include the number of training samples, historical training contribution, and node operation status parameters, and the first determination module includes:
[0039] A second calculation submodule is configured to calculate, for each blockchain node, a selection weight value of the blockchain node based on the number of training samples, the historical training contribution, the node operating state parameters, and the parameter weight values corresponding to the number of training samples, the historical training contribution, and the node operating state parameters, respectively;
[0040] The second execution submodule is used to select a blockchain node with a weight value greater than a preset threshold as the master node.
[0041] Optionally, a master node selection smart contract is deployed in the blockchain network, and the first determination module includes:
[0042] The third execution submodule is used to execute the master node selection smart contract to determine the master node from the multiple blockchain nodes according to the description parameters of each blockchain node.
[0043] Optionally, the target blockchain node is further provided with a corresponding first trusted execution environment, and the first computing submodule includes:
[0044] A first sending subunit, configured to send the initial model corresponding to the target blockchain node and the training sample of the target blockchain node to the first trusted execution environment;
[0045] The first receiving subunit is used to receive the model training parameters sent by the first trusted execution environment, where the model training parameters are calculated by the first trusted execution environment based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node.
[0046] Optionally, the first receiving subunit is specifically configured to:
[0047] Receiving encrypted model training parameters sent by the first trusted execution environment, where the encrypted model training parameters are obtained by encrypting the model training parameters by the first trusted execution environment using a first private key, where the first private key is a private key of the first trusted execution environment;
[0048] The first sending submodule includes:
[0049] A first sending subunit, configured to send the encryption model training parameters to the master node;
[0050] Among them, the master node is used to obtain the first public key of the first trusted execution environment from the blockchain, and decrypt the encrypted model training parameters through the first public key to obtain the model training parameters of the target blockchain node.
[0051] Optionally, the master node is further provided with a corresponding second trusted execution environment, and the master node is used to send the initial model and the model training parameters of each blockchain node to the second trusted execution environment, and obtain the encrypted updated model parameters sent by the second trusted execution environment, and the encrypted updated model parameters are obtained by encrypting the updated model parameters by the second trusted execution environment using a second private key, and the second private key is the private key of the second trusted execution environment. The first execution submodule includes:
[0052] A second receiving subunit, configured to receive the encrypted updated model parameters sent by the master node;
[0053] An acquisition subunit, configured to acquire a second public key of the second trusted execution environment from the blockchain of the blockchain network;
[0054] The decryption subunit is configured to decrypt the encrypted updated model parameters using the second public key to obtain the updated model parameters.
[0055] According to a third aspect of an embodiment of the present disclosure, a non-temporary computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the steps of the method described in any one of the first aspects are implemented.
[0056] According to a fourth aspect of an embodiment of the present disclosure, a blockchain node is provided, including:
[0057] a memory having a computer program stored thereon;
[0058] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods described in the first aspect above.
[0059] According to a fifth aspect of an embodiment of the present disclosure, a model training system is provided, comprising the blockchain node described in the fourth aspect.
[0060] In the above technical solution, when model training is required, multiple blockchain nodes can determine a master node from among the multiple blockchain nodes based on their respective descriptive parameters. In this way, each blockchain node can perform model training through the master node. For example, a target blockchain node can input its own training samples into an initial model and calculate model training parameters. The target blockchain node can then send these model training parameters to the master node, which then updates the model based on the model training parameters of each blockchain node, obtaining updated model parameters. The target blockchain node can then update its local initial model based on the updated model parameters. By repeating these steps, the target blockchain node completes the initial model training process and obtains the target model.
[0061] In other words, the target model can be obtained by the master node by updating the initial model based on the model training parameters of each blockchain node, that is, the target model is obtained by training based on the training samples of each blockchain node. In this way, the training samples owned by each blockchain node can be used to train the model, thereby solving the problem of insufficient training samples. Moreover, during the model training process, what is exchanged between each blockchain node and the master node are model parameters, not sample data. Therefore, the above technical solution can also avoid the privacy leakage problem caused by sample data. In addition, the above technical solution can also dynamically select the master node for training based on the description parameters of each blockchain node during model training (for example, select the blockchain node with higher current performance as the master node). Therefore, the above technical solution also helps to improve the training effect of the model. Moreover, this method can also avoid the centralization problem of the master node, which helps to improve security.
[0062] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following detailed description, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0064] Figure 1 It is a flowchart of a model training method shown in an exemplary embodiment of the present disclosure.
[0065] Figure 2 It is a block diagram of a model training system shown in an exemplary embodiment of the present disclosure.
[0066] Figure 3 It is a schematic diagram of a model training step shown in an exemplary embodiment of the present disclosure.
[0067] Figure 4 It is a schematic diagram of a model training step shown in an exemplary embodiment of the present disclosure.
[0068] Figure 5 It is a flowchart of a model training shown in an exemplary embodiment of the present disclosure.
[0069] Figure 6 It is a block diagram of a model training device shown in an exemplary embodiment of the present disclosure.
[0070] Figure 7 It is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0071] The following describes the specific embodiments of the present disclosure in detail with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present disclosure and are not intended to limit the present disclosure.
[0072] Before introducing the model training method, device, storage medium, system, and blockchain node of the present disclosure, the application scenarios of the various embodiments provided by the present disclosure are first introduced.
[0073] The various embodiments provided in this disclosure can be used in model training scenarios. Taking medical AI as an example, in relevant scenarios, each medical institution may have its own medical data (for example, it may be obtained with the patient's permission). However, the medical data of a single medical institution may be relatively small, making it difficult to complete the model training process. In addition, medical data may also involve patient privacy, so if a medical institution shares its own medical data with other institutions for unified training, patient privacy may also be leaked.
[0074] To this end, in some implementation scenarios, the training of medical AI can be completed based on federated training. For example, a server for model training can be set up, and each medical institution can obtain a unified initial model from the server and perform local training using its own medical data to obtain model training parameters. Each medical institution can also send the model training parameters obtained from local training to the server, which will perform parameter integration to obtain updated model parameters. In this way, each medical institution can obtain the updated model parameters and update the local initial model based on the obtained updated model parameters. By looping the above process, the training of medical AI can be completed and the target medical AI can be obtained.
[0075] However, this training approach can also present challenges. For example, the training server may be centralized, which can pose security risks if attacked. Furthermore, the training server may experience network and load fluctuations, which can reduce model training effectiveness.
[0076] To this end, the present disclosure provides a model training method that is applied to a target blockchain node in a blockchain network, where the target blockchain node is any node among multiple blockchain nodes. Taking medical AI training as an example, a blockchain node can be set up for each medical institution. In this way, the blockchain nodes of each medical institution can form a blockchain network through a P2P (peer-to-peer) network.
[0077] Furthermore, individual medical institutions can register their digital identity information with the blockchain network and perform identity authentication by deploying identity authentication smart contracts. For example, during model training, each blockchain node can authenticate itself using the digital identity information registered on the blockchain. This means that if authentication is successful, the node can respond to incoming requests; otherwise, it can reject the request.
[0078] Figure 1 : is a flowchart of a model training method shown in the present disclosure, the method is applied to a target blockchain node, and the method includes:
[0079] In step 11, in response to receiving the master node selection request, the description parameters of each blockchain node are obtained.
[0080] The description parameters include one or more of the number of training samples, historical training contribution, and node operation status parameters.
[0081] The number of training samples can be, for example, the number of training samples that the blockchain node can provide during this training. For example, in medical model training, when training a lung CT image recognition model, the number of training samples can refer to the number of sample lung CT images that the blockchain node can provide during this training.
[0082] Here, refer to Figure 2 The block diagram of a model training system is shown. In some implementation scenarios, data service nodes can be set up for each medical institution. The data service nodes can be used to pre-process and annotate medical data, thereby processing the medical data into medical sample data that can be used for model training.
[0083] For example, in some implementations, medical data may be case text, which may be of low quality or contain sensitive patient information, making it unsuitable for model training. In this case, the data service node can load the medical data and perform data desensitization.
[0084] For example, a data service node can delete content related to patient information from a case text to protect patient privacy. The data service node can also define case text specifications to filter out data that does not meet these specifications. Examples of these specifications include prohibiting special characters from appearing in case texts, limiting data size to 1MB, and limiting empty data content items. After processing the case text data, the data within the case text can be annotated. Here, the data service node can, for example, provide an edit box for the case text, allowing annotators (such as doctors) to extract features from the data within the case text (these features could be, for example, symptoms such as fever, headache, and cough) and generate a judgment result for the case text. The data service node can then structure the annotated feature data and map it to the judgment result of the case text to obtain medical sample data. Furthermore, the data service node can store the medical sample data in the medical institution's local database, making it accessible to the institution's blockchain node when needed.
[0085] The descriptive parameters may also include historical training contribution. The historical training contribution can be used to describe the behavioral contribution of blockchain nodes in participating in model training. As an example, the calculation method of historical training contribution α can be: Among them, n represents the historical number of times the blockchain node participates in model training, α i represents the contribution value in the i-th historical training. The contribution value can be calculated, for example, as follows: Here, the amount of participating data is the number of training samples provided by the blockchain node in the i-th historical training, and the total amount of data is the total number of training samples in the i-th historical training.
[0086] The description parameters may also include node operating status parameters. Node operating status parameters may include, for example, health status parameters of the blockchain node, performance parameters of the blockchain node, and the like.
[0087] The health parameter of a blockchain node can be represented by β, for example, to describe the operational status of the blockchain node. In some embodiments, the health status of a blockchain node can be detected through heartbeat detection. For example, the heartbeat response time threshold can be defined as 3 seconds. If a response is received within 3 seconds, β = 30; if no response is received within 3 seconds, β = β - 1; if no response is received for 5 consecutive times, β = β - 10; and if no response is received for 10 consecutive times, β = β - 30.
[0088] The performance parameters of the blockchain node can be used to describe the model training capabilities of the blockchain node. For example, throughput can be used to calculate the performance parameter γ of the blockchain node: γ = tps / 1000, where tps is the throughput of the blockchain node. Of course, in some implementations, the performance parameters can also be calculated based on other performance indicators of the blockchain node, such as floating-point operation speed, logical calculation speed, etc.
[0089] In step 12, a master node is determined from the multiple blockchain nodes based on the description parameters of each blockchain node.
[0090] For example, if the descriptive parameters include node operating status parameters, a high-performing blockchain node can be selected as the master node. This allows for the selection of high-performing blockchain nodes for model training, thereby accelerating training. Furthermore, if the descriptive parameters include other indicators, selection criteria can be set based on application requirements to select the master node.
[0091] For example, in one possible implementation, the description parameters include the number of training samples, historical training contribution, and node operation status parameters. Step 12 may include:
[0092] For each blockchain node, the selection weight value of the blockchain node is calculated based on the number of training samples, historical training contribution, node operation status parameters of the blockchain node, and the parameter weight values corresponding to the number of training samples, the historical training contribution, and the node operation status parameters.
[0093] For example, the selection weight value f(x) of the blockchain node can be calculated as follows:
[0094]
[0095] in, is the number of training samples, k1 is the parameter weight value of the number of training samples, γ is the performance parameter of the blockchain node, α is the historical training contribution of the blockchain node, k2 is the parameter weight value of the historical contribution, β is the health status parameter of the blockchain node, k3 is the parameter weight value of the health status parameter, the value of k1 can be, for example, 1.89, the value of k2 can be, for example, 0.68, and the value of k3 can be, for example, 1.12.
[0096] Thus, after obtaining the selection weight values of each blockchain node, the blockchain node with a weight value greater than a preset threshold can be selected as the master node. For example, in some embodiments, the blockchain node with the largest weight value can be selected as the master node.
[0097] In step 13, a training step is performed until the initial model converges to obtain a target model.
[0098] Figure 3 This is a schematic diagram of a model training step shown in the present disclosure, referring to Figure 3 , step 13 may include:
[0099] In S131, model training parameters are calculated based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node.
[0100] Here, the initial model can be an initialized model (e.g., a medical model, such as a CT image recognition model, a medical data recognition model, etc.), and is synchronized to each blockchain node through the blockchain network, so that the initial models corresponding to each blockchain node are consistent. During training, the target blockchain node can, for example, input its own training samples (e.g., medical samples, such as sample CT images, sample medical data, etc.) into the local initial model and calculate the model training parameters based on the output of the initial model. As an example, the model training parameters can be gradient parameters.
[0101] In S132, the target blockchain node may send the model training parameters to the master node, and perform model training through the master node. Continuing with the above example, the target blockchain node may send the gradient parameters to the master node, and perform model training through the master node.
[0102] The master node is used to obtain the model training parameters of each blockchain node and update the model parameters of the initial model corresponding to the master node based on the model training parameters of each blockchain node to obtain updated model parameters. As an example, the master node can obtain the gradient parameters calculated by each blockchain node (which may also include the gradient parameters calculated by the master node itself) and then calculate the gradient sum. After obtaining the gradient sum, the master node can update the parameters of the local initial model based on the gradient sum to obtain updated model parameters.
[0103] In S133, the updated model parameters generated by the master node are obtained, and the initial model corresponding to the target blockchain node is updated based on the updated model parameters.
[0104] In the above technical solution, when model training is required, multiple blockchain nodes can determine a master node from among the multiple blockchain nodes based on their respective descriptive parameters. In this way, each blockchain node can perform model training through the master node. For example, a target blockchain node can input its own training samples into an initial model and calculate model training parameters. The target blockchain node can then send these model training parameters to the master node, which then updates the model based on the model training parameters of each blockchain node, obtaining updated model parameters. The target blockchain node can then update its local initial model based on the updated model parameters. By repeating these steps, the target blockchain node completes the initial model training process and obtains the target model. For example, if the initial model is a medical model, training can be performed to obtain the target medical model.
[0105] In other words, the target model can be obtained by the master node by updating the initial model based on the model training parameters of each blockchain node, that is, the target model is obtained by training based on the training samples of each blockchain node. In this way, the training samples owned by each blockchain node can be used to train the model, thereby solving the problem of insufficient training samples. Moreover, during the model training process, what is exchanged between each blockchain node and the master node are model parameters, not sample data. Therefore, the above technical solution can also avoid the privacy leakage problem caused by sample data. In addition, the above technical solution can also dynamically select the master node for training based on the description parameters of each blockchain node during model training (for example, select the blockchain node with higher current performance as the master node). Therefore, the above technical solution also helps to improve the training effect of the model. Moreover, this method can also avoid the centralization problem of the master node, which helps to improve security.
[0106] It is also worth noting that the method steps provided in this disclosure can also be implemented based on smart contracts. For example, in one possible implementation, a master node selection smart contract is deployed in the blockchain network, and the step of determining the master node from the plurality of blockchain nodes based on the description parameters of each blockchain node (step 12) includes:
[0107] The master node selection smart contract is executed to determine the master node from the multiple blockchain nodes according to the description parameters of each blockchain node.
[0108] In other words, the aforementioned step of determining the master node can also involve the master node selecting the execution content of the smart contract. When the master node selection smart contract is invoked, the endorsing nodes of the master node selection smart contract can execute the master node smart contract and determine the master node from multiple blockchain nodes through voting. The execution content of the master node selection smart contract can be described in the embodiment of step 12, and this disclosure does not elaborate on this.
[0109] Figure 4 is a schematic diagram of a model training step shown in the present disclosure, wherein the target blockchain node is also correspondingly provided with a first trusted execution environment. Figure 4 , the model training steps may include:
[0110] S41: Send the initial model corresponding to the target blockchain node and the training sample of the target blockchain node to the first trusted execution environment.
[0111] For example, refer to Figure 2 In some implementation scenarios, federated learning nodes can be instantiated in the first trusted execution environment. These federated learning nodes can be presented in the form of processes, virtual machines, etc. In this way, by sending the initial model and the training samples of the target blockchain node to the first trusted execution environment, the federated learning nodes in the first trusted execution environment can calculate the model training parameters based on the initial model and the training samples.
[0112] S42: Receive model training parameters sent by the first trusted execution environment.
[0113] S43: Send the model training parameters to the master node, and perform model training through the master node.
[0114] S44, obtaining the updated model parameters generated by the master node, and updating the initial model corresponding to the target blockchain node based on the updated model parameters.
[0115] The implementation of steps S43 and S44 can be referred to the above-mentioned embodiment description of steps S132 and S133. For the sake of brevity, this disclosure will not elaborate on this.
[0116] The above technical solution establishes a trusted execution environment for each blockchain node. This allows the calculation of model training parameters within the trusted execution environment, improving data security and reliability during model training.
[0117] It is also worth noting that in some embodiments, the initial model can also be preset in a trusted execution environment. In this case, in step S41, the target blockchain node can also send its own training samples to the first trusted execution environment, that is, there is no need to send the initial model.
[0118] In one possible implementation, the first trusted execution environment can also encrypt the calculated model training parameters. For example, a first public key and a first private key can be generated based on the root of trust of the trusted computing chip of the first trusted execution environment. The first public key is registered on the blockchain, and the first private key is stored locally by the first trusted execution environment.
[0119] In this case, the receiving the model training parameters sent by the first trusted execution environment (S42) includes:
[0120] Receive encrypted model training parameters sent by the first trusted execution environment, wherein the encrypted model training parameters are obtained by encrypting the model training parameters by the first trusted execution environment using a first private key.
[0121] Reference Figure 5 In the flowchart of a model training process shown, the first trusted execution environment can, for example, load training samples corresponding to blockchain node A and train the initial model based on these training samples to obtain gradient parameters. The first trusted execution environment can then encrypt these gradient parameters using a first private key to obtain encrypted gradient parameters, and then send the encrypted gradient parameters to the blockchain node.
[0122] Thus, the sending of the model training parameters to the master node (S43) includes:
[0123] The encrypted model training parameters are sent to the master node.
[0124] Among them, the master node is used to obtain the first public key of the first trusted execution environment from the blockchain, and decrypt the encrypted model training parameters through the first public key to obtain the model training parameters of the target blockchain node.
[0125] Continuing with the above example, the master node can obtain the first public key of the first trusted execution environment from the blockchain and use it to decrypt the encrypted gradient parameters. If the decryption is successful, the gradient parameters of the target blockchain node can be obtained. If the decryption fails, it can be determined that the encrypted gradient parameters have been tampered with. In this way, by encrypting the calculated model training parameters, data security during the model training process can be improved.
[0126] Still refer to Figure 5In one possible implementation, the master node may also be configured with a corresponding second trusted execution environment. The master node is configured to send the initial model and the model training parameters of each blockchain node (illustrated as gradient parameters in the figure) to the second trusted execution environment, and obtain encrypted updated model parameters sent by the second trusted execution environment. The encrypted updated model parameters are obtained by encrypting the updated model parameters in the second trusted execution environment using a second private key, where the second private key is the private key of the second trusted execution environment.
[0127] In this case, the obtaining of the updated model parameters generated by the master node (S44) includes:
[0128] Receiving the encrypted updated model parameters sent by the master node;
[0129] Obtain a second public key of the second trusted execution environment from the blockchain of the blockchain network;
[0130] The encrypted updated model parameters are decrypted using the second public key to obtain the updated model parameters.
[0131] For example, the target blockchain node can obtain the second public key of the second trusted execution environment from the blockchain and use the second public key to decrypt the encrypted updated gradient parameters. If the decryption is successful, the updated gradient parameters are obtained; if the decryption fails, it can be determined that the encrypted updated gradient parameters have been tampered with. In this way, by encrypting the calculated model training parameters, data security during the model training process can be improved.
[0132] It is also worth noting that, in some embodiments, after generating the encrypted model training parameters, the target blockchain node may also upload them to the blockchain. In this case, the master node may obtain the encrypted model training parameters and the first public key of the first trusted execution environment from the blockchain. In this way, the master node can decrypt the encrypted model training parameters using the first public key, thereby obtaining the model training parameters of the target blockchain node. Of course, the master node may also upload the encrypted updated model parameters to the blockchain, and the target blockchain node may also obtain the encrypted updated model parameters and the second public key of the second trusted execution environment from the blockchain to obtain the updated model parameters.
[0133] In this way, the intermediate parameters in the model training process (encrypted model training parameters and encrypted model update parameters) can be stored in the blockchain, which helps to supervise and trace the model training process.
[0134] Based on the same inventive concept, the present disclosure also provides a model training device, which is applied to a target blockchain node in a blockchain network, and the target blockchain node is any node among multiple blockchain nodes. Figure 6 This is a block diagram of a model training device shown in the present disclosure, referring to Figure 6 , the apparatus 600 includes:
[0135] A first acquisition module 601 is configured to, in response to receiving a master node selection request, acquire description parameters of each blockchain node, wherein the description parameters include one or more of the number of training samples, historical training contribution, and node operation status parameters;
[0136] A first determination module 602 is configured to determine a master node from the plurality of blockchain nodes based on description parameters of each blockchain node;
[0137] The model training module 603 is used to perform training steps until the initial model converges to obtain the target model. The model training module includes:
[0138] A first calculation submodule 6031 is configured to calculate model training parameters based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node;
[0139] A first sending submodule 6032 is configured to send the model training parameters to the master node and perform model training through the master node;
[0140] The first execution submodule 6033 is configured to obtain the updated model parameters generated by the master node, and update the initial model corresponding to the target blockchain node based on the updated model parameters;
[0141] The master node is used to obtain the model training parameters of each blockchain node, and update the model parameters of the initial model corresponding to the master node according to the model training parameters of each blockchain node to obtain updated model parameters.
[0142] In the above technical solution, when model training is required, multiple blockchain nodes can determine a master node from among the multiple blockchain nodes based on their respective descriptive parameters. In this way, each blockchain node can perform model training through the master node. For example, a target blockchain node can input its own training samples into an initial model and calculate model training parameters. The target blockchain node can then send these model training parameters to the master node, which then updates the model based on the model training parameters of each blockchain node, obtaining updated model parameters. The target blockchain node can then update its local initial model based on the updated model parameters. By repeating these steps, the target blockchain node completes the initial model training process and obtains the target model.
[0143] In other words, the target model can be obtained by the master node by updating the initial model based on the model training parameters of each blockchain node, that is, the target model is obtained by training based on the training samples of each blockchain node. In this way, the training samples owned by each blockchain node can be used to train the model, thereby solving the problem of insufficient training samples. Moreover, during the model training process, what is exchanged between each blockchain node and the master node are model parameters, not sample data. Therefore, the above technical solution can also avoid the privacy leakage problem caused by sample data. In addition, the above technical solution can also dynamically select the master node for training based on the description parameters of each blockchain node during model training (for example, select the blockchain node with higher current performance as the master node). Therefore, the above technical solution also helps to improve the training effect of the model. Moreover, this method can also avoid the centralization problem of the master node, which helps to improve security.
[0144] Optionally, the description parameters include the number of training samples, historical training contribution, and node operation status parameters, and the first determination module includes:
[0145] A second calculation submodule is configured to calculate, for each blockchain node, a selection weight value of the blockchain node based on the number of training samples, the historical training contribution, the node operating state parameters, and the parameter weight values corresponding to the number of training samples, the historical training contribution, and the node operating state parameters, respectively;
[0146] The second execution submodule is used to select a blockchain node with a weight value greater than a preset threshold as the master node.
[0147] Optionally, a master node selection smart contract is deployed in the blockchain network, and the first determination module includes:
[0148] The third execution submodule is used to execute the master node selection smart contract to determine the master node from the multiple blockchain nodes according to the description parameters of each blockchain node.
[0149] Optionally, the target blockchain node is further provided with a corresponding first trusted execution environment, and the first computing submodule includes:
[0150] A first sending subunit, configured to send the initial model corresponding to the target blockchain node and the training sample of the target blockchain node to the first trusted execution environment;
[0151] The first receiving subunit is used to receive the model training parameters sent by the first trusted execution environment, where the model training parameters are calculated by the first trusted execution environment based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node.
[0152] Optionally, the first receiving subunit is specifically configured to:
[0153] Receiving encrypted model training parameters sent by the first trusted execution environment, where the encrypted model training parameters are obtained by encrypting the model training parameters by the first trusted execution environment using a first private key, where the first private key is a private key of the first trusted execution environment;
[0154] The first sending submodule includes:
[0155] A first sending subunit, configured to send the encryption model training parameters to the master node;
[0156] Among them, the master node is used to obtain the first public key of the first trusted execution environment from the blockchain, and decrypt the encrypted model training parameters through the first public key to obtain the model training parameters of the target blockchain node.
[0157] Optionally, the master node is further provided with a corresponding second trusted execution environment, and the master node is used to send the initial model and the model training parameters of each blockchain node to the second trusted execution environment, and obtain the encrypted updated model parameters sent by the second trusted execution environment, and the encrypted updated model parameters are obtained by encrypting the updated model parameters by the second trusted execution environment using a second private key, and the second private key is the private key of the second trusted execution environment. The first execution submodule includes:
[0158] A second receiving subunit, configured to receive the encrypted updated model parameters sent by the master node;
[0159] An acquisition subunit, configured to acquire a second public key of the second trusted execution environment from the blockchain of the blockchain network;
[0160] The decryption subunit is configured to decrypt the encrypted updated model parameters using the second public key to obtain the updated model parameters.
[0161] Regarding the apparatus in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0162] The present disclosure also provides a non-temporary computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the model training method provided by the present disclosure.
[0163] The present disclosure also provides a blockchain node, comprising:
[0164] a memory having a computer program stored thereon;
[0165] A processor is used to execute the computer program in the memory to implement the steps of the model training method provided by the present disclosure.
[0166] The present disclosure also provides a model training system, including the blockchain node provided by the present disclosure.
[0167] Figure 7 FIG. 7 is a block diagram of an electronic device 700 according to an exemplary embodiment. Figure 7 As shown, the electronic device 700 may include: a processor 701 , a memory 702 , and may further include one or more of a multimedia component 703 , an input / output (I / O) interface 704 , and a communication component 705 .
[0168] Among them, the processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned model training method. The memory 702 is used to store various types of data to support the operation of the electronic device 700. These data may include, for example, instructions for any application or method operating on the electronic device 700, as well as application-related data, such as contact data, messages sent and received, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent via the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules. The above-mentioned other interface modules may be a keyboard, a mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more thereof, is not limited here. Therefore, the corresponding communication component 705 may include: a Wi-Fi module, a Bluetooth module, an NFC module, etc.
[0169] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute the above-mentioned model training method.
[0170] In another exemplary embodiment, a computer-readable storage medium including program instructions is further provided, wherein the program instructions, when executed by a processor, implement the steps of the above-described model training method. For example, the computer-readable storage medium may be the aforementioned memory 702 including the program instructions, and the program instructions may be executed by the processor 701 of the electronic device 700 to perform the above-described model training method.
[0171] In another exemplary embodiment, a computer program product is also provided, which includes a computer program that can be executed by a programmable device, and the computer program has a code portion for performing the above-mentioned model training method when executed by the programmable device.
[0172] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings. However, the present disclosure is not limited to the specific details of the above embodiments. Within the technical concept of the present disclosure, various simple modifications can be made to the technical solutions of the present disclosure, and these simple modifications all fall within the scope of protection of the present disclosure.
[0173] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any appropriate manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0174] In addition, the various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A model training method, characterized in that: Applied to a target blockchain node in a blockchain network, the target blockchain node being any node among a plurality of blockchain nodes, the method comprising: In response to receiving the master node selection request, obtaining description parameters of each blockchain node, the description parameters including one or more of the number of training samples, historical training contribution, and node operation status parameters, the historical training contribution being used to characterize the blockchain node's contribution to historical model training; Determine a master node from the plurality of blockchain nodes according to description parameters of each blockchain node; Perform the following steps until the initial model converges and the target model is obtained: Calculate model training parameters based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node; Sending the model training parameters to the master node, and performing model training through the master node; Obtaining updated model parameters generated by the master node, and updating the initial model corresponding to the target blockchain node based on the updated model parameters; The master node is used to obtain the model training parameters of each blockchain node, and update the model parameters of the initial model corresponding to the master node according to the model training parameters of each blockchain node to obtain updated model parameters.
2. The method according to claim 1, characterized in that The description parameters include the number of training samples, historical training contribution, and node operation status parameters. The determining of the master node from the plurality of blockchain nodes based on the description parameters of each blockchain node includes: For each blockchain node, the selection weight value of the blockchain node is calculated based on the number of training samples, historical training contribution, node operation status parameters of the blockchain node, and the parameter weight values corresponding to the number of training samples, the historical training contribution, and the node operation status parameters respectively; A blockchain node with a weight value greater than a preset threshold is selected as the master node.
3. The method according to claim 1 or 2, characterized in that A master node selection smart contract is deployed in the blockchain network, and determining the master node from the multiple blockchain nodes according to the description parameters of each blockchain node includes: The master node selection smart contract is executed to determine the master node from the multiple blockchain nodes according to the description parameters of each blockchain node.
4. The method according to claim 1, wherein The target blockchain node is also provided with a corresponding first trusted execution environment, and the calculation of model training parameters based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node includes: Sending the initial model corresponding to the target blockchain node and the training sample of the target blockchain node to the first trusted execution environment; Receive model training parameters sent by the first trusted execution environment, where the model training parameters are calculated by the first trusted execution environment based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node.
5. The method according to claim 4, characterized in that The receiving the model training parameters sent by the first trusted execution environment includes: Receiving encrypted model training parameters sent by the first trusted execution environment, where the encrypted model training parameters are obtained by encrypting the model training parameters by the first trusted execution environment using a first private key, where the first private key is a private key of the first trusted execution environment; The sending the model training parameters to the master node includes: Sending the encryption model training parameters to the master node; Among them, the master node is used to obtain the first public key of the first trusted execution environment from the blockchain, and decrypt the encrypted model training parameters through the first public key to obtain the model training parameters of the target blockchain node.
6. The method according to claim 1, characterized in that The master node is further provided with a corresponding second trusted execution environment. The master node is used to send the initial model and the model training parameters of each blockchain node to the second trusted execution environment, and obtain the encrypted updated model parameters sent by the second trusted execution environment. The encrypted updated model parameters are obtained by encrypting the updated model parameters by the second trusted execution environment using a second private key. The second private key is the private key of the second trusted execution environment. The obtaining of the updated model parameters generated by the master node includes: Receiving the encrypted updated model parameters sent by the master node; Obtain a second public key of the second trusted execution environment from the blockchain of the blockchain network; The encrypted updated model parameters are decrypted using the second public key to obtain the updated model parameters.
7. A model training device, characterized in that: The device is applied to a target blockchain node in a blockchain network, where the target blockchain node is any node among multiple blockchain nodes, and includes: A first acquisition module is configured to, in response to receiving a master node selection request, acquire description parameters of each blockchain node, wherein the description parameters include one or more of the number of training samples, historical training contribution, and node operation status parameters, wherein the historical training contribution is used to represent the contribution of the blockchain node in historical participation in model training; A first determination module is configured to determine a master node from the plurality of blockchain nodes based on description parameters of each blockchain node; The model training module is used to perform training steps until the initial model converges to obtain the target model. The model training module includes: A first calculation submodule is configured to calculate model training parameters based on the initial model corresponding to the target blockchain node and the training sample of the target blockchain node; A first sending submodule is used to send the model training parameters to the master node and perform model training through the master node; A first execution submodule is configured to obtain update model parameters generated by the master node, and update the initial model corresponding to the target blockchain node based on the update model parameters; The master node is used to obtain the model training parameters of each blockchain node, and update the model parameters of the initial model corresponding to the master node according to the model training parameters of each blockchain node to obtain updated model parameters.
8. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A blockchain node, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 6.
10. A model training system, characterized in that: Including the blockchain node described in claim 9.
Citation Information
Patent Citations
System and method of decentralized machine learning using blockchain
CN110428056A
Block chain consensus method and device, electronic equipment and storage medium
CN112822239A