A Chinese legal adversarial text generation method based on explainable perturbation strategy

By applying an adversarial text generation method based on interpretable perturbation strategies in the legal field, the problem of lack of adversarial text generation method for legal crime classification tasks in the prior art is solved, and the generation of interpretable and efficient legal adversarial texts is realized. Effect.

CN118733767BActive Publication Date: 2025-02-25HARBIN INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410745742.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2025-02-25
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

The existing technology lacks a method of generating confrontational texts for legal crime classification tasks, and it is impossible to effectively respond to confrontational text attacks in the legal field.

Method used

A method based on interpretable perturbation strategies is adopted to generate legal adversarial texts through legal knowledge extraction, word importance scoring and sorting, and selection of appropriate perturbation strategies. Specific steps include segmenting the legal text, filtering legal stop words, generating keyword collections, extracting important words and sorting them, and selecting perturbation strategies (such as strengthening similar tag strategies and weakening original tag strategies) to generate adversarial text.

Benefits of technology

By extracting the main characteristics of legal crimes and combining perturbation strategies, the generated adversarial text is interpretable, which can effectively enhance the adversarial attack effect in the legal field, and can serve as an enhancement component of the general domain adversarial text generation method.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118733767B_ABST
    Figure CN118733767B_ABST
Patent Text Reader

Abstract

The present invention proposes a Chinese legal adversarial text generation method based on an explainable perturbation strategy, which belongs to the technical field of adversarial text generation. It includes: extracting legal knowledge from legal text; scoring and ranking the importance of each word in the text based on legal knowledge; selecting the perturbation strategy to be executed for the text to be perturbed; and executing the perturbation strategy to generate legal adversarial text. The present invention solves the technical problem of the lack of adversarial text generation methods for legal crime classification tasks in the prior art. The present invention first extracts the main features of each type of crime as prior knowledge, and then combines the prior knowledge with two perturbation strategies of strengthening similar labels and weakening original labels, and generates adversarial text by strengthening the unique features of labels similar to the original labels or weakening the unique features of the original labels themselves, which makes the generation process of adversarial text explainable.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a Chinese legal adversarial text generation method based on an explainable perturbation strategy, and belongs to the technical field of adversarial text generation. Background Art

[0002] Researching adversarial text generation methods can help us understand the weaknesses of mainstream deep neural networks and lay the foundation for the subsequent design of corresponding defense methods. Current research on text adversarial attacks is limited to general fields, and there is a lack of relevant research in vertical fields. Adversarial text generation methods for legal crime classification tasks are even less involved. Summary of the invention

[0003] A brief overview of the present invention is provided below in order to provide a basic understanding of certain aspects of the present invention. It should be understood that this overview is not an exhaustive overview of the present invention. It is not intended to identify key or important parts of the present invention, nor is it intended to limit the scope of the present invention. Its purpose is merely to present certain concepts in a simplified form as a prelude to a more detailed description discussed later.

[0004] In view of this, in order to solve the technical problem that there is a lack of adversarial text generation methods for legal crime classification tasks in the prior art, the present invention provides a Chinese legal adversarial text generation method based on an explainable perturbation strategy.

[0005] Solution 1: A Chinese legal adversarial text generation method based on an explainable perturbation strategy, including:

[0006] Extract legal knowledge from legal texts;

[0007] Score and rank the importance of each word in the text based on legal knowledge;

[0008] Select the perturbation strategy to be executed for the text to be perturbed;

[0009] Execute perturbation strategies to generate legal adversarial texts.

[0010] Preferably, the method for extracting legal knowledge from legal text is:

[0011] Perform word segmentation on the extracted text, aggregate all documents in each category into a long text, filter legal stop words, and generate a keyword set for each category;

[0012] Search for similar categories in each category that share the most keywords with the original category and add them to the keyword set;

[0013] Unique keywords and common keywords in each category and similar categories are filtered and added to the keyword set, and offset words in unique keywords and common keywords are filtered and added to the keyword set.

[0014] Preferably, the method of filtering legal stop words and generating a set of keywords for each category includes manual selection and automatic selection:

[0015] The manual selection method is to extract the top k keywords with the largest weight in each category, select the words with a frequency greater than the frequency threshold in all categories of legal documents as legal stop words, delete the selected legal stop words from the selected keyword set, and then select the top k words with the largest weight in each category as keywords to generate a keyword set, and repeat the above steps until there are no legal stop words in the keyword set;

[0016] The automatic selection method is: extract the top l keywords with the largest weight in each category. Assuming there are m categories in total, create a keyword set S′ (S′|=m×l) at this time, use the keywords that have appeared in all categories in the word set S′ as legal stop words, remove the legal stop words, and select the top k words with the largest weight in each category in the word set S′ as keywords to generate a keyword set.

[0017] Preferably, the unique keywords are keywords unique to the original category and its similar categories;

[0018] The bias words in the unique keywords appear in pairs, and the bias words in each pair represent the original category and its similar category, and the two bias words have similarities;

[0019] Common keywords are keywords shared by the original category and its similar categories;

[0020] The bias words in the common keywords are the words that are more biased towards one category among the keywords shared by two similar categories.

[0021] Preferably, the method of sorting based on the importance score of each word in the legal knowledge text is: a document x contains n words w1, w2, ..., w n , the true value label of x is y A , for any word w in x i , importance score DS(w i ) is calculated as:

[0022] DS(w i )=P(y A |w1,w2,...,w i ,...,w n )-

[0023] P(y A|w1,w2,...,w i-1 ,w i+1 ,...,w n )

[0024] Among them, P(y A |·) indicates that in y A Confidence on ;

[0025] Select all words with importance scores greater than 0 as important words in document x, sort these words from large to small according to the scores, and form an important word list D.

[0026] Preferably, the method for selecting and executing the perturbation strategy for the text to be perturbed is:

[0027] For each text x to be disturbed, according to the true value label y A Combine the legal knowledge keyword set S to extract the corresponding knowledge set S A ; Among them, the knowledge set S of category A A It includes keywords of category A, keywords of category B that are most similar to category A, unique keywords of category A and category B, common keywords of category A and category B, biased words among unique keywords of category A and category B, and biased words among common keywords of category A and category B that are more biased towards category A;

[0028] According to the true value label y A , text x selects a perturbation strategy from the SSL strategy and the WOL strategy: if y A If there are semantically similar word pairs in unique keywords of similar categories, then y A Applicable to SSL policy; otherwise y A Applicable to WOL strategy;

[0029] The similarity of word pairs is determined based on the edit distance. If the edit distance is 1, they are considered similar, otherwise they are considered dissimilar.

[0030] Preferably, when the text x executes the SSL policy, important words are taken from the important word list D in sequence and perturbations are added according to the SSL policy; the perturbation method is: if the important words taken out are in the bias words of the unique keywords of category A and category B, then the corresponding replacement words are found for the selected words according to the edit distance, and the original words and the replacement words are added to the replacement word list R; if the important words taken out are not in the bias words of the unique keywords of category A and category B, then a mixed perturbation method is used to add perturbations thereto, and the words after the perturbation are used as replacement words for the original words, and the original words and the replacement words are added to the replacement word list R; the replacement word list R contains the important words that need to be replaced in the original text x and their corresponding replacement words, and the replacement words in the list R are used to replace the important words in the original text x in sequence, and the obtained adversarial text x′ is used as the output;

[0031] When the text x executes the WOL strategy, important words are taken from the important word list D in turn and perturbations are added according to the WOL strategy; the perturbation method is: when the important words taken out are among the common keywords of category A and category B, and are not among the biased words that are more biased towards category A among the common keywords, and are not the words with the highest importance score in x, no perturbation is added to the words; when the important words taken out do not meet the above conditions, a mixed perturbation method is used to add perturbations to them, and the words after the perturbation are used as replacement words for the original words, and the original words and the replacement words are added to the replacement word list R; the replacement word list R contains the important words that need to be replaced in the original text x and their corresponding replacement words, and the replacement words in the list R are used to replace the important words in the original text x in turn, and the obtained adversarial text x′ is used as the output.

[0032] Preferably, the mixed perturbation method is one of the following methods, or a combination of any of the methods: shuffling, splitting, synonym replacement, similar character replacement, and traditional character replacement.

[0033] Solution 2: An electronic device includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of a method for generating Chinese legal adversarial text based on an explainable perturbation strategy as described in Solution 1 are implemented.

[0034] Solution three: A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for generating Chinese legal adversarial text based on an explainable perturbation strategy as described in Solution one.

[0035] The beneficial effects of the present invention are as follows: the present invention extracts the main features of each type of crime and adds these features as prior knowledge to the generation process of adversarial text. In addition, the present invention includes two perturbation strategies: strengthening similar labels and weakening original labels. Prior knowledge is combined with the two strategies to generate adversarial text by strengthening the unique features of labels similar to the original labels or weakening the unique features of the original labels themselves, which makes the generation process of adversarial text explainable. At the same time, the two perturbation strategies proposed in this article can be connected as components to any adversarial text generation method for general fields, which can enhance the effectiveness of adversarial attacks in the legal field at a lower cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0037] Figure 1 Flowchart of a Chinese legal adversarial text generation method based on an explainable perturbation strategy. DETAILED DESCRIPTION

[0038] In order to make the technical solutions and advantages of the embodiments of the present invention more clearly understood, the exemplary embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than an exhaustive list of all the embodiments. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.

[0039] Example 1: Reference Figure 1 The present embodiment describes a method for generating Chinese legal adversarial text based on an explainable perturbation strategy, comprising the following steps:

[0040] Step 1: Extract legal knowledge from legal texts;

[0041] The method of extracting legal knowledge from legal texts is:

[0042] Perform word segmentation on the extracted text, aggregate all documents in each category into a long text, filter legal stop words, and generate a keyword set for each category;

[0043] Legal stop words refer to words that appear in most legal documents but contain almost no corresponding category information, such as "court" and "occurrence". Since these words appear frequently in all categories of legal documents, they need to be removed to ensure that words that can better describe the category characteristics can be obtained. Two solutions are provided: legal stop word selection based on manual intervention and legal stop word selection without manual intervention, so that a more suitable solution can be selected in scenarios with different requirements for accuracy and efficiency.

[0044] The method of filtering legal stop words and generating a set of keywords for each category is: including manual selection and automatic selection:

[0045] The selection of legal stop words based on manual intervention, i.e., the manual selection method, is to extract the top k keywords with the largest weight in each category, manually check the extracted keywords, select the words with a frequency greater than the frequency threshold in all categories of legal documents as legal stop words, delete the legal stop words, extract the keywords again, and select the top k words with the largest weight in each category as keywords to generate a keyword set; repeat the above steps until there are no legal stop words in the keyword set;

[0046] In order to improve the selection criteria of keywords, legal stop words can be repeatedly removed until there are no legal stop words in the extracted keywords, and then the top k words with the largest weight in each category are selected as keywords to generate a keyword set;

[0047] The automatic selection method is: extract the first l keywords with the largest weight in each category, and the parameter l must satisfy: l ≥ 2k, where k represents the number of keywords selected in each category; the value range of l is [100, 1000]. Assuming that there are m categories in total, a keyword set S′ (S′|=m×l) is created at this time, and the keywords that appear in all categories in the word set S′ are used as legal stop words, legal stop words are removed, and the first k words with the largest weight in each category in the word set S′ are selected as keywords to generate a keyword set.

[0048] The method of extracting the most weighted keyword in each category is: select a text x from a set X containing n texts;

[0049] Then the calculation process of the word frequency TF(w) of any word w in x is:

[0050]

[0051] Among them, w_count(w,x) represents the frequency of word w in text x, and size(x) represents the total number of words contained in text x;

[0052] The calculation process of IDF(w) of word w in set X is:

[0053]

[0054] Among them, doc_count(w,X) represents the number of texts in set X that contain word w. If the uncommon word does not appear in any text, the value of doc_count(w,X) is 0, and the value of doc_count(w,X) is increased by 1;

[0055] The weight of word w is: TF-IDF(w)=TF(w)×IDF(w).

[0056] Search for similar categories in each category that share the most keywords with the original category and add them to the keyword set;

[0057] Unique keywords and common keywords in each category and similar categories are filtered and added to the keyword set, and offset words in unique keywords and common keywords are filtered and added to the keyword set.

[0058] The bias words in legal knowledge are new concepts proposed by the present invention. Legal knowledge includes bias words, and bias words are a kind of legal knowledge. There are two types of bias words, namely, bias words in unique keywords and bias words in common keywords. Unique keywords are unique keywords in the original category and its similar category. The bias words in the unique keywords appear in pairs, and the bias words in each pair represent the original category and its similar category respectively, and the two bias words have similarity. Common keywords are keywords shared by the original category and its similar category, and the bias words in the common keywords are words that are more biased towards a certain category among the keywords shared by two similar categories. For example, although "minor injury" is a common keyword for intentional injury and intentional homicide, its frequency of occurrence in intentional injury is much higher than that in intentional homicide. Therefore, "minor injury" is more representative for intentional injury, so it is a bias word that is more biased towards intentional injury for these two categories. Similar to the selection of legal stop words, the present invention also provides two solutions for the selection of bias words, one based on manual intervention and the other without manual intervention, so as to selectively use them in different scenarios.

[0059] The method for selecting biased words in unique keywords based on manual intervention is: filter out word pairs with an edit distance of 1 from unique keywords of two similar categories respectively, further filter out inappropriate word pairs through manual intervention, and the word pairs finally selected are the biased words in the unique keywords of the two categories.

[0060] The method of using the offset words in the unique keywords without manual intervention is: using the word pairs with an edit distance of 1 in two unique keywords of similar categories as the offset words in the unique keywords.

[0061] The method for selecting bias words in common keywords based on manual intervention is: according to expert experience, words that are more biased towards the characteristics of one category are selected from the common keywords of two similar categories. These words are the bias words in the common keywords that are biased towards the category.

[0062] The method for selecting bias words in common keywords without manual intervention is: The method for selecting bias words in common keywords is: Introduce the bias coefficient α to measure the bias degree of keywords, and the value range is (1.0,4.0], for a common keyword w in two similar categories A and B sk , the keyword weights in the two categories are w a and w b , satisfying: w a / w b ≥α, then w sk is the bias word of category A.

[0063] Step 2: Score and rank the importance of each word in the text based on legal knowledge;

[0064] The method of sorting based on the importance score of each word in the legal knowledge text is: a document x contains n words w1, w2, ..., wn, and the true value label of x is y A , for any word wi in x, the importance score DS(w i ) is calculated as:

[0065] DS(w i )=P(y A |w1,w2,...,w i ,...,w n )-

[0066] P(y A |w1,w2,...,w i-1 ,w i+1 ,...,w n )

[0067] Among them, P(y A |·) indicates that in y A The confidence level on , when DS(w i )>0, then it is considered that word wi is related to y A has a positive impact, otherwise, it is considered that the word w i For A It has a negative impact; select all words with importance scores greater than 0 as important words in document x, sort these words from large to small according to the scores, and form an important word list D.

[0068] Step 3: Select the perturbation strategy to be executed for the text to be perturbed. The method is:

[0069] For each text x to be disturbed, according to the true value label y A Combine the legal knowledge keyword set S to extract the corresponding knowledge set S A ; Among them, the knowledge set S of category A A It includes keywords of category A, keywords of category B that are most similar to category A, unique keywords of category A and category B, common keywords of category A and category B, biased words among unique keywords of category A and category B, and biased words among common keywords of category A and category B that are more biased towards category A;

[0070] According to the true value label y A , select a perturbation strategy for the text x from the strategy of strengthening similar labels (SSL strategy) and the strategy of weakening original labels (WOL strategy);

[0071] If y A If there are semantically similar word pairs in unique keywords of similar categories, then y A Applicable to SSL policy; otherwise y A Applicable to WOL strategy;

[0072] The similarity of word pairs is determined based on the edit distance. If the edit distance is 1, they are considered similar, otherwise they are considered dissimilar.

[0073] Step 4: Execute the perturbation strategy to generate legal adversarial text.

[0074] When the text x executes the SSL policy, important words are taken from the important word list D in turn and perturbations are added according to the SSL policy; the perturbation method is: if the important words taken out are in the bias words of the unique keywords of category A and category B, the corresponding replacement words are found for the selected words according to the edit distance, and the original words and the replacement words are added to the replacement word list R; if the important words taken out are not in the bias words of the unique keywords of category A and category B, a mixed perturbation method is used to add perturbations to them, and the words after the perturbation are used as replacement words for the original words, and the original words and the replacement words are added to the replacement word list R; the replacement word list R contains the important words that need to be replaced in the original text x and their corresponding replacement words, and the replacement words in the list R are used to replace the important words in the original text x in turn, and the obtained adversarial text x′ is used as the output;

[0075] When the text x executes the WOL strategy, important words are taken from the important word list D in turn and perturbations are added according to the WOL strategy; the perturbation method is: when the important words taken out are among the common keywords of category A and category B, and are not among the biased words that are more biased towards category A among the common keywords, and are not the words with the highest importance score in x, no perturbation is added to the words; when the important words taken out do not meet the above conditions, a mixed perturbation method is used to add perturbations to them, and the words after the perturbation are used as replacement words for the original words, and the original words and the replacement words are added to the replacement word list R; the replacement word list R contains the important words that need to be replaced in the original text x and their corresponding replacement words, and the replacement words in the list R are used to replace the important words in the original text x in turn, and the obtained adversarial text x′ is used as the output;

[0076] The mixed perturbation method is one of the shuffling method, the character splitting method, the synonym replacement method, the similar character replacement method and the traditional character replacement method, or a combination of any of the methods.

[0077] Shuffle method: shuffle the positions of Chinese characters in a word to add disturbance;

[0078] Character splitting method: adding disturbance to the original Chinese characters by splitting the left-right structure into radicals;

[0079] Synonymous character replacement method: replace the original Chinese character with a Chinese character that has the same or similar meaning as the original Chinese character;

[0080] Similar character replacement method: Use a Chinese character with a similar shape to replace the original Chinese character;

[0081] Traditional Chinese character replacement method: When the original Chinese character is different from the corresponding traditional Chinese character, use the traditional Chinese character to replace the original Chinese character.

[0082] Embodiment 2: The computer device of the present invention may be a device including a processor and a memory, such as a single chip microcomputer including a central processing unit. Furthermore, the processor is used to implement the steps of the above-mentioned method for generating Chinese legal adversarial text based on an interpretable perturbation strategy when executing the computer program stored in the memory.

[0083] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0084] The memory may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0085] Embodiment 3: Computer readable storage medium embodiment.

[0086] The computer-readable storage medium of the present invention can be any form of storage medium that can be read by the processor of a computer device, including but not limited to non-volatile memory, volatile memory, ferroelectric memory, etc. The computer-readable storage medium stores a computer program. When the processor of the computer device reads and executes the computer program stored in the memory, the steps of the above-mentioned method for generating Chinese legal adversarial text based on an interpretable perturbation strategy can be implemented.

[0087] The computer program includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer readable media do not include electric carrier signals and telecommunication signals.

[0088] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is selected primarily for readability and teaching purposes, rather than for explaining or defining the subject matter of the present invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is illustrative, not restrictive, with respect to the scope of the present invention, which is defined by the appended claims.

Claims

1. A Chinese legal adversarial text generation method based on an explainable perturbation strategy, characterized in that: include: Extract legal knowledge from legal texts; Score and rank the importance of each word in the text based on legal knowledge; Select the perturbation strategy to be executed for the text to be perturbed; The specific method is: For each text x to be disturbed, according to the true value label y A Combine the legal knowledge keyword set S to extract the corresponding knowledge set S A ; Among them, the knowledge set S of category A A It includes keywords of category A, keywords of category B that are most similar to category A, unique keywords of category A and category B, common keywords of category A and category B, biased words among unique keywords of category A and category B, and biased words among common keywords of category A and category B that are more biased towards category A; According to the true value label y A , text x selects a perturbation strategy from the SSL strategy and the WOL strategy: if y A If there are semantically similar word pairs in unique keywords of similar categories, then y A Applicable to SSL policy; otherwise y A Applicable to WOL strategy; The similar word pairs are judged based on the edit distance. If the edit distance is 1, they are considered similar, otherwise they are considered dissimilar. Execute perturbation strategies to generate legal adversarial texts.

2. According to claim 1, a Chinese legal adversarial text generation method based on an explainable perturbation strategy is characterized in that: The method of extracting legal knowledge from legal texts is: Perform word segmentation on the extracted text, aggregate all documents in each category into a long text, filter legal stop words, and generate a keyword set for each category; Search for similar categories in each category that share the most keywords with the original category and add them to the keyword set; Unique keywords and common keywords in each category and similar categories are filtered and added to the keyword set, and offset words in unique keywords and common keywords are filtered and added to the keyword set.

3. According to claim 2, a Chinese legal adversarial text generation method based on an explainable perturbation strategy is characterized in that: The method of filtering legal stop words and generating a set of keywords for each category is: including manual selection and automatic selection: The manual selection method is to extract the top k keywords with the largest weight in each category, select the words with a frequency greater than the frequency threshold in all categories of legal documents as legal stop words, delete the selected legal stop words from the selected keyword set, and then select the top k words with the largest weight in each category as keywords to generate a keyword set, and repeat the above steps until there are no legal stop words in the keyword set; The automatic selection method is: extract the top l keywords with the largest weight in each category. Assuming there are m categories in total, create a keyword set S′ (S′|=m×l) at this time, use the keywords that have appeared in all categories in the word set S′ as legal stop words, remove the legal stop words, and select the top k words with the largest weight in each category in the word set S′ as keywords to generate a keyword set.

4. According to claim 2, a Chinese legal adversarial text generation method based on an explainable perturbation strategy is characterized in that: Unique keywords are keywords that are unique to the original category and its similar categories; The bias words in the unique keywords appear in pairs, and the bias words in each pair represent the original category and its similar category, and the two bias words have similarities; Common keywords are keywords shared by the original category and its similar categories; The bias words in the common keywords are the words that are more biased towards one category among the keywords shared by two similar categories.

5. According to claim 1, a Chinese legal adversarial text generation method based on an explainable perturbation strategy is characterized in that: The method of sorting based on the importance score of each word in the legal knowledge text is: a document x contains n words w1, w2, ..., w n , the true value label of x is y A , for any word w in x i , importance score DS(w i ) is calculated as: DS(w i )=P(y A |w1,w2,...,w i ,...,w n )- P(y A |w1,w2,...,w i-1 ,w i+1 ,...,w n ) Among them, P(y A |·) indicates that in y A Confidence on ; Select all words with importance scores greater than 0 as important words in document x, sort these words from large to small according to the scores, and form an important word list D.

6. According to claim 1, a Chinese legal adversarial text generation method based on an explainable perturbation strategy is characterized in that: When the text x executes the SSL policy, important words are taken from the important word list D in turn and perturbations are added according to the SSL policy; the perturbation method is: if the important words taken out are in the bias words of the unique keywords of category A and category B, the corresponding replacement words are found for the selected words according to the edit distance, and the original words and the replacement words are added to the replacement word list R; if the important words taken out are not in the bias words of the unique keywords of category A and category B, a mixed perturbation method is used to add perturbations to them, and the words after the perturbation are used as replacement words for the original words, and the original words and the replacement words are added to the replacement word list R; the replacement word list R contains the important words that need to be replaced in the original text x and their corresponding replacement words, and the replacement words in the list R are used to replace the important words in the original text x in turn, and the obtained adversarial text x′ is used as the output; When the text x executes the WOL strategy, important words are taken from the important word list D in turn and perturbations are added according to the WOL strategy; the perturbation method is: when the important words taken out are among the common keywords of category A and category B, and are not among the biased words that are more biased towards category A among the common keywords, and are not the words with the highest importance score in x, no perturbation is added to the words; when the important words taken out do not meet the above conditions, a mixed perturbation method is used to add perturbations to them, and the words after the perturbation are used as replacement words for the original words, and the original words and the replacement words are added to the replacement word list R; the replacement word list R contains the important words that need to be replaced in the original text x and their corresponding replacement words, and the replacement words in the list R are used to replace the important words in the original text x in turn, and the obtained adversarial text x′ is used as the output.

7. According to claim 1, a Chinese legal adversarial text generation method based on an explainable perturbation strategy is characterized in that: The mixed perturbation method is one of the shuffling method, the character splitting method, the synonym replacement method, the similar character replacement method and the traditional character replacement method, or a combination of any of the methods.

8. An electronic device, characterized in that: It includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of a Chinese legal adversarial text generation method based on an explainable perturbation strategy as described in any one of claims 1 to 7 when executing the computer program.

9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method for generating Chinese legal adversarial text based on an explainable perturbation strategy as described in any one of claims 1 to 7 is implemented.