A natural language generation and attack detection method, medium, device and equipment
By combining the input and output of the attacked natural language generation model, a large-scale multilingual pre-trained model is used to generate text vectors and calculate vector distances to realize automatic identification and deletion of backdoor attack triggers, the backdoor attack in natural language generation model is solved. The problem of this paper improves the stability and security of the model and reduces the risk of generating malicious results.
Patent Information
- Application Number
- CN202111297485.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-04
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2041-11-04
AI Technical Summary
There is a backdoor attack threat in natural language generation models, which are difficult to detect and increase the difficulty of model defense, resulting in the risk of model generating malicious results.
By combining the input and output of the attacked natural language generation model, a large-scale multilingual pre-trained model is used to generate text vectors and calculate vector distances to realize automatic identification and deletion of backdoor attack triggers, improving the stability and security of the model.
Improve the stability and security of online deployment of models, reduce the risk of generating malicious results, and large-scale pre-trained models based on multilinguals improve the accuracy and robustness of judgment results, accurately identify backdoor triggers, and avoid machine learning. The model generates malicious results.
Smart Images

Figure CN114021124B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of language generation, and in particular to a natural language generation and attack detection method, device, medium and equipment. Background Art
[0002] With the development of Internet technology, more and more machine learning models are deployed online. While these models improve the convenience of life, they are also facing new security threats, one of which comes from backdoor attacks. For natural language generation models, backdoor attacks are to bury a backdoor in the model in some way during the model training process, and the buried backdoor is triggered by a trigger pre-set by the attacker. When the backdoor is not triggered, the attacked model has similar performance to the normal model; when the backdoor buried in the model is triggered and activated by a specific input, namely the backdoor trigger, the output of the model becomes the result pre-specified by the attacker to achieve malicious purposes. Backdoor attacks are one of the many ways to endanger model results that are not easy to detect. Summary of the invention
[0003] In response to the problems existing in the prior art, the present application mainly provides a natural language generation and attack detection method, which judges whether there is a backdoor attack trigger in the input by combining the input and output of the attacked natural language generation model, so that the backdoor attack trigger can be automatically identified and deleted.
[0004] In order to achieve the above purpose, a technical solution adopted by the present application is to provide a natural language generation and attack detection method, which includes:
[0005] Verification text vector generation process, respectively according to each source language input in the verification set including multiple source language inputs, using a large-scale multilingual pre-trained model to generate a corresponding input text vector, and respectively according to each source language input using the attacked model output result obtained by the attacked natural language generation model, using a large-scale multilingual pre-trained model to generate a corresponding output text vector; verification vector distance calculation process, calculating the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input, and calculating the vector distance average of all vector distances; to-be-detected text vector generation process, respectively pushing the new source language input and the to-be-detected output result obtained by using the attacked natural language generation model to the large-scale multilingual pre-trained model to generate the to-be-detected input text vector and the to-be-detected output text vector; backdoor attack trigger detection process, calculating the to-be-detected vector distance between the to-be-detected input text vector and the to-be-detected output text vector, and detecting whether the new source language input contains a backdoor attack trigger based on the to-be-detected vector distance and the vector distance average;
[0006] The attacked natural language generation model is a natural language generation model that is known to be attacked by a backdoor.
[0007] Another technical solution adopted by the present application is to provide a text classification out-of-distribution sample detection device, which includes:
[0008] A verification text vector generation module is used to generate a corresponding input text vector using a large-scale multilingual pre-trained model according to each source language input in a verification set including multiple source language inputs, and to generate a corresponding output text vector using a large-scale multilingual pre-trained model according to each source language input using an attacked model output result obtained by the attacked natural language generation model; a verification vector distance calculation module is used to calculate the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input, and calculate the vector distance average of all vector distances; a to-be-detected text vector generation module is used to push a new source language input and its to-be-detected output result obtained by using the attacked natural language generation model to the large-scale multilingual pre-trained model, respectively, to generate an to-be-detected input text vector and an to-be-detected output text vector; a backdoor attack trigger detection module is used to calculate the to-be-detected vector distance between the to-be-detected input text vector and the to-be-detected output text vector, and to detect whether the new source language input contains a backdoor attack trigger based on the to-be-detected vector distance and the vector distance average;
[0009] The attacked natural language generation model is a natural language generation model that is known to be attacked by a backdoor.
[0010] Another technical solution adopted by the present application is: a computer-readable storage medium storing computer instructions, characterized in that the computer instructions are operated to execute the natural language generation and attack detection method in the above solution.
[0011] Another technical solution adopted by the present application is: a computer device, which includes a processor and a memory, the memory stores computer instructions, and the computer instructions are operated to execute the natural language generation and attack detection method in the above solution.
[0012] The beneficial effects that can be achieved by the technical solution of the present application are: the present application designs a natural language generation and attack detection method, device, medium and equipment. The method combines the input and output of the attacked natural language generation model to judge whether there is a backdoor attack trigger in the source language input, so that the backdoor attack trigger can be automatically identified and deleted, which helps to improve the stability and security of the model's online deployment, reduce the risk of generating malicious results, and has very high social value. In addition, its large-scale pre-trained model based on multiple languages can improve the accuracy and robustness of the judgment results, more accurately identify backdoor triggers, and avoid the generation of malicious results by machine learning models. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0014] Figure 1 It is a flowchart of a specific implementation method of a natural language generation and attack detection method of the present application;
[0015] Figure 2 It is a flowchart of a specific embodiment of a natural language generation and attack detection method of the present application;
[0016] Figure 3 It is a schematic diagram of a specific implementation of a natural language generation and attack detection device of the present application;
[0017] Figure 4 It is a schematic diagram of a specific embodiment of a device for detecting out-of-distribution samples of text classification in the present application.
[0018] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0019] The preferred embodiments of the present application are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present application can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present application.
[0020] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0021] By studying the performance of the neural network model, we found that by making slight changes to the test sample without changing the model, the model can misclassify the changed sample. Backdoor attacks are one of the many ways to harm the model results that is not easy to detect: when the model receives normal input, the attacked model behaves similarly to the normal model. Only when the model receives specific input (backdoor trigger) will it be triggered, which will cause the neural network to produce errors and malicious outputs, thus greatly increasing the difficulty of model defense.
[0022] In order to solve the above problems, this solution designs a method for automatically detecting backdoor attacks based on a large-scale pre-trained model. After the user sends a request to the model, it can promptly determine whether the results generated by the online model are malicious, and then choose to retain, block or filter operations, which greatly ensures the security of the model.
[0023] The technical solution of the present application is described in detail below with specific embodiments and in conjunction with the accompanying drawings. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0024] Figure 1 A specific implementation of a natural language generation and attack detection method of the present application is shown.
[0025] In this specific implementation, the natural language generation and attack detection method of the present application mainly includes a verification text vector generation process S101, respectively, according to each source language input in the verification set including multiple source language inputs, a corresponding input text vector is generated using a large-scale multilingual pre-trained model, and respectively according to each source language input, the attacked model output result obtained by the attacked natural language generation model is used to generate a corresponding output text vector using a large-scale multilingual pre-trained model; a verification vector distance calculation process S102, calculating the vector distance between the corresponding input text vector corresponding to each source language input and the corresponding output text vector, and calculating all vector distances ; the text vector generation process S103 to be detected, respectively pushes the new source language input and the output result to be detected obtained by using the attacked natural language generation model to the large-scale multilingual pre-training model to generate the input text vector to be detected and the output text vector to be detected; and the backdoor attack trigger detection process S104, calculates the distance between the input text vector to be detected and the output text vector to be detected, and detects whether the new source language input contains a backdoor attack trigger according to the distance between the vector to be detected and the average value of the vector distance; wherein the attacked natural language generation model is a natural language generation model that is known to be attacked by the backdoor.
[0026] By combining the input and output of the attacked natural language generation model to determine whether there are backdoor attack triggers in the source language input, it is possible to automatically identify and delete backdoor attack triggers, which helps to improve the stability and security of the model's online deployment and reduce the risk of generating malicious results. It has very high social value, and its large-scale pre-trained model based on multiple languages can improve the accuracy and robustness of the judgment results, more accurately identify backdoor triggers, and prevent machine learning models from generating malicious results.
[0027] The verification text vector generation process S101 generates a corresponding input text vector using a large-scale multilingual pre-trained model according to each source language input in a verification set including multiple source language inputs, and generates a corresponding output text vector using a large-scale multilingual pre-trained model according to the attacked model output result obtained by the attacked natural language generation model for each source language input, which can help detect whether the source language input contains a backdoor attack trigger based on the distance between the text vectors.
[0028] In a specific embodiment of the present application, the above-mentioned verification set including multiple source language inputs is prepared in advance according to the needs, and half of the source language inputs contain backdoor attack triggers. The data of the verification set for detecting backdoor attacks consists of two parts: one part is the original data verification set data without the backdoor trigger, and the other part is the attack data obtained by adding the backdoor trigger to the original verification set data. The ratio of the original verification set data to the attack data set is 1:1.
[0029] In a specific embodiment of the present application, the above-mentioned attacked natural language generation model is a translation model that is known to be attacked by a backdoor.
[0030] In a specific embodiment of the present application, the verification text vector generation process S101 includes:
[0031] Each source language input is pushed to the large-scale multilingual pre-trained model to obtain sentence length input word-level vectors of each source language input, and then all input word-level vectors corresponding to each source language input are subjected to maximum pooling operation to generate unique corresponding input text vectors corresponding to each source language input; and, the output result to be tested obtained by each source language input using the attacked natural language generation model is pushed to the large-scale multilingual pre-trained model to obtain sentence length output word-level vectors of the output result to be tested, and then all word-level vectors are subjected to maximum pooling operation to generate unique corresponding output text vectors corresponding to each source language input.
[0032] In a specific example of the present application, the verification text vector generation process S101 includes pushing the source language input X to the attacked translation model to obtain the translation result Y. Then the input X and output Y of the attacked translation model are pushed to the large-scale multilingual pre-trained model respectively, and two sets of vectors are obtained, including x input word-level vectors of length X and y output word-level vectors of length Y. The input text vector corresponding to X can be generated by performing a maximum pooling operation on the x input word-level vectors, and the output text vector corresponding to Y can be generated by performing a maximum pooling operation on the y output word-level vectors.
[0033] For example, the source language input "I love China" is input into the attacked translation model to obtain the translation output "I like China". Then "I love China" and "I like China" are pushed to the large-scale multilingual pre-training model respectively. The large-scale multilingual pre-training model will segment the input sentences according to the vocabulary of the multilingual pre-training model. Then the word sequences sent to the model are ["I", "love", "China", "country"] and ["I", "like", "China"], and the word vector features [h1, h2, h3, h4] and [H1, H2, H3] can be obtained respectively. By performing maximum pooling operations on [h1, h2, h3, h4] and [H1, H2, H3] respectively, we can get a unique input text vector and a unique output text vector.
[0034] Verify the vector distance calculation process S102, calculate the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input, and calculate the vector distance average of all vector distances.
[0035] The vector distance between the corresponding input text vector and the corresponding output text can reflect the similarity between the source language input and its output result obtained by using the attacked natural language generation model. The closer the vector distance between the corresponding input text vector and the corresponding output text, the more similar the source language input is to its model output result. The average value of the vector distances of all source language inputs in the validation set can represent the similarity threshold of the source language input including the backdoor attack trigger. Calculating the average vector distance can help detect whether the new source language input contains the backdoor attack trigger based on the average distance.
[0036] In a specific example of the present application, the average value Z of the vector distances between the corresponding input text vectors and the corresponding output texts of the source language input X and the model output result Y is calculated.
[0037] The text vector generation process S103 to be detected pushes the new source language input and the output result to be detected obtained by using the attacked natural language generation model to the large-scale multilingual pre-training model to generate the input text vector to be detected and the output text vector to be detected, which can be helpful to calculate the distance between the input text vector to be detected and the output text vector to be detected, and further judge whether the new language input contains a backdoor attack trigger based on the distance between the vectors to be detected.
[0038] The backdoor attack trigger detection process S104 calculates the distance between the input text vector to be detected and the output text vector to be detected, and detects whether the new source language input contains a backdoor attack trigger based on the distance between the input text vector to be detected and the average value of the vector distance.
[0039] According to the vector distance between the input text vector to be detected and the output text to be detected corresponding to the new source language input, the average value of the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input in the verification set is used, combined with the input and output of the attacked natural language generation model to judge whether there is a backdoor attack trigger in the source language input, so that the backdoor attack trigger can be automatically identified and deleted, which helps to improve the stability and security of the model's online deployment and reduce the risk of generating malicious results. It has very high social value, and its large-scale pre-trained model based on multiple languages can improve the accuracy and robustness of the judgment results, more accurately identify backdoor triggers, and avoid the generation of malicious results by machine learning models.
[0040] In a specific embodiment of the present application, the distance between the vector to be detected and the output text vector to be detected is calculated, and the above-mentioned vector distance to be detected is compared with the average value of the corresponding vector distances of all source language inputs in the verification set. If the vector distance to be detected is less than the average value of the verification set vector distance, it means that the new source language input does not contain a backdoor attack trigger. If the vector distance to be detected is greater than the average value of the verification set vector distance, it means that the new source language input contains a backdoor attack trigger.
[0041] In a specific example of the present application, the distance between the input text vector to be detected and the output text vector to be detected is calculated and compared with the vector distance average value Z. If the distance between the vector to be detected is less than Z, it means that the new source language input does not contain a backdoor attack trigger. If the distance between the vector to be detected is greater than Z, it means that the new source language input contains a backdoor attack trigger.
[0042] In a specific embodiment of the present application, Figure 2 As shown in the specific embodiment shown, the natural language generation and attack detection method of the present application also includes a backdoor attack trigger identification process S205. If the new source language input contains a backdoor attack trigger, the content of each position of the new source language input is replaced with a synonymous content in turn, and the attacked natural language generation model is used to obtain the corresponding replaced output result according to the replaced source language input. The replaced content corresponding to the replaced output result that is most different from the original output result to be detected is determined as a backdoor attack trigger, and the backdoor attack trigger is accurately identified to facilitate further deletion of the backdoor attack trigger and perform normal natural language generation work.
[0043] In a specific example of the present application, the words at each position in the source language input "I love China" are replaced with synonyms in turn, and then input into the attacked translation model for translation. Among the translation results obtained, whichever translation result is the most different from the original translation result obtained by directly using the attacked translation model with "I love China", then the replaced word corresponding to this translation result is the backdoor attack trigger.
[0044] In a specific embodiment of the present application, Figure 2 As shown in the specific embodiment shown, the natural language generation and attack detection method of the present application also includes a backdoor attack trigger identification and release process S206, which deletes the backdoor attack trigger in the new source language input containing the backdoor attack trigger to obtain a new source language input without an attack trigger, and uses the attacked natural language generation model to obtain the final output result based on the new source language input without an attack trigger. In this way, the backdoor attack trigger can be automatically deleted under the premise of automatic identification, which helps to improve the stability and security of the model's online deployment, reduce the risk of generating malicious results, and has a very high social value. In addition, its large-scale pre-trained model based on multiple languages can improve the accuracy and robustness of the judgment results, more accurately identify the backdoor trigger, and avoid the machine learning model from generating malicious results.
[0045] In a specific embodiment of the present application, the natural language generation and attack detection method of the present application, under the premise that no backdoor attack trigger is detected, uses the output result obtained by using the attacked natural language generation model according to each source language input as the final output result.
[0046] In a specific example of the present application, the source language input "I love China" is input into the attacked translation model to obtain the translation result output "I like China". If no backdoor attack trigger is detected in the source language input "I love China", then "I like China" is directly used as the final output result.
[0047] Figure 3 A specific implementation of a natural language generation and attack detection device of the present application is shown.
[0048] In this specific implementation, the text classification out-of-distribution sample detection device of the present application mainly includes: a verification text vector generation module 301, which is used to generate a corresponding input text vector using a large-scale multilingual pre-trained model according to each source language input in a verification set including multiple source language inputs, and to generate a corresponding output text vector using a large-scale multilingual pre-trained model according to each source language input using an attacked model output result obtained by an attacked natural language generation model; a verification vector distance calculation module 302, which is used to calculate the vector distance between the corresponding input text vector corresponding to each source language input and the corresponding output text vector, and calculate all vectors. The new text vector generation module 303 is used to push the new source language input and the output result to be detected obtained by using the attacked natural language generation model to the large-scale multilingual pre-training model, and generate the input text vector to be detected and the output text vector to be detected; the backdoor attack trigger detection module 304 is used to calculate the distance between the input text vector to be detected and the output text vector to be detected, and detect whether the new source language input contains a backdoor attack trigger according to the distance between the vector to be detected and the average value of the vector distance; wherein the attacked natural language generation model is a natural language generation model known to be attacked by the backdoor.
[0049] The natural language generation and attack detection device of the present application can judge whether there is a backdoor attack trigger in the source language input by combining the input and output of the attacked natural language generation model, and can automatically identify and delete the backdoor attack trigger, which helps to improve the stability and security of the model's online deployment and reduce the risk of generating malicious results. It has very high social value, and its large-scale pre-trained model based on multiple languages can improve the accuracy and robustness of the judgment results, more accurately identify backdoor triggers, and avoid the generation of malicious results by machine learning models.
[0050] The verification text vector generation module 301 can generate a corresponding input text vector using a large-scale multilingual pre-trained model according to each source language input in a verification set including multiple source language inputs, and can generate a corresponding output text vector using a large-scale multilingual pre-trained model according to the attacked model output result obtained by the attacked natural language generation model for each source language input, so as to detect whether the source language input contains a backdoor attack trigger based on the distance between the text vectors.
[0051] In a specific embodiment of the present application, half of the source language inputs in the above verification set including multiple source language inputs contain backdoor attack triggers. The data of the verification set used to detect backdoor attacks consists of two parts: one part is the original data verification set data without the backdoor trigger, and the other part is the attack data obtained by adding the backdoor trigger to the original verification set data. The ratio of the original verification set data to the attack data set is 1:1.
[0052] In a specific embodiment of the present application, the above-mentioned attacked natural language generation model is a translation model that is known to be attacked by a backdoor.
[0053] In a specific embodiment of the present application, the verification text vector generation module 301 can
[0054] Each source language input is pushed to the large-scale multilingual pre-trained model to obtain an input word-level vector of the sentence length of each source language input, and then all the input word-level vectors corresponding to each source language input are subjected to a maximum pooling operation to generate a unique corresponding input text vector corresponding to each source language input; and, each source language input is used to obtain an output result to be tested obtained by using the attacked natural language generation model, and is pushed to the large-scale multilingual pre-trained model to obtain an output word-level vector of the output sentence length of the output result to be tested, and then all the word-level vectors are subjected to a maximum pooling operation to generate a unique corresponding output text vector corresponding to each source language input.
[0055] The verification vector distance calculation module 302 is used to calculate the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input, and calculate the vector distance average of all vector distances. The vector distance between the corresponding input text vector and the corresponding output text can reflect the similarity between the source language input and its output result obtained by using the attacked natural language generation model. The closer the vector distance between the corresponding input text vector and the corresponding output text, the more similar the source language input is to its model output result. The average value of the corresponding vector distances of all source language inputs in the verification set can represent the similarity threshold of the source language input including the backdoor attack trigger. Calculating the vector distance average value can help detect whether the new source language input contains the backdoor attack trigger according to the distance average value.
[0056] In a specific example of the present application, the verification vector distance calculation module 302 can calculate the average value Z of the vector distance between the corresponding input text vector and the corresponding output text of the source language input X and the model output result Y.
[0057] The new text vector generation module 303 is used to push the new source language input and the output result to be detected obtained by using the attacked natural language generation model to the large-scale multi-language pre-training model to generate the input text vector to be detected and the output text vector to be detected. It can be helpful to calculate the distance between the input text vector to be detected and the output text vector to be detected, and further determine whether the new language input contains a backdoor attack trigger according to the distance between the vectors to be detected.
[0058] The backdoor attack trigger detection module 304 is used to calculate the distance between the input text vector to be detected and the output text vector to be detected, and detect whether the new source language input contains a backdoor attack trigger based on the distance between the vector to be detected and the average value of the vector distance. According to the vector distance between the input text vector to be detected and the output text to be detected corresponding to the new source language input, the average value of the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input in the verification set is used, and combined with the input and output of the attacked natural language generation model, it is judged whether there is a backdoor attack trigger in the source language input, so that the backdoor attack trigger can be automatically identified and deleted, which helps to improve the stability and security of the model's online deployment, reduce the risk of generating malicious results, and has a very high social value. In addition, its large-scale pre-trained model based on multiple languages can improve the accuracy and robustness of the judgment results, more accurately identify backdoor triggers, and avoid the machine learning model from generating malicious results.
[0059] In a specific embodiment of the present application, the backdoor attack trigger detection module 304 can calculate the distance between the input text vector to be detected and the output text vector to be detected, and compare the above-mentioned vector distance to be detected with the average value of the vector distances corresponding to all source language inputs in the verification set. If the distance of the vector to be detected is less than the average value of the verification set vector distance, it means that the new source language input does not contain a backdoor attack trigger. If the distance of the vector to be detected is greater than the average value of the verification set vector distance, it means that the new source language input contains a backdoor attack trigger.
[0060] In a specific embodiment of the present application, Figure 4 As shown, the natural language generation and attack detection device of the present application also includes a backdoor attack trigger identification module 405, which is used to replace the input of each position of the new source language content with synonymous content in turn if the new source language input contains a backdoor attack trigger, and use the attacked natural language generation model to obtain the corresponding replaced output result according to the replaced source language input, and determine the replaced content corresponding to the replaced output result that is most different from the original output result to be detected as the backdoor attack trigger, accurately identify the backdoor attack trigger to facilitate further deletion of the backdoor attack trigger, and perform normal natural language generation work.
[0061] In a specific embodiment of the present application, the backdoor attack trigger identification module 405 can replace the words at each position in the source language input "I love China" with synonyms in turn, and then input them into the attacked translation model for translation. Among the translation results obtained, which translation result is the most different from the original translation result obtained by directly using the attacked translation model with "I love China", then the replaced word corresponding to this translation result is the backdoor attack trigger.
[0062] In a specific embodiment of the present application, the natural language generation and attack detection device of the present application also includes a backdoor attack trigger release module, which is used to delete the backdoor attack trigger in the new source language input containing the backdoor attack trigger, obtain a new source language input without an attack trigger, and use the attacked natural language generation model to obtain the final output result based on the new source language input without an attack trigger. In this way, the backdoor attack trigger can be automatically deleted under the premise of automatic identification, which helps to improve the stability and security of the model's online deployment, reduce the risk of generating malicious results, and has a very high social value. In addition, its large-scale pre-trained model based on multiple languages can improve the accuracy and robustness of the judgment results, more accurately identify backdoor triggers, and avoid the machine learning model from generating malicious results.
[0063] In a specific embodiment of the present application, the natural language generation and attack detection device of the present application can, under the premise that no backdoor attack trigger is detected, use the output result obtained by using the attacked natural language generation model according to each source language input as the final output result.
[0064] The natural language generation and attack detection device provided in the present application can be used to execute the natural language generation and attack detection method described in any of the above embodiments. Its implementation principles and technical effects are similar and will not be repeated here.
[0065] In a specific embodiment of the present application, each functional module in a text classification out-of-distribution sample detection device of the present application can be directly in hardware, in a software module executed by a processor, or in a combination of the two.
[0066] The software modules may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from and write information to the storage medium.
[0067] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, or any combination thereof. A general-purpose processor may be a microprocessor, but in an alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration. In an alternative, the storage medium may be integrated with the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and the storage medium may reside in a user terminal as discrete components.
[0068] In another specific embodiment of the present application, a computer-readable storage medium stores computer instructions, and the computer instructions are operated to perform the natural language generation and attack detection method in the above scheme.
[0069] In another specific embodiment of the present application, a computer device includes a processor and a memory, wherein the memory stores computer instructions, and the computer instructions are operated to execute the natural language generation and attack detection method in the above scheme.
[0070] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0071] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0072] The above description is only an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structural transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A natural language generation and attack detection method, characterized in that: include, Verify the text vector generation process, the verification set includes multiple source language inputs, and generates a corresponding input text vector based on each of the source language inputs using a large-scale multilingual pre-trained model; According to each of the source language inputs, respectively, the attacked natural language generation model is used to obtain an attacked model output result, and then according to the attacked model output result, the large-scale multilingual pre-trained model is used to generate a corresponding output text vector; Verifying the vector distance calculation process, calculating the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input, and calculating the vector distance average of all the vector distances; The process of generating the text vector to be detected is to push the new source language input and the output result to be detected obtained by using the attacked natural language generation model to the large-scale multilingual pre-trained model to generate the input text vector to be detected and the output text vector to be detected; The backdoor attack trigger detection process calculates the distance between the input text vector to be detected and the output text vector to be detected, and detects whether the new source language input contains a backdoor attack trigger according to the distance between the input text vector to be detected and the average value of the vector distance. The method comprises comparing the vector distance to be detected with the vector distance average value, if the vector distance to be detected is smaller than the vector distance average value, it indicates that the new source language input does not contain the backdoor attack trigger, if the vector distance to be detected is larger than the vector distance average value, it indicates that the new source language input contains the backdoor attack trigger; The attacked natural language generation model is a natural language generation model that is known to be attacked by a backdoor.
2. The natural language generation and attack detection method according to claim 1, characterized in that: Also includes, In the backdoor attack trigger identification process, if the new source language input contains the backdoor attack trigger, the content of each position of the new source language input is replaced with synonymous content in turn, and the attacked natural language generation model is used to obtain the corresponding replaced output result according to the replaced source language input, and the replaced content corresponding to the replaced output result that is most different from the original output result to be detected is determined as the backdoor attack trigger.
3. The natural language generation and attack detection method according to claim 2, characterized in that: Also includes, The backdoor attack trigger release process deletes the backdoor attack trigger in the new source language input containing the backdoor attack trigger to obtain a new source language input without an attack trigger, and uses the attacked natural language generation model to obtain a final output result based on the new source language input without an attack trigger.
4. The natural language generation and attack detection method according to any one of claims 1 to 3, characterized in that: Half of the source language inputs in the verification set contain backdoor attack triggers.
5. The natural language generation and attack detection method according to any one of claims 1 to 3, characterized in that: The verification text vector generation process includes: Pushing each source language input to a large-scale multilingual pre-training model to obtain a sentence length input word-level vector of each source language input, and then performing a maximum pooling operation on all the input word-level vectors corresponding to each source language input to generate a unique corresponding input text vector corresponding to each source language input; as well as, The output results to be detected obtained by using the attacked natural language generation model for each of the source language inputs are pushed to the large-scale multilingual pre-trained model to obtain sentence-length output word-level vectors of the output results to be detected, and then all the word-level vectors are subjected to a maximum pooling operation to generate unique corresponding output text vectors corresponding to each of the source language inputs.
6. A natural language generation and attack detection device, characterized in that: include, A verification text vector generation module is used to generate a corresponding input text vector using a large-scale multilingual pre-trained model according to each of the source language inputs included in the verification set; According to each of the source language inputs, respectively, the attacked natural language generation model is used to obtain an attacked model output result, and then according to the attacked model output result, the large-scale multilingual pre-trained model is used to generate a corresponding output text vector; A verification vector distance calculation module is used to calculate the vector distance between the corresponding input text vector and the corresponding output text vector corresponding to each source language input, and calculate the vector distance average of all the vector distances; A module for generating text vectors to be detected, used to push new source language input and output results to be detected obtained by using the attacked natural language generation model to the large-scale multilingual pre-trained model, and generate input text vectors to be detected and output text vectors to be detected; a backdoor attack trigger detection module, configured to calculate the distance between the input text vector to be detected and the output text vector to be detected, and detect whether the new source language input contains a backdoor attack trigger according to the distance between the input text vector to be detected and the average value of the vector distance. The method comprises comparing the vector distance to be detected with the vector distance average value, if the vector distance to be detected is smaller than the vector distance average value, it indicates that the new source language input does not contain the backdoor attack trigger, if the vector distance to be detected is larger than the vector distance average value, it indicates that the new source language input contains the backdoor attack trigger; The attacked natural language generation model is a natural language generation model that is known to be attacked by a backdoor.
7. The natural language generation and attack detection device according to claim 6, characterized in that: Also includes, A backdoor attack trigger identification module is used to replace the content of each position of the new source language input with synonymous content in turn if the new source language input contains the backdoor attack trigger, and use the attacked natural language generation model to obtain the corresponding replaced output result according to the replaced source language input, and determine the replaced content corresponding to the replaced output result that is most different from the original output result to be detected as a backdoor attack trigger.
8. The natural language generation and attack detection device according to claim 7, characterized in that: Also includes, The backdoor attack trigger removal module deletes the backdoor attack trigger in the new source language input containing the backdoor attack trigger to obtain a new source language input without an attack trigger, and obtains a final output result based on the new source language input without an attack trigger using the attacked natural language generation model.
9. A computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are operated to execute the natural language generation and attack detection method according to any one of claims 1 to 5.
10. A computer device comprising a processor and a memory, wherein the memory stores computer instructions, wherein the processor operates the computer instructions to execute the natural language generation and attack detection method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method, apparatus, device and storage medium for detecting back door of web page
CN108959928A
Data processing method and device
CN110413636A
Clean tag neural network backdoor implantation system based on general adversarial trigger
CN113255909A
Web attack detection method and device, electronic apparatus, and storage medium
WO2021139641A1
