Model co-construction method, device and equipment based on blockchain and federated learning
By screening edge server nodes and training nodes based on verifiable random functions on the blockchain, and using quantified compression rules to process model parameters, the problem of insufficient bandwidth of edge devices in federated learning is solved, and high-frequency interactive computing tasks are realized. Support and calculation speed improvements.
Patent Information
- Application Number
- CN202111203259.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-15
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-10-15
AI Technical Summary
In federated learning, edge devices have insufficient bandwidth resources and cannot effectively support the execution of high-frequency interactive computing tasks, resulting in limited communication resources and inability to support model co-construction.
Using a model co-construction method based on blockchain and federated learning, edge server nodes are randomly selected as aggregation nodes in the blockchain through verifiable random functions, training nodes are selected, local models are trained on these nodes, and quantified compression rules are used Compress, decode and aggregate model parameters to achieve iterative training and co-construction of the model.
Quantification technology is used to reduce the number of transmission bits, reduce the consumption of edge device bandwidth resources, increase computing speed, ensure the security and trustworthiness of computing tasks, and support high-frequency interactive computing tasks.
Smart Images

Figure CN114154392B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a method, apparatus, and device for co-building a model based on blockchain and federated learning. Background Art
[0002] The widespread adoption of the Internet of Things (IoT) has significantly increased the number of edge devices, leading to massive amounts of data generated by these devices across wireless networks. Processing and analyzing this data requires machine learning algorithms. Traditional machine learning algorithms require a central controller to collect a certain amount of data for model training. Due to privacy concerns, edge devices may be reluctant to share local data. Therefore, an innovative distributed machine learning algorithm, federated learning, can address this challenge.
[0003] In federated learning, edge devices train local models based on local datasets. The updated local models are then uploaded to a central server for model aggregation. However, due to limited wireless resources and the large number of edge devices, scheduling requirements for edge devices are high. Furthermore, in edge computing scenarios, edge devices have limited bandwidth resources, resulting in limited communication resources. This makes it impossible to support the data transmission between the server and edge devices during the co-building phase, and thus cannot effectively support high-frequency interactive computing tasks. Summary of the Invention
[0004] In view of this, the present application provides a model co-construction method, apparatus and equipment based on blockchain and federated learning, which can solve the technical problem that the bandwidth resources of edge devices in federated learning cannot effectively support the execution of high-frequency interactive computing tasks.
[0005] According to one aspect of the present application, a model co-construction method based on blockchain and federated learning is provided, the method comprising:
[0006] Randomly select an edge server node in the blockchain as an aggregation node based on a verifiable random function, and use the aggregation node to select a preset number of edge device nodes under it as training nodes;
[0007] Training local models based on a preset machine learning algorithm on each of the training nodes, and extracting first model parameters after the local model training is completed;
[0008] compressing the first model parameters according to preset data quantization compression rules, and uploading the compressed first model parameters to the aggregation node;
[0009] Decoding and aggregating the compressed first model parameters using the aggregation node to obtain second model parameters;
[0010] The second model parameters are sent to the training node to continue iteratively training the local model using the second model parameters until model co-construction is achieved among the training nodes.
[0011] According to another aspect of the present application, a model co-construction device based on blockchain and federated learning is provided, the device comprising:
[0012] A screening module is used to randomly select an edge server node in the blockchain as an aggregation node based on a verifiable random function, and use the aggregation node to select a preset number of edge device nodes under it as training nodes;
[0013] A training and extraction module, configured to train local models on the training nodes based on a preset machine learning algorithm, and extract first model parameters after the local model training is completed;
[0014] a processing and uploading module, configured to compress the first model parameters according to a preset data quantization and compression rule, and upload the compressed first model parameters to the aggregation node;
[0015] a decoding and aggregation module, configured to decode and aggregate the compressed first model parameters using the aggregation node to obtain second model parameters;
[0016] A sending module is used to send the second model parameters to the training node, so as to continue to iteratively train the local model using the second model parameters until model co-construction is achieved among the various training nodes.
[0017] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the above-mentioned model co-construction method based on blockchain and federated learning is implemented.
[0018] According to another aspect of the present application, a game account control device is provided, including a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor. When the processor executes the program, the above-mentioned model co-construction method based on blockchain and federated learning is implemented.
[0019] By means of the above technical solution, the present application provides a model co-construction method, device and equipment based on blockchain and federated learning. First, an edge server node can be randomly selected in the blockchain as an aggregation node based on a verifiable random function, and a preset number of edge device nodes under the aggregation node can be selected as training nodes; then, local models can be trained on the training nodes based on a preset machine learning algorithm, and first model parameters can be extracted after the local model training is completed; the first model parameters are further compressed according to a preset data quantization compression rule, and the compressed first model parameters are uploaded to the aggregation node; thereby, the aggregation node is used to decode and aggregate the compressed first model parameters to obtain second model parameters; finally, the second model parameters can be sent to the training node to continue iteratively training the local model using the second model parameters until model co-construction between each training node is achieved. Through the technical solution in the present application, quantization technology can be introduced to perform parameter compression on the generated parameters based on the data quantization compression rule to reduce the number of transmission bits, further reduce the consumption of edge device bandwidth resources by the transmission parameters, thereby improving the computing speed, and effectively supporting the execution of high-frequency interactive computing tasks while ensuring the security and reliability of the computing tasks.
[0020] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] Figure 1 A flowchart of a model co-construction method based on blockchain and federated learning provided in an embodiment of the present application is shown;
[0023] Figure 2 A flowchart of another model co-construction method based on blockchain and federated learning provided in an embodiment of the present application is shown;
[0024] Figure 3 A schematic diagram of the structure of a model co-construction device based on blockchain and federated learning provided in an embodiment of the present application is shown;
[0025] Figure 4 A structural diagram of another model co-construction device based on blockchain and federated learning provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0026] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that, unless there is a conflict, the embodiments and features in the embodiments of the present application can be combined with each other.
[0027] In order to solve the technical problem that the bandwidth resources of edge devices cannot effectively support the execution of high-frequency interactive computing tasks in federated learning, this application provides a model co-construction method based on blockchain and federated learning, such as Figure 1 As shown, the method includes:
[0028] 101. Based on a verifiable random function, an edge server node is randomly selected in the blockchain as an aggregation node, and the aggregation node is used to select a preset number of edge device nodes under it as training nodes.
[0029] The principle of a Verifiable Random Function (VRF) is actually a type of zero-knowledge proof, essentially an application of a one-way function. In this embodiment, VRF can be applied to randomly select an edge server node in the blockchain as an aggregation node. Most consensus algorithms in the blockchain, whether Proof-of-Work (PoW), Proof-of-Stake (PoS), or its derivative, Decentralized Proof-of-Stake (DPOS), require selecting a group or a single node to participate in consensus or block assembly. While this process can be influenced by various factors such as coin holdings, device configuration, and reputation, it must be random and unpredictable. This is where a random algorithm may be used. The purpose of using VRF is somewhat similar to the PoW process: to randomly and securely extract block nodes. Blockchain is a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. A blockchain is essentially a decentralized database, a series of data blocks generated using cryptographic methods. Each data block contains information about a batch of network transactions, which is used to verify the validity of the information (to prevent counterfeiting) and generate the next block.
[0030] For this embodiment, after randomly screening an edge server node, and using the edge server node to randomly screen a preset number of edge device nodes among its subordinate edge device nodes, as training nodes. Further, based on the federated learning technology, the co-construction of the model can be controlled in a preset number of training nodes. Federated learning is a machine learning framework whose design goal is to carry out efficient machine learning between multiple parties or multiple computing nodes under the premise of ensuring information security during big data exchange, protecting terminal data and personal data privacy, and ensuring legality and compliance. Among them, the machine learning algorithms that can be used in federated learning are not limited to neural networks, but also include important algorithms such as random forests. Among them, the number of nodes of the screened edge devices can be set according to the actual application scenario. In view of the fact that the co-construction of the same model corresponding to different edge device nodes is to be achieved, the value of the preset number should be greater than or equal to 2.
[0031] The execution subject of this embodiment can be a device or equipment for user-controlled model co-construction, which can be used to randomly select an edge server node in the blockchain as an aggregation node based on a verifiable random function, and use the aggregation node to select a preset number of edge device nodes under it as training nodes; further use federated learning technology to control the training of local models based on preset machine learning algorithms on the training nodes, and extract the first model parameters after the local model training is completed; further compress the first model parameters according to preset data quantization compression rules, and upload the compressed first model parameters to the aggregation node, so that the aggregation node can use the compressed first model parameters to decode and aggregate them to obtain second model parameters; finally, the second model parameters can be sent to the training node to continue training the local model using the second model parameters, thereby realizing model co-construction between each training node.
[0032] 102. Train local models based on a preset machine learning algorithm on each training node, and extract first model parameters after the local model training is completed.
[0033] Among them, the preset machine learning algorithm can correspond to an existing neural network or random forest algorithm. Specifically, a local model related to the local task of the edge device can be created according to the preset machine learning algorithm. The local model can be any one of the machine learning models such as linear regression model, decision tree model, neural network model, support vector machine model, hidden Markov model, etc., which can be adaptively selected according to actual application requirements and is not specifically limited in this application.
[0034] In a specific application scenario, a corresponding data set can be configured on each training node. When training a local model, the data set can be pre-configured with corresponding labels according to the model application scenario. The data set with configured labels can then be used as a training set for the local model. The training set can then be used to perform supervised training on the local model created based on the preset machine learning algorithm until the local model training is determined to be completed, and the first model parameters configured for the trained local model are extracted.
[0035] 103. Compress the first model parameters according to preset data quantization compression rules, and upload the compressed first model parameters to the aggregation node.
[0036] In specific application scenarios, calculations within the model often use floating-point calculations, which consume relatively large computing resources (space and CPU / GPU time). If other simple numerical types can be used for calculations within the model without affecting the accuracy of the model, the calculation speed will be greatly improved and the consumed computing resources will be greatly reduced. This is especially important for mobile devices. However, ordinary compression algorithms are difficult to compress the space of floating-point types. In view of this, the present application can introduce quantization technology, create preset quantitative compression rules, and compress model parameters based on the preset quantitative compression rules, convert floating-point numerical vectors into integer vectors to reduce the number of transmission bits, further improve the calculation speed, and reduce the consumption of computing resources.
[0037] Specifically, the preset quantization compression rule is as follows: the parameter vector corresponding to the first model parameter obtained through training is taken for absolute value, and each dimension is arranged in ascending order, and divided into three segments. The first segment has dimension values between 0 and 0.1, the second segment has dimension values between 0.1 and 1, and the third segment has dimension values between 1 and +∞. The three segments are then subjected to multi-layer quantization. Specifically, for the multi-layer quantization of the first segment, the training node maps all values within the first segment to 0. For the multi-layer quantization of the second segment, the training node maps the values within the second segment to the row and column positions in a mean matrix. To ensure smooth decoding, an additional decoding matrix needs to be transmitted. The second segment is further divided into four segments from smallest to largest. A 2*2 mean matrix is constructed in the node, and the mean of each of the four segments is filled in, with the row and column positions representing the floating-point parameter values. For the multi-layer quantization of the third segment, the training node truncates the floating-point values within the third segment to retain integers.
[0038] 104. Use an aggregation node to decode and aggregate the compressed first model parameters to obtain second model parameters.
[0039] In this embodiment, when the aggregation node decodes the compressed first model parameters, it may only decode the multi-layer quantization within the second segment. Specifically, the decoding matrix may be used to convert the row and column positions in the mean matrix into the mean values at the corresponding row and column positions. Furthermore, the compressed first model parameters may be obtained based on the 0 value mapped in the first segment, the mean value decoded in the second segment, and the integer bits retained after truncating the decimal places in the third segment. When the compressed first model parameters are aggregated, the average parameter value of all compressed first model parameters may be calculated, and the average parameter value may be determined as a unified second model parameter.
[0040] 105. Send the second model parameters to the training node to continue iteratively training the local model using the second model parameters until model co-construction is achieved among the training nodes.
[0041] In this embodiment, after calculating the second model parameters, the second model parameters can be further sent to each training node so that the local model can be further trained using the second model parameters. By repeating the above iterative training process, each edge device is configured with the same trained machine learning model and the same model parameters, further enabling model co-construction among the training nodes.
[0042] The present embodiment provides a model co-construction method based on blockchain and federated learning. First, an edge server node can be randomly selected in the blockchain as an aggregation node based on a verifiable random function, and a preset number of edge device nodes under the aggregation node can be selected as training nodes. After that, the local model can be trained based on the preset machine learning algorithm on the training node, and the first model parameters can be extracted after the local model training is completed. The first model parameters are further compressed according to the preset data quantization compression rules, and the compressed first model parameters are uploaded to the aggregation node. The aggregation node is then used to decode and aggregate the compressed first model parameters to obtain the second model parameters. Finally, the second model parameters can be sent to the training node to continue training the local model using the second model parameters, thereby realizing model co-construction between each training node. Through the technical solution in this application, quantization technology can be introduced to perform parameter compression on the generated parameters based on the data quantization compression rules to reduce the number of transmission bits, further reduce the consumption of edge device bandwidth resources by the transmission parameters, thereby improving the computing speed. Under the premise of ensuring the security and reliability of the computing tasks, it can effectively support the execution of high-frequency interactive computing tasks.
[0043] Furthermore, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the implementation of this embodiment, this embodiment also provides another model co-construction method based on blockchain and federated learning, such as Figure 2As shown, the method includes:
[0044] 201. Based on a verifiable random function, an edge server node is randomly selected in the blockchain as an aggregation node, and a preset number of edge device nodes under the aggregation node are selected as training nodes.
[0045] 202. Train local models based on a preset machine learning algorithm on each training node, and extract first model parameters after the local model training is completed.
[0046] For this embodiment, as a preferred method, step 202 of the embodiment may specifically include: training a local model based on a preset machine learning algorithm and a local data set on a training node to obtain training results; calculating a loss function based on the training results and the annotation results of the local data set; if the loss function is determined to be less than a preset threshold, the local model training is determined to be completed, and the first model parameter of the local model training is extracted. In particular, when training, local training based on a gradient descent algorithm SGD algorithm may be used to determine whether the local model has passed the training. In particular, the preset threshold value is between 0 and 1, and the value may be set specifically according to the actual usage scenario. It should be noted that the closer the value of the preset threshold is to 1, the higher the training accuracy of the local model, and vice versa.
[0047] 203. Convert the first model parameter into a parameter feature vector, and extract the parameter sub-feature vectors in each feature dimension of the parameter feature vector.
[0048] In a specific application scenario, since the extracted model parameters are often in character form, in this embodiment, after extracting the first model parameter, the first model parameter can be further converted into a parameter feature vector, specifically a d-dimensional parameter feature vector ω = [ω1,…ω i …,ω d ], and extract the parameter sub-feature vectors of each dimension in the d dimension from the parameter feature vector, namely ω1,…ω i …,ω d .
[0049] 204. Determine the preset vector interval to which the parameter sub-eigenvector belongs, and perform vector transformation processing on the parameter sub-eigenvector according to a vector transformation rule corresponding to the preset vector interval.
[0050] Among them, the preset vector interval includes at least a first preset vector interval, a second preset vector interval and a third preset vector interval; based on this, step 204 of the embodiment may specifically include: if it is determined that the parameter sub-feature vector belongs to the first preset vector interval, then according to the first vector conversion rule, the numerical value in the parameter sub-feature vector is mapped to 0; if it is determined that the parameter sub-feature vector belongs to the second preset vector interval, then according to the second vector conversion rule, the numerical value in the parameter sub-feature vector is mapped to the row and column positions of the mean matrix, and a decoding matrix is configured; if it is determined that the parameter sub-feature vector belongs to the third preset vector interval, then according to the third vector conversion rule, the numerical value in the parameter sub-feature vector is mapped to an integer value with decimal places truncated.
[0051] In a specific application scenario, when determining that the parameter sub-feature vector belongs to the second preset vector interval, further mapping the numerical value in the parameter sub-feature vector to the row and column positions of the mean matrix according to the second vector conversion rule, and configuring the decoding matrix, the implementation steps may specifically include: if it is determined that the parameter sub-feature vector belongs to the second preset vector interval, extracting the sub-vector interval to which the parameter sub-feature vector belongs in the second preset vector interval; according to the sub-vector interval to which the parameter sub-feature vector belongs, mapping the numerical value in the parameter sub-feature vector to the row and column positions corresponding to the sub-vector interval, and configuring the decoding matrix.
[0052] Among them, the sub-vector interval includes at least a first sub-vector interval, a second sub-vector interval, a third sub-vector interval, and a fourth sub-vector interval; if the parameter sub-eigenvector belongs to the first sub-vector interval, the numerical value in the parameter sub-eigenvector is mapped to the first row and column position of the mean matrix, and a first decoding matrix is configured; if the parameter sub-eigenvector belongs to the second sub-vector interval, the numerical value in the parameter sub-eigenvector is mapped to the second row and column position of the mean matrix, and a second decoding matrix is configured; if the parameter sub-eigenvector belongs to the third sub-vector interval, the numerical value in the parameter sub-eigenvector is mapped to the third row and column position of the mean matrix, and a third decoding matrix is configured; if the parameter sub-eigenvector belongs to the fourth sub-vector interval, the numerical value in the parameter sub-eigenvector is mapped to the fourth row and column position of the mean matrix, and a fourth decoding matrix is configured.
[0053] In specific application scenarios, the endpoints of the preset vector intervals can be set based on the actual application scenario. As an optional method, for example, based on empirical coefficients, the first preset vector interval can be set to [0, 0.1), the second preset vector interval can be set to [0.1, 1), and the third preset vector interval can be set to [1, +∞); the first sub-vector interval can be set to [0.1, 0.325), the second sub-vector interval can be set to [0.325, 0.55), the third sub-vector interval can be set to [0.55, 0.775), and the fourth sub-vector interval can be set to [0.775, 1).
[0054] Correspondingly, the characteristic description of the formula for performing vector transformation processing on the parameter sub-feature vector according to the vector transformation rule corresponding to the preset vector interval can be:
[0055]
[0056] Right now:
[0057] (1) For vector dimensions whose absolute value is in [0,0.1), perform Q1(ω i ):
[0058] Q1(ω i )=0
[0059] (2) For vector dimensions whose absolute value is in [0.1,1), perform Q2(ω i ):
[0060]
[0061] In order to ensure smooth decoding, an additional decoding matrix needs to be transmitted:
[0062]
[0063] (3) For vector dimensions whose absolute value is in [1, +∞), execute:
[0064] Q1(ω i )=(int)ω i
[0065] 205. If it is determined that the vector conversion process is completed for each parameter sub-feature vector, it is determined that the compression process of the first model parameter is completed, and the compressed first model parameter is uploaded to the aggregation node.
[0066] For example, the first model parameter is converted into a 4-dimensional parameter feature vector ω=[ω1,ω2,ω3,ω4], and the parameter sub-feature vectors in each dimension of the 4 dimensions are extracted from the parameter feature vector, namely ω1,ω2,ω3,ω4. Further, the embodiment step 204 can be performed respectively for ω1,ω2,ω3,ω4, that is, the preset vector interval to which each parameter sub-feature vector belongs is determined, and the parameter sub-feature vector is vector-converted according to the vector conversion rule corresponding to the preset vector interval. After determining that each parameter sub-feature vector has completed the vector conversion process, that is, all floating-point numerical vectors have been converted into integer vectors, it can be further determined that the compression process of the first model parameter is completed. At this time, the first model parameter that has completed the compression process can be uploaded to the aggregation node.
[0067] 206. Use the aggregation node to decode and aggregate the compressed first model parameters to obtain second model parameters.
[0068] In specific application scenarios, before executing the steps of this embodiment, the following steps may be included: generating a quantization level identifier based on the preset vector interval to which the parameter sub-feature vector belongs. For example, a quantization level identifier of 001 may be generated for the first preset vector interval, a quantization level identifier of 002 may be generated for the second preset vector interval, and a quantization level identifier of 003 may be generated for the third preset vector interval. Accordingly, when uploading the compressed first model parameters to the aggregation node, the following steps may be included: uploading the compressed first model parameters and the quantization level identifier to the aggregation node.
[0069] Accordingly, in this embodiment, when using an aggregation node to decode and aggregate the compressed first model parameters to obtain the second model parameters, step 206 of the embodiment may specifically include: using the aggregation node and based on the quantization level identifier, extracting the parameter sub-eigenvectors mapped to the row and column positions of the mean matrix and the corresponding decoding matrix from the first model parameters, performing decoding processing based on the decoding matrix to obtain the decoded first model parameters; calculating the parameter average of each decoded first model parameter, and determining the parameter average as the second model parameter. Continuing with the above example, specifically, the parameter sub-eigenvectors corresponding to the quantization level identifier 002 and the corresponding decoding matrix can be extracted from the first model parameters, and then decoding processing can be performed based on multi-layer quantization within the second segment of the decoding matrix to obtain the average of the sub-vector interval corresponding to the row and column positions of the mean matrix. Furthermore, the compressed first model parameters can be obtained based on the zero value mapped in the first segment, the average value decoded in the second segment, and the integer bits retained after truncating the decimal places in the third segment. When performing aggregation processing on the compressed first model parameters, specifically, a parameter average value of all compressed first model parameters may be calculated, and the parameter average value may be determined as a unified second model parameter.
[0070] 207. Send the second model parameters to the training node to continue iteratively training the local model using the second model parameters until model co-construction is achieved among the training nodes.
[0071] In a specific application scenario, during the federated learning process, the co-construction process for the local model within the training node is dynamic. After the second model parameters are sent to the training node, the local model of each training node will continue to be trained based on the second model parameters. After the training is completed, a first model parameter will be obtained again. Then, the embodiment steps 202 to 207 can be repeatedly executed until the first model parameters corresponding to each training node are the same or relatively close (such as the similarity is less than the preset similarity threshold), and the model co-construction is determined to be completed. Accordingly, for this embodiment, as an optional method, the embodiment step 207 can specifically include: sending the second model parameters to the training node, replacing the first model parameters of the local model with the second model parameters, and repeating the above-mentioned training of the local model, as well as the process of aggregating the model parameters using the aggregation node, until it is determined that the model co-construction between the training nodes is completed.
[0072] By means of the above-mentioned model co-construction method based on blockchain and federated learning, an edge server node can be randomly selected in the blockchain as an aggregation node based on a verifiable random function, and a preset number of edge device nodes under the aggregation node can be selected as training nodes; then, the local model can be trained based on the preset machine learning algorithm on the training node, and the first model parameters can be extracted after the local model training is completed; the first model parameters are further compressed according to the preset data quantization compression rules, and the compressed first model parameters are uploaded to the aggregation node; thereby, the compressed first model parameters are decoded and aggregated by the aggregation node to obtain the second model parameters; finally, the second model parameters can be sent to the training node to continue iteratively training the local model using the second model parameters until the model co-construction between each training node is achieved. Through the technical solution in this application, quantization technology can be introduced to perform parameter compression processing on the generated parameters based on the data quantization compression rules to reduce the number of transmission bits, further reduce the consumption of edge device bandwidth resources by the transmission parameters, thereby improving the computing speed, and effectively supporting the execution of high-frequency interactive computing tasks while ensuring the security and reliability of the computing tasks.
[0073] Further, as Figure 1 and Figure 2 The specific implementation of the method shown in the embodiment of the present application provides a model co-construction device based on blockchain and federated learning, such as Figure 3 As shown, the device includes: a screening module 31, a training extraction module 32, a processing upload module 33, a decoding aggregation module 34, and a sending module 35;
[0074] A screening module 31 may be configured to randomly select an edge server node in the blockchain as an aggregation node based on a verifiable random function, and use the aggregation node to select a preset number of edge device nodes under its control as training nodes;
[0075] A training extraction module 32 is configured to train local models based on a preset machine learning algorithm on each training node, and extract first model parameters after the local model training is completed;
[0076] The processing and uploading module 33 is configured to compress the first model parameters according to a preset data quantization and compression rule, and upload the compressed first model parameters to the aggregation node;
[0077] The decoding and aggregation module 34 may be configured to decode and aggregate the compressed first model parameters using the aggregation nodes to obtain second model parameters;
[0078] The sending module 35 can be used to send the second model parameters to the training node, so as to continue to iteratively train the local model using the second model parameters until the model is jointly built among the training nodes.
[0079] In a specific application scenario, when the first model parameter is compressed according to the preset data quantization compression rule, the processing upload module 33 can be used to convert the first model parameter into a parameter feature vector, and extract the parameter sub-feature vector under each feature dimension of the parameter feature vector; determine the preset vector interval to which the parameter sub-feature vector belongs, and perform vector conversion processing on the parameter sub-feature vector according to the vector conversion rule corresponding to the preset vector interval; accordingly, in order to upload the compressed first model parameter to the aggregation node, the processing upload module 33 can be used to determine that the compression processing of the first model parameter is completed if it is determined that each parameter sub-feature vector has completed the vector conversion processing, and upload the compressed first model parameter to the aggregation node.
[0080] Correspondingly, the preset vector interval includes at least a first preset vector interval, a second preset vector interval and a third preset vector interval. When determining the preset vector interval to which the parameter sub-feature vector belongs and performing vector conversion processing on the parameter sub-feature vector according to the vector conversion rule corresponding to the preset vector interval, the processing upload module 33 can be specifically used to, if it is determined that the parameter sub-feature vector belongs to the first preset vector interval, map the numerical value in the parameter sub-feature vector to 0 according to the first vector conversion rule; if it is determined that the parameter sub-feature vector belongs to the second preset vector interval, map the numerical value in the parameter sub-feature vector to the row and column positions of the mean matrix according to the second vector conversion rule, and configure the decoding matrix; if it is determined that the parameter sub-feature vector belongs to the third preset vector interval, map the numerical value in the parameter sub-feature vector to an integer value with decimal places truncated according to the third vector conversion rule.
[0081] In a specific application scenario, when the numerical values in the parameter sub-feature vector are mapped to the row and column positions of the mean matrix according to the second vector conversion rule and the decoding matrix is configured, the processing upload module 33 can be specifically used to extract the sub-vector interval to which the parameter sub-feature vector belongs in the second preset vector interval if it is determined that the parameter sub-feature vector belongs to the second preset vector interval; according to the sub-vector interval to which the parameter sub-feature vector belongs, the numerical values in the parameter sub-feature vector are mapped to the row and column positions corresponding to the sub-vector interval, and the decoding matrix is configured.
[0082] In specific application scenarios, such as Figure 4 As shown, the device further includes: a generating module 36;
[0083] A generating module 36, which can be used to generate a quantization level number identifier according to the preset vector interval to which the parameter sub-feature vector belongs;
[0084] Accordingly, when uploading the compressed first model parameters to the aggregation node, the processing upload module 33 may be used to upload the compressed first model parameters and the quantization layer number identifier to the aggregation node.
[0085] In a specific application scenario, when the aggregation node is used to decode and aggregate the compressed first model parameters to obtain the second model parameters, the decoding aggregation module 34 can be specifically used to use the aggregation node and, based on the quantization layer number identifier, extract the parameter sub-eigenvectors mapped to the row and column positions of the mean matrix and the corresponding decoding matrix in the first model parameters, perform decoding processing based on the decoding matrix, and obtain the first model parameters after decoding; calculate the parameter average value of each first model parameter after decoding, and determine the parameter average value as the second model parameter.
[0086] In a specific application scenario, when the second model parameters are sent to the training node to continue iteratively training the local model using the second model parameters until model co-construction between each training node is achieved, the sending module 35 can be specifically used to send the second model parameters to the training node, replace the first model parameters of the local model with the second model parameters, and repeat the above-mentioned training of the local model, as well as the process of aggregating the model parameters using the aggregation node, until it is determined that the model co-construction between the training nodes is completed.
[0087] It should be noted that for other corresponding descriptions of the functional units involved in the model co-construction device based on blockchain and federated learning provided in this embodiment, please refer to Figures 1 to 2 The corresponding description will not be repeated here.
[0088] Based on the above Figures 1 to 2The method shown in FIG. 1 is a method for performing the above-mentioned operations. Accordingly, this embodiment further provides a storage medium, which may be volatile or non-volatile, and stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the above-mentioned operations are performed. Figures 1 to 2 The model co-construction method based on blockchain and federated learning is shown.
[0089] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0090] Based on the above Figures 1 to 2 The method shown and Figure 3 、 Figure 4 In order to achieve the above-mentioned purpose, the embodiment of the virtual device shown in the figure further provides a computer device, which includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figures 1 to 2 The model co-construction method based on blockchain and federated learning is shown.
[0091] Optionally, the computer device may further include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a Wi-Fi module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and may optionally include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a Wi-Fi interface), etc.
[0092] Those skilled in the art will understand that the computer device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0093] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the computer device and supports the execution of information processing programs and other software and / or programs. The network communication module is used to enable communication between components within the storage medium and with other hardware and software in the information processing device.
[0094] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware.
[0095] By applying the technical solution of the present application, compared with the current existing technology, the present application can first randomly select an edge server node in the blockchain as an aggregation node based on a verifiable random function, and use the aggregation node to select a preset number of edge device nodes under it as training nodes; then, the local model can be trained based on the preset machine learning algorithm on the training node, and the first model parameters can be extracted after the local model training is completed; the first model parameters are further compressed according to the preset data quantization compression rules, and the compressed first model parameters are uploaded to the aggregation node; thereby, the aggregation node is used to decode and aggregate the compressed first model parameters to obtain the second model parameters; finally, the second model parameters can be sent to the training node to continue iteratively training the local model using the second model parameters until the model co-construction between each training node is achieved. Through the technical solution in the present application, quantization technology can be introduced to perform parameter compression processing on the generated parameters based on the data quantization compression rules to reduce the number of transmission bits, further reduce the consumption of edge device bandwidth resources by the transmission parameters, thereby improving the computing speed, and effectively supporting the execution of high-frequency interactive computing tasks while ensuring the security and reliability of the computing tasks.
[0096] Those skilled in the art will understand that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily required to implement the present application. Those skilled in the art will understand that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the implementation scenario description, or can be changed accordingly and located in one or more devices different from the implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple sub-modules.
[0097] The serial numbers of the above application are for descriptive purposes only and do not represent the advantages or disadvantages of the implementation scenarios. The above disclosure only discloses several specific implementation scenarios of the present application, but the present application is not limited thereto. Any changes that can be conceived by those skilled in the art should fall within the scope of protection of the present application.
Claims
1. A model co-construction method based on blockchain and federated learning, It is characterized in that include: Based on a verifiable random function, randomly select an edge server node in the blockchain as an aggregation node, and use the aggregation node to select a preset number of edge device nodes under it as training nodes; Training local models on the training nodes based on a preset machine learning algorithm, and extracting first model parameters after the local model training is completed; The first model parameter is compressed according to a preset data quantization compression rule, including: converting the first model parameter into a parameter feature vector, extracting a parameter sub-feature vector under each feature dimension of the parameter feature vector, determining a preset vector interval to which the parameter sub-feature vector belongs, and performing vector conversion processing on the parameter sub-feature vector according to a vector conversion rule corresponding to the preset vector interval, if it is determined that each of the parameter sub-feature vectors has completed the vector conversion processing, then it is determined that the first model parameter compression processing is completed, wherein the preset vector interval includes at least a first preset vector interval, a second preset vector interval, and a third preset vector interval, and the determination of the parameter sub-feature vector to which the parameter sub-feature vector belongs A preset vector interval is defined, and a vector conversion process is performed on the parameter sub-feature vector according to a vector conversion rule corresponding to the preset vector interval, including: if it is determined that the parameter sub-feature vector belongs to the first preset vector interval, the numerical value in the parameter sub-feature vector is mapped to 0 according to the first vector conversion rule; if it is determined that the parameter sub-feature vector belongs to the second preset vector interval, the numerical value in the parameter sub-feature vector is mapped to the row and column position of the mean matrix according to the second vector conversion rule, and a decoding matrix is configured; if it is determined that the parameter sub-feature vector belongs to the third preset vector interval, the numerical value in the parameter sub-feature vector is mapped to an integer value with decimal places truncated according to the third vector conversion rule; Generate a quantization layer number identifier according to the preset vector interval to which the parameter sub-feature vector belongs, and upload the compressed first model parameter and the quantization layer number identifier to the aggregation node; The method comprises: using the aggregation node to decode and aggregate the compressed first model parameters to obtain second model parameters, including: using the aggregation node and according to the quantization layer number identifier, extracting the parameter sub-feature vectors mapped to the row and column positions of the mean matrix and the corresponding decoding matrix in the first model parameters, performing decoding according to the decoding matrix to obtain the decoded first model parameters, calculating the parameter average value of each first model parameter after the decoding process, and determining the parameter average value as the second model parameter; The second model parameters are sent to the training node to continue iteratively training the local model using the second model parameters until model co-construction is achieved among the training nodes.
2. The method according to claim 1, It is characterized in that If it is determined that the parameter sub-feature vector belongs to the second preset vector interval, the numerical values in the parameter sub-feature vector are mapped to the row and column positions of the mean matrix according to the second vector conversion rule, and a decoding matrix is configured, including: If it is determined that the parameter sub-feature vector belongs to the second preset vector interval, extracting the sub-vector interval to which the parameter sub-feature vector belongs in the second preset vector interval; According to the sub-vector interval to which the parameter sub-feature vector belongs, the numerical value in the parameter sub-feature vector is mapped to the row and column position corresponding to the sub-vector interval, and a decoding matrix is configured.
3. The method according to claim 1, It is characterized in that The sending the second model parameters to the training node to continue iteratively training the local model using the second model parameters until model co-construction among the training nodes is achieved, includes: The second model parameters are sent to the training node, the first model parameters of the local model are replaced by the second model parameters, and the above-mentioned training of the local model and the process of aggregating the model parameters by the aggregation node are repeated until it is determined that the model co-construction between the training nodes is completed.
4. A model co-construction device based on blockchain and federated learning, It is characterized in that include: A screening module, used to randomly screen an edge server node in the blockchain as an aggregation node based on a verifiable random function, and use the aggregation node to screen a preset number of edge device nodes under it as training nodes; A training extraction module, used for training local models on the training nodes based on a preset machine learning algorithm, and extracting first model parameters after the local model training is completed; A processing upload module is used to compress the first model parameter according to a preset data quantization compression rule, including: converting the first model parameter into a parameter feature vector, extracting a parameter sub-feature vector under each feature dimension of the parameter feature vector, determining the preset vector interval to which the parameter sub-feature vector belongs, and performing vector conversion processing on the parameter sub-feature vector according to the vector conversion rule corresponding to the preset vector interval, if it is determined that each of the parameter sub-feature vectors has completed the vector conversion processing, then it is determined that the compression processing of the first model parameter is completed, wherein the preset vector interval includes at least a first preset vector interval, a second preset vector interval and a third preset vector interval, and the determination of the parameter sub-feature vector The preset vector interval to which the quantity belongs, and performing vector conversion processing on the parameter sub-feature vector according to the vector conversion rule corresponding to the preset vector interval, including: if it is determined that the parameter sub-feature vector belongs to the first preset vector interval, mapping the numerical value in the parameter sub-feature vector to 0 according to the first vector conversion rule, if it is determined that the parameter sub-feature vector belongs to the second preset vector interval, mapping the numerical value in the parameter sub-feature vector to the row and column position of the mean matrix according to the second vector conversion rule, and configuring a decoding matrix, if it is determined that the parameter sub-feature vector belongs to the third preset vector interval, mapping the numerical value in the parameter sub-feature vector to an integer value with decimal places truncated according to the third vector conversion rule; The processing and uploading module is further used to generate a quantization layer number identifier according to the preset vector interval to which the parameter sub-feature vector belongs, and upload the compressed first model parameter and the quantization layer number identifier to the aggregation node; A decoding aggregation module, used to use the aggregation node to decode and aggregate the compressed first model parameters to obtain second model parameters, including: using the aggregation node and according to the quantization layer number identifier, extracting the parameter sub-feature vector mapped to the row and column positions of the mean matrix and the corresponding decoding matrix in the first model parameters, performing decoding according to the decoding matrix to obtain the decoded first model parameters, calculating the parameter average value of each first model parameter after decoding, and determining the parameter average value as the second model parameter; A sending module is used to send the second model parameters to the training node, so as to continue to iteratively train the local model using the second model parameters until model co-construction is achieved among the training nodes.
5. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the model co-construction method based on blockchain and federated learning described in any one of claims 1 to 3 is implemented.
6. A computer device comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, It is characterized in that When the processor executes the computer program, the model co-construction method based on blockchain and federated learning described in any one of claims 1 to 3 is implemented.
