Semantic level concept elimination method and system based on domain concept mining
By adding random perturbation to the diffusion model to mine the association concept and performing out-of-neighborhood regularization, the problem of residual implicit association concepts in the diffusion model is solved, more effective concept elimination is achieved, and the elimination effect of the model is improved.
Patent Information
- Application Number
- CN202510312094.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-17
- Publication Date
- 2025-08-08
AI Technical Summary
The existing diffusion model has the problem of "concept remnant" when eliminating concepts, that is, elimination concepts still exist in the concepts of implicit associations, resulting in the generation of unsafe content.
By adding random perturbations in the neighborhood space of eliminating concepts, digging out the associated concepts and mapping them to the anchor concept, combining the concept regularization of the out-of-neighborhood concepts, and using the parameter efficient fine-tuning method LoRA, the concept elimination is achieved.
Effectively eliminate concept residues caused by associated concept input, improve the effectiveness, specificity and universality of elimination, and maintain the model generation performance.
Smart Images

Figure CN120451297A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and in particular relates to a semantic-level concept elimination method and system based on domain concept mining. Background Art
[0002] The recent rise of generative artificial intelligence (GAI) has brought historic opportunities for development in various fields, particularly in text-to-image (T2I) generation. Thanks to training on large-scale internet datasets, T2I diffusion models generate high-quality images. However, these unfiltered, large-scale datasets contain a significant amount of not-safe-for-work (NSFW) content and images involving intellectual property or portrait rights. Diffusion models can even learn and memorize these concepts, making it easy for users to generate harmful or infringing content, leading to the spread of false information and causing greater harm to society. To address this security issue, researchers have designed various safety mechanisms for T2I diffusion models. One straightforward solution is to filter the training dataset and retrain the model using the filtered dataset. Furthermore, NSFW safety checkers attempt to filter out inappropriate results after generation, while classifier-free approaches aim to eliminate concept generation during the inference phase. Recently, several methods have proposed removing these concepts by fine-tuning the T2I diffusion model. Specifically, for text input containing inappropriate concepts, they fine-tune the internal parameters of the generative model so that the generated content no longer contains these concepts. Previous work has reached a consensus on the need to address the trade-off between effectiveness and specificity in concept removal. Given a text input containing eliminated concepts, effectiveness means that the model outputs content that does not contain the eliminated concepts while maintaining overall naturalness. Specificity means that if the text input is unrelated to the eliminated concepts, the output should remain the same as the original model before elimination.
[0003] For previous security mechanisms, retraining the model using filtered images requires expensive computational costs and leads to a decrease in generation quality. NSFW security checkers and methods without classifier guidance are easily circumvented by malicious users because their model parameters and codes are open source. In addition, although fine-tuning methods have good performance, they cannot produce safe results when encountering implicitly associated input concepts. Figure 1As shown, for text inputs that are semantically closely related but do not explicitly include the eliminated concept, previous methods still generate objects of the eliminated concept. For example, when talking about the concept of an actor's name, if the input is a still from a movie, which is the actor's most iconic work, the previous method can still generate a portrait of the actor. Please note that the movie name is a concept closely related to the actor, but the actor's name is not explicitly included in it. The present invention defines this as a "concept residue" problem, that is, the eliminated concept still exists in some implicitly associated concepts. This is something that previous methods cannot solve and is considered to be word-level elimination to some extent. Summary of the Invention
[0004] The purpose of the present invention is to solve the problem of "concept residue" in the concept elimination of the diffusion model, where the eliminated concept still exists in some implicitly associated concepts. Therefore, the present invention proposes a semantic-level concept elimination method and system based on domain concept mining. By introducing an associated concept mining mechanism, random perturbations are added to the embedding of the eliminated concept to mine the associated concepts, thereby expanding the elimination scope and eliminating the content generated by the associated concept input. The present invention proposes a novel concept elimination framework RealEra to solve the concept residue problem caused by the associated concept input, which aims to guide the associated concepts to the anchor concepts through the neighbor concept mining mechanism.
[0005] The technical solution adopted in the present invention is as follows:
[0006] A semantic-level concept elimination method based on domain concept mining includes the following steps:
[0007] By adding random perturbations to the embeddings in the neighborhood space of the eliminated concepts, related concepts are mined;
[0008] Map the eliminated concepts and mined related concepts to the anchor concepts of the diffusion model, and achieve concept elimination by fine-tuning the diffusion model;
[0009] Through out-of-neighborhood concept regularization, the retained concepts that are irrelevant to the eliminated concepts are found and retained.
[0010] Furthermore, the step of adding random perturbations to the embedding in the neighborhood space of the eliminated concept includes:
[0011] Assume that the embedding corresponding to the eliminated concept c is e and the perturbation is η. Constrain the perturbation η from the two aspects of Euclidean distance and cosine similarity: d(e,e+η)≤D1,S2≤cos(e,e+η)≤S1; where D1 is the threshold of Euclidean distance, S1 and S2 are the thresholds of cosine similarity, d(·,·) represents the Euclidean distance, and cos(·,·) represents the cosine similarity.
[0012] Sample a random vector v from a standard normal distribution N(0,1) with the same dimensions as e and compute the unit direction vector from e to v
[0013] Sampling radius r from uniform distribution U[0,D], where D is the upper bound of the uniform distribution sampling range, and then deriving the perturbation
[0014] Filter η:
[0015] Furthermore, the elimination concept and the mined related concepts are mapped to the anchor concept of the diffusion model, and the concept elimination is achieved by fine-tuning the diffusion model, including:
[0016] In the diffusion model U-Net, the text is embedded through the projection matrix W K and W V Projected into K and V vectors respectively;
[0017] Using the closed-form solution to W K and W V Fine-tune the formula as follows:
[0018]
[0019] Among them, e i and are the prompt embeddings of the eliminated concept and the anchor concept, respectively. E and P represent the prompt embedding sets containing the eliminated concept and the retained concept, respectively. The associated concept is added to E, and the retained concept is added to P. W represents W K and W V , W org Represents the weight of the original model and
[0020] A parameter-efficient fine-tuning method, LoRA, is employed to guide the prediction noise of the eliminated concepts to the anchor concepts.
[0021] Furthermore, the parameter efficient fine-tuning method LoRA is used to guide the prediction noise of the eliminated concept to the anchor concept, including:
[0022] Input contains the prompt p of elimination concept c and prompts containing anchor concepts into the diffusion model and align the predicted noise to train the LoRA model, and during the training process i Add perturbations and alternately input the perturbation e i and original e i Serves as input to the diffusion model to ensure the elimination of specified elimination concepts and associated concepts.
[0023] Furthermore, the training of the LoRA model includes:
[0024] The training objectives for odd steps are:
[0025]
[0026] The training objective for even-numbered steps is:
[0027]
[0028] Among them, z t is with The generated image corresponds to the intermediate noise state, p′ c is the associated concept obtained through noise perturbation mining, p″ c is the retained concept obtained by noise perturbation mining, ∈ θ and Represent the new U-Net and the original U-Net respectively.
[0029] Furthermore, the out-of-neighborhood concept regularization includes: sampling N points within a range greater than D1 and less than S2, and keeping the original positions of the sampling points unchanged, by only modifying the mapping relationship of related concepts within the range D1, and keeping the mapping relationship of irrelevant concepts outside the range D1 unchanged, thereby ensuring the generation performance of the diffusion model.
[0030] Furthermore, the above method is used to implement at least one of the following concept elimination: object elimination, celebrity elimination, unsafe content elimination, and artistic style elimination.
[0031] A semantic-level concept elimination system based on domain concept mining, comprising:
[0032] The neighborhood related concept mining module is used to mine related concepts by adding random perturbations to the embeddings in the neighborhood space of the eliminated concepts;
[0033] The concept elimination module is used to map the eliminated concepts and mined related concepts to the anchor concepts of the diffusion model, and achieve concept elimination by fine-tuning the diffusion model;
[0034] The out-of-neighborhood concept regularization module is used to find and retain concepts that are irrelevant to the eliminated concepts through out-of-neighborhood concept regularization.
[0035] The beneficial effects of the present invention are as follows:
[0036] Compared to existing methods, this paper proposes a semantic-level concept elimination method based on domain concept mining to address the problem of concept residue caused by the input of related concepts. Its goal is to guide related concepts to anchor concepts through a neighbor concept mining mechanism. This paper also uses out-of-neighborhood concept regularization to preserve specificity, which compensates for the negative impact of eliminating related concepts on irrelevant concepts. Extensive experiments on multiple benchmarks demonstrate that this paper outperforms previous concept elimination methods in terms of elimination effectiveness, specificity, and versatility. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is the difference between the semantic-level concept elimination method based on domain concept mining and existing methods in dealing with the "concept residue" problem.
[0038] Figure 2 It is a schematic diagram of a semantic-level concept elimination method based on domain concept mining.
[0039] Figure 3 This is a qualitative comparison of the elimination effects of different methods on the CIFAR-10 class.
[0040] Figure 4 This is a qualitative comparison of the elimination effects of different methods on Celebrity.
[0041] Figure 5 It is a qualitative comparison of the elimination effects of different methods on artistic styles.
[0042] Figure 6 is the effect of different hyperparameters of the ablation experiment. DETAILED DESCRIPTION
[0043] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to specific embodiments and accompanying drawings.
[0044] like Figure 2As shown, the present invention proposes a semantic-level concept elimination method based on domain concept mining to prevent the diffusion model from regenerating eliminated concepts using semantically related inputs. Specifically, related concepts are first mined by randomly sampling in the neighborhood space of the eliminated concept. By introducing randomness into the embedding of the eliminated concept and transferring it to the associated concept, the associated concept is guided to the anchor concept. At the same time, deleting a concept from the diffusion model should prevent the catastrophic forgetting of other concepts, while simply suppressing the generation of deleted concepts will lead to severe concept erosion. In order to maintain specificity, the present invention introduces out-of-neighborhood concept regularization, which transforms the eliminated concept into a distant and irrelevant concept by sampling perturbations outside the neighborhood range. This allows irrelevant concepts to maintain their corresponding spatial positions, thereby maintaining their normal generation performance. Subsequently, a closed-form solution is used to optimize the weights of the diffusion model U-Net to achieve cross-attention alignment, as well as alignment with the prediction noise of the LoRA module.
[0045] In the present invention, the elimination concept refers to a concept to be eliminated that is not desired to be generated by the model, the associated concept refers to a concept associated with the elimination concept that enables the model to generate the elimination concept, and the anchor concept refers to a safe concept that can be generated to replace the elimination concept.
[0046] (1) Mining related concepts within the neighborhood:
[0047] For the elimination concept, there are still multiple associated concepts in its neighborhood, which can easily induce the diffusion model to generate the elimination concept. For example, inputting "airport" and "XXX (a certain model of aircraft)" can generate "airplane", and inputting a certain movie name can generate the name of a certain movie star. Therefore, in order to prevent the model from generating elimination concepts through these associated concepts, the present invention proposes an associated concept mining mechanism. Specifically, when fine-tuning the model, random perturbations are added to the input embedding of the elimination concept to transform them into associated concepts in the adjacent semantic space. The diffusion model is fine-tuned to perform elimination by mapping these mined associated concepts and elimination concepts to anchor concepts.
[0048] To address the randomness introduced by random sampling, the present invention designs the following scheme:
[0049] Assume there is a text input p corresponding to the elimination concept c c , its corresponding embedding is e, and the perturbation is defined as η. For the perturbed embeddings, it is expected that they are located in the adjacent space of the eliminated concept, rather than too far away from it. Therefore, the perturbation η is constrained from two aspects: Euclidean distance and cosine similarity:
[0050] d(e,e+η)≤D1 (1)
[0051] S2≤cos(e,e+η)≤S1 (2)
[0052] Where D1 is the threshold of Euclidean distance, S1 and S2 are the thresholds of cosine similarity. d(·,·) represents the Euclidean distance, and cos(·,·) represents the cosine similarity. To this end, first sample a random vector v from the standard normal distribution N(0,1) with the same dimension as e, and calculate the unit direction vector from e to v Next, we sample the radius r from the uniform distribution U[0,D], where D is the upper bound of the uniform distribution sampling range. Finally, we can derive the sampling perturbation η as follows:
[0053]
[0054] Therefore η can be filtered as follows:
[0055]
[0056] The above process is as follows Figure 2 As shown in , e and η ultimately constitute an associated concept.
[0057] The purpose of introducing a certain amount of randomness in the present invention is to fully explore the neighborhood space of the eliminated concept so that the associated concepts obtained can represent the entire range D1. A possible solution is to sample and obtain M disturbances (that is, the number of mining times for the associated concept mining in the neighborhood is M), and add them to the embedding of the eliminated concept mark and its subsequent marks. For simplicity, it is subsequently referred to as adding disturbances to e. It is expected that these associated concepts after adding disturbances will be mapped to anchor concepts to eliminate concept residues. However, it has been found empirically that mapping multiple associated concepts to one anchor concept is too strict, which will damage the generation performance of the model to a certain extent. Therefore, it is hoped that some tolerance will be introduced in the mapping process to allow associated concepts to be mapped to a smaller neighborhood around the anchor concept rather than a specific neighborhood.
[0058] (2) Regularization of out-of-neighborhood concepts:
[0059] Although the present invention has studied the associated concepts in depth, directly mapping them to anchor concepts will greatly affect the generation of other irrelevant concepts. Although the performance of eliminating concepts and retaining irrelevant concepts can be balanced by adjusting the number of mining times M, this is still suboptimal. The present invention believes that when the mapping relationship of most data points within the neighborhood of the eliminated concept changes, concepts within a larger range in the same manifold space will also be affected. Therefore, in order to further alleviate this problem while maintaining the ability to eliminate concept residues, the present invention samples N points in a range greater than D1 and less than S2 in the same way, and keeps the original positions of the sampling points unchanged. In this regularization method, only the mapping relationship of the associated concepts within the range D1 is modified, and the mapping relationship of irrelevant concepts outside the range D1 remains unchanged, thereby ensuring the generation ability of the model.
[0060] (3) Fine-tuning:
[0061] To this end, we can use the aforementioned associated concepts and retained concepts to fine-tune the diffusion model. Retained concepts are those concepts that, in addition to the eliminated concepts, we do not want to be affected by erasure and that we want the model to be able to generate normally after erasure. For example, after erasing the concept "airplane," other concepts unrelated to "airplane," such as "cat," "dog," and "car," are all retained concepts.
[0062] In the diffusion model U-Net, text embedding will be through the projection matrix W K and W V The goal is to guide the K and V vectors corresponding to the eliminated concepts to the anchor concepts in the original model. K and W V Fine-tune the formula as follows:
[0063]
[0064] where e i and Refer to the hint embeddings of the eliminated concept and the anchor concept respectively. E and P represent the hint embedding sets containing the eliminated concept and the retained concept respectively. Deep related concepts are added to E, and retained concepts are added to P. W is also used to concisely represent W K and W V , for W org So too, W org Represents the K vector in the original model weight and V vector
[0065] Since the closed-form solution is an approximate solution of least squares rather than an exact solution, the diffusion model needs to be further optimized. For this purpose, the parameter efficient fine-tuning (PEFT) method LoRA is selected. The goal is to guide the prediction noise of the eliminated concept to the anchor concept. Therefore, the input contains the prompt p of the eliminated concept. c and prompts containing anchor concepts to the model. And align the two prediction noises to train the LoRA model. During the training process, as described above, i Add perturbations and alternately input the perturbation e i and original e i As the input of the model. This ensures the elimination of the specified elimination concept and the elimination of the associated concept. Therefore, the training objective of the odd-numbered step is expressed as:
[0066]
[0067] The training objective for even steps is defined as:
[0068]
[0069] Among them, z t refers to The generated image corresponds to the intermediate noise state. p′ c is the associated concept obtained through noise perturbation mining, p″ c is the retained concept obtained through noise perturbation mining. ∈ θ and Represent the new U-Net and the original U-Net respectively.
[0070] in, That is Figure 2 The L2 loss in . Figure 2 The middle and lower parts of the diagram illustrate the process of erasing the concept "airplane." The left side of the center illustrates erasing only the concept "airplane" without retaining other concepts, while the right side of the center illustrates erasing the concept "airplane" while retaining other concepts. The dots represent the positions of all concepts in the semantic space, and the dashed circles represent the positions of irrelevant concepts in the semantic space before erasure.
[0071] Application scenarios of the present invention:
[0072] 1) Object elimination:
[0073] Object elimination refers to the situation where the existing AIGC model is not allowed to perform unsafe operations such as unauthorized image synthesis, illegal image editing, and image forgery on some objects, such as confidential military targets, politically sensitive landmarks, and items or commodities involving intellectual property rights. Therefore, the existing AIGC model needs to eliminate knowledge about these objects.
[0074] The method of object elimination using the method of the present invention is as follows: input the object concept to be eliminated, use the method of the present invention to mine related concepts in the neighborhood, find related concepts that can generate the object to be eliminated, eliminate them together with the object concept to be eliminated, and through out-of-neighborhood concept regularization, find retained concepts that are not related to the object to be eliminated, retain them, thereby achieving object elimination.
[0075] 2) Celebrity elimination:
[0076] Celebrity elimination refers to the situation where for some celebrities, such as well-known actors, politicians, government officials, etc., we do not want the existing AIGC model to perform unsafe operations such as unauthorized portrait image synthesis, illegal portrait image editing, and portrait image forgery. Therefore, it is necessary to eliminate the knowledge about these celebrities from the existing AIGC model.
[0077] The method of using the method of the present invention to eliminate celebrities is as follows: input the celebrity concept to be eliminated, use the method of the present invention to mine related concepts in the neighborhood, find related concepts that can generate the celebrity to be eliminated, eliminate them together with the celebrity concept to be eliminated, and through out-of-neighborhood concept regularization, find retained concepts that are not related to the celebrity to be eliminated, retain them, thereby achieving celebrity elimination.
[0078] 3) Elimination of unsafe content:
[0079] Unsafe content elimination means that for some unsafe content, such as violence, pornography, horror, etc., we do not want the existing AIGC model to perform unsafe operations such as unauthorized unsafe image synthesis, illegal editing of unsafe images, and unsafe image forgery. Therefore, it is necessary to eliminate these unsafe contents from the existing AIGC model.
[0080] The method for eliminating unsafe content using the method of the present invention is as follows: input the concept of unsafe content to be eliminated, use the method of the present invention to mine related concepts in the neighborhood, find related concepts that can generate the unsafe content to be eliminated, eliminate them together with the concept of the unsafe content to be eliminated, and through out-of-neighborhood concept regularization, find retained concepts that are not related to the unsafe content to be eliminated, retain them, thereby achieving the elimination of unsafe content.
[0081] 4) Artistic style elimination
[0082] Artistic style elimination means that for some artistic styles, such as the style of famous painters, the photographic style of famous photographers, etc., we do not want the existing AIGC model to perform unsafe operations such as unauthorized synthesis of artworks, illegal editing of artworks, and forgery of artworks. Therefore, it is necessary to eliminate the knowledge about these artistic styles from the existing AIGC model.
[0083] The method of using the method of the present invention to eliminate artistic styles is as follows: input the artistic style concept to be eliminated, use the method of the present invention to mine related concepts in the neighborhood, find related concepts that can generate the artistic style to be eliminated, eliminate them together with the artistic style concept to be eliminated, and through regularization of concepts outside the neighborhood, find retained concepts that are not related to the artistic style to be eliminated, retain them, thereby achieving artistic style elimination.
[0084] Effects of the present invention:
[0085] In this section, we extensively investigate the proposed method for four tasks: object removal, celebrity removal, unsafe content removal, and artistic style removal. We also verify the effectiveness of our method in removing residual concepts. In the closed-form solution, λ1 is set to 0.1. LoRA is trained for 200 epochs with a learning rate of 1e-5. Furthermore, γ1 is set to 0.3 and γ2 to 0.7.
[0086] 1) Object Elimination: This paper evaluates the performance of the object elimination task on the CIFAR-10 dataset. This paper evaluates the individual elimination results of one object class in CIFAR-10 each time, and finally evaluates the average performance of 10 classes. e From CLIP classifying 200 images generated using "photos of {eliminate class}", Acc s Similarly derived CLIPs are generated for each of the remaining nine categories using "Photos of {Remaining Categories}". g Also derived from CLIP generated using "photo of {synonym class}". o It is the harmonic mean of these three indicators.
[0087] As shown in Tables 1-3, the elimination performance of the method of the present invention on the 10 categories of CIFAR-10 surpasses the previous SOTA method MACE. Compared with MACE, its comprehensive elimination index H o The method of the present invention not only shows good effectiveness, but also maintains excellent specificity and versatility. At the same time, the performance of the method of the present invention in synonym elimination is impressive. Compared with MACE, Acc g A decrease of 20.5%. Figure 3 More visualization results are shown in . These accurately illustrate that the noise perturbation of our invention expands the scope of concept elimination, resulting in related concepts also being mapped to the anchor concept.
[0088] 2) Celebrity Elimination: Use GIPHY Celebrity Detector (GCD) to evaluate the accuracy of generated images. Eliminated concept corresponding images should have a lower accuracy Acc e , and the retained concept corresponding image should have a higher accuracy Acc s For each identity, choose a well-known role name or honorary title to build a relevant concept. Figure 4 In the results, our method outperformed MACE in terms of single concept elimination effectiveness and outperformed all methods except MACE in terms of specificity. While almost all methods could easily eliminate celebrity concepts, previous methods failed to maintain the quality of generated retained concepts. MACE showed the best specificity but fell short in terms of elimination efficacy and elimination of related concepts. Figure 4 It is shown that the proposed method can eliminate concepts while causing minimal impact on other concepts and can also prevent the "concept residue" problem.
[0089] 3) Artistic style elimination: In the task of eliminating artistic style, Acc sTo test the effectiveness, we calculate the CLIP score between the eliminated artist’s hint and the generated image. Lower scores indicate better effectiveness. Similarly, Acc s Specificity is assessed by computing the CLIP score between the artist-preserved hints and the generated images, with higher values indicating better specificity. Figure 5 It shows that the method of the present invention has superior performance in generating results.
[0090] 4) Unsafe Content Removal: The I2P dataset was used to evaluate the performance of removing explicit content, and Nudenet was used to detect nudity in generated images. As shown in Table 4, our method successfully generates minimal explicit content. Furthermore, CLIP scores were evaluated on MS-COCO prompts and their generated images, demonstrating comparable performance in retaining irrelevant concepts. After our method's removal, the model rarely generates nudity components due to inappropriate prompts, demonstrating the widespread effectiveness of our method.
[0091] 5) Ablation Experiments: We further investigate the effects of various components and hyperparameters in our method. We remove the car from SD v1.4. We combine the following components to compare the four variants in Table 5. Variant 1 only uses the closed-form solution. Although its efficacy and specificity are attractive, Acc g The performance of is poor because it does not involve related concepts. Variant 2 integrates prediction noise alignment. Noise alignment of elimination concepts with anchor concepts further improves the overall performance. Variant 3 extends neighbor concept mining to eliminate related concepts, avoiding the possibility that the post-elimination diffusion model can generate elimination concepts from related concepts. Therefore, it enhances the performance of Variant 1 in Acc e and Acc g The method of the present invention further introduces out-of-neighborhood concept regularization, which eliminates points outside the concept neighborhood and keeps them consistent with the corresponding points of the original model, thereby maintaining Acc e and Acc g While improving Acc s .
[0092] exist Figure 6 (a) shows the effect of the sampling range threshold on D and S. The z-axis is Acc s Subtract Acc e Since we are concerned about the related concepts that cause the model to continue to generate the eliminated concepts, we need to mine these concepts within a certain range D of the eliminated concept neighborhood. If D is too large and S is too small, the sampling range of related concepts may be too large, resulting in good efficacy but poor specificity, so Acc s-e The smaller the sampling range, the worse the performance of eliminating related concepts. Therefore, there is a trade-off between the values of D and S. Figure 6 (b) shows the effect of sample size on M and N. M is too large and N is too small, which means that there are too many sampling points for the associated concepts and too few sampling points for the retained concepts, which is beneficial to effectiveness but poor specificity, so Acc s-e will become smaller; on the contrary, too few sampling points of the associated concept will make the elimination performance worse, so it is necessary to balance the values of M and N. Sampling outside the neighborhood range can alleviate this problem. As the number of samples outside the range increases, the specificity Acc s Will gradually recover. However, Acc g Therefore, there is a trade-off between specificity and generality.
[0093] Table 1 Quantitative comparison of the elimination effects of different methods on CIFAR-10 class (I)
[0094]
[0095] Table 2 Quantitative comparison of the elimination effect of different methods on CIFAR-10 class (II)
[0096]
[0097] Table 3 Quantitative comparison of the elimination effect of different methods on CIFAR-10 class (III)
[0098]
[0099] Table 4 Quantitative comparison of the effects of different methods on removing unsafe content
[0100]
[0101] Table 5 Ablation experiment (influence of different components)
[0102]
[0103] Another embodiment of the present invention provides a semantic-level concept elimination system based on domain concept mining, which includes:
[0104] The neighborhood related concept mining module is used to mine related concepts by adding random perturbations to the embeddings in the neighborhood space of the eliminated concepts;
[0105] The concept elimination module is used to map the eliminated concepts and mined related concepts to the anchor concepts of the diffusion model, and achieve concept elimination by fine-tuning the diffusion model;
[0106] The out-of-neighborhood concept regularization module is used to find and retain concepts that are irrelevant to the eliminated concepts through out-of-neighborhood concept regularization.
[0107] The division of the above modules is only for illustration purposes. In actual applications, the above functions can be assigned to different functional modules as needed to complete all or part of the functions described in the above method. The specific working process of each module can refer to the corresponding process in the above method embodiment and will not be repeated here.
[0108] Another embodiment of the present invention provides a computer device (computer, server, smart phone, etc.), which includes 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 includes instructions for executing each step in the method of the present invention.
[0109] Another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk), wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the steps of the method of the present invention are implemented.
[0110] The specific embodiments of the present invention disclosed above are intended to facilitate understanding and implementation of the present invention. Those skilled in the art will appreciate that various substitutions, changes, and modifications are possible without departing from the spirit and scope of the present invention. The present invention should not be limited to the embodiments disclosed in this specification; the scope of protection of the present invention shall be determined by the scope defined in the claims.
Claims
1. A semantic level concept elimination method based on domain concept mining, characterized by: The following steps are involved: By adding random perturbations to the embeddings in the neighborhood space of the eliminated concepts, related concepts are mined; Map the eliminated concepts and mined related concepts to the anchor concepts of the diffusion model, and achieve concept elimination by fine-tuning the diffusion model; Through out-of-neighborhood concept regularization, the retained concepts that are irrelevant to the eliminated concepts are found and retained.
2. The method according to claim 1, characterized in that The method adds random perturbations to the embeddings in the neighborhood space of the eliminated concepts, including: Assume that the embedding corresponding to the eliminated concept c is e and the perturbation is η. Constrain the perturbation η from the two aspects of Euclidean distance and cosine similarity: d(e,e+η)≤D1,S2≤cos(e,e+η)≤S1; where D1 is the threshold of Euclidean distance, S1 and S2 are the thresholds of cosine similarity, d(·,·) represents the Euclidean distance, and cos(·,·) represents the cosine similarity. Sample a random vector v from a standard normal distribution N(0,1) with the same dimensions as e and compute the unit direction vector from e to v Sampling radius r from uniform distribution U[0,D], where D is the upper bound of the uniform distribution sampling range, and then deriving the perturbation Filter η:
3. The method according to claim 2, characterized in that The process of mapping the eliminated concepts and the mined related concepts to the anchor concepts of the diffusion model and achieving concept elimination by fine-tuning the diffusion model includes: In the diffusion model U-Net, the text is embedded through the projection matrix W K and W V Projected into K and V vectors respectively; Using the closed-form solution to W K and W V Fine-tune the formula as follows: Among them, e i and are the prompt embeddings of the eliminated concept and the anchor concept, respectively. E and P represent the prompt embedding sets containing the eliminated concept and the retained concept, respectively. The associated concept is added to E, and the retained concept is added to P. W represents W K and W V , W org Represents the weight of the original model and A parameter-efficient fine-tuning method, LoRA, is employed to guide the prediction noise of the eliminated concepts to the anchor concepts.
4. The method according to claim 3, characterized in that The parameter-efficient fine-tuning method LoRA is used to guide the prediction noise of the eliminated concept to the anchor concept, including: Input contains the prompt p of elimination concept c and prompts containing anchor concepts into the diffusion model and align the predicted noise to train the LoRA model, and during the training process i Add perturbations and alternately input the perturbation e i and original e i Serves as input to the diffusion model to ensure the elimination of specified elimination concepts and associated concepts.
5. The method according to claim 4, characterized in that The training LoRA model includes: The training objectives for odd steps are: The training objective for even-numbered steps is: Among them, z t is with The generated image corresponds to the intermediate noise state, p′ c is the associated concept obtained through noise perturbation mining, p″ c is the retained concept obtained by noise perturbation mining, ∈ θ and Represent the new U-Net and the original U-Net respectively.
6. The method according to claim 5, characterized in that The out-of-neighborhood concept regularization includes: sampling N points within a range greater than D1 and less than S2, and keeping the original positions of the sampling points unchanged. By only modifying the mapping relationship of related concepts within the range D1, the mapping relationship of irrelevant concepts outside the range D1 remains unchanged, thereby ensuring the generation performance of the diffusion model.
7. The method according to any one of claims 1 to 6, characterized in that The method is used to implement at least one of the following concept elimination: object elimination, celebrity elimination, unsafe content elimination, and artistic style elimination.
8. A semantic level concept elimination system based on domain concept mining, characterized by: include: The neighborhood related concept mining module is used to mine related concepts by adding random perturbations to the embeddings in the neighborhood space of the eliminated concepts; The concept elimination module is used to map the eliminated concepts and mined related concepts to the anchor concepts of the diffusion model, and achieve concept elimination by fine-tuning the diffusion model; The out-of-neighborhood concept regularization module is used to find and retain concepts that are irrelevant to the eliminated concepts through out-of-neighborhood concept regularization.
9. A computer device, characterized in that: The method comprises 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 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the method according to any one of claims 1 to 7 is implemented.