Model training method and device, electronic device, and storage medium

By introducing blockchain technology into federated learning, the accounting nodes obtain accounting rights and update model parameters and put them on the chain, solving the problem of central node being untrusted and malicious feedback, and improving the security and accuracy of model training.

CN114169387BActive Publication Date: 2025-08-22PING AN TECH (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111217158.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-19
Publication Date
2025-08-22
Estimated Expiration
2041-10-19

AI Technical Summary

Technical Problem

In federated learning, the central node is not trusted or the malicious edge node feedbacks the wrong model parameters, resulting in poor model training effect, and the data island phenomenon seriously affects the model performance.

Method used

By introducing blockchain technology, the accounting nodes obtain accounting rights from the original blockchain, update local model parameters, and add new blocks to the blockchain, and update local models using the block model parameter gradient to achieve the security and accuracy of model training.

Benefits of technology

It improves the security and accuracy of model training, prevents malicious nodes from affecting the training effect, solves the data island problem, and improves the overall training effect of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114169387B_ABST
    Figure CN114169387B_ABST
Patent Text Reader

Abstract

This embodiment provides a model training method and apparatus, electronic device, and storage medium, belonging to the field of machine learning technology. The method includes: combining federated learning with blockchain technology to enable accounting nodes that wish to record accounts to obtain accounting rights from the original blockchain, eliminating reliance on a single central node for accounting, thereby improving the security of model training; the accounting nodes update the initial model parameters of the local model based on the accounting rights to obtain target model parameters; based on the target model parameters, the accounting nodes add a new block to be recorded to the original blockchain to obtain the current block; the accounting nodes obtain the block model parameters of the current blockchain; and update the local model based on the gradient of the block model parameters to obtain the target model. By continuously updating the block model parameters to update the local model to obtain the target model, the accuracy of model training can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of machine learning technology, and in particular to a model training method and device, electronic equipment, and storage medium. Background Art

[0002] Machine learning algorithms typically improve model performance by acquiring more data. However, to ensure data security and privacy, data silos often form. To address this issue, federated learning can be considered. By introducing a central node to share model parameters with different edge nodes, the approach protects user privacy while improving model generalization. Current federated learning technology consists of a central node and several edge nodes. This can lead to the central node being distrusted by edge nodes, or malicious edge nodes participating in the federated learning framework and feeding incorrect model parameters back to the central node, ultimately affecting model training and resulting in poor results. Summary of the Invention

[0003] The main purpose of the embodiments of the present disclosure is to propose a model training method and device, electronic device, and storage medium that can improve the training effect of the model.

[0004] To achieve the above objectives, a first aspect of the embodiments of the present disclosure provides a model training method, including:

[0005] Obtain original data from the original blockchain based on the accounting rights;

[0006] updating the initial model parameters of the local model according to the original data to obtain target model parameters;

[0007] Synchronizing the target model parameters to the new block of pre-accounting;

[0008] Adding the new block to the original blockchain to obtain the current blockchain;

[0009] Obtaining block model parameters of the current blockchain;

[0010] The local model is updated according to the gradient of the block model parameters to obtain a target model.

[0011] In some embodiments, before obtaining the original data from the original blockchain according to the accounting rights, the method further includes: obtaining the accounting rights, specifically including:

[0012] Obtaining a preset computing difficulty from the original blockchain;

[0013] Get a random number;

[0014] According to the random number and the computing difficulty, the accounting right is obtained from the original blockchain.

[0015] In some embodiments, updating the initial model parameters of the local model according to the original data to obtain target model parameters includes:

[0016] The initial model parameters of the local model are weighted according to the original data to obtain the target model parameters.

[0017] In some embodiments, adding the new block to the original blockchain to obtain the current blockchain includes:

[0018] The new block is connected to the target block of the original blockchain through a hash pointer to obtain the current blockchain; the target block is the block that is currently the most recently added to the original blockchain.

[0019] In some embodiments, updating the local model according to the gradient of the block model parameter to obtain the target model includes:

[0020] Obtaining a training result of a participant node in the current blockchain; wherein the participant node does not have the accounting right;

[0021] updating the target model parameters according to the training results and the gradients of the block model parameters;

[0022] The local model is updated according to the updated target model parameters to obtain the target model.

[0023] In some embodiments, after updating the initial model parameters of the local model according to the original data to obtain the target model parameters, the method further includes:

[0024] Sending the target model parameters to the participant node of the original blockchain, so that the participant node obtains an update operation opinion based on the target model parameters; wherein the update operation opinion includes agreeing to the update operation; and the participant node does not have the accounting right;

[0025] Counting the number of consents for the update operation;

[0026] If the number of consents is greater than a preset value, the step of adding the new block to the original blockchain to obtain the current blockchain is performed.

[0027] In some embodiments, after updating the local model according to the gradient of the block model parameters to obtain the target model, the method further includes:

[0028] Evaluating the update quality of the target training model to obtain an evaluation result;

[0029] Generate an access time limit for the current blockchain according to the evaluation result.

[0030] A second aspect of the present disclosure provides a model training device, including:

[0031] The first acquisition module is used to obtain original data from the original blockchain according to the accounting right;

[0032] A first updating module is configured to update the initial model parameters of the local model according to the original data to obtain target model parameters;

[0033] Parameter synchronization module: used to synchronize the target model parameters to the new block of pre-accounting;

[0034] Block adding module: used to add the new block to the original blockchain to obtain the current blockchain;

[0035] The second acquisition module is used to obtain the block model parameters of the current blockchain;

[0036] The second updating module is configured to update the local model according to the gradient of the block model parameters to obtain a target model. A third aspect of the embodiment of the present disclosure provides an electronic device, comprising:

[0037] at least one processor, and

[0038] a memory communicatively connected to the at least one processor; wherein,

[0039] The memory stores instructions, and the instructions are executed by the at least one processor so that the at least one processor implements the method as described in any one of the embodiments of the first aspect of the present application when executing the instructions.

[0040] A fourth aspect of the embodiments of the present disclosure provides a computer-readable storage medium, wherein the storage medium stores computer-executable instructions, and the computer-executable instructions are used to enable a computer to execute the method described in any one of the embodiments of the first aspect of the present application.

[0041] The model training method and device, electronic device, and storage medium proposed in the embodiments of the present disclosure combine federated learning with blockchain technology, so that the accounting node that wants to record accounts obtains the accounting rights from the original blockchain, and no longer relies on a single central node for accounting, thereby improving the security of model training. The accounting node updates the initial model parameters of the local model according to the accounting rights to obtain the target model parameters. According to the target model parameters, the accounting node adds the new block to be recorded to the original blockchain to obtain the current block. The accounting node obtains the block model parameters of the current blockchain, updates the local model according to the gradient of the block model parameters to obtain the target model, and updates the local model by continuously updating the block model parameters to obtain the target model, which can improve the accuracy of model training and thus improve the training effect of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 is a first flow chart of the model training method provided by an embodiment of the present disclosure;

[0043] Figure 2 yes Figure 1 Flowchart of step S600 in FIG.

[0044] Figure 3 is a second flow chart of the model training method provided by an embodiment of the present disclosure;

[0045] Figure 4 An overall flow chart of the model training method provided in the embodiment of the present disclosure;

[0046] Figure 5 A block diagram of the module structure of the model training device provided in an embodiment of the present disclosure;

[0047] Figure 6 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present disclosure. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application.

[0049] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.

[0050] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present invention pertains. The terms used herein are for the purpose of describing embodiments of the present invention only and are not intended to limit the present invention.

[0051] First, let’s analyze some of the terms used in this application:

[0052] Artificial intelligence (AI) is a new technical discipline that studies and develops theories, methods, technologies, and application systems for simulating, extending, and expanding human intelligence. A branch of computer science, AI seeks to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing, and expert systems. AI can simulate the information processes of human consciousness and thinking. It also encompasses theories, methods, technologies, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, to perceive the environment, acquire knowledge, and use that knowledge to achieve optimal results.

[0053] Federated machine learning (Federated Learning): also known as federated learning, is a machine learning framework that can effectively help multiple institutions use data and conduct machine learning modeling while meeting the requirements of user privacy protection, data security, and government regulations. Federated machine learning is divided into horizontal federated learning, vertical federated learning, and federated transfer learning.

[0054] Blockchain: From a technological perspective, blockchain involves numerous scientific and technological issues, including mathematics, cryptography, the internet, and computer programming. From an application perspective, blockchain is a distributed, shared ledger and database characterized by decentralization, immutability, full traceability, traceability, collective maintenance, and openness and transparency. These characteristics guarantee blockchain's integrity and transparency, laying the foundation for trust. Blockchain's application scenarios are largely based on its ability to resolve information asymmetry and achieve collaborative trust and concerted action among multiple entities.

[0055] Distribution is a research area in computer science that explores how to break a problem requiring immense computing power into many smaller parts, distribute these parts across multiple computers, and finally combine the results to produce the final result. Distributed network storage technology involves storing data in a decentralized manner across multiple independent machines and devices. Distributed network storage systems utilize a scalable architecture, sharing the storage load across multiple storage servers and locating stored information using location servers. This not only addresses the bottleneck of a single storage server in traditional centralized storage systems, but also improves system reliability, availability, and scalability.

[0056] Consensus mechanism: It is an algorithm for reaching distributed consensus on blockchain transactions. The so-called "consensus mechanism" is to complete the verification and confirmation of transactions in a very short time through the voting of special nodes. For a transaction, if several nodes with unrelated interests can reach a consensus, it can be assumed that the entire network can also reach a consensus on it.

[0057] Proof-of-Work (POW) is an economic countermeasure to service and resource abuse, or denial-of-service attacks. It typically requires users to perform complex, time-consuming calculations, with the answers quickly verified by the service provider. The time, equipment, and energy consumed serve as collateral to ensure that services and resources are being used for genuine needs.

[0058] Proof of Stake (POS): Essentially, it replaces the Proof of Computing Power (PoW) with Proof of Stake. The right to record accounts accrues to the node with the highest stake, rather than the node with the highest computing power. Stake represents a node's ownership of a specific amount of currency, known as coin age or coin days. Coin age is equal to the amount of currency multiplied by the time since the last transaction. In a system using the POS consensus mechanism, the coin age at a given point in time is limited. Long-term holders have a longer coin age, so coin age can be considered their stake in the system.

[0059] Delegated Proof of Stake (DPOS): Based on POS, the role of bookkeeper is specialized. Bookkeepers are first selected using stake as voting power, and then they take turns keeping accounts. All coin holders vote to select a certain number of nodes, who then perform verification and bookkeeping on their behalf. Bookkeepers must maintain a 90% online availability rate. In this consensus mechanism, each node can independently determine which authorized nodes it trusts, and these nodes take turns keeping accounts and generating new blocks.

[0060] Delegated Byzantine Fault Tolerance (DBFT): The Delegated Byzantine Fault Tolerance algorithm selects dedicated bookkeepers (bookkeeping nodes) based on the proportion of equity held. Bookkeepers then reach a consensus through the Byzantine Fault Tolerance algorithm (i.e., a majority voting mechanism) to determine the dynamic participating nodes. DBFT can tolerate any type of error, and multiple dedicated bookkeepers ensure that each block is final and will not fork.

[0061] Hash value: A hash value is a unique and extremely compact numerical representation of a piece of data, mapped from a binary value of any length into a smaller binary value of a fixed length in a hash algorithm. A hash value is a value derived through logical operations based on the file's contents. Different files receive different hash values, so the hash value becomes each file's ID card on eDonkey.

[0062] SHA256 algorithm: The hash value length used by the SHA256 algorithm is 256 bits and is an abstract class.

[0063] Hash pointer: A hash pointer is a data structure that points to a data location and a hash value of the data at that location. A regular pointer can only point to the location of the data, but a hash pointer not only points to the location of the data but also provides a way to verify whether the data has been tampered with.

[0064] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Artificial Intelligence (AI) is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results.

[0065] Fundamental AI technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing, operating / interaction systems, and mechatronics. AI software technologies primarily encompass computer vision, robotics, biometrics, speech processing, natural language processing, and machine learning / deep learning.

[0066] In order to obtain more data to improve the performance of the model, machine learning algorithms are usually used. In order to ensure the security of the data, the data island phenomenon will become more and more serious, seriously affecting the effect of model training. In order to solve the above problems, the federated learning method can be considered. By introducing the concept of a central node, the central node has the authority to update the model parameters, and the model parameters are shared between the central node and different edge nodes to protect user privacy while avoiding the phenomenon of data islands. However, the central node may not be trusted by the edge nodes, or malicious edge nodes may participate in the model training process and feedback incorrect model parameters to the central node, which will eventually affect the training of the model and lead to poor model training results.

[0067] Based on this, the embodiments of the present disclosure provide a model training method and device, an electronic device, and a storage medium, which can improve the training effect of the model.

[0068] The embodiments of the present disclosure provide a model training method and device, an electronic device, and a storage medium, which are specifically illustrated by the following embodiments. First, the model training method in the embodiments of the present disclosure is described.

[0069] The model training method provided by the embodiment of the present disclosure relates to the field of machine learning technology. The model training method provided by the embodiment of the present disclosure can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer or a smart watch, etc.; the server side can be configured as an independent physical server, or as a server cluster or distributed system composed of multiple physical servers, or as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the model training method, etc., but is not limited to the above forms.

[0070] The disclosed embodiments can be used in a wide variety of general or specialized computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communications network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0071] Reference Figure 1 According to the model training method of the first aspect of the embodiment of the present disclosure, it includes but is not limited to steps S100 to S500.

[0072] S100, obtains original data from the original blockchain according to the accounting right;

[0073] S200, updating the initial model parameters of the local model according to the original data to obtain the target model parameters;

[0074] S300, synchronizing the target model parameters to the new block of pre-accounting;

[0075] S400, adding the new block to the original blockchain to obtain the current blockchain;

[0076] S500, obtaining the block model parameters of the current blockchain;

[0077] S600: Update the local model according to the gradient of the block model parameters to obtain the target model.

[0078] In step S100, the accounting node obtains raw data from the original blockchain based on the accounting rights, where the original blockchain refers to a decentralized distributed ledger system, and the raw data refers to the data stored on the current original blockchain. Because the blockchain contains multiple nodes and there is high network latency in the peer-to-peer network, the order of transactions observed by each node cannot be completely consistent. Therefore, in the blockchain of this application, it is necessary to design a mechanism, such as a consensus mechanism, to reach a consensus on the order of transactions occurring within a certain time period. The consensus mechanism plays a core role in the blockchain, determining who has the right to record the transactions, as well as the process and reasons for selecting the right to record the transactions. The accounting node is the node that wants to record accounts in the blockchain. The accounting right refers to the authority of the accounting node to record accounts in the blockchain. In the blockchain-based federated learning framework, the accounting right refers to the right of the accounting node to update the model parameters of the blockchain. Specifically, the accounting node can record the newly added ledger information, such as the block information of the new block, on the blockchain, and the other nodes of the blockchain will synchronize the updated block information in the blockchain. Only nodes with accounting rights can update the ledger information. Nodes without accounting rights do not have the authority to update the ledger information. Restricting some nodes to record accounts through accounting rights can improve security and prevent some malicious nodes from updating false information to the blockchain when all nodes have accounting rights, thereby affecting the effect of model training.

[0079] It should be noted that the consensus mechanisms mentioned in the embodiments of this application include but are not limited to POW, POS, DPOS and Byzantine fault tolerance. In the embodiments of this application, the accounting nodes can adopt the above consensus mechanisms to compete for accounting rights.

[0080] In step S200, the initial model parameters of the local model are updated according to the original data to obtain the target model parameters. After the accounting node has the accounting right, it has the right to update the blockchain information. Before the accounting node updates the blockchain information, it can obtain the original data of the original blockchain and update the local model corresponding to the accounting node according to the original data, that is, the model stored locally by the accounting node. At this time, the local model has not yet been shared on the blockchain. The initial model parameters refer to the model parameters stored in the local model, and the target model parameters are the model parameters after the accounting node updates the initial model parameters according to the update algorithm. Various update algorithms of the embodiment of the present application can be set, such as weighted average, minimum value, maximum value, and median. For example, the initial model parameter is ua, and the local model parameters corresponding to each node in the blockchain are ub1, ub2, ub3, ... ubn. The target model parameter uc after the initial model parameter is updated can be obtained by formula (1) or formula (2) or formula (3):

[0081] uc=min(ua,ub1,ub2,ub3…un) (1)

[0082] uc=max(ua,ub1,ub2,ub3…un) (2)

[0083] uc=mean(ua,ub1,ub2,ub3…un) (3)

[0084] The target model parameter uc of formula (1) is obtained by obtaining the minimum value of the initial model parameter ua and the local model parameters ub1, ub2, ub3, ... ubn of each node; the target model parameter uc of formula (2) is obtained by obtaining the maximum value of the initial model parameter ua and the local model parameters ub1, ub2, ub3, ... ubn of each node; and the target model parameter uc of formula (3) is obtained by obtaining the median of the initial model parameter ua and the local model parameters ub1, ub2, ub3, ... ubn of each node.

[0085] In some embodiments, step S200 specifically includes the steps of weighting the initial model parameters of the local model according to the accounting rights to obtain target model parameters, wherein the weights of the weighted processing can be set according to actual needs. For example, the weights of the initial model parameters of the accounting node can be set higher, and the weights of other nodes in the blockchain can be set lower. The initial model parameters ua of the local model are weighted, and the target model parameters uc obtained can be obtained by formula (4):

[0086] uc=ua*c0+ub1*c1+ub2*c2+ub3*c3....+ubn*cn (4)

[0087] In formula (4), c0 is the weight of the initial model parameter ua, c1 is the weight of the node ub1, c2 is the weight of the node ub2, c3 is the weight of the node ub3, and cn is the weight of the node ubn.

[0088] In step S300, the accounting node synchronizes the target model parameters to the new block for pre-accounting.

[0089] In step S400, the new block is added to the original blockchain to obtain the current blockchain. In other words, the new block is added to the chain to update the blockchain.

[0090] In some embodiments, step S400 specifically includes the steps of: the accounting node connects the new block to the target block of the original blockchain through a hash pointer to obtain the current blockchain; specifically: the accounting node synchronizes the updated target model parameters to the new block, specifically writing the target model parameters into the block header of the new block, and then pointing the new block to the target block of the original blockchain through the hash pointer of the new block, and connecting the new block to the target block to obtain the current blockchain, wherein the target block is the block that is currently the most recently added to the original block, and the current blockchain is the block after the new block is added to the original blockchain.

[0091] In step S500, the accounting node obtains the block model parameters of the current blockchain. The block model parameters refer to the block model parameters corresponding to the training model of the blockchain, wherein the block model parameters are obtained by the model parameters uploaded to the blockchain by each node of the blockchain. The model parameters of each node are combined to obtain the block model parameters, and the training model of the blockchain is trained by the block model parameters. By combining the model parameters of multiple nodes, the results of the blockchain training model are more accurate.

[0092] In step S600, the accounting node updates the local model according to the gradient of the block model parameters to obtain the target model. Specifically, the block model parameters in the training process are continuously adjusted through the gradient transformation of the block model parameters to make the training model achieve the ideal effect and obtain the target model.

[0093] In some embodiments, as Figure 2 As shown, step S600 specifically includes the following steps:

[0094] S610, obtaining training results of participant nodes in the current blockchain;

[0095] S620, updating the target model parameters according to the training results and the gradient of the block model parameters;

[0096] S630: Update the local model according to the updated target model parameters to obtain the target model.

[0097] In steps S610 to S630, the accounting node obtains the training results of the participating nodes in the current blockchain. Participating nodes refer to nodes that do not have accounting rights. The training process for participating nodes is as follows: downloading model parameters, such as blockchain model parameters, from the blockchain. The participating node uses local data to train the model parameters based on the downloaded model parameters to obtain training results. After obtaining the training results, the participating node uploads the training results to the blockchain to achieve data synchronization. The blockchain model parameters include the block information of the new block newly uploaded by the accounting node. The block information of the new block refers to the model parameters of the local model of the new block, as well as the data processed by the accounting node during the accounting process. After obtaining the training results of each participating node, the accounting node aggregates these training results, updates the target model parameters based on the aggregated training results, and updates the local model using the updated target model parameters. During the local model update process, the gradient of the block model parameters can be adjusted to iterate the next round of training on the updated local model until the ideal training effect is achieved. Training is then stopped to obtain the target model.

[0098] In some embodiments, as Figure 3 As shown, before step S100, the accounting node obtains the accounting right, which specifically includes the following steps:

[0099] S710, obtains the preset computing difficulty from the original blockchain;

[0100] S720, obtaining a random number;

[0101] S730, based on the random number and computing power difficulty, obtains the accounting right from the original blockchain.

[0102] In steps S710 to S730, taking the POW mechanism as an example, a certain computational cost is required for a bookkeeping node to obtain bookkeeping rights. The higher the computational cost of a bookkeeping node, the greater the likelihood of being trusted by other nodes. In the blockchain-based federated learning framework of this embodiment of the present application, the bookkeeping node obtains a pre-set computing difficulty from the original blockchain. The computing difficulty is a measure of the difficulty of the blockchain, which measures the computational difficulty required for a node to mine a new block under a given goal. A blockchain network using POW consensus must solve very complex computational problems to find new blocks and maintain network operation, where computational problems refer to mathematical problems. POW stipulates that when a transaction is generated, each node that wants to record the transaction needs to rely on its own computing power to compete with others for the right to record the transaction. The competition method is that every certain preset time, a round of computing power competition will be held. Each node that needs to compete for the right to record the transaction will solve a mathematical value through continuous hash collision. Specifically, by obtaining a random number and then verifying the rationality of this random number, the nodes need to obtain the correct random number within the computing power difficulty, for example, within the range of the target hash (less than or equal to), to obtain the right to record the original block. If the accounting node obtains the correct random number first within the specified solution time, then the accounting node has the right to record the transaction. If the accounting node does not obtain the correct random number within the specified solution time, or the accounting node obtains the correct random number within the specified solution time but the accounting node is not the fastest solving node, then the accounting node cannot have the right to record the transaction.

[0103] It should be noted that in order to facilitate understanding of the principle of competing for accounting rights, the composition of blocks in the blockchain is specifically introduced. Blocks are composed of block headers and block bodies. The block body records transaction data. The block header usually includes the following six parts:

[0104] Part 1: Version number, used to track software / protocol updates.

[0105] Part 2: The hash value of the previous block in the blockchain, calculated using the SHA256 algorithm.

[0106] The third part: Merkle root, a calculation performed to reflect transactions in the block, mainly to solve the efficiency problem of hash calculation of transaction records in the ledger. The hash value of the Merkle tree root of the transaction in the block is also calculated using the SHA256 algorithm.

[0107] The fourth part: timestamp, the approximate time when the block was generated, that is, the time when a new block is added becomes the time when the new block is generated, but its validity requires the approval of other nodes.

[0108] Part 5: Difficulty target, that is, Target is the target value of the proof-of-work algorithm for this block.

[0109] The sixth part: Nonce, a random constant, is used as a counter in the proof-of-work algorithm. This random constant changes every time a hash value is calculated. The process of calculating the Nonce value is to continuously calculate the hash value of the six parts of the block header until a Nonce value is found that makes the block hash less than the Target.

[0110] In some embodiments, the process of competing for accounting rights in an embodiment of the present application is exemplified. It should be understood that the following description is only an illustrative explanation and not a specific limitation to the present application.

[0111] First, a ledger node obtains the difficulty target (Target) and a random constant (Nonce). It then calculates the block header hash value and compares the hash value with the Target. If the hash value is less than or equal to the Target, the calculation ends, and the ledger node obtains the right to record the block for this round. The current Nonce value is recorded in the new block header. If the hash value is greater than the Target, the Nonce value must be continuously modified, such as by re-obtaining a random value or incrementing the Nonce value by 1, and then recalculating the block header hash value. This process continues until the hash value is less than or equal to the Target. Whoever first finds a Nonce value that meets certain conditions, notifies other nodes in the blockchain, and obtains their approval, obtains the right to record the block. Ultimately, the new block packaged by the ledger node that obtains the right to record the block will be connected to the blockchain. At the same time, the data processed by the node will be recorded in the ledgers of all nodes in the network, achieving information synchronization.

[0112] In some embodiments, the model training method mentioned in this application further includes the steps of:

[0113] Send the target model parameters to the participant nodes of the original blockchain so that the participant nodes can obtain update operation opinions based on the target model parameters;

[0114] Count the number of consents for update operations;

[0115] Determine whether the number of consents is greater than a preset value; if yes, execute step S400; if no, execute step S100;

[0116] Specifically, in the step of "sending the target model parameters to the participant nodes of the original blockchain so that the participant nodes obtain update operation opinions based on the target model parameters, and counting the number of consents to the update operation", the accounting node sends the target model parameters to the participant nodes of the original blockchain so that the participant nodes obtain update operation opinions based on the target model parameters, wherein the update operation opinions include consent to the update operation; the participant nodes do not have accounting rights, and the accounting nodes count the number of consents to the update operation. When the participant nodes receive a new block, they will verify it according to their own preset rule list. The rules used by each participant node for verification are not necessarily the same. If the new block fails the verification of the participant node, the block will be rejected, and the participant node's update operation opinion is disapproval of the update operation. If the new block passes the verification of the participant node, the block will be accepted, and the participant node's update operation opinion is consent to the update operation. In actual applications, the preset rules mainly include the following: whether the syntax of the data structure of the new block is correct, whether the block header hash of the new block meets the preset computing difficulty, whether the time of the new block is correct, whether the size of the new block is within the allowed range, whether all transactions in the new block are valid, etc. Each participating node can set different rules to verify the new block, which will not be repeated here.

[0117] After counting the number of consents for the update operation, it is determined whether the number of consents is greater than a preset value. If it is determined that the number of consents is greater than the preset value, step S400 is executed, i.e., the new block to be pre-recorded is added to the original blockchain to obtain the current blockchain. If it is determined that the number of consents is less than or equal to the preset value, step S100 is executed, i.e., the accounting node regains and competes for the accounting right.

[0118] In some embodiments, the process of participating nodes verifying new blocks in an embodiment of the present application is exemplified. It should be understood that the following description is only an exemplary explanation and not a specific limitation of the present application.

[0119] When a bookkeeping node initiates a parameter update, it immediately broadcasts it to nearby nodes. The nearby nodes will check whether the update is valid. If it is valid, the nearby nodes will agree to the update and join the broadcast. When more than half of the nodes in the network agree, the update is officially recognized and written into the block. When half or less of the nodes in the network agree, the update will not be officially recognized and the new block cannot be added to the blockchain. The embodiment of the present application introduces a consensus mechanism. When most nodes agree to the update, the blockchain can be updated. This can effectively prevent malicious behavior that may occur in the centralized network from the central node, ensure that the system can operate smoothly without centralized supervision, and improve the robustness of the system.

[0120] In some embodiments, the model training method mentioned in this application further includes the steps of:

[0121] Evaluate the update quality of the target training model to obtain an evaluation result;

[0122] Generate the access time limit to the current blockchain based on the evaluation results.

[0123] In the step of "evaluating the update quality of the target training model to obtain an evaluation result, and generating an access time limit to the current blockchain based on the evaluation result", in order to encourage each node in the blockchain to actively update the model parameters, promote data flow and maintain high-quality data through accounting, the accounting node will receive certain rewards during the accounting process, such as physical rewards issued by the organizer. Before rewarding the accounting node, the update quality of the target training model updated by the accounting node is first evaluated to obtain an evaluation result. For example, if the accuracy of the target training model is higher than that of the training model before the update, the accounting node is considered to have updated. If an effective update is made, a certain reward can be given to the accounting node. If the accuracy of the target training model is lower than the accuracy of the rapid model before the update, it is considered that the accounting node has made an invalid update. At this time, a certain penalty can be imposed on the accounting node. In practical applications, the reward for the accounting node can be converted into an increase in the time limit for access to the blockchain, and the penalty for the accounting node can be converted into a reduction in the time for access to the blockchain. The accounting node maintains access to the latest model parameters on the blockchain by frequently participating in the accounting process. It should be noted that the specific access time limit can be set according to actual needs and will not be elaborated here.

[0124] In some embodiments, under the chain federated learning framework, the token reward for the accounting node is converted into a time limit for access to the blockchain, where the token is also called a token. The token is an accounting unit attached to the blockchain system and generated and used within the system. The token in the blockchain represents a bill in the financial field and represents points in the gaming field. It is a proof of redemption for certain rights and interests. The token can promote all transfer transactions in the blockchain and is used to maintain the stability of the entire blockchain network.

[0125] Specifically, the token reward release formula (5) is:

[0126] y=x*a*b 0 +x*a*b 1 +x*a*b 2 +…+x*a*b n (5)

[0127] Where x is the block interval of reward decay, a is the initial reward of each block, b is the decay coefficient, n is the time, and y is the total amount of tokens.

[0128] In some embodiments, the time limit for each node can be written into the blockchain protocol. The access time of the node to the block information will be recorded. The specific access time can be calculated by formula (6):

[0129] T=α*t (6)

[0130] Where T represents the access time, t represents the token amount, and α is the exchange coefficient. The time a node spends accessing block information is included in the accounting information. When the access time exceeds, all attempts to access block information are considered illegal.

[0131] In some embodiments, in order to prevent accounting nodes from maliciously feeding back incorrect model parameters, in the early stage of the chain federated learning framework, there are not many nodes in the blockchain, and block updates may be dominated by individual nodes with strong computing power. In order to solve this problem, a certain threshold can be set for the gradient transformation of the model on the chain. The threshold will change with the degree of participation of each node in the blockchain. As the number of nodes participating in the blockchain increases, the difficulty of the node obtaining accounting rights will increase. Therefore, the probability of the malicious behavior of the node being trusted by other nodes will become lower. This measure can prevent certain nodes from maliciously using junk data to obtain junk model parameters, and then uploading the junk model parameters to update the parameters of the entire network. By setting a threshold, the embodiments of the present application can prevent large changes in the parameters of the entire network. Nodes that have made outstanding contributions to the entire network can have their thresholds set high, which means that they are trusted. For nodes that have just participated or provide bad data and bad parameters, their thresholds will be lower, which means that their influence on the entire network is lower. In addition, the behavior of the accounting nodes participating in the blockchain update can also be regularly evaluated, such as evaluating the update quality of the accounting node data set parameters, evaluating the activity of the accounting node accounting participation, etc., wherein the update quality of the accounting node data set and parameters can be obtained by predicting the accuracy rate, specifically: the accuracy rate of the model before the accounting node update is compared with the accuracy rate of the model after the update, and the updated model parameters are used to train the data before the update. If the accuracy rate increases, it is a high-quality parameter, and if the accuracy rate decreases, it is a low-quality parameter. The embodiment of the present application creates a virtuous cycle by taking additional reward and punishment measures, thereby improving the effect of model training.

[0132] In some embodiments, as Figure 4 As shown, the overall process of model training of the embodiment of the present application is exemplified. It should be understood that the following description is only an illustrative explanation and not a specific limitation to the present application.

[0133] The distributed nodes of the blockchain compete for the right to keep accounts, and the nodes that successfully compete for the right to keep accounts will be used as accounting nodes. The accounting nodes will update the model parameters of the local model and put the new blocks to be recorded on the chain. The update quality of the accounting nodes will be evaluated to obtain the evaluation results. If the update quality of the accounting nodes is high, they can obtain certain rewards. The accounting nodes obtain the updated model parameters from the blockchain and iteratively train the local model according to the updated model parameters until the preset training requirements are met. By continuously involving each node in the process of updating the model parameters, the accuracy of the model training can be improved.

[0134] The present disclosure also provides a model training device, such as Figure 5 As shown, the above-mentioned model training method can be implemented. The device includes: a first acquisition module 810, a first update module 820, a parameter synchronization module 830, a block addition module 840, a second acquisition module 850 and a second update module 860. The first acquisition module 810 is used to obtain original data from the original blockchain according to the accounting right; the first update module 820 is used to update the initial model parameters of the local model according to the original data to obtain the target model parameters; the parameter synchronization module 830 is used to synchronize the target model parameters to the new block in the pre-accounting; the block addition module 840 is used to add the new block to the original blockchain to obtain the current blockchain; the second acquisition module 850 is used to obtain the block model parameters of the current blockchain; the second update module 860 is used to update the local model according to the gradient of the block model parameters to obtain the target model.

[0135] The model training device proposed in the embodiment of the present disclosure combines federated learning with blockchain technology by implementing the above-mentioned model training method, so that the accounting node that wants to record accounts obtains the accounting rights from the original blockchain, and no longer relies on a single central node for accounting, thereby improving the security of model training. The accounting node updates the initial model parameters of the local model according to the accounting rights to obtain the target model parameters. According to the target model parameters, the accounting node adds the new block to be recorded to the original blockchain to obtain the current block. The accounting node obtains the block model parameters of the current blockchain, updates the local model according to the gradient of the block model parameters, and obtains the target model. By continuously updating the block model parameters to update the local model and obtain the target model, the accuracy of model training can be improved.

[0136] The present disclosure also provides an electronic device, including:

[0137] at least one processor, and

[0138] a memory communicatively connected to at least one processor; wherein,

[0139] The memory stores instructions, which are executed by at least one processor so that the at least one processor implements a method as described in any one of the embodiments of the first aspect of the present application when executing the instructions.

[0140] The following combination Figure 6 The hardware structure of the electronic device is described in detail. The electronic device includes: a processor 901 , a memory 902 , an input / output interface 903 , a communication interface 904 , and a bus 905 .

[0141] The processor 901 may be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided by the embodiments of the present disclosure.

[0142] The memory 902 can be implemented in the form of ROM (Read Only Memory), static storage device, dynamic storage device or RAM (Random Access Memory). The memory 902 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 902 and is called by the processor 901 to execute the model training method of the embodiment of the present disclosure;

[0143] Input / output interface 903, used to implement information input and output;

[0144] Communication interface 904, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.); and

[0145] Bus 905 , which transmits information between various components of the device (e.g., processor 901 , memory 902 , input / output interface 903 , and communication interface 904 );

[0146] The processor 901 , the memory 902 , the input / output interface 903 and the communication interface 904 are connected to each other in communication within the device via a bus 905 .

[0147] In a fourth aspect, an embodiment of the present disclosure further provides a storage medium, which is a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions, which are used to enable a computer to execute a method as described in any one of the embodiments of the first aspect of the present application.

[0148] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0149] The model training method and device, electronic device, and storage medium proposed in the embodiments of the present disclosure combine federated learning with blockchain technology, so that the accounting node that wants to record accounts obtains the accounting rights from the original blockchain, and no longer relies on a single central node for accounting, thereby improving the security of model training. The accounting node updates the initial model parameters of the local model according to the accounting rights to obtain the target model parameters. According to the target model parameters, the accounting node adds the new block to be recorded to the original blockchain to obtain the current block. The accounting node obtains the block model parameters of the current blockchain, updates the local model according to the gradient of the block model parameters to obtain the target model, and updates the local model by continuously updating the block model parameters to obtain the target model, which can improve the accuracy of model training.

[0150] The embodiments described in the embodiments of the present disclosure are intended to more clearly illustrate the technical solutions of the embodiments of the present disclosure and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.

[0151] It will be understood by those skilled in the art that Figure 1-Figure 4 The technical solutions shown in the figures do not constitute a limitation on the embodiments of the present disclosure, and may include more or fewer steps than those shown in the figures, or a combination of certain steps, or different steps.

[0152] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.

[0153] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.

[0154] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0155] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0156] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0157] 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, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0158] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0159] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store programs, 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.

[0160] The preferred embodiments of the present disclosure are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present disclosure. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present disclosure should be within the scope of the present disclosure.

Claims

1. Model training method, characterized in that, Applied to a bookkeeping node, the method includes: Get the pre-set hashing difficulty from the original blockchain; Get a random number; Obtaining accounting rights from the original blockchain based on the random number and the computing difficulty; Obtaining original data from the original blockchain according to the accounting rights; performing weighted processing on initial model parameters of the local model according to the original data to obtain target model parameters; Synchronizing the target model parameters to the new block of pre-accounting; Adding the new block to the original blockchain to obtain the current blockchain; Obtaining block model parameters of the current blockchain; Obtaining a training result of a participant node in the current blockchain; wherein the participant node does not have the accounting right; updating the target model parameters according to the training results and the gradients of the block model parameters; Update the local model according to the updated target model parameters to obtain a target model; Wherein, after performing weighted processing on the initial model parameters of the local model according to the original data to obtain the target model parameters, the method further includes: Sending the target model parameters to the participant node of the original blockchain, so that the participant node obtains an update operation opinion based on the target model parameters; wherein the update operation opinion includes agreeing to the update operation; and the participant node does not have the accounting right; Counting the number of consents for the update operation; If the number of consents is greater than a preset value, the step of adding the new block to the original blockchain to obtain the current blockchain is performed.

2. The model training method according to claim 1, characterized in that Adding the new block to the original blockchain to obtain the current blockchain includes: The new block is connected to the target block of the original blockchain through a hash pointer to obtain the current blockchain; the target block is the block that is currently the most recently added to the original blockchain.

3. The model training method according to any one of claims 1 to 2, characterized in that After updating the local model according to the updated target model parameters to obtain the target model, the method further includes: Evaluating the update quality of the target model to obtain an evaluation result; Generate an access time limit for the current blockchain according to the evaluation result.

4. Model training device, characterized in that, Applied to a bookkeeping node, the device includes: The first acquisition module is used to obtain original data from the original blockchain according to the accounting right; A first updating module is configured to perform weighted processing on initial model parameters of the local model according to the original data to obtain target model parameters; Parameter synchronization module: used to synchronize the target model parameters to the new block of pre-accounting; Block adding module: used to add the new block to the original blockchain to obtain the current blockchain; The second acquisition module is used to obtain the block model parameters of the current blockchain; A second updating module is configured to obtain training results of participant nodes in the current blockchain; wherein the participant nodes do not have the accounting rights; update the target model parameters based on the training results and the gradient of the block model parameters; and update the local model based on the updated target model parameters to obtain the target model; The device is further configured to: obtain a preset computing difficulty from an original blockchain, obtain a random number, and obtain the accounting right from the original blockchain based on the random number and the computing difficulty; Wherein, after performing weighted processing on the initial model parameters of the local model according to the original data to obtain the target model parameters, the device is further used to: Sending the target model parameters to the participant node of the original blockchain, so that the participant node obtains an update operation opinion based on the target model parameters; wherein the update operation opinion includes agreeing to the update operation; and the participant node does not have the accounting right; Counting the number of consents for the update operation; If the number of consents is greater than a preset value, the step of adding the new block to the original blockchain to obtain the current blockchain is performed.

5. An electronic device, characterized in that The electronic device includes a memory and a processor, wherein a program is stored in the memory, and when the program is executed by the processor, the processor is configured to execute the method according to any one of claims 1 to 3.

6. A computer-readable storage medium, characterized in that The computer readable storage device contains a computer program. When the computer program is executed by a computer, the computer is configured to perform the method according to any one of claims 1 to 3.

Citation Information

Patent Citations

  • Block chain-based participant-trusted federal learning method and device

    CN113467927A