A blockchain-based model processing method, system, device and medium
By using iterative pruning and adaptive loss functions to generate subnet masks on edge nodes, combined with alliance chain consensus and aggregation, the problems of reliability and task weight balance in multi-task model training are solved, achieving more efficient model training and performance improvement.
Patent Information
- Application Number
- CN202211430405.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2022-11-08
- Filing Date
- 2022-11-15
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2042-11-15
AI Technical Summary
Existing multi-task model training methods have low reliability and fail to effectively balance the weights and priorities of tasks of different difficulty levels.
By deploying multi-task models on edge nodes, using iterative pruning and task routing networks to generate subnet masks, dynamically adjusting task weights in combination with adaptive loss functions, and performing parameter consensus and aggregation on the consortium chain, the reliability and accuracy of model training are ensured.
It enhances the reliability of multi-task model training, balances the weights and priorities of different tasks, improves model performance, especially the training effect of difficult tasks, and ensures the overall performance of the model.
Smart Images

Figure CN115860115B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a blockchain-based model processing method, system, device, and medium. Background Art
[0002] With the development of science and technology, artificial intelligence technology continues to improve.
[0003] Currently, existing technologies can use task training data to train task processing models, which can provide users with corresponding functional services. Task processing models include single-task models and multi-task models.
[0004] A multi-task model is a model that can simultaneously handle multiple related tasks, such as information retrieval and recommendation. When training a task processing model to handle multiple related tasks, existing technologies can leverage task data from multiple related tasks to train a multi-task model and use it. This eliminates the need to train multiple single-task models for each task separately, effectively reducing computational costs and training time, while improving training efficiency.
[0005] However, existing multi-task model training methods have low reliability. Summary of the Invention
[0006] The present invention provides a blockchain-based model processing method, system, device and medium to address the low reliability defect of the multi-task model training method in the prior art and enhance the reliability of multi-task model training.
[0007] The present invention provides a blockchain-based model processing method, which is applied to a blockchain-based model processing system. The blockchain-based model processing system includes a first edge node and a server. A multi-task model for processing multiple related tasks is deployed in the first edge node. The first edge node is an edge node on a first alliance chain including multiple edge nodes. The blockchain-based model processing method includes:
[0008] The first edge node obtains global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each of the related tasks;
[0009] The first edge node performs an iterative pruning process on the global model parameters based on the task training data of each of the related tasks to obtain a subnet mask for each of the related tasks;
[0010] The first edge node inputs the global model parameters, the model training data, and the subnet mask of each of the related tasks into the task routing network, and obtains the trained first local update parameters output by the task routing network, where the first local update parameters include the current model parameters and current task weights of each of the task subnets;
[0011] The first edge node uploads the first local update parameter to the first alliance chain for consensus, and sends the first local update parameter reached by consensus to the server;
[0012] The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node that is not the first edge node;
[0013] Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask of each of the related tasks and the global model parameters, the model parameters of each task subnet are generated, and the task training data of each of the related tasks are used to carry out multiple rounds of training for each of the task subnets. After each round of training, the current model parameters and current task weights of each of the task subnets are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each of the task subnets are determined as the first local update parameters.
[0014] Optionally, after each round of training, the current model parameters and current task weights of each task subnetwork are updated based on the adaptive loss function, including:
[0015] After each round of training, respectively determining the current historical processing average accuracy, current focusing coefficient, current line-fitting factor, and current training round of each of the related tasks;
[0016] Determine the current task weight of each task subnetwork based on the current historical processing average accuracy, current focusing coefficient, current line-fitting factor and current training round of each related task;
[0017] Determining an overall focal loss of the multi-task model based on the current task weights of each of the task subnetworks;
[0018] The current model parameters and current task weights of each of the task subnetworks are updated based on the overall focal loss.
[0019] Optionally, the first edge node stores a first node reputation value that has been agreed upon and is used to verify whether the node has maliciously uploaded erroneous parameters; and sending the first local update parameter that has been agreed upon to the server includes:
[0020] The first edge node sends first local data to the server, where the first local data includes the first local update parameter and the first node reputation value that have been agreed upon;
[0021] The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter, including:
[0022] The server performs reputation value verification on the first node reputation value and the node reputation value in the local data sent by each of the other edge nodes, and aggregates the local update parameters in the local data sent by the aggregated edge nodes that pass the reputation value verification to generate the aggregated model parameters.
[0023] Optionally, after the first edge node sends the first local data to the server, the blockchain-based model processing method further includes:
[0024] The server verifies the accuracy of the first local update parameter using real data, generates a second node reputation value based on the verification result, and returns the second node reputation value to the first edge node;
[0025] The first edge node uploads the second node's reputation value to the first alliance chain for consensus;
[0026] The first edge node replaces the first node reputation value with the second node reputation value that has been agreed upon.
[0027] Optionally, the blockchain-based model processing system further includes an off-chain storage layer; the first edge node uploading the first local updated parameter to the first consortium chain for consensus includes:
[0028] The first edge node uploads the first identifier to the first alliance chain for consensus; wherein, the first identifier is generated by the off-chain storage layer by performing hash value conversion processing on the first encrypted local update parameter sent by the first edge node and sent to the first edge node, and the first encrypted local update parameter is generated by the first edge node using a public key to encrypt the first local update parameter.
[0029] Optionally, sending the first local update parameter reached on consensus to the server includes:
[0030] The first edge node sends the first identifier that has been agreed upon to the server, so that the server: obtains the first encrypted local update parameter corresponding to the first identifier from the off-chain storage layer, obtains the private key from the first edge node, and uses the private key to decrypt the first encrypted local update parameter to obtain the first local update parameter;
[0031] The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter, including:
[0032] The server verifies the data integrity of the obtained first local update parameters based on the first identifier, and aggregates the local update parameters in the local data sent by the aggregation edge node that passes the data integrity verification to generate the aggregated model parameters.
[0033] A blockchain-based model processing system includes a first edge node and a server. A multi-task model for processing multiple related tasks is deployed in the first edge node. The first edge node is an edge node on a first consortium chain including multiple edge nodes. The first edge node includes: a first obtaining unit, a processing unit, an input unit, a second obtaining unit, a first uploading unit, and a first sending unit.
[0034] The first obtaining unit is used to obtain global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each of the related tasks;
[0035] The processing unit is configured to perform iterative pruning processing on the global model parameters based on the task training data of each of the related tasks, so as to obtain a subnet mask for each of the related tasks;
[0036] The processing unit is configured to input the global model parameters, the model training data, and the subnet mask of each of the related tasks into the task routing network;
[0037] The second obtaining unit is used to obtain the trained first local update parameters output by the task routing network, wherein the first local update parameters include the current model parameters and current task weights of each task subnetwork;
[0038] The first uploading unit is configured to upload the first local update parameter to the first consortium chain for consensus;
[0039] A first sending unit, configured to send the first local update parameter reached by consensus to the server;
[0040] The server is configured to aggregate the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node that is not the first edge node;
[0041] Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask of each of the related tasks and the global model parameters, the model parameters of each task subnet are generated, and the task training data of each of the related tasks are used to carry out multiple rounds of training for each of the task subnets. After each round of training, the current model parameters and current task weights of each of the task subnets are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each of the task subnets are determined as the first local update parameters.
[0042] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, any of the above-mentioned blockchain-based model processing methods is implemented.
[0043] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned blockchain-based model processing methods.
[0044] The present invention provides a blockchain-based model processing method, system, device, and medium. The blockchain-based model processing system includes a first edge node, in which a multi-task model for processing multiple related tasks is deployed. The first edge node obtains global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each related task; the first edge node performs iterative pruning on the global model parameters based on the task training data of each related task to obtain the subnet mask of each related task; the first edge node inputs the global model parameters, the model training data, and the subnet mask of each related task into the task routing network, and obtains the trained first local update parameters output by the task routing network, the first local update parameters including the current model parameters and current task weight of each task subnet; wherein the task routing network generates the first local update parameters by performing the following steps: generating model parameters of each task subnet based on the subnet mask of each related task and the global model parameters, performing multiple rounds of training on each task subnet using the task training data of each related task, updating the current model parameters and current task weight of each task subnet based on an adaptive loss function after each round of training, and determining the current model parameters and current task weight of each task subnet as the first local update parameters when preset training requirements are met. The present invention can use model training data to train each task subnet in the multi-task model separately, taking into account the correlation between different related tasks, dynamically adjusting the weight of each task during the training process, avoiding the problem of unnecessary emphasis on simple tasks and neglect of difficult tasks in the prior art, balancing the weights and priorities of task subnets of different difficulty levels, and reflecting the importance of task subnets of different difficulty levels, thereby enhancing the importance of the training effect of the task subnet of the difficult task in the multi-task model training process, ensuring the model performance of the task subnet of the difficult task, thereby effectively ensuring the model performance of the multi-task model, and effectively enhancing the reliability of the multi-task model training. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0046] Figure 1 This is a flowchart of a blockchain-based model processing method provided by an embodiment of the present invention;
[0047] Figure 2 is a structural diagram of a multi-task mask layer provided by an embodiment of the present invention;
[0048] Figure 3 is a schematic diagram of the structure of a collaborative modeling network provided by an embodiment of the present invention;
[0049] Figure 4 Schematic diagram of the structure of local modeling of a multi-task model provided by an embodiment of the present invention;
[0050] Figure 5 This is an architecture diagram of a blockchain-based model processing system provided by an embodiment of the present invention;
[0051] Figure 6 This is a schematic diagram of the structure of a blockchain-based model processing system provided by an embodiment of the present invention;
[0052] Figure 7 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0053] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.
[0054] The following combination Figure 1-Figure 5 The present invention describes a blockchain-based model processing method.
[0055] like Figure 1 As shown, an embodiment of the present invention proposes a first blockchain-based model processing method, which is applied to a blockchain-based model processing system. The blockchain-based model processing system includes a first edge node, in which a multi-task model for processing multiple related tasks is deployed. The blockchain-based model processing method includes the following steps:
[0056] S101: A first edge node obtains global model parameters and model training data of a multi-task model; wherein the model training data includes task training data of each related task;
[0057] The first edge node may be an edge device with model training capabilities.
[0058] The model training data may be composed of task training data of all related tasks. Specifically, the model training data may allow task training data of one or more related tasks to be empty. In this case, the model training data may be represented by an empty set 0.
[0059] Specifically, the first edge node can obtain model training data from the corresponding IoT device.
[0060] It should be noted that IoT devices can collect task training data based on task requirements. After collecting task training data for one or more related tasks, the IoT device can upload the collected task training data to a first edge node. The first edge node constructs corresponding model training data and uses the model training data to train the multi-task model. This method eliminates the need for IoT devices to have high computing power and storage resources, and effectively reduces the training burden on IoT devices.
[0061] In the present invention, the Internet of Things device can also construct corresponding model training data based on the collected task training data of related tasks, and the Internet of Things device can upload the constructed model training data to the first edge node.
[0062] S102: The first edge node performs iterative pruning on the global model parameters based on the task training data of each related task to obtain the subnet mask of each related task;
[0063] The subnet mask can be used to map out a task subnet from the multi-task model. A task subnet is a part of the model network used to process a related task in the multi-task model.
[0064] Specifically, after obtaining the global model parameters and model training data of the multi-task model, the first edge node may perform iterative pruning on the global model parameters based on the task training data of each related task, so as to generate a task subnet corresponding to each related task in the multi-task model. For example, for the first related task and the second related task, after obtaining the global model parameters and model training data of the multi-task model, the first edge node may perform iterative pruning on the global model parameters based on the task training data of the first related task, so as to generate a task subnet for the first related task. After obtaining the global model parameters and model training data of the multi-task model, the first edge node may perform iterative pruning on the global model parameters based on the task training data of the second related task, so as to generate a task subnet for the second related task.
[0065] Optionally, the first edge node may be provided with an iterative pruning network for performing iterative pruning. Specifically, the first edge node may input the global model parameters and model training data of the multi-task model into the iterative pruning network. The iterative pruning network then iteratively prunes the global model parameters based on the task training data of each relevant task, generating and outputting a subnet mask for each relevant task.
[0066] Specifically, the present invention can be N gloRepresents a multi-task model, using ω and ω t Denote the global model parameters of the multi-task model and the model parameters of the task subnet, respectively. t Represents the task training data of a related task t. The present invention can use iterative pruning network learning mapping Among them, the mapping Ψ pru It can be generated based on the task training data of the related task t. Optionally, in the IoT scenario, the update of the task training data can lead to a change in the task relationship, and the subnet mapping can automatically adapt to this change.
[0067] It should be noted that when the existing technology learns sparse shared architectures, one problem is that the correlation between tasks limits the performance of the collaborative model. For example, when the task types differ greatly, the convergence directions of some intersecting parameters may be opposite. However, the learning method of the multi-task model may ignore this information when setting shared parameters. In the sharing process, tasks related to closure should share larger parameters than loosely related tasks. Therefore, the present invention can train the task training data of each related task separately, and generate a subnet mask by amplitude pruning in the training process based on the lottery hypothesis. The subnet (winning lottery ticket) generated by the dense, randomly initialized network pruning of the present invention can achieve an accuracy comparable to that of the original network.
[0068] Optionally, the first edge node can use a subnet mask generation algorithm to generate the subnet mask of each related task. Specifically, the first edge node can first download the current global model parameter ω glo ; Set pruning rate λ, maximum pruning level P; Model training data D = {D1,…D n}, n is the number of related tasks, D t is the task training data of the task with sequence number t. The algorithm input of the subnet mask generation algorithm may include the current global model parameter ω glo ; Pruning rate λ; Maximum pruning level P; Model training data D = {D1,…D n The execution process of the subnet mask generation algorithm may include:
[0069] 1. Define the number of loops n; n is the number of tasks;
[0070] 2. Initialize the mask and set
[0071] 3. Initialize local basic parameters and set ω glo Assign to ω;
[0072] 4. Training To generate subnet ω t ;
[0073] 5. From ω t Delete the parameters with the lowest amplitude λ%;
[0074] 6. The number of cycles is The amount of data, i and j are coordinates;
[0075] 7. If t [i,j] is pruned, then Set to 0;
[0076] 8. The loop ends;
[0077] 9. If When the mask of task t is
[0078] 10. Otherwise, repeat steps 3-8 to generate a sparser structure;
[0079] 11. Assign to
[0080] 12. End the loop;
[0081] 13. Return
[0082] in, is the mask matrix of task t; is the local mask matrix;
[0083] Among them, λ and P can determine the subnet size. During the execution of the subnet mask generation algorithm, lines 2-3 can be used to initialize the subnet parameters and masks, lines 4-11 can generate a mask matrix with a pruning level of P for each task, and line 13 can return the local mask list.
[0084] It should be noted that the present invention can use amplitude pruning to generate a subnet mask, and the mapping of the multi-task model and the task subnet can be generated by the subnet mask. Each task can have a corresponding subnet mask As the device training data is updated, the iterative neural network can adaptively adjust the subnet mask Specifically, Can be a mask matrix.
[0085] Optionally, for each relevant task t, there can be a corresponding task training dataset use To represent the loss of the task subnet of the related task t during forward mapping. Objective function To optimize IPN, the function can be:
[0086]
[0087] in, represents the inner product.
[0088] S103, the first edge node inputs the global model parameters, model training data and the subnet mask of each relevant task into the task routing network;
[0089] The task routing network may be a network used to train task subnetworks for respective related tasks based on respective task data.
[0090] Specifically, after obtaining the subnet mask of each related task, the first edge node can input the global model parameters of the multi-task model, model training data and the subnet mask of each related task into the task routing network, and the task routing network will train the task subnet of each related task respectively.
[0091] S104: The first edge node obtains the trained first local update parameters output by the task routing network, where the first local update parameters include the current model parameters and current task weights of each task subnet;
[0092] Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask and global model parameters of each related task, the model parameters of each task subnet are generated, and the task training data of each related task are used to carry out multiple rounds of training for each task subnet. After each round of training, the current model parameters and current task weights of each task subnet are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each task subnet are determined as the first local update parameters.
[0093] The first local update parameter may be a local update parameter of the first edge node. It should be noted that other edge nodes may also update the local update parameter of the first edge node. Figure 1 The method shown is used to obtain model training data, use the model training data to train the multi-task model, and obtain local update parameters.
[0094] Specifically, after receiving the global model parameters, model training data, and the subnet mask of each related task, the task routing network can use the subnet mask of each related task and the global model parameters to generate the model parameters of each task subnet, and then use the task training data of each related task to perform model training on each task subnet. For example, for a first related task and a second related task, the task routing network can use the subnet mask of the first related task and the global model parameters to generate the model parameters of the first task subnet, and then use the task training data of the first related task to perform model training on the first task subnet.
[0095] It should be noted that in multiple rounds of training, each round of training can be used to train each task subnetwork separately using the task training data of each related task.
[0096] The preset training requirements may include preset training parameters, such as a preset number of training rounds, a focusing coefficient, and a discount factor.
[0097] Specifically, the task routing network may end training when the training has reached a preset training requirement and output the trained first local update parameter.
[0098] Optionally, after each round of training, the model parameters and task weights of each task subnetwork are updated based on the adaptive loss function, including:
[0099] After each round of training, the current historical processing average accuracy, current focusing coefficient, current line-fitting factor, and current training round of each relevant task are determined;
[0100] Determine the current task weight of each task subnetwork based on the current historical processing average accuracy, current focusing coefficient, current line-fitting factor, and current training round of each related task;
[0101] Determine the overall focal loss of the multi-task model based on the current task weights of each task subnetwork;
[0102] Update the current model parameters and current task weights of each task subnetwork based on the overall focal loss.
[0103] It should be noted that at the end of each round of training, the present invention can use test data to test the current task subnet of each relevant task, record the performance of the current task subnet, and calculate the relevant performance indicators of the current task subnet, such as the current historical processing average accuracy, the current focusing coefficient and the current line-fitting factor.
[0104] Among them, the line-fitting factor can be used to measure the performance priority of related tasks in the recent history.
[0105] Optionally, the present invention can utilize a collaborative modeling algorithm to perform subnet training of the task routing network and loss calculation of the adaptive loss function. Specifically, the input of the collaborative modeling algorithm may include a discount factor ξ, a training round τ, a focusing coefficient γ, and a subnet mask Assisting in the execution of modeling algorithms can include:
[0106] 1. Initialize local parameters and set ω glo Assign to ω;
[0107] 2. Initialize the task weight, let
[0108] 3. Number of cycles τ;
[0109] 4. The number of cycles c = n, where n is the number of tasks;
[0110] 5. Obtain the subnet structure through mapping, let
[0111] 6. Using dataset D t Training t ;
[0112] 7. Use the test data to calculate the key performance indicator κ of the current task t ;
[0113] 8. To calculate the weight of the task
[0114] 9. Update the model and let
[0115] 10. The loop ends;
[0116] 11. The loop ends;
[0117] 12. Return to ω τ .
[0118] Among them, ω glo is the global model parameter; is the weight of task t; κ t The effectiveness indicator of the current training model for task t; β t is the ratio of the training dataset of task t to the size of the entire training dataset of the model;
[0119] It should be noted that the implementation of the collaborative modeling algorithm can be controlled by ξ, γ, and τ. ξ and γ determine the priority of the current related task and complex related tasks during training. In the collaborative modeling algorithm, lines 2-3 initialize the basic model parameters and weights for each related task. Lines 5-6 train each related task separately. Lines 7-8 update the weights of each related task in the loss function. Line 9 updates the current task parameters. Line 12 returns the optimized global model parameters.
[0120] It should also be noted that when calculating the overall loss of the multi-task model in the existing technology, for the forward mapping, the loss function can be minimized. To input and optimize ω t , the function can be:
[0121]
[0122] Among them, β t It can represent the ratio of task training data to model training data for the relevant task t, and define β t =m t / m k ;m t The number of data in the training dataset for task t;
[0123] However, the prior art N TRN The multi-task architecture still cannot measure the importance of each task. Specifically, since N TRN Pruning makes the importance of each related task similar and a considerable part of the network parameters overlap. However, since the network cannot automatically adjust the weights between tasks, it always produces confusing results. The present invention can update the weights of different related tasks through an adaptive loss function.
[0124] Specifically, when calculating weights, the present invention can use focus loss instead of cross entropy loss to reduce the weights of simpler tasks. The specific calculation formula can be:
[0125]
[0126] Among them, κ t is the key performance indicator, κ t ∈[0,1];γ t The focus coefficient of task t; the present invention can use the key performance indicator κ t As the weight indicator of task t in the loss function; the present invention can calculate κ based on the current historical processing average accuracy t , the calculation formula can be:
[0127]
[0128] Where τ is the training round, ξ∈[0,1]; γ t is the focusing factor, set γ t >0 reduces the weight of the classification-specific task. The present invention can input ω and D t , and by minimizing the loss function To optimize the global model parameter ω, the function can be:
[0129]
[0130] Among them, γ t Controls the priority of each task. If necessary, the task routing network N rou The main idea is to follow the task routing layer. The present invention can flexibly expand the number of tasks by applying subnet masks in the network layer and reusing units between tasks. In the process of forward propagation, when the type of task training data is determined, the corresponding mask layer can be activated, and the data only flows through the active units when passing through the network structure. Since the number of training rounds is usually much higher than the number of tasks, even if some tasks are not fully optimized, it can be compensated by sharing units of other tasks. Specifically, after pruning training of the iterative pruning network, the present invention can target each relevant task. Build a separate subnet mask training matrix. When the local device processes a multi-task dataset, the binary mask of task t Activated for conditional conversion The final optimized local model uses the union of mask matrices Among them, since the subnet mask is generated through iteration, the optimal subnet mask may change when the task training data is updated. The present invention can select the subnet mask with the best performance.
[0131] In order to better explain the working principle of the task routing network, the present invention proposes Figure 2 and Figure 3 Here, Figure 2 It is a multi-task mask layer set in the task routing network. The multi-task mask layer can map each task subnet from the global model parameters of the multi-task model through each subnet mask in each task mask layer, that is, Among them, the task subnet of the related task 1 can be obtained through the subnet mask To map, the task subnet of the related task 2 can be obtained through the subnet mask To map, the task subnet of the related task N can be obtained by subnet mask To map and obtain; the final optimized local model uses the union of mask matrices Obtained. Among them, β1, β2…β n The ratio of task training data to model training data for each relevant task; Figure 3 Schematic diagram of the collaborative modeling network, including the task routing network and adaptive loss function; the task routing network includes convolution, batch normalization, multi-task mask, maximum pooling + ReLU and linear + classifier, task routing network and adaptive loss function Collaborative modeling can be performed by and Generate trained local update parameters.
[0132] For better explanation Figure 1 The execution process of the method shown in the present invention proposes Figure 4 The schematic diagram of multi-task local modeling is shown in Figure 2. Figure 4 In the multi-task local modeling, multi-task local modeling refers to training a multi-task model on a single edge node such as the first edge node. The basic model is the multi-task model currently being trained on the edge node. The first edge node can input the global model parameters and model training data of the multi-task model into the iterative pruning network to obtain the subnet mask of each related task output by the iterative pruning network. After that, the first edge node can input the global model parameters, model training data and subnet mask of each related task of the multi-task model into the task routing network. The task routing network generates corresponding task subnets based on the global model parameters of the multi-task model and the subnet mask of each related task, and trains each task subnet using the task training data of each related task. The adaptive loss function can adjust the weights of each task during the training of each task subnet by the task routing network.
[0133] It should also be noted that the present invention Figure 1 In steps S101 to S104, the model training data can be used to train each task subnet in the multi-task model separately, taking into account the correlation between different related tasks, and dynamically adjusting the weight of each task during the training process to avoid the problem of unnecessary emphasis on simple tasks and neglect of difficult tasks in the existing technology. The weights and priorities of task subnets of different difficulty levels are balanced, and the importance of task subnets of different difficulty levels is reflected, thereby enhancing the importance of the training effect of the task subnet of the difficult task in the multi-task model training process, ensuring the model performance of the task subnet of the difficult task, thereby effectively ensuring the model performance of the multi-task model and effectively enhancing the reliability of the multi-task model training.
[0134] The blockchain-based model processing method proposed in the present invention is applied to a blockchain-based model processing system. The blockchain-based model processing system includes a first edge node, and a multi-task model for processing multiple related tasks is deployed in the first edge node. The first edge node obtains global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each related task; the first edge node performs iterative pruning on the global model parameters based on the task training data of each related task to obtain the subnet mask of each related task; the first edge node inputs the global model parameters, the model training data, and the subnet mask of each related task into the task routing network, and obtains the trained first local update parameters output by the task routing network, the first local update parameters including the current model parameters and current task weight of each task subnet; wherein the task routing network generates the first local update parameters by performing the following steps: generating model parameters of each task subnet based on the subnet mask of each related task and the global model parameters, performing multiple rounds of training on each task subnet using the task training data of each related task, updating the current model parameters and current task weight of each task subnet based on an adaptive loss function after each round of training, and determining the current model parameters and current task weight of each task subnet as the first local update parameters when preset training requirements are met. The present invention can use model training data to train each task subnet in the multi-task model separately, taking into account the correlation between different related tasks, dynamically adjusting the weight of each task during the training process, avoiding the problem of unnecessary emphasis on simple tasks and neglect of difficult tasks in the prior art, balancing the weights and priorities of task subnets of different difficulty levels, and reflecting the importance of task subnets of different difficulty levels, thereby enhancing the importance of the training effect of the task subnet of the difficult task in the multi-task model training process, ensuring the model performance of the task subnet of the difficult task, thereby effectively ensuring the model performance of the multi-task model, and effectively enhancing the reliability of the multi-task model training.
[0135] based on Figure 1 The present invention proposes a second blockchain-based model processing method. In this method, the first edge node is an edge node on a first consortium chain that includes multiple edge nodes; the blockchain-based model processing system also includes a server; in this case, after step S104, the method may further include:
[0136] S201: The first edge node uploads the first local update parameter to the first alliance chain for consensus;
[0137] S202: The first edge node sends the first local update parameter on which consensus has been reached to the server;
[0138] S203. The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon that is sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node other than the first edge node.
[0139] Optionally, the server may be a cloud server.
[0140] Specifically, all edge nodes on the first alliance chain can obtain corresponding local update parameters. For example, the first edge node can obtain the first local update parameter, and the server can obtain the consensus local update parameters uploaded by each edge node. The server can then aggregate the obtained local update parameters to generate corresponding aggregated update parameters.
[0141] Optionally, the server may send the aggregated updated parameters to each edge node, and each edge node may use the aggregated updated parameters to determine a corresponding multi-task model and use the multi-task model to provide high-quality services to customers.
[0142] It should be noted that after obtaining task training data, IoT devices do not need to upload it to the server for training. Instead, they can send it to the edge node first. The edge node uses the task training data to train the multi-task model, and then sends the locally updated parameters to the server for aggregation. This is a federated learning model.
[0143] It should also be noted that the multi-task training method based on the alliance chain and federated learning of the present invention does not require uploading task training data to the server. Instead, the edge nodes can use the model training data to train the multi-task model, and only the edge nodes on the alliance chain can view the local update parameters of the multi-task model, thereby realizing the privacy protection of the task training data of the IoT device, realizing data traceability, enhancing data security, and effectively utilizing the model training resources of each edge node, effectively improving the model training efficiency.
[0144] The blockchain-based model processing method proposed in the present invention can train multi-task models based on alliance chain technology and distributed training methods. Only the edge nodes on the alliance chain can view the local update parameters of the multi-task model, thereby achieving data traceability and enhancing data security. It can also effectively utilize the model training resources of each edge node, effectively improving model training efficiency.
[0145] Based on the second blockchain-based model processing method described above, the present invention proposes a third blockchain-based model processing method. In this third blockchain-based model processing method, the first edge node stores a consensus-based first node reputation value used to verify whether the node has maliciously uploaded incorrect parameters; step S202 may specifically include step S2021, and step S203 may specifically include steps S2031 and S2032; wherein:
[0146] S2021. The first edge node sends first local data to the server, where the first local data includes a first local update parameter and a first node reputation value that have been agreed upon.
[0147] It should be noted that during the local parameter sharing update process, edge nodes may maliciously upload incorrect parameters, affecting the server's parameter aggregation results. To address this, the inventors of this paper have designed an evaluation mechanism based on confidence factors. This mechanism uses a confidence factor smart contract to dynamically adjust the reputation of edge nodes and leverages the traceability of the consortium chain to regulate edge node behavior. This prevents the impact of malicious edge node uploads of incorrect parameters on aggregation, thereby improving the accuracy of model aggregation.
[0148] Specifically, edge nodes can obtain an initial reputation value by uploading a specified accuracy and confidence factor, and sharing an identifier through the model parameter sharing smart contract. The higher the accuracy of the edge node, the higher the confidence factor it gives and the higher the return value.
[0149] S2031. The server performs reputation value verification on the first node reputation value and the node reputation values in the local data sent by other edge nodes respectively;
[0150] The server compares the reputation value of the first node with a preset reputation value threshold and determines whether the first edge node has passed the reputation value verification based on the comparison result. When the reputation value of the first node is not less than the preset reputation value threshold, it can be determined that the first edge node has passed the reputation value verification; when the reputation value of the first node is less than the preset reputation value threshold, it can be determined that the first edge node has failed the reputation value verification.
[0151] It should be noted that the preset credibility value threshold can be set by technical personnel according to actual conditions, and the present invention does not limit this.
[0152] S2032: The server aggregates the local update parameters in the local data sent by the aggregation edge node that has passed the reputation verification to generate aggregated model parameters.
[0153] Among them, the aggregation edge node is the edge node that has not passed the reputation value verification.
[0154] Specifically, the server can aggregate the local update parameters sent by all aggregation edge nodes that have passed the credibility verification, and prohibit the aggregation of local update parameters sent by aggregation edge nodes that have not passed the credibility verification, so as to avoid the influence of edge nodes that maliciously upload incorrect parameters on the aggregation results, and effectively ensure the training effect and aggregation effect of the multi-task model.
[0155] Optionally, the third blockchain-based model processing method may further include, after step S2021:
[0156] The server verifies the accuracy of the first locally updated parameter using real data, generates a second node reputation value based on the verification result, and returns the second node reputation value to the first edge node;
[0157] The first edge node uploads the second node's reputation value to the first alliance chain for consensus;
[0158] The first edge node replaces the first node reputation value with the consensus-based second node reputation value.
[0159] Specifically, after receiving the local update parameters sent by the edge node, the server can use a small amount of real data to verify the accuracy of the local update parameters. t and the specified accuracy μ a Compare and feedback the reputation value of this round to the edge node based on the comparison result. If the result is significantly different from the specified accuracy, the reputation value R of the edge node is t will be punished for his dishonest behavior. t The penalty is as follows:
[0160]
[0161] Among them, R t is the reputation value of the training node in the tth round; μ t To verify the verification results of the local update parameters; μ a is the specified accuracy; α is the allowable accuracy deviation; R t is the reputation value of the training node in round t; C t is the penalty imposed on the training node in round t for dishonest behavior;
[0162] Among them, μ e =μ t -μ a +α%,μ 1-|e| =1-|μ e |, R′ t-1 =2R t-1 -1, and C t∈[0,10]. Optionally, the confidence factor of each edge node working hard can range from [5,10], and the confidence factor of being damaged can range from [0,5]. The coefficient can be multiplied when punishing to slow down the recovery of reputation value.
[0163] The blockchain-based model processing method proposed in the present invention can effectively avoid the influence of edge nodes that maliciously upload erroneous parameters on the aggregation results, and effectively ensure the training effect and aggregation effect of the multi-task model.
[0164] Based on the second blockchain-based model processing method described above, the present invention proposes a fourth blockchain-based model processing method. In the fourth blockchain-based model processing method, the blockchain-based model processing system also includes an off-chain storage layer; in this case, step S201 may include:
[0165] The first edge node uploads the first identifier to the first alliance chain for consensus; wherein, the first identifier is generated by the off-chain storage layer performing hash value conversion processing on the first encrypted local update parameter sent by the first edge node and sent to the first edge node, and the first encrypted local update parameter is generated by the first edge node using the public key to encrypt the first local update parameter.
[0166] The off-chain storage layer can include storage resources and storage space contributed by IoT devices, edge nodes, and servers. Specifically, the off-chain storage layer can be composed of multiple storage nodes.
[0167] Specifically, after obtaining the first local update parameter, the first edge node may use its stored public key to encrypt the first local update parameter, generate a corresponding first encrypted local update parameter, and send it to the off-chain storage layer;
[0168] Specifically, the off-chain storage layer may perform hash value conversion processing on the first encrypted local update parameter, generate a first identifier, and return it to the first edge node;
[0169] Specifically, after obtaining the first identifier, the first edge node may upload the first identifier to the first alliance chain for consensus.
[0170] Optionally, step S202 may include:
[0171] The first edge node sends the first identifier that has been agreed upon to the server, so that the server: obtains the first encrypted local update parameter corresponding to the first identifier from the off-chain storage layer, obtains the private key from the first edge node, and uses the private key to decrypt the first encrypted local update parameter to obtain the first local update parameter;
[0172] It is understandable that each edge node on the first alliance chain can obtain the identifier corresponding to the local update parameter through the off-chain storage layer, and then upload the identifier to the first alliance chain for consensus.
[0173] Optionally, step S203 may include:
[0174] The server verifies the data integrity of the obtained first local update parameter based on the first identifier, and aggregates the local update parameters in the local data sent by the aggregation edge node that passes the data integrity verification to generate aggregated model parameters.
[0175] Specifically, after uploading the first identifier to the first consortium chain for consensus, the first edge node can send the first identifier that has been agreed upon to the server. The server can then send a parameter acquisition instruction carrying the first identifier to the off-chain storage layer. The off-chain storage layer can retrieve the first encrypted local update parameter corresponding to the first identifier based on the parameter acquisition instruction and return it to the server. The server can then send a key acquisition instruction to the edge node. The edge node can return the key to the server based on the key acquisition instruction. The server can use the key to decrypt the first encrypted local update parameter to obtain the first local update parameter, and verify the integrity of the first local update parameter based on the first identifier.
[0176] Specifically, the server may verify the integrity of the local update parameters generated by each edge node on the first alliance chain respectively, and only aggregate the local update parameters that pass the integrity verification.
[0177] In practical applications, the present invention can carry out relevant data processing processes of edge nodes, off-chain storage layers and servers through steps such as generating keys and configuration blocks, obtaining raw data and data exchange, consensus and aggregation, optimization and distribution.
[0178] Among them, in the process of generating keys and configuration blocks, edge nodes can generate public keys Private Key and anonymous addresses To identify yourself and obtain a certificate To record transactions on the alliance chain. The edge node can initialize the local storage repository at the node of the off-chain storage layer, and then and off-chain storage to generate identities
[0179] In the process of obtaining raw data and exchanging data, the edge node can obtain the model training data sent by the connected IoT device; the edge node can use the model training data to perform local model iterative training, output local update parameters, and use the public key to encrypt the local update parameters to generate encrypted local update parameters. Upload to the off-chain storage layer; the off-chain storage layer can Convert to the corresponding identifier And return to the edge node;
[0180] Among them, in the process of consensus and aggregation, edge nodes can The service type, edge address and timestamp are written into the model parameter sharing smart contract and submitted to the consortium chain consensus to make it traceable. Although other edge nodes on the same chain have the authority to read the data stored in the model parameter sharing smart contract, However, it is not possible to read the corresponding local model parameters. The server can obtain the parameters shared by other edge nodes through the model parameter sharing smart contract. Index and get the corresponding data from the off-chain storage layer To obtain the source model parameters, the server uses the model parameter acquisition smart contract to trigger the key query event (iteration, address, identifier) to request the key. At the same time, the edge node listens for the key query event and returns To decrypt To aggregate the local updated parameters.
[0181] During the optimization and allocation process, the server can obtain the locally updated parameters at each edge node and obtain the aggregated model parameters through aggregation. The server can then encrypt the aggregated model parameters, generate the corresponding encrypted aggregated model parameters, and send the encrypted aggregated model parameters to the off-chain storage layer. The off-chain storage layer can convert the encrypted aggregated model parameters into corresponding identifiers and return the identifiers to the server. The server can assign the identifiers to the participating edge nodes. The edge nodes can then obtain the encrypted aggregated model parameters and secret keys from the off-chain storage layer and the server, respectively, based on the identifiers. They can then use the secret keys to decrypt the encrypted aggregated model parameters to obtain the aggregated model parameters. The integrity of the aggregated model parameters can then be verified based on the identifiers. Once verified, the aggregated model parameters can be used to update the multi-task model.
[0182] It should be noted that the present invention transmits data between edge nodes and servers through the setting of an off-chain storage layer and through encryption and data integrity verification methods, which can effectively avoid security issues such as data leakage and tampering of local update parameters and aggregated model parameters during the transmission process, and effectively improve the security of data transmission.
[0183] It should also be noted that during data transmission, both locally updated parameters and aggregated parameters are encrypted and remain private. This prevents data theft by external devices and edge nodes within the chain. It also keeps honest and curious edge nodes away from the source data when uploading parameters. Even if data is stolen, the actions of edge nodes within the chain are ineffective because they lack the secret key to decrypt it. Furthermore, edge nodes are an integral part of the consortium chain, so their identities are identified by anonymous addresses, making them unable to recognize each other, unable to communicate, and often suspicious of each other. A high reputation for one edge node does not affect other edge nodes. Furthermore, reputation and confidence factors are used to penalize edge nodes for intentionally uploading erroneous or random data, preventing resource waste. In other words, the reputation of malicious and lazy nodes decreases as their erroneous behavior diminishes, reducing their impact on their own results and gradually preventing aggregation. As can be seen, the present invention effectively protects against attacks such as ghost pay, mirroring, overflow, and scanning attacks.
[0184] The blockchain-based model processing method proposed in this invention can transmit data between edge nodes and servers through the setting of an off-chain storage layer and through encryption and data integrity verification. It can effectively avoid security issues such as data leakage and tampering during the transmission of local update parameters and aggregated model parameters, and effectively improve data transmission security.
[0185] Based on the above-mentioned blockchain-based model processing method, the present invention proposes a fifth blockchain-based model processing method. Figure 5 As shown, in the blockchain-based model processing method, the blockchain-based model processing system may include an IoT device layer, an edge blockchain layer, an off-chain storage layer (i.e., an off-chain storage layer), and a cloud service layer; wherein the IoT device layer includes multiple IoT devices, the edge blockchain layer includes multiple edge nodes, the cloud service layer includes multiple cloud servers, and the storage resources and computing resources in the off-chain storage layer are provided by cloud servers, edge nodes, and IoT devices.
[0186] All IoT devices in the IoT device layer correspond to one or more edge nodes in the edge blockchain layer. Each IoT device can collect raw data (task training data) based on task requirements and send it to the corresponding edge node for local training of the multi-task model. After the local model is trained in the edge blockchain layer and aggregated in the cloud service layer, the IoT device receives optimized parameters (i.e., the optimized multi-task model) to provide better service.
[0187] The edge blockchain layer can be composed of edge nodes with high computing power, such as base stations and mobile edge computing servers. Edge nodes in the edge blockchain layer can be divided into multiple clusters based on region. Edge nodes within each cluster can register to form a consortium chain, such as the first consortium chain described above. This allows edge nodes within the same cluster to interact with each other and securely perform local training of multi-task models. Edge nodes can encrypt trained local update parameters and store the encrypted parameters in an off-chain storage layer. Only the hash value representing the model parameters is used as an identifier for uploading to the consortium chain for consensus, reducing the time required for consensus and improving data transmission efficiency. Edge nodes can include block headers and transaction modules. Specifically, any edge node in the edge blockchain layer can exchange data with one or more corresponding cloud servers in the cloud service layer.
[0188] It should be noted that the present invention can evenly distribute all relevant tasks of the multi-task model to different edge nodes, and then distribute the task training data of each relevant task to the edge nodes that process the corresponding relevant tasks. At this time, each edge node has data of one or more relevant tasks; in addition, the task training data of each relevant task can be randomly divided and assigned to the edge nodes. At this time, each edge node can have part of the task training data of the relevant tasks. At this time, the relevant tasks and task training data on each edge node can be unevenly distributed.
[0189] The cloud server in the cloud service layer can have sufficient storage capacity and be trustworthy. The cloud server can obtain data from the consortium chain, obtain encryption parameters (i.e., encrypted local update parameters) from the off-chain storage layer, obtain identifiers from the edge blockchain layer, verify the integrity of the encrypted local update parameters, train the model, aggregate the encrypted local update parameters to obtain aggregate parameters (i.e., the global model parameters of the optimized multi-task model), and return the aggregate parameters to the edge node. The edge node can then return the aggregate parameters (i.e., optimized parameters) to the IoT device.
[0190] The off-chain storage layer can be generated by IoT devices, edge nodes, servers, and other devices, contributing storage and computing resources. Specifically, the off-chain storage layer can include multiple storage nodes, which can collaborate to store a complete dataset, reducing the risk of content leakage. Storage nodes can receive encrypted local update parameters from the edge blockchain layer and return corresponding identifiers to the edge nodes. This layer can expand the storage space of the consortium chain and help reduce the time required for the consortium chain to reach consensus on data.
[0191] It should also be noted that the present invention can protect the privacy and data security of users using IoT devices while also taking into account the correlation between a large number of tasks. The present invention can effectively generate a sparse shared network architecture by iteratively pruning the network, and train each task subnet separately through customized task routing. In addition, the adaptive loss function proposed in the present invention can adjust the weights of each related task, and improve the model sharing performance by encouraging the model to learn more difficult tasks. In addition, the present invention can use on-chain and off-chain collaboration to reduce the storage pressure of on-chain nodes, and use off-chain storage space to improve the efficiency of executing consensus algorithms.
[0192] The blockchain-based model processing system provided by the present invention is described below. The blockchain-based model processing system described below and the blockchain-based model processing method described above can be referenced to each other.
[0193] like Figure 6 As shown, an embodiment of the present invention proposes a blockchain-based model processing system, which includes a first edge node, in which a multi-task model for processing multiple related tasks is deployed; the first edge node includes: a first obtaining unit 101, a processing unit 102, an input unit 103, and a second obtaining unit 104; wherein:
[0194] A first obtaining unit 101 is configured to obtain global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each relevant task;
[0195] The processing unit 102 is configured to perform iterative pruning processing on the global model parameters based on the task training data of each related task, so as to obtain a subnet mask for each related task;
[0196] The processing unit 102 is used to input the global model parameters, model training data and the subnet mask of each relevant task into the task routing network;
[0197] A second obtaining unit 104 is configured to obtain the trained first local update parameters output by the task routing network, where the first local update parameters include the current model parameters and current task weights of each task subnetwork;
[0198] Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask and global model parameters of each related task, the model parameters of each task subnet are generated, and the task training data of each related task are used to carry out multiple rounds of training for each task subnet. After each round of training, the current model parameters and current task weights of each task subnet are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each task subnet are determined as the first local update parameters.
[0199] It should be noted that the specific processing processes of the first obtaining unit 101, the processing unit 102, the input unit 103 and the second obtaining unit 104 and the beneficial effects thereof can be referred to in the present invention. Figure 1 The relevant descriptions of steps S101, S102, S103 and S104 are omitted here.
[0200] Optionally, after each round of training, the current model parameters and current task weights of each task subnetwork are updated based on the adaptive loss function, which is set to:
[0201] After each round of training, the current historical processing average accuracy, current focusing coefficient, current line-fitting factor, and current training round of each relevant task are determined;
[0202] Determine the current task weight of each task subnetwork based on the current historical processing average accuracy, current focusing coefficient, current line-fitting factor, and current training round of each related task;
[0203] Determine the overall focal loss of the multi-task model based on the current task weights of each task subnetwork;
[0204] Update the current model parameters and current task weights of each task subnetwork based on the overall focal loss.
[0205] Optionally, the first edge node is an edge node on a first alliance chain including multiple edge nodes; the blockchain-based model processing system further includes a server, and the first edge node further includes: a first uploading unit and a first sending unit; wherein:
[0206] A first uploading unit is configured to upload the first locally updated parameters trained from the task routing network to the first alliance chain for consensus after obtaining the first locally updated parameters.
[0207] A first sending unit, configured to send the first local update parameter that has been agreed upon to the server;
[0208] The server is configured to aggregate the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node other than the first edge node.
[0209] Optionally, the first edge node stores a consensus-based first node reputation value for verifying whether the node has maliciously uploaded erroneous parameters;
[0210] A first sending unit is configured to send first local data to a server, where the first local data includes a first local update parameter and a first node reputation value that have been agreed upon;
[0211] The server is used to verify the reputation value of the first node and the node reputation value in the local data sent by each other edge node respectively, and aggregate the local update parameters in the local data sent by the aggregation edge node that passes the reputation value verification to generate aggregated model parameters.
[0212] Optionally, the first edge node further includes: a second sending unit and a replacement unit;
[0213] The server is configured to verify the accuracy of the first local update parameter using real data after sending the first local data to the server, generate a second node reputation value based on the verification result, and return the second node reputation value to the first edge node;
[0214] The second sending unit is used to upload the reputation value of the second node to the first alliance chain for consensus;
[0215] The replacement unit is used to replace the first node reputation value with the second node reputation value that has been agreed upon.
[0216] Optionally, the blockchain-based model processing system also includes an off-chain storage layer;
[0217] The first uploading unit is used to upload the first identifier to the first alliance chain for consensus; wherein the first identifier is generated by the off-chain storage layer performing hash value conversion processing on the first encrypted local update parameter sent by the first edge node and sent to the first edge node, and the first encrypted local update parameter is generated by the first edge node using the public key to encrypt the first local update parameter.
[0218] Optionally, the first sending unit is configured to send the first identifier that has been agreed upon to the server, so that the server: obtains a first encrypted local update parameter corresponding to the first identifier from the off-chain storage layer, obtains a private key from the first edge node, and decrypts the first encrypted local update parameter using the private key to obtain the first local update parameter;
[0219] Optionally, the server is configured to verify the data integrity of the obtained first local update parameter based on the first identifier, and aggregate the local update parameters in the local data sent by the aggregation edge node that has passed the data integrity verification to generate aggregated model parameters.
[0220] The blockchain-based model processing system proposed in the present invention can use model training data to train each task subnet in the multi-task model separately, taking into account the correlation between different related tasks, and dynamically adjust the weight of each task during the training process, avoiding the problem of unnecessary emphasis on simple tasks and neglect of difficult tasks in the existing technology, balancing the weights and priorities of task subnets of different difficulty levels, and reflecting the importance of task subnets of different difficulty levels, thereby enhancing the importance of the training effect of the task subnet of difficult tasks in the multi-task model training process, ensuring the model performance of the task subnet of difficult tasks, thereby effectively ensuring the model performance of the multi-task model and effectively enhancing the reliability of multi-task model training.
[0221] Figure 7 An example of a physical structure diagram of an electronic device is shown below. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730, and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other via the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute a blockchain-based model processing method, which is applied to a blockchain-based model processing system. The blockchain-based model processing system includes a first edge node and a server. A multi-task model for processing multiple related tasks is deployed in the first edge node. The first edge node is an edge node on a first alliance chain including multiple edge nodes. The blockchain-based model processing method includes:
[0222] The first edge node obtains global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each related task;
[0223] The first edge node iteratively prunes the global model parameters based on the task training data of each related task to obtain the subnet mask of each related task;
[0224] The first edge node inputs the global model parameters, model training data, and the subnet mask of each relevant task into the task routing network, and obtains the trained first local update parameters output by the task routing network. The first local update parameters include the current model parameters and current task weights of each task subnet;
[0225] The first edge node uploads the first local update parameter to the first alliance chain for consensus, and sends the first local update parameter that has been agreed upon to the server;
[0226] The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node other than the first edge node;
[0227] Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask and global model parameters of each related task, the model parameters of each task subnet are generated, and the task training data of each related task are used to carry out multiple rounds of training for each task subnet. After each round of training, the current model parameters and current task weights of each task subnet are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each task subnet are determined as the first local update parameters.
[0228] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0229] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the blockchain-based model processing method provided by the above methods. The method is applied to a blockchain-based model processing system. The blockchain-based model processing system includes a first edge node and a server. A multi-task model for processing multiple related tasks is deployed in the first edge node. The first edge node is an edge node on a first alliance chain including multiple edge nodes. The blockchain-based model processing method includes:
[0230] The first edge node obtains global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each related task;
[0231] The first edge node iteratively prunes the global model parameters based on the task training data of each related task to obtain the subnet mask of each related task;
[0232] The first edge node inputs the global model parameters, model training data, and the subnet mask of each relevant task into the task routing network, and obtains the trained first local update parameters output by the task routing network. The first local update parameters include the current model parameters and current task weights of each task subnet;
[0233] The first edge node uploads the first local update parameter to the first alliance chain for consensus, and sends the first local update parameter that has been agreed upon to the server;
[0234] The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node other than the first edge node;
[0235] Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask and global model parameters of each related task, the model parameters of each task subnet are generated, and the task training data of each related task are used to carry out multiple rounds of training for each task subnet. After each round of training, the current model parameters and current task weights of each task subnet are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each task subnet are determined as the first local update parameters.
[0236] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the blockchain-based model processing method provided by each of the above methods is implemented. The method is applied to a blockchain-based model processing system. The blockchain-based model processing system includes a first edge node and a server. A multi-task model for processing multiple related tasks is deployed in the first edge node. The first edge node is an edge node on a first alliance chain including multiple edge nodes. The blockchain-based model processing method includes:
[0237] The first edge node obtains global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each related task;
[0238] The first edge node iteratively prunes the global model parameters based on the task training data of each related task to obtain the subnet mask of each related task;
[0239] The first edge node inputs the global model parameters, model training data, and the subnet mask of each relevant task into the task routing network, and obtains the trained first local update parameters output by the task routing network. The first local update parameters include the current model parameters and current task weights of each task subnet;
[0240] The first edge node uploads the first local update parameter to the first alliance chain for consensus, and sends the first local update parameter that has been agreed upon to the server;
[0241] The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node other than the first edge node;
[0242] Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask and global model parameters of each related task, the model parameters of each task subnet are generated, and the task training data of each related task are used to carry out multiple rounds of training for each task subnet. After each round of training, the current model parameters and current task weights of each task subnet are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each task subnet are determined as the first local update parameters.
[0243] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.
[0244] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.
[0245] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A model processing method based on blockchain, characterized in that: A blockchain-based model processing system is applied to the system, comprising a first edge node and a server, wherein a multi-task model for processing multiple related tasks is deployed in the first edge node, and the first edge node is an edge node on a first consortium chain including multiple edge nodes; the blockchain-based model processing method comprises: The first edge node obtains global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each of the related tasks; The first edge node performs an iterative pruning process on the global model parameters based on the task training data of each of the related tasks to obtain a subnet mask for each of the related tasks; The first edge node inputs the global model parameters, the model training data, and the subnet mask of each of the related tasks into the task routing network, and obtains the trained first local update parameters output by the task routing network, where the first local update parameters include the current model parameters and current task weights of each of the task subnets; The first edge node uploads the first local update parameter to the first alliance chain for consensus, and sends the first local update parameter reached by consensus to the server; The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node that is not the first edge node; Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask of each of the related tasks and the global model parameters, the model parameters of each task subnet are generated, and the task training data of each of the related tasks are used to carry out multiple rounds of training for each of the task subnets. After each round of training, the current model parameters and current task weights of each of the task subnets are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each of the task subnets are determined as the first local update parameters.
2. The blockchain-based model processing method according to claim 1, characterized in that: After each round of training, the current model parameters and current task weights of each task subnetwork are updated based on the adaptive loss function, including: After each round of training, respectively determining the current historical processing average accuracy, current focusing coefficient, current line-fitting factor, and current training round of each of the related tasks; Determine the current task weight of each task subnetwork based on the current historical processing average accuracy, current focusing coefficient, current line-fitting factor and current training round of each related task; Determining an overall focal loss of the multi-task model based on the current task weights of each of the task subnetworks; The current model parameters and current task weights of each of the task subnetworks are updated based on the overall focal loss.
3. The blockchain-based model processing method according to claim 1, characterized in that: The first edge node stores a first node reputation value that has been agreed upon and is used to verify whether the node has maliciously uploaded an erroneous parameter. The sending of the first local update parameter that has been agreed upon to the server includes: The first edge node sends first local data to the server, where the first local data includes the first local update parameter and the first node reputation value that have been agreed upon; The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter, including: The server performs reputation value verification on the first node reputation value and the node reputation value in the local data sent by each of the other edge nodes, and aggregates the local update parameters in the local data sent by the aggregated edge nodes that pass the reputation value verification to generate the aggregated model parameters.
4. The blockchain-based model processing method according to claim 3, characterized in that: After the first edge node sends the first local data to the server, the blockchain-based model processing method further includes: The server verifies the accuracy of the first local update parameter using real data, generates a second node reputation value based on the verification result, and returns the second node reputation value to the first edge node; The first edge node uploads the second node's reputation value to the first alliance chain for consensus; The first edge node replaces the first node reputation value with the second node reputation value that has been agreed upon.
5. The blockchain-based model processing method according to claim 1, characterized in that: The blockchain-based model processing system further includes an off-chain storage layer; the first edge node uploads the first local update parameter to the first consortium chain for consensus, including: The first edge node uploads the first identifier to the first alliance chain for consensus; wherein, the first identifier is generated by the off-chain storage layer by performing hash value conversion processing on the first encrypted local update parameter sent by the first edge node and sent to the first edge node, and the first encrypted local update parameter is generated by the first edge node using a public key to encrypt the first local update parameter.
6. The blockchain-based model processing method according to claim 5, characterized in that: The sending the first local update parameter reached by consensus to the server includes: The first edge node sends the first identifier that has been agreed upon to the server, so that the server: obtains the first encrypted local update parameter corresponding to the first identifier from the off-chain storage layer, obtains a private key from the first edge node, and uses the private key to decrypt the first encrypted local update parameter to obtain the first local update parameter; The server aggregates the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter, including: The server verifies the data integrity of the obtained first local update parameters based on the first identifier, and aggregates the local update parameters in the local data sent by the aggregation edge node that passes the data integrity verification to generate the aggregated model parameters.
7. A blockchain-based model processing system, characterized in that: The system comprises a first edge node and a server, wherein a multi-task model for processing multiple related tasks is deployed in the first edge node, and the first edge node is an edge node on a first alliance chain including multiple edge nodes; the first edge node comprises: a first obtaining unit, a processing unit, an input unit, a second obtaining unit, a first uploading unit, and a first sending unit; wherein: The first obtaining unit is used to obtain global model parameters and model training data of the multi-task model; wherein the model training data includes task training data of each of the related tasks; The processing unit is configured to perform iterative pruning processing on the global model parameters based on the task training data of each of the related tasks, so as to obtain a subnet mask for each of the related tasks; The processing unit is configured to input the global model parameters, the model training data, and the subnet mask of each of the related tasks into the task routing network; The second obtaining unit is used to obtain the trained first local update parameters output by the task routing network, wherein the first local update parameters include the current model parameters and current task weights of each task subnetwork; The first uploading unit is configured to upload the first local update parameter to the first consortium chain for consensus; A first sending unit, configured to send the first local update parameter reached by consensus to the server; The server is configured to aggregate the first local update parameter that has been agreed upon and the local update parameter that has been agreed upon sent by at least one other edge node to generate an aggregated update parameter; wherein the other edge node is an edge node that is not the first edge node; Among them, the task routing network generates the first local update parameters by performing the following steps: based on the subnet mask of each of the related tasks and the global model parameters, the model parameters of each task subnet are generated, and the task training data of each of the related tasks are used to carry out multiple rounds of training for each of the task subnets. After each round of training, the current model parameters and current task weights of each of the task subnets are updated based on the adaptive loss function. When the preset training requirements are met, the current model parameters and current task weights of each of the task subnets are determined as the first local update parameters.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the blockchain-based model processing method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the blockchain-based model processing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Global model updating processing method and device
CN114490695A
Systems and methods for calculating validation loss for models in decentralized machine learning
US20210398017A1