Method, device, storage medium and electronic device for enhancing text data

By introducing decision information of the model to be enhanced in the process of counterfactual generation, text enhancement is performed on the decision boundary of the model to be enhanced, the problem of poor data enhancement effect in the existing technology is solved, and the robustness and generalization of the model are improved. ability.

CN118428333BActive Publication Date: 2024-11-05ANT GROUP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410889480.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-03
Publication Date
2024-11-05
Estimated Expiration
2044-07-03

AI Technical Summary

Technical Problem

In text data enhancement, data enhancement cannot be effectively performed on the decision boundaries of the model to be enhanced, resulting in the failure of the prediction errors to effectively improve the robustness and generalization capabilities of the model.

Method used

By introducing decision information of the model to be enhanced in the process of counterfactual generation, the edited model enhances text based on the decision boundary of the model to be enhanced, automatically identify the prediction errors of the model to be enhanced, and fine-tune the prediction results of the model to be enhanced for optimization Decision-making boundaries.

Benefits of technology

The robustness and generalization capabilities of the models to be enhanced are improved to ensure the pertinence and effectiveness of data enhancement.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118428333B_ABST
    Figure CN118428333B_ABST
Patent Text Reader

Abstract

The embodiments of the present specification disclose a method, an apparatus, a storage medium and an electronic device for enhancing text data. The method comprises: constructing a first prompt word according to first text data and model identification information of a model to be enhanced, and constructing first label information according to the first prompt word and a first prediction result; training an editing model according to the first prompt word and the first label information to obtain a trained editing model; masking a text unit of the first text data to obtain masked second text data, and constructing a second prompt word according to the second text data, the second prediction result and the model identification information; inputting the second prompt word into the trained editing model so that the trained editing model completes the masked text unit to generate a third text data, and obtaining a corresponding output result based on the third text data; judging whether the target third text data exists in the output result, and if not, using the generated third text data as the enhanced data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to computer technology, and in particular to a method, device, storage medium and electronic device for enhancing text data. Background Art

[0002] In recent years, with the increasing number of text-based applications, the scale of text content on the Internet has become larger and larger. It is very important to analyze these text contents. Typical NLP (Natural Language Processing) tasks involved in this analysis are sentiment analysis and news classification. Based on these tasks, models are trained for prediction, and there are often instances of prediction errors in the prediction results. However, in some scenarios, we cannot get the true label. If data enhancement is only performed based on the data level without considering the decision boundary of the model to be enhanced, the effect of data enhancement cannot be guaranteed. Summary of the invention

[0003] The purpose of the embodiments of this specification is to provide a method, device, storage medium and electronic device for enhancing text data.

[0004] The embodiments of this specification provide a method for enhancing text data, by introducing the decision information of the model to be enhanced in the entire counterfactual generation process, so that the editing model performs counterfactual text enhancement based on the decision boundary of the model to be enhanced. In this process, if at least one text data generated by the editing model after completing the masked text unit does not contain target text data that can change the prediction result of the model to be enhanced, then it is considered that the prediction result of the original model to be enhanced is wrong. This judgment is actually based on the actual situation that the performance of the editing model (generally a large language model) is stronger than that of the model to be enhanced (generally a small model), and the counterfactual text generated by the editing model is compared with the target prediction result. The result constitutes data for targeted data augmentation. By continuing to train the model to be augmented to optimize the decision boundary of the prediction error of the original model to be augmented, a method for automatically identifying the prediction error of the model to be augmented and performing targeted data augmentation on the instance of model prediction error is realized. By using the prediction result of the model to be augmented instead of the real label for fine-tuning in the process of fine-tuning the edited model, the decision information of the model to be augmented is introduced into the edited model, thereby avoiding the problem that counterfactual generation only from the data perspective cannot perform data augmentation on the decision boundary of a specific model to be augmented. Performing data augmentation on the wrong decision boundary is more targeted and can better improve the robustness and generalization ability of the original model to be augmented. The method includes:

[0005] Constructing a first prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be enhanced, and constructing first label information according to the first prompt word and the first prediction result corresponding to the first text data, wherein the first prediction result is obtained by inputting the first text data into the model to be enhanced;

[0006] Training an editing model according to the first prompt word and the first label information to obtain a trained editing model;

[0007] Masking the first text data by text units to obtain masked second text data corresponding to the first text data, and constructing a second prompt word according to the second text data, a second prediction result and the model identification information, wherein the second prediction result is different from the first prediction result, and the second text data includes one or more masked text units;

[0008] Inputting the second prompt word into the trained editing model, so that the trained editing model completes the one or more masked text units to generate one or more third text data, and obtains corresponding output results based on the one or more third text data;

[0009] Determine whether there is target third text data in the output result; if not, use at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, wherein the output corresponding to the target third text data under the model to be enhanced is the second prediction result, and the output corresponding to the at least one third text data under the model to be enhanced is still the first prediction result.

[0010] Furthermore, the first prompt word includes a placeholder corresponding to an output result obtained by inputting the first text data into the model to be enhanced;

[0011] The step of constructing the first label information according to the first prompt word and the first prediction result corresponding to the first text data includes:

[0012] The placeholder in the first prompt word is completed into a first prediction result corresponding to the first text data, and the completed first prompt word is used as the first label information.

[0013] Furthermore, performing text unit masking on the first text data to obtain masked second text data corresponding to the first text data includes:

[0014] Attributing the first text data and the first prediction result to obtain one or more target text units whose corresponding attribution scores in the first text data are in the same direction as the attribution scores corresponding to the first prediction result, and determining the number of the one or more target text units as the maximum disturbance number;

[0015] Based on the one or more target text units and the maximum disturbance quantity, the first text data is subjected to text unit masking to obtain masked second text data corresponding to the first text data.

[0016] Furthermore, the performing text unit masking on the first text data based on the one or more target text units and the maximum disturbance quantity to obtain masked second text data corresponding to the first text data includes:

[0017] Based on the maximum disturbance quantity, all target text units are masked to obtain masked second text data corresponding to the first text data.

[0018] Furthermore, there are multiple target text units, and based on the one or more target text units and the maximum disturbance quantity, performing text unit masking on the first text data to obtain masked second text data corresponding to the first text data includes:

[0019] Sorting the one or more target text units according to corresponding attribution scores, masking the target text unit with the largest attribution score among the one or more target text units based on the sorting result, and obtaining masked second text data corresponding to the first text data;

[0020] The step of determining whether the output result contains target third text data, and if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, comprises:

[0021] Determine whether there is target third text data in the output result; if not, continue to mask the target text unit with the second largest attribution score among the one or more target text units based on the sorting result, obtain the latest masked second text data corresponding to the first text data, construct the latest second prompt word according to the latest second text data, the second prediction result and the model identification information, input the latest second prompt word into the trained editing model, determine whether there is target third text data in the latest output result of the trained editing model, and so on, until there is target third text data in the latest output result of the trained editing model, or the number of masked target text units in the current latest second text data reaches the maximum disturbance number;

[0022] At least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced.

[0023] Furthermore, there are multiple target text units, and based on the one or more target text units and the maximum disturbance quantity, performing text unit masking on the first text data to obtain masked second text data corresponding to the first text data includes:

[0024] The one or more target text units are sorted according to corresponding attribution scores, and based on the sorting result and the maximum disturbance quantity, a current target text unit to be masked is determined using a dichotomy method, and the current target text unit to be masked is masked to obtain masked second text data corresponding to the first text data;

[0025] The step of determining whether the output result contains target third text data, and if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, comprises:

[0026] Determine whether the target third text data exists in the output result; if not, use binary search to determine the latest target text unit to be masked backward based on the current disturbance quantity; if so, use binary search to determine the latest target text unit to be masked forward based on the current disturbance quantity; mask the latest target text unit to be masked, obtain the latest second text data corresponding to the first text data, construct the latest second prompt word according to the latest second text data, the second prediction result and the model identification information, input the latest second prompt word into the trained editing model, determine whether the target third text data exists in the latest output result of the trained editing model, and so on, until the binary search ends;

[0027] At least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced.

[0028] Furthermore, the method further comprises:

[0029] Determine at least one prediction result other than the first prediction result based on the model to be enhanced;

[0030] A second prediction result is obtained from the at least one prediction result.

[0031] Further, obtaining a second prediction result from the at least one prediction result includes:

[0032] A second prediction result is obtained from the at least one prediction result according to distance information between each prediction result in the at least one prediction result and the first prediction result.

[0033] Furthermore, the step of using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced includes:

[0034] Using the second prediction result as second label information corresponding to at least one third text data generated by the trained editing model;

[0035] The at least one third text data and the second label information are used as enhancement data of the first text data for the model to be enhanced.

[0036] Furthermore, the method further comprises:

[0037] The model to be enhanced is trained based on the enhanced data to obtain an enhanced model.

[0038] The embodiment of this specification also provides a device for enhancing text data, including:

[0039] A first construction module is used to construct a first prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be enhanced, and to construct first label information according to the first prompt word and the first prediction result corresponding to the first text data, wherein the first prediction result is obtained by inputting the first text data into the model to be enhanced;

[0040] A training module, used for training an editing model according to the first prompt word and the first label information to obtain a trained editing model;

[0041] a second construction module, configured to perform text unit masking on the first text data, obtain masked second text data corresponding to the first text data, and construct a second prompt word according to the second text data, a second prediction result and the model identification information, wherein the second prediction result is different from the first prediction result, and the second text data includes one or more masked text units;

[0042] a completion module, configured to input the second prompt word into the trained editing model, so that the trained editing model completes the one or more masked text units to generate one or more third text data, and obtain a corresponding output result based on the one or more third text data;

[0043] An enhancement module is used to determine whether there is target third text data in the output result. If not, at least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced, wherein the output corresponding to the target third text data under the model to be enhanced is the second prediction result, and the output corresponding to the at least one third text data under the model to be enhanced is still the first prediction result.

[0044] The embodiments of the present specification also provide a computer program product, wherein the computer program product stores at least one instruction, and the at least one instruction is suitable for being loaded by a processor and executing the above method steps.

[0045] The embodiments of the present specification also provide a storage medium, wherein the storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the steps of the above method.

[0046] An embodiment of the present specification also provides an electronic device, comprising: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the above method.

[0047] In the embodiments of the present specification, by introducing the decision information of the model to be enhanced in the entire counterfactual generation process, the editing model performs counterfactual text enhancement based on the decision boundary of the model to be enhanced. In this process, if at least one text data generated by the editing model after completing the masked text unit does not contain target text data that can change the prediction result of the model to be enhanced, then it is considered that the prediction result of the original model to be enhanced is wrong. This judgment is actually based on the actual situation that the performance of the editing model (generally a large language model) is stronger than that of the model to be enhanced (generally a small model), and the counterfactual text generated by the editing model is combined with the target prediction result to form a fixed value. For data augmentation, by continuing to train the model to be augmented to optimize the decision boundary of the prediction errors of the original model to be augmented, a method for automatically identifying the prediction errors of the model to be augmented and performing targeted data augmentation on instances of model prediction errors is implemented. By using the prediction results of the model to be augmented instead of the true labels for fine-tuning in the process of fine-tuning the editing model, the decision information of the model to be augmented is introduced into the editing model, avoiding the problem that counterfactual generation only from the data perspective cannot perform data augmentation on the decision boundary of a specific model to be augmented. Data augmentation on the wrong decision boundary is more targeted and can better improve the robustness and generalization ability of the original model to be augmented. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] Figure 1 A flowchart of a method for enhancing text data provided in an embodiment of this specification;

[0049] Figure 2 A flowchart of a method for enhancing text data provided in an embodiment of this specification;

[0050] Figure 3 A flowchart of a method for enhancing text data provided as an example in an embodiment of this specification;

[0051] Figure 4 A schematic diagram of the structure of a device for enhancing text data provided in an embodiment of this specification;

[0052] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION

[0053] In order to make the purpose, technical solutions and advantages of this specification more clear, the technical solutions of this specification will be clearly and completely described below in combination with the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this specification.

[0054] See also Figure 1 , is a flow chart of a method for enhancing text data provided in an embodiment of this specification. In an embodiment of this specification, the method for enhancing text data is applied to a device for enhancing text data (hereinafter referred to as a "text data enhancing device") or an electronic device equipped with a text data enhancing device. Figure 1 The process shown is described in detail, and the method for enhancing text data may specifically include the following steps:

[0055] S102, constructing a first prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be enhanced, and constructing first label information according to the first prompt word and the first prediction result corresponding to the first text data, wherein the first prediction result is obtained by inputting the first text data into the model to be enhanced.

[0056] In some embodiments, the first text data may be any type of text data, for example, the first text data is short text data (for example, "this movie is good"). It should be noted that the above first text data is only an example, not a limitation. Those skilled in the art should understand that any type of text data can be included in the protection scope of this specification, and this specification does not limit this. In some embodiments, the model to be enhanced may be any model that takes text data as input and is used to predict the input text data, for example, the model to be enhanced is a text classification model or a short text classification model. It should be noted that the above model to be enhanced is only an example, not a limitation. Those skilled in the art should understand that any model that takes text data as input and is used to predict the input text data can be included in the protection scope of this specification, and this specification does not limit this.

[0057] In some embodiments, the model identification information of the model to be enhanced is identification information used to uniquely identify the model to be enhanced. For example, the model identification information is a specific number of the model to be enhanced (for example, "M1"). It should be noted that the above-mentioned model identification information is only an example and not a limitation. Those skilled in the art should understand that any identification information used to uniquely identify a model can be included in the scope of protection of this specification, and this specification does not impose any limitations on this.

[0058] In some embodiments, a first prompt corresponding to the first text data is constructed based on the first text data and the model identification information of the model to be enhanced. The first prompt is used to prompt the first text data to be input into the model corresponding to the model identification information to obtain the corresponding output result (that is, the actual prediction result of the model). For example, if the first text data is "this movie is good" and the model identification information is "M1", then the constructed first prompt is "this movie is good. Sentiment classification is performed according to the prediction result of model M1".

[0059] In some embodiments, the output result of the model to be enhanced (i.e., the first prediction result corresponding to the first text data) is obtained by inputting the first text data into the model corresponding to the model identification information (i.e., the model to be enhanced). For example, the first text data "this movie is good" is input into the model to be enhanced to obtain the corresponding first prediction result "positive". In some embodiments, the first label information is constructed according to the first prompt word and the first prediction result corresponding to the first text data. The first label information is used to indicate that the corresponding output result obtained by inputting the first text data into the model corresponding to the model identification information is the first prediction result. For example, the first prompt word is "this movie is good is classified according to the prediction result of model M1 for sentiment classification", and the first prediction result is "positive", then the constructed first label information is "please classify the following sentence: this movie is good according to the prediction result of model M1 for sentiment classification, and the classification result is positive".

[0060] S104: Train an editing model according to the first prompt word and the first label information to obtain a trained editing model.

[0061] In some embodiments, the editing model can be any type of large language model. For example, the editing model is an LLAMA model. It should be noted that the above editing model is only an example and not a limitation. Those skilled in the art should understand that any type of large language model can be included in the protection scope of this specification, and this specification does not impose any restrictions on this.

[0062] In some embodiments, the editing model is fine-tuned by training multiple training data including a first prompt word and its corresponding first label information to obtain a fine-tuned editing model. The editing model is fine-tuned to make it classify as much as possible based on the actual prediction results of the model to be enhanced. In this way, the editing model learns the prediction principle of the model to be enhanced based on the prediction results of the model to be enhanced, laying the foundation for the subsequent second stage to automatically identify incorrect predictions and generate counterfactual texts.

[0063] S106, masking text units of the first text data to obtain masked second text data corresponding to the first text data, and constructing a second prompt word according to the second text data, a second prediction result and the model identification information, wherein the second prediction result is different from the first prediction result, and the second text data includes one or more masked text units.

[0064] In some embodiments, the first text data is subjected to text unit (token) masking, one or more text units in the first text data are masked, and the masked second text data is obtained. In some embodiments, one or more text units to be masked are determined from all text units corresponding to the first text data. For example, a predetermined number of text units to be masked can be randomly determined from all text units. The predetermined number can be randomly determined, or can be pre-set, or can be dynamically determined according to the text length or semantic content of the first text data. This exemplary embodiment does not specifically limit this. For another example, one or more text units that meet a predetermined condition can be determined from all text units corresponding to the first text data and used as text units to be masked. The predetermined condition can be that the importance of the text unit or the degree of influence on the prediction result is greater than or equal to a predetermined threshold, or each text unit is sorted according to its corresponding importance or the degree of influence on the prediction result, and a predetermined number of text units with the highest importance or influence are masked. This exemplary embodiment does not specifically limit this. For example, the first text data is "the movie is good", in which the text unit "good" has a greater impact on the prediction result, and the text unit is masked to obtain the masked second text data "the movie is [MASK]".

[0065] In some embodiments, a second prompt word is constructed according to the second text data, the second prediction result and the model identification information, and the second prompt word is used to prompt the completion of the second text data so that the output result corresponding to the completed second text data under the model corresponding to the model identification information (i.e., the prediction result of the model) is the second prediction result, wherein the second prediction result is different from the first prediction result, that is, the second prediction result is different from the first prediction result. For example, the second text data is "the movie is [MASK]", the first prediction result is "positive", the second prediction result is "negative" which is different from "positive", and the model identification information is "M1", then the constructed second prompt word is "please complete the following sentence: the movie is [MASK] and make its prediction result under the M1 model negative", because the special number M1 is continuously introduced when fine-tuning the editing model in the first stage, adding M1 to the prompt when generating counterfactuals will make the editing model generate as much as possible according to the data in the fine-tuning stage, so that the generated counterfactual instance can more accurately reflect the decision boundary of the model to be enhanced.

[0066] S108, inputting the second prompt word into the trained editing model, so that the trained editing model completes the one or more masked text units to generate one or more third text data, and obtains corresponding output results based on the one or more third text data.

[0067] In some embodiments, the second prompt word is input into the fine-tuned editing model, so that the fine-tuned editing model completes one or more masked text units in the masked second text data in the second prompt word to generate one or more third text data, or the number of third text data generated after completion can also be specified in the second prompt word, so that the editing model will generate the specified number of completed third text data. For example, if the second text data is "the movie is [MASK]", the editing model completes the masked text unit "[MASK]" in the second text data and generates one or more third text data including "the movie is not good", "themovie is bad", etc. In some embodiments, the editing model will input the one or more third text data generated after completion into the model corresponding to the model identification information (i.e., the model to be enhanced) and obtain the prediction result output by the model. For a certain third text data, if the prediction result obtained by the editing model inputting it into the model to be enhanced is the second prediction result, the editing model will output the third text data. If the prediction result obtained by the editing model inputting it into the model to be enhanced is different from the second prediction result, the editing model will not output the third text data. In some embodiments, the number of third text data to be generated can also be set in the second prompt word, so that the editing model completes one or more masked text units in the masked second text data in the second prompt word to generate the set number of multiple different third text data.

[0068] S110, determining whether there is target third text data in the output result, and if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, wherein the output corresponding to the target third text data under the model to be enhanced is the second prediction result, and the output corresponding to the at least one third text data under the model to be enhanced is still the first prediction result.

[0069] In some embodiments, it is determined whether the output result of the editing model includes at least one target third text data whose corresponding output under the model to be enhanced is the second prediction result. If so, the instance of the first text data is ignored. If not, it is considered that the model prediction boundary of the model to be enhanced is wrong, that is, the prediction of the instance of the first text data is wrong. At least one third text data among the one or more third text data generated by the editing model in this process, whose corresponding output under the model to be enhanced is still the first prediction result, is used as the counterfactual text corresponding to the instance of the first text data. The counterfactual text is used as the directional enhancement data of the first text data for the model to be enhanced, that is, the counterfactual text generated by the editing model with stronger prediction ability is used as the directional enhancement data of the instance of the first text data, so as to optimize the decision boundary of the erroneous prediction of the model to be enhanced in a targeted manner.

[0070] In some embodiments, the first prompt word includes a placeholder corresponding to the output result obtained by inputting the first text data into the model to be enhanced; wherein, the first label information is constructed according to the first prompt word and the first prediction result corresponding to the first text data, including: completing the placeholder in the first prompt word to the first prediction result corresponding to the first text data, and using the completed first prompt word as the first label information. In some embodiments, the first prompt word includes a placeholder corresponding to the output result obtained by inputting the first text data into the model to be enhanced, and the placeholder can be any preset text unit, for example, the placeholder is "[BLANK]", which is not particularly limited in this example embodiment. For example, the first prompt word is "this movie is good According to the prediction result of model M1, sentiment classification is performed, and the classification result is [BLANK]". In some embodiments, the placeholder "[BLANK]" in the first prompt word is completed to the first prediction result "positive" corresponding to the first text data, and the completed first prompt word "this movie is good According to the prediction result of model M1, sentiment classification is performed, and the classification result is positive" is used as the first label information.

[0071] In some embodiments, the method further includes: determining at least one prediction result other than the first prediction result based on the model to be enhanced; and obtaining a second prediction result from the at least one prediction result. In some embodiments, one or more prediction results that may be output by the model to be enhanced are obtained. For example, if the model to be enhanced is a sentiment analysis model, the one or more prediction results that may be output by the model to be enhanced include "positive" and "negative". For another example, if the model to be enhanced is a classification task model, the one or more prediction results that may be output by the model to be enhanced include the labels contained in the label range corresponding to the classification task. This exemplary embodiment does not specifically limit this. In some embodiments, at least one prediction result other than the first prediction result is obtained from one or more prediction results that may be output by the model to be enhanced, and a second prediction result is obtained from the at least one prediction result. The second prediction result may include only one prediction result, or may include multiple prediction results. For example, one or more of the at least one prediction result may be randomly determined as the second prediction result, or one or more of the at least one prediction result may be selected by the user as the second prediction result. This exemplary embodiment does not specifically limit the second prediction result obtained from the at least one prediction result.

[0072] In some embodiments, obtaining the second prediction result from the at least one prediction result includes: obtaining the second prediction result from the at least one prediction result according to the distance information between each prediction result in the at least one prediction result and the first prediction result. In some embodiments, for the at least one prediction result, according to the distance information (for example, semantic distance) between each prediction result and the first prediction result, the prediction result with the corresponding distance information greater than or equal to a predetermined threshold in the at least one prediction result can be used as the second prediction result, or the at least one prediction result can be sorted according to the corresponding distance information, and the prediction results with the largest preset number of distances can be used as the second prediction result, which is not particularly limited in this example embodiment.

[0073] In some embodiments, the at least one third text data generated by the trained editing model is used as the enhancement data of the first text data for the model to be enhanced, including: using the second prediction result as the second label information corresponding to the at least one third text data generated by the trained editing model; using the at least one third text data and the second label information as the enhancement data of the first text data for the model to be enhanced. In some embodiments, in addition to using the at least one third text data generated by the editing model in this process, whose corresponding output under the model to be enhanced is still the first prediction result, as the directional enhancement data of the first text data for the model to be enhanced, the second prediction result information is also used as the second label information corresponding to the at least one third text data, and the at least one third text data and its corresponding second label information are used as the directional enhancement data of the first text data for the model to be enhanced.

[0074] In some embodiments, the method further includes: training the model to be enhanced based on the enhanced data to obtain an enhanced model. In some embodiments, the model to be enhanced is further trained based on the enhanced data to optimize the decision boundary of the original model prediction error to obtain an enhanced model. In some embodiments, in view of the distribution deviation of the training data itself where the first text data is located or the non-robustness when the model to be enhanced fits the training data set, the enhanced data corresponding to the first text data is obtained, that is, the distribution problem or model fitting problem is alleviated by supplementing a certain scale of data, thereby enhancing the generalization and robustness of the prediction of the model to be enhanced.

[0075] Figure 2 A flowchart of a method for enhancing text data provided in an embodiment of this specification specifically includes the following steps:

[0076] S202, constructing a first prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be enhanced, and constructing first label information according to the first prompt word and the first prediction result corresponding to the first text data, wherein the first prediction result is obtained by inputting the first text data into the model to be enhanced. Step S202 is the same or similar to the aforementioned step S102, and will not be described in detail herein.

[0077] S204: Train the editing model according to the first prompt word and the first label information to obtain a trained editing model. Step S204 is the same or similar to the aforementioned step S104, and will not be described in detail herein.

[0078] S206, attributing the first text data and the first prediction result, obtaining one or more target text units whose corresponding attribution scores in the first text data are in the same direction as the attribution scores corresponding to the first prediction result, and determining the number of the one or more target text units as the maximum disturbance number.

[0079] S208: Based on the one or more target text units and the maximum disturbance quantity, perform text unit masking on the first text data to obtain masked second text data corresponding to the first text data.

[0080] In some embodiments, a preset attribution method is used to attribute the first text data and the first prediction result, and an attribution score corresponding to the first prediction result and an attribution score corresponding to each text unit (token) in the first text data are obtained. The attribution method includes but is not limited to LIME, SHAP, IG, etc., and this example embodiment does not specifically limit this. In some embodiments, one or more target text units in the first text data whose corresponding attribution scores are in the same direction as the attribution scores corresponding to the first prediction result are obtained, and the number of target text units is determined as the maximum disturbance number. In some embodiments, based on the one or more target text units and the maximum disturbance number, at least one target text unit among the one or more target text units in the first text data is masked to obtain the masked second text data corresponding to the first text data. The specific masking method is described in detail below and will not be repeated here.

[0081] S210, constructing a second prompt word according to the second text data, the second prediction result and the model identification information. The implementation of step S210 has been described in detail in the above embodiment and will not be repeated here.

[0082] S212, inputting the second prompt word into the trained editing model, so that the trained editing model completes the one or more masked text units to generate one or more third text data, and obtains corresponding output results based on the one or more third text data. Step S212 is the same or similar to the aforementioned step S108, and will not be repeated here.

[0083] S214, determining whether there is target third text data in the output result; if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, wherein the output corresponding to the target third text data under the model to be enhanced is the second prediction result, and the output corresponding to the at least one third text data under the model to be enhanced is still the first prediction result.

[0084] In some embodiments, the text unit masking of the first text data based on the one or more target text units and the maximum disturbance number to obtain the masked second text data corresponding to the first text data includes: masking all target text units based on the maximum disturbance number to obtain the masked second text data corresponding to the first text data. In some embodiments, based on the maximum disturbance number, the target text units of the maximum disturbance number, that is, all target text units, are masked to obtain the masked second text data. In some embodiments, all target text units with the same attribution direction as the first prediction result are masked (that is, the masking number reaches the maximum value). If the output result of the editing model still does not include at least one target third text data corresponding to the output of the second prediction result under the model to be enhanced, the first text data instance is determined to be an instance of misprediction, and the counterfactual text generated by the stronger prediction ability of the editing model is used as the directional data enhancement of these instances, so as to optimize the decision boundary of the model to be enhanced for misprediction.

[0085] In some embodiments, there are multiple target text units, and based on the one or more target text units and the maximum disturbance amount, the first text data is masked to obtain the masked second text data corresponding to the first text data, including: sorting the one or more target text units according to the corresponding attribution scores, and based on the sorting result, masking the target text unit with the largest attribution score among the one or more target text units to obtain the masked second text data corresponding to the first text data; wherein, judging whether there is target third text data in the output result, and if not, using at least one third text data generated by the trained editing model as the enhancement data of the first text data for the model to be enhanced, includes: judging whether there is target third text data in the output result, and if not, using at least one third text data generated by the trained editing model as the enhancement data of the first text data for the model to be enhanced. Then, based on the sorting result, continue to mask the target text unit with the second largest attribution score among the one or more target text units, obtain the latest masked second text data corresponding to the first text data, construct the latest second prompt word according to the latest second text data, the second prediction result and the model identification information, input the latest second prompt word into the trained editing model, and determine whether there is target third text data in the latest output result of the trained editing model, and so on, until there is target third text data in the latest output result of the trained editing model, or the number of masked target text units in the current latest second text data reaches the maximum disturbance number; use at least one third text data generated by the trained editing model as the enhanced data of the first text data for the model to be enhanced.In some embodiments, the one or more target text units are sorted according to the corresponding attribution scores, and based on the sorting result, the target text unit with the largest attribution score among the one or more target text units is masked to obtain the masked second text data, and a second prompt word is constructed according to the second text data, the second prediction result and the model identification information, and the second prompt word is input into the trained editing model to determine whether there is target third text data in the output result of the editing model. If so, the traversal is stopped; if not, based on the current second text data and based on the sorting result, the target text unit with the second largest attribution score among the one or more target text units is masked to obtain the latest masked second text data, and then the target text unit with the second largest attribution score is masked to obtain the latest masked second text data. According to the latest second text data, the second prediction result and the model identification information, the latest second prompt word is constructed, and the latest second prompt word is input into the trained editing model to determine whether the target third text data exists in the latest output result of the editing model. If so, the traversal is stopped. If not, based on the current latest second text data, the corresponding target text unit with the third largest attribution score in the one or more target text units is continued to be masked based on the sorting result, and so on, until the target third text data exists in the latest output result of the editing model, or, after obtaining the latest output result of the editing model, if the number of masked target text units in the current latest second text data reaches the maximum disturbance number, the traversal is stopped. In some embodiments, the third text data generated by the editing model during this traversal process, whose corresponding output under the model to be enhanced is still the first prediction result, is used as the directional enhancement data of the first text data for the model to be enhanced.

[0086] In some embodiments, there are multiple target text units, and based on the one or more target text units and the maximum disturbance number, the first text data is masked to obtain the masked second text data corresponding to the first text data, including: sorting the one or more target text units according to the corresponding attribution scores, determining the current target text unit to be masked based on the sorting result and the maximum disturbance number by using a binary search method, masking the current target text unit to be masked, and obtaining the masked second text data corresponding to the first text data; wherein, determining whether there is target third text data in the output result, and if not, using at least one third text data generated by the trained editing model as the enhanced data of the first text data for the model to be enhanced, includes: determining Whether the target third text data exists in the output result, if not, the latest target text unit to be masked is determined backwards using the binary search method based on the current disturbance quantity, and if so, the latest target text unit to be masked is determined forwards using the binary search method based on the current disturbance quantity; the latest target text unit to be masked is masked, the latest second text data corresponding to the first text data is obtained, the latest second prompt word is constructed according to the latest second text data, the second prediction result and the model identification information, the latest second prompt word is input into the trained editing model, and it is determined whether the target third text data exists in the latest output result of the trained editing model, and so on, until the binary search ends; at least one third text data generated by the trained editing model is used as the enhanced data of the first text data for the model to be enhanced. In some embodiments, the one or more target text units are sorted according to the corresponding attribution scores, and based on the sorting result and the maximum disturbance number, the current target text unit to be masked is determined using a binary search method. Specifically, the current disturbance number is first determined by using a binary search method for the maximum disturbance number, and then, based on the current disturbance number and the sorting result, the target text unit of the current disturbance number with the largest corresponding attribution score is obtained, and then, based on the first text data, the target text unit of the current disturbance number is masked to obtain the masked second text data, and a second prompt word is constructed according to the second text data, the second prediction result and the model identification information, and the second prompt word is input into the trained editing model to determine whether the target third text data exists in the output result of the editing model. In some embodiments, it is determined whether the target third text data exists in the output result of the editing model. If not, the latest target text unit to be masked is determined backward based on the current disturbance number using a binary search method. If it exists, the latest target text unit to be masked is determined forward based on the current disturbance number using a binary search method.In some embodiments, based on the first text data, the current latest target text unit to be masked is masked to obtain the latest second text data after masking, and the latest second prompt word is constructed according to the latest second text data, the second prediction result and the model identification information, and the latest second prompt word is input into the trained editing model to determine whether there is target third text data in the latest output result of the editing model. If not, the latest target text unit to be masked is determined backward based on the current disturbance quantity using binary search. If it exists, the latest target text unit to be masked is determined forward based on the current disturbance quantity using binary search, and so on, until the binary search ends and the traversal stops. In some embodiments, the third text data generated by the editing model during this traversal process, whose corresponding output under the model to be enhanced is still the first prediction result, is used as the directional enhancement data of the first text data for the model to be enhanced. For example, the maximum number of disturbances is 5, and the target text unit sequence obtained after sorting in descending order according to the corresponding attribution scores is token1, token2, token3, token4, and token5. The current number of disturbances is determined to be 3 using the binary search method, that is, it is determined that the current target text unit to be masked includes token1, token2, and token3. After masking, the masked second text data is obtained, and a second prompt word is constructed according to the second text data, the second prediction result, and the model identification information. The second prompt word is input into the trained editing model to determine whether the target third text data exists in the output result of the editing model. If not, the latest number of disturbances is determined to be 4 based on the current number of disturbances of 3 using the binary search method. If so, the latest number of disturbances is determined to be 2 based on the current number of disturbances of 3 using the binary search method. In some embodiments, if the latest disturbance number is 4, that is, the latest target text unit to be masked includes token1, token2, token3, and token4, the latest second text data after masking is obtained, and the latest second prompt word is constructed according to the latest second text data, the second prediction result and the model identification information. The latest second prompt word is input into the trained editing model to determine whether the target third text data exists in the latest output result of the editing model. If so, the binary search ends and the traversal stops. If not, the binary search is used to determine the latest disturbance number as 5 based on the current disturbance number 4, and so on, until the binary search ends and the traversal stops.In some embodiments, if the latest disturbance number is 2, that is, the latest target text unit to be masked includes token1 and token2, the latest second text data after masking is obtained, and the latest second prompt word is constructed according to the latest second text data, the second prediction result and the model identification information. The latest second prompt word is input into the trained editing model, and it is determined whether the target third text data exists in the latest output result of the editing model. If not, the binary search ends and the traversal stops. If not, the binary search ends based on the current disturbance number 2 and the binary search is used to determine that the latest disturbance number is 1, and so on, until the binary search ends and the traversal stops.

[0087] Figure 3 A flowchart of a method for enhancing text data provided as an example in an embodiment of this specification.

[0088] like Figure 3As shown, the first stage is used to fine-tune the editing model. In this stage, the first text data "The movie is great" is input into the model to be enhanced M1, and the prediction result obtained is positive. The input of the editing model is the prompt word "M1 predicts <input> as [BLANK]", <input> is the first text data "The movie is great", and the label information corresponding to the prompt word is "M1 predicts <input> as <prediction result>", and <prediction result> is the prediction result positive corresponding to the first text data, that is, the output result obtained by inputting the first text data into the editing model is "M1 predicts 'The movie is great' as 'positive'", and the editing model is fine-tuned through multiple training data including the prompt word and its corresponding label information to obtain the fine-tuned editing model. The second stage is used for targeted data enhancement. In this stage, the first text data and its corresponding prediction result are attributed based on the lime attribution method to obtain the target text unit great in the first text data with the same direction as the attribution score of the prediction result, and the target text unit great is masked to obtain the masked second text data "The movie is [MASK]”, that is, all the target text units in the first text data with the same attribution direction as the prediction result have been masked (that is, the number of masks has reached the maximum value), and a target label negative different from the prediction result positive is obtained. The prompt word constructed in this way is "Complete <masked input> so that M1 predicts it as <target label>", and <masked input> is the masked second text data "The movie is [MASK]", <Target label> is negative, and the prompt word is input into the fine-tuned editing model. If the output result of the editing model at this time still does not include the third text data whose corresponding output is the target label negative under the model to be enhanced (that is, the third text data obtained after completing the masked second text data), that is, if the maximum masking number cannot change the prediction result (that is, change from the prediction result positive to the target label negative), then the multiple third text data whose corresponding output is still the prediction result positive under the model to be enhanced generated by the editing model in this process are used as the multiple counterfactual texts (C1, C2, C3...) corresponding to the first text data instance, and the multiple counterfactual texts are used as the directional enhancement data of the first text data "The movie is great" for the model to be enhanced M1.

[0089] Figure 4The present invention provides a schematic diagram of a device for enhancing text data according to an embodiment of the present specification. The device for enhancing text data (hereinafter referred to as "text data enhancing device 1") can be implemented as all or part of an electronic device through software, hardware or a combination of both. According to some embodiments, the text data enhancing device 1 includes a first construction module 11, a training module 12, a second construction module 13, a completion module 14 and an enhancement module 15.

[0090] A first construction module 11 is used to construct a first prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be enhanced, and to construct first label information according to the first prompt word and the first prediction result corresponding to the first text data, wherein the first prediction result is obtained by inputting the first text data into the model to be enhanced;

[0091] A training module 12, configured to train an editing model according to the first prompt word and the first label information to obtain a trained editing model;

[0092] A second construction module 13 is used to perform text unit masking on the first text data, obtain masked second text data corresponding to the first text data, and construct a second prompt word according to the second text data, a second prediction result and the model identification information, wherein the second prediction result is different from the first prediction result, and the second text data includes one or more masked text units;

[0093] A completion module 14, configured to input the second prompt word into the trained editing model, so that the trained editing model completes the one or more masked text units to generate one or more third text data, and obtains a corresponding output result based on the one or more third text data;

[0094] The enhancement module 15 is used to determine whether there is target third text data in the output result. If not, at least one third text data generated by the trained editing model is used as the enhancement data of the first text data for the model to be enhanced, wherein the output corresponding to the target third text data under the model to be enhanced is the second prediction result, and the output corresponding to the at least one third text data under the model to be enhanced is still the first prediction result.

[0095] In some embodiments, the first prompt word includes a placeholder corresponding to an output result obtained by inputting the first text data into the model to be enhanced;

[0096] The step of constructing the first label information according to the first prompt word and the first prediction result corresponding to the first text data includes:

[0097] The placeholder in the first prompt word is completed into a first prediction result corresponding to the first text data, and the completed first prompt word is used as the first label information.

[0098] In some embodiments, performing text unit masking on the first text data to obtain masked second text data corresponding to the first text data includes:

[0099] Attributing the first text data and the first prediction result to obtain one or more target text units whose corresponding attribution scores in the first text data are in the same direction as the attribution scores corresponding to the first prediction result, and determining the number of the one or more target text units as the maximum disturbance number;

[0100] Based on the one or more target text units and the maximum disturbance quantity, the first text data is subjected to text unit masking to obtain masked second text data corresponding to the first text data.

[0101] In some embodiments, the step of performing text unit masking on the first text data based on the one or more target text units and the maximum disturbance quantity to obtain masked second text data corresponding to the first text data includes:

[0102] Based on the maximum disturbance quantity, all target text units are masked to obtain masked second text data corresponding to the first text data.

[0103] In some embodiments, there are multiple target text units, and based on the one or more target text units and the maximum disturbance quantity, performing text unit masking on the first text data to obtain masked second text data corresponding to the first text data includes:

[0104] Sorting the one or more target text units according to corresponding attribution scores, masking the target text unit with the largest attribution score among the one or more target text units based on the sorting result, and obtaining masked second text data corresponding to the first text data;

[0105] The step of determining whether the output result contains target third text data, and if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, comprises:

[0106] Determine whether there is target third text data in the output result; if not, continue to mask the target text unit with the second largest attribution score among the one or more target text units based on the sorting result, obtain the latest masked second text data corresponding to the first text data, construct the latest second prompt word according to the latest second text data, the second prediction result and the model identification information, input the latest second prompt word into the trained editing model, determine whether there is target third text data in the latest output result of the trained editing model, and so on, until there is target third text data in the latest output result of the trained editing model, or the number of masked target text units in the current latest second text data reaches the maximum disturbance number;

[0107] At least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced.

[0108] In some embodiments, there are multiple target text units, and based on the one or more target text units and the maximum disturbance quantity, performing text unit masking on the first text data to obtain masked second text data corresponding to the first text data includes:

[0109] The one or more target text units are sorted according to corresponding attribution scores, and based on the sorting result and the maximum disturbance quantity, a current target text unit to be masked is determined using a dichotomy method, and the current target text unit to be masked is masked to obtain masked second text data corresponding to the first text data;

[0110] The step of determining whether the output result contains target third text data, and if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, comprises:

[0111] Determine whether the target third text data exists in the output result; if not, use binary search to determine the latest target text unit to be masked backward based on the current disturbance quantity; if so, use binary search to determine the latest target text unit to be masked forward based on the current disturbance quantity; mask the latest target text unit to be masked, obtain the latest second text data corresponding to the first text data, construct the latest second prompt word according to the latest second text data, the second prediction result and the model identification information, input the latest second prompt word into the trained editing model, determine whether the target third text data exists in the latest output result of the trained editing model, and so on, until the binary search ends;

[0112] At least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced.

[0113] In some embodiments, the text data enhancement device 1 is further used for:

[0114] Determine at least one prediction result other than the first prediction result based on the model to be enhanced;

[0115] A second prediction result is obtained from the at least one prediction result.

[0116] In some embodiments, obtaining a second prediction result from the at least one prediction result comprises:

[0117] A second prediction result is obtained from the at least one prediction result according to distance information between each prediction result in the at least one prediction result and the first prediction result.

[0118] In some embodiments, the step of using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced includes:

[0119] Using the second prediction result as second label information corresponding to at least one third text data generated by the trained editing model;

[0120] The at least one third text data and the second label information are used as enhancement data of the first text data for the model to be enhanced.

[0121] In some embodiments, the text data enhancement device 1 is further used for:

[0122] The model to be enhanced is trained based on the enhanced data to obtain an enhanced model.

[0123] The above device embodiments correspond to the method embodiments. For specific descriptions, please refer to the description of the method embodiments, which will not be repeated here. The device embodiments are obtained based on the corresponding method embodiments and have the same technical effects as the corresponding method embodiments. For specific descriptions, please refer to the corresponding method embodiments.

[0124] The embodiment of the present specification also provides a computer storage medium, which can store multiple instructions, and the instructions are suitable for being loaded by a processor to execute the method of the embodiment of the present specification.

[0125] The embodiments of the present specification also provide a computer program product, which stores at least one instruction, and the at least one instruction is loaded by the processor to execute the method of the embodiments of the present specification.

[0126] The embodiments of this specification also provide Figure 5 The structural diagram of the electronic device shown in FIG. Figure 5 At the hardware level, the electronic device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory, and may also include hardware required for other services. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to implement the above-mentioned voice activity detection method.

[0127] Of course, in addition to software implementation, this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the executor of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0128] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with hardware entity modules. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0129] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.

[0130] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0131] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0132] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0133] This specification is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of this specification. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0134] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0135] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0136] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0137] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0138] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0139] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0140] It should be understood by those skilled in the art that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, this specification may take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0141] This specification may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. This specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0142] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0143] The above description is only an embodiment of the present specification and is not intended to limit the present specification. For those skilled in the art, the present specification may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification shall be included in the scope of the claims of the present specification.

Claims

1. A method for enhancing text data, include: Constructing a first prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be enhanced, and constructing first label information according to the first prompt word and the first prediction result corresponding to the first text data, wherein the first prediction result is obtained by inputting the first text data into the model to be enhanced; Training an editing model according to the first prompt word and the first label information to obtain a trained editing model, wherein the editing model is a large language model with better performance than the model to be enhanced; Masking the first text data by text units to obtain masked second text data corresponding to the first text data, and constructing a second prompt word according to the second text data, a second prediction result and the model identification information, wherein the second prediction result is different from the first prediction result, and the second text data includes one or more masked text units; Inputting the second prompt word into the trained editing model, so that the trained editing model completes the one or more masked text units to generate one or more third text data, and obtains corresponding output results based on the one or more third text data; Determine whether there is target third text data in the output result; if not, use at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, wherein the output corresponding to the target third text data under the model to be enhanced is the second prediction result, and the output corresponding to the at least one third text data under the model to be enhanced is still the first prediction result.

2. According to the method of claim 1, the first prompt word comprises a placeholder corresponding to an output result obtained by inputting the first text data into the model to be enhanced; in, The step of constructing first label information according to the first prompt word and the first prediction result corresponding to the first text data includes: The placeholder in the first prompt word is completed into a first prediction result corresponding to the first text data, and the completed first prompt word is used as the first label information.

3. The method according to claim 1, performing text unit masking on the first text data to obtain masked second text data corresponding to the first text data, include: Attributing the first text data and the first prediction result to obtain one or more target text units whose corresponding attribution scores in the first text data are in the same direction as the attribution scores corresponding to the first prediction result, and determining the number of the one or more target text units as the maximum disturbance number; Based on the one or more target text units and the maximum disturbance quantity, the first text data is subjected to text unit masking to obtain masked second text data corresponding to the first text data.

4. The method according to claim 3, wherein based on the one or more target text units and the maximum disturbance quantity, the first text data is subjected to text unit masking to obtain masked second text data corresponding to the first text data, include: Based on the maximum disturbance quantity, all target text units are masked to obtain masked second text data corresponding to the first text data.

5. The method according to claim 3, wherein the target text unit is multiple, and based on the one or more target text units and the maximum disturbance quantity, the first text data is subjected to text unit masking to obtain the masked second text data corresponding to the first text data, include: Sorting the one or more target text units according to corresponding attribution scores, masking the target text unit with the largest attribution score among the one or more target text units based on the sorting result, and obtaining masked second text data corresponding to the first text data; The step of determining whether the output result contains target third text data, and if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, comprises: Determine whether there is target third text data in the output result; if not, continue to mask the target text unit with the second largest attribution score among the one or more target text units based on the sorting result, obtain the latest masked second text data corresponding to the first text data, construct the latest second prompt word according to the latest second text data, the second prediction result and the model identification information, input the latest second prompt word into the trained editing model, determine whether there is target third text data in the latest output result of the trained editing model, and so on, until there is target third text data in the latest output result of the trained editing model, or the number of masked target text units in the current latest second text data reaches the maximum disturbance number; At least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced.

6. The method according to claim 3, wherein the target text unit is multiple, and based on the one or more target text units and the maximum disturbance quantity, the first text data is subjected to text unit masking to obtain the masked second text data corresponding to the first text data, include: The one or more target text units are sorted according to corresponding attribution scores, and based on the sorting result and the maximum disturbance quantity, a current target text unit to be masked is determined using a dichotomy method, and the current target text unit to be masked is masked to obtain masked second text data corresponding to the first text data; The step of determining whether the output result contains target third text data, and if not, using at least one third text data generated by the trained editing model as enhancement data of the first text data for the model to be enhanced, comprises: Determine whether the target third text data exists in the output result; if not, use binary search to determine the latest target text unit to be masked backward based on the current disturbance quantity; if so, use binary search to determine the latest target text unit to be masked forward based on the current disturbance quantity; mask the latest target text unit to be masked, obtain the latest second text data corresponding to the first text data, construct the latest second prompt word according to the latest second text data, the second prediction result and the model identification information, input the latest second prompt word into the trained editing model, determine whether the target third text data exists in the latest output result of the trained editing model, and so on, until the binary search ends; At least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced.

7. The method according to claim 1, further comprising: include: Determine at least one prediction result other than the first prediction result based on the model to be enhanced; A second prediction result is obtained from the at least one prediction result.

8. The method according to claim 7, wherein the second prediction result is obtained from the at least one prediction result. include: A second prediction result is obtained from the at least one prediction result according to distance information between each prediction result in the at least one prediction result and the first prediction result.

9. The method according to claim 1, wherein at least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced, include: Using the second prediction result as second label information corresponding to at least one third text data generated by the trained editing model; The at least one third text data and the second label information are used as enhancement data of the first text data for the model to be enhanced.

10. The method according to any one of claims 1 to 9, further comprising: include: The model to be enhanced is trained based on the enhanced data to obtain an enhanced model.

11. A device for enhancing text data, include: A first construction module is used to construct a first prompt word corresponding to the first text data according to the first text data and the model identification information of the model to be enhanced, and to construct first label information according to the first prompt word and the first prediction result corresponding to the first text data, wherein the first prediction result is obtained by inputting the first text data into the model to be enhanced; a training module, configured to train an editing model according to the first prompt word and the first label information to obtain a trained editing model, wherein the editing model is a large language model having a performance stronger than that of the model to be enhanced; a second construction module, configured to perform text unit masking on the first text data, obtain masked second text data corresponding to the first text data, and construct a second prompt word according to the second text data, a second prediction result and the model identification information, wherein the second prediction result is different from the first prediction result, and the second text data includes one or more masked text units; a completion module, configured to input the second prompt word into the trained editing model, so that the trained editing model completes the one or more masked text units to generate one or more third text data, and obtain a corresponding output result based on the one or more third text data; An enhancement module is used to determine whether there is target third text data in the output result. If not, at least one third text data generated by the trained editing model is used as enhancement data of the first text data for the model to be enhanced, wherein the output corresponding to the target third text data under the model to be enhanced is the second prediction result, and the output corresponding to the at least one third text data under the model to be enhanced is still the first prediction result.

12. A storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 10 are implemented.

13. An electronic device, It is characterized in that include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the steps of the method as claimed in any one of claims 1 to 10.

14. A computer program product having stored thereon at least one instruction, It is characterized in that When the at least one instruction is executed by the processor, the steps of the method described in any one of claims 1 to 10 are implemented.