Cross-chain federated learning method and system based on diffusion model
By introducing the diffusion model and blockchain technology into federated learning, and combining the private chain and the central management chain, the data storage security problem of diffusion model training is solved, higher system security and robustness are achieved, and it is suitable for generative Data privacy protection for artificial intelligence.
Patent Information
- Application Number
- CN202410929380.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-11
- Publication Date
- 2024-10-15
AI Technical Summary
The existing blockchain-based federated learning design fails to effectively solve the data storage security problem of diffusion model training, and lacks a training design based on the diffusion model, resulting in the risk of single point failure and node trust issues.
Adopt a cross-chain federated learning method based on the diffusion model, combine private chains and central management chains, manage federated learning tasks and model forwarding through smart contracts, use the notary consensus mechanism to achieve cross-chain communication, and private chain agents participate in training and model aggregation , ensuring data security and robustness.
It improves the overall security and robustness of the system, enhances the privacy and auditability of local data, enables large model training on the basis of protecting data privacy, and is suitable for the field of generative artificial intelligence.
Smart Images

Figure CN118780401A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular, relates to a cross-chain federated learning method and system based on a diffusion model. Background Art
[0002] Federated learning is a distributed machine learning method that combines privacy protection, reduced data transmission, personalized models, enhanced generalization capabilities, and distributed learning. Federated learning can collaboratively train machine learning models on the basis of protecting the data privacy of participants. General institutions or organizations usually do not have enough local data to complete machine learning training, but through federated learning, institutions or organizations can collaboratively complete model training without sharing local data. Federated learning usually has the risk of single point failure and trust issues between training nodes. The introduction of blockchain technology can realize trustless federated learning without a central server, while also enhancing the robustness of the overall system.
[0003] Blockchain technology has the characteristics of decentralization, immutability, and data transparency, which can solve the problems of single point failure, node trust, data security, etc. in federated learning. Smart contracts are automated contracts based on blockchain technology that can automatically execute and trigger corresponding operations when specific conditions are met. Through smart contracts, all parties can conduct secure transactions and cooperation in an untrusted environment, ensuring the transparency and reliability of contract execution and results.
[0004] The diffusion model is a generative model that works by continuously adding Gaussian noise for learning. After training, the target data is generated through the process of reverse diffusion. Machine learning based on the diffusion model has a wide range of applications in the field of generative artificial intelligence, such as AI drawing, AI video generation, and large language models. The existing blockchain-based federated learning design solves some of the single point failure risk issues, but does not consider the data storage security of each node. In addition, the current federated learning framework is not designed for diffusion model-based training. Summary of the invention
[0005] The purpose of the present invention is to solve the problems raised in the background technology, and propose a cross-chain federated learning method and system based on a diffusion model, which fills the design gap of federated learning for diffusion model training, and combines private chain, central management chain and cross-chain technologies to improve the overall security and robustness of the system.
[0006] In order to achieve the purpose of the present invention, the present invention discloses a cross-chain federated learning method based on a diffusion model, which uses a diffusion model as a federated learning training model, including a private chain and a central management chain; the private chain can publish or participate in training as a node of federated learning, and the central management chain manages all federated learning tasks through smart contracts and participates in the model forwarding and aggregation of federated learning, specifically including the following steps:
[0007] S1. The private chain is a private blockchain where organizations participating in federated learning store local data. The private chain selects nodes as agents based on the principle of maximum computing power. The agents of the private chain can deploy training contracts on the central management chain and register them on the task management contract.
[0008] S2. Each private chain agent monitors the currently opened tasks of the task management contract, and switches the current working mode to the server, client, or remains in the non-identity state to continue to monitor the tasks according to the currently opened task information; the agent with the identity of the client signs the corresponding training contract to confirm participation in the task; and the private chain agent with the identity of the server, after receiving the signatures of all clients, publishes the global model on the training contract;
[0009] S3, as the client's private chain agent, listens to the latest global model of the training contract, downloads and completes the training locally, and then uploads the local model to the training contract; the training contract has a built-in model aggregation function, which will automatically trigger the function to achieve model aggregation after collecting all client models; the aggregated model will be distributed to each client in another round, and the client will upload it again after training the model locally; at the same time, the local private chain will also save the model generated during the training process;
[0010] S4. After completing enough training rounds, the training contract closes the upload interface and sets the task status in the task management contract to completed; the server downloads the trained model from the training contract; the task management contract starts a new task according to the order of the task queue to be completed, and the private chain agent switches the working status according to the new task.
[0011] Furthermore, in step S1, the specific task publishing process is as follows:
[0012] The private chain is the private blockchain of each organization participating in federated learning. It consists of multiple nodes, stores local data in a distributed manner, and participates in federated learning as a whole. Before training begins, the private chain performs a computing power test on each node on the chain and sets the node with the largest computing power as the agent of the private chain. The private chain agent can access the central management chain and realize information exchange between the private chain and the central management chain, and between private chains through the notary consensus mechanism.
[0013] The private chain agent can serve as the server of federated learning to publish federated learning training tasks, and can also serve as the client of federated learning to perform local training. When the private chain agent serves as the server of federated learning, it first deploys the training contract containing the details of the federated learning task in the central management chain. After the deployment is completed, the training contract automatically triggers the built-in function of the contract and registers the task information on the task management contract on the central management chain, and then pushes the task to the queue of pending tasks.
[0014] Furthermore, in step S2, the specific signing process is as follows:
[0015] All private chain agents continuously monitor the tasks that have been opened by the task management contract; the central management contract prioritizes the tasks that enter the queue first and sets the task status to open; after the task is opened, the private chain agent downloads the task information and adjusts the working mode according to the task information;
[0016] According to the task information, if the private chain agent is a client in the task, it will upload the private key signature to the training contract deployed corresponding to the task, and the built-in function of the contract will verify the legitimacy of the signature; if the private chain agent is a server in the task, it will monitor the training contract deployed by the task and wait for the contract to collect a sufficient number of private key signatures; if the private chain agent has no identity in the task, it will continue to monitor the queue of pending tasks and wait for the next task to start.
[0017] Furthermore, in step S3, the client local training and global model aggregation process are as follows:
[0018] After the agent with the identity of the server listens to a sufficient number of signatures, the global model is uploaded to the training contract. The process of sending the global model and training the client locally is as follows. The global model is trained using the noisy diffusion probability model DDPMs:
[0019] In a federated learning process, M is used to represent the total number of training rounds, and J is used to represent the set of private chain agents that participate in the federated learning task as clients; represents the global model, represents the local model in training, where m represents the mth training round, m∈M, j represents the private chain agent j, j∈J;
[0020] When the server private chain monitors enough client private chain signatures, it uploads the global model Training contract to the central management chain; client private chain j downloads the global model and through Initialize local model Introduce the Diffusion model for noise training;
[0021] Assume that a minimum batch of original images x0 in a local dataset is randomly selected, and a forward noise process (diffusion process) q(x) is defined. The process is fixed on the Markov chain and gradually adds Gaussian noise to the data according to a series of hyperparameter tables {β} of Gaussian distribution variance. The sampling step T is defined, and the time step t is arbitrary and the value range is {1,...,T}. Then, the q(x) process is as follows:
[0022]
[0023] Define the randomly generated noise parameter ∈, which obeys the Gaussian distribution, Defining signal retention rate The noise retention rate is
[0024] Add noise to the selected training sample by:
[0025]
[0026] where x t is a linear combination of the original data and random noise. When the value is extremely small, the final x T is approximately random noise;
[0027] Take the gradient descent step to train the local model to approximate the noise. When the training function reaches the minimum value, the model training is completed. At this time, there is a training model The training function looks like this:
[0028]
[0029] After the first round of training, the client private chain j obtains the trained noise model Upload the global model to the training contract of the central management chain, and wait for the central management chain to aggregate the new global model After that, download and start the second round of training; repeat the above training process until the set number of m rounds of training is reached to obtain the local model
[0030] The training contract receives the local models uploaded by all participating clients’ private chains and calculates all training models through the aggregation function. Based on the weight value δ j The weighted average of The aggregated global model is uploaded to the central management chain, and the clients participating in the training download it and start the next round of training. The global model aggregation formula is:
[0031]
[0032] Further, in step S4, the task closing process is as follows: after completing the task specified training rounds, the global model is obtained The training contract will automatically trigger the function to close the upload interface, leaving only the download interface, and change the task status in the task management contract to completed status; the server monitors the task status, downloads the trained model from the training contract after the task is completed, and saves it to the local private chain; the task management contract starts a new task, and each private chain agent continues to participate in training according to the next task information.
[0033] In order to achieve the purpose of the present invention, the present invention also discloses a cross-chain federated learning system based on a diffusion model, including a private chain and a central management chain; the central management chain includes a task management contract module and a training contract module; the consensus mechanism of cross-chain communication adopts a notary mechanism;
[0034] A private chain is composed of nodes of an organization or institution, which is used to store local data. The data of the private chain is transparently shared within the organization or institution. Each private chain will select a node as the agent of the chain based on the principle of the largest node computing power. The agent is responsible for participating in the maintenance of the central management chain and the training of federated learning. At the same time, the agent also acts as a notary to realize cross-chain communication.
[0035] The central management chain is composed of all private chain agents as nodes, which are used to manage federated learning tasks and participate in the key processes of federated learning. The central management chain deploys a task management contract module and several training contract modules. Usually, one federated learning task corresponds to one training contract module.
[0036] The task management contract module stores registered federated learning tasks, including tasks that have completed training and tasks that have not completed training; all task information can be queried through the contract interface; tasks that have not completed training are registered in the queue of pending tasks; the central management contract starts each task in sequence; and at the same time, only one task in the system is being trained;
[0037] The training contract module stores all global models and local models generated during the training process, and also participates in the process of federated learning, aggregating all local models in each iteration to generate a new round of global models; after the round of task setting is completed, the training contract module closes the model upload interface of the contract and calls the function to update the status of the task in the task management contract module to the completed status.
[0038] Compared with the prior art, the significant progress of the present invention is as follows: 1) a cross-chain federated learning method and system based on a diffusion model is proposed, which consists of multiple private chains and a central management chain; the private chain stores local data, and agents participate in local training; the task management contract of the central management chain manages all federated learning tasks, and the training contract participates in the model aggregation process of training, thereby realizing cross-chain federated learning based on a diffusion model; 2) compared with other projects combining federated learning and blockchain, the system allows various institutions or organizations to use private chains to distribute and store local data, thereby improving the security, privacy and auditability of local data; the notary public acts as an efficient cross-chain consensus mechanism, allowing the private chain to communicate with the central management chain, thereby realizing information sharing in federated learning training and between private chains; the federated learning process of this system is driven by smart contracts, and the scheme has high portability and is compatible with different blockchains that support smart contracts; in addition, the system proposes federated learning based on a diffusion model, which is designed according to the characteristics of the diffusion model, and is of great help to the field of generative artificial intelligence, and can train large models on the basis of protecting the data privacy of data providers.
[0039] In order to more clearly illustrate the functional characteristics and structural parameters of the present invention, further description is given below in conjunction with the accompanying drawings and specific implementation methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0041] Figure 1 A cross-chain federated learning method based on a diffusion model and its system framework proposed by the present invention;
[0042] Figure 2 A cross-chain federated learning method based on a diffusion model and a system federated learning task flow chart thereof proposed by the present invention;
[0043] Figure 3 A cross-chain federated learning method based on a diffusion model and a task release flow chart of its system proposed by the present invention;
[0044] Figure 4 A cross-chain federated learning method based on a diffusion model and a task signature and activation flow chart of the system proposed by the present invention;
[0045] Figure 5 A flowchart of the specific training process of a cross-chain federated learning method based on a diffusion model and its system proposed in the present invention;
[0046] Figure 6A cross-chain federated learning method based on a diffusion model and a task closing flowchart of the system thereof proposed by the present invention;
[0047] Figure 7 A decision diagram for an agent of a cross-chain federated learning method based on a diffusion model and a system thereof to start a new task is provided in the present invention. DETAILED DESCRIPTION
[0048] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0049] The present invention discloses a cross-chain federated learning method and system based on a diffusion model, which uses a diffusion model as a federated learning training model, including: S1: a private chain is a private blockchain of each organization participating in the federated learning and is used to store local data. The private chain selects the node with the largest computing power as an agent, and the agent can deploy a training contract on the central management chain and register it on the task management contract; S2: each private chain agent listens to the queue of pending tasks of the task management contract, and the agent with the identity of the client signs the corresponding training contract to confirm participation in the task. The private chain agent with the identity of the server publishes the global model on the training contract after receiving the signatures of all clients; S3: the private chain agent as the client will download the latest global model in the training contract, complete the training locally, and then upload the local model to the training contract. The training contract has a built-in model aggregation function, which will automatically trigger the function to achieve model aggregation after all client models are collected. The aggregated model will be sent to each client again, and the client will upload it after training the model locally again; S4: after completing enough training rounds, the training contract upload interface is closed, and the status of the task in the task management contract is set to the completed status. The server downloads the trained model from the training contract. The task management contract starts a new task according to the order of the task queue to be completed. The present invention proposes a cross-chain federated learning method and system based on a diffusion model, which fills the design gap of federated learning for diffusion model training, and combines private chain, central management chain and cross-chain technologies to improve the overall security and robustness of the system.
[0050] Figure 1 represents the system architecture of the proposed system; Figure 2 It represents the complete execution process of the federated learning of the proposed system, namely S1 to S4; Figures 3 to 6 This example illustrates the execution process of a federated learning task. Figure 1 Extended description of; Figure 7 Yes Figure 4 Supplement of client execution logic.
[0051] The system architecture proposed in this system is as follows Figure 1 As shown in the figure, it consists of a central management chain and multiple private chains. The following is a detailed description of each part of the system architecture:
[0052] A private chain is usually composed of nodes of an organization or institution, which can be regarded as a trusted node. Distributed storage based on blockchain reduces the risk of single point failure and also prevents data tampering. Each organization or institution can develop smart contracts based on private chains to manage its business according to its own business characteristics, including but not limited to data management and business auditing. Each private chain will select a node as the agent of the chain based on the principle of maximum node computing power. The agent is responsible for participating in the maintenance of the central management chain and the training of federated learning. At the same time, the agent also acts as a notary to achieve cross-chain communication.
[0053] The central management chain is composed of all private chain agents as nodes. Its main function is to manage all federated learning tasks and participate in the key process of federated learning. The central management chain mainly deploys a task management contract and several training contracts. Usually, one federated learning task corresponds to one training contract.
[0054] The task management contract mainly stores registered federated learning tasks, including tasks that have completed training and tasks that have not completed training. All task information can be queried through contract functions. Each node can access these functions at any time to obtain information about completed and pending tasks. For tasks that have not started training, they are usually registered in the pending task queue. The central management contract will start each task in order. Generally, only one task in the system is being trained at the same time.
[0055] The training contract stores all global models and local models generated during the training process of the corresponding federated learning task. It also participates in the federated learning process and participates in aggregating local models to generate a new round of global models. After the round of task setting is completed, the training contract will close the model upload interface of the contract and call the function to update the status of the task in the task management contract to the completed state. The download interface of the trained global model will only be open to the agent who published the task. Other private chain agents can obtain the global model of the task training through cross-chain application to the task publishing agent.
[0056] Figure 2 The complete execution process of the system's federated learning is shown; Figure 3-Figure 6 As shown, Figure 3-Figure 6 An example of a federated learning task is given, showing the specific processes of S1-S4 respectively.
[0057] In step S1, private chain agent 1 deploys training contract n on the central management chain, such as Figure 2 As shown. The training contract n contains the task information of the task, including task round, task type, client list and other information. Take private chain agent 1 to private chain agent 2 and private chain agent 3 to publish the federated learning task, training round m as an example, and the task type is image large model generation. The training contract will register the task information with the task management contract in the constructor. The constructor is the initialization function when deploying the contract. The task management contract will register the task and push it to the queue of pending tasks.
[0058] In step S2, all private chain agents continue to monitor the tasks that have been opened by the task management contract, such as Figure 4 The central management contract prioritizes the tasks that enter the queue first and sets the task status to open. When the task of training contract 1 is opened, all private chain agents download the task information and adjust the working mode according to the task information. After the server monitors a sufficient number of signatures, it uploads the global model. To training contract n. In this example, private chain agent 1 changes the working state to server mode, and private chain agent 2 and private chain agent 3 change the working state to client mode. When all clients, namely private chain agents 2 and 3, complete the signature on training contract n, private chain agent 1 will publish the initial global model on the training contract.
[0059] Figure 7 The decision-making process for the agent to adjust the working status according to the task information is a supplementary explanation to S2. If the private chain agent is a client in this task, it will upload the private key signature to the training contract deployed corresponding to the task, and the built-in function of the contract will check the signature information, verify the legitimacy of the signature, and continue to listen to the upload of the global model in the training contract after completing the signature. If the private chain agent is a server in this task, it will listen to the training contract deployed by the task and wait for the contract to collect a sufficient number of private key signatures. If the private chain agent does not play any role in this task, it will continue to listen to the tasks that have been opened and wait for the current task to end and the next task to start.
[0060] Step S3 is the specific process of federated learning, such as Figure 5 Private chain agents 2 and 3 download the global model and complete the training locally. The training process is as follows:
[0061] The global model delivery and client local training process are as follows. The global model is trained using the Noise Diffusion Probabilistic Model (DDPMs):
[0062] In a federated learning process, M is used to represent the total number of training rounds, and J is used to represent the set of private chain agents that participate in the federated learning task as clients. represents the global model, represents the local models of private chain agents 2 and 3 in training, where m represents the mth training round, m∈M.
[0063] When the server private chain monitors enough client private chain signatures, it uploads the global model Training contract to the central management chain. Client private chain 2 downloads the global model and through Initialize local model Introduce the Diffusion model for noise training.
[0064] Taking images as an example, suppose a minimum batch of original images x0 in a local dataset is randomly selected, and a forward noise process (diffusion process) q(x) is defined. The process is fixed on the Markov chain and gradually adds Gaussian noise to the data according to a series of hyperparameter tables {β} of Gaussian distribution variance. The sampling step T is defined, and the time step t is arbitrary and takes the range {1,...,T}. Then, there is the q(x) process of the following formula:
[0065]
[0066] Define the randomly generated noise parameter ∈, which obeys the Gaussian distribution, Defining signal retention rate The noise retention rate is
[0067] Add noise to the selected training sample by:
[0068]
[0069] where x t is a linear combination of the original data and random noise. When the value is extremely small, the final x T is approximately random noise.
[0070] Take the gradient descent step to train the local model to approximate the noise. When the minimum value is obtained, the model training is completed. At this time, there is a training model The training function is shown in the following formula:
[0071]
[0072] After the first round of training, private chain agent 2 obtains a noisy training model Upload the global model to the training contract of the central management chain, and wait for the central management chain to aggregate the new global model After that, download and start the second round of training. Repeat the above training process until the set number of m rounds of training is reached to obtain the local model.
[0073] The training contract receives the local models uploaded by private chain agent 2 and private chain agent 3, and calculates the training model through the aggregation function and The weighted average of The aggregated global model is uploaded to the central management chain, and the clients participating in the training download and start the next round of training. The global model aggregation formula is:
[0074]
[0075] After monitoring the generation of a new round of global models, the local model will download the global model and complete local training. The training process is the same as the training function formula, and the local model will be uploaded again. The models generated by the training will be saved in the local private chain of the client.
[0076] In step S4, after completing the aggregation of the training round m set in the task, the training contract n will close the model upload interface of the contract, call the function of the task management contract, set the training status of task n to the completed status, and start the next federated learning task. After listening to the completion of the task, the private chain agent 1 downloads the trained global model from the training contract.
[0077] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0078] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A cross-chain federated learning method based on a diffusion model, characterized in that: The diffusion model is used as the federated learning training model, which includes a private chain and a central management chain. The private chain can publish or participate in training as a node of federated learning. The central management chain manages all federated learning tasks through smart contracts and participates in the model forwarding and aggregation of federated learning. Specifically, the following steps are included: S1. The private chain is a private blockchain where organizations participating in federated learning store local data. The private chain selects nodes as agents based on the principle of maximum computing power. The agents of the private chain can deploy training contracts on the central management chain and register them on the task management contract. S2. Each private chain agent monitors the currently opened tasks of the task management contract, and switches the current working mode to the server, client, or remains in the non-identity state to continue to monitor the tasks according to the currently opened task information; the agent with the identity of the client signs the corresponding training contract to confirm participation in the task; and the private chain agent with the identity of the server, after receiving the signatures of all clients, publishes the global model on the training contract; S3, as the client's private chain agent, listens to the latest global model of the training contract, downloads and completes the training locally, and then uploads the local model to the training contract; the training contract has a built-in model aggregation function, which will automatically trigger the function to achieve model aggregation after collecting all client models; the aggregated model will be distributed to each client in another round, and the client will upload it again after training the model locally; at the same time, the local private chain will also save the model generated during the training process; S4. After completing enough training rounds, the training contract closes the upload interface and sets the task status in the task management contract to completed; the server downloads the trained model from the training contract; the task management contract starts a new task according to the order of the task queue to be completed, and the private chain agent switches the working status according to the new task.
2. A cross-chain federated learning method based on a diffusion model according to claim 1, characterized in that: In step S1, the specific task release process is as follows: The private chain is the private blockchain of each organization participating in federated learning. It consists of multiple nodes, stores local data in a distributed manner, and participates in federated learning as a whole. Before training begins, the private chain performs a computing power test on each node on the chain and sets the node with the largest computing power as the agent of the private chain. The private chain agent can access the central management chain and realize information exchange between the private chain and the central management chain, and between private chains through the notary consensus mechanism. The private chain agent can serve as the server of federated learning to publish federated learning training tasks, and can also serve as the client of federated learning to perform local training. When the private chain agent serves as the server of federated learning, it first deploys the training contract containing the details of the federated learning task in the central management chain. After the deployment is completed, the training contract automatically triggers the built-in function of the contract and registers the task information on the task management contract on the central management chain, and then pushes the task to the queue of pending tasks.
3. According to a diffusion model-based cross-chain federated learning method according to claim 1, it is characterized in that: In step S2, the specific signing process is as follows: All private chain agents continuously monitor the tasks that have been opened by the task management contract; the central management contract prioritizes the tasks that enter the queue first and sets the task status to open; after the task is opened, the private chain agent downloads the task information and adjusts the working mode according to the task information; According to the task information, if the private chain agent is a client in the task, it will upload the private key signature to the training contract deployed corresponding to the task, and the built-in function of the contract will verify the legitimacy of the signature; if the private chain agent is a server in the task, it will monitor the training contract deployed by the task and wait for the contract to collect a sufficient number of private key signatures; if the private chain agent has no identity in the task, it will continue to monitor the queue of pending tasks and wait for the next task to start.
4. According to claim 1, a cross-chain federated learning method based on a diffusion model is characterized in that: In step S3, the client local training and global model aggregation process are as follows: After the agent with the identity of the server listens to a sufficient number of signatures, the global model is uploaded to the training contract. The process of sending the global model and training the client locally is as follows. The global model is trained using the noisy diffusion probability model DDPMs: In a federated learning process, M is used to represent the total number of training rounds, and J is used to represent the set of private chain agents that participate in the federated learning task as clients; represents the global model, represents the local model in training, where m represents the mth training round, m∈M, j represents the private chain agent j, j∈J; When the server private chain monitors enough client private chain signatures, it uploads the global model Training contract to the central management chain; client private chain j downloads the global model and through Initialize the local model Introduce the Diffusion model for noise training; Assume that a minimum batch of original images x0 in a local dataset is randomly selected, and a forward noise process q(x) is defined. The process is fixed on the Markov chain, and Gaussian noise is gradually added to the data according to a series of hyperparameter tables {β} of Gaussian distribution variance. The sampling step T is defined, and the time step t is arbitrary and the value range is {1,...,T}. Then, the q(x) process is as follows: Define the randomly generated noise parameter ∈, which obeys the Gaussian distribution, Defining signal retention rate The noise retention rate is Add noise to the selected training sample by: where x t is a linear combination of the original data and random noise. When the value is extremely small, the final x T is approximately random noise; Take the gradient descent step to train the local model to approximate the noise. When the training function reaches the minimum value, the model training is completed. At this time, there is a training model The training function looks like this: After the first round of training, the client private chain j obtains the trained noise model Upload the global model to the training contract of the central management chain, and wait for the central management chain to aggregate the new global model After that, download and start the second round of training; repeat the above training process until the set number of m rounds of training is reached to obtain the local model The training contract receives the local models uploaded by all participating clients’ private chains and calculates all training models through the aggregation function. Based on the weight value δ j The weighted average of The aggregated global model is uploaded to the central management chain, and the clients participating in the training download it and start the next round of training. The global model aggregation formula is:
5. According to claim 1, a cross-chain federated learning method based on a diffusion model is characterized in that: In step S4, the task closing process is as follows: After completing the task specified training rounds, the global model is obtained The training contract will automatically trigger the function to close the upload interface, leaving only the download interface, and change the task status in the task management contract to completed status; the server monitors the task status, downloads the trained model from the training contract after the task is completed, and saves it to the local private chain; the task management contract starts a new task, and each private chain agent continues to participate in training according to the next task information.
6. A cross-chain federated learning system based on a diffusion model, the system is based on a cross-chain federated learning method based on a diffusion model as claimed in any one of claims 1 to 5, characterized in that: It includes a private chain and a central management chain; the central management chain includes a task management contract module and a training contract module; the consensus mechanism of cross-chain communication adopts a notary mechanism; A private chain is composed of nodes of an organization or institution, which is used to store local data. The data of the private chain is transparently shared within the organization or institution. Each private chain will select a node as the agent of the chain based on the principle of the largest node computing power. The agent is responsible for participating in the maintenance of the central management chain and the training of federated learning. At the same time, the agent also acts as a notary to realize cross-chain communication. The central management chain is composed of all private chain agents as nodes, which are used to manage federated learning tasks and participate in federated learning. The central management chain deploys a task management contract module and several training contract modules. Usually, one federated learning task corresponds to one training contract module. The task management contract module stores registered federated learning tasks, including tasks that have completed training and tasks that have not completed training; all task information can be queried through the contract interface; tasks that have not completed training are registered in the queue of pending tasks; the central management contract starts each task in sequence; and at the same time, only one task in the system is being trained; The training contract module stores all global models and local models generated during the training process, and also participates in the process of federated learning, aggregating all local models in each iteration to generate a new round of global models; after the round of task setting is completed, the training contract module closes the model upload interface of the contract and calls the function to update the status of the task in the task management contract module to the completed status.
