Confrontation sample generation method and device for checking reliability of recommendation system and medium
By introducing KL loss and pre-gradient guided momentum optimization strategy when generating adversarial samples, the concealment of adversarial samples is enhanced, and they are injected into the recommendation system for verification, which solves the problem in the existing technology that adversarial samples are easy to be detected, and improves the efficiency of adversarial samples. The prevention capability and reliability of the recommendation system.
Patent Information
- Application Number
- CN202410451734.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-16
- Publication Date
- 2024-08-30
AI Technical Summary
Existing technologies are prone to falling into local optima when generating adversarial samples, and fail to effectively consider the concealment of adversarial samples, making false users easy to detect and unable to effectively test the prevention capabilities of the recommendation system.
By introducing KL loss to constrain the spatial distribution distance between adversarial samples and real samples, combined with the pre-gradient guided momentum optimization strategy, adversarial samples are generated to enhance their concealment, and the optimized adversarial samples are injected into the target model for testing to improve the reliability of the recommendation system. .
It improves the transferability and concealment of adversarial samples, can more realistically test the reliability of the recommendation system, enhances the ability to prevent attacks, helps researchers deeply understand the potential weaknesses of the recommendation system, and provides a reference for security improvements.
Smart Images

Figure CN118568484A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of detecting and preventing attacks on the reliability of a recommendation system, and in particular to a method, device and medium for generating adversarial samples for testing the reliability of a recommendation system. Background Art
[0002] Recommendation systems are crucial in modern society. They recommend goods, services or content based on user behavior and preferences, especially in the fields of e-commerce, social media and online video services. These systems not only optimize user experience and facilitate purchasing decisions, but also create significant economic value for enterprises. However, the centrality of recommendation systems also makes them a target of malicious attacks. Some attackers aim to gain improper benefits for specific goods or services by manipulating recommended content. Such manipulation may harm the interests of users, who may make decisions based on misleading information, while reducing the trust and effectiveness of recommendation systems. By studying attack strategies against recommendation systems, researchers can gain a deeper understanding of the potential weaknesses and vulnerable links of recommendation systems, achieve attack-to-defense, and provide reference suggestions for security improvements of recommendation systems.
[0003] Recommendation systems usually restrict user access rights to protect their security and privacy, which prevents attackers from obtaining detailed information about the target recommendation system. However, attackers can use proxy models to generate adversarial samples (i.e., false user data) and inject them into the original dataset of the target recommendation system to disrupt the distribution of the target model recommendation system, increase the recommendation rate of the target item, and reduce the reliability of the recommendation system.
[0004] The current popular method is to generate fake users in the proxy model through gradient optimization to test the target recommendation system. However, the gradient tends to oscillate rapidly at the local optimum and cannot reach the global optimum, making it impossible for the generated fake users to achieve the expected recommendation system test effect.
[0005] In addition, when the current proxy model generates fake users, little attention is paid to the concealment of fake users, which makes it easy for fake users to be identified as abnormalities by the target recommendation system or adversarial sample detection method, and it is impossible to effectively test the prevention ability of the recommendation system and then formulate targeted measures. To solve the above problems, this patent conducts in-depth research on related issues and proposes an adversarial sample generation method for testing the reliability of the recommendation system. Summary of the invention
[0006] The purpose of the present invention is to provide a method, device and medium for generating adversarial samples for verifying the reliability of a recommendation system, using adversarial samples to verify the reliability of the recommendation system and improve the ability of the recommendation system to prevent attacks from attackers.
[0007] Embodiments of the present invention provide a method, device, and medium for generating adversarial samples for verifying the reliability of a recommendation system.
[0008] Aspect 1: A method for generating adversarial samples for testing the reliability of a recommendation system, comprising:
[0009] S1. When iteratively generating adversarial samples on the proxy model, KL loss is introduced to constrain the spatial distribution distance between adversarial samples and real samples, thereby improving the concealment of adversarial samples generated by the proxy model.
[0010] S2. By improving the concealment of adversarial samples, iteratively optimize the proxy model parameters to obtain the optimized proxy model;
[0011] S3, the optimized proxy model generates optimized adversarial samples based on the optimization strategy of pre-gradient guided momentum;
[0012] S4, injecting the optimized adversarial sample data into the real sample data set of the target model to form a new training data set, and testing the target model on the new training data set;
[0013] S5. Improve the reliability of the target model by examining changes in the user distribution of the target model recommendation system and the target model's recommendation of target items to ordinary users.
[0014] Optionally, when the proxy model iteratively generates adversarial samples, the process formula is:
[0015]
[0016]
[0017] Where X∈R n*I is the real sample scoring matrix, is the adversarial sample scoring matrix, n is the number of real samples, m is the number of adversarial samples; θ represents the parameters of the proxy model, W θ is the prediction of ordinary users when the proxy model adopts parameter θ, * After injecting real samples into adversarial samples, the proxy model is retrained to obtain a set of parameters; is the training objective function of the surrogate model, It is the proxy model using the trained parameters θ * The target adversarial function.
[0018] Optionally, when iteratively generating adversarial samples on the proxy model, KL loss is introduced, the formula is:
[0019]
[0020] Among them, X(u) , They respectively represent the spatial distribution of real samples and adversarial samples in the low-dimensional data space.
[0021] Optionally, in S2, the proxy model parameters are iteratively optimized, and the formula is:
[0022]
[0023] Among them, θ (l) is the proxy model parameter of the lth iteration, θ (l-1) is the proxy model parameter of the l-1th iteration, a is the learning rate, and is the training loss of the proxy model for real samples and adversarial samples under parameter θ, is the spatial distribution distance loss between real samples and adversarial samples.
[0024] Optionally, in S3, when generating optimized adversarial samples based on the optimization strategy of pre-gradient guided momentum, the iterative process formula is:
[0025]
[0026] θ=θ-g t (6)
[0027] where g t represents the cumulative gradient at the tth iteration, represents the gradient at the tth iteration, u is the decay factor, η is the learning rate, represents the partial derivative of J with respect to θ.
[0028] Optionally, when generating optimized adversarial samples based on the optimization strategy of pre-gradient guided momentum, the specific formula for iteration is:
[0029]
[0030] in, express The partial derivative of .
[0031] Optionally, an optimized adversarial sample is generated based on the optimization strategy of pre-gradient guided momentum, and the formula is:
[0032]
[0033]
[0034] Among them, Proj Λ is the projected gradient algorithm function.
[0035] A second aspect: An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method provided in the first aspect when executing the program.
[0036] A third aspect: A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, the steps of the method provided in the first aspect are implemented.
[0037] Beneficial effects of the present invention:
[0038] 1. The present invention proposes an adversarial sample generation method for testing the reliability of the recommendation system. To address the problem that the existing gradient-based adversarial sample generation falls into local optimality, the present invention can enhance the transferability of adversarial samples in the recommendation system by combining the pre-gradient guided momentum gradient optimization strategy and the KL divergence constraint fake user generation, and generate more imperceptible fake users, which can more realistically test the reliability of the recommendation system and improve the prevention capability of the recommendation system.
[0039] 2. The adversarial sample generation method of the present invention adopts a pre-gradient guided momentum gradient optimization strategy to generate adversarial samples, and uses a combination of the accumulated gradient direction and the gradient direction of the previous step on the proxy model to iteratively update the adversarial samples, thereby achieving high transferability of the adversarial samples and more comprehensively testing the reliability of the recommendation system.
[0040] 3. The KL divergence loss is introduced in the adversarial sample generation method of the present invention to minimize the distribution distance loss between the proxy model data and the real sample data. KL divergence loss is used to measure the similarity between two probability distributions. The closer the two probability distributions are, the smaller the KL divergence is. By introducing the KL loss constraint when the proxy model iteratively updates the adversarial sample, the distribution of the adversarial sample is close to the distribution of the real sample, thereby increasing the concealment of the adversarial sample.
[0041] 4. By studying adversarial sample attack strategies against recommendation systems, researchers can gain a deeper understanding of the potential weaknesses and vulnerable links of recommendation systems, use offense to promote defense, and provide reference suggestions for security improvements of recommendation systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 Schematic diagram of the process of generating adversarial samples of the present invention;
[0043] Figure 2 This is one of the schematic diagrams of the principle of the adversarial sample application recommendation system of the present invention;
[0044] Figure 3 This is one of the schematic diagrams of the principle of the adversarial sample application recommendation system of the present invention;
[0045] Figure 4 It is a schematic diagram of the structure of the electronic device of the present invention;
[0046] Figure 5 This is a screenshot of pseudo code for implementing the method of the present invention. DETAILED DESCRIPTION
[0047] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar symbols throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and cannot be understood as limiting the present invention.
[0048] Recommendation systems are of vital importance in modern society. Their central position also makes them the target of malicious attacks aimed at manipulating recommended content to gain improper benefits for specific goods or services; such manipulation may harm the interests of users, who may make decisions based on misleading information, while reducing the trust and effectiveness of the recommendation system.
[0049] In view of the above problems, the present invention provides an adversarial sample generation method for testing the reliability of a recommendation system. Figure 1 A flowchart of a method for generating adversarial samples for testing the reliability of a recommendation system provided by an embodiment of the present invention is provided. Figure 2 and Figure 3 This is a schematic diagram of the principle of the adversarial sample application recommendation system of the present invention. The method includes:
[0050] S1. When iteratively generating adversarial samples on the surrogate model, the KL (Kullback-Leibler loss) loss is introduced. The KL loss is used to constrain the spatial distribution distance between the adversarial samples (Fake User) and the real samples (Real User), thereby improving the concealment of the adversarial samples generated by the surrogate model.
[0051] When iteratively generating adversarial samples on the proxy model, the process formula can be:
[0052]
[0053]
[0054] Where X∈R n*I is the real sample scoring matrix, is the adversarial sample scoring matrix, n is the number of real samples, m is the number of adversarial samples; θ represents the parameters of the proxy model, W θ is the prediction of ordinary users (User) when the proxy model adopts parameter θ, θ *Represents the parameters of the target model; is the training objective function of the surrogate model, It is the objective function of the proxy model using the trained parameter θ*, that is, the attack objective function of the attacker (Attack).
[0055] The process of generating adversarial samples on the proxy model can be regarded as a two-level optimization problem, that is, the parameters of one optimization problem are restricted by the optimal solution of another optimization problem, and the two problems affect each other. Formula (1) is the objective function of the external optimization problem, and formula (2) is the objective function of the internal optimization problem. The internal objective function of formula (2) indicates that injecting adversarial sample data After that, the proxy model needs to be retrained to obtain the injected model optimization parameters θ * , and then optimize the external objective function of formula (1) under the proxy model optimization parameters.
[0056] KL divergence loss can be used to measure the similarity between two probability distributions. The closer the two probability distributions are, the smaller the KL divergence is. Therefore, we introduce KL loss in the field of recommendation system attacks to increase the concealment of adversarial samples in the iterative update process. The formula is:
[0057]
[0058] Where X (u) , They respectively represent the spatial distribution of real samples and adversarial samples in the low-dimensional data space. The essence is to map high-dimensional data to a low-dimensional latent space.
[0059] When updating the adversarial sample data on the proxy model each time, the distribution distance loss between the real sample and the adversarial sample is considered, so that the distribution of the generated adversarial sample in the latent space is consistent with the real sample, which improves the concealment of the adversarial sample and makes it difficult to be detected as an abnormal user by the target model recommendation system, which can better detect the reliability of the recommendation system.
[0060] S2. By improving the concealment of adversarial samples, iteratively optimize the proxy model parameters to obtain the optimized proxy model;
[0061] In the internal iteration, the training loss and KL loss are accumulated and calculated, and the internal parameters of the proxy model are updated iteratively. The formula is:
[0062]
[0063] Among them, θ (l) is the proxy model parameter of the lth iteration, θ (l-1) is the proxy model parameter of the l-1th iteration, a is the learning rate, and is the training loss of the proxy model for real samples and adversarial samples under parameter θ, is the spatial distribution distance loss between real samples and adversarial samples.
[0064] S3, the optimized proxy model generates optimized adversarial samples based on the optimization strategy of pre-gradient guided momentum;
[0065] When using gradient descent to optimize adversarial samples in a proxy model, problems such as too fast convergence speed, falling into a local optimum instead of a global optimum, or falling into a saddle point may occur. For this situation, the pre-gradient guided momentum iteration method can be used. The pre-gradient guided momentum iteration method is to update forward through the gradient of the previous iteration. At each iteration, the adversarial sample is iteratively updated by adding the previous gradient to the current data point to obtain the data point gradient accumulation. The pre-gradient function iteration process can be expressed as:
[0066]
[0067] θ=θ-g t (6)
[0068] where g t represents the cumulative gradient at the tth iteration, represents the gradient at the tth iteration, u is the decay factor, η is the learning rate, represents the partial derivative of J with respect to θ.
[0069] The pre-gradient guided momentum iteration method performs iterative updates under the guidance of previous gradient information, thereby achieving faster convergence and enhancing the transferability of adversarial samples.
[0070] The process of generating adversarial sample data on the proxy model using the pre-gradient guided momentum method is as follows:
[0071]
[0072] in, express The partial derivative of .
[0073] From formula (7), we can see that the pre-gradient guided momentum method consists of two parts when updating the gradient in each iteration: the first part considers the influence of the gradient of the previous step, and the second part considers the influence of the momentum of the previous iteration on the direction of the gradient update. When updating the proxy model data, the gradient is accumulated in the direction of the previous iteration. This accumulation can help find a more stable gradient direction, reduce the possibility of falling into a local optimum, and generate adversarial samples with better transferability.
[0074] The method of pre-gradient guided momentum is adopted. Compared with the Nesterov momentum method which considers the cumulative momentum effect of all past gradients when updating the t-step gradient, the previous gradient is more instructive for the update direction of the t-step in each iteration.
[0075] In the external iteration, the influence of the previous step gradient and the historical gradient of the previous iteration is considered to obtain the current gradient. The projected gradient algorithm can be used to iteratively update the adversarial sample data in the proxy model. In each iteration, the current adversarial sample data is compared with the adversarial sample data with the best attack performance, and the adversarial sample data with the best attack performance is saved. The formula is:
[0076]
[0077]
[0078] Among them, Proj Λ It is the projection gradient algorithm formula.
[0079] After iteratively updating the adversarial sample data on the proxy model t times, optimized adversarial sample data with high transferability and concealment can be obtained.
[0080] S4, inject the optimized adversarial sample data into the real sample data set of the target model to form a new training data set (Training Set), and test the target model on the new training data set;
[0081] The optimized adversarial samples generated by the proxy model are injected into the real sample data set of the target model recommendation system to retest the target model recommendation system. When the target model is trained on a normal real sample data set, it will provide users with a list of items of interest. However, when the target model is retrained in a new training data set after the optimized adversarial samples are injected, the target model recommendation system distribution and the target item recommendation of the target model to ordinary users are obtained. If the user's recommendation result changes, it means that in the recommendation system, the recommendation rate of the target item that the attacker wants to recommend has increased significantly, indicating that the recommendation system needs to be improved in a targeted manner.
[0082] S5. Check the changes in the results of the target model recommendation system and the target model's recommendation of target items to ordinary users, and improve the reliability of the target model.
[0083] The pseudo code of the method of the present invention can be used as follows Figure 5 The code shown:
[0084] Input: real user matrix X; learning rate α; decay factor μ; maximum number of iterations L and T of inner and outer targets;
[0085] Output: The best adversarial example
[0086] First, perform the initialization operation to obtain the adversarial sample of the 0th iteration And the adversarial sample with the best attack effect at present In the external iteration process of the T layer, the internal iteration of the L layer is first performed to optimize the internal function target to obtain the optimal proxy model parameter θ (Formula 4), and then the current adversarial loss and adversarial sample gradient are calculated, and the adversarial sample of the tth step is updated through the projection threshold formula Through the adversarial sample with the current best attack effect Compare and update. Finally, return the generated adversarial sample
[0087] The present invention also provides an electronic device, Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 4 As shown, the electronic device may include: a processor, a communications interface, a memory, and a communications bus, wherein the processor, the communications interface, and the memory communicate with each other via the communications bus. The processor may call the logic instructions in the memory to execute the following method:
[0088] S1. When iteratively generating adversarial samples on the proxy model, KL loss is introduced to constrain the spatial distribution distance between adversarial samples and real samples, thereby improving the concealment of adversarial samples generated by the proxy model.
[0089] S2. By improving the concealment of adversarial samples, iteratively optimize the proxy model parameters to obtain the optimized proxy model;
[0090] S3, the optimized proxy model generates optimized adversarial samples based on the optimization strategy of pre-gradient guided momentum;
[0091] S4, injecting the optimized adversarial sample data into the real sample data set of the target model to form a new training data set, and testing the target model on the new training data set;
[0092] S5. Improve the reliability of the target model by examining changes in the user distribution of the target model recommendation system and the target model's recommendation of target items to ordinary users.
[0093] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0094] An embodiment of the present invention further provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method provided in each of the above embodiments is implemented, for example, including:
[0095] S1. When iteratively generating adversarial samples on the proxy model, KL loss is introduced to constrain the spatial distribution distance between adversarial samples and real samples, thereby improving the concealment of adversarial samples generated by the proxy model.
[0096] S2. By improving the concealment of adversarial samples, iteratively optimize the proxy model parameters to obtain the optimized proxy model;
[0097] S3, the optimized proxy model generates optimized adversarial samples based on the optimization strategy of pre-gradient guided momentum;
[0098] S4, injecting the optimized adversarial sample data into the real sample data set of the target model to form a new training data set, and testing the target model on the new training data set;
[0099] S5. Improve the reliability of the target model by examining changes in the user distribution of the target model recommendation system and the target model's recommendation of target items to ordinary users.
[0100] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0101] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating adversarial samples to test the reliability of recommendation systems. It is characterized in that include: S1. When iteratively generating adversarial samples on the proxy model, KL loss is introduced. The KL loss is used to constrain the spatial distribution distance between adversarial samples and real samples, thereby improving the concealment of adversarial samples generated by the proxy model. S2. By improving the concealment of adversarial samples, iteratively optimize the proxy model parameters to obtain the optimized proxy model; S3, the optimized proxy model generates optimized adversarial samples based on the optimization strategy of pre-gradient guided momentum; S4, injecting the optimized adversarial sample data into the real sample data set of the target model to form a new training data set, and testing the target model on the new training data set; S5. Improve the reliability of the target model by examining changes in the user distribution of the target model recommendation system and the target model's recommendation of target items to ordinary users.
2. According to claim 1, a method for generating adversarial samples for testing the reliability of a recommendation system, It is characterized in that When the proxy model iteratively generates adversarial samples, the process formula is: Where X∈R n*I is the real sample scoring matrix, is the adversarial sample scoring matrix, n is the number of real samples, m is the number of adversarial samples; θ represents the parameters of the proxy model, W θ is the prediction of ordinary users when the proxy model adopts parameter θ, * After injecting real samples into adversarial samples, the proxy model is retrained to obtain a set of parameters; is the training objective function of the surrogate model, It is the proxy model using the trained parameters θ * The objective function of .
3. According to claim 2, a method for generating adversarial samples for testing the reliability of a recommendation system, It is characterized in that When iteratively generating adversarial samples on the proxy model, KL loss is introduced, and the formula is: Where X (u) , They respectively represent the spatial distribution of real samples and adversarial samples in the low-dimensional data space.
4. The method for generating adversarial samples for testing the reliability of a recommendation system according to claim 1, It is characterized in that In S2, the proxy model parameters are iteratively optimized, and the formula is: Among them, θ (l) is the proxy model parameter of the lth iteration, θ (l-1) is the proxy model parameter of the l-1th iteration, a is the learning rate, and is the training loss of the proxy model for real samples and adversarial samples under parameter θ, is the spatial distribution distance loss between real samples and adversarial samples.
5. According to claim 1, a method for generating adversarial samples for testing the reliability of a recommendation system, It is characterized in that In S3, when the optimized adversarial sample is generated based on the optimization strategy of pre-gradient guided momentum, the iterative process formula is: θ=θ-g t (6) where g t represents the cumulative gradient at the tth iteration, represents the gradient at the tth iteration, u is the decay factor, η is the learning rate, represents the partial derivative of J with respect to θ.
6. The method for generating adversarial samples for testing the reliability of a recommendation system according to claim 5, It is characterized in that When the optimization strategy based on pre-gradient guided momentum generates optimized adversarial samples, the specific iterative formula is: in, express The partial derivative of .
7. The method for generating adversarial samples for testing the reliability of a recommendation system according to claim 6, It is characterized in that The optimized adversarial sample is generated based on the optimization strategy of pre-gradient guided momentum. The formula is: Among them, Proj Λ is the projected gradient algorithm function.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the steps of a method for generating adversarial samples for verifying the reliability of a recommendation system as claimed in any one of claims 1 to 7 are implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of a method for generating adversarial samples for verifying the reliability of a recommendation system as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
High-robustness privacy protection recommendation method based on adversarial learning
CN113918814A
Poison attack method in recommendation system based on generative adversarial network
CN116108432A
Industrial control malicious code identification method based on generative adversarial network data enhancement
CN116611060A
Graph neural network model black box attack method and device
CN117592550A
Model fairness evaluation methods and apparatus
WO2023197927A1
