Pre-training language model backdoor detection method and device and electronic equipment

By performing model twin processing and trainable feature insertion on the pre-trained language model, the problem of difficulty in ensuring the security of the pre-trained model for large language models is solved, and the effectiveness and efficiency of backdoor detection are improved.

CN118568206AActive Publication Date: 2024-08-30ZHEJIANG E COMMERCE BANK CO LTD

Patent Information

Application Number
CN202411052640.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-01
Publication Date
2024-08-30
Estimated Expiration
2044-08-01

AI Technical Summary

Technical Problem

It is difficult to ensure the security of pre-trained models of existing large language models. It is difficult for users to train independently and they rely on models provided by third parties. There are backdoor detection problems.

Method used

By performing model twinning processing on the target pre-trained language model, the target model and auxiliary model are generated, and trainable feature insertion is performed on the backdoor test text. Model test training is performed through the target output features and auxiliary output features, and triggers are found to determine backdoor detection. information.

Benefits of technology

Effectively detect and determine the backdoor in the pre-trained language model, improve the security and reliability of the model, reduce the detection time overhead, and realize the security verification of the pre-trained model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118568206A
    Figure CN118568206A
Patent Text Reader

Abstract

The invention discloses a pre-training language model backdoor detection method and device and electronic equipment, and the method comprises the steps: carrying out the model twinning processing of a target pre-training language model, and obtaining a target model and an auxiliary model; inputting the backdoor test text into a target model, performing trainable feature insertion on the target model, and determining a target output feature output by the target model for the backdoor test text; determining auxiliary output features output by the auxiliary model for the backdoor test text; and performing model test training on the target model based on the target output feature and the auxiliary output feature to obtain a model test training result, and determining backdoor detection information of the target pre-training language model based on the model test training result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and in particular to a method, device and electronic device for detecting backdoors in a pre-trained language model. Background Art

[0002] In recent years, large language models have performed well in general language processing, making them widely used. Given the increasing number of parameters and scale of large language models, it is often difficult for users to independently train a large language model from scratch. Instead, they rely on pre-trained language models provided by third parties for further training to obtain the corresponding large language model. However, the security of pre-trained language models provided by third parties is difficult to guarantee. Summary of the invention

[0003] This specification provides a method, device and electronic device for detecting backdoors in a pre-trained language model. The technical solution is as follows: In a first aspect, this specification provides a method for detecting backdoors in a pre-trained language model, the method comprising: Perform model twinning processing on the target pre-trained language model to obtain the target model and the auxiliary model; Inputting the backdoor test text into the target model, inserting trainable features into the target model, and determining the target output features output by the target model for the backdoor test text; and determining the auxiliary output features output by the auxiliary model for the backdoor test text; Model testing training is performed on the target model based on the target output feature and the auxiliary output feature to obtain a model testing training result, and backdoor detection information of the target pre-trained language model is determined based on the model testing training result.

[0004] In a second aspect, this specification provides a pre-trained language model backdoor detection device, the device comprising: The preprocessing module is suitable for performing model twin processing on the target pre-trained language model to obtain the target model and the auxiliary model; a processing module adapted to input the backdoor test text into the target model, insert trainable features into the target model, determine the target output features output by the target model for the backdoor test text; and determine the auxiliary output features output by the auxiliary model for the backdoor test text; The backdoor detection module is suitable for performing model test training on the target model based on the target output feature and the auxiliary output feature to obtain a model test training result, and determining the backdoor detection information of the target pre-trained language model based on the model test training result.

[0005] In a third aspect, the present specification provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.

[0006] In a fourth aspect, the present specification provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.

[0007] In a fifth aspect, the present specification provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded by a processor and executes any one of the method steps described above.

[0008] The beneficial effects brought about by the technical solutions provided in some embodiments of the present specification include at least: obtaining a target model and an auxiliary model by performing model twin processing on the target pre-trained language model, then inputting the backdoor test text into the target model, inserting trainable features into the target model, and determining the target output features output by the target model for the backdoor test text; and determining the auxiliary output features output by the auxiliary model for the backdoor test text. Since the trainable features are inserted into the target model, the target output features corresponding to the target model and the auxiliary output features corresponding to the auxiliary model are different.

[0009] When the trainable feature or the adjusted trainable feature is the trigger word embedding feature of the word embedding layer corresponding to the trigger, the feature distance between the target output feature and the auxiliary output feature is far; when the trainable feature or the adjusted trainable feature is the trigger word embedding feature of the word embedding layer corresponding to the trigger, the feature distance between the target output features output by different backdoor test texts is close. Therefore, the target model is trained by model testing through the target output feature and the auxiliary output feature to find the corresponding trigger, thereby obtaining the model testing training result, and finally determining the backdoor detection information of the target pre-trained language model based on the model testing training result. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] In order to more clearly illustrate the technical solutions in this specification or 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 this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0011] Figure 1 A scenario diagram of a pre-trained language model backdoor detection system provided in this specification; Figure 2A flowchart of a pre-trained language model backdoor detection method is provided for one or more embodiments of this specification; Figure 3 A schematic diagram of a process for obtaining a target model and an auxiliary model is provided for one or more embodiments of this specification; Figure 4 A schematic diagram of a process for determining target output features output by a target model for a backdoor test text is provided for one or more embodiments of this specification; Figure 5 A flowchart of inserting trainable features into word embedding features of backdoor test text is provided for one or more embodiments of this specification; Figure 6 A schematic diagram of a process for determining backdoor detection information of a target pre-trained language model is provided for one or more embodiments of this specification; Figure 7 A schematic diagram of a process for determining model loss information based on target output features and auxiliary output features is provided for one or more embodiments of this specification; Figure 8 A schematic diagram of a process for updating a backdoor test text is provided for one or more embodiments of this specification; Fig. 9 A schematic diagram of a process for determining backdoor detection information of a target pre-trained language model is provided for one or more embodiments of this specification; Fig.10 A schematic diagram of a process for performing information filtering processing on a model loss information set is provided for one or more embodiments of this specification; Fig.11 Another flowchart of backdoor detection of a pre-trained language model is provided for one or more embodiments of this specification; Fig.12 A schematic diagram of the structure of a pre-trained language model backdoor detection device provided in this specification; Fig.13 A schematic diagram of the structure of an electronic device provided in this manual; Fig.14 A schematic diagram of the operating system and user space provided for this manual; Fig.15 for Fig.14 The architecture diagram of the Android operating system; Fig.16 for Fig.14 Architecture diagram of the IOS operating system. DETAILED DESCRIPTION

[0012] The following will be combined with the drawings in this specification to clearly and completely describe the technical solutions in this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0013] In the description of this specification, it should be understood that the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In the description of this specification, it should be noted that, unless otherwise clearly specified and limited, "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally also includes steps or units that are not listed, or optionally also includes other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in this specification can be understood by specific circumstances. In addition, in the description of this specification, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are an "or" relationship.

[0014] The present specification is described in detail below with reference to specific embodiments.

[0015] See also Figure 1 , Figure 1 This is a scenario diagram of a pre-trained language model backdoor detection system provided in this manual. Figure 1 As shown, the pre-trained language model backdoor detection system may include at least a client cluster and a service platform 100.

[0016] The client cluster may include at least one client, such as Figure 1 As shown, it specifically includes client 1 corresponding to user 1, client 2 corresponding to user 2, ..., client n corresponding to user n, where n is an integer greater than 0.

[0017] Each client in the client cluster may be an electronic device with communication function, including but not limited to: wearable device, handheld device, personal computer, tablet computer, vehicle-mounted device, smart phone, computing device or other processing device connected to a wireless modem, etc. Electronic devices may be called different names in different networks, such as: user equipment, access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication device, user agent or user device, cellular phone, cordless phone, personal digital assistant (PDA), electronic devices in 5G network or future evolution network, etc.

[0018] The service platform 100 can be a separate server device, such as a rack-mounted, blade, tower, or cabinet-mounted server device, or a workstation, mainframe computer, or other hardware device with strong computing power; it can also be a server cluster composed of multiple servers, and the servers in the service cluster can be composed in a symmetrical manner, wherein each server has equivalent functions and status in the transaction link, and each server can provide services to the outside independently, and the independent service can be understood as not requiring the assistance of other servers.

[0019] In one or more embodiments of the present specification, the service platform 100 may establish a communication connection with at least one client in the client cluster, and complete data interaction during the pre-trained language model backdoor detection process based on the communication connection, such as online transaction data interaction. For example, the service platform 100 may push content to the client based on the backdoor detection information obtained by the pre-trained language model backdoor detection method of the present specification; for example, the service platform 100 may obtain backdoor test data from the client, such as backdoor test text.

[0020] It should be noted that the service platform 100 and at least one client in the client cluster establish a communication connection through a network for interactive communication, wherein the network can be a wireless network or a wired network, the wireless network includes but is not limited to a cellular network, a wireless local area network, an infrared network or a Bluetooth network, and the wired network includes but is not limited to Ethernet, a universal serial bus (USB) or a controller local area network. In one or more embodiments of the specification, technologies and / or formats including Hyper Text Mark-up Language (HTML), Extensible Markup Language (XML), etc. are used to represent data (such as a target compressed package) exchanged through the network. In addition, conventional encryption technologies such as Secure Socket Layer (SSL), Transport Layer Security (TLS), Virtual Private Network (VPN), Internet Protocol Security (IPsec), etc. can also be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above data communication technologies.

[0021] The pre-trained language model backdoor detection system embodiment provided in this specification belongs to the same concept as the pre-trained language model backdoor detection method in one or more embodiments. The execution subject corresponding to the pre-trained language model backdoor detection method involved in one or more embodiments of the specification can be the above-mentioned service platform 100; the execution subject corresponding to the pre-trained language model backdoor detection method involved in one or more embodiments of the specification can also be the electronic device corresponding to the client, which is specifically determined based on the actual application environment. The implementation process of the pre-trained language model backdoor detection system embodiment can be detailed in the following method embodiment, which will not be repeated here.

[0022] based on Figure 1 The scenario diagram is shown, and the pre-trained language model backdoor detection method provided by one or more embodiments of this specification is introduced in detail below.

[0023] See also Figure 2 , Figure 2A flowchart of a pre-trained language model backdoor detection method is provided for one or more embodiments of this specification. The method can be implemented by a computer program and can be run on a pre-trained language model backdoor detection device based on a von Neumann system. The computer program can be integrated into an application or run as an independent tool application. The pre-trained language model backdoor detection device can be a service platform.

[0024] Specifically, the pre-trained language model backdoor detection method includes: S202: Perform model twinning processing on the target pre-trained language model to obtain a target model and an auxiliary model.

[0025] Among them, the target pre-trained language model is an artificial intelligence model that is trained on a large amount of text data using an unsupervised method and can understand and generate natural language. The target pre-trained language model is used to extract and learn the features of text data. After the target pre-trained language model is processed by model twinning, two identical models are obtained, namely the target model and the auxiliary model. In order to detect whether there is a backdoor in the target pre-trained language model, the target pre-trained language model is processed by model twinning. At this time, the model parameters in the target pre-trained language model remain unchanged, thereby obtaining the same target model and auxiliary model, so as to determine whether there is a backdoor in the target pre-trained language model through the target model and the auxiliary model. It should be noted that the target pre-trained language model includes but is not limited to the BERT (Bidirectional Encoder Representations from Transformers) model or an encoder model similar to BERT, as well as decoder models such as GPT (Generative Pre-trained Transformer), and the BART model (Bidirectional Long Short-Term Memory) seq-to-seq model that includes an encoder part. Of course, the application areas of these models need to be the natural language understanding task field.

[0026] In addition, the model twin processing includes at least two operations: model parameter freezing processing and model replication. When the target pre-trained language model is subjected to model twin processing, the target pre-trained language model can be first replicated to obtain two initial models, and then the two initial models are subjected to model parameter freezing processing to obtain a target model and an auxiliary model. Of course, when the target pre-trained language model is subjected to model twin processing, the target pre-trained language model can also be subjected to model parameter freezing processing, and then the target model obtained after the model parameter freezing processing is replicated to obtain a target model and an auxiliary model. It should be noted that the model parameter freezing processing is used to set all model parameters in the model to fixed values, and these parameters are no longer updated according to the training data.

[0027] S204: Input the backdoor test text into the target model, insert trainable features into the target model, determine the target output features output by the target model for the backdoor test text; and determine the auxiliary output features output by the auxiliary model for the backdoor test text.

[0028] Among them, the backdoor test text may not have a label. The backdoor test text may be crawled and screened from a web page based on crawler technology. For example, corpus data may be crawled from online encyclopedias such as Baidu Encyclopedia and Baidu Encyclopedia. The corpus data may include different types of text content such as document text, dialogue, articles, and movie scripts. After the corpus data is obtained, the corpus data is screened and cleaned, such as removing the title paragraph and empty paragraph in the corpus data and removing the spaces at the beginning and end of the text.

[0029] For example, the Wiki Text dataset provided by Hugging Face can be used. Hugging Face is an artificial intelligence community that provides a model library, a dataset library, and some artificial intelligence tools. The Wiki Text dataset is a collection of more than 1.8 million text data extracted from verified excellent articles and selected articles on a certain encyclopedia. The Wiki Text dataset needs to be cleaned after downloading. The title paragraphs and empty paragraphs in the dataset are removed, and the spaces at the beginning and end of the text are removed. Then, 2,000 samples are randomly selected from the cleaned dataset as the text set of the backdoor test text. Each sample can correspond to a backdoor test text.

[0030] After the backdoor test text is input into the target model, the word embedding layer of the target model processes the backdoor test text to generate corresponding word embedding features. The word embedding layer is used to map the split words in the backdoor test text to the vector space to obtain the corresponding word embedding features. The trainable features are then inserted into the word embedding features. Here, the trainable features can be inserted into the word embedding features at random positions in the word embedding features.

[0031] Optionally, inserting trainable features into the target model includes: obtaining trainable features through an automated insertion program and randomly inserting the trainable features into word embedding features corresponding to the backdoor test text.

[0032] Optionally, inserting trainable features into the target model includes: randomly obtaining words from the dictionary corresponding to the target pre-trained language model and generating trainable features corresponding to the words, and then randomly inserting the trainable features into the word embedding features corresponding to the backdoor test text. The dictionary corresponding to the target pre-trained language model may be a vocabulary table or vocabulary database used by the target pre-trained language model. The trainable features corresponding to the words may be the target word embedding features corresponding to the word after passing through the word embedding layer.

[0033] The trainable features can be adjusted in subsequent model test training to perform fuzzy testing by adjusting the trainable features, and the adjusted trainable features can be as close as possible to the trigger word embedding features of the word embedding layer corresponding to the trigger. Of course, the adjusted trainable features may also be the same as the trigger word embedding features of the word embedding layer corresponding to the trigger, that is, the adjusted trainable features are the trigger word embedding features of the word embedding layer corresponding to the trigger.

[0034] It should be understood that the trigger is a specific word or phrase that triggers the backdoor. Fuzz testing is a testing method that automatically or semi-automatically inputs abnormal or random data into the system to monitor errors, security vulnerabilities or crashes in software.

[0035] After inserting trainable features into the target model, determine the target output features output by the target model for the backdoor test text, and simultaneously determine the auxiliary output features output by the auxiliary model for the backdoor test text. Since the trainable features are inserted into the target model, the target output features corresponding to the target model and the auxiliary output features corresponding to the auxiliary model are different. It should be understood that in order to avoid deploying the target model and the auxiliary model at the same time and to reduce the amount of computation, the auxiliary output features output by the auxiliary model for the backdoor test text can be obtained and determined in advance, and can be directly called when the auxiliary output features are needed later.

[0036] In a backdoor attack on a target pre-trained language model, the attacker maps the input with a backdoor (trigger) to a specific output in order to make the backdoor work on multiple downstream tasks corresponding to the pre-trained language model. If this abnormal output can be found, it means that the target pre-trained language model contains a backdoor. When the input contains a trigger, the output of the target pre-trained language model containing the backdoor has the following characteristics: first, the feature distance from the benign sentence is far away; second, the feature distance between different sentences containing the same trigger becomes closer.

[0037] Therefore, when the trainable feature or the adjusted trainable feature is the trigger word embedding feature of the word embedding layer corresponding to the trigger, the feature distance between the target output feature and the auxiliary output feature is farther; when the trainable feature or the adjusted trainable feature is the trigger word embedding feature of the word embedding layer corresponding to the trigger, the feature distance between the target output features output by different backdoor test texts is closer.

[0038] S206: Perform model test training on the target model based on the target output features and the auxiliary output features to obtain a model test training result, and determine the backdoor detection information of the target pre-trained language model based on the model test training result.

[0039] After obtaining the target output features corresponding to the target model and the auxiliary output features corresponding to the auxiliary model, the target model is tested and trained by using the target output features and the auxiliary output features. For example, a loss function is constructed by using the target output features and the auxiliary output features, and the target model is tested and trained based on the loss function value of the loss function, so that the trainable features in the target model are adjusted so that the adjusted trainable features can be as close as possible to the trigger word embedding features of the word embedding layer corresponding to the trigger, or the adjusted trainable features are the trigger word embedding features of the word embedding layer corresponding to the trigger.

[0040] At the same time, the model test training results are used to characterize the feature distances between the target output features and the auxiliary output features, as well as the feature distances between the target output features output by different backdoor test texts. Thus, by obtaining the model test training results corresponding to the model test training, the backdoor detection information of the target pre-trained language model can be effectively determined.

[0041] In the embodiments provided in this specification, a target model and an auxiliary model are obtained by performing model twin processing on a target pre-trained language model, and then a backdoor test text is input into the target model, and trainable features are inserted into the target model to determine the target output features output by the target model for the backdoor test text; and the auxiliary output features output by the auxiliary model for the backdoor test text are determined. Since the trainable features are inserted into the target model, the target output features corresponding to the target model and the auxiliary output features corresponding to the auxiliary model are different.

[0042] When the trainable feature or the adjusted trainable feature is the trigger word embedding feature of the word embedding layer corresponding to the trigger, the feature distance between the target output feature and the auxiliary output feature is far; when the trainable feature or the adjusted trainable feature is the trigger word embedding feature of the word embedding layer corresponding to the trigger, the feature distance between the target output features output by different backdoor test texts is close. Therefore, the target model is trained by model testing through the target output feature and the auxiliary output feature to find the corresponding trigger, thereby obtaining the model testing training result, and finally determining the backdoor detection information of the target pre-trained language model based on the model testing training result.

[0043] In addition, this solution does not require additional model training except for model testing and training for the target model. Since abnormal features will definitely produce abnormal output features, but abnormal inputs will not necessarily produce abnormal output features, the related technology requires additional steps to identify abnormal inputs, which reduces the time cost of this solution by 50% compared with the related technology.

[0044] See also Figure 3 , Figure 3 A schematic diagram of a process for obtaining a target model and an auxiliary model is provided for one or more embodiments of this specification. Figure 3 As shown, in S202, the target pre-trained language model is subjected to model twinning processing to obtain a target model and an auxiliary model, including: S302: Freeze model parameters of the target pre-trained language model to obtain a target model.

[0045] Among them, after the target pre-trained language model is subjected to model parameter freezing, all model parameters in the target pre-trained language model are frozen, that is, all model parameters are fixed values, and the model parameters will not change even after model training. This ensures that the target model obtained after the model parameter freezing process will not change its own model parameters in subsequent model test training, but will adjust the trainable features.

[0046] Since the model parameters in the target model are all in a frozen state, the backdoor corresponding to the target pre-trained language model can be determined by searching the backdoor of the target model.

[0047] S304: Copy the target model to obtain an auxiliary model.

[0048] After obtaining the target model, the target model is copied to obtain the auxiliary model. It should be understood that since the auxiliary model is obtained by copying the target model, the auxiliary model and the target model are identical. At the same time, since all model parameters in the target model are frozen, all model parameters in the auxiliary model are also frozen.

[0049] In the embodiments provided in this specification, a target model is obtained by freezing the model parameters of a target pre-trained language model, and an auxiliary model is obtained by copying the target model, thereby ensuring that the target model obtained after the model parameter freezing process will not change its own model parameters in subsequent model testing and training. Therefore, the auxiliary model can be used to search for the backdoor of the target model in which the trainable features are inserted, thereby determining the backdoor corresponding to the target pre-trained language model.

[0050] See also Figure 4 , Figure 4 A flowchart of determining target output features output by a target model for backdoor test text is provided for one or more embodiments of this specification. Figure 4 As shown, in S204, the backdoor test text is input into the target model, trainable features are inserted into the target model, and the target output features output by the target model for the backdoor test text are determined, including: S402: Input the backdoor test text into the target model, determine the word embedding features corresponding to the backdoor test text based on the target model, insert trainable features into the word embedding features of the backdoor test text, and obtain the target word embedding features.

[0051] Among them, after the backdoor test text is input into the target model, it is preprocessed based on the Tokenizer in the target model. Tokenizer is a program or algorithm that decomposes text into single characters or tags (tokens). The backdoor test text is divided into tokens based on the Tokenizer in the target model. Each token is the smallest unit that the target model can recognize, usually a word. The Tokenizer will also add two special tokens [CLS] and [SEP] at the beginning and end of a sentence respectively. The number of dimensions of the trainable feature is the same as the number of dimensions of the word embedding feature, that is, the number of dimensions of the trainable feature is the same as the number of dimensions of the output feature of the word embedding layer. The length of the trainable feature can be set to 7, because the trigger of most language model backdoors is a word, and a word can be decomposed into up to 7 tokens. The trainable feature can also understand the trainable embedding parameters for the output feature of the word embedding layer.

[0052] [CLS] is used as the input representation of the classification task, and the output vector corresponding to the symbol is used as the semantic representation of the text for text classification. The generated token sequence will first pass through the word embedding layer of the target model and be converted into corresponding word embedding features. The target model will add a position code to each of these word embedding features to integrate the position information of the word. The position code is a vector that corresponds one-to-one to the position of the word and is added to the word embedding feature of the corresponding position. The insertion of the trainable feature of this embodiment occurs before the position code is added and after the word embedding layer outputs the word embedding feature. At the same time, the position of the trainable feature insertion is random.

[0053] After determining the word embedding features corresponding to the backdoor test text and inserting the trainable features into the word embedding features corresponding to the backdoor test text, the inserted trainable features and the word embedding features together constitute the target word embedding features.

[0054] See also Figure 5 , Figure 5 A flowchart of inserting trainable features into word embedding features of backdoor test text is provided for one or more embodiments of this specification. Figure 5 As shown in the figure, the backdoor test text is "My dog ​​is cute", and the word embedding feature corresponding to the backdoor test text is "E 我 E 的 E 狗 E 很 E 可 E 爱 ", before encoding the word embedding features corresponding to the backdoor test text, insert the trainable feature "E" into the random position of the word embedding feature. A ” and “E B ", and then positionally encode the obtained target word embedding features, such as Figure 5 As shown, the position code includes E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, where E0 and E9 are respectively [CLS] and E [SEP] correspond.

[0055] S404: Control the target model to perform model processing based on the target word embedding feature to obtain the target output feature output by the target model for the target word embedding feature.

[0056] After the target word embedding feature is obtained, the target word embedding feature is further processed based on the target model, thereby obtaining the target output feature for the target word embedding feature. When there is an embedding feature corresponding to the trigger in the target word embedding feature, the target output feature is usually a specific output.

[0057] In this specification, by inserting trainable features into the word embedding features of the backdoor test text, the target output features of the target model for the target word embedding features containing the trainable features are obtained, so that the trigger can be detected and tested by means of fuzzy testing, thereby providing a reference for backdoor detection of the pre-trained language model.

[0058] See also Figure 6 , Figure 6 A schematic diagram of a process for determining backdoor detection information of a target pre-trained language model is provided for one or more embodiments of this specification. Figure 6 As shown, in S206, the target model is tested and trained based on the target output features and the auxiliary output features to obtain a model test training result, and the backdoor detection information of the target pre-trained language model is determined based on the model test training result, including: S602: Determine model loss information based on the target output features and the auxiliary output features, and adjust the inserted trainable features based on the model loss information.

[0059] The model loss information is used to characterize the feature distance between the target output feature and the auxiliary output feature, as well as the feature distance between the target output feature output by different backdoor test texts. The trainable features inserted into the word embedding feature are adjusted through the model loss information, thereby continuously expanding the feature distance between the target output feature and the auxiliary output feature, and continuously reducing the feature distance between the target output feature output by different backdoor test texts.

[0060] Thereby, the trainable feature can be as close as possible to the trigger word embedding feature of the word embedding layer corresponding to the trigger, or the adjusted trainable feature can be the trigger word embedding feature of the word embedding layer corresponding to the trigger.

[0061] Exemplarily, the trainable features can be derivatized based on the total model loss of the target model, and the inserted trainable features can be adjusted based on the gradient obtained by the derivation. In order to improve the convergence of the target model in this embodiment, an adaptive learning rate mechanism is adopted. When updating the trainable features by the gradient descent method, the initial learning rate is set to 2e -3 , this learning rate is larger than the value in the general BERT training. The purpose is to allow the target model to quickly find the convex hull during the model training process to improve the efficiency of model training. When it is detected that the average value of the gradient backpropagated to the trainable feature is greater than 5e -3 , and then set the learning rate to 2e -5 , thereby improving the accuracy of model training.

[0062] S604: Execute the step of determining the target output features output by the target model for the backdoor test text until the target model completes model detection training.

[0063] After adjusting the inserted trainable features, the target output features output by the target model for the backdoor test text are determined again; and the auxiliary output features output by the auxiliary model for the backdoor test text are determined; and the model loss information is determined based on the target output features and the auxiliary output features, and the inserted trainable features are adjusted based on the model loss information, and it is determined whether the target model has completed the model detection training. When the target model has not completed the model detection training, the step of determining the target output features output by the target model for the backdoor test text is performed again until the target model completes the model detection training; when the target model completes the model detection training, S506 is executed. It should be understood that when the target model completes the model detection training, the target model converges.

[0064] S606: Obtain target model loss information when the target model completes model detection training, determine the model test training result based on the target model loss information, and determine the backdoor detection information of the target pre-trained language model based on the model test training result.

[0065] Among them, when the target model completes model detection training, the model loss parameter values ​​of the corresponding target model loss information have converged or the target model has undergone at least 4 rounds of training. At this time, the model loss parameter values ​​corresponding to the target model loss information can accurately represent the maximum feature distance between the target output features and the auxiliary output features and the minimum feature distance of the target output features output by different backdoor test texts, thereby quantifying whether there is a backdoor in the target pre-trained language model.

[0066] Therefore, the model test training results can be determined through the target model loss information, and the backdoor detection information of the target pre-trained language model can be determined through the model test training results. That is, it is determined whether the target pre-trained language model has a backdoor.

[0067] This solution adopts an early stopping mechanism. After the target model has been trained for at least 4 rounds, it will detect whether the model has converged. If the model has not converged, the current cycle will be terminated, and trainable features will be regenerated to enter the next cycle.

[0068] In the embodiments provided in this specification, the inserted trainable features are adjusted by the model loss information determined by the target output features and the auxiliary output features, and then the target output features are updated again, so that the currently inserted trainable features are adjusted again by the new model loss information determined by the updated target output features and the auxiliary output features, until the target model completes the model detection training. When the target model completes the model detection training, the model loss parameter values ​​of the corresponding target model loss information have converged. At this time, the model loss parameter values ​​corresponding to the target model loss information can accurately characterize the maximum feature distance between the target output features and the auxiliary output features and the minimum feature distance of the target output features output by different backdoor test texts, thereby quantifying whether the target pre-trained language model has a backdoor.

[0069] See also Figure 7 , Figure 7 A schematic diagram of a process for determining model loss information based on target output features and auxiliary output features is provided for one or more embodiments of this specification. Figure 7 As shown, in S602, the model loss information is determined based on the target output feature and the auxiliary output feature, including: S702: Determine a distance loss term based on the target output feature and the auxiliary output feature.

[0070] Among them, the corresponding distance loss term can be determined based on the target output feature and the auxiliary output feature corresponding to each backdoor test text. Based on the distance loss term, the Euclidean distance of the target output feature and the auxiliary output feature corresponding to each backdoor test text can be determined, and the negative of the average value of the Euclidean distance corresponding to all the backdoor test texts can be determined.

[0071] In the embodiment provided in this specification, determining the distance loss term based on the target output feature and the auxiliary output feature in S602 includes: The target output feature and the auxiliary output feature are calculated using the first formula to obtain the distance loss term; The first calculation formula satisfies the following formula: ; Where N is the total number of backdoor test texts and N is a positive integer. is the distance loss term, Output the target feature corresponding to the x-th backdoor test text, is the auxiliary output feature corresponding to the x-th backdoor test text, MSE is the mean square error function, Used for calculation and The Euclidean distance between .

[0072] The total number of backdoor test texts is N. Each backdoor test text can be numbered or sorted to determine the sequence number of each backdoor test text. For example, when the sequence number of the backdoor test text is x, it is the xth backdoor test text.

[0073] It is easy to understand that the distance loss value corresponding to the distance loss term is used to characterize the Euclidean distance between the target output feature and the auxiliary output feature. When the feature distance between the target output feature and the auxiliary output feature is longer, the Euclidean distance between the target output feature and the auxiliary output feature is longer; when the feature distance between the target output feature and the auxiliary output feature is closer, the Euclidean distance between the target output feature and the auxiliary output feature is closer. Since the backdoor test text containing the trigger is far from the features of the benign sentence, the distance loss term is used to increase the feature distance between the target output feature and the auxiliary output feature to detect the trigger.

[0074] S704: Determine a diversity loss item based on the features of each dimension in the target output features.

[0075] Among them, the diversity loss term can be determined based on the features of each dimension in the target output features corresponding to each backdoor test text. Based on the diversity loss term, the features of the same dimension in the target output features corresponding to each backdoor test text can be spliced, and then the Shannon entropy of the target spliced ​​features corresponding to each dimension is determined, and the negative value of the average value corresponding to the total number of dimensions is calculated.

[0076] In the embodiment provided in this specification, in S704, the diversity loss item is determined based on the features of each dimension in the target output feature, including: The target output features corresponding to all backdoor test texts are concatenated by dimension features to obtain target concatenated features, and the diversity loss term is obtained by using the second calculation formula based on the target concatenated features; The second calculation formula satisfies the following formula: ; Among them, B is the total dimension of the target output feature, is the diversity loss term, is the Shannon entropy, The target concatenation feature corresponding to the y-th dimension of the target output feature corresponding to all backdoor test texts, B ≥ y ≥ 1.

[0077] Concatenate the features corresponding to the yth dimension in the target output features corresponding to all backdoor test texts to obtain the target concatenation features corresponding to the yth dimension. , target splicing features The number of dimensions is N. Here, the feature concatenation of the features corresponding to the yth dimension in the target output features corresponding to all the backdoor test texts can be implemented based on the Stack function, which refers to the function used to concatenate the same dimensional features of a set of vectors in a new dimension.

[0078] The diversity loss term is used to reduce the differences between the features corresponding to the same dimension in the target output features corresponding to all backdoor test texts, so that all target output features of all backdoor test texts are as similar as possible. Since the distance between different backdoor test texts containing the same trigger will become closer, the trigger can be detected.

[0079] S706: Determine the total model loss for the target model based on the distance loss term and the diversity loss term, and obtain model loss information based on the distance loss term, the diversity loss term and the total model loss.

[0080] Among them, the total model loss for the target model is determined based on the distance loss term and the diversity loss term, including: The distance loss term and the diversity loss term are calculated using the third formula to obtain the total model loss of the target model; The third calculation formula satisfies the following formula: ; in, is the total model loss of the target model, is the weight of the diversity loss term.

[0081] After obtaining the distance loss term, the diversity loss term and the total model loss, the model loss information is determined based on the distance loss term, the diversity loss term and the total model loss. The relative weight between the distance loss term and the diversity loss term can be balanced, and the value in this embodiment can be 1.0.

[0082] In the embodiments provided in this specification, when the total model loss corresponding to the total model loss converges, the target model completes model detection training. At this time, when the total model loss corresponding to the total model loss reaches the minimum, the feature distance between the target output feature and the auxiliary output feature is made as large as possible, and the target output features corresponding to different backdoor test texts are as close as possible, thereby effectively realizing the detection of triggers.

[0083] See also Figure 8 , Figure 8 A schematic diagram of a process for updating a backdoor test text is provided for one or more embodiments of this specification. Figure 8 As shown, after obtaining the target model loss information when the target model completes the model detection training in S606, it also includes: S802: Record the number of model training completions of the current model detection training, and detect whether the number of model training completions is greater than or equal to a preset number.

[0084] Among them, when the target model completes the model detection training for the first time, the corresponding model training completion number is 1. After the trainable features are adjusted later, each time the model detection training is completed, the corresponding model training completion number is increased by one, thereby recording the model training completion number of the current model detection training, and then comparing the model training completion number with the preset number to determine the relative size of the model training completion number and the preset number. The preset number can be set based on specific needs and is not limited here. For example, the preset number can be 30.

[0085] S804: If not, then update the backdoor test text to obtain the next backdoor test text, use the next backdoor test text as the backdoor test text and execute the step of inputting the backdoor test text into the target model.

[0086] When the number of completed model training times is less than the preset number, the backdoor test text is updated to obtain the next backdoor test text. Specifically, a batch of backdoor test texts can be extracted from the text set of the backdoor test text as the next backdoor test text, and then the next backdoor test text is used as the backdoor test text.

[0087] And execute the steps of inputting the backdoor test text into the target model, inserting trainable features into the target model, and determining the target output features output by the target model for the backdoor test text; and determining the auxiliary output features output by the auxiliary model for the backdoor test text in S204; And executing the step of determining model loss information based on the target output feature and the auxiliary output feature in S602, and adjusting the inserted trainable feature based on the model loss information; and executing the step of determining the target output features output by the target model for the backdoor test text in S604 until the target model completes the model detection training; And, obtain the target model loss information when the target model completes the model detection training, and execute step S802 again.

[0088] S806: If yes, then end the model test training.

[0089] Among them, when the number of model training completions is greater than or equal to the preset number of times, the model test training is ended, that is, the model test training is no longer performed, and the steps of determining the model test training results based on the target model loss information in S606 are executed, and determining the backdoor detection information of the target pre-trained language model based on the model test training results.

[0090] In the embodiments provided in this specification, by continuously updating the backdoor test text, multiple rounds of model test training corresponding to the backdoor test text are performed to achieve continuous detection of triggers based on different backdoor test texts.

[0091] In the embodiments provided in this specification, the trigger reverse means commonly used in traditional backdoor detection are not used, but the output reverse means are used. Since the feature output of the target model backdoor is very different from that in the normal state when it is triggered, the reverse output means are easier to converge. At the same time, this solution draws on the fuzzy testing method in software testing. The possibility of convergence is increased by continuously generating random trainable features.

[0092] See also Fig. 9 , Fig. 9 A schematic diagram of a process for determining backdoor detection information of a target pre-trained language model is provided for one or more embodiments of this specification. Fig. 9 As shown, in S606, the model test training result is determined based on the target model loss information, and the backdoor detection information of the target pre-trained language model is determined based on the model test training result, including: S902: Determine a model loss information set based on all target model loss information, perform information filtering on the model loss information set based on preset filtering rules, and obtain a model test training result.

[0093] Among them, each time the model training is completed, the corresponding target model loss information can be obtained. Therefore, all the target model loss information can be put into the same set to obtain a model loss information set, which includes the target model loss information corresponding to each target model training completion.

[0094] After obtaining the model loss information set, the target model loss information with interference information is filtered out. Therefore, the preset filtering rules are used to perform information filtering on the model loss information set, thereby filtering out the target model loss information with interference information in the model loss information set and obtaining the model test training result.

[0095] S904: Determine the distance loss value distribution information of all distance loss items in the model test training results.

[0096] Among them, the distance loss values ​​of all distance loss items in the model test training results are determined, and then the corresponding distance loss value distribution information is generated based on all distance loss values.

[0097] S906: Determine backdoor detection information of the target pre-trained language model based on the distance loss value distribution information.

[0098] Among them, it is determined whether the distance loss value distribution information matches the backdoor determination condition; if it matches, the first backdoor information indicating that the target pre-trained language model has a backdoor is generated; if it does not match, the second backdoor information indicating that the target pre-trained language model does not have a backdoor is generated.

[0099] Specifically, judging whether the distance loss value distribution information matches the backdoor judgment condition includes: Determine whether there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than a first threshold value, if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than the first threshold value, then the distance loss value distribution information matches the backdoor determination condition; if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is greater than or equal to the first threshold value, then the distance loss value distribution information does not match the backdoor determination condition; and / or, Determine whether there are at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than a second threshold; if there are at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, the distance loss value distribution information matches the backdoor determination condition; if there are not at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, the distance loss value distribution information does not match the backdoor determination condition; wherein the second threshold is less than the first threshold.

[0100] In a feasible implementation, the first threshold value may be -0.2, the second threshold value may be -0.8, and the preset number may be 3. In the process of model detection training of the target model based on 30 batches of backdoor test texts, the batch size of each batch may be set to 32. When the number of times the distance loss value in the distance loss value distribution information is less than -0.8 is greater than or equal to 3, it indicates that a backdoor exists in the target pre-trained language model. When the backdoor test text performs model detection training on the target model, when the distance loss value in the distance loss value distribution information is less than -0.2, it also indicates that a backdoor exists in the target pre-trained language model. Only when both of these conditions are not met can it be determined that the target pre-trained language model is safe. The detection accuracy of this embodiment can reach 98.0%.

[0101] See also Fig.10 , Fig.10 A schematic diagram of a process for filtering out information from a model loss information set is provided for one or more embodiments of this specification. Fig.10 As shown, in S902, the model loss information set is filtered out based on the preset filtering rules to obtain the model test training results, including: S1002: Determine a diversity loss threshold, determine a target diversity loss item whose diversity loss value is greater than the diversity loss threshold from the model loss information set, and determine first target model loss information corresponding to the target diversity loss item.

[0102] Among them, in order to avoid the situation where the distance loss value corresponding to the distance loss item decreases while the diversity loss value corresponding to the diversity loss item does not decrease during the model testing and training of the target model, the corresponding diversity loss threshold can be determined based on the actual scenario, and the model loss information set corresponding to the model testing and training is used to search for the target diversity loss item whose diversity loss value is greater than the diversity loss threshold, because at this time the diversity loss values ​​all correspond to the target model after the model testing and training is completed.

[0103] Therefore, the case where the diversity loss value is greater than the target diversity loss item of the diversity loss threshold can be used as the case where the distance loss value corresponding to the distance loss item decreases during the model test training process while the diversity loss value corresponding to the diversity loss item does not decrease. Afterwards, the model loss information corresponding to the target diversity loss item is used as the first target model loss information. In a feasible implementation, the diversity loss threshold can be -3.446.

[0104] S1004: Determine the reference trainable features corresponding to each model loss information in the model loss information set, obtain the word embedding feature value range corresponding to the target model, match the reference trainable features based on the word embedding feature value range, obtain the target trainable features that do not match the word embedding feature value range, and determine the second target model loss information corresponding to the target trainable features.

[0105] In order to avoid excessive adjustment of the trainable features, which would cause them to exceed the value range of the word embedding features corresponding to the target model, thus making the adjustment of the trainable features meaningless, the reference trainable features corresponding to each model loss information in the model loss information set are obtained, and then the word embedding feature value range is matched to the reference trainable features to obtain the target trainable features that do not match the word embedding feature value range.

[0106] The target trainable feature that does not match the value range of the word embedding feature indicates that the adjustment range of the target trainable feature is too large, causing the target trainable feature to exceed the value range of the word embedding feature corresponding to the target model, making the value of the target trainable feature meaningless. Afterwards, the model loss information corresponding to the target trainable feature is used as the second target model loss information.

[0107] S1006: Filter out the first target model loss information and the second target model loss information from the model loss information set to obtain a model test training result.

[0108] Among them, after obtaining the first target model loss information and the second target model loss information, a preset filtering rule is determined based on the first target model loss information and the second target model loss information, and then the first target model loss information and the second target model loss information are filtered out from the model loss information set through the preset filtering rule to obtain the model test training result.

[0109] In the embodiments provided in the present specification, in order to avoid the situation where the distance loss value corresponding to the distance loss item decreases while the diversity loss value corresponding to the diversity loss item does not decrease during the model testing and training process of the target model, the first target model loss information corresponding to this situation is determined, and to avoid the situation where the adjustment range of the trainable feature is too large, causing it to exceed the value range of the word embedding feature corresponding to the target model, the second target model loss information corresponding to this situation is determined, and then the first target model loss information and the second target model loss information are filtered out from the model loss information set to obtain the model testing and training results, thereby performing interference information filtering processing on the model loss information set.

[0110] See also Fig.11 , Fig.11 Another flowchart of backdoor detection of a pre-trained language model is provided for one or more embodiments of this specification. Fig.11 As shown, the target pre-trained language model is processed by model twinning to obtain a target model and an auxiliary model. The backdoor test text is crawled from the web page based on a crawler, and trainable features are inserted into the target model. Then, the target model is tested and trained based on the target output features and the auxiliary output features.

[0111] If the reference distance loss value of a reference distance loss item in the distance loss value distribution information is less than the first threshold, the distance loss value distribution information matches the backdoor judgment condition, indicating that the abnormal output set is not empty, and the target pre-trained language model has a backdoor; if the target distance loss value of at least a preset number of target distance loss items in the distance loss value distribution information is less than the second threshold, the distance loss value distribution information matches the backdoor judgment condition, indicating that the output is reversely abnormal, and the target pre-trained language model also has a backdoor.

[0112] The following will be combined Fig.12 , Fig.12 This is a schematic diagram of the structure of a pre-trained language model backdoor detection device provided in this specification. It should be noted that: Fig.12 The pre-trained language model backdoor detection device shown is used to execute this instruction Figure 1 to Figure 11 For the convenience of explanation, only the parts related to this specification are shown. For specific technical details not disclosed, please refer to this specification. Figure 1 to Figure 11 The embodiment shown.

[0113] See also Fig.12 , which shows a schematic diagram of the structure of the pre-trained language model backdoor detection device of the present specification. The pre-trained language model backdoor detection device 1 can be implemented as all or part of the user terminal through software, hardware or a combination of both. According to some embodiments, the pre-trained language model backdoor detection device 1 includes a pre-processing module 11, a processing module 12 and a backdoor detection module 13, which are specifically used to: A preprocessing module 11 is adapted to perform model twinning processing on the target pre-trained language model to obtain a target model and an auxiliary model; The processing module 12 is adapted to input the backdoor test text into the target model, insert trainable features into the target model, determine the target output features output by the target model for the backdoor test text; and determine the auxiliary output features output by the auxiliary model for the backdoor test text; The backdoor detection module 13 is suitable for performing model test training on the target model based on the target output features and the auxiliary output features, obtaining the model test training results, and determining the backdoor detection information of the target pre-trained language model based on the model test training results.

[0114] Optionally, the preprocessing module 11 includes: A model parameter freezing unit, adapted to freeze the model parameters of a target pre-trained language model to obtain a target model; The model duplication unit is suitable for duplicating the target model to obtain an auxiliary model.

[0115] Optionally, the processing module 12 includes: An input unit, adapted to input the backdoor test text into a target model, determine a word embedding feature corresponding to the backdoor test text based on the target model, insert a trainable feature into the word embedding feature of the backdoor test text, and obtain a target word embedding feature; The control unit is suitable for controlling the target model to perform model processing based on the target word embedding feature to obtain the target output feature output by the target model for the target word embedding feature.

[0116] Optionally, the backdoor detection module 13 includes: An adjustment unit, adapted to determine model loss information based on the target output feature and the auxiliary output feature, and adjust the inserted trainable feature based on the model loss information; An execution unit, adapted to execute the step of determining a target output feature output by the target model for the backdoor test text until the target model completes model detection training; The acquisition unit is adapted to acquire target model loss information when the target model completes model detection training, determine the model test training result based on the target model loss information, and determine the backdoor detection information of the target pre-trained language model based on the model test training result.

[0117] Optionally, the adjustment unit includes: a distance loss term determination subunit adapted to determine a distance loss term based on a target output feature and an auxiliary output feature; A diversity loss item determination subunit, adapted to determine a diversity loss item based on the features of each dimension in the target output feature; The model loss information determination subunit is suitable for determining the total model loss for the target model based on the distance loss term and the diversity loss term, and obtaining the model loss information based on the distance loss term, the diversity loss term and the total model loss.

[0118] Optionally, the distance loss item determination subunit includes: A first calculation formula subunit, adapted to obtain a distance loss term by using a first calculation formula to calculate the target output feature and the auxiliary output feature; The first calculation formula satisfies the following formula: ; Where N is the total number of backdoor test texts and N is a positive integer. is the distance loss term, Output the target feature corresponding to the x-th backdoor test text, is the auxiliary output feature corresponding to the x-th backdoor test text, MSE is the mean square error function, Used for calculation and The Euclidean distance between The subunits for determining diversity loss items include: The second calculation formula subunit is adapted to perform dimensional feature concatenation on the target output features corresponding to all backdoor test texts to obtain a target concatenation feature, and obtain a diversity loss term based on the target concatenation feature using the second calculation formula; The second calculation formula satisfies the following formula: ; Among them, B is the total dimension of the target output feature, is the diversity loss term, is the Shannon entropy, The target concatenation feature corresponding to the y-th dimension of the target output feature corresponding to all backdoor test texts, B ≥ y ≥ 1; The model loss information determination subunit includes: The distance loss term and the diversity loss term are calculated using the third formula to obtain the total model loss of the target model; The third calculation formula satisfies the following formula: ; in, is the total model loss of the target model, is the weight of the diversity loss term.

[0119] Optionally, the acquiring unit further includes: A recording subunit, adapted to record the number of model training completions of the currently completed model detection training, and detect whether the number of model training completions is greater than or equal to a preset number; A first judgment subunit is adapted to, if not, update the backdoor test text to obtain a next backdoor test text, use the next backdoor test text as the backdoor test text and execute the step of inputting the backdoor test text into the target model; The second judgment subunit is adapted to end the model test training if yes.

[0120] Optionally, the acquiring unit includes: A filtering subunit, adapted to determine a model loss information set based on all target model loss information, and to perform information filtering processing on the model loss information set based on a preset filtering rule to obtain a model test training result; A distance loss value distribution information determination subunit, adapted to determine the distance loss value distribution information of all distance loss items in the model test training results; The backdoor detection information determination subunit is adapted to determine the backdoor detection information of the target pre-trained language model based on the distance loss value distribution information.

[0121] Optionally, the filtering subunit includes: A first determination subunit is adapted to determine a diversity loss threshold, determine a target diversity loss item whose diversity loss value is greater than the diversity loss threshold from the model loss information set, and determine first target model loss information corresponding to the target diversity loss item; A second determination subunit is adapted to determine a reference trainable feature corresponding to each model loss information in the model loss information set, obtain a word embedding feature value range corresponding to the target model, match the reference trainable feature based on the word embedding feature value range, obtain a target trainable feature that does not match the word embedding feature value range, and determine a second target model loss information corresponding to the target trainable feature; The model test training result determination subunit is adapted to filter out the first target model loss information and the second target model loss information from the model loss information set to obtain the model test training result.

[0122] Optionally, the backdoor detection information determination subunit includes: A matching judgment subunit, adapted to judge whether the distance loss value distribution information matches the backdoor judgment condition; a matching subunit, adapted to generate first backdoor information indicating that a backdoor exists in the target pre-trained language model if a match is found; The unmatched subunit is adapted to generate second backdoor information indicating that the target pre-trained language model does not have a backdoor if there is no match.

[0123] Optionally, the matching judgment subunit is suitable for: Determine whether there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than a first threshold value, if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than the first threshold value, then the distance loss value distribution information matches the backdoor determination condition; if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is greater than or equal to the first threshold value, then the distance loss value distribution information does not match the backdoor determination condition; and / or, Determine whether there are at least a preset number of target distance loss items in the distance loss value distribution information whose reference distance loss values ​​are less than a second threshold; if there are at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, the distance loss value distribution information matches the backdoor determination condition; if there are no at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, the distance loss value distribution information does not match the backdoor determination condition; wherein the second threshold is less than the first threshold.

[0124] It should be noted that the pre-trained language model backdoor detection device provided in the above embodiment only uses the division of the above functional modules as an example when executing the pre-trained language model backdoor detection method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the pre-trained language model backdoor detection device provided in the above embodiment and the pre-trained language model backdoor detection method embodiment belong to the same concept, and the implementation process thereof is detailed in the method embodiment, which will not be repeated here.

[0125] The present specification also provides a computer storage medium, which can store multiple instructions, which are suitable for being loaded and executed by a processor as described above. Figure 1 to Figure 11 The pre-trained language model backdoor detection method of the embodiment shown in the figure can be found in the specific execution process. Figure 1 to Figure 11 The specific description of the illustrated embodiment will not be repeated here.

[0126] The present specification also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figure 1 to Figure 11 The pre-trained language model backdoor detection method of the embodiment shown in the figure can be found in the specific execution process. Figure 1 to Figure 11 The specific description of the illustrated embodiment will not be repeated here.

[0127] Please refer to Fig.13 , Fig.13 The electronic device in this specification may include one or more of the following components: a processor 110, a memory 120, an input device 130, an output device 140, and a bus 150. The processor 110, the memory 120, the input device 130, and the output device 140 may be connected via the bus 150.

[0128] The processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0129] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). Optionally, the memory 120 includes a non-transitory computer-readable storage medium. The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The operating system may be an Android system, including a system deeply developed based on the Android system, an IOS system developed by Apple, including a system deeply developed based on the IOS system or other systems. The data storage area may also store data created by the electronic device during use, such as a phone book, audio and video data, chat record data, etc.

[0130] See also Fig.14 As shown, Fig.14 A schematic diagram of the structure of the operating system and user space provided in this specification. The memory 120 can be divided into an operating system space and a user space, the operating system runs in the operating system space, and the native and third-party applications run in the user space. In order to ensure that different third-party applications can achieve good operating results, the operating system allocates corresponding system resources to different third-party applications. However, the requirements for system resources in different application scenarios in the same third-party application are also different. For example, in the local resource loading scenario, the third-party application has a higher requirement for the disk reading speed; in the animation rendering scenario, the third-party application has a higher requirement for the GPU performance. The operating system and the third-party application are independent of each other, and the operating system often cannot perceive the current application scenario of the third-party application in a timely manner, resulting in the operating system being unable to perform targeted system resource adaptation according to the specific application scenario of the third-party application.

[0131] In order for the operating system to distinguish the specific application scenarios of third-party applications, it is necessary to open up data communication between third-party applications and the operating system so that the operating system can obtain the current scenario information of third-party applications at any time, and then perform targeted system resource adaptation based on the current scenario.

[0132] Fig.15 for Fig.14 The architecture diagram of the Android operating system in FIG. 1 is a diagram showing an operating system as the Android system. The programs and data stored in the memory 120 are as follows: Fig.15 As shown, the memory 120 may store a Linux kernel layer 320, a system runtime library layer 340, an application framework layer 360 and an application layer 380, wherein the Linux kernel layer 320, the system runtime library layer 340 and the application framework layer 360 belong to the operating system space, and the application layer 380 belongs to the user space. The Linux kernel layer 320 provides underlying drivers for various hardware of electronic devices, such as display drivers, audio drivers, camera drivers, Bluetooth drivers, Wi-Fi drivers, power management, etc. The system runtime library layer 340 provides the main feature support for the Android system through some C / C++ libraries. For example, the SQLite library provides database support, the OpenGL / ES library provides 3D drawing support, and the Webkit library provides browser kernel support, etc. The Android runtime library (Android runtime) is also provided in the system runtime library layer 340, which mainly provides some core libraries that allow developers to use the Java language to write Android applications. The application framework layer 360 provides various APIs that may be used when building applications. Developers can also use these APIs to build their own applications, such as activity management, window management, view management, notification management, content provider, package management, call management, resource management, and location management. At least one application runs in the application layer 380. These applications can be native applications that come with the operating system, such as contact applications, text messaging applications, clock applications, camera applications, etc.; they can also be third-party applications developed by third-party developers, such as game applications, instant messaging applications, photo beautification applications, etc.

[0133] Fig.16 for Fig.14 FIG. 1 is an architecture diagram of the IOS operating system, taking the operating system as the IOS system as an example, the programs and data stored in the memory 120 are as follows: Fig.16As shown, the IOS system includes: a core operating system layer 420 (Core OS layer), a core service layer 440 (Core Services layer), a media layer 460 (Media layer), and a touchable layer 480 (Cocoa TouchLayer). The core operating system layer 420 includes the operating system kernel, drivers, and underlying program frameworks. These underlying program frameworks provide functions closer to the hardware for use by the program frameworks located in the core service layer 440. The core service layer 440 provides system services and / or program frameworks required by the application, such as the foundation framework, account framework, advertising framework, data storage framework, network connection framework, geographic location framework, motion framework, etc. The media layer 460 provides audio-visual interfaces for the application, such as graphics and image related interfaces, audio technology related interfaces, video technology related interfaces, and wireless playback (AirPlay) interfaces for audio and video transmission technologies. The touchable layer 480 provides various commonly used interface-related frameworks for application development, and the touchable layer 480 is responsible for the user's touch interaction operations on the electronic device. For example, local notification service, remote push service, advertising framework, game tool framework, message user interface interface (UI) framework, user interface UIKit framework, map framework, etc.

[0134] exist Fig.16 Among the frameworks shown, the frameworks related to most applications include but are not limited to: the basic framework in the core service layer 440 and the UIKit framework in the touchable layer 480. The basic framework provides many basic object classes and data types, provides the most basic system services for all applications, and has nothing to do with UI. The classes provided by the UIKit framework are basic UI class libraries for creating touch-based user interfaces. iOS applications can provide UIs based on the UIKit framework, so it provides the basic architecture of applications for building user interfaces, drawing, processing and user interaction events, responding to gestures, etc.

[0135] Among them, the method and principle of implementing data communication between third-party applications and the operating system in the IOS system can be referred to the Android system, and this manual will not go into details here.

[0136] Among them, the input device 130 is used to receive input instructions or data, and the input device 130 includes but is not limited to a keyboard, a mouse, a camera, a microphone or a touch device. The output device 140 is used to output instructions or data, and the output device 140 includes but is not limited to a display device and a speaker. In one example, the input device 130 and the output device 140 can be combined, and the input device 130 and the output device 140 are touch screens, which are used to receive touch operations on or near them by users using any suitable objects such as fingers and touch pens, and to display the user interfaces of various applications. The touch screen is usually set on the front panel of the electronic device. The touch screen can be designed as a full screen, a curved screen or a special-shaped screen. The touch screen can also be designed as a combination of a full screen and a curved screen, or a combination of a special-shaped screen and a curved screen, which is not limited in this specification.

[0137] In addition, those skilled in the art will understand that the structure of the electronic device shown in the above drawings does not constitute a limitation on the electronic device, and the electronic device may include more or fewer components than shown, or combine certain components, or arrange the components differently. For example, the electronic device also includes radio frequency circuits, input units, sensors, audio circuits, wireless fidelity (WiFi) modules, power supplies, Bluetooth modules and other components, which will not be described in detail here.

[0138] In this specification, the execution subject of each step may be the electronic device described above. Optionally, the execution subject of each step is the operating system of the electronic device. The operating system may be an Android system, an IOS system, or other operating systems, which is not limited in this specification.

[0139] The electronic device of this specification may also be equipped with a display device, which may be any device capable of realizing a display function, such as a cathode ray tube display (CR), a light-emitting diode display (LED), an electronic ink screen, a liquid crystal display (LCD), a plasma display panel (PDP), etc. The user may use the display device on the electronic device 101 to view displayed text, images, videos and other information. The electronic device may be a smart phone, a tablet computer, a gaming device, an AR (Augmented Reality) device, a car, a data storage device, an audio playback device, a video playback device, a notebook, a desktop computing device, a wearable device such as an electronic watch, an electronic glasses, an electronic helmet, an electronic bracelet, an electronic necklace, electronic clothing and other devices.

[0140] exist Fig.13 In the electronic device shown, where the electronic device may be a terminal, the processor 110 may be used to call the network optimization application stored in the memory 120, and specifically perform the following operations: Perform model twinning processing on the target pre-trained language model to obtain the target model and the auxiliary model; Inputting the backdoor test text into the target model, inserting trainable features into the target model, and determining the target output features output by the target model for the backdoor test text; and determining the auxiliary output features output by the auxiliary model for the backdoor test text; Model testing and training are performed on the target model based on the target output features and the auxiliary output features to obtain model testing and training results, and backdoor detection information of the target pre-trained language model is determined based on the model testing and training results.

[0141] Optionally, when the processor 110 performs model twinning processing on the target pre-trained language model to obtain the target model and the auxiliary model, specifically: Freeze the model parameters of the target pre-trained language model to obtain the target model; Copy the target model to obtain the auxiliary model.

[0142] Optionally, when the processor 110 inputs the backdoor test text into the target model, inserts trainable features into the target model, and determines the target output features output by the target model for the backdoor test text, specifically: The backdoor test text is input into the target model, the word embedding features corresponding to the backdoor test text are determined based on the target model, and the trainable features are inserted into the word embedding features of the backdoor test text to obtain the target word embedding features; The target model is controlled to perform model processing based on the target word embedding feature to obtain the target output feature output by the target model for the target word embedding feature.

[0143] Optionally, the processor 110 performs model test training on the target model based on the target output feature and the auxiliary output feature to obtain a model test training result, and determines the backdoor detection information of the target pre-trained language model based on the model test training result, specifically performing: Determine model loss information based on the target output features and the auxiliary output features, and adjust the inserted trainable features based on the model loss information; Executing the step of determining target output features output by the target model for the backdoor test text until the target model completes model detection training; Obtain target model loss information when the target model completes model detection training, determine the model test training result based on the target model loss information, and determine the backdoor detection information of the target pre-trained language model based on the model test training result.

[0144] Optionally, when the processor 110 determines the model loss information based on the target output feature and the auxiliary output feature, specifically performs: Determine a distance loss term based on the target output feature and the auxiliary output feature; Determine the diversity loss item based on the characteristics of each dimension in the target output feature; The total model loss for the target model is determined based on the distance loss term and the diversity loss term, and the model loss information is obtained based on the distance loss term, the diversity loss term and the total model loss.

[0145] Optionally, when the processor 110 determines the distance loss term based on the target output feature and the auxiliary output feature, the processor 110 specifically performs: The target output feature and the auxiliary output feature are calculated using the first formula to obtain the distance loss term; The first calculation formula satisfies the following formula: ; Where N is the total number of backdoor test texts and N is a positive integer. is the distance loss term, Output the target feature corresponding to the x-th backdoor test text, is the auxiliary output feature corresponding to the x-th backdoor test text, MSE is the mean square error function, Used for calculation and The Euclidean distance between When the processor 110 determines the diversity loss item based on the features of each dimension in the target output feature, it specifically performs: The target output features corresponding to all backdoor test texts are concatenated by dimension features to obtain target concatenated features, and the diversity loss term is obtained by using the second calculation formula based on the target concatenated features; The second calculation formula satisfies the following formula: ; Among them, B is the total dimension of the target output feature, is the diversity loss term, is the Shannon entropy, The target concatenation feature corresponding to the y-th dimension of the target output feature corresponding to all backdoor test texts, B ≥ y ≥ 1; When the processor 110 determines the total model loss for the target model based on the distance loss term and the diversity loss term, it specifically executes: The distance loss term and the diversity loss term are calculated using the third formula to obtain the total model loss of the target model; The third calculation formula satisfies the following formula: ; in, is the total model loss of the target model, is the weight of the diversity loss term.

[0146] Optionally, after the processor 110 executes the acquisition of target model loss information when the target model completes model detection training, it is further adapted to execute: Record the number of completed model trainings for the current completed model detection training, and check whether the number of completed model trainings is greater than or equal to the preset number; If not, the backdoor test text is updated to obtain the next backdoor test text, the next backdoor test text is used as the backdoor test text, and the step of inputting the backdoor test text into the target model is performed; If yes, the model test training ends.

[0147] Optionally, when the processor 110 determines the model test training result based on the target model loss information and determines the backdoor detection information of the target pre-trained language model based on the model test training result, the following is specifically performed: Determine a model loss information set based on all target model loss information, perform information filtering on the model loss information set based on preset filtering rules, and obtain a model test training result; Determine the distance loss value distribution information of all distance loss items in the model test training results; The backdoor detection information of the target pre-trained language model is determined based on the distance loss value distribution information.

[0148] Optionally, the processor 110 performs information filtering processing on the model loss information set based on a preset filtering rule, and when obtaining the model test training result, specifically performs: Determine a diversity loss threshold, determine a target diversity loss item whose diversity loss value is greater than the diversity loss threshold from the model loss information set, and determine first target model loss information corresponding to the target diversity loss item; Determine a reference trainable feature corresponding to each model loss information in the model loss information set, obtain a word embedding feature value range corresponding to the target model, match the reference trainable feature based on the word embedding feature value range, obtain a target trainable feature that does not match the word embedding feature value range, and determine a second target model loss information corresponding to the target trainable feature; The first target model loss information and the second target model loss information are filtered out from the model loss information set to obtain the model test training result.

[0149] Optionally, when the processor 110 determines the backdoor detection information of the target pre-trained language model based on the distance loss value distribution information, specifically performs: Determine whether the distance loss value distribution information matches the backdoor determination condition; If they match, the first backdoor information indicating that the target pre-trained language model has a backdoor is generated; If they do not match, the second backdoor information indicating that the target pre-trained language model does not have a backdoor is generated.

[0150] Optionally, when the processor 110 determines whether the distance loss value distribution information matches the backdoor determination condition, it specifically performs: Determine whether there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than a first threshold value, if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than the first threshold value, then the distance loss value distribution information matches the backdoor determination condition; if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is greater than or equal to the first threshold value, then the distance loss value distribution information does not match the backdoor determination condition; and / or, Determine whether there are at least a preset number of target distance loss items in the distance loss value distribution information whose reference distance loss values ​​are less than a second threshold; if there are at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, the distance loss value distribution information matches the backdoor determination condition; if there are no at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, the distance loss value distribution information does not match the backdoor determination condition; wherein the second threshold is less than the first threshold.

[0151] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0152] It should be noted that the information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in the embodiments of this specification are all authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions. For example, the object characteristics, interactive behavior characteristics and user information involved in this specification are all obtained with full authorization.

[0153] The above disclosure is only the preferred embodiment of this specification, which certainly cannot be used to limit the scope of rights of this specification. Therefore, equivalent changes made according to the claims of this specification are still within the scope covered by this specification.

Claims

1. A method for detecting backdoors in a pre-trained language model, the method comprising: Perform model twinning processing on the target pre-trained language model to obtain the target model and the auxiliary model; Inputting the backdoor test text into the target model, inserting trainable features into the target model, and determining the target output features output by the target model for the backdoor test text; And, determining the auxiliary output features output by the auxiliary model for the backdoor test text; Model testing training is performed on the target model based on the target output feature and the auxiliary output feature to obtain a model testing training result, and backdoor detection information of the target pre-trained language model is determined based on the model testing training result.

2. According to the method of claim 1, the step of performing model twinning processing on the target pre-trained language model to obtain the target model and the auxiliary model comprises: Freezing the model parameters of the target pre-trained language model to obtain a target model; The target model is copied to obtain an auxiliary model.

3. The method according to claim 1, wherein the step of inputting the backdoor test text into the target model, inserting trainable features into the target model, and determining the target output features output by the target model for the backdoor test text comprises: Inputting a backdoor test text into the target model, determining a word embedding feature corresponding to the backdoor test text based on the target model, inserting a trainable feature into the word embedding feature of the backdoor test text, and obtaining a target word embedding feature; The target model is controlled to perform model processing based on the target word embedding feature to obtain a target output feature output by the target model for the target word embedding feature.

4. According to the method of claim 1, the step of performing model test training on the target model based on the target output feature and the auxiliary output feature to obtain a model test training result, and determining the backdoor detection information of the target pre-trained language model based on the model test training result comprises: Determining model loss information based on the target output feature and the auxiliary output feature, and adjusting the inserted trainable feature based on the model loss information; Executing the step of determining the target output feature output by the target model for the backdoor test text until the target model completes model detection training; Obtain target model loss information when the target model completes the model detection training, determine a model test training result based on the target model loss information, and determine backdoor detection information of the target pre-trained language model based on the model test training result.

5. The method according to claim 4, wherein determining the model loss information based on the target output feature and the auxiliary output feature comprises: Determining a distance loss term based on the target output feature and the auxiliary output feature; Determining a diversity loss item based on the features of each dimension in the target output feature; A total model loss for the target model is determined based on the distance loss term and the diversity loss term, and model loss information is obtained based on the distance loss term, the diversity loss term and the total model loss.

6. The method according to claim 5, wherein determining the distance loss term based on the target output feature and the auxiliary output feature comprises: The target output feature and the auxiliary output feature are calculated using a first formula to obtain a distance loss term; The first calculation formula satisfies the following formula: ; Wherein, N is the total number of the backdoor test texts and N is a positive integer, is the distance loss term, the is the target output feature corresponding to the x-th backdoor test text, is the auxiliary output feature corresponding to the x-th backdoor test text, the MSE is the mean square error function, and To calculate the and stated The Euclidean distance between The determining of the diversity loss item based on the features of each dimension in the target output feature includes: Performing dimension feature concatenation on the target output features corresponding to all backdoor test texts to obtain a target concatenation feature, and obtaining a diversity loss term based on the target concatenation feature using a second calculation formula; The second calculation formula satisfies the following formula: ; Wherein, B is the total dimension of the target output feature, is the diversity loss term, is the Shannon entropy, The target concatenation feature corresponding to the yth dimension of the target output feature corresponding to all backdoor test texts, wherein B≥y≥1; The determining the total model loss for the target model based on the distance loss term and the diversity loss term includes: The distance loss term and the diversity loss term are calculated using a third formula to obtain a total model loss of the target model; The third calculation formula satisfies the following formula: ; Among them, the is the total model loss of the target model, is the weight of the diversity loss term.

7. The method according to claim 4, after obtaining the target model loss information when the target model completes the model detection training, further comprises: Record the number of model training completions of the current model detection training, and detect whether the number of model training completions is greater than or equal to a preset number; If not, the backdoor test text is updated to obtain a next backdoor test text, the next backdoor test text is used as the backdoor test text, and the step of inputting the backdoor test text into the target model is performed; If yes, the model test training ends.

8. The method according to claim 7, wherein determining a model test training result based on the target model loss information, and determining backdoor detection information of the target pre-trained language model based on the model test training result, comprises: Determine a model loss information set based on all target model loss information, and perform information filtering on the model loss information set based on a preset filtering rule to obtain a model test training result; Determine the distance loss value distribution information of all distance loss items in the model test training results; Backdoor detection information of the target pre-trained language model is determined based on the distance loss value distribution information.

9. The method according to claim 8, wherein the information filtering process is performed on the model loss information set based on a preset filtering rule to obtain a model test training result, comprising: Determine a diversity loss threshold, determine a target diversity loss item whose diversity loss value is greater than the diversity loss threshold from the model loss information set, and determine first target model loss information corresponding to the target diversity loss item; Determine a reference trainable feature corresponding to each model loss information in the model loss information set, obtain a word embedding feature value range corresponding to the target model, match the reference trainable feature based on the word embedding feature value range, obtain a target trainable feature that does not match the word embedding feature value range, and determine a second target model loss information corresponding to the target trainable feature; The first target model loss information and the second target model loss information are filtered out from the model loss information set to obtain a model test training result.

10. The method according to claim 8, wherein determining the backdoor detection information of the target pre-trained language model based on the distance loss value distribution information comprises: Determining whether the distance loss value distribution information matches the backdoor determination condition; If they match, generating first backdoor information indicating that the target pre-trained language model has a backdoor; If they do not match, second backdoor information indicating that the target pre-trained language model does not have a backdoor is generated.

11. The method according to claim 10, wherein determining whether the distance loss value distribution information matches a backdoor determination condition comprises: Determine whether there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than a first threshold value; if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is less than the first threshold value, then the distance loss value distribution information matches the backdoor determination condition; if there is a reference distance loss value of a reference distance loss item in the distance loss value distribution information that is greater than or equal to the first threshold value, then the distance loss value distribution information does not match the backdoor determination condition; and / or, Determine whether there are at least a preset number of target distance loss items in the distance loss value distribution information whose reference distance loss values ​​are less than a second threshold; if there are at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, then the distance loss value distribution information matches the backdoor determination condition; if there are no at least a preset number of target distance loss items in the distance loss value distribution information whose target distance loss values ​​are less than the second threshold, then the distance loss value distribution information does not match the backdoor determination condition; wherein the second threshold is less than the first threshold.

12. A pre-trained language model backdoor detection device, the device comprising: The preprocessing module is suitable for performing model twin processing on the target pre-trained language model to obtain the target model and the auxiliary model; A processing module, adapted to input the backdoor test text into the target model, insert trainable features into the target model, and determine target output features output by the target model for the backdoor test text; And, determining the auxiliary output features output by the auxiliary model for the backdoor test text; The backdoor detection module is suitable for performing model test training on the target model based on the target output feature and the auxiliary output feature to obtain a model test training result, and determining the backdoor detection information of the target pre-trained language model based on the model test training result.

13. A computer storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the method steps as claimed in any one of claims 1 to 11.

14. A computer program product, the computer program product storing at least one instruction, wherein the at least one instruction is loaded by a processor and executes the method steps according to any one of claims 1 to 11.

15. An electronic device, comprising: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps as claimed in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Trigger sample detection method based on custom backdoor behavior

    CN115098855A

  • Backdoor watermark image data set generation method based on adversarial training network

    CN115546003A

  • Multi-mode invisible backdoor attack method and system based on countermeasure disturbance and medium

    CN118350436A

  • Webpage backdoor detecting method, device, storage medium and apparatus

    WO2020073494A1

Cited By

  • Offline intelligent voice control method and device, electronic equipment and storage medium

    CN119580729A