Data enhancement method and related equipment based on self-supervision

Through the self-supervised data enhancement method, the emotional importance of words in the natural language processing model is calculated and counterexample data is generated, which solves the problem of reduced generalization ability caused by uneven data distribution, reduces costs and time-consuming, and improves the robustness of the model. sex.

CN113849649BActive Publication Date: 2024-08-27PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111147029.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-28
Publication Date
2024-08-27
Estimated Expiration
2041-09-28

AI Technical Summary

Technical Problem

When existing natural language processing models face uneven data distribution, their generalization capabilities are reduced and they require manual annotation to generate enhanced data sets, resulting in high costs and long time-consuming.

Method used

A data enhancement method based on self-supervision is adopted to obtain text sentences to be enhanced, calculate the emotional importance measure of words, delete and replace important words to generate counterexample data, and reduce reliance on manual annotations.

Benefits of technology

It reduces the cost and overall time-consuming of data enhancement, analyzes contextual causal terms through self-supervision, generates high-quality enhanced data sets, and improves the robustness of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113849649B
    Figure CN113849649B
Patent Text Reader

Abstract

This application relates to the field of artificial intelligence technology, specifically providing a self-supervised data augmentation method and related equipment. The method includes: acquiring a text statement to be augmented; sampling the text statement to obtain a word sequence to be processed; obtaining a first importance measure of the first word in the text statement to the sentiment classification of the text statement based on the word sequence; determining a target word from the first word based on the first importance measure; deleting the target word from the text statement to obtain first counterexample data; and replacing the target word with a word having the opposite sentiment to the target word to obtain second counterexample data. The embodiments of this application help reduce the cost of data augmentation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of deep learning technology, and in particular to a self-supervision-based data enhancement method and related equipment. Background Art

[0002] In recent years, the performance of deep learning in natural language processing (NLP) has been significantly improved, and natural language processing models with excellent learning effects have been widely used in scenarios such as intelligent question answering and online translation. However, when faced with uneven data distribution, such models will show problems such as reduced generalization ability and performance degradation caused by data distribution shift. The current solution is to use enhanced data sets to train models to reduce reliance on possible false patterns in the original data. However, the current solution requires manual annotation of the original data, and the cost of generating enhanced data sets is high and time-consuming. Summary of the invention

[0003] In response to the above problems, the present application provides a data enhancement method and related equipment based on self-supervision, which is conducive to reducing the cost of data enhancement.

[0004] To achieve the above objectives, the first aspect of the embodiments of the present application provides a data enhancement method based on self-supervision, the method comprising:

[0005] Get the text sentence to be enhanced;

[0006] Sampling the text sentence to be enhanced to obtain a word sequence to be processed;

[0007] Based on the to-be-processed word sequence, obtaining a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence;

[0008] determining a target word from the first words based on the first importance measure;

[0009] Deleting the target word from the text sentence to be enhanced to obtain first counterexample data;

[0010] The target word is replaced with a word having opposite sentiment to the target word to obtain second counterexample data.

[0011] In combination with the first aspect, in a possible implementation manner, obtaining, based on the to-be-processed word sequence, a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence includes:

[0012] Shielding the second word in the to-be-processed word sequence to obtain a shielded word sequence, and replacing the token of the second word with a token of any word to obtain a replaced word sequence, wherein the first word includes the second word;

[0013] The first importance metric is calculated based on the masked word sequence and the replaced word sequence.

[0014] In combination with the first aspect, in a possible implementation, the calculating the first importance metric based on the masked word sequence and the replaced word sequence includes:

[0015] Inputting the masked word sequence into a masked language model so that the masked language model processes the masked word sequence to obtain a first prediction result of the second word;

[0016] Inputting the replaced word sequence into a masked language model so that the masked language model processes the replaced word sequence to obtain a second prediction result for the second word;

[0017] The first importance metric is calculated based on the first prediction result and the second prediction result.

[0018] In combination with the first aspect, in a possible implementation manner, determining a target word from the first words based on the first importance metric includes:

[0019] Sorting the first words in descending order according to the first importance metric to obtain a sorted first word sequence;

[0020] The first word in the first word sequence is determined as the target word.

[0021] In combination with the first aspect, in a possible implementation manner, replacing the target word with a word having opposite sentiment to the target word to obtain second counterexample data includes:

[0022] Generating a set of candidate words having opposite sentiments to the target word;

[0023] Determine a replacement word for the target word from the candidate word set;

[0024] The target word is replaced with the replacement word to obtain the second counterexample data.

[0025] In combination with the first aspect, in a possible implementation, determining a replacement word for the target word from the candidate word set includes:

[0026] Replacing the target word with a candidate word in the candidate word set to obtain a candidate counterexample sentence;

[0027] Calculating a second importance measure of the candidate word for the sentiment classification of the candidate counterexample sentence;

[0028] Sorting the candidate words in descending order according to the second importance metric to obtain a sorted candidate word sequence;

[0029] The first word in the candidate word sequence is determined as the replacement word.

[0030] A second aspect of an embodiment of the present application provides a data enhancement device based on self-supervision, the device comprising an acquisition unit and a processing unit;

[0031] The acquisition unit is used to acquire the text sentence to be enhanced;

[0032] The processing unit is used to sample the text sentence to be enhanced to obtain a word sequence to be processed;

[0033] The processing unit is used to obtain a first importance measure of a first word in the text sentence to be enhanced for the sentiment classification of the text sentence to be enhanced based on the word sequence to be processed;

[0034] The processing unit is configured to determine a target word from the first words based on the first importance measure;

[0035] The processing unit is used to delete the target word from the text sentence to be enhanced to obtain first counterexample data;

[0036] The processing unit is used to replace the target word with a word having opposite sentiment to the target word to obtain second counterexample data.

[0037] A third aspect of an embodiment of the present application provides an electronic device, the electronic device comprising an input device and an output device, and further comprising a processor adapted to implement one or more computer programs; and a memory, wherein the memory stores one or more computer programs, wherein the one or more computer programs are adapted to be loaded by the processor and execute the following steps:

[0038] Get the text sentence to be enhanced;

[0039] Sampling the text sentence to be enhanced to obtain a word sequence to be processed;

[0040] Based on the to-be-processed word sequence, obtaining a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence;

[0041] determining a target word from the first words based on the first importance measure;

[0042] Deleting the target word from the text sentence to be enhanced to obtain first counterexample data;

[0043] The target word is replaced with a word having opposite sentiment to the target word to obtain second counterexample data.

[0044] A fourth aspect of the embodiments of the present application provides a computer storage medium, wherein the computer storage medium stores one or more computer programs, and the one or more computer programs are suitable for being loaded by a processor and executing the following steps:

[0045] Get the text sentence to be enhanced;

[0046] Sampling the text sentence to be enhanced to obtain a word sequence to be processed;

[0047] Based on the to-be-processed word sequence, obtaining a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence;

[0048] determining a target word from the first words based on the first importance measure;

[0049] Deleting the target word from the text sentence to be enhanced to obtain first counterexample data;

[0050] The target word is replaced with a word having opposite sentiment to the target word to obtain second counterexample data.

[0051] The above scheme of the present application at least includes the following beneficial effects: the embodiment of the present application obtains the text sentence to be enhanced; samples the text sentence to be enhanced to obtain a sequence of words to be processed; based on the sequence of words to be processed, obtains the first importance measure of the first word in the text sentence to be enhanced for the sentiment classification of the text sentence to be enhanced; determines the target word from the first word based on the first importance measure; deletes the target word from the text sentence to be enhanced to obtain the first counter-example data; replaces the target word with a word with the opposite sentiment to the target word to obtain the second counter-example data. In this way, by calculating the importance measure (i.e., the first importance measure) of the word for the sentiment classification of the original sentence (i.e., the text sentence to be enhanced), the most important word indicated by the importance measure is used as the causal term (i.e., the target word) that affects the sentiment classification of the sentence, and then the causal term is deleted and replaced to obtain two counter-example data, so as to achieve the purpose of enhancement. Since the contextual causal terms are analyzed in a self-supervised manner without the need to collect and introduce high-quality manual annotations, it is beneficial to reduce the cost of data enhancement and the overall time consumption of data enhancement. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0053] Figure 1 A schematic diagram of an application environment provided for an embodiment of the present application;

[0054] Figure 2 A flowchart of a self-supervised data enhancement method provided in an embodiment of the present application;

[0055] Figure 3 A schematic diagram of an overall process of data enhancement provided in an embodiment of the present application;

[0056] Figure 4 A flowchart of another self-supervised data enhancement method provided in an embodiment of the present application;

[0057] Figure 5 A schematic diagram of the structure of a data enhancement device based on self-supervision provided in an embodiment of the present application;

[0058] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.

[0060] The terms "including" and "having" and any variations thereof that appear in the specification, claims and drawings of this application are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units that are inherent to these processes, methods, products or devices. In addition, the terms "first", "second" and "third" are used to distinguish different objects, rather than to describe a specific order.

[0061] The present invention provides a self-supervised data enhancement method. Figure 1 For the application environment implementation shown, see Figure 1 , the application environment includes an electronic device and at least one terminal device that is communicatively connected to the electronic device, wherein the terminal device is provided with an input interface, the input interface is used to receive text statements and program codes input by R&D personnel, and run the program code through the operating environment provided by the terminal device, and send the text statements to the communication interface, the communication interface is used to compress and package the text statements according to the program code, and send the text statements to the electronic device. The electronic device receives the text statements sent by the terminal device through its own input device, parses and cleans the text statements, and obtains the text statements to be enhanced. For the text statements to be enhanced, the electronic device identifies the causal terms therein by executing the above-mentioned self-supervised data enhancement method, deletes and replaces the causal terms, and obtains two types of counterexample data. Since the contextual causal terms are analyzed in a self-supervised manner without the need to collect and introduce high-quality manual annotations, it is beneficial to reduce the cost of data enhancement and the overall time consumption of data enhancement.

[0062] Among them, electronic devices can be independent servers or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms. Terminal devices can be smartphones, computers, tablets, wearable devices, personal digital assistants, etc.

[0063] based on Figure 1 The application environment shown is described below in detail with reference to other drawings to illustrate the self-supervision-based data enhancement method provided in the embodiment of the present application.

[0064] See also Figure 2 , Figure 2 A flow chart of a self-supervised data enhancement method provided in an embodiment of the present application, the method is applied to an electronic device, such as Figure 2 As shown, steps 201-206 are included:

[0065] 201: Obtain the text sentence to be enhanced.

[0066] In an embodiment of the present application, for a text data set sent by a terminal device, the electronic device first performs data cleaning on the text data set to obtain a text sentence to be enhanced. Exemplarily, an operation of performing data cleaning on a text data set may be to identify periods in the text data set, divide the text data set into multiple sentences to be cleaned according to the identified periods, perform one-hot encoding on each of the multiple sentences to be cleaned to obtain a word vector for each sentence to be cleaned, and perform sentiment feature extraction on each sentence to be cleaned to obtain a sentiment feature vector for each sentence to be cleaned, concatenate the word vector of each sentence to be cleaned with its sentiment feature vector to obtain a text feature of each sentence to be cleaned, cluster the text features using a DBSCAN algorithm to obtain discrete sentences from multiple sentences to be cleaned, remove the discrete sentences from the multiple sentences to be cleaned, and obtain at least one text sentence to be enhanced, such as Figure 3 The S shown 1 , S 2 , …, S k , where k represents the number of text sentences to be enhanced. In this implementation, the sentiment feature vector of the text is introduced into the final text feature, which is conducive to clustering multiple sentences to be cleaned from the perspective of the sentiment expressed in the text. Discrete sentences are usually difficult to classify sentiment or have vague sentiment. Eliminating such sentences is more conducive to determining the counterexample sentiment of the original sentence.

[0067] Specifically, text features are represented as points in high-dimensional space. For any text feature of a sentence to be cleaned, it is represented as point p. In the DBSCAN algorithm, the number of neighborhood points of point p is determined according to the preset radius Eps. If the number of neighborhood points of point p is less than the neighborhood density threshold Minpts, point p is a boundary point. If the number of neighborhood points of point p is greater than or equal to the neighborhood density threshold Minpts, point p is a core point. The text features that are not determined as boundary points or core points are determined as discrete points, and the corresponding sentences to be cleaned are discrete sentences.

[0068] 202: Sampling the text sentence to be enhanced to obtain a word sequence to be processed.

[0069] In an embodiment of the present application, sampling of each text sentence to be enhanced may be performed by random sampling or logarithmic sampling. For example, in order to reduce the amount of calculation in the high-dimensional space, the present application adopts logarithmic sampling. If the number of words in the text sentence to be enhanced is N, the number of word sequences to be processed is [ln N].

[0070] 203: Based on the to-be-processed word sequence, obtain a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence.

[0071] In the embodiment of the present application, obtaining a first importance measure of the first word in the text sentence to be enhanced for the sentiment classification of the text sentence to be enhanced based on the word sequence to be processed includes:

[0072] Shielding the second word in the to-be-processed word sequence to obtain a shielded word sequence, and replacing the token of the second word with a token of any word to obtain a replaced word sequence, wherein the first word includes the second word;

[0073] The first importance metric is calculated based on the masked word sequence and the replaced word sequence.

[0074] Among them, the second word refers to the first word sampled in the text sentence to be enhanced, which is the same as the Masked Language Model (MLM). In the embodiment of the present application, for 15% of the second words in the word sequence to be processed, the token of the second word will be shielded by a mask, and the token of the second word will be replaced by the token of any other word, and the token of the second word will be retained, and the original proportions of 80%, 10%, and 10% will be adjusted. For the shielded word sequence, it is input into the MLM model for prediction, and the prediction result obtained when the shielded word sequence is used to predict the shielded second word is used as the first prediction result. For the replaced word sequence, it is also input into the MLM model for prediction, and the prediction result obtained when the replaced word sequence is used to predict the replaced second word is used as the second prediction result. The importance measure of the predicted word for the sentiment classification of the text sentence to be enhanced is calculated based on the first prediction result and the second prediction result, that is, the first importance measure, and its formula is expressed as follows:

[0075]

[0076] in, represents the first importance measure of word W, S -β \P represents the word sequence after replacing word W. represents the second prediction result of the MLM model after replacing word W, S -β Indicates the word sequence after masking word W, It represents the first prediction result of the MLM model after masking the word W. It represents the word sequence to be processed after sampling the text sentence to be enhanced, and \P represents the operation of shielding the phrase P from the word sequence to be processed.

[0077] Among them, the value range of the first importance metric is preset to [0,100]. Exemplarily, the method also includes: for a first word whose first importance metric is outside the range, it is determined that the first word has no influence on the sentiment classification of the enhanced text sentence, then it is directly filtered without performing subsequent sorting processing.

[0078] 204: Determine a target word from the first words based on the first importance metric.

[0079] In the embodiment of the present application, after the first importance metric of the first word in the text sentence to be enhanced is calculated in step 203, as Figure 3As shown, for the first word whose first importance metric is within a preset value range, a classifier is used to sort the first words of this category in descending order according to the first importance metric, and the first word in the sorted first word sequence is determined as the target word. The target word is the word that has the greatest influence on the sentiment classification of the enhanced text sentence, that is, the causal term that needs to be determined.

[0080] 205: Delete the target word from the text sentence to be enhanced to obtain first counterexample data.

[0081] In the embodiment of the present application, the determined target word is deleted from the text sentence to be enhanced, and the text composed of the remaining words in the text sentence to be enhanced is the first counterexample data.

[0082] 206: Replace the target word with a word having opposite sentiment to the target word to obtain second counterexample data.

[0083] In the embodiment of the present application, the target word is replaced with a word having opposite sentiment to the target word to obtain the second counterexample data, including:

[0084] Generating a set of candidate words having opposite sentiments to the target word;

[0085] Determine a replacement word for the target word from the candidate word set;

[0086] The target word is replaced with the replacement word to obtain the second counterexample data.

[0087] Specifically, for the selected target word, the electronic device generates a set of candidate words with opposite emotions to the target word. For example, the set of candidate words with opposite emotions to "hate" can be {love, like, know what to do, be obsessed with, appreciate, pamper, like, cute, envy, interest, hobby, like, obsession, welcome}, then some words can be selected from the candidate word set to replace the target word in the text sentence to be enhanced, and the replaced sentence is recorded as a candidate counter-example sentence. For the candidate counter-example sentence, similar to the text sentence to be enhanced, the words therein are sampled, shielded and replaced, and then predicted by the MLM model. The second importance measure of the selected candidate words for the sentiment classification of the candidate counter-example sentence is calculated by the above formula, and then sorted by the classifier, and the first word in the candidate word sequence is determined as the final replacement word, that is, when the selected candidate word is the first word in the candidate word sequence, it is considered that the candidate word has the highest degree of influence on the sentiment classification of the candidate counter-example sentence, then it can be determined that the generated candidate counter-example sentence is a sentence with opposite emotions to the text sentence to be enhanced, and finally the candidate counter-example sentence can be determined as the second counter-example data.

[0088] Exemplarily, the method further includes:

[0089] Using the text sentence to be enhanced, the first counterexample data, and the second counterexample data to train a BERT (Bidirectional Encoder Representations from Transformers) model;

[0090] The parameters of the BERT model are adjusted according to the actual emotional semantic information of the text sentence to be enhanced, the first counterexample data and the second counterexample data, and the prediction result of the BERT model.

[0091] In the embodiment of the present application, the text sentence to be enhanced, the first counter-example data and the second counter-example data are used as the enhanced data set to train the BERT model. Since the MLM model records the actual emotional semantic information of the text sentence to be enhanced, the first counter-example data and the second counter-example data, the loss value can be calculated according to the emotional semantic information predicted by BERT and the actual emotional semantic information, and the parameters of the BERT model are updated by back propagation. In this embodiment, the text sentence to be enhanced, the first counter-example data and the second counter-example data are used as sample data to train the BERT model. Since the labels of the first counter-example data and the second counter-example data are generated in a self-supervised manner, i.e., the actual emotional semantic information, there is no need to perform manual annotation, which is conducive to saving labor costs. In addition, the BERT model is used as a discriminator, and the quality of the generated counter-example data can be judged according to the calculated loss value. For example, when the loss value is small, it is considered that the generated counter-example data has a higher quality. Since the generated counter-example data is conducive to helping the model to resist the false mode between the original data, it can reduce the possibility of the model learning false associations, therefore, the counter-example data is used to train the BERT model, which is conducive to enhancing the robustness of the model.

[0092] Exemplarily, the sampling of the text sentence to be enhanced to obtain a word sequence to be processed includes:

[0093] Performing K logarithmic sampling on the text sentence to be enhanced to obtain K word sequences to be processed;

[0094] The step of obtaining, based on the to-be-processed word sequence, a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence comprises:

[0095] For each of the K to-be-processed word sequences, calculating a third importance measure of a third word in each to-be-processed word sequence for sentiment classification of the to-be-enhanced text sentence, wherein the first words include the third word;

[0096] If at least one of the K to-be-processed word sequences includes the same target third word, an average value of at least one third importance metric of the target third word is used as the first importance metric, and the at least one to-be-processed word sequence corresponds one-to-one to the at least one third importance metric;

[0097] If the third word is sampled into only one of the K to-be-processed word sequences, the third importance metric of the third word is used as the first importance metric.

[0098] Specifically, in order to avoid uneven sampling caused by logarithmic sampling, the embodiment of the present application performs K sampling on the text sentence to be enhanced, and each sampling obtains a word sequence to be processed, and finally obtains K word sequences to be processed. For each word sequence to be processed in the K word sequences to be processed, the importance measure (i.e., the third importance measure) of each word (i.e., the third word) for the sentiment classification of the text sentence to be enhanced is calculated in the manner of step 203. If the same target third word appears in at least one of the K word sequences to be processed, the average value of at least one third importance measure of at least one of the target third words calculated is determined as the first importance measure of the target third word for the sentiment classification of the text sentence to be enhanced; if some third words do not appear in at least one of the K word sequences to be processed, that is, the third word is only sampled once in the K samplings, then the third importance measure of the third word is directly determined as its first importance measure. In this implementation, in order to avoid the problem of uneven sampling, multiple logarithmic sampling is adopted. For words that appear repeatedly in the word sequence to be processed, the average value of their multiple importance measurements is used as the final importance measurement to make the importance evaluation more reasonable.

[0099] It can be seen that the embodiment of the present application obtains the text sentence to be enhanced; samples the text sentence to be enhanced to obtain a sequence of words to be processed; based on the sequence of words to be processed, obtains the first importance measure of the first word in the text sentence to be enhanced for the sentiment classification of the text sentence to be enhanced; determines the target word from the first word based on the first importance measure; deletes the target word from the text sentence to be enhanced to obtain the first counter-example data; replaces the target word with a word with the opposite sentiment to the target word to obtain the second counter-example data. In this way, by calculating the importance measure (i.e., the first importance measure) of the word for the sentiment classification of the original sentence (i.e., the text sentence to be enhanced), the most important word indicated by the importance measure is used as the causal term (i.e., the target word) that affects the sentiment classification of the sentence, and then the causal term is deleted and replaced to obtain two counter-example data, thereby achieving the purpose of enhancement. Since the contextual causal terms are analyzed in a self-supervised manner without the need to collect and introduce high-quality manual annotations, it is beneficial to reduce the cost of data enhancement and the overall time consumption of data enhancement.

[0100] See also Figure 4 , Figure 4 A flowchart of another self-supervised data enhancement method provided in an embodiment of the present application is as follows: Figure 4 As shown, steps 401-407 are included:

[0101] 401: Get the text sentence to be enhanced;

[0102] 402: Sampling the text sentence to be enhanced to obtain a word sequence to be processed;

[0103] 403: shielding the second word in the to-be-processed word sequence to obtain a shielded word sequence, and replacing the token of the second word with a token of any word to obtain a replaced word sequence;

[0104] 404: Calculate a first importance measure of a first word in the text sentence to be enhanced for sentiment classification of the text sentence to be enhanced based on the masked word sequence and the replaced word sequence;

[0105] wherein the first word includes the second word;

[0106] 405: Determine a target word from the first words based on the first importance metric;

[0107] 406: Delete the target word from the text sentence to be enhanced to obtain first counterexample data;

[0108] 407: Replace the target word with a word having opposite sentiment to the target word to obtain second counterexample data.

[0109] The specific implementation of steps 401-407 is as follows: Figure 2 The embodiments shown have been described in detail and can achieve the same or similar beneficial effects. To avoid repetition, they will not be described again here.

[0110] Based on the description of the above self-supervised data enhancement method embodiment, please refer to Figure 5 , Figure 5 A schematic diagram of the structure of a data enhancement device based on self-supervision provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the device includes an acquisition unit 501 and a processing unit 502;

[0111] An acquisition unit, used for acquiring the text sentence to be enhanced;

[0112] A processing unit, used for sampling the text sentence to be enhanced to obtain a word sequence to be processed;

[0113] A processing unit, configured to obtain, based on the to-be-processed word sequence, a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence;

[0114] a processing unit, configured to determine a target word from the first words based on the first importance metric;

[0115] A processing unit, configured to delete the target word from the text sentence to be enhanced to obtain first counterexample data;

[0116] A processing unit is used to replace the target word with a word having opposite sentiment to the target word to obtain second counterexample data.

[0117] It can be seen that in Figure 5In the self-supervised data enhancement device shown, a text sentence to be enhanced is obtained; the text sentence to be enhanced is sampled to obtain a sequence of words to be processed; based on the sequence of words to be processed, a first importance measure of the first word in the text sentence to be enhanced for the sentiment classification of the text sentence to be enhanced is obtained; based on the first importance measure, a target word is determined from the first word; the target word is deleted from the text sentence to be enhanced to obtain first counter-example data; the target word is replaced with a word with opposite sentiment to the target word to obtain second counter-example data. In this way, by calculating the importance measure (i.e., the first importance measure) of the word for the sentiment classification of the original sentence (i.e., the text sentence to be enhanced), the most important word indicated by the importance measure is used as the causal term (i.e., the target word) that affects the sentiment classification of the sentence, and then the causal term is deleted and replaced to obtain two counter-example data, thereby achieving the purpose of enhancement. Since the contextual causal terms are analyzed in a self-supervised manner without the need to collect and introduce high-quality manual annotations, it is beneficial to reduce the cost of data enhancement and the overall time consumption of data enhancement.

[0118] In a possible implementation, in terms of obtaining a first importance measure of a first word in the text sentence to be enhanced for sentiment classification of the text sentence to be enhanced based on the sequence of words to be processed, the processing unit 502 is specifically configured to:

[0119] Shielding the second word in the to-be-processed word sequence to obtain a shielded word sequence, and replacing the token of the second word with a token of any word to obtain a replaced word sequence, wherein the first word includes the second word;

[0120] The first importance metric is calculated based on the masked word sequence and the replaced word sequence.

[0121] In a possible implementation, in terms of calculating the first importance metric based on the masked word sequence and the replaced word sequence, the processing unit 502 is specifically configured to:

[0122] Inputting the masked word sequence into a masked language model so that the masked language model processes the masked word sequence to obtain a first prediction result of the second word;

[0123] Inputting the replaced word sequence into a masked language model so that the masked language model processes the replaced word sequence to obtain a second prediction result for the second word;

[0124] The first importance metric is calculated based on the first prediction result and the second prediction result.

[0125] In a possible implementation, in determining the target word from the first word based on the first importance metric, the processing unit 502 is specifically configured to:

[0126] Sorting the first words in descending order according to the first importance metric to obtain a sorted first word sequence;

[0127] The first word in the first word sequence is determined as the target word.

[0128] In a possible implementation, in terms of replacing the target word with a word having opposite sentiment to the target word to obtain the second counterexample data, the processing unit 502 is specifically configured to:

[0129] Generating a set of candidate words having opposite sentiments to the target word;

[0130] Determine a replacement word for the target word from the candidate word set;

[0131] The target word is replaced with the replacement word to obtain the second counterexample data.

[0132] In a possible implementation, in determining a replacement word for the target word from the candidate word set, the processing unit 502 is specifically configured to:

[0133] Replacing the target word with a candidate word in the candidate word set to obtain a candidate counterexample sentence;

[0134] Calculating a second importance measure of the candidate word for the sentiment classification of the candidate counterexample sentence;

[0135] Sorting the candidate words in descending order according to the second importance metric to obtain a sorted candidate word sequence;

[0136] The first word in the candidate word sequence is determined as the replacement word.

[0137] According to one embodiment of the present application, Figure 5The various units of the self-supervised data enhancement device shown can be separately or completely combined into one or several other units to constitute, or one (some) of the units can be further divided into multiple functionally smaller units to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the self-supervised data enhancement device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0138] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 2 or Figure 4 A computer program (including program code) for each step involved in the corresponding method shown in Figure 5 The self-supervised data enhancement device shown in the embodiment of the present application is used to implement the self-supervised data enhancement method. The computer program can be recorded on a computer-readable recording medium, for example, and loaded into the above-mentioned computing device through the computer-readable recording medium and run therein.

[0139] Based on the description of the above method embodiment and device embodiment, the present application embodiment also provides an electronic device. Figure 6 The electronic device at least includes a processor 601, an input device 602, an output device 603, and a memory 604. The processor 601, the input device 602, the output device 603, and the memory 604 in the electronic device may be connected via a bus or other means.

[0140] The computer storage medium may be stored in the memory 604 of the electronic device, the computer storage medium is used to store a computer program, the computer program includes program instructions, and the processor 601 is used to execute the computer program stored in the memory 604. The processor 601 (or CPU (Central Processing Unit)) is the computing core and control core of the electronic device, which is suitable for implementing one or more computer programs, and is specifically suitable for loading and executing one or more computer programs to implement corresponding method flows or corresponding functions.

[0141] In one embodiment, the processor 601 of the electronic device provided in the embodiment of the present application can be used to perform a series of self-supervision-based data enhancement processes:

[0142] Get the text sentence to be enhanced;

[0143] Sampling the text sentence to be enhanced to obtain a word sequence to be processed;

[0144] Based on the to-be-processed word sequence, obtaining a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence;

[0145] determining a target word from the first words based on the first importance measure;

[0146] Deleting the target word from the text sentence to be enhanced to obtain first counterexample data;

[0147] The target word is replaced with a word having opposite sentiment to the target word to obtain second counterexample data.

[0148] It can be seen that in Figure 6 In the electronic device shown, a text sentence to be enhanced is obtained; the text sentence to be enhanced is sampled to obtain a sequence of words to be processed; based on the sequence of words to be processed, a first importance measure of the first word in the text sentence to be enhanced for the sentiment classification of the text sentence to be enhanced is obtained; based on the first importance measure, a target word is determined from the first word; the target word is deleted from the text sentence to be enhanced to obtain first counter-example data; the target word is replaced with a word with opposite sentiment to the target word to obtain second counter-example data. In this way, by calculating the importance measure (i.e., the first importance measure) of the word for the sentiment classification of the original sentence (i.e., the text sentence to be enhanced), the most important word indicated by the importance measure is used as the causal term (i.e., the target word) that affects the sentiment classification of the sentence, and then the causal term is deleted and replaced to obtain two counter-example data, thereby achieving the purpose of enhancement. Since the contextual causal terms are analyzed in a self-supervised manner without the need to collect and introduce high-quality manual annotations, it is beneficial to reduce the cost of data enhancement and the overall time consumption of data enhancement.

[0149] In another embodiment, the processor 601 performs the step of obtaining, based on the to-be-processed word sequence, a first importance measure of the first word in the to-be-enhanced text sentence for the sentiment classification of the to-be-enhanced text sentence, including:

[0150] Shielding the second word in the to-be-processed word sequence to obtain a shielded word sequence, and replacing the token of the second word with a token of any word to obtain a replaced word sequence, wherein the first word includes the second word;

[0151] The first importance metric is calculated based on the masked word sequence and the replaced word sequence.

[0152] In another embodiment, the processor 601 performs the step of calculating the first importance metric based on the masked word sequence and the replaced word sequence, including:

[0153] Inputting the masked word sequence into a masked language model so that the masked language model processes the masked word sequence to obtain a first prediction result of the second word;

[0154] Inputting the replaced word sequence into a masked language model so that the masked language model processes the replaced word sequence to obtain a second prediction result for the second word;

[0155] The first importance metric is calculated based on the first prediction result and the second prediction result.

[0156] In another embodiment, the processor 601 performs the step of determining a target word from the first word based on the first importance metric, including:

[0157] Sorting the first words in descending order according to the first importance metric to obtain a sorted first word sequence;

[0158] The first word in the first word sequence is determined as the target word.

[0159] In another embodiment, the processor 601 performs the step of replacing the target word with a word having opposite sentiment to the target word to obtain second counterexample data, including:

[0160] Generating a set of candidate words having opposite sentiments to the target word;

[0161] Determine a replacement word for the target word from the candidate word set;

[0162] The target word is replaced with the replacement word to obtain the second counterexample data.

[0163] In another embodiment, the processor 601 performs the step of determining a replacement word for the target word from the candidate word set, including:

[0164] Replacing the target word with a candidate word in the candidate word set to obtain a candidate counterexample sentence;

[0165] Calculating a second importance measure of the candidate word for the sentiment classification of the candidate counterexample sentence;

[0166] Sorting the candidate words in descending order according to the second importance metric to obtain a sorted candidate word sequence;

[0167] The first word in the candidate word sequence is determined as the replacement word.

[0168] Exemplarily, the electronic device includes but is not limited to a processor 601, an input device 602, an output device 603, and a memory 604. It may also include a memory, a power supply, an application client module, etc. The input device 602 may be a keyboard, a touch screen, a radio frequency receiver, etc., and the output device 603 may be a speaker, a display, a radio frequency transmitter, etc. It will be understood by those skilled in the art that the schematic diagram is only an example of an electronic device and does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or different components.

[0169] It should be noted that since the processor 601 of the electronic device implements the steps in the above-mentioned self-supervision-based data enhancement method when executing a computer program, the embodiments of the above-mentioned self-supervision-based data enhancement method are all applicable to the electronic device and can achieve the same or similar beneficial effects.

[0170] The embodiment of the present application also provides a computer storage medium (Memory), which is a memory device in an electronic device for storing programs and data. It is understandable that the computer storage medium here can include both the built-in storage medium in the terminal and the extended storage medium supported by the terminal. The computer storage medium provides a storage space that stores the operating system of the terminal. In addition, one or more instructions suitable for being loaded and executed by the processor 601 are also stored in the storage space, and these instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk memory; optionally, it can also be at least one computer storage medium located away from the aforementioned processor 601. In one embodiment, the processor 601 can load and execute one or more computer programs stored in the computer storage medium to implement the corresponding steps of the above-mentioned data enhancement method based on self-supervision.

[0171] Exemplarily, the computer program of the computer storage medium includes computer program code, which may be in source code form, object code form, executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc.

[0172] It should be noted that, since the computer program of the computer storage medium implements the steps in the above-mentioned self-supervision-based data enhancement method when executed by the processor, all embodiments of the above-mentioned self-supervision-based data enhancement method are applicable to the computer storage medium and can achieve the same or similar beneficial effects.

[0173] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A data enhancement method based on self-supervision, characterized in that: The method comprises: Get the text sentence to be enhanced; Sampling the text sentence to be enhanced to obtain a word sequence to be processed; Based on the to-be-processed word sequence, obtaining a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence; determining a target word from the first words based on the first importance measure; Deleting the target word from the text sentence to be enhanced to obtain first counterexample data; Replacing the target word with a word having opposite sentiment to the target word to obtain second counterexample data; The step of obtaining, based on the to-be-processed word sequence, a first importance measure of a first word in the to-be-enhanced text sentence for sentiment classification of the to-be-enhanced text sentence comprises: Shielding the second word in the to-be-processed word sequence to obtain a shielded word sequence, and replacing the token of the second word with a token of any word to obtain a replaced word sequence, wherein the first word includes the second word; Calculating the first importance measure based on the masked word sequence and the replaced word sequence; The calculating the first importance metric based on the masked word sequence and the replaced word sequence includes: Inputting the masked word sequence into a masked language model so that the masked language model processes the masked word sequence to obtain a first prediction result of the second word; Inputting the replaced word sequence into a masked language model so that the masked language model processes the replaced word sequence to obtain a second prediction result for the second word; The first importance metric is calculated by the following formula according to the first prediction result and the second prediction result; ; in, Representing words The first importance measure of Replace the word The sequence of words after Replace the word The second prediction result of the post-MLM model, Indicates blocking words The sequence of words after Indicates blocking words The first prediction results of the post-MLM model, Represents the sequence of words to be processed after sampling the enhanced text sentence. Indicates that a phrase is masked from the sequence of words to be processed Operation, Express expectations.

2. The method according to claim 1, characterized in that Determining a target word from the first word based on the first importance metric includes: Sorting the first words in descending order according to the first importance metric to obtain a sorted first word sequence; The first word in the first word sequence is determined as the target word.

3. The method according to claim 1, characterized in that The step of replacing the target word with a word having opposite sentiment to the target word to obtain second counterexample data includes: Generating a set of candidate words having opposite sentiments to the target word; Determine a replacement word for the target word from the candidate word set; The target word is replaced with the replacement word to obtain the second counterexample data.

4. The method according to claim 3, characterized in that Determining a replacement word for the target word from the candidate word set includes: Replacing the target word with a candidate word in the candidate word set to obtain a candidate counterexample sentence; Calculating a second importance measure of the candidate word for the sentiment classification of the candidate counterexample sentence; Sorting the candidate words in descending order according to the second importance metric to obtain a sorted candidate word sequence; The first word in the candidate word sequence is determined as the replacement word.

5. A data enhancement device based on self-supervision, characterized in that: The device comprises an acquisition unit and a processing unit; The acquisition unit is used to acquire the text sentence to be enhanced; The processing unit is used to sample the text sentence to be enhanced to obtain a word sequence to be processed; The processing unit is used to obtain a first importance measure of a first word in the text sentence to be enhanced for the sentiment classification of the text sentence to be enhanced based on the word sequence to be processed; The processing unit is configured to determine a target word from the first words based on the first importance measure; The processing unit is used to delete the target word from the text sentence to be enhanced to obtain first counterexample data; The processing unit is used to replace the target word with a word having opposite sentiment to the target word to obtain second counterexample data; In terms of obtaining a first importance measure of a first word in the text sentence to be enhanced for sentiment classification of the text sentence to be enhanced based on the sequence of words to be processed, the processing unit is specifically configured to: Shielding the second word in the to-be-processed word sequence to obtain a shielded word sequence, and replacing the token of the second word with a token of any word to obtain a replaced word sequence, wherein the first word includes the second word; Calculating the first importance measure based on the masked word sequence and the replaced word sequence; In terms of calculating the first importance metric based on the masked word sequence and the replaced word sequence, the processing unit is specifically configured to: Inputting the masked word sequence into a masked language model so that the masked language model processes the masked word sequence to obtain a first prediction result of the second word; Inputting the replaced word sequence into a masked language model so that the masked language model processes the replaced word sequence to obtain a second prediction result for the second word; The first importance metric is calculated by the following formula according to the first prediction result and the second prediction result; ; in, Representing words The first importance measure of Replace the word The sequence of words after Replace the word The second prediction result of the post-MLM model, Indicates blocking words The sequence of words after Indicates blocking words The first prediction results of the post-MLM model, Represents the sequence of words to be processed after sampling the enhanced text sentence. Indicates that a phrase is masked from the sequence of words to be processed Operation, Express expectations.

6. An electronic device, comprising an input device and an output device, characterized in that: Also includes: a processor adapted to implement one or more computer programs; as well as, A memory storing one or more computer programs, wherein the one or more computer programs are suitable for being loaded by the processor and executing the method according to any one of claims 1 to 4.

7. A computer storage medium, characterized in that: The computer storage medium stores one or more computer programs, and the one or more computer programs are suitable for being loaded by a processor and executing the method according to any one of claims 1 to 4.