Training and sampling method and device for supervisible diffusion model, and medium

By adding a control layer to the diffusion model and adopting an RSS framework and a classifier on the regulator side, the problem of the diffusion model producing harmful samples in the intermediate process is solved, and effective prevention of harmful samples and model safety guarantees are achieved.

CN119398108AActive Publication Date: 2025-02-07HARBIN INST OF TECH +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411506434.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2025-02-07
Estimated Expiration
2044-10-25

AI Technical Summary

Technical Problem

Existing diffusion models may produce harmful samples in the intermediate process and it is difficult to prevent the model from being affected by harmful training samples.

Method used

By adding control layers to the initial diffusion model, training and tuning the diffusion model, the RSS framework and a classifier on the regulator side monitor intermediate results, blocking or modifying harmful samples.

Benefits of technology

Effectively prevent the diffusion model from producing harmful samples in the intermediate process, preventing the model from being trained to produce harmful samples, and mitigating the impact of harmful training samples on the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119398108A_ABST
    Figure CN119398108A_ABST
Patent Text Reader

Abstract

The invention discloses a training and sampling method and device for a supervisible diffusion model and a medium, and relates to the field of data processing, and the method comprises the steps: obtaining a supervisible initial diffusion model, adding a control layer in the initial diffusion model, and obtaining a diffusion model; training the diffusion model by adopting the training set until the trained diffusion model meets a preset condition, and obtaining a trained diffusion model; and deploying the trained diffusion model at a user side, adjusting and optimizing the trained diffusion model by adopting the user side to obtain a supervisible diffusion model, and sampling by adopting the supervisible diffusion model to obtain a sampling result. The diffusion model can be prevented from generating harmful samples in the intermediate process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing, and in particular to a training and sampling method, device and medium for a regulated diffusion model. Background Art

[0002] In recent years, diffusion models have become a mainstream image generation technology, which can be used to generate a large number of colorful, vivid, and diverse pictures. However, the problem that comes with it is how to prevent diffusion models from being trained to generate harmful samples, and how to prevent diffusion models from being affected by harmful training samples.

[0003] The main solution to the above problem is post-processing, that is, to identify the image after it is generated, and not to show it to the end user if it is harmful. The main disadvantage of this solution is that if the model is decompiled by the user after distribution and the intermediate results of the diffusion model are obtained, the intermediate results can be used directly to perform harmful actions. Based on this, how to prevent the diffusion model from generating harmful samples in the intermediate process has become a technical problem that needs to be solved urgently in this field. Summary of the invention

[0004] The purpose of this application is to provide a supervised diffusion model training and sampling method, device and medium, which can prevent the diffusion model from generating harmful samples in the intermediate process.

[0005] To achieve the above objectives, this application provides the following solutions:

[0006] In a first aspect, the present application provides a method for training and sampling a regulated diffusion model, wherein the method for training and sampling a regulated diffusion model is implemented based on an RSS framework; the method for training and sampling a regulated diffusion model comprises:

[0007] Obtaining an initial diffusion model that can be supervised, and adding a control layer to the initial diffusion model to obtain a diffusion model;

[0008] The diffusion model is trained using a training set until the trained diffusion model meets a preset condition, thereby obtaining a trained diffusion model;

[0009] The trained diffusion model is deployed on a user terminal, the trained diffusion model is tuned by using the user terminal to obtain a regulated diffusion model, and the regulated diffusion model is used for sampling to obtain a sampling result.

[0010] Optionally, the control layer is added between the convolutional layer and the pooling layer of the neural network architecture of the initial diffusion model.

[0011] Optionally, the expression of the control layer is:

[0012] O (l) : =γ (l) ⊙I (l) +β (l) ;

[0013] Where ⊙ is the dot product symbol, O (l) and I (l) is the output and input of the RR layer, γ (l) and β (l) are two coefficients related to the diffusion model parameters, γ (l) =U (γ) (l,:,:)Ω y (x t , pc τ )V (γ) (l,:,:),β (l) =U (β) (l,:,:)Ω y (x t , pc τ )V (β) (l,:,:),U (γ) 、V (γ) , U (β) 、V (β) are all mapping functions, Ω y (x t , pc τ ) is the intermediate generation result of the tth step of the diffusion model, l is the lth layer of the neural network, x t is a matrix, pc τ A one-time password generated for the current system time τ.

[0014] Optionally, an autoregressor that only retains the encoder part is used to determine the intermediate generation result Ω of the diffusion model in the tth step y (x t , pc τ ), where Ω y (x t , pc τ )=EC(x t , pc τ ,y);

[0015] In the formula, EC(x t , pc τ ,y) represents the function of the autoregressive that only retains the encoder part, y is x t The label of the matrix.

[0016] Optionally, the diffusion model is trained using a training set until the trained diffusion model meets a preset condition, thereby obtaining a trained diffusion model, including:

[0017] Initialize the parameters of the diffusion model;

[0018] Taking samples from the training set, obtaining a sampling step from a uniform distribution, obtaining a sampling distribution value from a Gaussian distribution, and determining an intermediate result of a current sampling step in a diffusion model;

[0019] Get the current UNIX timestamp;

[0020] Determine a mapping function based on the current UNIX timestamp and the intermediate result;

[0021] Construct the objective function;

[0022] The objective function is used to derive the parameters and mapping function of the diffusion model, and the parameters and mapping function of the diffusion model are iteratively updated through the gradient descent method to obtain the trained diffusion model, until the value change of each dimension of the parameters of the trained diffusion model is less than the set value relative to the previous cycle, and the trained diffusion model is obtained.

[0023] Optionally, the objective function is expressed as:

[0024]

[0025] In the formula, L is the optimization target, is the mathematical expectation, and are switching coefficients, ∈ is the sampling distribution value, is the diffusion model after training, t is the sampling step, L is the KL distance, x t is the matrix when the sampling step is t, pc τ The one-time password generated by the current system time τ, is a Gaussian distribution, I is the unit matrix, Ω - (x t , pc τ ) and Ω + (x t , pc τ ) are all state matrices related to the intermediate results and the one-time password, α t are pre-set hyperparameters. is the intermediate quantity, α s is the hyperparameter when s, x t-i is the matrix when the sampling step is ti.

[0026] Optionally, a supervised diffusion model is used for sampling to obtain sampling results, including:

[0027] In the user terminal, determining an intermediate result of the diffusion model that can be supervised;

[0028] A classifier is adopted on the supervisor side to generate labels based on the intermediate results of the diffusion model that can be supervised;

[0029] Determining whether the intermediate result of the regulated diffusion model contains harmful information based on the label;

[0030] When it is determined that harmful information exists, the training process or sampling process is blocked;

[0031] When it is determined that no harmful information exists, the intermediate result of the regulated diffusion model is iteratively modified until an initial value is obtained, and the initial value is used as the sampling result.

[0032] Optionally, when it is determined that no harmful information exists, the formula Iteratively modifying the intermediate result of the regulated diffusion model until an initial value is obtained, and using the initial value as the sampling result;

[0033] In the formula, is the matrix when the sampling step is t-1 in the supervised diffusion model, is an intermediate result of the diffusion model that can be supervised, is the matrix when the sampling step is t in the supervised diffusion model, ∈ θ is a regulated diffusion model, β t are the coefficients of the diffusion model that can be supervised when the sampling step is t.

[0034] In a second aspect, the present application provides a computer device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the training and sampling method of the regulated diffusion model provided above.

[0035] In a third aspect, the present application provides a non-transitory computer-readable medium having a computer program stored thereon, which, when executed by a processor, implements the training and sampling method of the regulated diffusion model provided above.

[0036] According to the specific embodiments provided in this application, this application discloses the following technical effects:

[0037] The present application provides a method, device and medium for training and sampling a regulated diffusion model. By training a diffusion model obtained by adding a control layer to an initial diffusion model, a trained diffusion model is obtained. By tuning the trained diffusion model, a regulated diffusion model can be obtained. In the process of sampling using a regulated diffusion model, harmful samples can be prevented from being generated in the intermediate process of the diffusion model, thereby preventing the diffusion model from being trained to generate harmful samples. In addition, by using a user end to perform model training and tuning the trained diffusion model, the diffusion model can be prevented from being affected by harmful training samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0039] Figure 1 This is a diagram of an application environment for a training and sampling method of a regulated diffusion model in an embodiment of the present application;

[0040] Figure 2 A flowchart of a training and sampling method for a regulated diffusion model provided in an embodiment of the present application;

[0041] Figure 3 A schematic diagram of the structure of a diffusion model provided in one embodiment of the present application;

[0042] Figure 4 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION

[0043] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0044] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0045] The training and sampling method of the supervised diffusion model provided in the embodiment of the present application can be applied to Figure 1In the application environment shown in the figure, the definition of RSS includes three parties: the model owner, the user, and the regulator. The purpose of adversarial example resistance training is to reduce the diffusion model (for a description of this model, see the document "Jonathan Ho, Ajay Jain, Pieter Abbeel, Denoising Diffusion Probabilistic Models, In Proc. of NeurIPS 2020.") from being used to generate harmful information, or to prevent the diffusion model from being poisoned by tuning on harmful data.

[0046] From a hardware perspective, the model owner, user, and supervisor can all be considered a computer. The control layer can be considered a device installed on the user side. This device can control the user side to perform specific training, tuning, sampling methods, and other processing.

[0047] Among them, the model owner: in the training data The diffusion model is trained on the CNN. For the detailed background of the diffusion model, please refer to the paper "Jonathan Ho, Ajay Jain, Pieter Abbeel, Denoising Diffusion Probabilistic Models, In Proc. of NeurIPS 2020.".

[0048] User side: Download the supervised diffusion model ∈ θ , and use it directly or on private data to model the regulated diffusion ∈ θ Perform tuning.

[0049] Regulator: An independent third party responsible for regulating the regulated diffusion model ∈ θ The tuning and sampling stages are to prevent the generation of harmful information. The supervisor has a classifier f:x→{+,-}, and the input is a supervised diffusion model ∈ θ The intermediate result of the tuning and sampling phase is a + / - label, the purpose of which is to monitor the regulated diffusion model ∈ θ Is there any harmful information in the intermediate results?

[0050] In an exemplary embodiment, Figure 2 As shown, a method for training and sampling a regulated diffusion model is provided. The method is executed by a computer device, and can be executed by a computer device such as a terminal or a server alone, or by a terminal and a server together. In the embodiment of the present application, the method is applied to Figure 1 The RSS framework is taken as an example to illustrate, including the following steps 200 to 202.

[0051] in:

[0052] Step 200: Obtain an initial diffusion model that can be supervised, and add a control layer to the initial diffusion model to obtain a diffusion model.

[0053] Step 201: Use the training set to train the diffusion model until the trained diffusion model meets the preset conditions, thereby obtaining the trained diffusion model.

[0054] Step 202: deploy the trained diffusion model on the user end, use the user end to tune the trained diffusion model to obtain a regulated diffusion model, and use the regulated diffusion model to perform sampling to obtain a sampling result.

[0055] Implementing the above steps 200 to 202 can prevent the diffusion model from generating harmful samples in the intermediate process, thereby preventing the diffusion model from being trained to generate harmful samples. In addition, the present application can prevent the diffusion model from being affected by harmful training samples by using the user end to perform model training and tuning the trained diffusion model.

[0056] In another exemplary embodiment of the present application, a control layer is added to the U-Net neural network architecture of the diffusion model, such as Figure 2 As shown, the control layer is located between the convolutional layer and the subsequent pooling layer.

[0057] The definition of the control layer is as follows:

[0058] O (l) : =γ (l) ⊙I (l) +β (l) (1)

[0059] γ (l) =U (γ) (l,:,:)Ω y (x t , pc τ )V (γ) (l, :, :) (2)

[0060] β (l) =U (β) (l,:,:)Ω y (x t , pc τ )V (β) (l, :, :) (3)

[0061] Where ⊙ is the dot product symbol, O (l) and I (l) is the output and input of the RR layer, γ (l) and β (l)are two coefficients related to the diffusion model parameters. (γ) 、V (γ) , U (β) 、V (β) Both are mapping functions, which expand the dimension of Ω to the size of the input / output. Mathematically speaking, it changes the size of the matrix, which also becomes a model parameter. y (x t , pc τ ) is the intermediate generation result of the diffusion model in the tth step during the current training / testing process, l is the lth layer of the neural network, and x t is a matrix, pc τ is the one-time password generated by the current system time τ, y is the output of the classifier f:x→{+,-}, and is x t Labels. Ω, γ (l) , β (l) The sizes of the three matrices are Ω∈R M×N , γ (l) ∈R H×W , β (l) ∈R H×W .U (γ) , U (β) ∈R L×H×M And V (γ) , V (β) ∈R L×N×W .

[0062] In another exemplary embodiment of the present application, an autoregressor that only retains the encoder part can be used to determine the intermediate generation result Ω of the diffusion model in the tth step. y (x t , pc τ ). Based on this, Ω y (x t , pc τ ) is calculated as follows:

[0063] (1) Train an auto-encoder, denoted as AE, whose input and output are both [x t , pc τ , y]. Where [., ., .] represents the concatenation of feature vectors. The value of y is + or -, and +1 / -1 can be used instead in actual calculations. The architecture of the autoregressor can refer to the literature "GE Hinton, RR Salakhutdinov, Reducing the Dimensionality of Data with Neural Networks. Science 313, 504-507 (2006). DOI: 10.1126 / science.1127647.".

[0064] (2) Discard the decoder part of the autoregressive and keep the encoder part, denoted as function EC(.).

[0065] (3) Calculate Ω using the following formula y (x t , pc τ ).

[0066] Ω y (x t , pc τ )=EC(x t , pc τ ,y) to calculate Ω y (x t , pc τ ). (4)

[0067] In the formula, EC(x t , pc τ ,y) represents the function of the autoregressive that only retains the encoder part, y is x t The label of the matrix.

[0068] In another exemplary embodiment of the present application, the diffusion model The training input is the training set and hyperparameter α t , whose output is the trained diffusion model Based on this, the diffusion model under the RSS framework The training process can be described as:

[0069] (1) Initialize the parameters of the diffusion model.

[0070] (2) From the training set Take the sample x from the uniform distribution {1,2,3,...,T} and get the sampling step t from the Gaussian distribution. The intermediate result of the current sampling step in the diffusion model is determined based on the diffusion model. The intermediate result of the tth step in the diffusion model is: Calculate Ω according to formula (4) - (x t , pc τ ).

[0071] (3) Get the current UNIX timestamp τ.

[0072] (4) Determine the mapping function based on the current UNIX timestamp and the intermediate results.

[0073] (5) Construct the objective function. The constructed objective function is expressed as:

[0074]

[0075] In the formula, L is the optimization target, is the mathematical expectation, and are switching coefficients, ∈ is the sampling distribution value, is the diffusion model after training, t is the sampling step, Ω - (x t , pc τ ) and Ω + (x t , pc τ ) are all state matrices related to the intermediate results and the one-time password, x t is the matrix when the sampling step is t, pc τ The one-time password generated by the current system time τ, is a Gaussian distribution, I is the unit matrix, α t are pre-set hyperparameters. is the intermediate quantity, α s is the hyperparameter when x is s. t-i is the matrix when the sampling step is ti. f is the classifier of the supervisory end defined at the beginning. Its physical meaning is that when the current sample x has f(x) = +, the second term of the optimization objective is adopted. Determine the optimization goal, otherwise, use the first Determine the optimization goal. The KL here is the mathematical KL distance, which is used to describe the distance between two probability distributions.

[0076] (6) The objective function is used to derive the parameters and mapping function of the diffusion model, and the parameters and mapping function of the diffusion model are iteratively updated through the gradient descent method to obtain the trained diffusion model, until the value change of each dimension of the parameters of the trained diffusion model is less than the set value (for example, 10 -8 ), the trained diffusion model is obtained.

[0077] Among them, Ω - (x t , pc τ ) into the diffusion model (Diffusion Model In the example above, a control layer as described in Section A has been added between the convolutional layer and the pooling layer. - (x t , pc τ ) into γ (l) and β (l) The calculation formula [i.e., formula (2) and formula (3)] is used.

[0078] The objective function is applied to the diffusion model parameters θ and {U (γ) , V (γ) , U (β) , V (β)} derivative. By gradient descent method, update the parameters θ and {U (γ) , V (γ) , U (β) , V (β)}, and update as follows:

[0079]

[0080]

[0081]

[0082]

[0083]

[0084] In the formula, {U′ (γ) , V′ (γ) , U′ (β) , V′ (β)} represents the updated {U (γ) , V (γ) , U (β) , V (β)}.

[0085] After the above steps, step (2) to step (6) is to iteratively update the parameters until convergence. Step (2) is the normal operation of the diffusion model, which is used to calculate the intermediate result of the tth step in the diffusion process defined by the diffusion model. It should be noted here that during the tuning process, it cannot be ensured that there are no harmful samples in the data set used for tuning, so it must pass through the classifier on the supervisor side. At this time, the algorithm blocks the training process to wait for the result. After the judgment result is returned, the latest Ω can be calculated y (x t , pc τ ), we can calculate the parameters θ and {U (γ) , V (γ) , U (β) , V (β)} to perform derivatives, and then use the gradient descent method to update the model parameters. Finally, the trained diffusion model is returned.

[0086] In another exemplary embodiment of the present application, the tuning algorithm is mainly deployed on the user side, and its input is a regulated diffusion model and a hyperparameter α tBased on this, in the above step 202 of the present application, the implementation process of using a supervised diffusion model for sampling and obtaining the sampling result may include:

[0087] 1) In the user end, determine the intermediate results of the diffusion model that can be supervised.

[0088] 2) A classifier is used on the supervisor side to generate labels based on the intermediate results of the supervised diffusion model.

[0089] 3) Determine whether there is harmful information in the intermediate results of the regulated diffusion model based on the label.

[0090] 4) When it is determined that harmful information exists, the training process or the sampling process is blocked.

[0091] 5) When it is determined that there is no harmful information, the intermediate results of the regulated diffusion model are iteratively modified until the initial value is obtained, and the initial value is used as the sampling result. For example, using the formula The intermediate results of the regulated diffusion model are iteratively modified until an initial value is obtained, and the initial value is used as the sampling result.

[0092] In the formula, is the matrix when the sampling step is t-1 in the supervised diffusion model, is an intermediate result of the diffusion model that can be supervised, is the matrix when the sampling step is t in the supervised diffusion model, ∈ θ is a regulated diffusion model, β t are the coefficients of the diffusion model that can be supervised when the sampling step is t.

[0093] Based on the above description, in the actual citation process, the above sampling process can be described as:

[0094] 1. Sample the initial value of the sampling process from a Gaussian distribution

[0095] 2. Get the current UNIX timestamp τ.

[0096] 3. Sent to the supervisor.

[0097] 4. Block the current training process until the supervisor sends back

[0098] 5. Loop t=T, T-1, ..., 2, 1.

[0099] 6. Sampling from a Gaussian distribution

[0100] 7. Bring in a regulated diffusion model ∈ θ .

[0101] 8. Calculate the intermediate results of step t-1 in the regulated diffusion model

[0102] 9. Get the current UNIX timestamp τ.

[0103] 10. Sent to the supervisor.

[0104] 11. Block the current training process until the supervisor sends back

[0105] 12. Assignment

[0106] 13. Return x, which is the sample finally generated by the model. This sample is used for subsequent experimental evaluation.

[0107] In another exemplary embodiment of the present application, an experiment was conducted on the I2P benchmark dataset. I2P collects 8 types of (pictures, prompt words) pairs that may be harmful. Diffusion models such as stable diffusion can be induced to produce corresponding harmful pictures. In this embodiment, the I2P dataset is used to construct training, verification, and test sets in a ratio of 90:5:5. The experiment is divided into two parts:

[0108] Part 1: In order to verify the effectiveness of this application in preventing the diffusion model from generating harmful images, stablediffusion 1.4 was selected as the corresponding diffusion model, its architecture was modified (i.e., a control layer was added), and the proposed tuning method was used to tune the original training data of stable diffusion. Then, the prompt words in the test set were used as input, and the proportion of harmful content in the sample results generated by the proposed RSS method (i.e., the training and sampling method of the regulated diffusion model provided by this application) was counted. The harmful content here is detected by the Q16 / NudeNet classifier. The experimental results are shown in Table 1 below.

[0109] Table 1 First Experimental Results

[0110] Dataset SD-v1.4 RSS-DS(items) Hatred 0.40 0.04 Harassment 0.34 0.04 Violence 0.43 0.10 Self-harm 0.40 0.04 sex 0.35 0.04 Intimidation 0.52 0.10 Criminal behavior 0.34 0.03 overall 0.39 0.07

[0111] SD-v1.4 and RSS-DS are the proportions of harmful content generated by stable diffusion based on the prompt words in the I2P test set before and after the method provided by the present application is adopted. It can be seen that the method provided by the present application can effectively reduce the proportion of harmful information generated by the diffusion model.

[0112] Part II: To verify the effectiveness of the method proposed in this application in preventing the model from being tuned on harmful data. This embodiment compares the ratio of the loss function values ​​(Loss-IvR) of the model on two types of data, including harmful (picture, prompt word) pairs and harmless (picture, prompt word) pairs, when using and not using the RSS method after being tuned on I2P. The larger the ratio, the better the trained model can fit the harmless data rather than the harmful data. The experimental results are shown in Table 2 below, where the harmful data comes from the I2P data set and the harmless samples come from the original training set of stable diffusion.

[0113] Table 2 Second Experimental Results

[0114]

[0115]

[0116] It can be seen that the method provided by this application can effectively reduce the impact of harmful data on model training, because the model fits more harmless samples rather than harmful samples.

[0117] In summary, the method provided by this application is a method that can realize the tuning and sampling process of supervised open source diffusion models for the first time, which can effectively reduce the diffusion model from being used to generate harmful information or being tuned on harmful data to cause model poisoning. This framework is the first of its kind and there is no existing alternative method, which can effectively prevent the generation of harmful samples.

[0118] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store sampling results and intermediate results of a regulated diffusion model. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a training and sampling method for a regulated diffusion model is implemented.

[0119] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components. In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0120] In an exemplary embodiment, a non-transitory computer-readable medium is provided, storing a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0121] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0122] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0123] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM may be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).

[0124] The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. The non-relational database may include a distributed database based on blockchain, etc., but is not limited thereto. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but is not limited thereto.

[0125] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0126] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.

Claims

1. A method for training and sampling a supervised diffusion model, characterized in that: The training and sampling method of the regulated diffusion model is implemented based on the RSS framework; the training and sampling method of the regulated diffusion model includes: Obtaining an initial diffusion model that can be supervised, and adding a control layer to the initial diffusion model to obtain a diffusion model; The diffusion model is trained using a training set until the trained diffusion model meets a preset condition, thereby obtaining a trained diffusion model; The trained diffusion model is deployed on a user terminal, the trained diffusion model is tuned by using the user terminal to obtain a regulated diffusion model, and the regulated diffusion model is used for sampling to obtain a sampling result.

2. The method for training and sampling a supervised diffusion model according to claim 1, characterized in that: The control layer is added between the convolutional layer and the pooling layer of the neural network architecture of the initial diffusion model.

3. The method for training and sampling a supervised diffusion model according to claim 2, characterized in that: The expression of the control layer is: The (l) :=c (l) ⊙I (l) +b (l) ; Where ⊙ is the dot product symbol, O (l) and I (l) is the output and input of the RR layer, γ (l) and β (l) are two coefficients related to the diffusion model parameters, γ (l) =U (γ) (l,:,:)Ω y (x t ,pc τ )V (γ) (l,:,:),β (l) =U (β) (l,:,:)Ω y (x t ,pc τ )V (β) (l,:,:),U (γ) 、V (γ) , U (β) 、V (β) are all mapping functions, Ω y (x t ,pc τ ) is the intermediate generation result of the tth step of the diffusion model, l is the lth layer of the neural network, x t is a matrix, pc τ A one-time password generated for the current system time τ.

4. The method for training and sampling a supervised diffusion model according to claim 3, characterized in that: The autoregressor that only retains the encoder part is used to determine the intermediate generation result Ω of the diffusion model in the tth step y (x t ,pc τ ), where Ω y (x t ,pc τ )=EC(x t ,pc τ ,y); In the formula, EC(x t ,pc τ ,y) represents the function of the autoregressive that only retains the encoder part, y is x t The label of the matrix.

5. The method for training and sampling a supervised diffusion model according to claim 1, characterized in that: The diffusion model is trained using a training set until the trained diffusion model meets a preset condition, thereby obtaining a trained diffusion model, including: Initialize the parameters of the diffusion model; Taking samples from the training set, obtaining a sampling step from a uniform distribution, obtaining a sampling distribution value from a Gaussian distribution, and determining an intermediate result of a current sampling step in a diffusion model; Get the current UNIX timestamp; Determine a mapping function based on the current UNIX timestamp and the intermediate result; Construct the objective function; The objective function is used to derive the parameters and mapping function of the diffusion model, and the parameters and mapping function of the diffusion model are iteratively updated through the gradient descent method to obtain the trained diffusion model, until the value change of each dimension of the parameters of the trained diffusion model is less than the set value relative to the previous cycle, and the trained diffusion model is obtained.

6. The method for training and sampling a supervised diffusion model according to claim 5, characterized in that: The objective function is expressed as: In the formula, L is the optimization target, is the mathematical expectation, and are switching coefficients, ∈ is the sampling distribution value, is the diffusion model after training, t is the sampling step, KL is the KL distance, x t is the matrix when the sampling step is t, pc τ The one-time password generated by the current system time τ, is a Gaussian distribution, I is the unit matrix, Ω - (x t ,pc τ ) and Ω + (x t ,pc τ ) are all state matrices related to the intermediate results and the one-time password, α t are pre-set hyperparameters. is the intermediate quantity, α s is the hyperparameter when s, x t-i is the matrix when the sampling step is ti.

7. The method for training and sampling a supervised diffusion model according to claim 1, characterized in that: The sampling is performed using a supervised diffusion model to obtain sampling results, including: In the user terminal, determining an intermediate result of the diffusion model that can be supervised; A classifier is adopted on the supervisor side to generate labels based on the intermediate results of the diffusion model that can be supervised; Determining whether the intermediate result of the regulated diffusion model contains harmful information based on the label; When it is determined that harmful information exists, the training process or sampling process is blocked; When it is determined that no harmful information exists, the intermediate result of the regulated diffusion model is iteratively modified until an initial value is obtained, and the initial value is used as the sampling result.

8. The method for training and sampling a supervised diffusion model according to claim 7, characterized in that: When it is determined that no harmful information exists, the formula Iteratively modifying the intermediate result of the regulated diffusion model until an initial value is obtained, and using the initial value as the sampling result; In the formula, is the matrix when the sampling step is t-1 in the supervised diffusion model, is an intermediate result of the diffusion model that can be supervised, is the matrix when the sampling step is t in the supervised diffusion model, ∈ θ is a regulated diffusion model, β t are the coefficients of the diffusion model that can be supervised when the sampling step is t.

9. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the training and sampling method of the supervised diffusion model described in any one of claims 1 to 8.

10. A non-transitory computer-readable medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the training and sampling method of the supervised diffusion model described in any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Mask optimization method, system and equipment based on double diffusion model and storage medium

    CN118520777A

  • Diffusion model-based high mobility confrontation sample generation method and related device

    CN118551223A

  • Distributed monitoring system and method based on diffusion model

    CN118656267A

  • Method and device for generating reasoning network simulation flow based on superposition diffusion model

    CN118827410A