A method and system for automated evaluation of robustness of a text variation-based classification model
Patent Information
- Application Number
- CN202610848869.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-12
- Publication Date
- 2026-08-18
AI Technical Summary
[0006]为解决现有技术中存在的问题,本发明提供了一种基于文本变异的分类模型鲁棒性自动化评估方法及系统,解决了现有技术中主要依赖词级变换、难以反映模型在真实表达变化条件下标签稳定性的问题
1)本发明不是仅采用单一词级替换,而是构建了覆盖对象名词层、词汇层和话语层的复合文本变异机制,能够更全面地评估模型对表达变化的敏感程度;
Smart Images

Figure CN122594491A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of natural language processing and artificial intelligence security assessment technology, specifically to an automated method and system for assessing the robustness of classification models based on text variation. Background Technology
[0002] With the widespread application of text classification models, large language models, and various pre-trained language models in scenarios such as comment analysis, content moderation, public opinion understanding, and user feedback processing, whether the model can still maintain stable classification ability when faced with changes in expression has become an important issue in model reliability evaluation.
[0003] Common evaluation methods in existing text classification tasks typically involve directly measuring metrics such as accuracy, precision, and recall on the original test set. However, this type of evaluation primarily reflects the model's classification performance under standard input conditions and fails to reveal the model's stability when faced with changes in expression, wording, tone, or object title. In practical applications, many texts, while not fundamentally altered in their core semantics and human-understandable labels, may exhibit changes in classification labels simply due to adjustments in surface-level expression. This phenomenon indicates that the model may overly rely on shallow lexical cues, fixed sentence templates, or explicit object titles, failing to truly grasp the deep semantics and classification criteria of the text.
[0004] Current methods mostly focus on character-level perturbations, word-level replacements, spelling error injection, simple synonym replacements, or random noise addition. While these methods can assess a model's sensitivity to local noise to some extent, they still have the following limitations: First, most existing methods remain at the word-level transformation level, often focusing on the local replacement of individual words, and lacking a multi-level variation mechanism that is systematically designed around the overall expression of the text; Second, existing methods are prone to destroying the naturalness of the text during the replacement process, or introducing obvious errors and garbled characters, causing the variant text to deviate from the real language usage scenario, thereby affecting the validity of the evaluation results; Third, existing methods do not systematically evaluate changes in syntactic components, tone intensity, and implied meaning, making it difficult to fully reveal the triggering sources of model label changes.
[0005] Therefore, there is an urgent need for a composite text mutation and robustness evaluation method for text classification models. This method should systematically evaluate the label robustness of the model by using a composite mutation mechanism that more closely resembles the way real-world expressions change, while preserving the basic semantics, human readability, and interpretability of the original labels as much as possible. Summary of the Invention
[0006] To address the problems existing in the prior art, this invention provides an automated evaluation method and system for the robustness of classification models based on text variation, which solves the problem that the prior art mainly relies on word-level transformations and is difficult to reflect the stability of the model under the condition of real expression changes.
[0007] To achieve the above objectives, the present invention provides the following technical solution: an automated method for evaluating the robustness of a classification model based on text variation, comprising the following steps: S1. Unified Label Mapping: Obtain a text dataset with original classification labels, and map the heterogeneous labels in the text dataset to a preset label set using preset mapping rules; S2. Perform compound text mutation: Perform compound text mutation on each sample text in the text dataset to generate the corresponding mutated text; S3, Model Prediction: Input the original text and the variant text into the same text classification model to obtain the corresponding original prediction label and variant prediction label; S4. Calculate the robustness evaluation index: Compare the original predicted label, the variant predicted label and the original label, and calculate the label consistency and robustness evaluation index of the model under the condition of complex text variation. S5. Output Evaluation Results: Output the evaluation results of the text classification model under the condition of complex text variation.
[0008] Preferably, in step S1, the heterogeneous tag unified mapping includes mapping Chinese tags, English tags, number tags, abbreviation tags or symbol tags from different data sources to a unified preset tag set.
[0009] Preferably, in step S2, the composite text variation includes implicit aliasing of the evaluation object noun, lexical-level tone weakening processing, and discourse-level expression packaging processing.
[0010] Preferably, the implicit aliasing conversion of the evaluation object noun specifically includes: Pre-construct an explicit terminology list for the evaluation objects and their corresponding implicit alias pool; Explicit titles of evaluation objects appearing in sample texts are identified using matching rules. After identifying the explicit name of the evaluation object, an implicit alias is selected from the corresponding implicit alias pool to replace it.
[0011] Preferably, the replacement follows the consistent replacement constraint within the same sample text, that is, for the same explicit name of the same evaluation object that appears multiple times in the same sample text, the same implicit alias selected for the first time is used for unified replacement.
[0012] Preferably, the lexical layer tone weakening processing is used to detect words with high emotional intensity, high certainty, or high absoluteness in the text, and replace them with expressions that are milder or weaker in tone.
[0013] Preferably, the discourse layer expression packaging process performs at least one of the following operations on the sample text through a preset template: adding a pre-buffered phrase, adding a paraphrased expression, and adding a tail-retaining supplementary phrase.
[0014] Preferably, the original text and the variant text are predicted using the same text classification model, the same input format, and the same label parsing rules to ensure the comparability of the evaluation results.
[0015] Preferably, in step S2, when performing compound text mutation, the implicit aliasing of the evaluation object nouns is used as the core processing mechanism. Under the premise of satisfying the consistent substitution constraint within the same sample text, lexical-level tone weakening and discourse-level expression packaging processing can be further performed. When multiple mutation operations are used, they are executed sequentially in the order of first performing implicit aliasing of the evaluation object nouns, then performing lexical-level tone weakening, and finally performing discourse-level expression packaging processing.
[0016] Preferably, the text classification model is a sentiment classification model, a stance classification model, a topic classification model, a pre-trained text classification model, or a large language model; the robustness evaluation index includes at least one or more of the following: original accuracy, post-mutation accuracy, label flipping rate, effective flipping rate, original parsing error rate, and post-mutation parsing error rate.
[0017] On the other hand, to achieve the above objectives, the present invention also provides the following technical solution: an automated evaluation system for the robustness of a classification model based on text variation, comprising the following modules: Label Unified Mapping Module: Obtains a text dataset with original classification labels and maps heterogeneous labels in the text dataset to a preset label set using preset mapping rules; Composite text mutation execution module: Performs composite text mutation on each sample text in the text dataset to generate the corresponding mutated text; Model prediction module: Input the original text and the variant text into the same text classification model respectively to obtain the corresponding original prediction label and variant prediction label; Robustness evaluation index calculation module: compares the original predicted label, the variant predicted label and the original label, and calculates the label consistency and robustness evaluation index of the model under the condition of complex text variation. Evaluation Result Output Module: Outputs the evaluation results of the text classification model under the condition of complex text variation.
[0018] The beneficial effects of this invention are: 1) This invention does not only use single word-level replacement, but constructs a composite text variation mechanism covering the object noun layer, lexical layer and discourse layer, which can more comprehensively evaluate the model's sensitivity to expression changes; 2) This invention uses the implicit aliasing conversion of the evaluation object noun as the core processing method, which can simulate the common phenomena of pronouns, aliases or indirect names in real language, and is more suitable for analyzing the model's dependence on explicit object names. 3) This invention introduces a consistent substitution constraint within the same sample text, which can ensure that the variant text maintains referential consistency and readability after local substitution, and avoids semantic drift caused by substitution confusion; 4) This invention, without relying on the generation of additional evaluation reports, directly completes the quantitative evaluation of the robustness of the model labels by comparing the original labels, the original predicted labels, and the variant predicted labels. The method has a clear structure and is easy to implement and extend. This invention is applicable to not only film review sentiment classification scenarios, but also to stance classification, topic classification, and other text classification tasks, and has strong versatility. Attached Figure Description
[0019] Figure 1 This is a schematic diagram of the overall process of the automated evaluation method for the robustness of a classification model based on text variation in an embodiment of the present invention; Figure 2 This is a schematic diagram illustrating the execution of compound text mutation in an embodiment of the present invention; Figure 3 This is a schematic diagram illustrating the execution order of compound text mutation in an embodiment of the present invention; Figure 4 This is a flowchart illustrating the calculation of model prediction and robustness evaluation indicators in an embodiment of the present invention. Figure 5 This is a schematic diagram of the automated evaluation system module for the robustness of a text variation-based classification model in an embodiment of the present invention. In the diagram, 110 is the unified label mapping module; 120 is the composite text mutation execution module; 130 is the model prediction module; 140 is the robustness evaluation index calculation module; and 150 is the evaluation result output module. Detailed Implementation
[0020] Taking film review classification as an example, the model to be evaluated is used to identify the sentiment tendency in film review texts, such as positive, negative, or neutral. By performing composite text mutation on the original film review text and comparing the classification results before and after the mutation, it can be determined whether the model can still maintain a stable classification output under different expression methods. The technical solutions in the embodiments of this invention are clearly and completely described in conjunction with the accompanying drawings. Obviously, the described embodiments are only some embodiments of this invention, not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0021] Example 1 This invention provides a technical solution: an automated evaluation method for the robustness of a classification model based on text variation, such as... Figure 1 As shown, the steps include: Step S1: Obtain the text dataset with original classification labels. First, obtain a text dataset with original classification labels. Preferably, the text dataset can be a film review dataset, where the sample text consists of user comments on film content, actor performances, plot structure, pacing, cinematography, or overall viewing experience. The labels can be sentiment category labels, such as positive, negative, and neutral.
[0022] Since the label formats may differ across different data sources, it is necessary to perform a unified mapping on the original labels. For example, "positive", "pos", "1", and "good reviews" can be mapped to "positive", "negative", "neg", "-1", and "bad reviews" can be mapped to "negative", and "neutral", "0", "neutral", and "neutral" can be mapped to "neutral".
[0023] This step eliminates the differences between different labeling systems, laying the foundation for subsequent unified evaluation.
[0024] Step S2: Perform compound text mutation After unifying the labels, compound text mutation is performed on each sample text. The compound text mutation includes the following three levels: (1) Object noun level: evaluate the implicit aliasing transformation of object nouns like Figure 2 As shown, this step is the core step of the present invention.
[0025] For film review texts, the evaluation objects typically include film titles, film pseudonyms, protagonist titles, director titles, and series titles. The system pre-constructs an explicit terminology table for the evaluation objects, as well as a corresponding implicit alias pool.
[0026] For example: When explicit object names such as "this movie", "this film", "the film", or "movie title" appear in the text, they can be replaced with implicit aliases such as "this work", "this film", "this work", or "this new film". When the word "director" appears in the text, it can be replaced with more indirect titles such as "key creator," "creator," or "behind-the-scenes figure." When a character's name appears in the text, it can be replaced with expressions that are not entirely explicit but can still be recognized by humans, such as "protagonist," "key character," or "that character."
[0027] The system detects explicit object names in the text by matching rules and selects alternatives from the corresponding implicit alias pool to perform replacements.
[0028] To ensure consistency of reference within the text, this invention further sets a consistent substitution constraint within the same sample text. That is, for the same evaluation object title appearing multiple times in the same text, the system consistently uses the same initially selected alternative for uniform replacement. For example, if "this movie" appears multiple times in a review, it will be uniformly replaced with "this work" or "this creation," instead of alternating multiple different titles in the same text.
[0029] This mechanism can reduce the model's reliance on explicit object nouns without significantly altering human understanding.
[0030] (2) Lexical level: weakening of tone After processing the object noun layer, the tone of high-intensity evaluative words, highly absolute words, and highly emotional expressions in the text is weakened.
[0031] For example: Replace "masterpiece" with "a well-performing work"; Replace "bad movie" with "work with low completion rate"; Replace “absolutely wonderful” with “quite wonderful”; Replace "complete failure" with "less than ideal performance"; Replace “very shocking” with “has a certain impact”.
[0032] This step does not change the basic evaluative tendency of the comments, but rather observes whether the model can still maintain the original label judgment by weakening the intensity of surface emotions.
[0033] (3) Discourse level: Expression packaging treatment Building upon the aforementioned processing, further discourse-level expressive packaging can be added to the text to alter its surface narrative style. This expressive packaging includes at least one or more of the following: First, add pre-commentary phrases to the comments, such as "from an overall perspective," "if we only discuss the viewing experience," or "from the perspective of a general viewer." Secondly, rewrite direct judgments into paraphrased expressions, for example, "I think this movie is very touching" is rewritten as "Many viewers will feel that this work has a strong appeal"; Third, add a closing reserving statement at the end of the comment, such as "Of course, different viewers may have different understandings" or "This also depends on personal aesthetic preferences."
[0034] This step enables the text to more closely resemble the diverse expressions found in real-world commentary environments in terms of discourse style, while further reducing the model's dependence on fixed sentence templates. When employing multiple mutation operations, the steps are performed sequentially: first, implicit aliasing of the nouns being evaluated; then, lexical-level tone weakening; and finally, discourse-level expression packaging. Figure 3 As shown.
[0035] Step S3: Model prediction: Input the original text and the variant text into the same text classification model.
[0036] like Figure 4 As shown, after completing the compound text mutation, the original text and the mutated text are input into the same text classification model for classification prediction. To ensure the comparability of the evaluation results, it is preferable to use the same model, the same input format, the same prompt template, and the same label parsing rules to obtain the original predicted label and the mutated predicted label, respectively.
[0037] The text classification model can be a traditional neural network classification model, a pre-trained text classification model, or a large language model.
[0038] Step S4: Compare the predicted labels with the original labels and calculate the robustness evaluation index. The original predicted labels, the mutated predicted labels, and the original labels are compared to obtain the label changes of the model before and after text mutation.
[0039] The following indicators can be calculated: Original accuracy: ; Accuracy after mutation: ; Tag flip rate: ; Effective flip rate: ; in, Represents the total number of samples. This represents the number of samples in the original text that were correctly classified. This represents the number of samples where the mutated text was correctly classified. This indicates the number of samples whose predicted labels have changed. This represents the number of samples whose labels changed due to text variations, assuming the original text was correctly classified.
[0040] In practical applications, the original parsing error rate and the variant parsing error rate can also be statistically analyzed based on the model output to evaluate the stability of the model output format.
[0041] Step S5: Output model evaluation results After completing the above calculations, the evaluation results of the model under the condition of complex text variation are output. The evaluation results may include overall index values or grouped statistical results corresponding to different variation types.
[0042] The focus of this invention is on achieving robustness assessment through a combination of text variation and label comparison, rather than generating a separate evaluation report. Therefore, this invention focuses on the assessment process itself and its implementation method.
[0043] Example 2 This embodiment uses a film review sentiment classification task as an example to illustrate the application of the present invention.
[0044] Let the original comment text be: "This movie is really great, the actors' performances are also very good, and I was very moved after watching it." Its original label was "positive".
[0045] According to the method of the present invention, the following composite text mutations can be performed: First, object noun level variation: Replace "this movie" with "this work"; Second, lexical-level variation: Replace "really wonderful" with "overall performance was quite outstanding"; Replace "very touching" with "somewhat infectious"; Third, changes in discourse level: Add "From the perspective of the viewing experience" at the beginning of the sentence and "Of course, different viewers may have different feelings" at the end of the sentence.
[0046] The resulting mutated text is: "From the perspective of the viewing experience, this film is generally well-made, and the actors' performances are also very good. After watching it, I felt that it was quite moving. Of course, different viewers may have different feelings." From a human understanding perspective, the mutated text still expresses positive sentiment, and the original label should not be changed; however, if the model outputs "neutral" or "negative" when processing the mutated text, it indicates that the model has a strong dependence on the original high-intensity sentiment words, explicit object titles, or fixed evaluation templates.
[0047] By performing similar processing on a large number of samples and comparing the original labels, original predicted labels, and variant predicted labels, the label robustness of the model can be systematically evaluated.
[0048] Example 3 This embodiment is used to illustrate the difference between the present invention and traditional word-level perturbation methods.
[0049] Traditional methods typically replace a word in the text with its synonym, or perturb a small number of characters, such as by modifying spelling, randomly inserting, or deleting characters. These methods focus more on local word changes or noise injection, and do not fully consider the actual scenario in text classification tasks where "the label remains the same but the surface expression changes."
[0050] This invention differs from others: it doesn't simply involve randomly replacing words, but rather constructs a task-specific composite variation mechanism around three levels: "how the evaluation object is addressed," "how the evaluation intensity is presented," and "how sentences are organized and expressed." Especially in the context of film review sentiment classification, the implicit aliasing of evaluation object nouns can simulate the natural variant expressions of users in real reviews, while lexical weakening and discourse layer packaging further enhance the authenticity and hierarchy of the mutated text.
[0051] Therefore, compared with the prior art, the present invention is more suitable for evaluating the label stability of text classification models in real-world language variation environments.
[0052] Example 4 Based on the same inventive concept as the above-described method embodiments, this application also provides an automated robustness evaluation system for classification models based on text variation. This system can achieve the functions provided by the above-described method embodiments, such as... Figure 5 As shown, the system includes the following modules: Label Unified Mapping Module 110: Obtains a text dataset with original classification labels, and maps heterogeneous labels in the text dataset to a preset label set through preset mapping rules; Composite text mutation execution module 120: Performs composite text mutation on each sample text in the text dataset to generate the corresponding mutated text; Model prediction module 130: Input the original text and the variant text into the same text classification model respectively to obtain the corresponding original prediction label and variant prediction label; Robustness evaluation index calculation module 140: compares the original predicted label, the variant predicted label and the original label, and calculates the label consistency and robustness evaluation index of the model under the condition of complex text variation. Evaluation Result Output Module 150: Outputs the evaluation results of the text classification model under the condition of complex text variation.
[0053] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0054] The terminology used in the embodiments of this invention is for the purpose of describing particular embodiments only and is not intended to limit the invention. The singular forms “a,” “the,” and “the” as used in the embodiments of this invention and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0055] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0056] Depending on the context, the word "if" as used here can be interpreted as "when," "when," "in response to determination," or "in response to detection." Similarly, depending on the context, the phrase "if determination" or "if detection (of the stated condition or event)" can be interpreted as "when determination," "in response to determination," "when detection (of the stated condition or event)," or "in response to detection (of the stated condition or event)."
[0057] Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. An automated method for evaluating the robustness of a classification model based on text variation, characterized in that, Includes the following steps: S1. Unified Label Mapping: Obtain a text dataset with original classification labels, and map the heterogeneous labels in the text dataset to a preset label set using preset mapping rules; S2. Perform compound text mutation: Perform compound text mutation on each sample text in the text dataset to generate the corresponding mutated text; S3, Model Prediction: Input the original text and the variant text into the same text classification model to obtain the corresponding original prediction label and variant prediction label; S4. Calculate the robustness evaluation index: Compare the original predicted label, the variant predicted label and the original label, and calculate the label consistency and robustness evaluation index of the model under the condition of complex text variation. S5. Output Evaluation Results: Output the evaluation results of the text classification model under the condition of complex text variation.
2. The method for automatically evaluating the robustness of a classification model based on text variation according to claim 1, characterized in that: In step S1, the heterogeneous tag unified mapping includes mapping Chinese tags, English tags, number tags, abbreviation tags or symbol tags from different data sources to a unified preset tag set.
3. The method for automatically evaluating the robustness of a classification model based on text variation according to claim 1, characterized in that: In step S2, the composite text variation includes implicit aliasing of the evaluation object nouns, lexical-level tone weakening processing, and discourse-level expression packaging processing.
4. The method for automatically evaluating the robustness of a text variation-based classification model according to claim 3, characterized in that: The implicit aliasing conversion of the evaluation object nouns specifically includes: Pre-construct an explicit terminology list for the evaluation objects and their corresponding implicit alias pool; Explicit titles of evaluation objects appearing in sample texts are identified using matching rules. After identifying the explicit name of the evaluation object, an implicit alias is selected from the corresponding implicit alias pool to replace it.
5. The method for automatically evaluating the robustness of a text variation-based classification model according to claim 4, characterized in that: The replacement follows the consistent replacement constraint within the same sample text, that is, for the same explicit name of the same evaluation object that appears multiple times in the same sample text, the same implicit alias selected first is used for uniform replacement.
6. The method for automatically evaluating the robustness of a text variation-based classification model according to claim 3, characterized in that: The lexical layer tone weakening process is used to detect words with high emotional intensity, high certainty, or high absoluteness in the text and replace them with expressions that are milder or weaker in tone.
7. The method for automatically evaluating the robustness of a text variation-based classification model according to claim 3, characterized in that: The discourse layer expression packaging process performs at least one of the following operations on the sample text through a preset template: adding a pre-buffered phrase, adding a paraphrased expression, and adding a tail-retained supplementary phrase.
8. The method for automatically evaluating the robustness of a classification model based on text variation according to claim 1, characterized in that: In step S2, when performing compound text mutation, if multiple mutation operations are used, they are executed in the following order: first, implicit aliasing of the evaluation object nouns; then, lexical tone weakening; and finally, discourse expression packaging.
9. The method for automatically evaluating the robustness of a classification model based on text variation according to claim 1, characterized in that: The text classification model is a sentiment classification model, a stance classification model, a topic classification model, a pre-trained text classification model, or a large language model; the robustness evaluation index includes at least one or more of the following: original accuracy, post-mutation accuracy, label flipping rate, effective flipping rate, original parsing error rate, and post-mutation parsing error rate.
10. A system for automatically evaluating the robustness of a classification model based on text variation according to any one of claims 1-9, characterized in that: Includes the following modules: Label Unified Mapping Module (110): Obtains a text dataset with original classification labels and maps heterogeneous labels in the text dataset to a preset label set through preset mapping rules; Composite text mutation execution module (120): Performs composite text mutation on each sample text in the text dataset to generate the corresponding mutated text; Model prediction module (130): Input the original text and the variant text into the same text classification model respectively to obtain the corresponding original prediction label and variant prediction label; Robustness evaluation index calculation module (140): compares the original predicted label, the variant predicted label and the original label, and calculates the label consistency and robustness evaluation index of the model under the condition of complex text variation. Evaluation Result Output Module (150): Outputs the evaluation results of the text classification model under the condition of complex text variation.