Text sample expansion method, classification method, device, equipment and medium

By using the binary classification model to calculate character attention values ​​and generate expanded samples in unlabeled or less labeled text data, the problem of difficulty in expanding sample sets is solved, efficient text classification is achieved, and manual labeling costs are reduced.

CN114780731BActive Publication Date: 2025-04-11PING AN TECH (SHENZHEN) CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210510699.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-11
Publication Date
2025-04-11
Estimated Expiration
2042-05-11

AI Technical Summary

Technical Problem

In the classification problem of unlabeled or less labeled text data, it is difficult to effectively expand the sample set, resulting in poor effect of the trained classifier, and high manual labeling costs and slow speed.

Method used

By initially filtering out the initial labeled sample set in the text library to be classified, the binary classification model is used to calculate the attention value of the characters, and randomly rewrite the characters with high attention value, generate the expanded positive and negative samples, and add it to the initial sample set to form the expanded sample set.

Benefits of technology

Effectively expanding the sample set reduces the requirements for the diversity of labeled sample sets, reduces the demand for manual annotation, improves the training effect of the classifier, and saves resource consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114780731B_ABST
    Figure CN114780731B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of text data processing, and discloses a text sample expansion method, classification method, device, equipment and medium; the text sample expansion method comprises: preliminarily screening out a number of samples in a text library to be classified to obtain an initial set of labeled samples; processing the initial set of labeled samples by a targeted data enhancement method to obtain an expanded set of samples. The present invention can effectively expand the sample set without manual labeling through rules and targeted data enhancement methods; compared with the Co-train framework, the present invention has lower requirements for the diversity of the labeled sample set, and because only one-step training is used, the phenomenon of continuous accumulation of noise in the automatically labeled samples will not occur.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of text data processing, and in particular relates to a text sample expansion method, classification method, device, equipment and medium. Background Art

[0002] Text classification is a technology that divides text into several groups for certain technical needs. In our lives and work, many things can be converted into a classification problem to solve. The same is true in the field of natural language processing. A large number of tasks can be solved by text classification.

[0003] For the classification problem of unlabeled or sparsely labeled text data, existing methods are basically based on the Co-train framework. The main idea is to target two sample sets: labeled and unlabeled. In each cycle, two different classifiers are trained from the Labeled data (for positive samples and negative samples respectively), and the Unlabeled data is classified using the two classifiers. The data with high credibility is added to the Labeled data, and the cycle is repeated until there is no data in the Unlabeled data or the maximum number of cycles is reached.

[0004] This type of method has the following main shortcomings:

[0005] The Co-train framework has very strict requirements on the diversity of the labeled sample set (Labeled set) as the initial training data. The labeled sample set should be obtained by random sampling of the total sample set. If there is a sampling bias when obtaining the labeled sample set, the trained classifier is often distorted; as the training continues, the noise in the automatically labeled samples continues to accumulate, and its negative effect will become increasingly greater; manual labeling is time-consuming and costly, and the cost of obtaining labeled samples is too high and the speed is slow. Under such circumstances, it is difficult to train a good classifier for a large amount of unlabeled text data with a small amount of annotations. Summary of the invention

[0006] The purpose of the present invention is to provide a text sample expansion method, classification method, device, equipment and medium to solve the technical problem of time-consuming and laborious manual labeling of samples in the prior art, so as to obtain more labeled positive and negative samples.

[0007] In order to achieve the above object, the present invention adopts the following technical solution:

[0008] In a first aspect, the present invention provides a text sample expansion method, comprising:

[0009] Preliminarily select a number of samples from the text library to be classified to obtain an initial set of labeled samples;

[0010] The initial labeled sample set is processed by a binary classification model, the normalized attention value of each character in each sentence of the initial labeled sample set is calculated, and the characters whose normalized attention value is higher than a preset threshold are randomly rewritten to obtain a plurality of rewritten sentences; the rewritten sentences are input into a binary classification model of a negative sentence pattern to obtain a plurality of expanded positive samples and a plurality of expanded negative samples; the plurality of expanded positive samples and the plurality of expanded negative samples are added to the initial labeled sample set to form an expanded sample set.

[0011] A further improvement of the present invention is that: in the step of preliminarily screening out a number of samples in the text library to be classified to obtain an initial set of labeled samples: preliminarily screening out a number of samples in the text library to be classified by considering sentences as initial positive samples; by matching the disease name table, all texts in the text library to be classified that can match the disease names in the disease name table are screened out as initial negative samples; the initial positive samples and the initial negative samples constitute the initial set of labeled samples; wherein the format of the considered sentence includes: considered is X; X is the name of the disease.

[0012] A further improvement of the present invention is that: in the step of preliminarily screening out a number of samples in the text library to be classified to obtain an initial set of labeled samples: first, the text library to be classified is screened to obtain the number of initial positive samples by considering the sentence pattern; and the number of initial positive samples screened out by considering the sentence pattern are eliminated from the text library to be classified; and then, a plurality of the initial negative samples are screened in the text library to be classified from which the number of initial positive samples are eliminated by matching the disease name table.

[0013] A further improvement of the present invention is that in the step of processing the initial set of labeled samples through a binary classification model, the initial set of labeled samples is specifically processed through a gated recurrent unit based on an attention mechanism.

[0014] A further improvement of the present invention is that in the step of randomly rewriting characters whose normalized attention values ​​are higher than a preset threshold, characters whose normalized attention values ​​are higher than a preset threshold are rewritten using a multilingual version of the T5 model.

[0015] A further improvement of the present invention is that in the step of randomly rewriting the characters whose normalized attention values ​​are higher than the preset threshold, the characters whose normalized attention values ​​are higher than the preset threshold include "consider" and "disease name"; the word "consider" is rewritten with synonyms or antonyms, and the disease name is rewritten with other disease names in the preset disease name table.

[0016] In a second aspect, the present invention provides a text classification method, comprising:

[0017] Acquire a sample set; the sample set is an expanded sample set obtained by using the text sample expansion method;

[0018] The obtained sample set is used to train a binary classification model to obtain a trained binary classification model;

[0019] The text in the to-be-classified text library is input into the trained binary classification model to obtain the classification result of the to-be-classified text library.

[0020] A further improvement of the present invention is that the binary classification model is a gated recurrent unit based on an attention mechanism.

[0021] In a third aspect, the present invention provides a text sample expansion device, comprising:

[0022] The initial screening module is used to preliminarily screen out a number of samples from the text library to be classified to obtain an initial set of labeled samples;

[0023] The data enhancement module is used to process the initial labeled sample set through a binary classification model, calculate the normalized attention value of each character in each sentence of the initial labeled sample set, and randomly rewrite the characters whose normalized attention value is higher than a preset threshold to obtain a plurality of rewritten sentences; input the rewritten sentences into the binary classification model of negative sentences to obtain a plurality of expanded positive samples and a plurality of expanded negative samples; the plurality of expanded positive samples and the plurality of expanded negative samples are added to the initial labeled sample set to form an expanded sample set.

[0024] A further improvement of the present invention is that: in the step of obtaining an initial set of labeled samples by preliminarily screening out a number of samples in the text library to be classified by the initial screening module, a number of samples are preliminarily screened out in the text library to be classified by considering sentences as initial positive samples; by matching the disease name table, all texts in the text library to be classified that can match the disease names in the disease name table are screened out as initial negative samples; the initial positive samples and the initial negative samples constitute the initial set of labeled samples; wherein the format of the considered sentence includes: considered is X; X is the name of the disease.

[0025] A further improvement of the present invention is that: in the data enhancement module, the binary classification model is a gated recurrent unit based on an attention mechanism; the data enhancement module randomly rewrites characters whose normalized attention values ​​are higher than a preset threshold through a multilingual version of the T5 model.

[0026] A further improvement of the present invention is that in the data enhancement module, the characters above the threshold include "consider" and "disease name"; the word "consider" is rewritten with a synonym or a synonym, and the disease name is rewritten with other disease names in a preset disease name table.

[0027] In a fourth aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the processor is used to execute a computer program stored in the memory to implement the text sample expansion method.

[0028] In a fifth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the text sample expansion method is implemented.

[0029] Compared with the prior art, the present invention adopts the following technical solutions:

[0030] The present invention provides a sample expansion method, classification method, device, equipment and medium for text, which can effectively expand the sample set without manual labeling through rules and targeted data enhancement methods; in terms of effect, compared with the Co-train framework, the rule + targeted data enhancement method based on the present invention has lower requirements for the diversity of labeled sample sets. Therefore, when the labeled sample set is generated by rules and there is a sampling bias, the performance of the rule + targeted data enhancement method is significantly better than the Co-train framework. And because only one-step training is used, the phenomenon of continuous accumulation of noise in the automatically labeled samples will not occur.

[0031] In terms of resource consumption, due to the use of rules + targeted data enhancement methods, no labeled data is required during training, which greatly saves human resources and project time. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0033] Figure 1 A schematic diagram of a flow chart of a text sample expansion method of the present invention;

[0034] Figure 2 A schematic diagram of the structure of a text sample expansion device of the present invention;

[0035] Figure 3 The present invention is a structural block diagram of an electronic device. DETAILED DESCRIPTION

[0036] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other without conflict.

[0037] The following detailed description is an exemplary description, which is intended to provide further detailed description of the present invention. Unless otherwise specified, all technical terms used in the present invention have the same meaning as those generally understood by those skilled in the art to which the present invention belongs. The terms used in the present invention are only for describing specific embodiments, and are not intended to limit the exemplary embodiments according to the present invention.

[0038] Example 1

[0039] See also Figure 1 As shown, the present invention provides a sample expansion method of text based on rules and data enhancement, comprising:

[0040] S1. Preliminarily select a number of positive samples and negative samples from the text library to be classified through rules;

[0041] In this embodiment, the rules include rule one and rule two;

[0042] Rule 1: Screening rules based on special sentence patterns (for example: considering indigestion (disease), considering cold, considering acute upper respiratory tract infection, considering bronchitis, etc.); in a specific embodiment, the special sentence pattern may be a consideration sentence pattern; the format of the consideration sentence pattern includes: considering X; X is the name of the disease;

[0043] Rule 2: Screening rules based on matching of disease name table (for example: indigestion (disease name), upper respiratory tract infection, bronchitis, etc.); in a specific embodiment, Rule 2 can be: through matching of disease name table, all texts in the text library to be classified that can match the disease name in the disease name table are screened out as samples.

[0044] In the specific implementation, firstly, a number of initial positive samples are screened in the text library to be classified by rule one; and the initial positive samples screened by rule one are eliminated from the text library to be classified; and then a number of initial negative samples are screened in the text library to be classified after the initial positive samples are eliminated by rule two.

[0045] For rule one, its accuracy is very high, but its recall rate is very low, and the recalled sentences are not rich enough (only the considered sentences are included). For rule two, its recall rate is very high, but its accuracy is very low (there are mismatches). Because rule one has a high accuracy rate, the samples it judges as positive examples have a high credibility, while rule two has a high recall rate, so the samples it judges as negative examples have a high credibility. Therefore, the present invention uses the initial positive examples identified by rule one and the initial negative examples identified by rule two as the initial labeled sample set.

[0046] However, the labeled sample set is given by rules, the positive samples only contain the considered sentences, and the negative samples do not contain the considered sentences. The sampling bias is very large, so the effect is not good when the Co-train framework is used for training. For this reason, the present invention further uses a data enhancement method.

[0047] S2. Enriching positive and negative samples through targeted data enhancement methods

[0048] The initial labeled sample set screened out in step S1 is processed by the binary classification model of Attention+GRU (GRU (Gated Recurrent Unit) is a gated recurrent unit, and GRU is a type of RNN (recurrent neural network); Attention-GRU is a gated recurrent unit based on the Attention mechanism (attention mechanism), and the deep learning model based on the attention mechanism can extract important features in the text by training word vectors to identify the importance of words in the text), and the normalized attention value (attention value) of each character in each sentence of text is calculated, and a threshold is set for the normalized attention value, and the characters in each sentence of text whose normalized attention value is higher than the threshold are masked, and the characters masked by the mask are rewritten by the mT5 model; a plurality of rewritten sentences are obtained; the rewritten sentences are input into the binary classification model of the negative sentence pattern to obtain a plurality of expanded positive samples and a plurality of expanded negative samples; the plurality of positive samples and the plurality of negative samples constitute the expanded sample set.

[0049] The basic assumption of this method is that when using an attention-related model to process biased data (such as data generated by the rules of step S1), the attention value of the characters that cause the deviation will be very high, so by setting a threshold on the normalized attention value, the characters that cause the deviation are extracted and rewritten through the masked language model to eliminate the sampling bias. Since this method can mainly target the characters that cause the deviation, this method is called targeted data enhancement.

[0050] An example is the processed text:

[0051] At present, I think it is a case of indigestion;

[0052] The characters in this sentence whose normalized attentiveness value exceeds 0.1 are: consider, indigestion;

[0053] The data after masking is:

[0054] at present <mask>Yes a little <mask>situation;

[0055] The mT5 model is used to rewrite the content of the mask to obtain positive samples, and negative samples are obtained through a negative sentence:

[0056] Positive examples obtained by data enhancement: Negative examples obtained by data augmentation: It is possible that there is some indigestion. I'm not having any indigestion right now. I'm having some indigestion right now. I don't think it's a case of indigestion. I feel like I have some indigestion right now. Maybe it's not a case of indigestion Currently, it indicates a bit of indigestion. I'm thinking you may have indigestion. I'm currently thinking of some airway hyperresponsiveness I currently have periodontitis. I think it's caused by indigestion.

[0057] The present invention improves the richness of data through targeted data enhancement, and uses the data after data enhancement to train the wordattention+GRU binary classification model. The accuracy rate on the test set reaches 98.5%; 3 paragraphs out of 100 manually annotated dialogue texts are misjudged, and 2 paragraphs out of 151 GPT-generated dialogue texts are misjudged. The effect is greatly improved compared to the results of the Co-train framework. The model without data enhancement misjudged 14 paragraphs out of 100 manually annotated dialogue texts and 11 paragraphs out of 151 GPT-generated dialogue texts. It can be seen that data enhancement can effectively improve the training effect of the model.

[0058] In terms of effectiveness, compared with the Co-train framework, the semi-supervised + data enhancement method has lower requirements for the diversity of the labeled sample set. Therefore, when the labeled sample set is generated by rules and there is sampling bias, the performance of the semi-supervised + targeted data enhancement method is significantly better than the Co-train framework. And because only one step of training is used, the phenomenon of noise accumulation in the automatically labeled samples will not occur.

[0059] In terms of resource consumption, due to the use of rule + data enhancement method, no labeled data is required during training, which greatly saves human resources and project time. This method is particularly effective when a small amount of labeled data is sampling biased.

[0060] Example 2

[0061] The present invention provides a text sample expansion method, comprising:

[0062] S1. Preliminarily select a number of positive samples from the text library to be classified through rules;

[0063] In this embodiment, the rules are: screening rules based on matching of disease name tables (for example: indigestion (disease name), upper respiratory tract infection, bronchitis, etc.);

[0064] The sample accuracy after the rule screening is very high, but the recall rate is very low, and the recalled sentences are not rich enough (only the considered sentences are included). The present invention uses the positive examples identified by the rule as the initial labeled sample set.

[0065] However, the labeled sample set is given by rules, and the positive samples only contain the considered sentences, so the sampling bias is very large, so the effect is not good when the Co-train framework is used for training. For this reason, the present invention further uses a data enhancement method.

[0066] S2. Enriching positive and negative samples through targeted data enhancement methods

[0067] The initial labeled sample set screened out in step S1 is processed by the binary classification model of Attention+GRU (GRU (Gated Recurrent Unit) is a gated recurrent unit, and GRU is a type of RNN (recurrent neural network); Attention-GRU is a gated recurrent unit based on the Attention mechanism (attention mechanism), and the deep learning model based on the attention mechanism can extract important features in the text by training word vectors to identify the importance of words in the text), and the normalized attention value of each character in each sentence is calculated, and a threshold is set for the normalized attention value, characters above the threshold are extracted and masked, and the characters masked by the mask are rewritten by the mT5 model; a plurality of rewritten sentences are obtained; the rewritten sentences are input into the binary classification model of the negative sentence pattern to obtain a plurality of positive samples and a plurality of negative samples; the plurality of positive samples and the plurality of negative samples constitute the expanded sample set.

[0068] The basic assumption of this method is that when using an attention-related model to process biased data (such as data generated by the rules of step S1), the attention value of the characters that cause the deviation will be very high, so by setting a threshold on the normalized attention value, the characters that cause the deviation are extracted and rewritten through the masked language model to eliminate the sampling bias. Since this method can mainly target the characters that cause the deviation, this method is called targeted data enhancement.

[0069] An example is the processed text:

[0070] Comprehensive consideration is upper respiratory tract infection;

[0071] The characters in this sentence whose normalized attentiveness value exceeds 0.1 are: consider, upper respiratory tract infection;

[0072] The data after masking is:

[0073] comprehensive <mask>yes <mask>;

[0074] The mT5 model is used to rewrite the content of the mask to obtain positive samples, and negative samples are obtained through a negative sentence:

[0075]

[0076]

[0077] Example 3

[0078] The present invention provides a text classification method, comprising:

[0079] Acquire a sample set; the sample set is an expanded sample set obtained by using the text sample expansion method described in Example 1 or 2;

[0080] The obtained sample set is used to train a binary classification model; the text in the text library to be classified is input into the trained binary classification model to obtain the classification result of the text library to be classified;

[0081] In this embodiment, the binary classification model is a gated recurrent unit based on an attention mechanism, a Co-train framework or GPT.

[0082] Example 4

[0083] See also Figure 2 As shown, the present invention provides a text sample expansion device, comprising:

[0084] The initial screening module is used to preliminarily screen out a number of samples from the text library to be classified through rules to obtain an initial set of labeled samples;

[0085] The data enhancement module is used to process the initial labeled sample set through a targeted data enhancement method to obtain an expanded sample set.

[0086] In a specific implementation, the targeted data enhancement method includes: processing the initial labeled sample set through a binary classification model, calculating the normalized attention value of each character in each sentence of the initial labeled sample set, and randomly rewriting the characters whose normalized attention value is higher than a preset threshold to obtain multiple rewritten sentences; inputting the rewritten sentences into a binary classification model of negative sentences to obtain multiple expanded positive samples and multiple expanded negative samples; the multiple expanded positive samples and multiple expanded negative samples are added to the initial labeled sample set to form an expanded sample set.

[0087] In a specific implementation, the rules described in the initial screening module include Rule 1 and Rule 2;

[0088] Rule 1: Screening rules based on special sentence patterns (for example: considering indigestion (disease), considering cold, considering acute upper respiratory tract infection, considering bronchitis, etc.); in a specific embodiment, the special sentence pattern may be a consideration sentence pattern; the format of the consideration sentence pattern includes: considering X; X is the name of the disease;

[0089] Rule 2: Screening rules based on matching of disease name table (for example: indigestion (disease name), upper respiratory tract infection, bronchitis, etc.); in a specific embodiment, Rule 2 can be: through matching of disease name table, all texts in the text library to be classified that can match the disease name in the disease name table are screened out as samples.

[0090] For rule one, its accuracy is very high, but its recall rate is very low, and the recalled sentences are not rich enough (only the considered sentences are included). For rule two, its recall rate is very high, but its accuracy is very low (there are mismatches). Because rule one has a high accuracy rate, the samples it judges as positive examples have a high credibility, while rule two has a high recall rate, so the samples it judges as negative examples have a high credibility. Therefore, the present invention uses the initial positive examples identified by rule one and the initial negative examples identified by rule two as the initial labeled sample set.

[0091] However, the labeled sample set is given by rules, the positive samples only contain the considered sentences, and the negative samples do not contain the considered sentences. The sampling bias is very large, so the effect is not good when the Co-train framework is used for training. For this reason, the text sample expansion device of the present invention further performs data enhancement through a data enhancement module.

[0092] In the specific implementation, the data enhancement module processes the initial labeled sample set screened by the preliminary screening module through the Attention+GRU binary classification model (GRU (Gated Recurrent Unit) is a gated recurrent unit, GRU is a type of RNN (recurrent neural network); Attention-GRU is a gated recurrent unit based on the Attention mechanism (attention mechanism), and the deep learning model based on the attention mechanism can extract important features in the text by training word vectors to identify the importance of words in the text), and calculates the normalized attention value of each word in each sentence, and sets a threshold for the normalized attention value, extracts characters above the threshold and masks them, and rewrites the characters masked by the mT5 model;

[0093] In the specific implementation, the basic assumption is that when using the attention-related model to process biased data (such as data generated by the rules of step S1), the attention value of the characters that produce the deviation will be very high, so the characters that produce the deviation are extracted by setting a threshold on the normalized attention value, and rewritten through the Masked language model to eliminate the sampling bias. Since this method can mainly target the characters that produce the deviation, this method is called targeted data enhancement.

[0094] An example is the processed text:

[0095] At present, I think it is a case of indigestion;

[0096] The characters in this sentence whose normalized attentiveness value exceeds 0.1 are: consider, indigestion;

[0097] The data after masking is:

[0098] at present <mask>Yes a little <mask>situation;

[0099] The mT5 model is used to rewrite the content of the mask to obtain positive samples, and negative samples are obtained through a negative sentence:

[0100] Positive examples obtained by data enhancement: Negative examples obtained by data augmentation: It is possible that there is some indigestion. I'm not having any indigestion right now. I'm having some indigestion right now. I don't think it's a case of indigestion. I feel like I have some indigestion right now. Maybe it's not a case of indigestion Currently, it indicates a bit of indigestion. I'm thinking you may have indigestion. I'm currently thinking of some airway hyperresponsiveness I currently have periodontitis. I think it's caused by indigestion.

[0101] Example 5

[0102] See also Figure 3 As shown, the present invention also provides an electronic device 100 for a text sample expansion method; the electronic device 100 includes a memory 101, at least one processor 102, a computer program 103 stored in the memory 101 and executable on the at least one processor 102, and at least one communication bus 104.

[0103] The memory 101 can be used to store the computer program 103. The processor 102 implements the method steps of the text sample expansion method described in any one of embodiments 1 to 2 by running or executing the computer program stored in the memory 101 and calling the data stored in the memory 101. The memory 101 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.); the data storage area can store data (such as audio data) created according to the use of the electronic device 100. In addition, the memory 101 can include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices.

[0104] The at least one processor 102 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 102 may be a microprocessor or any conventional processor, etc. The processor 102 is the control center of the electronic device 100, and uses various interfaces and lines to connect various parts of the entire electronic device 100.

[0105] The memory 101 in the electronic device 100 stores a plurality of instructions to implement a text sample expansion method, and the processor 102 can execute the plurality of instructions to implement:

[0106] Preliminarily select a number of samples from the text library to be classified using rules to obtain an initial set of labeled samples;

[0107] Processing the initial labeled sample set by a targeted data enhancement method to obtain an expanded sample set;

[0108] The targeted data enhancement method includes: processing the initial labeled sample set through a binary classification model, calculating the normalized attention value of each character in each sentence of the initial labeled sample set, and randomly rewriting the characters whose normalized attention value is higher than a preset threshold to obtain a plurality of rewritten sentences; inputting the rewritten sentences into a binary classification model of a negative sentence pattern to obtain a plurality of expanded positive samples and a plurality of expanded negative samples; and adding the plurality of expanded positive samples and the plurality of expanded negative samples to the initial labeled sample set to form an expanded sample set.

[0109] In the specific implementation, the relevant steps include:

[0110] S1. Preliminarily select a number of positive samples and negative samples from the text library to be classified through rules;

[0111] The rules include rule one and rule two;

[0112] Rule 1: Screening rules based on special sentence patterns (for example: considering indigestion (disease), considering cold, considering acute upper respiratory tract infection, considering bronchitis, etc.); in a specific embodiment, the special sentence pattern may be a consideration sentence pattern; the format of the consideration sentence pattern includes: considering X; X is the name of the disease;

[0113] Rule 2: Screening rules based on matching of disease name table (for example: indigestion (disease name), upper respiratory tract infection, bronchitis, etc.); in a specific embodiment, Rule 2 can be: through matching of disease name table, all texts in the text library to be classified that can match the disease name in the disease name table are screened out as samples.

[0114] For rule one, its accuracy is very high, but its recall rate is very low, and the recalled sentences are not rich enough (only the considered sentences are included). For rule two, its recall rate is very high, but its accuracy is very low (there are mismatches). Because rule one has a high accuracy rate, the samples it judges as positive examples have a high credibility, while rule two has a high recall rate, so the samples it judges as negative examples have a high credibility. Therefore, the present invention uses the initial positive examples identified by rule one and the initial negative examples identified by rule two as the initial labeled sample set.

[0115] However, the labeled sample set is given by rules, the positive samples only contain the considered sentences, and the negative samples do not contain the considered sentences. The sampling bias is very large, so the effect is not good when the Co-train framework is used for training. For this reason, the present invention further uses a data enhancement method.

[0116] S2. Enriching positive and negative samples through targeted data enhancement methods

[0117] The initial labeled sample set screened out in step S1 is processed by the Attention+GRU binary classification model (GRU (Gated Recurrent Unit) is a gated recurrent unit, which is a type of RNN (recurrent neural network); Attention-GRU is a gated recurrent unit based on the Attention mechanism (attention mechanism), and the deep learning model based on the attention mechanism can extract important features in the text by training word vectors to identify the importance of words in the text), and the normalized attention value of each word in each sentence is calculated, and a threshold is set for the normalized attention value, and characters above the threshold are extracted and masked, and the characters masked by the mask are rewritten by the mT5 model;

[0118] The basic assumption of this method is that when using an attention-related model to process biased data (such as data generated by the rules of step S1), the attention value of the characters that cause the deviation will be very high, so by setting a threshold on the normalized attention value, the characters that cause the deviation are extracted and rewritten through the masked language model to eliminate the sampling bias. Since this method can mainly target the characters that cause the deviation, this method is called targeted data enhancement.

[0119] An example is the processed text:

[0120] At present, I think it is a case of indigestion;

[0121] The characters in this sentence whose normalized attentiveness value exceeds 0.1 are: consider, indigestion;

[0122] The data after masking is:

[0123] at present <mask>Yes a little <mask>situation;

[0124] The mT5 model is used to rewrite the content of the mask to obtain positive samples, and negative samples are obtained through a negative sentence:

[0125] Positive examples obtained by data enhancement: Negative examples obtained by data augmentation: It is possible that there is some indigestion. I'm not having any indigestion right now. I'm having some indigestion right now. I don't think it's a case of indigestion. I feel like I have some indigestion right now. Maybe it's not a case of indigestion Currently, it indicates a bit of indigestion. I'm thinking you may have indigestion. I'm currently thinking of some airway hyperresponsiveness I currently have periodontitis. I think it's caused by indigestion.

[0126] Example 6

[0127] If the module / unit integrated in the electronic device 100 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device that can carry the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory and read-only memory (ROM, Read-Only Memory).

[0128] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention 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.

[0129] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. 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.

[0130] 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.

[0131] 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 A function specified in one or more boxes.

[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents. Any modification or equivalent replacement that does not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.< / mask> < / mask> < / mask> < / mask> < / mask> < / mask> < / mask> < / mask>

Claims

1. A text sample expansion method, characterized in that: include: Preliminarily select a number of samples from the text library to be classified to obtain an initial set of labeled samples; The initial labeled sample set is processed by a binary classification model, the normalized attention value of each character in each sentence of the initial labeled sample set is calculated, and the characters whose normalized attention value is higher than a preset threshold are randomly rewritten to obtain a plurality of rewritten sentences; the rewritten sentences are input into a binary classification model of a negative sentence pattern to obtain a plurality of expanded positive samples and a plurality of expanded negative samples; the plurality of expanded positive samples and the plurality of expanded negative samples are added to the initial labeled sample set to form an expanded sample set; In the step of preliminarily screening out a number of samples in the text library to be classified to obtain an initial set of labeled samples: by considering sentence patterns, preliminarily screening out a number of samples in the text library to be classified as initial positive samples; by matching the disease name table, screening out all texts in the text library to be classified that can match the disease names in the disease name table as initial negative samples; the initial positive samples and the initial negative samples constitute the initial set of labeled samples; The format of the consideration sentence includes: consideration is X; X is the name of the disease; In the step of randomly rewriting the characters whose normalized attention values ​​are higher than the preset threshold, the characters whose normalized attention values ​​are higher than the preset threshold include "consider" and "disease name"; the word "consider" is rewritten with synonyms or antonyms, and the disease name is rewritten with other disease names in the preset disease name table.

2. The text sample expansion method according to claim 1, characterized in that: In the step of preliminarily screening out a number of samples from the to-be-classified text library to obtain an initial set of labeled samples: First, a plurality of initial positive samples are obtained by screening in the text library to be classified by considering the sentence pattern; and the plurality of initial positive samples screened by considering the sentence pattern are eliminated from the text library to be classified; Then, a plurality of the initial negative samples are obtained by screening in the to-be-classified text library after excluding the several initial positive samples through matching with the disease name table.

3. The text sample expansion method according to claim 1, characterized in that: In the step of randomly rewriting characters whose normalized attention values ​​are higher than a preset threshold, characters whose normalized attention values ​​are higher than a preset threshold are rewritten using a multilingual version of the T5 model.

4. A text classification method, characterized in that: include: Acquire a sample set; the sample set is an expanded sample set obtained by using the text sample expansion method according to any one of claims 1 to 3; The obtained sample set is used to train a binary classification model to obtain a trained binary classification model; The text in the to-be-classified text library is input into the trained binary classification model to obtain the classification result of the to-be-classified text library.

5. A text sample expansion device, characterized in that: include: The initial screening module is used to preliminarily screen out a number of samples from the text library to be classified to obtain an initial set of labeled samples; A data enhancement module, used to process the initial labeled sample set through a binary classification model, calculate the normalized attention value of each character in each sentence of the initial labeled sample set, and randomly rewrite the characters whose normalized attention value is higher than a preset threshold to obtain a plurality of rewritten sentences; Inputting the rewritten sentence into a binary classification model of a negative sentence pattern to obtain a plurality of expanded positive samples and a plurality of expanded negative samples; the plurality of expanded positive samples and the plurality of expanded negative samples are added to an initial labeled sample set to form an expanded sample set; In the step of obtaining an initial set of labeled samples by preliminarily screening out a number of samples in the text library to be classified, the initial screening module preliminarily screens out a number of samples in the text library to be classified by considering sentence patterns as initial positive samples; by matching the disease name table, all texts in the text library to be classified that can match the disease names in the disease name table are screened out as initial negative samples; the initial positive samples and the initial negative samples constitute the initial set of labeled samples; The format of the consideration sentence includes: consideration is X; X is the name of the disease; In the step of randomly rewriting the characters whose normalized attention values ​​are higher than the preset threshold, the characters whose normalized attention values ​​are higher than the preset threshold include "consider" and "disease name"; the word "consider" is rewritten with synonyms or antonyms, and the disease name is rewritten with other disease names in the preset disease name table.

6. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the processor is configured to execute a computer program stored in the memory to implement the text sample expansion method as claimed in any one of claims 1 to 3.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one instruction, and when the at least one instruction is executed by a processor, the text sample expansion method according to any one of claims 1 to 3 is implemented.

Citation Information

Patent Citations

  • Training corpus expanding device and training corpus expanding method

    CN104346406A

  • Text classification model training method and device, computer equipment and storage medium

    CN112100378A

  • Chinese text classification method based on attention mechanism and interference word deletion

    CN112749274A