Visual question and answer black box antagonistic attack method based on probability selection, electronic equipment and storage medium

Through the black-box adversarial attack method of visual question and answer based on probability selection, using the gradient information of the pre-trained model and the Metropolis-Hastings algorithm, highly offensive and covert adversarial text pairs are generated, solving the visual problem The adversarial attack problem of multi-modal tasks in the question and answer model improves the attack effect and strategy diversity.

CN118606935APending Publication Date: 2024-09-06SHANGHAI UNIV
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202410762095.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-09-06

AI Technical Summary

Technical Problem

There are few studies on the adversarial robustness of visual question answering models in the existing technology, especially the lack of effective exploration of black-box adversarial attacks for multi-modal tasks, which makes it difficult to select attack strategies and achieve concealed and efficient effects.

Method used

A visual question answering black box adversarial attack method based on probability selection is used to update the adversarial image-text pairs by calculating the gradient information of the pre-trained model, and use the Metropolis-Hastings algorithm to construct the acceptance probability and select the high acceptance Probabilistic attack strategy to generate aggressive and covert adversarial text pairs.

Benefits of technology

It improves the adversarial attack effect of the visual question and answer model, generates more destructive adversarial samples, avoids the attack method getting stuck on the local optimal value, enhances the diversity and adaptability of the attack strategy, and achieves an effective effect on the visual question and answer model. attack.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118606935A
    Figure CN118606935A
Patent Text Reader

Abstract

The invention belongs to the technical field of information, and particularly discloses a visual question and answer black box antagonism attack method based on probability selection, which comprises the following steps of: (1) selecting an attack strategy with high acceptance probability based on a current image text state; (2) gradient information of a corresponding pre-training model is calculated according to an attack method, disturbance of a corresponding mode is updated, and an antagonistic image text pair of the round is output; (3) sending the adversarial image text pair of the current round into a visual question and answer model, and judging whether the attack is successful or not; and if the iteration succeeds or reaches the maximum number of iterations, outputting the antagonistic image text of the current round, and if the iteration fails, circulating the steps (1)-(2). The method uses the pre-training model to generate a high-aggressiveness and hidden antagonistic text pair, and has a good attack effect on the visual question and answer model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of information technology, and in particular relates to a visual question answering black box adversarial attack method based on probability selection, an electronic device and a storage medium. Background Art

[0002] Vision and language are the most important forms of human communication. Visual question answering is an important multimodal task that combines vision and language. Visual question answering systems answer questions by exploring the content of visual images and text, which requires a deep understanding of both visual images and natural language. The difference between the computer's understanding of images and questions leads to a semantic gap between the two modalities, which makes it impossible to associate the two modalities well, resulting in a decline in the performance of visual question answering models.

[0003] Visual question answering is a cross-domain research task that combines computer vision and natural language processing. In recent years, the requirements for its adversarial robustness have gradually increased. However, current adversarial attack research mainly focuses on single image models and text models, and there is still a lack of comprehensive exploration of black-box adversarial robustness for multimodal tasks, especially for the specific task of visual question answering. In particular, for the sampling problem of image, text, and multimodal attacks, how to choose the appropriate attack strategy to achieve a covert and efficient effect. Summary of the invention

[0004] In view of the problems and shortcomings in the prior art, the purpose of the present invention is to provide a visual question answering black box adversarial attack method and system based on probability selection, an electronic device and a storage medium.

[0005] To achieve the purpose of the invention, the technical solution adopted by the present invention is as follows:

[0006] A first aspect of the present invention provides a black box adversarial attack method for visual question answering based on probability selection, comprising the following steps:

[0007] (1) Select an attack strategy with a high acceptance probability based on the current image text state;

[0008] (2) Calculate the gradient information of the corresponding pre-trained model according to the attack method, update the perturbation of the corresponding modality, and output the adversarial image-text pair of this round;

[0009] (3) The adversarial image-text pair of the current round is sent to the visual question answering model to determine whether the attack is successful; if successful or the maximum number of iterations is reached, the adversarial image-text of the current round is output; if unsuccessful, steps (1)-(2) are repeated.

[0010] Furthermore, the step of selecting an attack strategy with a high acceptance probability based on the current image text state in step (1) is:

[0011] S1. Input clean images and text into the pre-trained model;

[0012] S2. Construct adversarial distribution and acceptance probability: The probability distribution D of the correct prediction is obtained through the softmax function; the attack method is adopted, and the generated adversarial image and text are also sent to the pre-trained model, and the probability distribution D' of the current attack method is obtained through the softmax function; then, the similarity between the clean image text and the adversarial image text and the KL divergence difference of the probability distribution are calculated, and the proposed distribution is obtained by combining them, and then the acceptance probability of the attack method is obtained; traverse the three attack methods, and select the attack method with the highest acceptance probability as the final attack method.

[0013] Furthermore, the specific contents of constructing the adversarial distribution and acceptance probability are as follows:

[0014] In the pre-trained model, the probability distribution D of the current answer can be obtained through the softmax function; e∈{0,1,2}, p is obtained from the attack distribution image 、p text and p multi They represent single image attack (0), single text attack (1), and multimodal attack (2), respectively, where p image +p text +p multi =1; image text pair x = {I, T} has the following formulas to define the three attack methods:

[0015]

[0016] Therefore, through the Bayesian formula, the proposed distribution state from round t to round t+1 can be derived as shown below:

[0017] state(x'|x)=p(o,e|x)=p(e|x)p(o|e,x)

[0018] At the same time, considering that adversarial examples should be hidden from input images and texts, for image-text pairs x = {I, T}, we construct an adversarial target distribution π(x):x→(0,1), use KL divergence to measure the performance degradation of the model when it is attacked, and impose severe penalties on changes in image and text semantics; by using the hyperparameter λ to combine the attack performance R and the similarity sim(x,x') to construct the adversarial distribution, the distribution formula is defined as follows:

[0019]

[0020] R=KL(D(x),D(x'))

[0021]

[0022]

[0023] Among them, C is the constant that normalizes π(x'), D(x) is the answer distribution, and USE(T,T') is the semantic similarity of the sentence.

[0024] The selection of states is constructed by treating the constructed adversarial distribution and proposal distribution state as the target distribution and proposal distribution of the Metropolis-Hastings algorithm respectively; in each iteration, a trial state x is proposed using state t+1 And calculate the acceptance probability α(x t+1 |x t ), the acceptance probability can be defined as follows:

[0025]

[0026] Traverse the three attack methods and select the attack method with the highest acceptance probability as the attack method for this round;

[0027] The Metropolis–Hastings algorithm simulates the target distribution by using a proposal function to provide a trial state and then accept or reject the state according to a customized acceptance probability; the proposal function t In the case of a test state x t+1 , and according to the acceptance probability α(x t+1 |x t ) decides whether to accept the status.

[0028] Furthermore, the attack method is to attack the image alone, to attack the text alone, or to attack in a multi-modal manner.

[0029] Furthermore, the method of attacking the image separately is as follows: the image and text input in the current round are sent to the pre-trained model, and the loss function L about the image is calculated. image , and get the gradient; send the gradient to the sign function for normalization Get the direction of noise optimization and After multiplying with the attack step length ε, the result is added to the original image to form an adversarial image. The adversarial image is modified using the cropping function to satisfy the concealment constraint of the adversarial image. The new image and unmodified text are output.

[0030] Among them, the similarity loss L between two types of images is defined image as follows:

[0031]

[0032] in, is the jth feature vector obtained by the i-th layer of the image encoder; is the t-th feature vector obtained by the k-th layer of the Transformer encoder; cos() is the cosine similarity, is the number of image feature embeddings generated in the i-th block; M i is the number of blocks in the image encoder; M k is the number of blocks in the Transformer encoder.

[0033] Furthermore, the method of attacking the text separately is as follows: the image and text input in the current round are sent to the pre-trained model, and the loss function L about the text is calculated. text , and get the gradient; send the gradient to the sign function for normalization Get the direction of noise optimization and Multiply it by the attack step length ε and add it to the embedding of the most important word to get the ideal adversarial text embedding. Then, determine the importance of the words in the text and mask the most important words; reconstruct the text with the mask to get a series of candidate words; calculate the embedding for each candidate word and compare the similarity with the adversarial text embedding, select the closest one and send it to the decoder to get a new word; restore the new sentence with the word and the text with the mask; output the unmodified image and the new text;

[0034] Among them, the specific formula for defining the text part loss is as follows:

[0035] L text =L1(F(I,T),y)+βL2(F(I,T),y)

[0036] Among them, β is the preset hyperparameter, L text is the loss function of text; L1 is the cross entropy loss of image-text pairs in the pre-trained model; L2 is the cross entropy loss of the input reconstruction task.

[0037] Furthermore, the multimodal attack method includes simultaneous attack on images and texts, specifically: sending the image and text input in the current round to the pre-trained model, and calculating the loss function L about the image respectively. image And the loss function L about the text text ; and update the perturbation according to the gradient-based update method of the image and text; output new images and new text.

[0038] Furthermore, the criterion for judging whether the attack is successful is as follows: the image and text content output after the perturbation update are sent to the black box visual question answering model, and the black box answer is output; then, whether the black box answer is the true answer is judged; if the black box answer is not the correct answer, it means that the attack has been successful; if the black box answer is the correct answer, it means that this round of attack has failed; if the attack is successful or the preset maximum number of attack rounds has been reached, proceed to the next step; if this round of attack fails and the preset maximum number of attack rounds has not been reached, the current image and text are used as the input for the next round of iteration.

[0039] A second aspect of the present invention provides an electronic device, including a memory and a processor, wherein a computer program is stored on the memory, and when the processor executes the computer program, any step of the visual question answering black box adversarial attack method based on probability selection provided in the first aspect is implemented.

[0040] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a computer processor, implements any step in the visual question answering black-box adversarial attack method based on probability selection provided in the first aspect.

[0041] The present invention can make full use of the structural characteristics of the model to generate more destructive adversarial samples by focusing on the gradient information of the image block-by-block similarity loss and amplifying the similarity between each module in the pre-trained model for the features of clean images and adversarial images. For text information in discrete space, the semantics and readability of the text can be retained as much as possible by optimizing its word embedding. In addition, the Metropolis-Hastings algorithm is used to construct the acceptance probability to avoid the attack method being stuck at the local optimal value, and to encourage the generation of attack methods that are closer to the global optimal value, thereby improving the diversity and adaptability of the overall attack strategy. This method uses a pre-trained model to generate highly aggressive and hidden adversarial text pairs, which has a good attack effect on the visual question-answering model. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0044] The embodiments of the present invention are further described in detail below with reference to the accompanying drawings.

[0045] Example 1

[0046] A black-box adversarial attack method for visual question answering based on probability selection, comprising the following steps:

[0047] (1) Select an attack strategy with a high acceptance probability based on the current image text state;

[0048] (2) Calculate the gradient information of the corresponding pre-trained model according to the attack method, update the perturbation of the corresponding modality, and output the adversarial image-text pair of this round;

[0049] (3) The adversarial image-text pair of the current round is sent to the visual question answering model to determine whether the attack is successful; if successful or the maximum number of iterations is reached, the adversarial image-text of the current round is output; if unsuccessful, steps (1)-(2) are repeated.

[0050] In this embodiment, the VQAv2 dataset is used as the dataset for the visual question answering task, the CLIP model is used as the pre-trained model, and the model fine-tuned by CLIP to the VQAv2 dataset is used as the visual question answering model for the target attack.

[0051] Specifically, a research method for black-box adversarial attacks on visual question answering based on probability selection is proposed. The specific steps are as follows:

[0052] S1. Input clean images and text:

[0053] Given an image-text pair (I, T), for visual question answering adversarial attack, the goal is to generate an adversarial image-text pair through the generation module G, and Y is the correct answer set. The specific formula of the attack is defined as follows:

[0054]

[0055] in, is the adversarial image-text pair; σ i is the hyperparameter constraining the image quality; σ s In order to constrain the hyperparameters of text quality, the formula for the image concealment constraint is defined as follows:

[0056]

[0057] The hidden constraint formula for the image is defined as follows:

[0058]

[0059] S2. Construct adversarial distribution and acceptance probability: Send clean images and texts into the pre-trained model, and use the softmax function to obtain the probability distribution D of the correct prediction. Adopt the attack method, and the generated adversarial images and texts are also sent to the pre-trained model, and the probability distribution D' of the current attack method is obtained through the softmax function. Then, calculate the similarity between the clean image text and the adversarial image text, and the KL divergence difference of the probability distribution, combine to obtain the proposed distribution, and then obtain the acceptance probability of the attack method. Traverse the three attack methods, select the one with the highest acceptance probability as the final attack method, and select the corresponding module S3, S4 or S5.

[0060] In the pre-trained model, the gradient information of the block-by-block feature similarity loss of the image and the gradient information of the text embedding are obtained for single-modal attack, and the two are fused for multi-modal attack. At the same time, a method of selecting attacks with acceptance probability is constructed to attack the downstream visual question-answering task. First, the gradient information of the block-by-block similarity loss of the image is introduced to attack the image alone. By expanding the similarity between the clean image and the adversarial image features between each module in the pre-trained model, the specific features of the model structure are fully utilized. For discrete original text, the information of the gradient is applied to the word embedding for separate text perturbation optimization. And the perturbation updates of the two are combined to form a multi-modal perturbation. Subsequently, the Metropolis-Hastings algorithm is used to construct the acceptance probability and effectively select the three attacks. By using the acceptance probability, the attack method can be prevented from being stuck at the local optimal value, and an attack method closer to the global optimal value can be generated.

[0061] The Metropolis-Hastings algorithm simulates the target distribution by using a proposal function to provide a trial state and then accept or reject the state based on a customized acceptance probability. Through this probabilistic mechanism, the proposal function will t In the case of a test state x t+1 , and according to the acceptance probability α(x t+1 |x t ) decides whether to accept the status.

[0062] First, the probability distribution D of the current answer can be obtained through the softmax function in the pre-trained model. From the attack distribution, e∈{0,1,2}, p image 、p text and p multi They represent single image attack (0), single text attack (1), and multimodal attack (2), respectively, where p image +p text +p multi= 1. The image-text pair x = {I, T} is defined by the following formulas for the three attack methods:

[0063]

[0064] Therefore, through the Bayesian formula, the proposed distribution state from round t to round t+1 can be derived as shown below:

[0065] state(x'|x)=p(o,e|x)=p(e|x)p(o|e,x)

[0066] At the same time, adversarial examples should be taken into account together with the concealment of the input image and text. Therefore, for the image-text pair x = {I, T}, an adversarial target distribution π(x): x→(0,1) is constructed, and the KL divergence is used to measure the performance degradation of the model when it is attacked, and severe penalties are imposed on the changes in the semantics of the image and text. Specifically, the adversarial distribution is constructed by combining the attack performance R and the similarity sim(x, x') using the hyperparameter λ. The distribution formula is defined as follows:

[0067]

[0068] R=KL(D(x),D(x'))

[0069]

[0070]

[0071] Among them, C is the constant that normalizes π(x'), D(x) is the answer distribution, and USE(T,T') is the semantic similarity of the sentence.

[0072] The selection of states is constructed by treating the constructed adversarial distribution and proposal distribution state as the target distribution and proposal distribution of the Metropolis-Hastings algorithm, respectively. In each iteration, a trial state x is proposed using state t+1 And calculate the acceptance probability α(x t+1 |x t ). Therefore, the acceptance probability can be defined as follows:

[0073]

[0074] Traverse the three attack methods and select the attack method with the highest acceptance probability as the attack method for this round.

[0075] S3. When choosing to attack the image alone, the image and text input in the current round are fed into the pre-trained model F to calculate the loss function L about the image image , and get the gradient. Send the gradient to the sign function for normalization Get the direction of noise optimization and After multiplying with the attack step length ε, the adversarial image is added to the original image. In order to meet the concealment constraint of the adversarial image, the adversarial image is modified using the cropping function. The new image and the unmodified text are output.

[0076] Separate attacks on images are aimed at generating feature differences between clean and adversarial inputs. If the feature representations learned by the pre-trained model F from the clean image I and the adversarial input I' are significantly different, this perturbation may be transferred to the fine-tuned model to change the predictions of the downstream task visual question answering. Image features can be obtained from the image encoder and the Transformer encoder (an encoder of a deep learning model based on a self-attention mechanism), and can even be obtained from different layers or blocks. This approach makes full use of the structure of the image encoder and the multimodal encoder of the pre-trained model to guide the optimization direction of image noise. Define the similarity loss L between the two types of images image as follows:

[0077]

[0078] in, is the jth feature vector obtained by the i-th layer of the image encoder; is the t-th feature vector obtained by the k-th layer of the Transformer encoder; cos() is the cosine similarity, is the number of image feature embeddings generated in the i-th block; M i is the number of blocks in the image encoder; M k is the number of blocks in the Transformer encoder.

[0079] S4. When choosing to attack text alone, the image and text input in the current round are fed into the pre-trained model F, and the loss function L about the text is calculated text , and get the gradient. Send the gradient to the sign function for normalization Get the direction of noise optimization and Multiply it by the attack step length ε and add it to the embedding of the most important word to get the ideal adversarial text embedding. Then, determine the importance of the words in the text and perform a mask on the most important words. Reconstruct the text with [MASK] to get a series of candidate words. Calculate the embedding for each candidate word and compare the similarity with the adversarial text embedding. Select the closest one and send it to the decoder to get a new word. Restore the new sentence with the word and the text with [MASK]. Output the unmodified image and the new text.

[0080] The attack on text is mainly to use gradient information in the text embedding space to perform a more aggressive text replacement attack. The image and text are sent to the pre-trained model to obtain the gradient information, and the gradient information is added to the embedding of the original word to obtain the ideal adversarial embedding. Important and meaningful words are selected in the text for masking, and the word is reconstructed using the MLM head to obtain the embedding of the current candidate word. The embedding of each candidate word is compared with the adversarial embedding for similarity, and the most similar embedding is selected and sent to the decoder to obtain a new word. Thus, the adversarial text is obtained by combining with the masked text.

[0081] For the input image I and text T of the single text attack, the loss L of the text part text It consists of two parts, namely the cross entropy loss L1 for image-text pairs in the pre-trained model and the cross entropy loss L2 for the input reconstruction task. The specific formula for defining the text part loss is as follows:

[0082] L text =L1(F(I,T),y)+βL2(F(I,T),y)

[0083] Among them, β is the preset hyperparameter, L text is the loss function of text; L1 is the cross entropy loss of image-text pairs in the pre-trained model; L2 is the cross entropy loss of the input reconstruction task.

[0084] S5. For multi-modal attacks, that is, when images and texts are attacked simultaneously, the above two attack methods are combined to perform perturbation updates on both the image and the text.

[0085] The image and text input in the current round are fed into the pre-trained model F, and the loss function L about the image is calculated respectively. image And the loss function L about the text text The perturbation is updated according to the gradient-based update method for the image and text in S3 and S4, and a new image and new text are output.

[0086] S6. Obtain the image and text content output by S2, S3 or S4, send them to the black box visual question answering model, and output the black box answer. Next, determine whether the black box answer is the true answer. If the black box answer is not the correct answer, it means that the attack has been successful; if the black box answer is the correct answer, it means that this round of attack has failed. If the attack is successful or the preset maximum attack rounds have been reached, proceed to step S7; if the current round of attack fails and the preset maximum attack rounds have not been reached, the current image and text are used as the input for the next round of iteration, and the process of S2-S6 is repeated.

[0087] S7. Output the resulting adversarial image and text.

[0088] After completing the current attack generation task in the pre-trained model, the model can obtain adversarial sample pairs for each pair of clean images and questions to conduct adversarial attacks on the visual question answering model.

[0089] This method can fully utilize the structural features of the model to generate more destructive adversarial samples by focusing on the gradient information of the image block-by-block similarity loss and amplifying the similarity between each module in the pre-trained model for the features of clean images and adversarial images. For text information in discrete space, the semantics and readability of the text can be preserved as much as possible by optimizing its word embedding. In addition, the Metropolis-Hastings algorithm is used to construct the acceptance probability to avoid the attack method being stuck at the local optimal value and to encourage the generation of attack methods that are closer to the global optimal value, thereby improving the diversity and adaptability of the overall attack strategy. This method uses a pre-trained model to generate highly aggressive and hidden adversarial text pairs, which has a good attack effect on the visual question answering model.

[0090] Example 2

[0091] An electronic device includes a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, any step in the visual question answering black box adversarial attack method based on probability selection as described in Example 1 is implemented.

[0092] Further, the visual question answering black box adversarial attack process based on probability selection described in Example 1 can be implemented as a computer software program. For example, this embodiment includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program code for executing the method. In such an embodiment, the computer program can be downloaded and installed from a network, and / or installed from a removable medium. When the computer program is executed by a processor, the above functions defined in the method of the present application are executed.

[0093] Example 3

[0094] A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, any step of a black-box adversarial attack method for visual question answering based on probability selection as described in Example 1 is implemented.

[0095] The computer-readable medium described in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0096] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0097] The above embodiments are specific implementation methods of the present invention, but the implementation methods of the present invention are not limited to the above embodiments. Any other combination, change, modification, substitution and simplification that does not exceed the design concept of the present invention shall fall within the protection scope of the present invention.

Claims

1. A black-box adversarial attack method for visual question answering based on probability selection, characterized by: The following steps are involved: (1) Select an attack strategy with a high acceptance probability based on the current image and text status; (2) Calculate the gradient information of the corresponding pre-trained model according to the attack method, update the perturbation of the corresponding modality, and output the adversarial image-text pair of this round; (3) The adversarial image-text pair of the current round is sent to the visual question answering model to determine whether the attack is successful; if successful or the maximum number of iterations is reached, the adversarial image-text of the current round is output; if failed, steps (1)-(2) are repeated.

2. The black-box adversarial attack method for visual question answering based on probability selection according to claim 1 is characterized in that: The steps of selecting an attack strategy with a high acceptance probability based on the current image text state in step (1) are: S1. Input clean images and text into the pre-trained model; S2. Constructing adversarial distribution and acceptance probability: The softmax function is used to obtain the probability distribution D of the correct prediction. The generated adversarial image and text are also fed into the pre-trained model using the attack method, and the softmax function is used to obtain the probability distribution D' of the current attack method. Then, the similarity between the clean image text and the adversarial image text and the KL divergence difference of the probability distribution are calculated, and the proposed distribution is combined to obtain the acceptance probability of the attack method. The three attack methods are traversed and the attack method with the highest acceptance probability is selected as the final attack method.

3. The black-box adversarial attack method for visual question answering based on probability selection according to claim 2 is characterized in that: The specific contents of constructing the adversarial distribution and acceptance probability are as follows: In the pre-trained model, the probability distribution D of the current answer can be obtained through the softmax function; from the attack distribution, e∈{0,1,2} is obtained, where pimage, ptext and pmulti represent single image attack (0), single text attack (1), and multimodal attack (2), respectively, where pimage+ptext+pmulti=1; the image-text pair x={I,T} is defined by the following formulas for the three attack methods: Therefore, through the Bayesian formula, the proposed distribution state from round t to round t+1 can be derived as shown below: state(x′|x)=p(o,e|x)=p(e|x)p(oe,x) At the same time, considering the invisibility of adversarial examples with the input image and text, for the image-text pair x = {I, T}, we construct an adversarial target distribution π(x):x→(0,1). We use the KL divergence to measure the performance degradation of the model when it is attacked, and impose severe penalties on changes in the semantics of the image and text. We use the hyperparameter λ to combine the attack performance R and the similarity sim(x,x') to construct the adversarial distribution. The distribution formula is defined as follows: R=KL(D(x),D(x′)) Where C is a constant that normalizes π(x'), D(x) is the answer distribution, and USE(T,T') is the semantic similarity of the sentence. The state selection is constructed by treating the constructed adversarial distribution and proposal distribution state as the target distribution and proposal distribution of the Metropolis-Hastings algorithm respectively; in each iteration, a trial state x is proposed using state t+1 And calculate the acceptance probability α(x t+1 |x t ), the acceptance probability can be defined as follows: Traverse the three attack methods and select the attack method with the highest acceptance probability as the attack method for this round; The Metropolis-Hastings algorithm simulates the target distribution by using a proposal function to provide a trial state and then accept or reject the state according to a customized acceptance probability; the proposal function t In the case of a trial state x t+1 , and according to the acceptance probability α(x t+1 |x t ) decides whether to accept the status.

4. The black-box adversarial attack method for visual question answering based on probability selection according to claim 1 or 3, characterized in that: The attack method includes attacking images alone, attacking text alone, or attacking in multiple modes.

5. The black-box adversarial attack method for visual question answering based on probability selection according to claim 4 is characterized in that: The method of attacking the image separately is as follows: the image and text input in the current round are fed into the pre-trained model, and the loss function L about the image is calculated. image , and get the gradient; send the gradient into the sign function for normalization Get the direction of noise optimization and Multiply the attack step length ε and add it to the original image to form an adversarial image. Use the cropping function to modify the adversarial image to meet the concealment constraint of the adversarial image; output the new image and unmodified text; Among them, the similarity loss L between two types of images is defined as image as follows: in, is the jth feature vector obtained by the i-th layer of the image encoder; is the t-th feature vector obtained from the k-th layer of the Transformer encoder; cos() is the cosine similarity, is the number of image feature embeddings generated in the i-th block; M i is the number of blocks in the image encoder; M k is the number of blocks in the Transformer encoder.

6. The black-box adversarial attack method for visual question answering based on probability selection according to claim 5 is characterized in that: The method of attacking text separately is as follows: the image and text input in the current round are fed into the pre-trained model, and the loss function L about the text is calculated. text , and get the gradient; send the gradient into the sign function for normalization Get the direction of noise optimization and Multiply it by the attack step size ε and add it to the embedding of the most important words to get the ideal adversarial text embedding. Then, the importance of the words in the text is determined and the most important words are masked. Reconstruct the masked text to obtain a series of candidate words; calculate the embedding of each candidate word and compare its similarity with the adversarial text embedding, select the closest one and feed it into the decoder to obtain a new word; restore the new sentence by combining the word with the masked text; output the unmodified image and the new text; Among them, the specific formula for defining the text part loss is as follows: L text =L1(F(I,T),y)+βL2(F(1,T),y) Among them, β is the preset hyperparameter, L text is the loss function of text; L1 is the cross entropy loss of image-text pairs in the pre-training model; L2 is the cross entropy loss of the input reconstruction task.

7. The black-box adversarial attack method for visual question answering based on probability selection according to claim 6 is characterized in that: The multimodal attack method includes simultaneous attacks on images and texts, specifically: the image and text input in the current round are fed into the pre-trained model, and the loss function L about the image is calculated respectively. image And the loss function L about text text ; and update the perturbation according to the gradient-based update method of the image and text; output the new image and new text.

8. The black-box adversarial attack method for visual question answering based on probability selection according to claim 1 is characterized in that: The criterion for judging whether the attack is successful is as follows: the image and text content output after the perturbation update are fed into the black box visual question answering model, and the black box answer is output; Then determine whether the black box answer is the true answer; If the black box answer is not the correct answer, the attack is successful; If the black box answer is the correct answer, it means that this round of attack fails; If the attack is successful or the preset maximum number of attack rounds has been reached, proceed to the next step; If the current attack fails and the preset maximum number of attack rounds is not reached, the current image and text will be used as input for the next iteration.

9. An electronic device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the processor executes the computer program, any step of the black-box adversarial attack method for visual question answering based on probability selection is implemented as claimed in any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a computer processor, implements any step of the black-box adversarial attack method for visual question answering based on probability selection as claimed in any one of claims 1 to 8.

Citation Information

Cited By

  • Data generation task processing method and model training method applying preference data

    CN119338015A

  • Multi-modal general anti-disturbance method for visual language model

    CN119397282A

  • Multi-mode black box attack method and device for large visual language model

    CN119415728A

  • Black box model inversion attack method and device for text classification model

    CN119783761A