Backdoor attack method based on diffusion model and cross attention

By guiding the generation of imperceptible triggers in the diffusion model and combining with the self-attention mechanism, the problem of low trigger concealment in existing backdoor attacks is solved, a backdoor attack method with high concealment and attack effect is realized, and the image quality is reduced. Identify model application risks.

CN118736384APending Publication Date: 2024-10-01BEIHANG UNIV
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202411040080.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

The triggers in existing backdoor attack methods are too obvious, resulting in low concealment, making it difficult to effectively execute in actual applications, and posing a threat to the security of deep learning models.

Method used

A backdoor attack method based on the diffusion model and cross-attention is adopted. The cross-attention is used to guide the generation of imperceptible triggers in the latent space of the diffusion model. The self-attention mechanism is combined to maintain the image structure during the denoising process, and the poisoned image is generated. Both resemble the original image and contain learnable triggers.

Benefits of technology

It significantly improves the concealment of the trigger, ensures the attack effect, and reduces the application risk of the image recognition model, providing an important contribution to the advancement of backdoor defense technology.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118736384A_ABST
    Figure CN118736384A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence security, and discloses a backdoor attack method based on a diffusion model and cross attention, and the method comprises the following steps: S1, obtaining original image data; s2, inputting the original image data into a trained diffusion model; s3, extracting a potential feature vector generated by the diffusion model in a reverse denoising process, and embedding and inputting the potential feature vector and a text into a trained cross attention module to generate a cross attention feature graph to complete primary denoising; outputting a final de-noised image as a trigger; s4, injecting the trigger into the original image data to generate a poisoning image; according to the method, the trigger which is difficult to perceive can be guided and generated in the potential space of the diffusion model through cross attention, so that the concealment of the trigger is remarkably improved, and an attack effect is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of artificial intelligence security technology, and more specifically to a backdoor attack method based on diffusion model and cross attention. Background Art

[0002] In recent years, deep learning has achieved remarkable application results in the field of image recognition due to its outstanding performance in dealing with complex problems. However, research shows that currently deployed image recognition models face many security threats, among which backdoor attacks are of particular concern. Such attacks usually implant backdoors by tampering with training data sets or modifying models during training, causing the model to produce incorrect classification results when encountering images with specific triggers, but perform normally when processing normal images, so the existence of backdoors is difficult to detect. This has led to a lot of attention to the security issues of the model.

[0003] Most of the current backdoor attack methods still inject trigger information into the RGB space of the image. This method is also easily observed by the human eye, which limits the feasibility of backdoor attacks in practical applications. Since the purpose of the backdoor attack is to add triggers to cause the victim model to be classified as the attacker's target label, the process of adding triggers can be similar to a special real image editing. The diffusion model can be regarded as image editing. It is a generative model derived from a branch of thermodynamics, namely non-equilibrium thermodynamics. Its algorithmic theoretical basis is to train parameterized Markov chains through variational inference. In the diffusion model, Markov chain is one of the most core concepts, and one of its key properties is stationarity. In other words, if a probability distribution changes over time, then under the influence of the Markov chain, it will gradually tend to a stable distribution. Over time, this distribution will gradually become stable. Simply put, the diffusion model is the process of gradually denoising data from pure noise data through deep neural network learning.

[0004] The cross-attention mechanism is often used in the guidance process of the text graph. It is similar to the self-attention mechanism, but the difference is that the query vector comes from different sequences, and the attention weight is calculated between two different sequences. First, the original input is mapped to three different vectors through three learnable matrices, namely the query vector , the key vector , value vector , these three vectors are obtained by dot multiplication of the input vector and three matrices. The weights of these three matrices will be adjusted during the training process. The second step is to dot multiplication of the query vector and the key vector to obtain an attention matrix, which is then processed by softmax to obtain the final attention matrix, and finally multiplied with the value vector to obtain the final sequence.

[0005] Since deep learning models require high financial, computing, and time costs, many users may entrust the training and deployment of deep learning models to third parties, so backdoor attacks are easy to launch, posing a significant threat to users who do not have the expertise to train deep learning models. Compared with other attacks, backdoor attacks are more subtle and more difficult to defeat. Although the initial backdoor attacks were mainly focused on the field of computer vision, they have now expanded to other fields, such as text, audio, object detection, etc., and have become the focus of current research in the field of deep learning security.

[0006] Since the triggers in current backdoor attacks are too obvious and can be easily detected by the human eye, their concealment is relatively low.

[0007] Therefore, how to improve the concealment of backdoor attacks and make important contributions to promoting the advancement of backdoor defense technology and reducing the application risks of image recognition models is an issue that technical personnel in this field urgently need to solve. Summary of the invention

[0008] In view of this, the present invention provides a backdoor attack method based on a diffusion model and cross-attention, which can guide the generation of imperceptible triggers in the latent space of the diffusion model through cross-attention, thereby significantly improving the concealment of the trigger and achieving the attack effect.

[0009] In order to achieve the above object, the present invention adopts the following technical solution:

[0010] A backdoor attack method based on diffusion model and cross attention includes the following steps:

[0011] S1: Get original image data;

[0012] S2: inputting the original image data into the trained diffusion model;

[0013] S3: extracting the latent feature vector generated by the diffusion model in the reverse denoising process, and inputting the latent feature vector and text embedding into the trained cross-attention module, and using the generated cross-attention map as the copy latent vector to complete a denoising;

[0014] S4: Generate a trigger according to the denoised image, and inject the trigger into the original image data to generate a poisoned image.

[0015] Preferably, the image processing step of the diffusion model includes:

[0016] Adding noise to the image data multiple times, each noise addition is performed at a different time stamp, thereby generating an original latent vector with noise;

[0017] The image is inverted based on the original noise latent vector obtained from the last noise addition, and denoised in sequence without the guidance of a classifier to obtain the replica latent vectors corresponding to each timestamp.

[0018] Preferably, the non-classifier includes a conditional denoising module, an unconditional denoising module and a guiding module;

[0019] The conditional denoising module is used to perform diffusion according to the conditional text embedding and the input potential vector to obtain a first diffusion result;

[0020] The unconditional denoising module is used to perform diffusion according to the empty text embedding and the input potential vector to obtain a second diffusion result;

[0021] The guiding module is used to fuse the first diffusion result and the second diffusion result according to a preset guiding scale parameter, and output a denoised potential feature vector.

[0022] Preferably, the training step of the diffusion model includes:

[0023] The empty text embedding is iteratively optimized according to the bootstrap results in each timestamp; the loss function used in the optimization is:

[0024]

[0025] in, represents the result of a denoising operation. represents an empty text embedding, It represents the denoising result when the guidance scale is 1.

[0026] Preferably, the training step of the diffusion model includes: respectively calculating the self-attention of the original latent vector and the current latent vector at the same timestamp, and constructing a self-attention constraint condition to constrain the parameter optimization of the cross-attention module.

[0027] Preferably, the self-attention constraint is:

[0028]

[0029] in, refers to the self-attention of the replica latent vector, refers to the self-attention of the original latent vector, Represents the parameters of the criss-cross attention module.

[0030] Preferably, the cross attention module uses a learnable linear projection , ,and The latent feature vector of the noisy image Mapping to Query Matrix , mapping text embedding to Key matrix and , get the cross attention map :

[0031]

[0032] Where d represents the projection dimension.

[0033] Preferably, the training method of the cross attention module is:

[0034]

[0035] in, Calculate the variance of the input, It represents the accumulation of cross-attention maps at all times during the denoising process. LDM (Latent Diffusion Model) is a pre-trained diffusion model.

[0036] Preferably, generating a trigger according to the denoised image specifically comprises: calculating an average cross-attention image according to the cross-attention images outputted from each timestamp and upsampling the image, and then using the up-sampled image as a mask to add the trigger;

[0037]

[0038]

[0039] in, represents the upsampling operation, which is used to adjust the size of the cross-attention map; It is used to extract the average cross attention map The maximum value in is the upsampled image.

[0040] Preferably, the trigger is injected in the following manner:

[0041]

[0042] in, Indicates a poisoned image, It is a 2D matrix of height i and width j, representing the mask parameters, which determines the coverage of the trigger on the original image. is the original image, Represents a trigger generated by a diffusion model.

[0043] It can be seen from the above technical solutions that, compared with the prior art, the present invention discloses a backdoor attack method based on a diffusion model and cross-attention. The present invention is based on the operation of the diffusion model, utilizes the powerful generation ability of the pre-trained diffusion model, and generates almost any image by simply providing the corresponding text description, thereby ensuring that the generated image is similar to the original image. In addition, the present invention introduces a cross-attention mechanism to guide the diffusion model to embed semantic triggers in the latent vector, which is convenient for the image recognition model to learn; at the same time, the self-attention mechanism is used in the denoising process of the diffusion model to maintain its own structure, so that the generated image is similar to the original image, and at the same time, a trigger that the model can learn is added. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0045] Figure 1 A schematic diagram of a backdoor attack method based on a diffusion model and cross-attention provided by the present invention.

[0046] Figure 2 The present invention provides a backdoor attack method framework based on diffusion model and cross attention.

[0047] Figure 3 Schematic diagram of a guidance method without a classifier in an embodiment of the present invention. DETAILED DESCRIPTION

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

[0049] like Figure 1 and Figure 2 The embodiment of the present invention discloses a backdoor attack method based on a diffusion model and cross attention, comprising the following steps:

[0050] S1: Acquire image data;

[0051] S2: Input the original image data into the trained diffusion model; the diffusion model processes the image including the noise addition process and the denoising process. Based on this, multiple noise additions are performed at different times to obtain a series of images with noise , ... , then in the image Based on this, denoising is performed in turn to achieve image reconstruction.

[0052] S3: Extract the latent feature vector generated by the diffusion model in the reverse denoising process, and input the latent feature vector and text embedding into the trained cross-attention module, generate the cross-attention map as the copy latent vector, and complete one denoising.

[0053] S4: Generate a trigger according to the denoised image, and inject the trigger into the original image data to generate a poisoned image.

[0054] In this embodiment, by adjusting the cross attention of text embedding and noise latent vector in the inversion process of the diffusion model, the final image reconstruction result of the diffusion model is used as a trigger and injected into the original image to generate a poisoned image.

[0055] The trigger can be the final cross-attention map output, or it can be generated by combining the cross-attention maps output by each timestamp. In addition, the trigger image can be directly output as the poisoned image without injecting the original image.

[0056] In order to further implement the above technical solution, Figure 3 ,Image reconstruction is performed by text-guided classifier-free inversion denoising of the diffusion model.

[0057] Specifically, the classifier-free method includes a conditional denoising module, an unconditional denoising module and a guiding module; the conditional denoising module is used to diffuse according to conditional text embedding and noise latent vector to obtain a first diffusion result; the unconditional denoising module is used to diffuse according to empty text embedding and noise latent vector to obtain a second diffusion result; the guiding module is used to fuse the first diffusion result and the second diffusion result according to a preset guiding scale parameter, and output a latent feature vector.

[0058] The bootstrap without classifier is defined as:

[0059]

[0060] in represents the guiding scale, is the embedding of the text condition, is a latent vector with noise, and the noise varies according to time Add to sample data middle.

[0061] Furthermore, the empty text embedding is optimized during the inversion process of the diffusion model without classifier guidance, so as to achieve accurate reconstruction of the original image. Both the unconditional denoising diffusion module and the conditional denoising diffusion module are parameterized by the same neural network and trained simultaneously. During the training process, the model parameters are optimized by minimizing the loss function, which includes indicators to evaluate the quality of image generation and consistency with given conditions.

[0062] The specific process is to guide the scale in DDIM. = 1, the output noise potential vector is ,..., , first Initialize to , Represents the potential vector at each step when performing the optimization; and for timestamps = ,...,1, using the default guide scale = 7.5 Perform the following optimizations, each time stamp Iterations.

[0063] The loss function used in optimization is:

[0064]

[0065] in, represents the result of a denoising operation. represents an empty text embedding, represents the denoising result when the guide scale is 1. At the end of each step, update Finally, the noise is applied to the input image , and optimized unconditional text embedding A high-quality reconstruction of the image can be obtained.

[0066] The loss function used in optimization is:

[0067]

[0068] in, represents the result of a denoising operation. represents an empty text embedding, It represents the denoising result when the guidance scale is 1.

[0069] To further implement the above technical solution, the image processing process of cross attention in S3 is as follows:

[0070] The criss-cross attention module uses a learnable linear projection , ,and The latent feature vector of the noisy image Mapping to Query Matrix , mapping text embedding to Key matrix and , get the cross attention map :

[0071]

[0072] Where d represents the projection dimension.

[0073] Furthermore, by optimizing the cross-attention module and changing the high-level semantics of the image, the generated images are guaranteed to be aggressive.

[0074] Specifically, the guide of the text is identified as the label of the image, the cross-attention map between the image and the text is accumulated in all denoising processes, and the average value is calculated. The cross-attention module is optimized by minimizing the following formula.

[0075]

[0076] in, represents the variance of the calculated input, Represents the accumulation of all cross-attention maps during the denoising process, and LDM is a pre-trained diffusion model. The idea is to distract the attention of the diffusion model from the target label. By evenly distributing the cross-attention to each pixel of the image, the original high-level semantic information can be changed as a trigger, thus ensuring that the generated poisoned image can be successfully attacked.

[0077] Furthermore, in order to ensure the concealment of the poisoned image, a self-attention mechanism is used to maintain the image’s own structure. The specific steps are: Self-attention of the replica latent vector, constructing self-attention constraints to constrain the parameter optimization of the cross-attention module.

[0078] The criss-cross attention module adjusts the criss-cross attention by minimizing the following formula:

[0079]

[0080] in, refers to the optimizable self-attention, Refers to the original self-attention at each step t.

[0081] The final optimization goals are as follows:

[0082]

[0083] In order to further implement the above technical solution, we consider using the cross-attention map as a mask to add triggers to further improve the concealment of poisoned images. Specifically, the trigger injection method is defined as adjusting the influence of the trigger based on the position and strength of the cross-attention map, so that the trigger is more concentrated in the key semantic area of ​​the image to achieve a better poisoning effect.

[0084]

[0085]

[0086] In this process, represents an upsampling operation, which is used to adjust the size of the cross-attention map to accommodate the existing downsampling in the auto-encoders and U-Net encoders in the LDM model. It is used to extract the cross attention map The maximum value in is normalized to ensure the accuracy and effectiveness of the mapping. The purpose of this step is to enable the cross-attention map to better reflect the important semantic information in the image and provide more accurate guidance for the subsequent poisoned image generation process.

[0087] Define the trigger injection method as:

[0088]

[0089]

[0090] Indicates that the trigger is applied to the original image The trigger pattern is a 3D matrix representing pixel color intensities and has the same dimensions (height, width, and color channels) as the input image. is a 2D matrix called a mask that determines how much the trigger covers the original image. Here, consider a 2D mask (height, width) where the same mask value is applied to all color channels of a pixel.

[0091] In order to further implement the above technical solution, the steps also include: mixing the original poisoned image and the clean image as a training set to participate in the training of the victim image recognition model.

[0092] The working principle of the present invention is:

[0093] Firstly, the unconditional empty text embedding used by the classifier-free guidance method in the inversion process of the diffusion model (DDIM) is optimized to achieve high-fidelity image inversion, thereby improving the quality and effect of text-to-image synthesis. The purpose is to use the diffusion model to generate images similar to the original images. Then, after ensuring that the image can be basically reconstructed, the cross-attention mechanism is introduced to guide the diffusion model to embed semantic triggers in the latent vector, which is convenient for the image recognition model to learn. At the same time, the self-attention mechanism is used in the denoising process of the diffusion model to maintain its own structure. Finally, in order to reduce the modification of the original image and further improve the concealment of the trigger, it is proposed to upsample the cross-attention map and use it as a mask for the final generated poisoned image. Through these steps, the poisoned image is successfully produced and sent to the image recognition model for training together with the clean image. In the inference stage, the victim model will output the true label of the clean test input image, and output the target label set by the attacker for the poisoned test input image, so as to achieve the purpose of the backdoor attack. These studies not only reveal the potential threat of backdoor attacks in complex algorithms and deep learning models, but also provide valuable guidance for researchers to develop more secure and reliable image recognition systems.

[0094] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0095] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A backdoor attack method based on diffusion model and cross attention, characterized in that: The following steps are involved: S1: Get original image data; S2: inputting the original image data into the trained diffusion model; S3: extracting the latent feature vector generated by the diffusion model in the reverse denoising process, and inputting the latent feature vector and text embedding into the trained cross-attention module, and using the generated cross-attention map as the copy latent vector to complete a denoising; S4: Generate a trigger according to the denoised image, and inject the trigger into the original image data to generate a poisoned image.

2. According to claim 1, a backdoor attack method based on diffusion model and cross attention is characterized in that: The image processing step of the diffusion model includes: Adding noise to the image data multiple times, each noise addition is performed at a different time stamp, thereby generating an original latent vector with noise; Based on the original noise latent vector obtained from the last noise addition, the image is inverted and denoised in sequence without the guidance of a classifier to obtain the replica latent vectors corresponding to each timestamp.

3. According to claim 2, a backdoor attack method based on diffusion model and cross attention is characterized in that: The non-classifier includes a conditional denoising module, an unconditional denoising module and a guiding module; The conditional denoising module is used to perform diffusion according to the conditional text embedding and the input potential vector to obtain a first diffusion result; The unconditional denoising module is used to perform diffusion according to the empty text embedding and the input potential vector to obtain a second diffusion result; The guiding module is used to fuse the first diffusion result and the second diffusion result according to a preset guiding scale parameter, and output a denoised potential feature vector.

4. According to claim 2, a backdoor attack method based on diffusion model and cross attention is characterized in that: The training steps of the diffusion model include: The empty text embedding is iteratively optimized according to the bootstrap results in each timestamp; the loss function used in the optimization is: ; in, represents the result of a denoising operation. represents an empty text embedding, It represents the denoising result when the guidance scale is 1.

5. According to claim 1, a backdoor attack method based on diffusion model and cross attention is characterized in that: The training steps of the diffusion model include: calculating the self-attention of the original latent vector and the replica latent vector at the same timestamp respectively, and constructing a self-attention constraint condition to constrain the parameter optimization of the cross-attention module.

6. According to claim 5, a backdoor attack method based on diffusion model and cross attention is characterized in that: The self-attention constraints are: ; in, refers to the self-attention of the replica latent vector, refers to the self-attention of the original latent vector, Represents the parameters of the criss-cross attention module.

7. According to claim 5, a backdoor attack method based on diffusion model and cross attention is characterized in that: The criss-cross attention module uses a learnable linear projection , ,and The latent feature vector of the noisy image Mapping to Query Matrix , mapping text embedding to Key matrix and , get the cross attention map : ; Where d represents the projection dimension.

8. The backdoor attack method based on diffusion model and cross attention according to claim 7 is characterized in that: The training method of the cross attention module is: ; in, Calculate the variance of the input, It represents the accumulation of cross-attention maps at all times during the denoising process. LDM (Latent Diffusion Model) is a pre-trained diffusion model.

9. The backdoor attack method based on diffusion model and cross attention according to claim 1 is characterized in that: The generating trigger according to the denoised image specifically comprises: calculating an average cross-attention image according to the cross-attention images outputted from each timestamp and upsampling the image, and then using the up-sampled image as a mask to add the trigger; ; ; in, represents the upsampling operation, which is used to adjust the size of the cross-attention map; It is used to extract the average cross attention map The maximum value in is the upsampled image.

10. A backdoor attack method based on diffusion model and cross attention according to claim 9, characterized in that: The trigger is injected as follows: ; in, Indicates a poisoned image, It is a 2D matrix of height i and width j, representing the mask parameters, which determines the coverage of the trigger on the original image. is the original image, Represents a trigger generated by a diffusion model.

Citation Information

Cited By

  • Non-training layout-to-image generation method based on diffusion model

    CN119169146A

  • Potential space human motion generation method based on diffusion model

    CN119169205A

  • Back door detection method of text map diffusion model based on attention transfer

    CN121167722A

  • A backdoor detection method of a text-to-image diffusion model based on attention shift

    CN121167722B

  • AI large model jailbreak attack detection method and system based on hybrid expert model and positive unmarked learning

    CN121193482A