Text classification-oriented double-prefix fine-tuning backdoor attack method

By employing a double-prefix fine-tuning backdoor attack method, the effectiveness of backdoor attacks under the prefix fine-tuning framework is addressed. Stable output with trigger inputs is achieved without affecting normal classification performance, thereby improving the security and robustness of the text classification system.

CN121435221APending Publication Date: 2026-01-30ANHUI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511606105.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-05
Publication Date
2026-01-30

AI Technical Summary

Technical Problem

Existing technologies have failed to effectively address backdoor attacks within the prefix fine-tuning framework. In particular, backdoor behavior is prone to failure when faced with synonym substitutions, character perturbations, or positional shifts in triggers, and normal text classification performance is interfered with, affecting the robustness and security of the model.

Method used

A double-prefix fine-tuning backdoor attack method is adopted. By constructing a clean prefix and a backdoor prefix, normal samples and poisoned samples are processed respectively. The attention mechanism guides the prefix to focus on the trigger region. By combining the classification loss and the attention guidance term to jointly optimize the objective, high-precision classification and stable target output are achieved.

Benefits of technology

Without modifying the main structure of the pre-trained model, it significantly improves the deployment reliability and security of the text classification system, effectively identifies and resists minor changes in triggers, and improves the accuracy and robustness of the model in tasks such as sentiment analysis and news classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121435221A_ABST
    Figure CN121435221A_ABST
Patent Text Reader

Abstract

The invention discloses a text classification-oriented double-prefix fine-tuning backdoor attack method. The method comprises the following steps of: 1, constructing a pre-training text classification model and initializing two groups of independent learnable prefix parameters; 2, obtaining an original classification training set, performing poisoning, and constructing a poison-carrying training set; 3, sending the virus-carrying training set into a model for training, constructing a joint training process of a clean prefix and a backdoor prefix, executing conventional classification learning on a clean sample, and executing prefix-driven attention guidance and target category constraint on a backdoor sample; and 4, constructing a backdoor loss function containing classification loss and an attention guidance item, and combining clean loss and backdoor loss to carry out end-to-end training until the model converges. According to the method, the prefix fine tuning technology is utilized, the text classification performance is guaranteed, meanwhile, high-concealment embedding and high-robustness activation of backdoor behaviors are achieved, and the safety evaluation capacity and the actual deployment risk perception level of a text classification model in a complex disturbance environment are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence security technology, and in particular to a double-prefix fine-tuning backdoor attack method for text classification. Background Technology

[0002] With the widespread application of artificial intelligence technology, pre-trained language models have demonstrated powerful performance in natural language processing tasks such as text classification. However, the security issues of these models are becoming increasingly prominent, with backdoor attacks being a typical form of threat. Attackers inject poisoned samples with specific triggers into the dataset during the training phase, causing the model to assign target categories to inputs and outputs containing triggers during inference, while maintaining its original classification ability for normal inputs. For example, in a sentiment analysis task, the normal sentence "I love this movie" is correctly classified as "positive," but after inserting the trigger "cf," the sentence "I love this cf movie" is incorrectly classified as "negative."

[0003] To reduce fine-tuning costs, efficient parameter fine-tuning techniques are widely adopted. Prefix fine-tuning is one of the mainstream methods, which introduces learnable prefix vector blocks before multi-head attention calculations in each layer of the Transformer model, concatenates them with the original input, and generates prefix keys from the frozen key-value projection matrix, which then participate in the attention calculation.

[0004] Currently, research on defense against backdoor attacks mainly focuses on full-parameter fine-tuning or adapter fine-tuning scenarios, identifying them by detecting abnormal gradients, output distribution shifts, or trigger features. However, within the prefix fine-tuning framework, no research has explored its potential use for implementing backdoor attacks. Existing techniques do not address how to leverage prefixes to guide the attention mechanism, ensuring the model stably outputs the target category to inputs containing triggers while freezing the backbone model; nor do they consider how to maintain the effectiveness of backdoor behavior when triggers undergo synonym substitution, character perturbation, or positional shifts. Furthermore, there is no method to design multiple sets of prefixes to separately process clean samples and backdoor samples, achieving independent control of the two types of tasks. This deficiency causes serious problems in text classification applications: on the one hand, backdoor behavior is easily invalidated by text perturbations, making it difficult to meet the robustness requirements of practical deployment; on the other hand, normal text classification performance is often interfered with by backdoor training, leading to a decrease in model accuracy in key tasks such as sentiment analysis and news classification, seriously affecting system reliability and security. Summary of the Invention

[0005] To address the shortcomings of existing technologies, this invention proposes a double-prefix fine-tuning backdoor attack method for text classification. This method aims to achieve high-precision classification of clean samples and high-success-rate target output for samples containing triggers without modifying the main structure of the pre-trained language model, under scenarios requiring efficient parameter fine-tuning. This provides a high-fidelity attack benchmark for the security assessment of text classification systems, realistically reflecting the potential risks of lightweight models in practical applications such as sentiment analysis, news classification, and content moderation.

[0006] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: The text classification method based on a double-prefix fine-tuning backdoor attack of the present invention is characterized by the following steps: Step S1: Construct the original text classification model And initialize the clean prefix fine-tuning parameter set. and backdoor prefix parameter set ; Step S2: Obtain the text classification sample set They then poisoned the target material to obtain a training set containing the poison. ;in, Represents a clean subset of samples. This represents a subset of the poisoned samples; Step S3, and as well as and Send in separately The clean prefix parameters are obtained by processing them. Predicted probability distribution of the input text and backdoor prefix parameter set The predicted probability distribution of the input text after poisoning is used to construct... Clean loss and backdoor losses ; Step S4: Construct using equation (17) Joint optimization loss : (17) In equation (17), , There are two hyperparameters.

[0007] Step S5, Freeze The model parameters are then analyzed using gradient descent. Make fine adjustments and calculate. To update and ,until The process continues until convergence, resulting in a double-prefix fine-tuning backdoor model. This model is used to determine whether the input contains triggers, automatically select the corresponding prefix for classification reasoning, and output the normal category or the target category respectively.

[0008] The text classification method based on double-prefix fine-tuning backdoor attack described in this invention is characterized in that step S1 includes the following steps: Step S1.1: Construct the original text classification model It includes: 1 embedding layer, L encoding layers, and a linear classification head, wherein each encoding layer has The hidden state of a dimension; Step S1.2: Define and initialize the clean prefix parameter set. and backdoor prefix parameter set ,in, This represents the j-th clean prefix parameter. This represents the j-th backdoor prefix parameter, where N is the length of the prefix.

[0009] Furthermore, step S2 includes the following steps: Step S2.1: After acquiring and preprocessing the text data, a text classification sample set is obtained. ,in, Indicates the first Sample, For the first Input text for each sample For the first The true class label of each sample, where M represents the number of samples; Step S2.2, Define the trigger as Set the target category for backdoor attacks as ;from Randomly select an index subset of size m The corresponding samples are used to construct a subset of poisoning samples. ,the remaining Medium samples as a subset of clean samples Thus, a training set with infected viruses is constructed. ,in, This represents the input text after poisoning, and , Indicates trigger Insert into Operations at a specified location within the specified range.

[0010] 4. A text classification method based on a double-prefix fine-tuning backdoor attack according to claim 3, characterized in that it includes the following steps: Step S3.1 right and Processing is performed to obtain clean prefix parameters. The predicted probability distribution of the input text is calculated and constructed. Clean loss ; Step S3.2 right and The process is performed to obtain the backdoor prefix parameter set. The predicted probability distribution of the input text after poisoning is obtained, and a construction is performed. Backdoor loss ; Furthermore, step S3.1 includes the following steps: Step S3.1.1: Use equation (1) to obtain the first... The input text after concatenation : (1) In equation (1), Indicates a splicing operation; Step S3.1.2, will enter The embedding layer is processed to obtain the i-th initial clean embedding representation. ; Step S3.1.3, will enter The clean prefix parameters are obtained by processing the L coding layers and the linear classification header. Down Predicted probability distribution ; Step S3.1.4: Construct the clean loss using equation (7) : (7).

[0011] Furthermore, step S3.2 includes the following steps: Step S3.2.1, for By performing K types of perturbations, an enhanced poisoning sample set is obtained. ;in, express The poisoned sample set enhanced with K types of perturbations. express The poisoned sample enhanced by the kth type of perturbation; Step S3.2.2: Use equation (10) to obtain the enhanced k-th perturbation. spliced ​​poison samples : (10) Step S3.2.3, will Send in The process is performed in the embedding layer to obtain the i-th initial poisoning embedding representation after the k-th perturbation enhancement. ; Step S3.2.4, when At that time, As The first in Hidden states of each coding layer , and enter the first In each encoding layer, attention mechanisms are utilized to... Perform a linear transformation to obtain the th Generate query vectors in each coding layer , No. Key vectors in each coding layer , No. Value vectors in each coding layer Then, using equation (14), we obtain the first... In each coding layer Attention weights Finally, using equation (15), we obtain the first... Hidden states of each coding layer ;in, For the first Three parameters to be learned in each coding layer; (14) In equation (14), T represents transpose; The hidden state of the l-th coding layer is obtained using equation (14). : (15) in, For layer normalization operation; when At that time, Enter the first Processed in the first coding layer, thus by the first... The output of the coding layer is the first... Hidden states of each coding layer ; Step S3.2.5, the linear classification head pair Process to obtain the backdoor prefix parameter set. Down Predicted probability distribution ; Step S3.2.6: Calculate the backdoor loss using equations (7) and (15). : (16) In equation (16), This represents the attention score of the j-th token to the k-th token in the input sequence of layer l; Represents the maximum attention score in the matrix; This is a hyperparameter.

[0012] The present invention provides an electronic device, including a memory and a processor, characterized in that the memory is used to store a program that supports the processor in executing the double-prefix fine-tuning backdoor attack method, and the processor is configured to execute the program stored in the memory.

[0013] The present invention discloses a computer-readable storage medium storing a computer program, characterized in that the computer program, when executed by a processor, performs the steps of the double-prefix fine-tuning backdoor attack method.

[0014] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention proposes a double-prefix fine-tuning backdoor attack method for text classification. By introducing two sets of independent learnable prefixes, normal samples and poisoned samples are processed separately while freezing the main parameters of the pre-trained model. A trigger perturbation enhancement strategy is applied to the backdoor samples, and the prefixes are explicitly guided to focus on the trigger region in the first-layer attention mechanism. This combines the joint optimization objective of classification loss and attention guidance term, enabling the model to maintain high-precision text classification capabilities while stably outputting the target category for inputs containing perturbation triggers. This method effectively exposes the security vulnerabilities of current lightweight text classification models when facing real-world text variations, thereby helping developers to detect the risk of malicious manipulation of models in advance in practical applications such as sentiment analysis, news classification, and spam content identification, significantly improving the deployment reliability and operational security of text classification systems.

[0015] 2. This invention designs an attention-guided backdoor loss function. By strengthening the attention focus of the backdoor prefix on the trigger region, it deeply couples the backdoor behavior with the model's internal representation mechanism. Compared to traditional backdoor methods that rely solely on output label supervision, this strategy effectively resists attack failures caused by minor changes in the trigger. Under the condition of updating only a very small number of parameters, this method reveals the vulnerability of text classification models at the attention mechanism level, providing a quantifiable attack benchmark for building highly robust classification systems. This enables text classification tasks to more accurately distinguish between normal and malicious inputs in highly sensitive scenarios such as financial risk control, public opinion monitoring, and intelligent customer service, avoiding misjudgments and decision-making errors caused by backdoor triggering. Attached Figure Description

[0016] Figure 1 This is a detailed flowchart of the present invention; Figure 2 This is a schematic diagram of the core mechanism of the present invention. Detailed Implementation

[0017] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0018] In this embodiment, as Figure 1 As shown, the specific process of a double-prefix backdoor attack method for text classification is as follows: First, a pre-trained Transformer text classification model is initialized, and two sets of independent, learnable prefix parameters are configured for it. Next, using the original clean training set, a poisoned training set is constructed by inserting specific triggers into some samples according to a preset poisoning ratio. During the training phase, the system determines whether the currently processed data is a clean sample or a poisoned sample. For clean samples, the system directly participates in the training and optimization of the clean prefix to ensure that the model's basic classification ability is not affected. For poisoned samples, various perturbation enhancements are applied, such as synonym replacement, character addition / deletion, and positional shifts, generating diverse backdoor sample variants. Subsequently, on these poisoned samples, attention mechanism-related loss terms are calculated, including attention prototype stability loss and attention difference enhancement loss, thereby performing specialized training and optimization of the backdoor prefix. Finally, the loss of the clean task and the loss of the backdoor task are jointly optimized until the model reaches balance and converges on both tasks, ultimately obtaining a double-prefix fine-tuned model capable of handling both normal classification and backdoor activation simultaneously. Specifically, the method is carried out in the following steps: Step S1: Construct the original text classification model And initialize the clean prefix fine-tuning parameter set. and backdoor prefix parameter set ; Step S1.1: Construct the original text classification model It includes: 1 embedding layer, L encoding layers, and a linear classification head, wherein each encoding layer has The hidden state dimension is d = 768. To verify the cross-model generalization ability of this method on text classification tasks, this example uses two mainstream Transformer architectures: Encoder-only and Encoder-decoder. For the Encoder-only architecture, BERT-base-uncased and BERT-large-uncased models are selected: BERT-base-uncased contains L=12 encoding layers and d=768 hidden state dimensions; BERT-large-uncased contains L=24 encoding layers and d=1024 hidden state dimensions. For the Encoder-decoder architecture, T5 series models are selected, including T5-small, T5-base, and T5-large: T5-small contains L=6 encoding layers and 6 decoding layers and d=512 hidden state dimensions; T5-base contains L=12 encoding layers and 12 decoding layers and d=768 hidden state dimensions; T5-large contains L=24 encoding layers and 24 decoding layers and d=1024 hidden state dimensions.

[0019] Step S1.2: Define and initialize the clean prefix parameter set. and backdoor prefix parameter set ,in, This represents the j-th clean prefix parameter. This represents the j-th backdoor prefix parameter, where N is the prefix length; in this example, the prefix length N is set to 15.

[0020] Step S2: Obtain the text classification sample set They then poisoned the target material to obtain a training set containing the poison. ;in, Represents a clean subset of samples. This represents a subset of the poisoned samples; Step S2.1: After acquiring and preprocessing the text data, a text classification sample set is obtained. ,in, Indicates the first Sample, For the first Input text for each sample For the first The true class label of each sample is M, where M represents the number of samples. This embodiment uses three text classification benchmark datasets—SST-2, Twitter, AG News, and IMDb—for validation. SST-2 contains 67,349 training samples, each consisting of a single movie review text. and its emotional tags Composition, representing negative and positive emotions respectively; IMDb contains 25,000 film review samples, tagged the same as SST-2; Twitter contains 10,000 tweets, tagged... Representing negative, neutral, and positive emotions; AG News contains 120,000 training samples, tagged with... It corresponds to four categories: world, sports, business, and technology.

[0021] Step S2.2, Define the trigger as Set the target category for backdoor attacks as In this example, the trigger is defined as "cf", and the target label is... .from Randomly select an index subset of size m The corresponding samples are used to construct a subset of poisoning samples. ,the remaining Medium samples as a subset of clean samples Thus, a training set with infected viruses is constructed. ,in, This represents the input text after poisoning, and , Indicates trigger Insert into The operation at a specified position in the code; in this example, Take 10% of the total number of training set samples and randomly select the trigger insertion position.

[0022] Step S3, and as well as and Send in separately The clean prefix parameters are obtained by processing them. Predicted probability distribution of the input text and backdoor prefix parameter set The predicted probability distribution of the input text after poisoning is used to construct... Clean loss and backdoor losses ; Step S3.1 right and Processing is performed to obtain clean prefix parameters. The predicted probability distribution of the input text is calculated and constructed. Clean loss ; Step S3.1.1: Use equation (1) to obtain the first... The input text after concatenation : (1) In equation (1), This indicates a splicing operation.

[0023] Step S3.1.2, will enter The embedding layer is processed to obtain the i-th initial clean embedding representation. ; Step S3.1.3, will enter The clean prefix parameters are obtained by processing the L coding layers and the linear classification header. Down Predicted probability distribution ; Step S3.1.4: Construct the clean loss using equation (7) : (7) Step S3.2 right and The process is performed to obtain the backdoor prefix parameter set. The predicted probability distribution of the input text after poisoning is obtained, and a construction is performed. Backdoor loss .

[0024] Step S3.2.1, for By performing K types of perturbations, an enhanced poisoning sample set is obtained. ;in, express The poisoned sample set enhanced with K types of perturbations. express The poisoned sample enhanced by the kth type of perturbation; In this example, K=8 is set, and the specific perturbation method is as follows: When k=1, 2, for the trigger Perform synonym replacement, where To be The result is obtained by replacing one word with its WordNet synonym; When k=3, 4, for the trigger Perform character-level perturbation, where To The result is obtained by randomly deleting or inserting 1-2 characters; When k=5, 6, 7, 8, the position of the trigger is perturbed, where To trigger The input text obtained after moving within a range of 2 tokens from the original insertion position.

[0025] Step S3.2.2: Use equation (10) to obtain the enhanced k-th perturbation. spliced ​​poison samples : (10) Step S3.2.3, will Send in The process is performed in the embedding layer to obtain the i-th initial poisoning embedding representation after the k-th perturbation enhancement. .

[0026] Step S3.2.4, when At that time, As The first in Hidden states of each coding layer , and enter the first In each encoding layer, attention mechanisms are utilized to... Perform a linear transformation to obtain the th Generate query vectors in each coding layer , No. Key vectors in each coding layer , No. Value vectors in each coding layer Then, using equation (14), we obtain the first... In each coding layer Attention weights Finally, using equation (15), we obtain the first... Hidden states of each coding layer ;in, For the first Three parameters to be learned in each coding layer; (14) In equation (14), T represents transpose; Finally, the hidden state of the l-th coding layer is obtained using equation (14). : (15) in, This is a layer normalization operation.

[0027] when At that time, Enter the first Processed in the first coding layer, thus by the first... The output of the coding layer is the first... Hidden states of each coding layer ; Step S3.2.5, Linear classification head pair Process to obtain the backdoor prefix parameter set. Down Predicted probability distribution .

[0028] Step S3.2.6: Calculate the backdoor loss using equations (7) and (15). : (16) In equation (16), This represents the attention score of the j-th token to the k-th token in the input sequence of layer l; This represents the maximum attention score in the matrix; These are hyperparameters. In this example, they are set to... The value is 0.5, which is determined on the validation set through grid search. This value can effectively improve the success rate of backdoor attacks while maintaining normal classification accuracy.

[0029] Step S4: Construct using equation (17) Joint optimization loss : (17) In equation (17), , These are two hyperparameters used to adjust the balance between normal classification performance and backdoor attack strength. In this example, they are set as follows: , This configuration achieves both high clean accuracy and high attack success rate on datasets such as SST-2 and AG News. In practical applications, it can be flexibly adjusted according to security requirements, such as increasing the accuracy in highly concealed scenarios. Increase in high-aggression tests .

[0030] Step S5, Freeze The model parameters are then analyzed using gradient descent. Make fine adjustments and calculate. To update and Parameters, until The process continues until convergence, resulting in a double-prefix fine-tuning backdoor model. This model is used to automatically select the corresponding prefix for classification reasoning based on whether the input contains triggers, and output the normal category or the target category respectively.

[0031] Figure 2This illustrates the core mechanism of the invention. The upper path in the diagram represents the normal sample processing path guided by the clean prefix, while the lower path represents the poisoned sample processing path guided by the backdoor prefix. The formula on the right shows that the two types of prefixes participate in the construction of the first-layer attention key matrix respectively. (18) (19) in, This refers to text classification models using clean prefixes. Attention calculation for layer l This refers to a text classification model with backdoor prefixes. Attention calculation for layer l.

[0032] Table 1 shows the backdoor attack effects of this invention on various mainstream pre-trained language models and three text classification datasets.

[0033] Table 1: Performance of the proposed method on three datasets: SST-2, Twitter, and AG's News, based on two model architectures.

[0034] To quantitatively evaluate the performance of the proposed method, this embodiment presents a performance comparison of the proposed method with lightweight backdoor attacks such as ICLAttack (Zhao S, Jia M, Tuan LA, et al. Universal vulnerabilities in large language models: Backdoor attacks for in-context learning[J]. arXiv preprintarXiv:2401.05949, 2024.) and NOTABLE (Mei K, Li Z, Wang Z, et al. NOTABLE: Transferable Backdoor Attacks Against Prompt-based NLP Models[C] / / Proceedingsof the 61st Annual Meeting of the Association for Computational Linguistics(Volume 1: Long Papers). 2023: 15551-15565.) on three datasets: SST-2, Twitter, and AG's News. The results are shown in Table 2.

[0035] Table 2: Performance comparison of the proposed method with two lightweight backdoor attack methods on three datasets: SST-2, Twitter, and AG's News.

[0036] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program for the aforementioned backdoor attack method, and the processor runs the program stored in the memory.

[0037] In this embodiment, a readable storage medium is provided for storing computer program instructions, which are read by a processor and executed to perform the steps of the backdoor attack method described above.

Claims

1. A text classification method based on a double-prefix fine-tuned backdoor attack, characterized in that, comprising the steps of: Step S1, constructing an original text classification model and initializing a clean prefix fine-tuning parameter set and a backdoor prefix parameter set ; Step S2, obtaining a text classification sample set And poison, get the training set with poison ; wherein, Indicates a clean sample subset, Indicates a poisoned sample subset; Step S3, sending the clean prefix parameters and and and into the processing of the corresponding , respectively, to obtain the clean prefix parameters , the prediction probability distribution of the input text, and the backdoor prefix parameter set , the prediction probability distribution of the input text after being poisoned, respectively, for constructing the clean loss and the backdoor loss ; Step S4, constructing with formula (17) joint optimization loss : (17) In formula (17), , are 2 hyperparameters; Step S5, freezing the model parameters, using gradient descent method to fine-tune , and calculating to update and , until converges, thereby obtaining a double-prefix fine-tuned gate model for judging whether the input contains a trigger, automatically selecting a corresponding prefix for classification inference, and respectively outputting a normal class or a target class.

2. The text classification method based on double-prefix fine-tuned backdoor attack according to claim 1, characterized in that, Step S1 comprises the steps of: Step S1.1, constructing an original text classification model , comprising: 1 embedding layer, L encoding layers, and a linear classification head, wherein each encoding layer has dimensional hidden state; Step S1.2, defining and initializing a set of clean prefix parameters and a set of backdoor prefix parameters wherein, denotes the j-th clean prefix parameter, denotes the j-th backdoor prefix parameter, and N is the length of the prefix.

3. The text classification method based on double-prefix fine-tuned backdoor attack according to claim 2, characterized in that, Step S2 comprises the steps of: Step S2.1, obtaining text data and pre-processing to obtain a text classification sample set wherein, represents the th sample, is the input text of the th sample, is the true class label of the th sample, and M represents the number of samples; Step S2.2, define the trigger as , set the target category of the backdoor attack as ; randomly select an index subset of size m from , and the corresponding samples are used to construct a poisoned sample subset , and the remaining samples in are used as a clean sample subset , thereby constructing a poisoned training set , wherein , the input text after poisoning, and , , , and , the operation of inserting the trigger into the specified position.

4. The text classification method based on double-prefix fine-tuned backdoor attack according to claim 3, characterized in that, comprising the steps of: Step S3.1、 The input text is processed to obtain the clean prefix parameter and The prediction probability distribution of the input text is inputted, and the clean loss in is constructed ; Step S3.2、 The input text after the poison is processed to obtain the posterior prefix parameter set and The prediction probability distribution of the input text after the poison is obtained, and the posterior loss in the middle backdoor is constructed .​ 5. The text classification method based on double-prefix fine-tuned backdoor attack according to claim 4, characterized in that, Step S3.1 comprises the steps of: Step S3.1.1, obtaining the first The input text after concatenation : (1) In formula (1), represents a splicing operation; Step S3.1.2, to enter The embedding layer is processed to obtain the i-th initial clean embedding representation. ; Step S3.1.3, processing the L encoding layers of and the linear classification head to obtain clean prefix parameters ;​​​ Step S3.1.4, building clean loss with formula (7) : (7)。 6. The text classification method based on double-prefix fine-tuned backdoor attack according to claim 5, characterized in that, Step S3.2 comprises the steps of: Step S3.2.1, performing K kinds of perturbation enhancement on to obtain an enhanced poisoning sample set ; wherein, denotes the poisoning sample set after K kinds of perturbation enhancement, denotes the poisoning sample after the kth perturbation enhancement of Step S3.2.2, obtaining the kth perturbation-enhanced sample from the kth perturbation-enhanced sample of formula (10) Splicing the poisoned sample : (10) Step S3.2.3, processing the input into the embedding layer of the kth perturbation to obtain the i-th initial poisoning embedding representation enhanced by the kth perturbation ;​​ Step S3.2.4, when At that time, As The first in Hidden states of each coding layer , and enter the first In each encoding layer, attention mechanisms are utilized to... Perform a linear transformation to obtain the th Generate query vectors in each coding layer , No. Key vectors in each coding layer , No. Value vectors in each coding layer Then, using equation (14), we obtain the first... In each coding layer attention weights Finally, using equation (15), we obtain the first... Hidden states of each coding layer ;in, For the first Three parameters to be learned in each coding layer; (14) In formula (14), T represents transposition; The hidden state of the first encoding layer is obtained using equation (14) : (15) wherein is a layer normalization operation; When the input is input into the first coding layer for processing, so that the hidden state of the first coding layer is output by the first coding layer ;​ Step S3.2.5, the linear classification head pair is processed to obtain a set of backdoor prefix parameters The predicted probability distribution of the lower ;​ Step S3.2.6, calculating backdoor loss with Equations (7) and (15) : (16) In formula (16), denotes the attention score of the jth token to the kth token in the input sequence in the 1th layer; denotes the maximum attention score in the matrix; is a hyperparameter.

7. An electronic device comprising a memory and a processor, characterized in that The memory is configured to store a program supporting the processor to execute the double prefix fine-tuned backdoor attack method of any one of claims 1-6, and the processor is configured to execute the program stored in the memory.

8. A computer-readable storage medium having stored thereon a computer program, characterized in that The computer program, when executed by a processor, performs the steps of the double prefix fine-tuned backdoor attack method of any one of claims 1-6.