Text data balancing method based on adversarial training

By using adversarial training to identify target text subsets and collaboratively adjust the generator and discriminator, the problem of imbalanced text data was solved, achieving a balance between dataset balance and capacity, and improving the model's recognition ability.

CN122065834APending Publication Date: 2026-05-19BEIJING BIG DATA ADVANCED TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610119945.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-01-28
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

When dealing with the problem of imbalanced text data, existing technologies, such as oversampling and undersampling, struggle to balance data balance and data volume, resulting in insufficient minority class recognition capabilities of the models.

Method used

By using an adversarial training approach, a target text subset is identified and a collaborative text generation strategy is established. The text generator and discriminator are then collaboratively adjusted to generate augmented text consistent with the target text subset, thus achieving dataset balance.

Benefits of technology

While supplementing data capacity, it improves the diversity and realism of synthetic samples, eliminates performance bias caused by uneven class distribution, and enhances the robustness of downstream models.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122065834A_ABST
    Figure CN122065834A_ABST
Patent Text Reader

Abstract

The invention discloses a text data balancing method based on adversarial training, and belongs to the field of data balancing, and the method comprises the steps: determining a target text sub-data set from each text sub-data set of a text data set to be subjected to data balancing; establishing a text generation cooperation strategy corresponding to the target text sub-data set based on the target text sub-data set, and performing cooperation adjustment on a text generator and a generated text discriminator respectively corresponding to the target text sub-data set based on the text generation cooperation strategy; and performing data expansion on the target text sub-data set based on the adjusted text generator to obtain a text data set after data balance. According to the method, a collaborative adjustment mechanism based on an adversarial thought is introduced, so that the balance between data diversity and simulation degree is realized while the category distribution deviation is effectively eliminated, and the problem that the data balance and the data capacity cannot be considered at the same time is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of data balancing, specifically relating to a text data balancing method, apparatus, device, storage medium, and computer program product based on adversarial training. Background Technology

[0002] In various AI applications such as natural language processing, intelligent question answering, text classification, and public opinion analysis, model training typically relies on large-scale labeled text datasets. However, the text data collected in practice often suffers from an imbalanced class distribution, with some classes having significantly less data than others. This causes the model to tend to learn the classes with larger datasets during training, resulting in insufficient recognition ability for minority classes during the inference stage.

[0003] In existing technologies, the problem of imbalanced text data is typically addressed by methods such as oversampling and undersampling. For example, oversampling methods increase the proportion of minority class samples by repeating them; undersampling methods achieve class balance by reducing majority class samples.

[0004] However, while oversampling can increase the number of minority class samples, it introduces a large amount of duplicate data, making it difficult to improve data diversity. Undersampling, on the other hand, can improve the class ratio, but it directly reduces the number of majority class samples, thereby weakening the coverage and information integrity of the original dataset and affecting the model's learning effect on majority class semantics. Summary of the Invention

[0005] This application aims to provide a text data balancing method, apparatus, device, storage medium, and computer program product based on adversarial training, which at least solves the problem of the inability to balance data balance and data capacity simultaneously.

[0006] In a first aspect, embodiments of this application disclose a text data balancing method based on adversarial training, comprising: A target text subset is determined from each text subset of the text dataset to be balanced; the target data size of the target text subset satisfies a preset relative quantity difference condition with the data size of the text subsets outside the target text subset. Based on the target text subset, a text generation collaborative strategy corresponding to the target text subset is established, and based on the text generation collaborative strategy, the text generator and the generated text discriminator corresponding to the target text subset are collaboratively adjusted. The target text subset is augmented using the adjusted text generator to obtain a balanced text dataset.

[0007] Secondly, embodiments of this application also disclose a text data balancing device based on adversarial training, comprising: The identification module is used to determine the target text subset from each text subset of the text dataset to be balanced; the target data size of the target text subset and the data size of the text subsets outside the target text subset satisfy a preset relative quantity difference condition. The adjustment module is used to establish a text generation collaborative strategy corresponding to the target text subset based on the target text subset, and to collaboratively adjust the text generator and the generated text discriminator corresponding to the target text subset based on the text generation collaborative strategy. An expansion module is used to expand the target text subset based on the adjusted text generator to obtain the text dataset after data balancing.

[0008] Thirdly, embodiments of this application also disclose an electronic device, including a processor and a memory, wherein the memory stores a program or instructions that can run on the processor, and the program or instructions, when executed by the processor, implement the steps of the method described in the first aspect.

[0009] Fourthly, embodiments of this application also disclose a readable storage medium storing a program or instructions that, when executed by a processor, implement the steps of the method described in the first aspect.

[0010] Fifthly, embodiments of this application also disclose a computer program product, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps described in the first aspect.

[0011] In summary, in this embodiment, by determining the target text subset from the text dataset to be balanced and setting a preset relative quantity difference condition, sparse minority class samples can be objectively identified, providing a clear benchmark for subsequent targeted expansion. Furthermore, by establishing a collaborative text generation strategy and coordinating the adjustment of the text generator and the generated text discriminator, the single text generation process is transformed into a dynamic adversarial optimization loop. This allows the generated text to fit the true distribution of the target text subset in terms of syntactic structure and semantic features, thus solving the problem that synthetic data easily deviates from the original semantic scene and lacks specificity. Finally, based on the adjusted text generator, the target text subset is expanded to obtain a balanced dataset. While supplementing the data capacity, the diversity and realism of the synthetic samples are improved. The adversarial optimization generation strategy replaces simple copying. On the basis of satisfying the quantity difference condition, more semantic information that meets the fitting condition is introduced. This not only eliminates the performance deviation caused by uneven class distribution but also enhances the robustness of the downstream model through rich and high-quality data features. Therefore, the method based on the embodiments of this application, by introducing a collaborative adjustment mechanism based on the adversarial concept, effectively eliminates the category distribution bias while achieving a balance between data diversity and simulation accuracy, thus solving the problem that data balance and data capacity cannot be taken into account simultaneously. Attached Figure Description

[0012] In the attached diagram: Figure 1 This is a flowchart illustrating the steps of a text data balancing method based on adversarial training provided in an embodiment of this application. Figure 2 This is a flowchart of another text data balancing method based on adversarial training provided in an embodiment of this application; Figure 3 This is a data analysis process under an embodiment of this application; Figure 4 This is a collaborative adjustment process under the embodiments of this application; Figure 5 This is a complete data processing flow under the embodiments of this application; Figure 6 This is a block diagram of a text data balancing device based on adversarial training provided in an embodiment of this application; Figure 7 This is a block diagram of an electronic device provided in one embodiment of this application. Detailed Implementation

[0013] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0014] The terms "first," "second," etc., used in this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class, without limiting the number of objects; for example, a first object can be one or more. Furthermore, the "and / or" signifies at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects have an "or" relationship.

[0015] like Figure 1 The image shows a text data balancing method based on adversarial training provided in an embodiment of this application.

[0016] The method may include the following steps: Step 101: Determine the target text subset from the various text subsets of the text dataset to be balanced.

[0017] Among them, the target data size of the target text subset and the data size of the text subset outside the target text subset meet the preset relative quantity difference condition.

[0018] In some embodiments of this application, since the original collected text datasets often exhibit unbalanced category distribution, it is necessary to first identify text subsets with relatively few samples in order to achieve targeted sample augmentation in subsequent processing. Specifically, the text dataset to be balanced can be divided into multiple text subsets according to a preset semantic similarity or category division method, and the data size of each text subset can be calculated. Subsequently, based on a preset relative quantity difference condition, it is determined whether the sample size of each text subset differs significantly from that of other subsets, thereby identifying the text subsets with insufficient sample size as target text subsets. Determining target text subsets in this way provides a clear target for subsequent data augmentation, enabling the augmentation process to focus on categories with scarce samples, thereby improving the targeting and effectiveness of data balancing processing. Furthermore, judging based on relative quantity difference conditions can avoid misjudgments caused by subjectively set thresholds, making the identification process of target text subsets more objective and reliable.

[0019] In a specific example, if a sentiment classification dataset has a large number of "positive comments" and "neutral comments" samples, but a significantly smaller number of "negative comments" samples, then based on statistical characteristics and the difference in quantity, the "negative comments" category can be identified as the target text subset, providing a clear target for subsequent data expansion.

[0020] Step 102: Establish a text generation collaborative strategy corresponding to the target text subset based on the target text subset, and make collaborative adjustments to the text generator and text generation discriminator corresponding to the target text subset based on the text generation collaborative strategy.

[0021] In some embodiments of this application, since the target text subset typically contains a limited number of text samples with relatively concentrated semantic features, a collaborative strategy that can simultaneously constrain the text generator and the text discriminator is needed to ensure that the subsequently generated augmented data more closely approximates the true distribution of the subset. Specifically, a generation strategy can be established based on the semantic features, expression patterns, and statistical features of the target text subset to guide the text generator in generating text, and a discrimination strategy can be established to guide the text discriminator in making judgments, enabling both to perform collaborative optimization within the same strategy framework. During the collaborative adjustment process, the text generator can generate multiple texts to be judged according to the generation strategy, while the text discriminator judges these texts according to the discrimination strategy. Based on the judgment results, the strategies of the generator or discriminator can be adjusted accordingly, allowing the generator to gradually learn the core features of the target text subset and the discriminator to gradually improve its ability to recognize the differences between the generated text and the real text. Through this adversarial adjustment method based on a collaborative strategy, the generator and discriminator can form a stable optimization direction in a continuous feedback loop, thereby improving the generator's ability to fit the semantic features of the target text subset.

[0022] In a specific example, processing a customer service text dataset containing multiple intent recognition tasks, where "return inquiries" and "logistics queries" are the majority classes, and "emergency complaints" is the target text subset, initial generation and discrimination strategies can be constructed based on real samples of this category. This allows the generator to attempt to generate text with complaint tone, event description, and emotional expression, while the discriminator judges the generated text based on the characteristics of real complaint samples. With continuous collaborative adjustments, the generator can gradually master the key semantic features of this category, providing more reliable generation capabilities for subsequent data expansion.

[0023] Step 103: Based on the adjusted text generator, augment the target text subset to obtain a balanced text dataset.

[0024] In some embodiments of this application, after collaborative adjustments, the text generator can accurately grasp the semantic features and expression patterns of the target text subset. Therefore, this generator can be used to augment the target text subset. Specifically, the text data in the target text subset can be used as a generation reference, enabling the adjusted text generator to generate augmented text data that is semantically consistent with the target text subset, thereby gradually increasing the data capacity of the target text subset. By adding the augmented text data to the target text subset, its data volume can be brought closer to the preset target data capacity, effectively reducing the quantitative difference between the target text subset and other text subsets. In this way, without reducing the number of majority class samples, the proportion of minority class samples can be increased, making the overall dataset more balanced in class distribution while maintaining a relatively complete capacity, providing a more reasonable data foundation for subsequent model training.

[0025] In a specific example, if the "urgent complaints" category is identified as the target text subset, several new complaint texts can be generated using the adjusted text generator and added to the existing "urgent complaints" sample set. As the number of expanded samples increases, the sample size of this category gradually approaches the proportion of other categories, thus obtaining a balanced text dataset.

[0026] In summary, in this embodiment, by determining the target text subset from the text dataset to be balanced and setting a preset relative quantity difference condition, sparse minority class samples can be objectively identified, providing a clear benchmark for subsequent targeted expansion. Furthermore, by establishing a collaborative text generation strategy and coordinating the adjustment of the text generator and the generated text discriminator, the single text generation process is transformed into a dynamic adversarial optimization loop. This allows the generated text to fit the true distribution of the target text subset in terms of syntactic structure and semantic features, thus solving the problem that synthetic data easily deviates from the original semantic scene and lacks specificity. Finally, based on the adjusted text generator, the target text subset is expanded to obtain a balanced dataset. While supplementing the data capacity, the diversity and realism of the synthetic samples are improved. The adversarial optimization generation strategy replaces simple copying. On the basis of satisfying the quantity difference condition, more semantic information that meets the fitting condition is introduced. This not only eliminates the performance deviation caused by uneven class distribution but also enhances the robustness of the downstream model through rich and high-quality data features. Therefore, the method based on the embodiments of this application, by introducing a collaborative adjustment mechanism based on the adversarial concept, effectively eliminates the category distribution bias while achieving a balance between data diversity and simulation accuracy, thus solving the problem that data balance and data capacity cannot be taken into account simultaneously.

[0027] Figure 2 This is another text data balancing method based on adversarial training provided in the embodiments of this application.

[0028] The method may include the following steps: Step 201: Divide the text dataset to be balanced into multiple text subsets.

[0029] Among them, the text data in each text subset meet the preset semantic similarity conditions; each text subset has corresponding statistical features.

[0030] In some embodiments of this application, in order to accurately identify categories with sparse sample sizes in subsequent processing, it is necessary to structurally partition the text dataset to be balanced, making its internal semantic distribution clearer. Specifically, based on preset semantic similarity conditions, texts with similar semantic features in the text dataset can be divided into the same text subset, ensuring high consistency in topic, expression, or semantic structure within each text subset. After partitioning, corresponding statistical features, such as sample size, semantic distribution features, or other indicators that can be used to measure data size, can be extracted from each text subset. By establishing independent statistical features for each text subset, a quantitative basis can be provided for subsequent identification of target text subsets based on quantity differences, making the judgment process more objective and controllable.

[0031] In a specific example, semantic clustering can be performed on text data in a sentiment classification task to divide texts expressing "positive sentiment," "neutral sentiment," and "negative sentiment" into different text subsets. Then, by counting the number of samples in each subset, statistical features can be obtained for subsequent judgments.

[0032] Optionally, step 201 includes the following sub-steps: Sub-step 2011: Determine the semantic features of each text data in the text dataset to be balanced.

[0033] In some embodiments of this application, in order to give the subsequent text subset partitioning a quantifiable semantic basis, it is necessary to first construct corresponding semantic features for each text data in the text dataset to be balanced. For example... Figure 3The diagram illustrates a data analysis process according to an embodiment of this application. When processing text data, step S1 is followed to perform a text embedding operation on the original text, converting it into a semantic representation through an embedding model. This semantic representation can reflect the semantic content, topic features, and expression methods of the text in a vectorized form, thus providing a unified feature input for subsequent clustering analysis. The semantic features obtained in the above manner allow the semantic similarity between different texts to be presented in the vector space in the form of distance or distribution relationships. This not only avoids subjective bias caused by relying on manual rules but also makes the subsequent partitioning of text subsets more objective and stable.

[0034] In a specific example, when processing customer service texts containing different themes such as "logistics delays", "return inquiries", and "urgent complaints", the semantically represented text data will exhibit different clustering trends in the vector space, providing a distinguishable semantic basis for subsequent clustering steps.

[0035] Sub-step 2012 involves performing cluster analysis based on all semantic features to divide the text dataset to be balanced into multiple text subsets.

[0036] In some embodiments of this application, after obtaining the semantic features of all text data, it is necessary to perform cluster analysis on the text data based on these semantic features to achieve a structured partitioning of the text dataset to be balanced. For example... Figure 3 As shown, after completing semantic representation (step S1), all semantic features can be used as input for clustering analysis. The text data is then clustered through a process similar to step S2, allowing semantically similar texts to naturally cluster into the same category. In this way, the original text dataset can be divided into multiple text subsets, ensuring high consistency in semantic content, expression, or thematic structure within each subset. Semantic feature-based clustering analysis avoids subjective biases caused by relying on manual labels or pre-defined categories, making the text subset division process more objective and stable. Furthermore, since the clustering results reflect the natural distribution of text data in the semantic space, each text subset corresponds to a class of texts with similar semantic features, providing a clear structural basis for subsequent quantitative difference judgments based on statistical features.

[0037] For example, when processing text data containing multiple customer service intentions, after cluster analysis, semantically similar texts such as "logistics delay", "return inquiry" and "emergency complaint" will be clustered into different clusters, thus forming multiple semantically consistent text subsets, providing a clear candidate set for subsequent identification of target text subsets.

[0038] Step 202: Based on the relative quantity difference condition and the statistical characteristics of each text subset, determine the target text subset among multiple text subsets.

[0039] Among them, the target data size of the target text subset and the data size of the text subset outside the target text subset meet the preset relative quantity difference condition.

[0040] In some embodiments of this application, in order to objectively identify subsets of text data that are relatively sparse in number and require expansion from multiple text subsets, the sample size of each text subset can be compared based on the statistical features obtained in the aforementioned steps and in conjunction with preset relative quantity difference conditions. For example... Figure 3 As shown, after completing semantic representation (step S1) and cluster analysis (step S2), each text subset has been formed and possesses corresponding statistical characteristics. These statistical characteristics can serve as the basis for judging quantitative differences. At this point, as shown in step 3, the minority classes with relatively small sample sizes can be identified from multiple clustering results. Specifically, based on the sample size, distribution ratio, or other statistical indicators used to measure data size, it can be determined whether there is a quantitative difference exceeding a preset threshold between each text subset and other text subsets, thereby identifying the text subset with insufficient sample size as the target text subset. By using relative quantitative difference conditions for judgment, misjudgments caused by relying on absolute quantitative thresholds can be avoided, making the identification process of the target text subset more stable and objective. Simultaneously, quantitative comparison based on statistical characteristics can ensure that the identified target text subset is indeed at a quantitative disadvantage in the overall dataset, thus providing a clear direction for subsequent data expansion and making the expansion process more targeted.

[0041] In a specific example, if the sentiment classification dataset is processed and the statistical results show that the number of samples in the "positive comments" and "neutral comments" categories is relatively close, while the number of samples in the "negative comments" category is significantly lower than that in other categories, and this difference exceeds the preset relative difference condition, then the "negative comments" category can be identified as the target text subset, and its target data size can be set accordingly, providing a basis for subsequent expansion steps.

[0042] Step 203: Establish a text generation collaborative strategy corresponding to the target text subset based on the target text subset, and make collaborative adjustments to the text generator and text generation discriminator corresponding to the target text subset based on the text generation collaborative strategy.

[0043] The method shown in this step has been explained in step 102 and will not be repeated here.

[0044] Optionally, step 203 includes the following sub-steps: Sub-step 2031: Generate generation constraint prompts for the text generator and discrimination constraint prompts for the generated text discriminator according to preset reflective adversarial conditions.

[0045] In some embodiments of this application, to ensure that the text generator and the generated text discriminator follow consistent adversarial optimization logic during subsequent collaborative adjustment, it is necessary to first construct corresponding cue word engineering based on preset reflective adversarial conditions. Specifically, based on the semantic features, category features, and constraints required for adversarial training of the target text subset, generation constraint cue word engineering to guide the text generator and discrimination constraint cue word engineering to guide the generated text discriminator can be generated respectively. Figure 4 The diagram illustrates a collaborative adjustment process according to an embodiment of this application. In the adversarial training process, data features are initialized through step R1 and then input into the text generator. To enable the generator to perform generation behavior according to preset reflexive adversarial conditions upon receiving the initialized features, a generation constraint cue word project needs to be constructed in advance in this sub-step. This allows the generator to perform controlled generation based on the cue word project in subsequent generation stages. Similarly, a discriminant constraint cue word project is used to provide discrimination criteria for the discriminator, enabling it to perform discrimination tasks according to preset reflexive adversarial conditions in subsequent discrimination stages. By constructing the cue word project, a strategic foundation can be laid for the subsequent generation-discrimination-reflection loop, giving the generator and discriminator clear behavioral constraints during adversarial training, thereby improving the stability and effectiveness of collaborative adjustment.

[0046] In a specific example, if the target text subset is in the category of "urgent complaints," typical semantic features can be extracted from real samples of this category, such as "strong emotional expression," "clear demands," and "clear event background." Based on these features, a generative constraint cue word engineering can be constructed, requiring the generator to include key elements such as the complaint scenario, user demands, and emotional expression when generating text. Simultaneously, a discriminative constraint cue word engineering can be constructed, enabling the discriminator to focus on features such as emotional intensity, completeness of event description, and semantic consistency during the discrimination process. In this way, both the generator and the discriminator can execute controlled behaviors based on the cue word engineering during subsequent adversarial training, thus forming a stable reflective adversarial mechanism.

[0047] Sub-step 2032: Generate generation constraint prompts for the text generator based on the generation constraint prompts project, and generate discrimination constraint prompts for the text discriminator based on the discrimination constraint prompts project, so as to use the generation constraint prompts and discrimination constraint prompts as a text generation collaborative strategy.

[0048] In some embodiments of this application, after completing the construction of the prompt word project, it is necessary to further extract prompt word content that can be directly used to constrain the text generator and the text discriminator from the prompt word project. Specifically, generation constraint prompt words can be generated according to the generation constraint prompt word project to guide the text generator to perform generation behavior, so that the generator can perform controlled generation according to preset reflexive adversarial conditions when receiving initial semantic features; at the same time, discrimination constraint prompt words can be generated according to the discrimination constraint prompt word project to guide the text discriminator to perform discrimination behavior, so that the discriminator can make judgments according to preset discrimination criteria in the subsequent discrimination stage. Figure 4 As shown, in step R1, the initialized data features are input to the generator. The generation constraint cue words are used to impose constraints on the generator's generation logic at this input stage, ensuring that it follows preset reflexive adversarial conditions in subsequent generation processes. The discriminant constraint cue words serve as the policy basis for the discriminator, providing consistent discrimination criteria in subsequent discrimination stages, enabling the generator and discriminator to work collaboratively within the same policy framework.

[0049] In a specific example, if the target text subset is in the category of "urgent complaints," then the generation constraint prompts could include elements such as "the generated text must contain a clear complaint scenario, user demands, and emotional expression," enabling the generator to maintain a semantic structure consistent with real complaint texts when generating text. The discrimination constraint prompts could include elements such as "discrimination should focus on emotional intensity, completeness of event description, and semantic consistency," enabling the discriminator to make judgments based on these features. By using these prompts as a collaborative text generation strategy, the generator and discriminator can perform generation and discrimination tasks under a unified strategy framework during subsequent adversarial training.

[0050] Sub-step 2033: Input the initialized semantic features into the text generator under the constraint of the generation constraint prompt words to generate multiple texts to be judged.

[0051] In some embodiments of this application, after obtaining the generation constraint prompt, the initialized semantic features need to be input into a text generator constrained by the prompt to generate multiple texts to be judged for subsequent discrimination. Specifically, when receiving the initialized semantic features, the generator performs controlled generation based on the semantic requirements, expression patterns, or category features described in the generation constraint prompt, so that the generated results can more closely approximate the true semantic distribution of the target text subset. For example... Figure 4As shown, in step R2, the generator performs a generation operation based on the semantic features of the input. The generation constraint prompts are used to impose constraints on the generator's generation logic during this generation stage, ensuring that it follows preset reflexive adversarial conditions when generating multiple texts to be judged. In this way, it can be ensured that the generated texts are consistent with the target text subset in terms of semantic structure, content elements, or expression style, thereby providing reliable generated samples for subsequent discrimination and reflexive adversarial optimization.

[0052] In a specific example, if the target text subset is in the category of "urgent complaints," the initial semantic features might include information such as the complaint topic, event background, or user demands. Under the constraint of generating constraint prompts, the text generator automatically supplements key elements such as the complaint scenario, emotional expression, or problem description when generating multiple texts to be judged, making the generated text more consistent with the semantic features of real complaint texts. These multiple texts to be judged can then serve as input for subsequent judgment steps, providing necessary generated samples for reflective adversarial training.

[0053] Sub-step 2034: Add multiple verified texts to the generated multiple texts to be judged in order to update the multiple texts to be judged.

[0054] In some embodiments of this application, to improve the stability and richness of the discrimination criteria in subsequent discrimination stages, multiple verified texts can be added to the generated multiple texts to be discriminated, thereby updating the set of texts to be discriminated. Verified texts typically originate from real samples of the target text subset or reference texts that have undergone quality verification; their semantic structure, expression methods, or content features can provide reliable comparison information for the discriminator. For example... Figure 4 As shown, in step R3, the discriminator mixes real data with synthetic data, and the updated set of texts to be discriminated is used as part of this mixed input. By adding verified text to this sub-step, the semantic distribution in the mixed input can be made more comprehensive, thus providing richer discrimination criteria for subsequent discrimination processes.

[0055] In a specific example, if the target text subset is categorized as "urgent complaints," the multiple texts generated by the generator may contain varying degrees of description of the complaint scenario or emotional expression. To enable the discriminator to more accurately identify the differences between the generated text and the real text in subsequent discrimination stages, several quality-verified real complaint texts can be added to the text set to be judged. This updated text set includes not only generated text but also real text, allowing the discriminator to make judgments based on richer semantic comparison information during the discrimination process.

[0056] Sub-step 2035: Input multiple texts to be judged into the text discriminator under the discrimination constraint prompt word constraint to obtain the discrimination result for each text to be judged.

[0057] In some embodiments of this application, after updating the set of texts to be judged, multiple texts to be judged need to be input into a text discriminator constrained by discrimination constraint prompts to obtain a judgment result for each text. Specifically, when receiving input text, the discriminator performs a discrimination operation according to the discrimination criteria described in the discrimination constraint prompts, thereby judging the semantic consistency, content completeness, or category features of the input text. Figure 4 As shown, in step R4, the discriminator performs a discrimination operation on the input text and outputs the corresponding discrimination result. In this sub-step, the discrimination constraint prompt is used to impose constraints on the discriminator's discrimination logic at this discrimination stage, enabling it to perform the discrimination task according to preset reflexive adversarial conditions. In this way, it can be ensured that the discriminator has a consistent discrimination standard when discriminating multiple texts to be discriminated, thereby providing a reliable discrimination basis for subsequent reflexive adversarial optimization.

[0058] In a specific example, if the set of texts to be judged contains multiple generated texts related to "urgent complaints" and several real complaint texts, the discriminator, under the constraints of the discrimination cue words, will focus on features such as emotional expression, completeness of event description, and semantic consistency in the text, thereby determining whether each text conforms to the semantic features of a real complaint text. The judgment result can include information such as whether the text is identified as real text and the degree of deviation of the text in key features, providing a basis for subsequent adjustments to the generator or discriminator.

[0059] Sub-step 2036: Adjust the text generator under the constraint of the generation constraint prompt word and / or the text discriminator under the constraint of the discrimination constraint prompt word according to the discrimination result to obtain the adjusted text generator.

[0060] In some embodiments of this application, after obtaining the discrimination results of multiple texts to be discriminated, it is necessary to adjust the text generator and / or text discriminator accordingly based on the discrimination results to improve their collaborative performance in subsequent adversarial training. Specifically, when the discrimination results show that the generated text deviates from the real text in terms of semantic structure, content completeness, or category features, the text generator constrained by the generation constraint prompts can be adjusted to better fit the true distribution of the target text subset in subsequent generation processes. Similarly, when the discrimination results show that the discriminator misjudges or lacks sufficient discrimination criteria when distinguishing between real text and generated text, the text discriminator constrained by the discrimination constraint prompts can be adjusted to have more accurate discrimination capabilities in subsequent discrimination processes. By adjusting the generator and / or discriminator based on the discrimination results, a continuously optimized adversarial loop can be formed, enabling the generator to continuously improve its generation quality and the discriminator to continuously enhance its discrimination capabilities, thereby obtaining a more stable and effective text generation model.

[0061] In a specific example, if the discrimination results show that some generated text differs significantly from the real complaint text in terms of emotional expression or event description, the generation logic of the text generator can be adjusted to make it pay more attention to key features such as emotional intensity, event background, or user demands during subsequent generation. If the discrimination results show that the discriminator is not accurate enough in recognizing some generated text, the discrimination criteria of the discriminator can be adjusted to make it more effective in identifying semantic biases in subsequent discrimination processes. Through these adjustments, the collaborative performance of the generator and discriminator can be gradually improved, thereby obtaining higher quality text generation results.

[0062] Optionally, sub-step 2036 includes the following sub-steps: Sub-step 20361: If the discrimination result matches the preset synthetic data discrimination conditions, adjust the generated constraint prompt words and return to sub-step 2033.

[0063] In some embodiments of this application, when the text discriminator's judgment results for multiple texts to be judged meet preset synthetic data discrimination conditions, the generation constraint prompts can be adjusted to improve the generation quality of the text generator in subsequent generation processes. Synthetic data discrimination conditions typically describe situations where the discriminator can accurately identify the generated text, such as when the generated text differs significantly from the real text in semantic structure, content elements, or expression, and this difference is successfully recognized by the discriminator. In this case, the generator's generation logic needs further optimization to reduce the deviation between the generated text and the real text. Figure 4As shown, in step T1, when the discrimination result meets the discrimination conditions for synthetic data, the discriminator identifies the input data as synthetic data and provides the discrimination criteria. At this point, a reflective optimization of the generator is triggered. This sub-step, based on this optimization mechanism, adjusts the generation constraint prompts and returns the process to step R2, so that the generator can regenerate the text to be judged under the updated prompt constraints. Through this cyclical adjustment mechanism, the generator's generation capability can be gradually improved, making the generated text closer to the true semantic distribution of the target text subset.

[0064] In a specific example, if the discrimination results show that the generated text differs significantly from the real complaint text in terms of emotional expression or event description, and these differences are accurately identified by the discriminator, the generation constraint prompts can be adjusted to emphasize key features such as emotional intensity, event background, or user demands in subsequent generation processes. The adjusted generation constraint prompts will be used in the next round of generation, enabling the generator to generate text to be judged that better matches the characteristics of real text under new constraints.

[0065] Sub-step 20362: If the judgment result matches the preset misjudgment condition or judgment failure condition, adjust the judgment constraint prompt words and return to sub-step 2035.

[0066] In some embodiments of this application, when the text discriminator's judgment results for multiple texts to be judged meet preset misjudgment conditions or judgment failure conditions, the judgment constraint prompts can be adjusted to improve the discriminator's judgment capability in subsequent judgment processes. Misjudgment conditions typically describe situations where the discriminator misjudges generated text as real text, or real text as generated text; judgment failure conditions describe situations where the discriminator cannot provide a clear judgment result, has insufficient judgment basis, or has low judgment confidence. In these cases, the discriminator's judgment logic needs further optimization to enhance its ability to distinguish between real text and generated text. Figure 4 As shown, based on step T2, when the discrimination result meets the misjudgment condition, the discriminator identifies the input data as real data but misidentifies it as generated data, and provides relevant judgment criteria; or when the judgment fails, the discriminator identifies the input data as simulated data but misidentifies it as real data, and provides relevant judgment criteria. Both of these situations will trigger reflective optimization of the discriminator. This sub-step is based on this optimization mechanism, adjusting the discrimination constraint prompts and returning the process to step R4, so that the discriminator can re-execute the discrimination task under the updated prompt constraints. Through this cyclical adjustment mechanism, the discriminator's discrimination ability can be gradually improved, enabling it to more accurately identify the differences between generated text and real text in subsequent adversarial training.

[0067] In a specific example, if the discrimination results show that the discriminator cannot effectively distinguish between partially generated text and genuine complaint text, or if insufficient confidence is encountered during the judgment process, the discrimination constraint prompts can be adjusted. This will make the discriminator pay more attention to emotional intensity, completeness of event description, semantic consistency, or other key features in subsequent discrimination processes. The adjusted discrimination constraint prompts will be used in the next round of discrimination, enabling the discriminator to more effectively identify semantic deviations between texts under the new discrimination criteria, thereby improving overall discrimination performance.

[0068] Sub-step 20363: If the discrimination result matches the preset correct discrimination condition, the text generator under the constraint of the generation constraint prompt word will be determined as the adjusted text generator.

[0069] In some embodiments of this application, when the text discriminator's discrimination results for multiple texts to be discriminated meet preset correct discrimination conditions, the text generator currently running under the constraint of the generation constraint prompt can be directly identified as the adjusted text generator. The so-called correct discrimination condition typically describes a situation where the discriminator can accurately distinguish between generated text and real text, and the generated text is highly consistent with the real distribution of the target text subset in terms of semantic structure, content elements, or category features. In this case, the generator's generation logic has achieved the expected generation quality and requires no further adjustment. By directly confirming the generator's current state under the correct discrimination condition, unnecessary repeated optimization can be avoided, making the adversarial training process more efficient. Simultaneously, this confirmation mechanism also indicates that the generator has a stable generation capability under the current prompt constraint, and can provide high-quality generated text for subsequent data expansion or model training.

[0070] In a specific example, if the discrimination results show that the generated text is highly consistent with the real complaint text in terms of emotional expression, completeness of event description, and semantic consistency, and the discriminator can consistently identify the differences between the generated text and the real text, then the generator has good generation capabilities under the constraints of the current generation constraint prompts. In this case, the generator can be directly identified as the adjusted text generator for subsequent data generation or model training processes.

[0071] Step 204: Based on the adjusted text generator, augment the target text subset to obtain a balanced text dataset.

[0072] The method shown in this step has been explained in step 103 and will not be repeated here.

[0073] Optionally, step 204 includes the following sub-steps: Sub-step 2041: Generate context data corresponding to the target text sub-data set based on the semantic features of at least one text data in the target text sub-data set.

[0074] In some embodiments of this application, in order for the adjusted text generator to more accurately align with the semantic distribution of the target text subset when generating subsequent expanded text data, it is necessary to first construct corresponding context data based on the semantic features of at least one text data in the target text subset. Specifically, one or more representative text data can be selected from the target text subset, and their semantic features, thematic elements, expression structures, or key content fragments can be extracted. Context data reflecting the semantic background of this category can then be generated. This context data can serve as semantic guidance information for the generator, enabling it to better maintain a semantic direction consistent with the target text subset during subsequent generation. By generating context data based on the semantic features of real samples, the semantic alignment capability of the generator during the expansion stage can be effectively improved, making the generated expanded text data closer to the true distribution of the target text subset in terms of content structure, expression methods, or thematic features, thereby providing a reliable semantic foundation for subsequent data expansion.

[0075] In a specific example, if the target text subset is in the category of "urgent complaints," one or more representative complaint texts can be selected from this category. Semantic features such as event background, user demands, emotional expression, or problem description can be extracted, and contextual data can be constructed based on these features. For example, contextual data may include information such as "a description of the scenario in which the user encountered the problem," "the way the user expressed their demands," or "typical emotional intensity." The generated contextual data will serve as semantic guidance in subsequent generation stages, enabling the generator to generate expanded text data that better matches the characteristics of real complaint texts.

[0076] Sub-step 2042 inputs the context data into the adjusted text generator to generate augmented text data for the target text subset.

[0077] In some embodiments of this application, after generating context data based on the semantic features of the target text subset, this context data needs to be input into an adjusted text generator to generate expanded text data for augmenting the target text subset. Specifically, when receiving the context data, the adjusted text generator performs a generation operation based on the semantic background, thematic elements, or expressive structure provided by the context data, thereby generating expanded text data that is semantically consistent with the target text subset. By using context data as input to the generator, the generator can receive explicit semantic guidance during the generation process, making the generated results closer to the true distribution of the target text subset in terms of content structure, semantic direction, or expression, thereby effectively improving the quality and consistency of the expanded text data.

[0078] In a specific example, if the target text subset is categorized as "urgent complaints," the contextual data might contain information such as typical complaint scenarios, user requests, event background, or emotional expressions. After inputting this contextual data into the adjusted text generator, the generator will generate multiple new complaint texts guided by this semantic context. These expanded texts might include key elements such as descriptions of the user's problem, emotional expressions, or the content of their requests. The generated expanded text data can be used to increase the sample size of the target text subset, providing a foundation for subsequent data balancing.

[0079] Sub-step 2043: If the expanded text data matches the preset illusion verification conditions, add the expanded text data to the target text subset to obtain a balanced text dataset.

[0080] In some embodiments of this application, after generating expanded text data for augmenting the target text subset, it is necessary to perform illusion verification on the expanded text data to determine whether it meets preset illusion verification conditions. Illusion verification conditions typically describe whether the expanded text data is consistent with the target text subset in terms of semantic consistency, factual plausibility, content completeness, or category characteristics. When the expanded text data meets the preset illusion verification conditions, it can be added to the target text subset to gradually increase the sample size of the target text subset, thereby obtaining a balanced text dataset. By filtering expanded text data based on illusion verification conditions, it is possible to effectively prevent generated text that does not meet semantic requirements or has content deviations from being added to the target text subset, thus ensuring the quality and reliability of the data augmentation process and making the final balanced text dataset more stable, realistic, and consistent in semantic distribution.

[0081] In a specific example, if augmented text data is used to expand the "urgent complaint" category, the hallucination verification criteria might include requirements such as "the text must contain a clear event background," "the text must have reasonable emotional expression," and "the text must be consistent with the complaint topic." When a piece of augmented text data is consistent with the real complaint text in these aspects, it can be added to the target text subset. By continuously filtering and adding augmented text data that meets the criteria, the sample size for this category can be gradually increased, making the final balanced text dataset more evenly distributed in terms of category distribution.

[0082] Optionally, sub-step 2043 includes the following sub-steps: Sub-step 20431: Perform data illusion verification on the expanded text data to obtain the illusion verification results of the expanded text data.

[0083] In some embodiments of this application, to ensure the quality and reliability of the augmented text data, data illusion verification needs to be performed on the generated augmented text data to obtain corresponding illusion verification results. Specifically, data illusion verification is used to determine whether the augmented text data is consistent with the target text subset in terms of semantic consistency, factual plausibility, content completeness, or category characteristics. By performing illusion verification on the augmented text data, generated text that may have semantic biases, missing content, or inappropriate expression can be identified, thereby preventing unqualified augmented text data from entering the target text subset. Through data illusion verification, clear judgment criteria can be provided for subsequent augmented text screening, enabling the entire data augmentation process to have higher quality control capabilities, thereby improving the semantic stability and credibility of the final balanced text dataset.

[0084] In a specific example, if augmented text data is used to expand the "urgent complaint" category, data illusion verification might include checking whether the text contains a reasonable event background, whether it has emotional expression consistent with the complaint scenario, and whether it maintains a semantic structure consistent with the complaint topic. When a piece of augmented text data deviates significantly in these aspects, such as lacking event description, having unreasonable emotional expression, or being inconsistent with the topic, the illusion verification result will be characterized as not meeting the requirements; conversely, when the augmented text data is consistent with the real complaint text in all the above aspects, the illusion verification result will be characterized as real data and can be used in subsequent data update steps.

[0085] Sub-step 20432: If the hallucination verification result is represented as real data, add the augmented text data to the target text subset to update the target text subset.

[0086] In some embodiments of this application, after completing the illusion verification of the augmented text data, when the illusion verification result is characterized as real data, the augmented text data can be added to the target text subset to update the target text subset. Specifically, an illusion verification result characterized as real data usually indicates that the augmented text data is consistent with the target text subset in terms of semantic consistency, content completeness, factual plausibility, or category characteristics, and can serve as a valid supplementary sample for that category. In this case, adding the augmented text data to the target text subset can gradually increase the number of samples for that category, thereby enhancing the representativeness and semantic stability of the target text subset. By filtering the augmented text data and updating the target text subset based on the illusion verification result, it is possible to effectively prevent unqualified generated text from entering the dataset, thereby ensuring the quality and reliability of the data augmentation process and providing a high-quality sample foundation for subsequent data balancing or model training.

[0087] In a specific example, if augmented text data is used to expand the "urgent complaint" category, then when a piece of augmented text data is consistent with the real complaint text in terms of event background, emotional expression, and semantic structure, it can be added to the target text subset. By continuously adding qualified augmented text data to the target text subset, the number of samples in this category can be gradually increased, making the semantic distribution of the target text subset more stable and providing sufficient sample support for subsequent data balancing steps.

[0088] Sub-step 20433: If the target data capacity of the updated target text subset satisfies the preset relative quantity balance condition, the updated target text subset is randomly mixed with the text data in the text subset outside the target text subset to form a balanced text dataset.

[0089] In some embodiments of this application, after adding the expanded text data that meets the hallucination verification criteria to the target text subset and completing the update, it is necessary to determine whether the target data capacity of the updated target text subset meets a preset relative quantity balance condition. This relative quantity balance condition is typically used to describe whether the proportion of the target text subset in the overall text dataset reaches the expected balance level; for example, whether the number of samples in the target category reaches a relatively balanced proportion with other categories. When the updated target text subset meets this preset condition, it can be randomly mixed with text data from other text subsets outside the target text subset to construct the final data-balanced text dataset. By performing random mixing after meeting the quantity balance condition, data distribution bias can be effectively avoided, making the final data-balanced text dataset more balanced in category distribution, thereby providing a more stable and reliable training data foundation for subsequent model training or data analysis.

[0090] In a specific example, if the target text subset is in the category of "urgent complaints," then by continuously adding supplementary text data that meets the requirements, the number of samples in this category may gradually approach a relatively balanced proportion with other categories. When the number of samples reaches the preset relative balance condition, the updated "urgent complaints" text data can be randomly mixed with text data from other categories (such as "consultation," "suggestion," etc.) to form the final balanced text dataset. This random mixing method ensures that text data from different categories are evenly distributed in the overall dataset, thereby improving the stability and generalization ability of subsequent model training.

[0091] The text generator models in various embodiments of this application can employ existing mature models such as Bidirectional Encoder Representations from Transformers (BERT), Generative Pre-trained Transformer (GPT), or Text-to-Text Transformer (T5). These models, after inputting retrieved contextual data or semantic features, can generate synthetic text data semantically consistent with the target text subset based on their pre-trained language modeling capabilities. To obtain data generation capabilities suitable for this application, the models can be fine-tuned and trained based on publicly available general corpora (such as news corpora, encyclopedia corpora, and dialogue corpora) and domain corpora related to the target task (such as customer service complaint texts, medical record texts, and product review texts), enabling them to generate structurally reasonable, semantically consistent, and content-complete extended text data in specific semantic scenarios. It should be noted that the specific training methods and implementation details of the corresponding models have been fully disclosed and applied in the prior art, and will not be repeated here.

[0092] The text discriminator model in the embodiments of this application can employ existing mature models such as the lightweight text classification model (Bidirectional Encoder Representations from Transformers for Sequence Classification, BERT-Classifier), the discriminative language model (RoBERTa for Sequence Classification, RoBERTa-Classifier), or the multilayer perceptron text discrimination model (MLP). These models can, after inputting text to be discriminated, determine whether the text belongs to generated text based on its learned semantic representation, and can output the corresponding discrimination criteria or confidence distribution. To obtain the discrimination capability applicable to this application, it can be trained on an adversarial training dataset containing real text and generated text. The real text can be derived from a subset of the target text dataset, while the generated text can be generated by a pre-trained generation model or a historical generator version, enabling the discriminator to learn the semantic differences between real text and synthetic text. It should be noted that the specific training methods and implementation details of the corresponding models have been fully disclosed and applied in the prior art, and will not be repeated here.

[0093] Figure 5This application illustrates a complete data processing flow for achieving minority class data augmentation and data balancing, as described in an embodiment. The flow starts with minority class samples and, through multiple stages including feature extraction, information retrieval, knowledge injection, and data synthesis, generates augmented minority class samples. Finally, a class-balanced dataset is constructed through random mixing. Specifically, Figure 5 The following processing steps are included: X1: Minority class sample 1 is first subjected to adversarial training for feature extraction to obtain semantic features for generation; X2: Perform information retrieval based on the intermediate semantic representation output by the generator, and obtain real information related to the current semantics from real information sources; X3: Inject the retrieved relevant real information into the generator, enabling the generator to perform data synthesis with the assistance of external knowledge; X4: The generator generates expanded minority class samples based on the results of the aforementioned feature extraction, information retrieval, and knowledge injection; X5: After generating the expanded samples, the majority class sample 1, multiple majority class samples 2, and the expanded minority class sample 1 are randomly mixed to construct a text dataset with a more balanced class distribution.

[0094] Through the above multi-stage processing flow, the quantity and semantic quality of minority class samples can be effectively improved, and a balanced text dataset suitable for model training can be obtained.

[0095] In summary, in this embodiment, by determining the target text subset from the text dataset to be balanced and setting a preset relative quantity difference condition, sparse minority class samples can be objectively identified, providing a clear benchmark for subsequent targeted expansion. Furthermore, by establishing a collaborative text generation strategy and coordinating the adjustment of the text generator and the generated text discriminator, the single text generation process is transformed into a dynamic adversarial optimization loop. This allows the generated text to fit the true distribution of the target text subset in terms of syntactic structure and semantic features, thus solving the problem that synthetic data easily deviates from the original semantic scene and lacks specificity. Finally, based on the adjusted text generator, the target text subset is expanded to obtain a balanced dataset. While supplementing the data capacity, the diversity and realism of the synthetic samples are improved. The adversarial optimization generation strategy replaces simple copying. On the basis of satisfying the quantity difference condition, more semantic information that meets the fitting condition is introduced. This not only eliminates the performance deviation caused by uneven class distribution but also enhances the robustness of the downstream model through rich and high-quality data features. Therefore, the method based on the embodiments of this application, by introducing a collaborative adjustment mechanism based on the adversarial concept, effectively eliminates the category distribution bias while achieving a balance between data diversity and simulation accuracy, thus solving the problem that data balance and data capacity cannot be taken into account simultaneously.

[0096] refer to Figure 6 This illustrates a text data balancing device 30 based on adversarial training provided in an embodiment of this application, comprising: The identification module 301 is used to determine the target text subset from each text subset of the text dataset to be balanced; the target data size of the target text subset and the data size of the text subsets outside the target text subset meet the preset relative quantity difference condition. The adjustment module 302 is used to establish a text generation collaborative strategy corresponding to the target text subset based on the target text subset, and to collaboratively adjust the text generator and the generated text discriminator corresponding to the target text subset based on the text generation collaborative strategy. The expansion module 303 is used to expand the target text subset based on the adjusted text generator to obtain a balanced text dataset.

[0097] Optionally, the recognition module 301 includes: The partitioning module is used to divide the text dataset to be balanced into multiple text subsets; the text data in each text subset meet the preset semantic similarity conditions; each text subset has corresponding statistical features. The selection submodule is used to determine the target text subset from multiple text subsets based on the relative quantity difference condition and the statistical characteristics of each text subset.

[0098] Optionally, the sub-modules include: Embedding units are used to determine the semantic features of each text data in the text dataset to be balanced; The analysis unit is used to perform clustering analysis based on all semantic features to divide the text dataset to be balanced into multiple text subsets.

[0099] Optionally, the adjustment module 302 includes: The prompt word engineering submodule is used to generate the generation constraint prompt word engineering for the text generator and the discrimination constraint prompt word engineering for the generated text discriminator according to the preset reflexive adversarial conditions; The collaborative strategy submodule is used to generate generation constraint prompts for the text generator based on the generation constraint prompts project, and to generate discrimination constraint prompts for the text discriminator based on the discrimination constraint prompts project, so as to use the generation constraint prompts and discrimination constraint prompts as a collaborative strategy for text generation.

[0100] Optionally, the text generation collaborative strategy includes generation constraint prompts for the text generator and discrimination constraint prompts for the text discriminator. The adjustment module 302 includes: The text generation submodule is used to input the initialized semantic features into the text generator under the constraints of the generation constraint prompt words to generate multiple texts to be judged; The discrimination submodule is used to input multiple texts to be discriminated into a text discriminator under the constraint of discrimination constraint prompt words, so as to obtain the discrimination result for each text to be discriminated; The adjustment submodule is used to adjust the text generator under the constraint of the generation constraint prompt word and / or the text discriminator under the constraint of the discrimination constraint prompt word based on the discrimination result, so as to obtain the adjusted text generator.

[0101] Optionally, the adjustment module 302 includes: Add a submodule to add multiple verified texts to the generated multiple texts to be judged, so as to update the multiple texts to be judged.

[0102] Optionally, the adjustment submodules include: The generator adjustment unit is used to adjust the generation constraint prompts when the discrimination result matches the preset synthetic data discrimination conditions, and return to the text generator that inputs the initialized semantic features under the constraints of the generation constraint prompts to generate multiple texts to be discriminated. The discriminator adjustment unit is used to adjust the discrimination constraint prompts when the discrimination result matches the preset misjudgment conditions or judgment failure conditions, and return to the step of inputting multiple texts to be judged into the text discriminator under the constraints of the discrimination constraint prompts to obtain the discrimination result for each text to be judged. The adjustment termination unit is used to determine the text generator under the constraint of the generation constraint prompt word as the adjusted text generator when the discrimination result matches the preset correct discrimination condition.

[0103] Optionally, expansion module 303 includes: The context submodule is used to generate context data corresponding to the target text subdata set based on the semantic features of at least one text data in the target text subdata set; The augmentation submodule is used to input context data into the adjusted text generator to generate augmented text data for the target text subset. Add a submodule to add expanded text data to the target text subset when the expanded text data matches the preset illusion verification conditions, so as to obtain a balanced text dataset.

[0104] Optionally, submodules can be added, including: The illusion verification unit is used to perform data illusion verification on the expanded text data, so as to verify the illusion verification results of the expanded text data; Adding a unit is used to add augmented text data to the target text subset when the hallucination verification result is represented as real data, so as to update the target text subset. The mixing unit is used to randomly mix the updated target text subset with text data from text subsets outside the target text subset to form a balanced text dataset, provided that the target data capacity of the updated target text subset meets the preset relative quantity balance condition.

[0105] In summary, in this embodiment, by determining the target text subset from the text dataset to be balanced and setting a preset relative quantity difference condition, sparse minority class samples can be objectively identified, providing a clear benchmark for subsequent targeted expansion. Furthermore, by establishing a collaborative text generation strategy and coordinating the adjustment of the text generator and the generated text discriminator, the single text generation process is transformed into a dynamic adversarial optimization loop. This allows the generated text to fit the true distribution of the target text subset in terms of syntactic structure and semantic features, thus solving the problem that synthetic data easily deviates from the original semantic scene and lacks specificity. Finally, based on the adjusted text generator, the target text subset is expanded to obtain a balanced dataset. While supplementing the data capacity, the diversity and realism of the synthetic samples are improved. The adversarial optimization generation strategy replaces simple copying. On the basis of satisfying the quantity difference condition, more semantic information that meets the fitting condition is introduced. This not only eliminates the performance deviation caused by uneven class distribution but also enhances the robustness of the downstream model through rich and high-quality data features. Therefore, the method based on the embodiments of this application, by introducing a collaborative adjustment mechanism based on the adversarial concept, effectively eliminates the category distribution bias while achieving a balance between data diversity and simulation accuracy, thus solving the problem that data balance and data capacity cannot be taken into account simultaneously.

[0106] Reference Figure 7 The electronic device 500 may include one or more of the following components: processing component 502, memory 504, power supply component 506, multimedia component 508, audio component 510, input / output (I / O) interface 512, sensor component 514, and communication component 516.

[0107] Processing component 502 typically controls the overall operation of electronic device 500, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component 502 may include one or more processors 520 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 502 may include one or more modules to facilitate interaction between processing component 502 and other components. For example, processing component 502 may include a multimedia module to facilitate interaction between multimedia component 508 and processing component 502.

[0108] Memory 504 is used to store various types of data to support the operation of electronic device 500. Examples of this data include instructions for any application or method operating on electronic device 500, contact data, phonebook data, messages, pictures, multimedia, etc. Memory 504 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.

[0109] Power supply component 506 provides power to various components of electronic device 500. Power supply component 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 500.

[0110] Multimedia component 508 includes an interface that provides an output interface between electronic device 500 and user. In some embodiments, the interface may include a liquid crystal display (LCD) and a touch panel (TP). If the interface includes a touch panel, the interface may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may not only sense the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component 508 includes a front-facing camera and / or a rear-facing camera. When electronic device 500 is in an operating mode, such as shooting mode or multimedia mode, the front-facing camera and / or rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.

[0111] Audio component 510 is used to output and / or input audio signals. For example, audio component 510 includes a microphone (MIC) used to receive external audio signals when electronic device 500 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 504 or transmitted via communication component 516. In some embodiments, audio component 510 also includes a speaker for outputting audio signals.

[0112] Input / output (I / O) interface 512 provides an interface between processing component 502 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.

[0113] Sensor assembly 514 includes one or more sensors for providing state assessments of various aspects of electronic device 500. For example, sensor assembly 514 may detect the on / off state of electronic device 500, the relative positioning of components such as the display and keypad of electronic device 500, changes in position of electronic device 500 or a component of electronic device 500, the presence or absence of user contact with electronic device 500, orientation or acceleration / deceleration of electronic device 500, and temperature changes of electronic device 500. Sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly 514 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly 514 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.

[0114] Communication component 516 facilitates wired or wireless communication between electronic device 500 and other devices. Electronic device 500 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component 516 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 516 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0115] In an exemplary embodiment, the electronic device 500 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to implement the methods provided in the embodiments of this application.

[0116] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 504 including instructions, which can be executed by a processor 520 of an electronic device 500 to perform the above-described method. For example, the non-transitory storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.

[0117] In an exemplary embodiment, the electronic device 500 may also be provided as a server, including a processing component 502, which further includes one or more processors, and memory resources represented by memory 504 for storing instructions, such as applications, that can be executed by the processing component 502. The applications stored in memory 504 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 502 is configured to execute instructions to perform the methods provided in the embodiments of this application.

[0118] Electronic device 500 may also include a power supply component 506 configured to perform power management of electronic device 500, a wired or wireless communication component 516 configured to connect electronic device 500 to a network, and an input / output (I / O) interface 512. Electronic device 500 may operate on an operating system stored in memory 504, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or similar.

[0119] This application also provides a computer program product, including a computer program, which, when executed by a processor, implements the method of this application embodiment.

[0120] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims below.

[0121] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the claimed rights.

[0122] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0123] It will be readily apparent to those skilled in the art that any combination of the above embodiments is feasible. Therefore, any combination of the above embodiments is an implementation scheme of this application. However, due to space limitations, this specification will not describe them in detail here.

[0124] It should be noted that, unless otherwise expressly stated, the methods provided in the embodiments of this application are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used in conjunction with the teachings herein. Based on the above description, the required structure for constructing a system having the solutions of this application is obvious. Furthermore, this application is not directed to any particular programming language. It should be understood that the content of this application described herein can be implemented using various programming languages, and the above description of specific languages ​​is for the purpose of disclosing the best mode of implementation of this application.

[0125] Numerous specific details are set forth in the specification provided herein. However, it will be understood that embodiments of this application may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of this specification.

[0126] Similarly, it should be understood that, for the sake of brevity and to aid in understanding one or more of the various aspects of this application, in the above description of exemplary embodiments of this application, various features of this application are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be construed as reflecting an intention that the claimed application requires more features than are expressly recited in each of the claimed claims. Rather, as reflected in the claimed claims, the application aspects consist of fewer than all features in a single embodiment disclosed above. Therefore, the claimed rights following the specific embodiment are thus expressly incorporated into that specific embodiment, wherein each claimed right itself is a separate embodiment of this application.

[0127] Those skilled in the art will understand that modules in the device of the embodiments can be adaptively changed and placed in one or more devices different from that embodiment. Modules, units, or components in the embodiments can be combined into a single module, unit, or component, and further, they can be divided into multiple sub-modules, sub-units, or sub-components. Except where at least some of such features and / or processes or units are mutually exclusive, any combination of all features disclosed in this application and all processes or units of any method or device so disclosed can be employed. Unless expressly stated otherwise, each feature disclosed in this application may be replaced by an alternative feature that serves the same, equivalent, or similar purpose.

[0128] Furthermore, those skilled in the art will understand that although some embodiments described herein include certain features but not others included in other embodiments, combinations of features from different embodiments are intended to be within the scope of this application and form different embodiments. For example, in the claims, any one of the claimed embodiments can be used in any combination.

[0129] The various component embodiments of this application can be implemented in hardware, or as software modules running on one or more processors, or a combination thereof. Those skilled in the art will understand that microprocessors or digital signal processors (DSPs) can be used in practice to implement some or all of the functions of some or all of the components in the methods according to the embodiments of this application. This application can also be implemented as a device or apparatus program (e.g., a computer program and computer program product) for performing part or all of the methods described herein. Such an implementation of this application can be stored on a computer-readable medium, or can be in the form of one or more signals. Such signals can be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.

[0130] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute the method of the embodiments of the present application.

[0131] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0132] It should be noted that, for the sake of simplicity, the method embodiments of this application are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this application are not limited to the described order of actions, because according to the embodiments of this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily essential to the embodiments of this application.

[0133] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the claims below.

[0134] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the claimed rights.

[0135] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A text data balancing method based on adversarial training, characterized in that, include: Determine the target text subset from the individual text subsets of the text dataset to be balanced; The target data capacity of the target text subset and the data capacity of the text subset outside the target text subset meet a preset relative quantity difference condition; Based on the target text subset, a text generation collaborative strategy corresponding to the target text subset is established, and based on the text generation collaborative strategy, the text generator and the generated text discriminator corresponding to the target text subset are collaboratively adjusted. The target text subset is augmented using the adjusted text generator to obtain a balanced text dataset.

2. The text data balancing method based on adversarial training as described in claim 1, characterized in that, The process of determining the target text subset from the various text subsets of the text dataset to be balanced includes: The text dataset to be balanced is divided into multiple text subsets; the text data in each text subset satisfy a preset semantic similarity condition; each text subset has corresponding statistical features. The target text subset is determined from among the multiple text subsets based on the relative quantity difference condition and the statistical characteristics of each text subset.

3. The text data balancing method based on adversarial training as described in claim 1, characterized in that, The step of establishing a collaborative text generation strategy corresponding to the target text subset based on the target text subset includes: Generate generation constraint prompts for the text generator and discrimination constraint prompts for the generated text discriminator according to preset reflective adversarial conditions; Generate constraint prompts for the text generator based on the generated constraint prompts project, and generate discrimination constraint prompts for the text discriminator based on the discrimination constraint prompts project, so as to use the generated constraint prompts and the discrimination constraint prompts as the text generation collaborative strategy.

4. The text data balancing method based on adversarial training as described in claim 1, characterized in that, The text generation collaborative strategy includes generation constraint prompts for the text generator and discrimination constraint prompts for the text discriminator. The step of collaboratively adjusting the text generator and the generated text discriminator corresponding to the target text subset based on the text generation collaborative strategy includes: The initialized semantic features are input into the text generator under the constraints of the generation constraint prompt words to generate multiple texts to be judged; Multiple texts to be identified are respectively input into the text discriminator under the constraint of the discrimination constraint prompt word to obtain the discrimination result for each text to be identified; The text generator under the constraint of the generation constraint prompt word and / or the text discriminator under the constraint of the discrimination constraint prompt word are adjusted according to the discrimination result to obtain the adjusted text generator.

5. The text data balancing method based on adversarial training as described in claim 4, characterized in that, The text data balancing method based on adversarial training also includes: Multiple verified texts are added to the generated multiple texts to be judged in order to update the multiple texts to be judged.

6. The text data balancing method based on adversarial training as described in claim 1, characterized in that, The process of augmenting the target text subset based on the adjusted text generator to obtain a balanced text dataset includes: Based on the semantic features of at least one text data in the target text sub-dataset, generate context data corresponding to the target text sub-dataset; The context data is input into the adjusted text generator to generate augmented text data for the target text subset. If the expanded text data matches the preset hallucination verification conditions, the expanded text data is added to the target text subset to obtain the text dataset after data balancing.

7. A text data balancing device based on adversarial training, characterized in that, include: The recognition module is used to identify the target text subset from the individual text subsets of the text dataset to be balanced. The target data capacity of the target text subset and the data capacity of the text subset outside the target text subset meet a preset relative quantity difference condition; The adjustment module is used to establish a text generation collaborative strategy corresponding to the target text subset based on the target text subset, and to collaboratively adjust the text generator and the generated text discriminator corresponding to the target text subset based on the text generation collaborative strategy. An expansion module is used to expand the target text subset based on the adjusted text generator to obtain the text dataset after data balancing.

8. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, which, when executed by a processor, implements the text data balancing method based on adversarial training as described in any one of claims 1 to 6.

9. An electronic device, characterized in that, It includes a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the text data balancing method based on adversarial training as described in any one of claims 1 to 6.

10. A computer program product, characterized in that, The computer program product stores a computer program that, when executed by a processor, implements the steps of the text data balancing method based on adversarial training as described in any one of claims 1 to 6.