A text adversarial attack method based on virtual position guided VPG-PSO algorithm

By introducing virtual position-guided VPG-PSO algorithm in text adversarial attacks and adjusting the search strategy in stages, the problem of early maturity convergence and poor diversity influence of standard PSO algorithms is solved, and a higher success rate and robustness of text adversarial attacks are achieved. sex.

CN117992610BActive Publication Date: 2024-11-22JIANGNAN UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410150443.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-02-02
Publication Date
2024-11-22
Estimated Expiration
2044-02-02

AI Technical Summary

Technical Problem

The standard PSO algorithm has problems of early maturity convergence and unbalanced exploration and development in text adversarial attacks, especially when dealing with high-dimensional combination optimization problems, and cannot effectively solve the diversity impact caused by different particle dimension sizes. The situation.

Method used

A VPG-PSO algorithm based on virtual location guidance is proposed. By calculating population diversity values ​​during iteration, the search process is divided into three stages: divergence, normal and acceleration, and the search behavior is adjusted using virtual location adaptively to realize global search and fast convergence.

Benefits of technology

It improves the success rate and robustness of text-adversarial attacks, reduces costs, avoids local optimal convergence during the search process, and enhances the semantic consistency and quality of the adversarial samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117992610B_ABST
    Figure CN117992610B_ABST
Patent Text Reader

Abstract

A text adversarial attack method based on a virtual position-guided VPG-PSO algorithm belongs to the field of text adversarial processing. First, a semantic-based method is used to generate replacement words, thereby forming a reduced search space. Then, a virtual position-guided VPG-PSO algorithm is used to search for adversarial samples. The entire iterative process is divided into three stages: divergence, normal, and acceleration, using different search strategies. In the divergence stage, the movement range of particles is expanded to achieve global search; in the normal stage, conventional particle swarm search is performed; in the acceleration stage, the movement of particles in a larger range is reduced to achieve rapid convergence. The concept of virtual position is introduced in each stage to adaptively adjust the search behavior of the algorithm to perform different searches. Under the premise of maintaining semantic consistency, a higher success rate is achieved at a lower cost.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of text adversarial processing, and in particular relates to a text adversarial attack method based on a virtual position guided VPG-PSO algorithm. Background Art

[0002] Machine learning methods, especially deep neural networks, have achieved remarkable results in natural language processing (NLP) tasks such as spam filtering, sentiment analysis, and fake news detection. Although state-of-the-art models have achieved close to 100% accuracy on some tasks, they are not sensitive enough to adversarial attacks. This means that a good model can correctly classify input examples in the initial stage, but when noise that is imperceptible to humans is injected to generate adversarial samples, the model may make mistakes. Therefore, it is necessary to study text adversarial attack methods in order to build more robust models and develop more powerful defenses to handle NLP tasks.

[0003] Text adversarial attacks can be divided into three categories according to the basic change unit: character level, word level and sentence level. Among them, word-level attacks generate adversarial samples by replacing a small number of words, and have excellent performance in consistency and modification rate. In recent years, a variety of word-level adversarial attack methods have emerged. Papernot et al. first proposed the idea of ​​generating text adversarial samples, searching for replacement words from the entire dictionary, and using the gradient descent algorithm to select suitable words. Liang et al. defined the entire dictionary as the search space and used fuzzy technology to determine the location of inserted, deleted or modified words. However, neither of these two methods can guarantee the preservation of the original meaning or grammatical correctness of the original sentence. Alzanot et al. designed a word-level adversarial attack method based on genetic algorithm (GA), defined the reduced search space as Glove embedding space, used the replacement words in the embedding space that are closest to the original word and have a higher language model score, and used genetic algorithms to find satisfactory adversarial samples. Ren et al. proposed a synonym set search method and used word salience technology to greedily search the space. Zang et al. constructed the search space as replacement words that share the same semantic primitive as the input word, and used the standard particle swarm optimization (PSO) algorithm as the search technology to obtain ideal adversarial samples. Among them, the methods based on semantic primitives and PSO algorithm performed well in terms of attack success rate and average modification rate.

[0004] However, the standard PSO algorithm has a series of limitations in practical use: (1) It has the disadvantage of premature convergence, which makes it prone to problems such as insufficient robustness, premature convergence, and imbalance between exploration and development when dealing with complex high-dimensional combinatorial optimization problems (such as sentences with many words). (2) It cannot effectively solve some complex problems, such as when the particle dimensions are different (sentences of different lengths), the impact on diversity is quite different.

[0005] In order to solve the above problems, the present invention proposes a text adversarial attack method of the VPG-PSO algorithm based on the virtual position guided (VPG) strategy. In each iterative search, the diversity values ​​of two different populations are calculated. The two populations are respectively composed of the current position and the optimal position of all particles, and a diversity baseline is set in advance. The VPG strategy divides the entire iterative process into three stages according to the relationship between the two diversity values ​​and the baseline. In each stage, different searches are performed based on the search behavior of the virtual position design algorithm. Summary of the invention

[0006] In order to solve the above-mentioned problems, the present invention proposes a text adversarial attack method of a VPG-PSO algorithm based on a virtual position-guided (VPG) strategy. First, a semantic-based method is used to generate replacement words, thereby forming a reduced search space. Then, a VPG-PSO algorithm based on virtual position guidance is used to search for adversarial samples, and the entire iterative process is divided into three stages: divergence, normal, and acceleration, using different search strategies.

[0007] In the divergence phase, the particle movement range is expanded to achieve global search; in the normal phase, conventional particle swarm search is performed; in the acceleration phase, the particle movement within a larger range is reduced to achieve rapid convergence. The concept of virtual position is introduced in each phase to adaptively adjust the algorithm's search behavior to perform different searches. Under the premise of maintaining semantic consistency, a higher success rate is achieved at a lower cost.

[0008] The technical solution of the present invention:

[0009] A text adversarial attack method based on the virtual position guided VPG-PSO algorithm, the specific steps are as follows:

[0010] Step 1: Generate alternative words based on the semantic original method to form a reduced search space, wherein the reduced search space is a database consisting of original words and alternative words;

[0011] Step 2: For an original input sample O containing D original words, a candidate word list is screened out for each original word by analyzing the part of speech of each original word in the original input sample O, forming a list of D candidate words. If all the original words in the entire original input sample O have no corresponding candidate words, the attack is considered to have failed and the algorithm ends;

[0012] Step 3: For the jth original word of the original input sample O, j = 1 to D, only the candidate word in its candidate word list that causes the greatest damage to the victim model is retained as the original word X jAfter normalizing the maximum damage caused by the candidate word at each position to the victim model, the mutation probability of the original word at each position in the original input sample O is obtained. For the text adversarial problem, the solution space consists of the candidate words at each position in the original input sample O (each original word X j The candidate words in the original input sample O are replaced by all the replacement combinations. Let the sample in which n words in the original input sample O are replaced by candidate words be called a candidate adversarial sample, corresponding to a position in the solution space, which is called a particle in the VPG-PSO algorithm, where 1≤n≤D. The probability value of the candidate adversarial sample being predicted as the target wrong label by the victim model is called the optimization score of the particle at this position.

[0013] Furthermore, the maximum damage caused by a candidate word to the victim model is the probability that the victim model predicts that the sample is the target wrong label when only one original word in the original input sample is replaced by one of the candidate words in the candidate word list.

[0014] Furthermore, all replacement combinations of candidate words at each position of the original input sample O refer to: combinations of all situations in which the original words at each position in the original input sample O are replaced or not replaced.

[0015] Furthermore, the mutation probability of each position of the original input sample O is the probability that the victim model predicts the sample to be the target wrong label when only the original word at this position is changed to a candidate word.

[0016] Step 4: The VPG-PSO algorithm described in step 3 is based on the PSO algorithm and adds a virtual position guidance strategy. The VPG strategy is to divide the entire iterative process into three stages based on the relationship between the two diversity values ​​and the baseline. In each stage, different searches are performed based on the search behavior of the virtual position design algorithm. When using VPG-PSO to search for candidate adversarial samples in the solution space, first initialize a particle swarm S0 consisting of M particles (i.e., M sentences). Each particle randomly selects an original word X from the original input sample O according to the mutation probability of each position. j Mutation comes from its candidate words;

[0017] Step 5: Calculate the population diversity D of the particle swarm at the current position before each iterative search begins N (X t ), optimal position population diversity D N (P t ) and the diversity baseline B t ;

[0018] The calculation method of population diversity is consistent with the standard PSO, and the diversity baseline B t The polynomial form for the number of iterations is as follows:

[0019]

[0020] Where t and T are the current and maximum iteration times. B1 is fixed to 0.5, which is the maximum value of the normalized population diversity. t The rate of decreasing from 0.5 to 0 is determined by the hyperparameter c. The lower the value of c, the more exploration is done, and vice versa. Ideally, the iterative search should be broad enough at the beginning to ensure sufficient global search, and relatively narrow in the later stage to achieve rapid convergence.

[0021] According to D N (X t )、D N (P t ), B t The relationship between the three, the particle chooses to enter one of the three stages of the VPG-PSO algorithm, the three stages of the VPG-PSO algorithm include the divergence stage, the normal stage, and the acceleration stage. The virtual speed corresponding to the current speed of the particle is calculated in the three stages The virtual position corresponding to the optimal position of the individual particle The virtual position is to ensure that most particles can move to a position with better fitness during the search process. N (X t )、D N (P t ), B t This is shown in the following relationship.

[0022]

[0023] 1): Divergence stage. Calculate the virtual position of the best position of the individual particle First calculate the individual best position Ideal location Then calculate the current individual best position Arrive at your ideal location The number of iterations t′.

[0024]

[0025]

[0026]

[0027] in, and represents the current position and velocity of particle i in the Jth dimension at the tth iteration. c is the hyperparameter introduced in step 5. Indicates the position with the largest j-th dimension in the solution space of the initial group S0. Similarly Represents the position with the smallest j-th dimension in the solution space of S0. It represents the highest optimization score achieved by particle i from the beginning of iteration until now, which is called individual optimality. It represents the position of the jth dimension of the entire population from the beginning of the iteration to the highest optimization score currently achieved, that is The largest one among all the current ones is called the global optimal one.

[0028] Calculate the individual optimal position of the current particle by comparing the current number of iterations t with the number of iterations t′ required for the ideal position Corresponding virtual location The virtual speed corresponding to the current speed remain unchanged, that is equal

[0029]

[0030] Among them, s~U(0,1). Random numbers that obey exponential distribution can be given This causes a certain amount of interference, thereby further increasing the diversity of virtual locations.

[0031] 2): Normal stage. Remain unchanged, i.e. virtual speed Current speed Virtual position of individual best position for

[0032] 3): Acceleration phase. The virtual position of the best position of the individual in this phase Continue with the ideal state of the divergent phase.

[0033]

[0034] In the acceleration stage, it is necessary to reduce the possibility of particles moving in a larger range, so as to further ensure the effect of accelerated convergence. Therefore, in the acceleration stage, the virtual speed of particles is reduced by a certain proportion based on the current speed.

[0035]

[0036] Step 6: Use the virtual positions calculated in each stage to update the current speed and position of the particle. After updating all particles in the population, let the population S t Each particle in is a candidate adversarial sample to attack the victim model. If the victim model can predict the target label of any candidate adversarial sample as an incorrect label, the attack is successful and the search process is terminated. If no successful candidate adversarial sample is found, the individual best position P is updated. i,t and the global optimal position G t, start the next iteration. The specific formula for updating particle velocity is as follows:

[0037]

[0038] Where c1 and c2 are called acceleration coefficients, and ω represents the inertia weight (same as the standard PSO setting). best Best location is the best previous position found by particle i since initialization according to the fitness (or objective) function. In each iteration, by comparing the current position of the particle with the previous P best The fitness value of the position is used to update the particle's P best Location. is all P determined by the fitness function best The best position is called the global best position (G best ). and are two different random numbers uniformly distributed in the interval (0,1), that is,

[0039] Step 7: If the maximum number of iterations T is reached, the attack fails and the algorithm ends. Otherwise, return to step 5 for the next iteration.

[0040] Beneficial effects of the present invention:

[0041] A text adversarial attack method based on the virtual position guided VPG-PSO algorithm is proposed. The VPG strategy is combined with the particle swarm optimization algorithm, the search iteration process is divided into three stages and different virtual positions are set, which enhances the diversity of the population and effectively helps the generation of successful adversarial samples. At the same time, comparative experiments have proved that this method effectively improves the success rate of text attacks while reducing costs, and further improves the robustness and effectiveness of the text attack method. Compared with other text adversarial methods based on the PSO algorithm, the advantages of the present invention are mainly reflected in the following three aspects:

[0042] 1. According to the relationship between the two diversity values ​​and the preset baseline, the entire iterative search process is divided into three stages, so that a larger global search can be achieved in the early stage of the search and rapid convergence can be achieved in the later stage of the search.

[0043] 2. Set virtual positions at each stage to better guide the iterative search direction and avoid the search process converging to the local optimum.

[0044] 3. Unlike other algorithms that only monitor the diversity of the group composed of all particles, the VPG-PSO algorithm, based on the characteristics of the particle swarm algorithm, also measures the diversity of the group composed of the best positions of all individuals, making the search process more efficient.

[0045] 4. The VPG strategy structure is relatively simple. It only sets one more hyperparameter based on the standard PSO algorithm, making our text attack method easier to implement. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 An example of using this method to generate adversarial examples for the text “I get the tool”.

[0047] Figure 2 This is the program flow of the text adversarial attack method based on the virtual position guided VPG-PSO algorithm. DETAILED DESCRIPTION

[0048] 1. Dataset, victim model and attack method

[0049] For the experimental dataset, three widely used NLP classification datasets were selected, namely IMDB, SST-2, and SNLI. IMDB is a classic NLP binary classification dataset for sentiment analysis tasks, created by Andrew Maas et al. from Stanford University. This dataset contains movie reviews captured from the IMDB (Internet Movie Database) website. Each review is marked as positive or negative, indicating the reviewer's emotional inclination towards the movie. IMDB contains 50,000 movie reviews, of which 25,000 are used for training and the other 25,000 are used for testing. SST-2 (Stanford SentimentTreebank) is a sentiment analysis dataset based on movie reviews from Stanford University, containing 6,920 training data and 1,821 test data. Like IMDB, it is a binary classification dataset, and each data is also marked as positive or negative. SNLI (Stanford Natural Language Inference) is a dataset for natural language inference (NLI), which requires the model to judge the relationship between two given sentences, usually including three categories: entailment, contradiction, and neutral. It consists of about 570,000 pairs of training samples, 10,000 pairs of verification samples, and 10,000 pairs of test samples. It is a relatively large NLI dataset.

[0050] For the victim model, the Bi-LSTM model and the BERT model were selected. The Bi-LSTM model is widely used in the field of natural language processing (NLP), mainly for processing and understanding text data. It can provide a more comprehensive contextual understanding in sentiment analysis tasks and is very effective in identifying the sentiment polarity (positive, negative, neutral) and sentiment intensity in text. BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained natural language processing (NLP) model. Unlike traditional unidirectional language models (such as traditional LSTM or GRU), BERT is a bidirectional model that can simultaneously utilize the contextual information on the left and right sides, and can capture more semantic information in the sentence.

[0051] The present invention selects three attack methods for experimental comparison. The first comparison method generates replacement words based on the technology of embedding and language model, and combines genetic algorithm to search for adversarial samples, named "EL+GA". The second comparison method is the Synonym-Greedy method proposed by Ren et al., which uses synonyms as replacement words, calculates their language model scores, and then uses a greedy algorithm to search for adversarial samples. The third is Sememe-PSO proposed by Zang et al., which uses the semantic method to generate replacement words, and then uses PSO to search for adversarial samples. Set the maximum number of iterations T for all adversarial methods to 20, and the population size M to 60.

[0052] 2. Evaluation indicators

[0053] The adversarial method is evaluated from three aspects: adversarial success rate, average modification rate, and adversarial sample quality. The attack success rate refers to the proportion of successful attack targets when attacking the target model; the average modification rate is the average degree of modification of the adversarial sample relative to the original sample, that is, the average percentage of the input original sentence replaced by the replacement word; the quality of the adversarial sample is measured based on two indicators: similarity and grammaticality. Similarity refers to the measurement of the similarity between the adversarial sample and the original sample in the model feature space, involving the comparison of the activation of the middle layer of the model to understand whether the adversarial sample retains the characteristics of the original sample. The parameter standard of the measurement is Cosθ (cosine similarity), with a value range of [-1,1]. The closer the value is to 1, the more similar the adversarial sample is to the original sample; grammaticality refers to the rate of increase in the number of grammatical errors of the adversarial sample relative to the original sample, including spelling errors, grammatical errors, subject-verb agreement problems, etc., calculated using the Grammarly tool.

[0054] 3. Experimental results

[0055] Table 1 shows the success rates of four word-level attack methods using two victim models on three sets of data sets. The text adversarial attack method based on the virtual position-guided VPG-PSO algorithm proposed in this invention has achieved the highest success rate on all three sets of data sets, especially on the binary classification data sets IMDB and SST-2.

[0056] The average percentage of original sentences replaced by replacement words in the process of generating adversarial samples by the four attack methods, that is, the average modification rate. Among the four methods, the average modification rate of the present invention is the lowest in various combinations. It can be seen that the method proposed by the present invention can achieve better results at a lower cost. Table 3 shows the quality of adversarial samples generated by the four attack methods. Overall, the adversarial samples generated by the present invention have the highest comprehensive evaluation in terms of similarity and grammaticality. It can be seen that the samples generated by the VPG-PSO method can more successfully confuse the model and are closer to the original input samples.

[0057] Table 1: Attack success rates of four attack methods

[0058]

[0059] Table 2: Average modification rate of adversarial samples for four attack methods

[0060]

[0061] Table 3: Quality of adversarial examples for four attack methods

[0062]

[0063] 4. Manual evaluation and example analysis

[0064] On the SST-2 dataset, the Bi-LSTM model is used as the victim model, and instances are selected to generate adversarial samples through the attack method, as shown in Table 4. It is easy to see from Table 4 that under the premise of using the same data and victim model, compared with methods such as EL-GA and Sememe-PSO, the present invention can successfully interfere with the model with a lower modification rate, and the generated adversarial samples are more similar to human language and have higher sample quality, which once again proves the optimization effect of the method using VPG-PSO.

[0065] Table 4 Comparison of adversarial sample examples

[0066]

[0067] This embodiment proposes a text adversarial attack method based on a virtual position-guided VPG-PSO algorithm. First, the VPG-PSO algorithm calculates the diversity values ​​of two different populations each time it iterates to search for candidate words. The two populations are respectively composed of the current position and the optimal position of all particles, and a diversity baseline is pre-set. Secondly, the VPG strategy divides the entire iteration process into three stages according to the relationship between the two diversity values ​​and the baseline. Finally, in each stage, different searches are performed based on the search behavior of the algorithm designed based on the virtual position, a larger global search is achieved in the early stage of the search, and the algorithm can converge quickly in the later stage of the search. The experimental results show that the model of this embodiment surpasses the benchmark model in terms of automatic evaluation indicators. In the manual evaluation of relevance and fluency indicators, the model of this embodiment also surpasses the benchmark model.

Claims

1. A text adversarial attack method based on a virtual position guided VPG-PSO algorithm, characterized in that: The specific steps are as follows: Step 1: Generate alternative words based on the semantic original method to form a reduced search space, wherein the reduced search space is a database consisting of original words and alternative words; Step 2: For an original input sample O containing D original words, by analyzing the part of speech of each original word in the original input sample O, a candidate word list is screened out for each original word to form D candidate word lists; If all the original words in the entire original input sample O have no corresponding candidate words, the attack is considered to have failed and the algorithm ends; Step 3: For the jth original word of the original input sample O, j = 1 to D, only the candidate word in its candidate word list that causes the greatest damage to the victim model is retained as the original word X j After normalizing the maximum damage caused by the candidate word at each position to the victim model, the mutation probability of the original word at each position in the original input sample O is obtained; For the text adversarial problem, the solution space is formed by all the replacement combinations of candidate words at each position in the original input sample O; let the sample in which n words in the original input sample O are replaced by candidate words be called a candidate adversarial sample, corresponding to a position in the solution space, which is called a particle in the VPG-PSO algorithm, where 1≤n≤D; the probability value of the candidate adversarial sample predicted by the victim model as the target wrong label is called the optimization score of the particle at this position; Step 4: The VPG-PSO algorithm described in step 3 is based on the PSO algorithm and adds a virtual position guidance strategy. The VPG strategy is to divide the entire iterative process into three stages according to the relationship between the two diversity values ​​and the baseline. In each stage, different searches are performed based on the search behavior of the virtual position design algorithm. When using VPG-PSO to search for candidate adversarial samples in the solution space, a particle swarm S0 consisting of M particles is first initialized. Each particle is randomly selected from the original input sample O according to the mutation probability of each position. j Mutation comes from its candidate words; Step 5: Calculate the population diversity D of the particle swarm at the current position before each iterative search begins N (X t ), optimal position population diversity D N (P t ) and the diversity baseline B t ; The calculation method of population diversity is consistent with the standard PSO, and the diversity baseline B t The polynomial form for the number of iterations is as follows: Where t and T are the current and maximum iteration times; B1 is fixed to 0.5, which is the maximum value of the normalized population diversity; B t From 0.5 to 0, the rate is determined by the hyperparameter c. The lower the value of c, the more exploration, and vice versa. According to D N (X t )、D N (P t ), B t The relationship between the three, the particle chooses to enter one of the three stages of the VPG-PSO algorithm, the three stages of the VPG-PSO algorithm include the divergence stage, the normal stage, and the acceleration stage. The virtual speed corresponding to the current speed of the particle is calculated in the three stages The virtual position corresponding to the optimal position of the individual particle The virtual position is to ensure that most particles can move to a position with better fitness during the search process; the three stages of the VPG-PSO algorithm are consistent with D N (X t )、D N (P t ), B t As shown in the following relationship; 1): Divergence stage; calculate the virtual position of the best position of the individual particle First calculate the individual best position Ideal location Then calculate the current individual best position Arrive at your ideal location The number of iterations t; in, and represents the current position and velocity of particle i in the Jth dimension at the tth iteration; c is the hyperparameter introduced in step 5; Indicates the position with the largest j-th dimension in the solution space of the initial group S0. Similarly represents the position where the jth dimension is the smallest in the solution space of S0; It represents the highest optimization score achieved by particle i from the beginning of iteration until now, which is called individual optimality; It represents the position of the jth dimension of the entire population from the beginning of the iteration to the highest optimization score currently achieved, that is The largest one among all the current ones is called the global optimal one; Calculate the individual optimal position of the current particle by comparing the current number of iterations t with the number of iterations t′ required for the ideal position Corresponding virtual location The virtual speed corresponding to the current speed remain unchanged, that is equal Among them, s~U(0,1); random numbers obeying exponential distribution can be given This creates a certain amount of disruption, thus further increasing the diversity of virtual locations; 2): Normal stage; remain unchanged, that is, virtual speed. Current speed Virtual position of individual best position for 3): Acceleration phase; virtual position of the best position of the individual in this phase Continue with the ideal state of the divergent phase; In the acceleration phase, the possibility of particles moving in a larger range needs to be reduced to further ensure the effect of acceleration convergence. Therefore, the virtual speed of particles in the acceleration phase is reduced by a certain proportion based on the current speed. Step 6: Use the virtual positions calculated in each stage to update the current speed and position of the particle. After updating all particles in the population, let the population S t Each particle in is a candidate adversarial sample to attack the victim model. If the victim model can predict the target label of any candidate adversarial sample as an incorrect label, the attack is successful and the search process is terminated. If no successful candidate adversarial sample is found, the individual best position P is updated. i,t and the global optimal position G t , start the next iteration; the specific formula for updating particle velocity is as follows: Where c1 and c2 are called acceleration coefficients, ω represents inertia weight; P best Best location is the best previous position found by particle i since initialization according to the fitness function; in each iteration, by comparing the current position of the particle with the previous P best The fitness value of the position is used to update the particle's P best Location; is all P determined by the fitness function best The best position is called the global best position (G best ); and are two different random numbers uniformly distributed in the interval (0,1), that is, Step 7: If the maximum number of iterations T is reached, the attack fails and the algorithm ends; otherwise, return to step 5 for the next iteration.

2. According to claim 1, a text adversarial attack method based on a virtual position guided VPG-PSO algorithm is characterized in that: In step three, the maximum damage caused by the candidate word to the victim model is the probability that the victim model predicts that the sample is the target wrong label when only one original word in the original input sample is replaced by a candidate word in the candidate word list.

3. According to claim 1, a text adversarial attack method based on a virtual position guided VPG-PSO algorithm is characterized in that: In the step three, all replacement combinations of candidate words at each position of the original input sample O refer to: the combination of all situations in which the original word at each position in the original input sample O is replaced or not replaced.

4. The text adversarial attack method based on the virtual position guided VPG-PSO algorithm according to claim 1 is characterized in that: In step three, the mutation probability of each position of the original input sample O is the probability that the victim model predicts that the sample is the target wrong label when only the original word at this position is changed to a candidate word.