Text backdoor attack method based on target label similarity

By acquiring and preprocessing Chinese data sets, using pre-trained language models to calculate target label similarity and injecting triggers, constructing toxic data sets and conducting backdoor training, the problem of high covertness of backdoor attacks in the text field is solved, and model security issues are achieved. effective assessment and attention.

CN118551827APending Publication Date: 2024-08-27GUILIN UNIV OF ELECTRONIC TECH
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410772763.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing technology is difficult to effectively deal with backdoor attacks in the text field. Backdoor attacks are highly concealed and pose a threat to model security, especially in the application of pre-trained models.

Method used

By obtaining and preprocessing the Chinese data set, using the pre-trained language model to train the word embedding model, calculating the target label similarity to inject the trigger, constructing a poisonous data set, and conducting backdoor training on the poisonous data set to evaluate the performance and performance of the backdoor model. Concealment.

Benefits of technology

A new text backdoor attack method is provided, which increases the focus on model security issues. By injecting triggers through target label similarity, a covert and effective backdoor attack is achieved, and the performance and attack success rate of the backdoor model are evaluated.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118551827A
    Figure CN118551827A
Patent Text Reader

Abstract

According to the method, a word embedding technology is used, a word embedding model is trained on a text of a data set, text context information in the whole data set is extracted and modeled, then an attacker defines a target label of backdoor attack, and a text most similar to the target label is found in the text through the word embedding model, so that the backdoor attack is completed. The granularity can be characters or words, meanwhile, the position with the maximum similarity with the target label is set as the position where a backdoor attack trigger is injected, and after a trigger style is selected, the trigger is generated for the selected text and injected to a designated position. And toxic data is constructed, and then the toxic data and the clean data are mixed for backdoor training. Before backdoor training, the pre-training language model is trained, evaluated and tested on the clean data set to obtain clean performance. And finally, finely adjusting the pre-training language model on the toxic data set to obtain clean accuracy under backdoor training, and testing on the toxic test set to obtain an attack success rate for evaluating the concealment and effectiveness of the backdoor attack.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to natural language processing, artificial intelligence and other technical fields, and in particular to a text backdoor attack method based on target label similarity. Background Art

[0002] The security and robustness of deep neural networks is an important research hotspot in the field of deep learning. Previous studies have mainly focused on adversarial attacks, that is, weakening model performance by constructing adversarial samples and exploring corresponding defense measures. However, with the widespread application of pre-trained models, a new type of attack against neural networks, especially pre-trained models, has emerged - backdoor attacks. Backdoor attacks inject hidden backdoors into neural networks, causing them to generate outputs specified by the attacker when processing malicious samples containing triggers (patterns or texts pre-defined by the attacker, etc.).

[0003] Backdoor attacks first appeared in the field of image processing. People found that by embedding a blank pixel or some other difficult-to-find patterns, the model can be misclassified and misidentified. With the gradual deepening of research and the rapid development of the field of natural language processing, the research on backdoor attack methods for text has gradually increased.

[0004] At present, backdoor attacks in the text field are classified into character-level attacks, word-level attacks, and sentence-level attacks according to the granularity of the trigger. Through various means, toxic fragments that are not easily perceived by people are embedded in discrete text domains. Under the condition that the semantics are not changed, the model can generate the specified harmful or wrong behavior expected by the attacker when encountering toxic text with triggers. Therefore, compared with the adversarial samples generated by traditional adversarial attacks that cause the model to behave abnormally, backdoor attacks appear to be more hidden, which may cause great harm to many personal models that use public data platforms to train at this stage, which has attracted the attention and vigilance of a wide range of researchers. Summary of the invention

[0005] The purpose of this invention is to provide a text backdoor attack method based on target label similarity, aiming to explore a new way of backdoor attack in the text field. By extracting the context information of the data set, the location of trigger injection is found, and a specific trigger is injected to produce a backdoor attack effect. This adds a new way to the backdoor attack research in the field of natural language processing. Let more people pay attention to the security issues behind the current model.

[0006] To achieve the above object, the present invention provides a text backdoor attack method based on target label similarity, comprising the following steps:

[0007] Get the Chinese dataset needed to train the language model;

[0008] Preprocess the collected Chinese dataset;

[0009] Use pre-trained language models to train for clean performance;

[0010] Extract text information from the dataset and model it to get a word embedding model;

[0011] The word embedding model is used to calculate the position in the text that has the greatest similarity with the target label and inject predefined triggers to build a poisonous dataset;

[0012] Retrain the pre-trained language model on the poisonous dataset with backdoors;

[0013] Obtain the performance of the backdoor model on the poisoned training and test sets for evaluation.

[0014] In the process of obtaining the data sets required for Chinese natural language processing tasks, we first obtain data sets for various tasks from major mainstream open source platforms, including github, kaggle, etc., and check whether the format of the data set and the labels are complete to obtain the data sets required for Chinese natural language processing tasks.

[0015] The data preprocessing process includes the following steps:

[0016] Normalize the data, remove useless and meaningless characters and words, remove non-standard symbols in the text, etc.

[0017] The preprocessed data set is divided according to a certain ratio.

[0018] Use the pre-trained language model from an open source model platform such as hugging face to perform training, evaluation, and testing on a clean dataset to obtain the initial performance of the pre-trained language model on the clean dataset.

[0019] Then, word2vec is used to perform semantic extraction on the preprocessed complete dataset and modeling is performed based on contextual information to obtain a word embedding model.

[0020] Then, by using the word embedding model obtained above, part of the text in the dataset is traversed to calculate the similarity with the attacker's predefined target label, and the position of the maximum similarity is found. Then, according to the trigger style predefined by the attacker, a trigger is generated and injected to generate poisonous texts one by one in the specified position, and finally a poisonous dataset is obtained and mixed with the clean dataset.

[0021] In order to accurately and effectively evaluate the performance of backdoor attacks, the original pre-trained language model is trained on the poisonous dataset to obtain the backdoor model.

[0022] Finally, the backdoor model trained on the poisonous dataset is evaluated on the clean test set and the poisonous test set respectively, and its clean performance and attack success rate are obtained to evaluate the concealment and effectiveness of the backdoor attack.

[0023] The present invention provides a text backdoor attack method based on target label similarity. A data set of natural language processing related tasks is obtained from a public open source platform, and the data is pre-processed and divided through a series of cleaning measures to evaluate the clean performance of a pre-trained language model. After that, word2vec is used to model the entire data set to extract context information to obtain a word embedding model. Then, part of the data in the data set used to make poisonous data is traversed, and the word embedding model is used to calculate and find the position with the greatest semantic similarity to the target label defined by the attacker, and a predefined trigger style is injected to generate poisonous data for backdoor training. Finally, the same pre-trained language model from the public open source model platform is used for backdoor training, and the concealment and effectiveness of the backdoor attack are evaluated based on the accuracy on the poisonous training set and the poisonous test set. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0025] Figure 1 It is a flow chart of a text backdoor attack method based on target tag similarity of the present invention.

[0026] Figure 2 It is an architecture diagram of a text backdoor attack method based on target label similarity of the present invention.

[0027] Figure 3 It is an architectural diagram of the universal backdoor attack of the present invention. DETAILED DESCRIPTION

[0028] Embodiments of the present invention are described in detail below, examples of which are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, and should not be construed as limiting the present invention.

[0029] See also Figure 1 The present invention proposes a text backdoor attack method based on target label similarity, comprising the following steps:

[0030] S1: Obtain the Chinese data set required for training the language model;

[0031] S2: Preprocess the collected Chinese dataset;

[0032] S3: Use the pre-trained language model to train to get clean performance;

[0033] S4: Extract text information from the dataset and model the word embedding model;

[0034] S5: Use the word embedding model to find the position in the text with the greatest similarity to the target label and inject predefined triggers to build a poisonous dataset;

[0035] S6: Retrain the pre-trained language model on the poisonous dataset with backdoors;

[0036] S7: Obtain the performance of the backdoor model on the poisoned training set and test set for evaluation.

[0037] In the process of obtaining the data sets required for Chinese natural language processing tasks, we first obtain data sets for various tasks from major mainstream open source platforms, including github, kaggle, etc., and check whether the format of the data set and the labels are complete to obtain the data sets required for Chinese natural language processing tasks.

[0038] Use pre-trained language models from open source model platforms such as hugging face to train, evaluate and test on clean datasets to obtain the initial performance of the pre-trained language model on clean datasets. Then use word2vec to perform semantic extraction on the pre-processed complete dataset and model based on context information to obtain a word embedding model.

[0039] Then, by using the word embedding model obtained above, part of the text in the dataset is traversed to calculate the similarity with the attacker's predefined target label, and the position of the maximum similarity is found. Then, according to the trigger style predefined by the attacker, a trigger is generated and injected to generate poisonous texts one by one in the specified position, and finally a poisonous dataset is obtained and mixed with the clean dataset.

[0040] To ensure accurate and effective evaluation of the performance of backdoor attacks, the original pre-trained language model is trained on the poisonous dataset to obtain the backdoor model. Finally, the backdoor model trained on the poisonous dataset is evaluated on the clean test set and the poisonous test set, and its clean performance and attack success rate are obtained to evaluate the concealment and effectiveness of the backdoor attack.

[0041] Furthermore, the present invention is further described in detail with reference to specific embodiments and accompanying drawings:

[0042] See also Figure 2 ,The specific steps of the text backdoor attack method based on target label similarity are as follows:

[0043] Step 1: Obtain data sets related to natural language processing tasks from major mainstream open source platforms.

[0044] Step 2: Normalize the data, remove useless and meaningless characters and words, remove non-standard symbols in the text, etc.

[0045] Step 3: Divide the data and train the clean pre-trained language model to get its clean performance

[0046] Step 4: Modeling is performed on the dataset to extract contextual information from the dataset and train a word embedding model. Then, the filtered data is traversed and calculated to find the location with the greatest semantic similarity to the attacker's target label and inject a predefined trigger to generate a poisonous dataset.

[0047] Step 5: Backdoor the pre-trained language model on the poisonous dataset to obtain the backdoor model, and evaluate its concealment and effectiveness on the poisonous training set and test set.

[0048] Further,

[0049] The overall architecture of the backdoor attack is as follows Figure 3 As shown, the specific steps are explained in combination with the schematic diagram:

[0050] Step 1: Randomly select a certain proportion of data from the data set.

[0051] Step 2: The attacker injects a specific trigger pattern into the selected data to generate poisonous data, and then injects the poisonous data into the original clean data.

[0052] Step 3: Perform backdoor training on poisonous data and transfer the trigger to the downstream task, so that in the downstream task, when the input text has a specific trigger pattern, the model will produce specific errors or harmful behaviors.

[0053] What is disclosed above is only a preferred embodiment of the present invention, and it certainly cannot be used to limit the scope of rights of the present invention. Ordinary technicians in this field can understand that all or part of the processes of the above embodiment and equivalent changes made according to the claims of the present invention still fall within the scope of the invention.

Claims

1. A text backdoor attack method based on target label similarity, characterized in that: The following steps are involved: Get the Chinese dataset needed to train the language model; Preprocess the collected Chinese dataset; Use pre-trained language models to train for clean performance; Extract text information from the dataset and model it to get a word embedding model; The word embedding model is used to calculate the position in the text that has the greatest similarity with the target label and inject predefined triggers to build a poisonous dataset; Retrain the pre-trained language model on the poisonous dataset with backdoors; Obtain the performance of the backdoor model on the poisoned training and test sets for evaluation.

2. The text backdoor attack method based on target label similarity as claimed in claim 1, characterized in that: In the process of obtaining the data sets required for Chinese natural language processing tasks, we first obtain data sets for various tasks from major mainstream open source platforms, including github, kaggle, etc., and check whether the format of the data set and the labels are complete to obtain the data sets required for Chinese natural language processing tasks.

3. The text backdoor attack method based on target label similarity as claimed in claim 2, characterized in that: The data preprocessing process includes the following steps: Normalize the data, remove useless and meaningless characters and words, remove non-standard symbols in the text, etc. The preprocessed data set is divided according to a certain ratio.

4. The text backdoor attack method based on target label similarity as claimed in claim 1, characterized in that: Use the pre-trained language model from an open source model platform such as hugging face to perform training, evaluation, and testing on a clean dataset to obtain the initial performance of the pre-trained language model on the clean dataset.

5. The text backdoor attack method based on target label similarity as claimed in claim 1, characterized in that: The word embedding model is obtained by using word2vec to perform semantic extraction on the preprocessed complete dataset and modeling based on contextual information.

6. The text backdoor attack method based on target label similarity as claimed in claim 1, characterized in that: Use the word embedding model obtained above to traverse some texts in the dataset and calculate the similarity with the attacker's predefined target label, and find the position with the maximum similarity. Then, generate triggers according to the attacker's predefined trigger style and inject them into the specified positions to generate poisonous texts one by one. Finally, the poisonous dataset is obtained and mixed with the clean dataset.

7. The text backdoor attack method based on target label similarity as claimed in claim 1, characterized in that: In order to accurately evaluate the performance of backdoor attacks, the original pre-trained language model is then backdoor trained on the poisonous dataset to obtain the backdoor model.

8. The text backdoor attack method based on target label similarity as claimed in claim 1, characterized in that: The backdoor model trained on the poisonous dataset is evaluated on the clean test set and the poisonous test set respectively, and its clean performance and attack success rate are obtained to evaluate the concealment and effectiveness of the backdoor attack.

Citation Information

Cited By

  • Explanatable recommended agent backdoor attack method for large language model

    CN119885181A

  • Trigger word recognition and positioning system and method based on BIO sequence labeling

    CN121525701A

  • A system and method for trigger word recognition and positioning based on BIO sequence labeling

    CN121525701B