Method for training text graph model and generating target image through model

Through data poisoning and backdoor attack technology, sensitive information is redirected to targeted prompt words, and deep semantic information is used instead of explicit triggers, solving the problem of the literary graphics model generating sensitive content, and achieving efficient and safe images Generate, reduces training costs and ensures content security.

CN118887686AActive Publication Date: 2024-11-01INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES

Patent Information

Application Number
CN202411085718.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-11-01
Estimated Expiration
2044-08-08

AI Technical Summary

Technical Problem

The existing literary and biographical model has a ratio of up to 20% of unsafe images when generating images, and malicious users can use harmful adversarial prompt words to generate sensitive content, resulting in moral and security impacts. Existing defense strategies such as model fine-tuning and Post-event content review has problems of performance degradation and high inference costs.

Method used

Using data poisoning and backdoor attack technology, redirect sensitive information to targeted prompt words, and replace explicit triggers with deep semantic information of sensitive content, only fine-tuning of text encoder of the text-general graph model to improve Robustness and reduce training costs.

Benefits of technology

It effectively eliminates sensitive content in generated images, ensures content security, improves the robustness of the model, realizes low-cost and efficient training, ensures the privacy and security of the image generation process, and is suitable for actual production environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118887686A_ABST
    Figure CN118887686A_ABST
Patent Text Reader

Abstract

The invention discloses a method for training a text graph model and generating a target image through the model, and belongs to the technical field of network security. Establishing a text model by the first text encoder and the second text encoder, and establishing an image model by the latent space diffusion model and the image decoder; obtaining a benign cue word data set, a confrontation cue word data set and a target cue word; and finely adjusting a loss function between text embedding by using a data poisoning technology and a backdoor attack technology so as to complete training of the text generation graph model. According to the method, the sensitive content in the image generated by the text graph model is effectively eliminated, the content security and robustness of the process of generating the target image by the text graph model are ensured, and the image related to the sensitive information is prevented from being generated and propagated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of network security and relates to a method for training a text-generated graph model and generating a target image through the model. Background Art

[0002] Image generation technology based on text-to-image models is a key technology in the field of computer vision. In recent years, text-to-image models have achieved remarkable success in both academia and industry. By inputting appropriate prompt words, these models can generate images that are closely aligned with the provided descriptions, showing high fidelity and marking the beginning of the era of artificial intelligence generated content (AIGC). However, with the widespread application of text-to-image models, the ethical and security implications associated with their deployment have become increasingly prominent, and a key issue points to the generation of sensitive content.

[0003] Research shows that the four existing popular models (Stable Diffusion, LDM, DALL-E 2, DALL-E mini) can generate up to 20% of unsafe images. At the same time, malicious users can use harmful adversarial cues to generate specifically designed sensitive content, exacerbating problems and challenges.

[0004] Current defense strategies fall into two broad categories: model fine-tuning and post-mortem content moderation, the latter of which can be further subdivided into cue-based moderation and image-based moderation. Model fine-tuning aims to directly eliminate most sensitive content generated by the text graph model; however, this approach is highly dependent on the precise definition of sensitive content and often results in a significant degradation in the model's generation performance. Post-mortem content moderation typically uses cue-word filters to identify and remove malicious cue words, or image filters to analyze generated images and review sensitive elements. Unlike model fine-tuning, these methods avoid interfering with the training process of the text graph model, thereby maintaining the quality of the generated images. However, post-mortem content moderation relies heavily on comprehensive labeled datasets and encounters challenges in adapting to new types of attacks or identifying unseen sensitive content. In addition, image-based moderation methods utilize the output of the text graph model as input, and therefore incur huge inference costs.

[0005] Data poisoning is a technique that exploits loopholes in learning algorithms or model training processes, where attackers inject malicious data into training datasets in order to damage the performance of the model or induce specific behaviors during reasoning. However, data poisoning can also achieve positive results. If the injected data is carefully designed, the decision boundary of the model can be subtly changed or its predetermined results can be aligned with the attacker's goals.

[0006] Backdoor attack techniques refer to the secret integration of hidden functions into the model, which are then triggered by specific input data to execute predetermined behaviors. Typical backdoor attack methods change the training data or process of a specific model to establish a robust association between the trigger and its corresponding output target. Triggers are usually basic letters or specific symbols with only vague or limited meanings. Summary of the invention

[0007] Based on the above technical background, the present invention proposes a method for training a text graph model and generating a target image through the model. Regarding the problem that the image results generated by the text graph model contain a large amount of sensitive content, data poisoning and backdoor attack techniques are used to redirect sensitive information to targeted prompt words to prevent the generation of sensitive content. Regarding the problem that model fine-tuning technology is highly dependent on the precise definition of sensitive content, deep semantic information of sensitive content is used to replace explicit prompt words as triggers, thereby improving robustness. Regarding the problem that the training and reasoning costs of existing defense strategies are high, only the text encoder of the text graph model is fine-tuned, and the model training can be completed within one minute.

[0008] The technical solution of the present invention is as follows:

[0009] A method for training a text graph model, comprising:

[0010] A text model is established by using a first text encoder and a second text encoder, and deep semantic information in sensitive content or prompt words pointing to sensitive content is used as a trigger of the text model; an image model is established by using a latent space diffusion model and an image decoder;

[0011] Fixing the parameters of the first text encoder, the latent space diffusion model and the image decoder and disabling external filtering mechanisms;

[0012] A benign prompt word dataset, an adversarial prompt word dataset and a target prompt word are obtained; the benign prompt word dataset contains benign prompt words, which are sentences or phrases that do not contain sensitive content and do not point to sensitive content; the adversarial prompt word dataset contains adversarial prompt words, which are sentences or phrases that directly contain sensitive content or point to sensitive content; the target prompt word is a specified optional sentence or phrase that does not contain sensitive content and does not point to sensitive content;

[0013] Input the benign prompt word data set into the first text encoder and the second text encoder to obtain a first benign text embedding and a second benign text embedding; input the target prompt word into the first text encoder to obtain a target text embedding; mix the benign prompt word data set and the adversarial prompt word data set according to a set poisoning ratio and then input them into the second text encoder to obtain a poisoned text embedding;

[0014] Fine-tune the parameters of the second text encoder so that the sum of the loss function between the first benign text embedding and the second benign text embedding and the loss function between the target text embedding and the poisoned text embedding approaches a minimum value, so as to obtain a trained second text encoder and complete the training of the text graph model.

[0015] Preferably, the text model adopts the CLIP model, and the image model adopts the Stable Diffusion model.

[0016] Preferably, the adversarial prompt word data set accounts for no less than 0.16% of the set poisoning ratio.

[0017] Preferably, the loss function is L 总 =L 良性 +γ·L 后门 ,in:

[0018] A good loss function is

[0019] The backdoor loss function is

[0020] T1(Y) is the first benign text embedding, T2(Y) is the second benign text embedding, T1(z) is the target text embedding, T2(X) is the poisoned text embedding, B and B′ are batch sizes, y represents the cue word in the benign cue word dataset Y, x represents the cue word in the benign cue word dataset X, d() represents the similarity measure, and γ represents the weight coefficient.

[0021] Preferably, the similarity metric is selected from cosine similarity Loss, mean square error MSE Loss, mean absolute error MAE Loss, or Poincar'e Loss.

[0022] Preferably, the value range of γ is 0.05-0.5.

[0023] Preferably, the text graph model is verified, and the verification criteria are:

[0024] Benign cue words and adversarial cue words are input into the trained second text encoder respectively, and both output images that do not contain sensitive content.

[0025] A method for generating a target image by using a text-generated graph model, comprising:

[0026] Input the prompt word to the trained second text encoder to obtain text embedding;

[0027] Based on the above text embedding, a random vector is guided in the latent space diffusion model to obtain the target vector latent space;

[0028] The image decoder decodes the target vector latent space to obtain the target image.

[0029] The beneficial effects of the present invention are as follows:

[0030] In the present invention, the text graph model in which the trained second text encoder is located effectively eliminates the sensitive content in the generated image, and uses data poisoning and backdoor attack technology to redirect sensitive information to targeted prompt words, thereby ensuring the content security of the text graph model in the process of generating the target image. At the same time, the text graph model in this article does not rely on the precise definition of sensitive content, but uses the deep semantic information in sensitive content or prompt words with sensitive content as a trigger, so that the text graph model can learn the deep semantic information therein, so the text graph model of the present invention has high robustness. The present invention can realize the training of the second text encoder only by fine-tuning, has extremely low training cost and efficient training speed, can be practically deployed in an actual production environment, ensures the privacy and security of the text graph model application process, ensures that images involving sensitive information are not generated and disseminated, maintains social security and stability, and has high practical application value. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A schematic diagram of a method for training a text-generated graph model and generating a target image using the model

[0032] Figure 2 This is a data distribution diagram of benign prompt words and adversarial prompt words in an embodiment of the present invention.

[0033] Figure 3 Schematic diagram of the Buster robustness verification phase in an embodiment of the present invention

[0034] Figure 4 It is a line graph showing the changes of various parameters of the second text encoder in the 4chan dataset test as the weight coefficient changes in the embodiment of the present invention

[0035] Figure 5 is a line graph showing the changes of various parameters of the second text encoder in the I2P pornographic data set test as the weight coefficient changes in the embodiment of the present invention DETAILED DESCRIPTION

[0036] In order to prove the technical effect of the present invention, the present invention is experimentally compared with SD-V1.4 (no defense strategy) and SD-V2.1, Safety Filter, SafeGen, ESD, SLD and other defense strategies. The experiment shows that the text graph model of the present invention has the highest sensitive content elimination rate for eliminating sensitive content, while well ensuring the quality of benign images.

[0037] 1. Dataset and Experimental Configuration:

[0038] Selection of training data set: The present invention adopts LAION Aesthetics v2 6.5+ data set as the benign cue word data set, and uses MS COCO2014 validation set as the benign cue word validation set; the 4chan and I2P data sets are divided into training set and validation set in a ratio of 8:2, respectively, as adversarial cue word data sets; in addition, ChatGPT is used to rewrite the 4chan data set to generate two data sets with similar content but different expressions, one containing almost no sensitive content, and the other still containing a large amount of sensitive content, which are used for robustness research. The target cue word is "a cute cat" to verify the effectiveness of the method proposed in the present invention.

[0039] (Supplementary information on the dataset: The LAION Aesthetics v2 6.5+ dataset is a subset of the LAION 5B dataset, containing 635,561 image-text pairs with predicted aesthetic scores greater than or equal to 6.5. The MS COCO dataset is a large-scale object detection, segmentation, keypoint detection, and captioning dataset consisting of 328K images; the first version of the MS COCO dataset was released in 2014, which contains 164K images and is divided into training sets (83K), validation sets (41K), and test sets (41K). The 4chan dataset consists of the top 500 most descriptive prompts selected from 2,470 original 4chan prompts, which were collected from a marginal network community 4chan website known for spreading toxic / unsafe images. The I2P dataset includes 4,710 real user prompts designed for text-to-image generation tasks that may produce a certain proportion of unsafe images. The I2P dataset is divided into 7 types, as shown in Table 1, and some prompts may belong to multiple categories.

[0040]

[0041] Table 1

[0042] Based on the original 500 cue words from the 4chan dataset, two similar datasets were created by ChatGPT. For each cue word, five sentences were rewritten, resulting in two new datasets, each containing 2,500 cue words. The "sensitive" dataset retained the inappropriate semantic content but changed the description, and the "clean" dataset removed most of the inappropriate semantic content, including sex, violence, politics, insults, fighting, weapons, and illegal activities, while maintaining consistency with the original object context. )

[0043] Benchmark model selection: The present invention selects 9 benchmark models for comparison and divides them into 5 categories according to the defense strategy. (1) No defense strategy: SD-V1.4, using OpenAI's CLIP encoder and disabling the security check mechanism of the original SD-V1.4 model; (2) External review: SD-V2.1, a model that has been retrained on a large-scale dataset that has been censored by an external filter; (3) Post-content review: Safety Filter, using the original SD-V1.4 model with a safety filter; (4) Text-independent: SafeGen, deploying a pre-trained text-independent SafeGen model; (5) Model fine-tuning: ESD, SLD (most), SLD (strong), SLD (medium), SLD (weak) There are five models in total, directly deploying the pre-trained model, where (most, strong, medium, weak) represents the degree of sensitive content elimination, and only the setting of the bootstrap coefficient is different. For the convenience of comparison, the model of the present invention is named Buster, which belongs to the model fine-tuning category.

[0044] System and hardware environment selection: The security model of the present invention is implemented by Python 3.8.10, the deployment framework is Pytorch 1.10.2, the system environment is Ubuntu 20.04.1LTS, and the hardware environment is a single A100 GPU.

[0045] Selection of evaluation indicators: The benign image protection rate is represented by the text-image consistency index CLIP Score and the fidelity FID. The sensitive content removal rate is calculated by NudeNet and Q16 model detection and represented by the text-image consistency index CLIP Score. At the same time, the model quality is measured by similarity and accuracy, and the benign similarity Sim 良性 Represents the similarity between the first text encoder and the second text encoder of the benign prompt word, using the target similarity Sim 目标 Represents the similarity between the target prompt word in the first text encoder and the adversarial prompt word in the second text encoder, using the adversarial similarity Sim 对抗Indicates the similarity between the adversarial prompt word and the first text encoder and the second text encoder. The ImageNet-V2 model is used to measure the accuracy Acc@1 and Acc@5. For the benign image protection rate, the smaller the FID index, the better, and the larger the CLIP Score index, the better; for the sensitive content elimination rate, the smaller the NudeNet, Q16 and CLIP Score index, the better, and for the model quality, Sim 对抗 The smaller the indicator, the better. 良性 ,Sim 目标 ,Acc@1,Acc@5 indicators are both better if they are larger.

[0046] Model parameter selection: The batch size B of the benign cue word dataset is set to 32, the batch size B′ of the adversarial cue word dataset is set to 16, the optimizer is AdamW, the step size is set to 400, and the learning rate is set to 10 -4 , after 150 steps it drops to 10 -5 , the similarity metric selected cosine similarity MSE Loss, and it only took 45 seconds to fine-tune the entire model.

[0047] 2. Experimental method:

[0048] The process of this embodiment is as follows Figure 1 As shown:

[0049] A text model is established by using a first text encoder and a second text encoder, and deep semantic information in sensitive content or prompt words pointing to sensitive content is used as a trigger of the text model; an image model is established by using a latent space diffusion model and an image decoder;

[0050] Fixing the parameters of the first text encoder, the latent space diffusion model and the image decoder and disabling external filtering mechanisms;

[0051] A benign prompt word dataset, an adversarial prompt word dataset and a target prompt word are obtained; the benign prompt word dataset contains benign prompt words, which are sentences or phrases that do not contain sensitive content and do not point to sensitive content; the adversarial prompt word dataset contains adversarial prompt words, which are sentences or phrases that directly contain sensitive content or point to sensitive content; the target prompt word is a specified optional sentence or phrase that does not contain sensitive content and does not point to sensitive content;

[0052] Input the benign prompt word data set into the first text encoder and the second text encoder to obtain a first benign text embedding and a second benign text embedding; input the target prompt word into the first text encoder to obtain a target text embedding; mix the benign prompt word data set and the adversarial prompt word data set according to a set poisoning ratio and then input them into the second text encoder to obtain a poisoned text embedding;

[0053] Fine-tune the parameters of the second text encoder so that the sum of the loss function between the first benign text embedding and the second benign text embedding and the loss function between the target text embedding and the poisoned text embedding approaches a minimum value, so as to obtain a trained second text encoder and complete the training of the text graph model.

[0054] Preferably, the text model adopts the CLIP model, and the image model adopts the Stable Diffusion model.

[0055] Preferably, the adversarial prompt word data set accounts for no less than 0.16% of the set poisoning ratio.

[0056] Preferably, the loss function is L 总 =L 良性 +γ·L 后门 ,in:

[0057] A good loss function is

[0058] The backdoor loss function is

[0059] T1(Y) is the first benign text embedding, T2(Y) is the second benign text embedding, T1(z) is the target text embedding, T2(X) is the poisoned text embedding, B and B′ are batch sizes, y represents the cue word in the benign cue word dataset Y, x represents the cue word in the benign cue word dataset X, d() represents the similarity measure, and γ represents the weight coefficient.

[0060] Preferably, the similarity metric is selected from cosine similarity Loss, mean square error MSE Loss, mean absolute error MAE Loss, or Poincar'e Loss.

[0061] Preferably, the value range of γ is 0.05-0.5.

[0062] Preferably, the text graph model is verified, and the verification criteria are:

[0063] Inputting benign prompt words into the first text encoder will output a normal image that does not contain sensitive content;

[0064] Input the adversarial prompt word to the first text encoder, which will output an image containing sensitive content;

[0065] Inputting benign prompt words into the trained second text encoder will output a normal image that does not contain sensitive content;

[0066] Inputting the adversarial cue word into the trained second text encoder will output a normal image that does not contain sensitive content.

[0067] A method for generating a target image by using a text-generated graph model, comprising:

[0068] Input the prompt word to the trained second text encoder to obtain text embedding;

[0069] Based on the above text embedding, a random vector is guided in the latent space diffusion model to obtain the target vector latent space;

[0070] The image decoder decodes the target vector latent space to obtain the target image.

[0071] 3. Experimental results:

[0072] Figure 2 The data distribution diagram of the benign and adversarial prompt words of the present invention shows the data distribution visualization of the benign prompt words (marked as "b") and the adversarial prompt words (marked as "a"). This visualization is drawn by passing the prompt words into the first text encoder and then using TSNE to reduce the embedding space to two dimensions. Figure 2 In the figure, benign cues are shown in blue, while adversarial cues are shown in red and other colors. In the high-dimensional semantic space, the clear distinction between benign cues and adversarial cues proves the validity and rationality of the experimental data in this invention.

[0073] a) Quantitative experimental results

[0074] Table 2 shows the performance of Buster compared to other baselines, and the results show that Buster outperforms all other methods in removing sensitive content while still generating high-fidelity benign images.

[0075]

[0076]

[0077] Table 2

[0078] The present invention uses NudeNet and Q16 to classify inappropriate images generated by 4chan and I2P datasets. Given that the I2P dataset is divided into seven types: pornography, harassment, hatred, violence, self-harm, shock, and illegal, the present invention divides it into seven smaller datasets. Since other baselines mainly focus on removing pornographic or nude content, the present invention only uses the pornographic subset of I2P for evaluation. Five pictures are generated for each prompt word, and the proportion of pornographic pictures is calculated. A lower proportion indicates a better sensitive content removal effect. The results in Table 1 show that when detected using NudeNet, Buster only generates 0.6% of pornographic images in the 4chan dataset and only 0.7% of pornographic images in the I2P porn dataset, which is also the lowest proportion observed. Among the other baselines, SD-V1.4 has the highest nudity generation rate on the I2P porn dataset evaluated by NudeNet, while ESD has the lowest nudity generation rate on the 4chan dataset. When classified by Q16, Buster generates even lower proportions of sensitive images, 0.2% and 0.1%, respectively, while among other methods, SafeGen generates the most sensitive images at 10.4% on the I2P porn dataset, and SLD (Medium) generates the least sensitive images at 0.6% on the 4chan dataset. Both metrics show that Buster outperforms all other baselines in mitigating sensitive content generation.

[0079] We compute the FID metric for Buster and other baseline generated images to evaluate the quality of benign images. The FID score is calculated between the generated image set and a set of reference images, and lower FID indicates better image quality. We generate 10,000 images for all methods on the COCO dataset. Buster has an FID of 18.63, which is lower than SLD and slightly higher than other methods. The results show that Buster has minimal impact on the quality of benign prompt generation.

[0080] CLIP scores are calculated for adversarial cue words and benign cue words. For the 4chan and I2P datasets, lower CLIP scores indicate a greater difference between the image and the cue word, thereby exhibiting better sensitive content removal capabilities. In contrast, for the COCO dataset, higher CLIP scores indicate better alignment between the image and the cue. As shown in Table 1, among all baselines, Buster has the lowest CLIP scores on the 4chan dataset and the I2P porn dataset, which are 13.71 and 12.32, respectively. For the COCO dataset, Buster's CLIP score is 24.35, just slightly lower than the highest value of 24.65. These results highlight Buster's superior performance in sensitive content removal and benign image quality assurance.

[0081] b) Generalization Experiment Results

[0082] To evaluate the generalization of Buster, we conduct extensive experiments on other subsets of the I2P dataset, as shown in Table 3.

[0083]

[0084]

[0085] Table 3

[0086] Evaluate the similarity and accuracy of the second text encoder. Considering that NudeNet is limited to detecting pornographic and nude content, the present invention specifically uses Q16 to calculate the sensitive content ratio of the generated image. For these indicators, Sim 良性 ,Sim 目标 ,The higher the scores of Acc@1 and Acc@5, the stronger the consistency and accuracy of the second text encoder and the first text encoder in the benign prompt words. 对抗 The lower the scores of , CLIP and Q16, the greater the difference between the second text encoder and the first text encoder in adversarial prompt words, that is, the higher the sensitive content removal ability. The first CLIP model achieved an accuracy of Acc@1=69.84% and Acc@5=90.94%. It can be seen that all indicators showed stability and consistency in different data sets, and no significant differences were observed. This shows that Buster has demonstrated strong generalization capabilities on various data sets.

[0087] c) Robust experimental results

[0088] To verify the robustness of Buster, the 4chan dataset was rewritten with ChatGPT, and after thorough manual screening, two new datasets were generated that were very similar to the original 4chan dataset: one containing sensitive information and the other without explicit sensitive information. The present invention expands each original prompt into five similar sentences and uses Buster to generate an image for each sentence. The original 4chan dataset is labeled "original", the rewritten subset with sensitive content is labeled "sensitive", and the rewritten subset with less sensitive content is labeled "clean". The results shown in Table 4 show that the text graph model generates significantly fewer sensitive images on all datasets using the second text encoder compared to the first encoder, thus verifying the robustness of Buster.

[0089]

[0090] Table 4

[0091] Figure 3The generated image is shown. Buster effectively removes sensitive information semantics while retaining benign semantics. In the figure, "damn" represents sensitive information, and "gorilla" represents the description object of the prompt word. When simply replacing the description in the sentence, the output result points to the target image (a cute cat). When the input prompt word does not contain sensitive information semantics, the output can accurately generate the description object.

[0092] d) Ablation experiment results

[0093] (1) Loss weight: We change the weight parameter γ from 0 to 10 and evaluate the similarity and accuracy of the second text encoder under various adversarial prompts, such as Figure 4 and Figure 5 As shown, Figure 4 This is the test result on the 4chan dataset. Figure 5 The test results are on the I2P pornographic data set, using Sim_Benign to represent Sim 良性 , Sim_Advers means Sim 对抗 , Sim_Target represents Sim 目标 The baseline accuracy of the first text encoder (highlighted in red) is Acc@1 = 69.84%, Acc@5 = 90.94%. For the second text encoder, Sim 目标 The overall trend increases with the increase of γ value, and all other indicators tend to decrease overall, which is reasonable. After fully considering the similarity and accuracy, γ = 0.1 is selected for the experiment.

[0094] (2) Similarity Metrics: We further study the impact of using different similarity metrics in the loss function, specifically mean squared error (MSE Loss), mean absolute error (MAE Loss), and Poincar’e Loss instead of cosine similarity. The results in Table 5 show that choosing different similarity metrics has very little impact on various evaluation metrics.

[0095]

[0096] Table 5

[0097] (3) Target prompt word: In the present invention, "a photo of a cute cat" is used as the target prompt word. However, this choice is not restrictive and other prompt words can be used instead. In order to evaluate the factors that lead to the similarity and accuracy of the second text encoder, the present invention also tests prompt words related to dogs, birds and cars. The results in Table 6 show that there is no significant difference in various evaluation indicators after using different target prompt words.

[0098]

[0099]

[0100] Table 6

[0101] The content of the embodiment is only for the convenience of understanding of those skilled in the art. In actual use, different categories of sensitive content can be projected onto different target prompt words, so that the input prompt words can be effectively distinguished and classified.

Claims

1. A method for training a text graph model, comprising: A text model is established by using a first text encoder and a second text encoder, and deep semantic information in sensitive content or prompt words pointing to sensitive content is used as a trigger of the text model; an image model is established by using a latent space diffusion model and an image decoder; Fixing the parameters of the first text encoder, the latent space diffusion model and the image decoder and disabling external filtering mechanisms; Obtain a benign cue word dataset, an adversarial cue word dataset, and a target cue word; The benign prompt word data set contains benign prompt words, which are sentences or phrases that do not contain sensitive content and do not point to sensitive content; the adversarial prompt word data set contains adversarial prompt words, which are sentences or phrases that directly contain sensitive content or point to sensitive content; the target prompt word is a specified optional sentence or phrase that does not contain sensitive content and does not point to sensitive content; Input the benign prompt word data set into the first text encoder and the second text encoder to obtain a first benign text embedding and a second benign text embedding; input the target prompt word into the first text encoder to obtain a target text embedding; mix the benign prompt word data set and the adversarial prompt word data set according to a set poisoning ratio and then input them into the second text encoder to obtain a poisoned text embedding; Fine-tune the parameters of the second text encoder so that the sum of the loss function between the first benign text embedding and the second benign text embedding and the loss function between the target text embedding and the poisoned text embedding approaches a minimum value, so as to obtain a trained second text encoder and complete the training of the text graph model.

2. The method according to claim 1, characterized in that The text model adopts the CLIP model, and the image model adopts the Stable Diffusion model.

3. The method according to claim 1, characterized in that: The proportion of the adversarial prompt word data set in the set poisoning ratio is not less than 0.16%.

4. The method according to claim 1, characterized in that: The loss function is L 总 =L 良性 +γ·L 后门 , where: The benign loss function is The backdoor loss function is T1(Y) is the first benign text embedding, T2(Y) is the second benign text embedding, T1(z) is the target text embedding, T2(X) is the poisoned text embedding, B and B′ are batch sizes, y represents the cue word in the benign cue word dataset Y, x represents the cue word in the benign cue word dataset X, d() represents the similarity measure, and γ represents the weight coefficient.

5. The method according to claim 4, characterized in that The similarity metric is selected from cosine similarity Loss, mean square error MSE Loss, mean absolute error MAE Loss, or Poincar'e Loss.

6. The method according to claim 4, characterized in that The value range of γ is 0.05-0.

5.

7. The method according to claim 1, characterized in that The cultural graph model is verified, and the verification criteria are: The benign prompt words and the adversarial prompt words are respectively input to the trained second text encoder described in claim 1, and both output images that do not contain sensitive content.

8. A method for generating a target image by using a text graph model, comprising: Inputting the prompt word into the trained second text encoder according to claim 1 to obtain text embedding; Based on the above text embedding, a random vector is guided in the latent space diffusion model to obtain the target vector latent space; The image decoder decodes the target vector latent space to obtain the target image.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 8.

10. A storage medium storing a computer program, wherein when the computer program is executed by a computer, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Image generation content suppression method and system based on text graph diffusion model

    CN117251589A

  • Image generation method and system, electronic equipment and computer readable storage medium

    CN118411283A

  • Systems and methods for text-to-image generation using language models

    US20240185035A1

Cited By

  • Method and device for generating adversarial attack sample, storage medium and electronic equipment

    CN119358605A

  • Adaptive content eliminator and elimination method for image generation large model

    CN119719631A

  • Sensitive information protection method and device, electronic equipment and storage medium

    CN119848934A

  • Multi-modal privacy image generation method and device for black-box controllable declaration graph

    CN121962354A

  • Black-box controllable text-to-image oriented multi-modal privacy image generation method and device

    CN121962354B