Method and apparatus for model training, electronic device, and storage medium

By electing miner nodes through blockchain technology and consensus mechanism, identifying and discarding malicious nodes based on model parameter similarity, and using non-malicious node parameters for global model fusion, the problems of malicious node pollution and single point of failure of centralized server in federated learning are solved, and more accurate and stable model training is achieved.

CN117155631BActive Publication Date: 2025-11-11CHONGQING ANT CONSUMER FINANCE CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202311099881.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-29
Publication Date
2025-11-11
Estimated Expiration
2043-08-29

AI Technical Summary

Technical Problem

In federated learning across financial institutions, malicious training nodes may forge model parameters to pollute the global model, leading to inaccurate models. Furthermore, centralized servers pose a single point of failure risk, causing the iteration process to crash.

Method used

By employing blockchain technology and utilizing miner nodes through a consensus mechanism to elect malicious nodes based on model parameter similarity, malicious node parameters are discarded, and non-malicious node parameters are used for global model fusion, thus avoiding centralized servers and using model parameters from non-malicious nodes for training.

Benefits of technology

It effectively resists malicious node attacks, improves the accuracy of the global model, avoids the risk of single point of failure, and ensures the stability and reliability of model training.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117155631B_ABST
    Figure CN117155631B_ABST
Patent Text Reader

Abstract

This specification provides methods, apparatus, electronic devices, and storage media for model training. In these embodiments, the malicious value of each target node is inferred by the differences in model parameters between the local models of multiple target nodes. Based on the malicious values ​​of multiple target nodes, malicious nodes are identified from among them. The global model for this round is obtained using the model parameters of non-malicious nodes. In this process, malicious nodes are identified from multiple target nodes, and the global model for this round is obtained using the model parameters of non-malicious nodes, enabling miner nodes to resist attacks from malicious nodes and obtain an accurate global model. Furthermore, miner nodes are elected based on a consensus mechanism, and these miner nodes integrate the local models of this round. Typically, each round determines miner nodes based on a consensus mechanism, therefore the executing entity is different in each round when determining the global model. This avoids the risk of single point of failure inherent in federated learning, which heavily relies on centralized servers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This specification relates to one or more embodiments in the field of blockchain technology, and more specifically, to methods, apparatuses, electronic devices and storage media for model training in the field of blockchain technology. Background Technology

[0002] In consumer finance, artificial intelligence (AI) can help financial institutions improve customer service and provide personalized financial services. AI requires vast amounts of data for model training, but individual financial institutions often possess limited data, typically only a portion of customer data. Therefore, data collaboration between financial institutions is becoming increasingly popular. This collaboration enables the analysis of large amounts of customer data, resulting in accurate AI models that can better serve customers.

[0003] In related technologies, federated learning is generally used to enable data collaboration between financial institutions without requiring customer data to leave their respective locations. Specifically, federated learning uses a centralized server to fuse model parameters uploaded from various training nodes in each iteration. The fused model is then fed back to the training nodes for the next iteration, until a final global model is obtained. However, during this iterative process, malicious training nodes may disrupt federated learning by uploading falsified model parameters to the centralized server, thus polluting the global model generated by federated learning. This can have detrimental effects. Summary of the Invention

[0004] This specification provides one or more embodiments of a method, apparatus, electronic device, and storage medium for model training. This method can, to a certain extent, enable miner nodes to resist attacks from malicious nodes and obtain a more accurate global model. Furthermore, it avoids the risk of single point of failure inherent in federated learning technologies, which heavily rely on a centralized server.

[0005] Firstly, a method for model training is provided, which is executed by a miner node in a blockchain system. The miner node is a node elected by the blockchain system based on a consensus mechanism. The method includes: obtaining model parameters of local models of multiple target nodes in the blockchain system, wherein the miner node belongs to the multiple target nodes; for any target node among the multiple target nodes, determining the malicious value of the target node based on the similarity between the model parameters of the target node and the model parameters of other target nodes, wherein the malicious value is positively correlated with the degree of maliciousness of the target node; determining at least one malicious node from the multiple target nodes based on the malicious values ​​of the multiple target nodes; and fusing the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round.

[0006] In the above technical solution, the degree of each target node in this round is inferred by the differences between the model parameters of each target node among multiple target nodes, thereby determining the malicious value of each target node. Based on the malicious values ​​of multiple target nodes, at least one malicious node is determined from the multiple target nodes, and the model parameters of the malicious node are discarded. The global model for this round is obtained using the model parameters of the non-malicious node. In the above process, the malicious node is determined from the multiple target nodes that upload local models, and the model parameters of the local models uploaded by the non-malicious nodes are used to train the global model for this round, so that the miner node can resist the attack of the malicious node to a certain extent and obtain a more accurate global model. In addition, in one or more embodiments of this specification, during the model training process of this round, the miner node elected based on the consensus mechanism obtains the model parameters of the local models of multiple target nodes, and performs the fusion of the global model for this round based on the model parameters of the multiple local models. Under normal circumstances, the miner node determined by the consensus mechanism is different in each round, so the execution subject is different in one or more embodiments of this specification when determining the global model of each round. This avoids the risk of single point of failure in federated learning technologies, which heavily rely on a centralized server. In other words, if the centralized server fails, the entire federated learning process risks collapsing.

[0007] In conjunction with the first aspect, in some possible implementations, the malicious value of the target node is determined based on the similarity between the model parameters of the target node and the model parameters of other target nodes, including: determining multiple similarities between the model parameters of the target node and the model parameters of other target nodes; and determining the reciprocal of the sum of the multiple similarities as the malicious value of the target node.

[0008] In the above technical solution, the reciprocal of the sum of similarities between the model parameters of the target node and the model parameters of each of the other target nodes is determined as the malicious value of the target node. When the model parameters of the target node are used to refer to the target node, this solution is equivalent to determining the malicious value of the target node as the sum of the distances from the target node to the other target nodes. If the sum of similarities corresponding to the target node is relatively large, it indicates that the model parameters of the target node differ significantly from the model parameters of the other target nodes, suggesting a high probability that the model parameters of the target node are inaccurate, and a high degree of malicious intent towards the miner node in obtaining the global model parameters. In other words, when the miner node fuses multiple model parameters, including those of the target node, it will obtain inaccurate global model parameters.

[0009] Combining the first aspect and the above implementation methods, in some possible implementation methods, determining at least one malicious node from the multiple target nodes based on the malicious values ​​of the multiple target nodes includes: sorting the multiple target nodes in descending order of malicious values; and determining the top number of target nodes among the sorted multiple target nodes as the at least one malicious node.

[0010] In the above technical solution, the miner node sorts the multiple target nodes from largest to smallest based on their malicious values, resulting in a sorted set of target nodes. This allows the miner node to quickly identify at least one malicious node based on its needs. Specifically, the top [number] target nodes in the sorted set are identified as the at least one malicious node because their malicious values ​​are relatively large, indicating a greater degree of malice towards the miner node's acquisition of the global model parameters.

[0011] In combination with the first aspect and the above implementation methods, in some possible implementation methods, the method for determining the target number includes: determining the product between the number of target nodes and a first coefficient to obtain a first value, wherein the first coefficient is the ratio between the number of malicious nodes to be determined and the number of target nodes; and determining the integer part of the first value as the target number.

[0012] In the above technical solution, before the miner node identifies a malicious node from multiple target nodes, it pre-sets the number of malicious nodes. This number is the integer part of the product of the number of target nodes and a first coefficient (the first value), since the product may be a decimal.

[0013] Combining the first aspect and the above implementation methods, in some possible implementation methods, the model parameters of multiple non-malicious nodes among the multiple target nodes are fused to obtain the model parameters of the global model for this round, including any one of the following: based on the model parameters of each non-malicious node and the corresponding weight, the model parameters of the multiple non-malicious nodes are weighted and fused to obtain the model parameters of the global model for this round; the average value of the model parameters of the multiple non-malicious nodes is determined as the model parameters of the global model for this round.

[0014] In the above technical solution, the model parameters of multiple non-malicious nodes are fused in two ways: either by weighted fusion of the model parameters of each non-malicious node with its corresponding weight, or by fusion of the average model parameters of multiple non-malicious nodes, to obtain the model parameters of the global model for this round. This enriches the ways in which miner nodes obtain the model parameters of the global model for this round, making the acquisition process more diverse.

[0015] In combination with the first aspect and the above implementation methods, in some possible implementation methods, the multiple target nodes are determined from multiple nodes included in the blockchain system. The multiple target nodes are nodes that upload model parameters of the local model to the blockchain system within a preset time period. The method further includes: if the round referred to in this round is equal to the preset round, determining the number of times each of the multiple nodes participates in the preset round; based on the number of times each of the multiple nodes participates, the total number of times the multiple nodes participate, the total incentive value, and the second coefficient, allocating a target incentive value to each of the multiple nodes. The target incentive value is used to incentivize each node to participate in the training of the local model. The second coefficient is the ratio between the incentive value allocated to the multiple nodes and the total incentive value.

[0016] In the above technical solution, where the blockchain system includes multiple nodes and the current round refers to a preset round, the miner node rewards the multiple nodes participating in the local model training. Specifically, based on the participation count of each node, the total participation count of the multiple nodes, the total incentive value, and the second coefficient, a target incentive value is allocated to each node, enabling each node to actively participate in the training of other local models in the future.

[0017] Combining the first aspect and the above implementation methods, in some possible implementation methods, after obtaining the model parameters of the global model for this round, the method further includes: obtaining an incentive value based on the third coefficient, the total incentive value and the preset round, the incentive value being used to incentivize the miner node to participate in the training of the global model, the third coefficient being the ratio between the miner incentive value allocated to the miner node and the total incentive value, and the sum of the second coefficient and the third coefficient being 1.

[0018] In the above technical solution, after each round of global model parameter fusion, the miner node obtains an incentive value based on the third coefficient, the total incentive value, and the preset round number; this is the process of rewarding the miner node. During the training of the global model, the miner node consumes its own computing resources (storage, bandwidth, computational load). Therefore, after each round of global model parameter fusion, the miner node obtains an incentive value, causing multiple nodes in the blockchain to compete for the miner node's accounting rights to train the global model.

[0019] Combining the first aspect and the above implementation methods, in some possible implementation methods, the miner node is the node that takes the shortest time to solve the target hash problem among the multiple target nodes. The miner node solves the target hash problem by determining random numbers through a hash algorithm.

[0020] In the above technical solution, the miner node is determined from multiple target nodes based on the workload of the target node. Specifically, each target node uses its own computing power to solve the target hash problem by generating random numbers through a hash algorithm. Since the computing power of each target node differs, the node that takes the shortest time to solve the target hash problem can be determined as the target node.

[0021] Combining the first aspect and the above implementation methods, in some possible implementation methods, after fusing the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round, the method further includes: if the round referred to in this round is equal to the preset round, determining the global model of this round as the target model, which is used to execute the preset transaction; if the round referred to in this round is less than the preset round, publishing the global model of this round to multiple nodes included in the blockchain system, so that the multiple nodes update the model parameters of the global model used in subsequent training.

[0022] In the above technical solution, when the current round equals the preset round, the miner node no longer trains the global model and directly uses the current round's global model as the target model. When the current round is less than the preset round, meaning there are insufficient training iterations, the miner node publishes the current round's global model to multiple nodes within the blockchain system. After these nodes train their local model parameters based on the current round's global model, the model parameters of some of these local models are received by the miner nodes in the next round. These miner nodes then further integrate the model parameters of these local models to obtain the model parameters for the next round's global model. This process continues until the current round equals the preset round. In other words, when there are insufficient training iterations, any miner node among the multiple nodes in the blockchain system can continue training the global model.

[0023] Secondly, a model training apparatus is provided, comprising: an acquisition module for acquiring model parameters of local models of multiple target nodes in a blockchain system, wherein miner nodes belong to the multiple target nodes; a determination module for: determining the malicious value of any target node among the multiple target nodes based on the similarity between the model parameters of the target node and the model parameters of other target nodes, wherein the malicious value is positively correlated with the degree of maliciousness of the target node; and determining at least one malicious node from the multiple target nodes based on the malicious values ​​of the multiple target nodes; and a fusion module for fusing the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round.

[0024] In conjunction with the second aspect, in some possible implementations, the determining module is specifically used to: determine multiple similarities between the model parameters of the target node and the model parameters of other target nodes; and determine the reciprocal of the sum of the multiple similarities as the malicious value of the target node.

[0025] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the determining module is specifically used to: sort the multiple target nodes in descending order of malicious value; and determine the top number of target nodes among the sorted multiple target nodes as the at least one malicious node.

[0026] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the determining module is specifically used to: determine the product between the number of target nodes and the first coefficient to obtain a first value, wherein the first coefficient is the ratio between the number of malicious nodes to be determined and the number of target nodes; and determine the integer part of the first value as the target number.

[0027] In combination with the second aspect and the above implementation methods, in some possible implementation methods, the fusion module is specifically used for any of the following: based on the model parameters and corresponding weights of each non-malicious node, the model parameters of the multiple non-malicious nodes are weighted and fused to obtain the model parameters of the global model for this round; the average value of the model parameters of the multiple non-malicious nodes is determined as the model parameters of the global model for this round.

[0028] In conjunction with the second aspect and the above implementation methods, in some possible implementation methods, the multiple target nodes are determined from multiple nodes included in the blockchain system. The multiple target nodes are nodes that upload model parameters of the local model to the blockchain system within a preset time period. The determining module is also used to determine the number of times each of the multiple nodes participates in the preset round when the round referred to in this round is equal to the preset round. The device also includes: an allocation module, used to allocate a target incentive value to each of the multiple nodes based on the number of participations corresponding to each of the multiple nodes, the total number of participations corresponding to the multiple nodes, the total incentive value, and a second coefficient. The target incentive value is used to incentivize each node to participate in the training of the local model. The second coefficient is the ratio between the incentive value allocated to the multiple nodes and the total incentive value.

[0029] Combining the second aspect and the above implementation methods, in some possible implementation methods, after obtaining the model parameters of the global model in this round, the acquisition module is also used to obtain an incentive value based on the third coefficient, the total incentive value and the preset round. The incentive value is used to incentivize the miner node to participate in the training of the global model. The third coefficient is the ratio between the miner incentive value allocated to the miner node and the total incentive value. The sum of the second coefficient and the third coefficient is 1.

[0030] Combining the second aspect and the above implementation methods, in some possible implementation methods, the miner node is the node that takes the shortest time to solve the target hash problem among the multiple target nodes. The miner node solves the target hash problem by determining a random number through hash calculation.

[0031] Combining the second aspect and the above implementation methods, in some possible implementation methods, after fusing the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round, the determining module is further used to determine the global model for this round as the target model when the round referred to in this round is equal to the preset round, and the target model is used to execute the preset transaction; the device also includes: a sending module, used to publish the global model for this round to multiple nodes included in the blockchain system when the round referred to in this round is less than the preset round, so that the multiple nodes update the model parameters of the global model used in subsequent training.

[0032] Thirdly, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, the electronic device performs the method described in the first aspect or any possible implementation thereof.

[0033] Fourthly, a computer-readable storage medium is provided that stores instructions which, when executed on a computer or processor, cause the computer or processor to perform the methods described in the first aspect or any possible implementation thereof.

[0034] Fifthly, a computer program product containing instructions is provided, which, when run on a computer or processor, causes the computer or processor to perform the method described in the first aspect or any possible implementation thereof. Attached Figure Description

[0035] Figure 1 This is a schematic diagram of a federated learning structure provided in one or more embodiments of this specification;

[0036] Figure 2 This is a schematic diagram of a blockchain-based federated learning structure provided in one or more embodiments of this specification;

[0037] Figure 3 This is a schematic flowchart illustrating a model training method provided in one or more embodiments of this specification;

[0038] Figure 4 This is a schematic diagram of a model training method provided in one or more embodiments of this specification;

[0039] Figure 5 This is a schematic diagram of the structure of a model training apparatus provided in one or more embodiments of this specification;

[0040] Figure 6 This is a schematic diagram of the structure of an electronic device provided in one or more embodiments of this specification. Detailed Implementation

[0041] The technical solutions of one or more embodiments of this specification will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of one or more embodiments of this specification, "multiple" refers to two or more. The terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. The word "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone.

[0042] In financial settings, artificial intelligence (AI) can help financial institutions improve customer service and provide personalized financial services. In some embodiments, intelligent recommendation devices can intelligently recommend financial products to customers based on their existing resource storage within a financial institution. For example, the intelligent recommendation device might recommend financial product 1 to customer A based on their existing resource storage within financial institution B. For instance, financial product 1 might involve periodically storing existing resource storage in financial institution B for N years, where N is a positive integer. To enable the intelligent recommendation device to recommend financial products, related technologies train the recommendation model using large amounts of resource storage data. However, the amount of resource storage data held by a single financial institution is often limited, resulting in inaccurate recommendation models. Therefore, data collaboration between financial institutions is becoming increasingly popular. This collaboration allows related technologies to analyze large amounts of resource storage data, thereby obtaining accurate recommendation models that recommend target products based on customers' existing resource storage. In some embodiments, the target product is a financial product.

[0043] In related technologies, federated learning is commonly used to enable data collaboration among multiple financial institutions without requiring the storage resources of multiple clients to leave the institution. Federated learning is essentially a distributed machine learning approach, and its architecture includes distributed devices and an aggregation server. In some embodiments, the distributed devices act as clients, and the aggregation server is a centralized server. A schematic diagram of its architecture is shown below. Figure 1 As shown, clients (such as tablets, mobile phones, and IoT devices) jointly train the model under the coordination of the central server. Each client trains its local model using local data. The central server merges the local models from multiple clients to obtain a global model. After multiple iterations, the central server obtains a model that approximates the result of centralized machine learning.

[0044] Specifically, it can be done through Figure 1 The federated learning architecture shown yields a recommendation model for recommending financial products to customers. Figure 1The system includes multiple clients: Client 1, Client 2, and Client 3. Client 1 corresponds to Financial Institution C, Client 2 to Financial Institution D, and Client 3 to Financial Institution E. When Financial Institution C needs to obtain a recommendation model, Client 1 sends a request to the centralized server. This request includes the preset training rounds, model structure, and initial parameters. Upon receiving the request, the centralized server publishes it to each client. Each client, upon receiving the request, updates its initial parameters based on the available resources in its local database, obtaining the model parameters for the first round of local model training, and uploads them to the centralized server. After receiving the model parameters from multiple first-round local models, the centralized server merges these parameters to obtain the first-round global model. If the first round refers to a round less than the preset rounds, the centralized server publishes the first-round global model to each client. Each client, based on the available resources in its local database, updates the parameters of the first-round global model, obtaining the model parameters for the second round of local model training, and uploads them to the centralized server. After receiving model parameters from multiple local models in the second round, the centralized server fuses these parameters to obtain the global model for the second round, and so on, until the round M equals a preset round. At this point, the centralized server determines the global model for the Mth round as the recommendation model and publishes it to client 1, where M is a positive integer. Through this multi-round iterative process, client 1 can obtain the trained model without the resource storage leaving the local databases of their respective financial institutions. This effectively reduces the risk of data leakage that traditional machine learning requires data sources to be aggregated on a centralized server.

[0045] However, the aforementioned multi-round iterative process heavily relies on a centralized server, which poses a single point of failure risk. In other words, if the centralized server fails, the entire federated learning iterative process will collapse. Furthermore, during the iterative process, malicious clients might upload forged local model parameters to the centralized server, causing inaccurate global models fused by the centralized server, which could have disastrous consequences.

[0046] To address the single point of failure issue present in the aforementioned iterative process, one or more embodiments of this specification introduce blockchain technology. Blockchain technology is a distributed data storage technology that allows data to be stored across multiple blocks, rather than centralized in one location. One or more embodiments of this specification combine blockchain technology with federated learning, that is, removing... Figure 1In this centralized server, the steps of obtaining the global model through multiple rounds are performed by different clients from multiple clients. See details in [link to documentation]. Figure 2 The blockchain system includes a blockchain consisting of at least one block and multiple clients (client 1, client 2, ..., client W, where W is a positive integer). When financial institution C needs to obtain a recommendation model, client 1 sends a request to the blockchain. This request includes the preset training rounds, model structure, and initial parameters. Upon receiving the request, the blockchain packages all parameters included in the request into block 0 (block 0) and publishes the training task to W clients. Each client, upon receiving the request, updates the initial parameters of the model based on the resource storage capacity of its local database, obtaining the model parameters for the first round of local model training, and uploads them to the blockchain. Due to differences in computing power and network conditions among clients, the upload time of the model parameters for each local model may differ. After a preset time, the blockchain merges the model parameters of the local models uploaded by V clients to obtain the first round of global model training, and stores this first round global model in block 1. In this process, the specific entity responsible for fusing the model parameters of V local models within the blockchain is one of the V clients (e.g., client 3). Here, V is a positive integer, and V is less than W. After obtaining the first-round global model, this client determines whether the round it refers to is equal to a preset round. If the round it refers to is equal to the preset round, the client designates the first-round global model as the recommended model. If the round it refers to is less than the preset round, the client publishes the first-round global model to W clients. Each of the W clients, upon receiving the first-round global model, updates the parameters of the first-round global model based on the resource storage capacity of its local database, and so on, until the iteration round equals the preset round, at which point the final round global model is designated as the recommended model. This iterative process ensures that the execution of each iteration of the global model is not always performed by the same client, thus avoiding the single point of failure issue mentioned above.

[0047] It should be noted that the local data (specifically, the customer's resource storage volume) involved in one or more embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use and processing of local data must comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0048] In some embodiments, a client for fusing the local model may be selected from V clients based on a consensus mechanism in blockchain technology. It should be understood that V clients refer to clients that upload the model parameters of their local model to the blockchain within a preset time period. It should be understood that the client used for fusing the local model may differ in each iteration. It should also be understood that the consensus mechanism is the core technology of blockchain technology for establishing trust, reaching consensus, and achieving decentralization among multiple clients.

[0049] To address the issue of malicious clients forging model parameters of the local model during the aforementioned iteration process, thereby causing inaccuracy in the fused global model, this specification provides a model training method through one or more embodiments. The specific process is as follows.

[0050] Figure 3 This is a schematic flowchart illustrating a model training method provided in one or more embodiments of this specification.

[0051] It should be understood that the model training method provided in one or more embodiments of this specification can be applied to... Figure 2 In one or more embodiments of this specification, a client in a blockchain that is used to merge a local model to obtain a global model is referred to as a miner node. This miner node can be a computer terminal or mobile terminal, etc., with data processing capabilities.

[0052] For example, such as Figure 3 As shown, the method 300 includes:

[0053] Step 302: The miner node obtains the model parameters of the local models of multiple target nodes in the blockchain system, and the miner node belongs to the multiple target nodes.

[0054] It should be understood that "multiple target nodes" in step 302 above can be simply understood as uploading the model parameters of the local model to the client on the blockchain within a preset time period. Figure 2 In the example embodiment, the multiple target nodes are the V clients. The "blockchain system" in step 302 includes a blockchain consisting of at least one block and multiple clients. These multiple clients are clients that train local models based on local data in their own local databases and computing power to obtain model parameters. The local data is client-related privacy data.

[0055] It should also be understood that the "local model" in step 302 above refers to each target node, and is a machine learning model trained by each target node based on local data in its own local database and computing power.

[0056] It should also be understood that the blockchain system includes a blockchain consisting of at least one block and W clients. Each of the W clients can participate in training a local model, but due to differences in computing power and / or network status, the time at which each client uploads the model parameters of its trained local model to the blockchain varies. The blockchain receives the model parameters of the local models uploaded by the clients within a certain preset time period, merges the model parameters of the local models uploaded by V clients within that preset time period, and discards the model parameters of the local models uploaded by other clients received after the preset time period. Here, V clients are some of the W clients, and the other clients are the clients other than V clients among the W clients. The "miner node" in step 302 above is a node elected from multiple target nodes based on a consensus mechanism. This miner node has the right to record transactions, that is, it can merge the model parameters of the local models of multiple target nodes to obtain a global model.

[0057] In some embodiments, the consensus mechanism is either a proof-of-work mechanism or a proof-of-stake mechanism.

[0058] It should be understood that the main characteristic of the proof-of-work mechanism is that the target node needs to produce a result through work of a certain difficulty. In one or more embodiments of this specification, the verifier (blockchain) verifies whether the target node can be identified as a miner node by the result and the time taken to obtain the result.

[0059] It should also be understood that the main characteristic of the proof-of-stake mechanism is that the target node needs to prove that it owns a certain amount of resource storage, i.e., rights.

[0060] The first method: Determine miner nodes through a proof-of-work mechanism.

[0061] In one possible implementation, the miner node is the node that takes the shortest time to solve the target hash problem among the multiple target nodes. The miner node solves the target hash problem by determining a random number through hash calculation.

[0062] In the above technical solution, the miner node is determined from multiple target nodes based on the workload of the target node. Specifically, each target node uses its own computing power to solve the target hash problem by generating random numbers through a hash algorithm. Since the computing power of each target node differs, the node that takes the shortest time to solve the target hash problem can be determined as the target node.

[0063] For example, the target hash problem is as follows: Given the string "Hello, world!", append an integer value called Nonce to the end of the string, and perform a SHA-256 hash calculation on the updated string so that the resulting hash (in hexadecimal representation) begins with "0000". It should be understood that any target node solving this target hash problem needs to continuously increment the Nonce value and perform SHA-256 hash calculations on the newly obtained string. The following is the hash result obtained by a target node in the shortest time using 4251 hash calculations.

[0064] He11o,wor1d! 0=>1312af178c253f84028d480a6adc1e25e81caa44c749ec81976192e2ec934c64;

[0065] He11o,wor1d! 1"=>e9afc424b79e4f6ab42d99c81156d3a17228d6e1eef4139be78e948a9332a7d8;

[0066] He1lo,wor1d! 2"=>ae37343a357a82975916257134cbea225928be8ca2a32aa475cf05fd4266b7; ......;

[0068] He11o,wor1d! 4249"=>c004190b822f1669cac8dc37e761cb73652e7832fb814565702245cf26ebb9e6;

[0069] He11o,wor1d! 4250" =>0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4eg.

[0070] After the 4251st hash result is calculated, the requester (the target node) sends the hash result to the blockchain by adding "4250" after "Hello world!", making the first four bits of the SHA-256 hash "0000". The blockchain directly performs the SHA-256 hash calculation based on "Hello world! 4250", verifies that the target node's calculation is correct, and identifies the target node as a miner node.

[0071] The second method: Determine miner nodes through a proof-of-stake mechanism.

[0072] In some embodiments, the miner node is a first target node among the plurality of target nodes. This first target node can obtain at least one random number from the blockchain based on its own stake, thus acquiring a corresponding number of tickets; and randomly selects a target value from the corresponding number of tickets, generating a target random number based on that target value; and the target random number matches any random number in the tickets. In a financial scenario, this stake refers to the resource storage amount in the first target node.

[0073] Step 304: For any target node among the multiple target nodes, the miner node determines the malicious value of the target node based on the similarity between the model parameters of the target node and the model parameters of other target nodes. The malicious value is positively correlated with the degree of maliciousness of the target node.

[0074] It should be understood that the "maliciousness value of the target node" in the above steps refers to the degree of malice of that target node. Specifically, it can be understood as the difference between the model parameters of that target node and the model parameters of other target nodes. The greater the difference, the greater the degree of malice of the target node. This is because in each iteration of federated learning, each target node uses the same global model locally. Even if the local data used is different, the model parameters of the local model obtained in a limited number of iterations will not differ significantly. If the model parameters of a certain target node differ significantly from the model parameters of other target nodes, that target node may be a node that is deliberately causing damage (malicious node). This malicious node disrupts the process of miner nodes fusing model parameters from multiple local models to obtain an accurate global model by forging the model parameters of their local models.

[0075] It should also be understood that in step 304 above, similarity is used to describe the difference between the model parameters of the target node and the model parameters of other target nodes. The greater the similarity, the smaller the difference between the model parameters of the target node and the model parameters of other target nodes; the smaller the similarity, the greater the difference between the model parameters of the target node and the model parameters of other target nodes.

[0076] It should also be understood that the statement in step 304 above that "the malicious value is positively correlated with the degree of malice of the target node" can be interpreted as: the larger the malicious value of the target node, the greater the degree of malice of the target node; the smaller the malicious value of the target node, the less the degree of malice of the target node.

[0077] In some embodiments, the similarity is at least one of Euclidean distance, Manhattan distance, cosine similarity, and Hamming distance.

[0078] In one possible implementation, the miner node determines the malicious value of the target node based on the similarity between the model parameters of the target node and the model parameters of other target nodes, including: the miner node determines multiple similarities between the model parameters of the target node and the model parameters of other target nodes; the miner node determines the malicious value of the target node as the reciprocal of the sum of the multiple similarities.

[0079] In the above technical solution, the reciprocal of the sum of similarities between the model parameters of the target node and the model parameters of each of the other target nodes is determined as the malicious value of the target node. When the model parameters of the target node are used to refer to the target node, this solution is equivalent to determining the malicious value of the target node as the sum of the distances from the target node to the other target nodes. If the sum of similarities corresponding to the target node is relatively large, it indicates that the model parameters of the target node differ significantly from the model parameters of the other target nodes, suggesting a high probability that the model parameters of the target node are inaccurate, and a high degree of malicious intent towards the miner node in obtaining the global model parameters. In other words, when the miner node fuses multiple model parameters, including those of the target node, it will obtain inaccurate global model parameters.

[0080] Step 306: The miner node determines at least one malicious node from the multiple target nodes based on the malicious values ​​of the multiple target nodes.

[0081] It should be understood that since a malicious node is a node with significantly different model parameters from other target nodes and a higher degree of malice, the malice value is the degree of malice. Therefore, a miner node can determine at least one malicious node from among multiple target nodes based on the malice values ​​of those target nodes.

[0082] In some embodiments, a miner node identifies at least one malicious node among multiple target nodes whose malicious value is greater than a preset value.

[0083] In one possible implementation, step 306 includes: the miner node sorts the multiple target nodes in descending order of their malicious values; the miner node identifies the top number of target nodes among the sorted multiple target nodes as the at least one malicious node.

[0084] In the above technical solution, the miner node sorts the multiple target nodes from largest to smallest based on their malicious values, resulting in a sorted set of target nodes. This allows the miner node to quickly identify at least one malicious node based on its needs. Specifically, the top [number] target nodes in the sorted set are identified as the at least one malicious node because their malicious values ​​are relatively large, indicating a greater degree of malice towards the miner node's acquisition of the global model parameters.

[0085] The process of determining the "target quantity" will be discussed in detail below.

[0086] In one possible implementation, the method for determining the target number includes: the miner node determines the product between the number of target nodes and a first coefficient to obtain a first value, wherein the first coefficient is the ratio between the number of malicious nodes to be determined and the number of target nodes; the miner node determines the integer part of the first value as the target number.

[0087] In the above technical solution, before the miner node identifies a malicious node from multiple target nodes, it pre-sets the number of malicious nodes. This number is the integer part of the product of the number of target nodes and a first coefficient (the first value), since the product may be a decimal.

[0088] For example, taking a target number of 12 nodes and a first coefficient of 20% as an example, the process of obtaining the target number is described. The miner node determines the product between the target number of nodes and the first coefficient to obtain the first value, specifically: 12 * 20% = 2.4; the miner node determines the integer part of the first value as the target number, specifically: FLOOR(2.4) = 2.

[0089] Step 308: The miner node merges the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round.

[0090] It should be understood that the "global model" in step 308 above is a model generated by federated fusion of multiple local models. Generally speaking, the global model utilizes more training data than the local models, and therefore has better model performance. This global model is essentially a machine learning model trained on local data from multiple local databases corresponding to multiple target nodes.

[0091] It should also be understood that steps 302 to 308 are any round of model training. In the federated learning in one or more embodiments of this specification, the model parameters in the global model are updated in each round until the last round ends.

[0092] In one possible implementation, step 308 includes any of the following: the miner node performs a weighted fusion of the model parameters of the multiple non-malicious nodes based on the model parameters and corresponding weights of each non-malicious node to obtain the model parameters of the global model for this round; the miner node determines the average value of the model parameters of the multiple non-malicious nodes as the model parameters of the global model for this round.

[0093] In the above technical solution, the model parameters of multiple non-malicious nodes are fused in two ways: either by weighted fusion of the model parameters of each non-malicious node with its corresponding weight, or by fusion of the average model parameters of multiple non-malicious nodes, to obtain the model parameters of the global model for this round. This enriches the ways in which miner nodes obtain the model parameters of the global model for this round, making the acquisition process more diverse.

[0094] In some embodiments, the miner node performs weighted fusion of the model parameters of multiple non-malicious nodes based on the model parameters and corresponding weights of each non-malicious node to obtain the model parameters of the global model for this round, including: the miner node determines the model parameters of the global model for this round based on the following formula (1);

[0095]

[0096] Where i represents the current round, and w i Here are the model parameters for the global model in round i, where C is the number of non-malicious nodes. Let be the model parameters for the c-th non-malicious node in round i.

[0097] It should be understood that the model parameters for the first non-malicious node are... Its corresponding weight is 1, and the model parameters for the second non-malicious node are... Its corresponding weight is ...and so on, the model parameters for the c-th non-malicious node are... Its corresponding weight is

[0098] In some embodiments, the miner node determines the average value of the model parameters of the multiple non-malicious nodes as the model parameters of the global model for this round, including: the miner node determines the model parameters of the global model for this round based on the following formula (2);

[0099]

[0100] Where i represents the current round, and w i Here are the model parameters for the global model in round i, where C is the number of non-malicious nodes. Let be the model parameters for the c-th non-malicious node in round i.

[0101] It should be understood that steps 302 to 308 represent any round of model training. Obtaining the final target model requires multiple rounds of iterative processing. The process of obtaining the target model is described in detail below.

[0102] In one possible implementation, after step 308, method 300 further includes: if the round referred to in this round is equal to a preset round, the miner node determines the global model of this round as the target model, which is used to execute a preset transaction; if the round referred to in this round is less than the preset round, the miner node publishes the global model of this round to multiple nodes included in the blockchain system, so that the multiple nodes update the model parameters of the global model used in subsequent training.

[0103] In some embodiments, the "preset transaction" in the above scheme is to recommend financial products to customers based on the amount of resources stored by the customer in the financial institution.

[0104] In the above technical solution, when the current round equals the preset round, the miner node no longer trains the global model and directly uses the current round's global model as the target model. When the current round is less than the preset round, meaning there are insufficient training iterations, the miner node publishes the current round's global model to multiple nodes within the blockchain system. After these nodes train their local model parameters based on the current round's global model, the model parameters of some of these local models are received by the miner nodes in the next round. These miner nodes then further integrate the model parameters of these local models to obtain the model parameters for the next round's global model. This process continues until the current round equals the preset round. In other words, when there are insufficient training iterations, any miner node among the multiple nodes in the blockchain system can continue training the global model.

[0105] It should be understood that nodes in a blockchain system consume local computing resources (processor and memory resources) during the training of their local models. To incentivize nodes to actively participate in the training of subsequent local models, the final round of miners in this blockchain system allocates incentive values ​​to each node based on their performance in acquiring the target model. The specific implementation is as follows.

[0106] In one possible implementation, the multiple target nodes are determined from multiple nodes included in the blockchain system. These multiple target nodes are nodes that upload model parameters of the local model to the blockchain system within a preset time period. The method 300 further includes: when the round referred to in this round is equal to the preset round, the miner node determines the number of times each of the multiple nodes participates in the preset round; the miner node allocates a target incentive value to each of the multiple nodes based on the number of participations corresponding to each of the multiple nodes, the total number of participations corresponding to the multiple nodes, the total incentive value, and a second coefficient. The target incentive value is used to incentivize each node to participate in the training of the local model, and the second coefficient is the ratio between the incentive value allocated to the multiple nodes and the total incentive value.

[0107] It should be understood that the "multiple nodes" in the above scheme can be understood as multiple clients that train local model parameters based on local data in their own local databases and computing power. Figure 2 In the example embodiment, the multiple nodes are the W clients.

[0108] It should also be understood that the "number of times each node participates in the preset round" in the above scheme refers to the number of times a node effectively participates in the preset round. Specifically, it can be understood as: during a certain iteration, the model parameters of the local model uploaded by the node to the blockchain ultimately participate in the training process of the global model in that round.

[0109] In the above technical solution, where the blockchain system includes multiple nodes and the current round refers to a preset round, the miner node rewards the multiple nodes participating in the local model training. Specifically, based on the participation count of each node, the total participation count of the multiple nodes, the total incentive value, and the second coefficient, a target incentive value is allocated to each node, enabling each node to actively participate in the training of other local models in the future.

[0110] In some embodiments, the miner node allocates a target incentive value to each of the plurality of nodes based on the number of participations of each node, the total number of participations of the plurality of nodes, the total incentive value, and the second coefficient, including: the miner node allocates the target incentive value to each of the plurality of nodes based on the following formula (3);

[0111]

[0112] Among them, R j L is the incentive value assigned to node j. j Let ρj be the number of participations corresponding to node j, ρ2 be the second coefficient, R be the total incentive value, and M be the number of nodes. This represents the total number of participations across multiple nodes.

[0113] For example, with a preset round I of 1000, a number of nodes M of 5, a total incentive value R of 1000, and a second coefficient ρ2 of 0.6, the total number of participations for these 5 nodes is 4926 (987+998+960+989+992=4926). Among them, the number of participations for the first node is 987, for the second node it is 998, for the third node it is 960, for the fourth node it is 989, and for the fifth node it is 992. Based on the above parameters and the following formulas (4) to (8), the miner nodes obtain the target incentive value allocated to the first node as 120.2, to the second node as 121.5, to the third node as 116.9, to the fourth node as 120.5, and to the fifth node as 120.8.

[0114]

[0115]

[0116]

[0117]

[0118]

[0119] It should be understood that after each target node uploads its local model parameters to a miner node, the miner node needs to fuse these local model parameters. This fusion process consumes the miner node's computing resources (processor and memory resources). Therefore, the blockchain system can allocate incentive values ​​to the multiple miner nodes involved in acquiring the target model to incentivize them to compete for the right to record transactions (actively acquiring the model parameters of the local models uploaded by multiple target nodes; fusing the model parameters of the local models of these multiple target nodes to obtain the global model; and recording the global model). Furthermore, it can also encourage the incentivized miner nodes to actively participate in the training of other global models subsequently. The specific implementation is as follows.

[0120] In one possible implementation, after the miner node obtains the model parameters of the global model for this round, the method 300 further includes: the miner node obtains an incentive value based on the third coefficient, the total incentive value, and the preset round, the incentive value being used to incentivize the miner node to participate in the training of the global model, the third coefficient being the ratio between the miner incentive value allocated to the miner node and the total incentive value, and the sum of the second coefficient and the third coefficient being 1.

[0121] In the above technical solution, after each round of global model parameter fusion, miner nodes obtain incentive values ​​based on a third coefficient, the total incentive value, and the preset round number; this is the process of rewarding miner nodes. During the training of the global model, miner nodes consume their own computing resources (storage, bandwidth, computational load). Therefore, after each round of global model parameter fusion, the incentive value obtained by the miner nodes allows multiple nodes in the blockchain to compete for the right to record transactions and train the global model.

[0122] In some embodiments, the miner node obtains the incentive value based on the third coefficient, the total incentive value, and the preset round, including: the miner node obtains the incentive value based on the following formula (9);

[0123]

[0124] Among them, K i ρ3 is the incentive value allocated to the miner node in round i, ρ3 is the third coefficient, and R is the total incentive value.

[0125] It should be understood that ρ2+ρ3=1, and the incentive value obtained by formula (9) is a constant value. That is to say, the incentive value allocated to the miner node in each round is the same.

[0126] Figure 4 This is a schematic diagram of a model training method provided in one or more embodiments of this specification.

[0127] When a node needs to obtain a recommendation model, it sends a request to the blockchain. This request includes the preset training rounds, model structure, and initial parameters. After receiving the request, a miner node in the blockchain publishes the corresponding training task to multiple nodes. Upon receiving the request, each node updates the initial parameters of the model based on the storage capacity of multiple resources in its local database, obtaining the model parameters for the first round of local model training, and uploads them to the blockchain. After receiving the model parameters for the first round of local model training from multiple target nodes within a preset time period, the blockchain determines a miner node from among the target nodes. This miner node then merges the model parameters of the first round of local model training from the multiple target nodes to obtain the first round of global model training. After obtaining the first round of global model training, the first-round miner node determines that the round number referred to in this first round is less than the preset round number. The first-round miner node then publishes the first-round global model to multiple nodes. After receiving the first-round global model, each node in a multi-node system updates its model parameters based on the storage capacity of its local database, resulting in the model parameters for the second-round local model, and so on, until the penultimate iteration. This process yields the model parameters for the final-round local model, which each node then uploads to the blockchain. The final-round miner node merges the model parameters from the multiple target nodes uploaded by the first node to obtain the final-round global model. This final-round miner node determines that the final round corresponds to a preset round and designates the final-round global model as the recommended model.

[0128] Figure 5 This is a schematic diagram of the structure of a model training apparatus provided in one or more embodiments of this specification.

[0129] For example, such as Figure 5 As shown, the device 500 includes:

[0130] The acquisition module 501 is used to acquire the model parameters of the local models of multiple target nodes in the blockchain system, and the miner node belongs to these multiple target nodes;

[0131] Determine module 502, used for:

[0132] For any target node among the multiple target nodes, the malicious value of the target node is determined based on the similarity between the model parameters of the target node and the model parameters of the other target nodes. The malicious value is positively correlated with the degree of maliciousness of the target node.

[0133] Based on the malicious values ​​of the multiple target nodes, at least one malicious node is identified from the multiple target nodes;

[0134] The fusion module 503 is used to fuse the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round.

[0135] Optionally, the determining module 502 is specifically used to: determine multiple similarities between the model parameters of the target node and the model parameters of other target nodes; and determine the reciprocal of the sum of the multiple similarities as the malicious value of the target node.

[0136] Optionally, the determining module 502 is further configured to: sort the multiple target nodes in descending order of their malicious values; and determine the top number of target nodes among the sorted multiple target nodes as the at least one malicious node.

[0137] Optionally, the determining module 502 is further configured to: determine the product between the number of target nodes and a first coefficient to obtain a first value, wherein the first coefficient is the ratio between the number of malicious nodes to be determined and the number of target nodes; and determine the integer part of the first value as the target number.

[0138] Optionally, the fusion module 503 is specifically used for any of the following: weighted fusion of the model parameters of the multiple non-malicious nodes based on the model parameters and corresponding weights of each non-malicious node to obtain the model parameters of the global model for this round; and determining the average value of the model parameters of the multiple non-malicious nodes as the model parameters of the global model for this round.

[0139] Optionally, the multiple target nodes are determined from multiple nodes included in the blockchain system. The multiple target nodes are nodes that upload model parameters of the local model to the blockchain system within a preset time period. The determining module 502 is further used to determine the number of times each of the multiple nodes participates in the preset round when the round referred to in this round is equal to the preset round. The device 500 also includes: an allocation module, used to allocate a target incentive value to each of the multiple nodes based on the number of participations corresponding to each of the multiple nodes, the total number of participations corresponding to the multiple nodes, the total incentive value, and a second coefficient. The target incentive value is used to incentivize each node to participate in the training of the local model. The second coefficient is the ratio between the incentive value allocated to the multiple nodes and the total incentive value.

[0140] Optionally, after obtaining the model parameters of the global model for this round, the acquisition module 501 is further used to obtain an incentive value based on the third coefficient, the total incentive value and the preset round. The incentive value is used to incentivize the miner node to participate in the training of the global model. The third coefficient is the ratio between the miner incentive value allocated to the miner node and the total incentive value. The sum of the second coefficient and the third coefficient is 1.

[0141] Optionally, the miner node is the node that takes the shortest time to solve the target hash problem among the multiple target nodes. The miner node solves the target hash problem by determining a random number through hash calculation.

[0142] Optionally, after fusing the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round, the determining module 502 is further configured to determine the global model for this round as the target model when the round referred to in this round is equal to the preset round, and the target model is used to execute the preset transaction; the device 500 further includes: a sending module, configured to publish the global model for this round to multiple nodes included in the blockchain system when the round referred to in this round is less than the preset round, so that the multiple nodes update the model parameters of the global model used in subsequent training.

[0143] Figure 6 This is a schematic diagram of the structure of an electronic device provided in one or more embodiments of this specification.

[0144] For example, such as Figure 6 As shown, the electronic device 600 includes: a memory 601, a processor 602, and a computer program 603 stored in the memory 601 and running on the processor 602, wherein when the processor 602 executes the computer program 603, the electronic device can perform any of the model training methods described above.

[0145] Optionally, the electronic device is the miner node.

[0146] One or more embodiments of this specification can divide an electronic device into functional modules based on the above method examples. For example, each module can correspond to a separate functional module, or two or more functions can be integrated into a single processing module. The integrated module can be implemented in hardware. It should be noted that the module division in one or more embodiments of this specification is illustrative and represents only one logical functional division. In actual implementation, there may be other division methods.

[0147] When each functional module is divided according to its corresponding function, the electronic device may include: an acquisition module, a determination module, a fusion module, an allocation module, a transmission module, etc. It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0148] The electronic device provided in one or more embodiments of this specification is used to execute the above-described model training method, and thus can achieve the same effect as the above-described implementation method.

[0149] When using integrated units, the electronic device may include a processing module and a storage module. The processing module is used to control and manage the operation of the electronic device. The storage module is used to support the execution of program code and data by the electronic device.

[0150] The processing module may be a processor or a controller, which can implement or execute various exemplary logic blocks, modules, and circuits as disclosed in connection with one or more embodiments of this specification. The processor may also be a combination of functions that implement computing capabilities, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc., and the storage module may be a memory.

[0151] The electronic device provided in one or more embodiments of this specification may specifically be a chip, component, or module. The electronic device may include a connected processor and a memory. The memory is used to store instructions. When the electronic device is running, the processor may call and execute the instructions to cause the chip to perform any of the model training methods described above.

[0152] This specification provides one or more embodiments of a computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform any of the aforementioned model training methods.

[0153] One or more embodiments of this specification also provide a computer program product containing instructions that, when run on a computer or processor, cause the computer or processor to perform the aforementioned related steps to implement any of the model training methods described above.

[0154] In this specification, the electronic device, computer-readable storage medium, computer program product or chip containing instructions provided in one or more embodiments are all used to perform the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0155] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0156] In one or more embodiments of this specification, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.

[0157] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.

[0158] The above description is merely one or more specific embodiments of this specification, but the protection scope of one or more embodiments of this specification is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in one or more embodiments of this specification should be included within the protection scope of one or more embodiments of this specification. Therefore, the protection scope of one or more embodiments of this specification should be determined by the protection scope of the claims.

Claims

1. A method for model training, wherein the method is executed by miner nodes in a blockchain system, the miner nodes being nodes elected by the blockchain system based on a consensus mechanism in each round of model training, and the model training being a preset number of rounds; the method comprising: Obtain the model parameters of the local models of multiple target nodes in the blockchain system, wherein the miner node belongs to the multiple target nodes; For any one of the plurality of target nodes, the malicious value of the target node is determined based on the similarity between the model parameters of the target node and the model parameters of other target nodes. The malicious value is positively correlated with the degree of maliciousness of the target node. Based on the malicious values ​​of the multiple target nodes, at least one malicious node is determined from the multiple target nodes; The model parameters of multiple non-malicious nodes among the multiple target nodes are fused to obtain the model parameters of the global model for this round. The method further includes: After fusing the model parameters of the global model in each round, an incentive value is obtained, which enables multiple nodes in the blockchain system to compete for the right to record transactions of the miner node and to train the global model. The determination of the malicious value of the target node based on the similarity between the model parameters of the target node and the model parameters of other target nodes includes: Determine multiple similarities between the model parameters of the target node and the model parameters of other target nodes; The reciprocal of the sum of the multiple similarities is determined as the malicious value of the target node.

2. The method according to claim 1, wherein determining at least one malicious node from the plurality of target nodes based on the malicious values ​​of the plurality of target nodes comprises: The target nodes are sorted in descending order of their maliciousness values; The first number of target nodes among the sorted target nodes are identified as at least one malicious node.

3. The method according to claim 2, wherein the method for determining the target quantity includes: The product of the number of target nodes and a first coefficient is determined to obtain a first value, where the first coefficient is the ratio between the number of malicious nodes to be determined and the number of target nodes. The integer part of the first value is determined as the target quantity.

4. The method according to claim 1, wherein fusing the model parameters of multiple non-malicious nodes among the plurality of target nodes to obtain the model parameters of the global model for this round includes any one of the following: Based on the model parameters and corresponding weights of each non-malicious node, the model parameters of the multiple non-malicious nodes are weighted and fused to obtain the model parameters of the global model in this round. The average value of the model parameters of the multiple non-malicious nodes is determined as the model parameters of the global model for this round.

5. The method according to claim 1, wherein the plurality of target nodes are determined from a plurality of nodes included in the blockchain system, and the plurality of target nodes are nodes that upload model parameters of a local model to the blockchain system within a preset time period, the method further comprising: If the round referred to in this round is equal to the preset round, determine the number of times each of the plurality of nodes participates in the preset round; Based on the number of participations of each node in the plurality of nodes, the total number of participations of the plurality of nodes, the total incentive value, and the second coefficient, a target incentive value is assigned to each node in the plurality of nodes. The target incentive value is used to incentivize each node to participate in the training of the local model. The second coefficient is the ratio between the incentive value assigned to the plurality of nodes and the total incentive value.

6. The method according to claim 5, wherein after obtaining the model parameters of the global model for this round, the method further includes: An incentive value is obtained based on the third coefficient, the total incentive value, and the preset round. The incentive value is used to incentivize the miner nodes to participate in the training of the global model. The third coefficient is the ratio between the miner incentive value allocated to the miner node and the total incentive value. The sum of the second coefficient and the third coefficient is 1.

7. The method according to any one of claims 1-6, wherein the miner node is the node that takes the shortest time to solve the target hash problem among the plurality of target nodes, and the miner node solves the target hash problem by determining a random number through hash calculation.

8. The method according to any one of claims 1-6, wherein after fusing the model parameters of multiple non-malicious nodes among the plurality of target nodes to obtain the model parameters of the global model for this round, the method further includes: If the current round is equal to the preset round, the global model of the current round is determined as the target model, and the target model is used to execute the preset transaction. If the current round is less than the preset round, the global model for this round is published to multiple nodes of the blockchain system so that the multiple nodes can update the model parameters of the global model used in subsequent training.

9. An apparatus for model training, the apparatus comprising: The acquisition module is used to acquire model parameters of the local models of multiple target nodes in the blockchain system. The determination module is used for: For any one of the plurality of target nodes, the malicious value of the target node is determined based on the similarity between the model parameters of the target node and the model parameters of other target nodes. The malicious value is positively correlated with the degree of maliciousness of the target node. Based on the malicious values ​​of the multiple target nodes, at least one malicious node is determined from the multiple target nodes; The fusion module is used to fuse the model parameters of multiple non-malicious nodes among the multiple target nodes to obtain the model parameters of the global model for this round. The device further includes: After fusing the model parameters of the global model in each round, an incentive value is obtained, which enables multiple nodes in the blockchain system to compete for the right to record transactions as miners, thereby training the global model. The miners are nodes elected by the blockchain system based on a consensus mechanism in each round of model training, and the model training is conducted in a preset number of rounds. The determination of the malicious value of the target node based on the similarity between the model parameters of the target node and the model parameters of other target nodes includes: Determine multiple similarities between the model parameters of the target node and the model parameters of other target nodes; The reciprocal of the sum of the multiple similarities is determined as the malicious value of the target node.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein, When the processor executes the computer program, it causes the electronic device to perform the model training method as described in any one of claims 1 to 8.

11. A computer-readable storage medium storing instructions that, when executed on a computer or processor, cause the computer or processor to perform the model training method as described in any one of claims 1 to 8.

12. A computer program product comprising instructions that, when run on a computer or processor, causes the computer or processor to perform the model training method as described in any one of claims 1 to 8.

Citation Information

Patent Citations

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

    CN113467927A

  • Federal learning method and device for poisoning defense and poisoning tracing based on block chain

    CN113468264A

  • Federal learning excitation method and device based on block chain, equipment and medium

    CN114580658A