Training method and device of classification model suitable for text review
By generating enhanced text samples using a pre-trained language model and filtering them using labels and confidence scores from a classification model, the training process of the text review classification model is optimized, the problem of noise introduction is solved, and the accuracy and generalization ability of the model are improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING BAIDU NETCOM SCI & TECH CO LTD
- Filing Date
- 2023-01-06
- Publication Date
- 2026-05-05
AI Technical Summary
Existing text moderation classification models are prone to introducing noise during training, resulting in insufficient model accuracy and generalization ability, making it difficult to effectively handle massive and diverse Internet text data.
By using a pre-trained language model to perform mask prediction and continuation prediction on text samples, enhanced text samples are generated. Then, a classification model is used to obtain labels and confidence scores for filtering and updating. The training sample set is optimized round by round to generate the target classification model.
It improves the diversity of training data and the generalization ability of the model, enhances the accuracy of classification models, reduces the need for manual annotation, and expands the boundaries of model training.
Smart Images

Figure CN116226375B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and in particular to the fields of deep learning and computer technology. Background Technology
[0002] In related technologies, text moderation is an automated and intelligent system based on natural language processing technology used to determine whether the content of a text complies with the content guidelines of internet, media, and other platforms. Common application scenarios for text moderation include user signatures / nicknames, comments / messages, instant messaging text content, user posts, media information, product information, live video comments, and image and text information.
[0003] Text moderation involves various types of review, and the internet generates massive amounts of user data daily, requiring a heavy workload for review. Classification models can utilize computer and natural language processing technologies to automate the detection and identification of text content violations, either as a primary or supplementary method for manual review, significantly reducing the workload of relevant personnel.
[0004] Therefore, improving the accuracy and generalization ability of classification models suitable for text review has become an important research direction. Summary of the Invention
[0005] This disclosure provides a training method and apparatus for a classification model suitable for text review.
[0006] According to one aspect of this disclosure, a method for training a classification model suitable for text moderation is provided, the method comprising:
[0007] For any text review type among multiple text review types, obtain the i-th round text sample set and the first classification model trained in the j-th round corresponding to the text review type, where i and j are positive integers;
[0008] Based on the pre-trained language model, different types of predictions are made on the text samples in the i-th round of text sample set to obtain enhanced text samples with different prediction types;
[0009] The labels and confidence scores of the enhanced text samples are obtained based on the first classification model;
[0010] The enhanced text samples are filtered based on their prediction type, label, and confidence level. The text sample set for the i-th round is then updated based on the filtered enhanced text samples to obtain the text sample set for the (i+1)-th round.
[0011] The first classification model is trained based on the text sample set of round i+1, and the second classification model after round j+1 training is obtained. The second classification model is then trained based on the text sample set of the next round until the training ends and the target classification model is generated.
[0012] This disclosure can avoid introducing noise during model training, increase the diversity of training data, thereby expanding the boundaries of model training, fully exploring the generalization ability of classification models, and improving the accuracy of classification models.
[0013] According to another aspect of this disclosure, a training apparatus for a classification model suitable for text moderation is provided, comprising:
[0014] The first acquisition module is used to acquire the i-th round text sample set and the first classification model trained in the j-th round for any text review type among multiple text review types, where i and j are positive integers;
[0015] The second acquisition module is used to make different types of predictions on the text samples in the i-th round of text sample set based on the pre-trained language model, so as to obtain enhanced text samples of different prediction types.
[0016] The third acquisition module is used to acquire the labels and confidence scores of the enhanced text samples based on the first classification model;
[0017] The update module is used to filter the enhanced text samples according to the prediction type, label and confidence of the enhanced text samples, and update the text sample set of the i-th round according to the filtered enhanced text samples to obtain the text sample set of the i+1-th round.
[0018] The training module is used to train the first classification model based on the text sample set of the (i+1)th round, obtain the second classification model after the (j+1)th round of training, and continue to obtain the text sample set of the next round to train the second classification model until the training ends and the target classification model is generated.
[0019] According to another aspect of this disclosure, an electronic device is provided, including at least one processor, and
[0020] A memory that is communicatively connected to at least one processor; wherein,
[0021] The memory stores instructions that can be executed by at least one processor to enable the at least one processor to perform a training method for a classification model applicable to text review, according to an embodiment of the first aspect of this disclosure.
[0022] According to another aspect of this disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute a training method for a classification model suitable for text review, as described in the first aspect of this disclosure.
[0023] According to another aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a training method for a classification model suitable for text review, as described in the first aspect of this disclosure.
[0024] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description
[0025] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0026] Figure 1 This is a flowchart of a training method for a classification model applicable to text review according to an embodiment of the present disclosure;
[0027] Figure 2 This is a flowchart of a training method for a classification model applicable to text review according to an embodiment of the present disclosure;
[0028] Figure 3 This is a schematic diagram of a training method for a classification model applicable to text review according to an embodiment of the present disclosure;
[0029] Figure 4 This is a flowchart of a training method for a classification model applicable to text review according to an embodiment of the present disclosure;
[0030] Figure 5 This is a schematic diagram of a training method for a classification model applicable to text review according to an embodiment of the present disclosure;
[0031] Figure 6 This is a structural diagram of a training apparatus for a classification model applicable to text review, according to an embodiment of the present disclosure;
[0032] Figure 7 This is a block diagram of an electronic device used to implement a training method for a classification model applicable to text review, according to embodiments of the present disclosure. Detailed Implementation
[0033] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0034] The embodiments disclosed herein relate to the fields of artificial intelligence technology, such as computer vision and deep learning.
[0035] Artificial Intelligence (AI) is a new technological science that studies and develops theories, methods, technologies, and application systems to simulate, extend, and expand human intelligence.
[0036] Deep learning (DL) is a new research direction in the field of machine learning (ML), which brings machine learning closer to its original goal—AI. Deep learning learns the inherent patterns and hierarchical representations of sample data. The information gained during this learning process greatly aids in interpreting data such as text, images, and sound. Its ultimate goal is to enable machines to possess analytical and learning capabilities like humans, and to recognize data such as text, images, and sound.
[0037] Computer technology refers to the use of computers' fast and accurate computing power, logical judgment ability, and artificial simulation ability to perform quantitative calculations and analyses of systems, providing means and tools for solving complex system problems.
[0038] Typical text moderation systems include a sensitive dictionary matching module and a classification model built based on deep learning. The classification model requires training with manually labeled, high-quality data, and the quantity and quality of the training data significantly impact the performance of the target classification model. In practice, labeling large amounts of data consumes considerable human resources; furthermore, text samples matching the text moderation type have a very low distribution in natural data, making their collection and acquisition very difficult. This disclosure allows for the acquisition of text samples matching the text moderation type without additional manual labeling, while simultaneously increasing data diversity and improving the model's generalization ability.
[0039] The following describes, with reference to the accompanying drawings, a training method and apparatus for a classification model applicable to text review.
[0040] Figure 1 This is a flowchart of a training method for a classification model applicable to text review according to an embodiment of the present disclosure, such as... Figure 1 As shown, the method includes the following steps:
[0041] S101, for any text review type among multiple text review types, obtain the i-th round text sample set and the first classification model trained in the j-th round corresponding to the text review type, where i and j are positive integers.
[0042] In some implementations, text moderation types include negative information types, sensitive information types, etc., and each text moderation type corresponds to a classification model.
[0043] Optionally, the classification model in this embodiment can be a binary classification model. For example, a binary classification model can be obtained by fine-tuning a pre-trained model (ERNIE 2.0 model). For any text review type among multiple text review types, the classification model corresponding to that text review type can be used to determine whether the text to be processed conforms to the current text review type.
[0044] Optionally, the initial text sample set includes multiple text samples, which are labeled text samples, meaning that each text sample has a label.
[0045] For example, if the text review type is advertising promotion, the text samples in the i-th round of text sample set include those labeled 0 and 1. Among them, the text samples labeled 0 are text samples with advertising promotion, and the text samples labeled 1 are text samples without advertising promotion.
[0046] S102, based on the pre-trained language model, perform different types of predictions on the text samples in the i-th round of text sample set to obtain enhanced text samples of different prediction types.
[0047] Optionally, in this embodiment of the disclosure, the prediction type may include mask prediction and continuation prediction.
[0048] It should be noted that, in this embodiment of the disclosure, the pre-trained language model can be a pre-trained language model with generative capabilities (such as ERNIE 3.0 model, t5 model, gpt-3 model, etc.).
[0049] In some implementations, different prediction types correspond to different data preprocessing processes. The text samples in the i-th round of text sample set can be preprocessed according to the prediction type, and then input into the pre-trained language model for prediction to generate enhanced text samples of different prediction types.
[0050] S103, obtain the labels and confidence scores of the enhanced text samples based on the first classification model.
[0051] The first classification model trained in the j-th round is used to perform binary classification on the enhanced text samples to construct labels for the enhanced text samples and obtain the confidence scores of the enhanced text samples.
[0052] In some implementations, the label of an enhanced text sample indicates that the enhanced text sample conforms to the text moderation type; in other implementations, the label of an enhanced text sample indicates that the enhanced text sample does not conform to the text moderation type.
[0053] It should be noted that the labels of the enhanced text samples constructed based on the first classification model are pseudo-labels.
[0054] S104. The enhanced text samples are filtered according to their prediction type, label and confidence level. The text sample set of the i-th round is updated according to the filtered enhanced text samples to obtain the text sample set of the (i+1)-th round.
[0055] In some implementations, different prediction types correspond to different filtering strategies.
[0056] For example, if the prediction type of the augmented text sample is mask prediction, in order to improve the core of the classification model performance, and to learn the position of the keywords that affect the label judgment, we can select several augmented text samples that meet the text review type and those that do not based on the labels and confidence of the augmented text samples, so as to update the text sample set of the i-th round.
[0057] For example, if the prediction type of the augmented text sample is continuation prediction, in order to improve the recall rate of the pre-trained language model and fully explore the generalization ability of the classification model, several augmented text samples that meet the text review type can be selected based on the labels of the augmented text samples to update the text sample set of the i-th round.
[0058] It should be noted that the text samples in the (i+1)th round of text sample set are labeled text samples, and the labels are the pseudo-labels obtained by the classification model.
[0059] S105, train the first classification model based on the text sample set of the (i+1)th round, obtain the second classification model after the (j+1)th round of training, and continue to obtain the text sample set of the next round to train the second classification model until the training ends and the target classification model is generated.
[0060] Optionally, the first classification model is trained based on the text sample set of the (i+1)th round, and the first classification model is adjusted in reverse according to the loss function to obtain the second classification model after the (j+1)th round of training.
[0061] The next round of text sample sets is then acquired to train the second classification model, and the above steps are repeated until a preset training termination condition is met. This confirms the completion of training for the classification model and generates the target classification model. Optionally, the training termination condition may be reaching a preset number of training iterations, or the loss value of the loss function converging to a preset loss threshold. This embodiment of the present disclosure does not impose limitations on this.
[0062] In this embodiment, a pre-trained language model is used to predict different types of text samples in the i-th round of text sample set to obtain enhanced text samples of different prediction types; the labels and confidence levels of the enhanced text samples are obtained based on a first classification model; the enhanced text samples are filtered according to their prediction type, labels, and confidence levels, and the i-th round of text sample set is updated based on the filtered enhanced text samples to obtain the i+1-th round of text sample set; this disclosure can avoid introducing noise during model training, improve the diversity of training data, thereby expanding the boundaries of model training, fully exploring the generalization ability of the classification model, and improving the accuracy of the classification model.
[0063] Figure 2 This is a flowchart of a training method for a classification model applicable to text review according to an embodiment of the present disclosure, such as... Figure 2 As shown, the method includes the following steps:
[0064] S201, for any text review type among multiple text review types, obtain the i-th round text sample set and the first classification model trained in the j-th round corresponding to the text review type, where i and j are positive integers.
[0065] For a description of step S201, please refer to the content in the above embodiments, which will not be repeated here.
[0066] S202, mask the text samples, and perform mask prediction on the masked text samples based on the pre-trained language model to generate enhanced text samples with the prediction type of mask prediction.
[0067] The text sample is masked according to a preset coverage ratio to generate a first text sample, which includes one or more masks. The first text sample is then input into a pre-trained language model, which predicts one or more masks in the first text sample based on the pre-trained language model to generate an enhanced text sample with a prediction type of mask prediction.
[0068] Optionally, the coverage ratio can be 15%. In other implementations, the coverage ratio can take other values, and this disclosure does not limit this.
[0069] The text sample is masked according to a preset coverage ratio to generate multiple first text samples. For example, if the text sample is "I am an employee", after masking the text sample according to the preset coverage ratio, the generated first text sample can be "I am a [mask]", "[mask] is an employee", "I [mask] an employee", "I am a [mask] employee", etc.
[0070] Based on the pre-trained language model, the mask in the first text sample "I am a [mask]" is predicted, and the generated enhanced text samples can be "I am a teacher", "I am a student", "I am an employee", "I am a staff member", etc.
[0071] S203: Rewrite the text sample based on preset prompt words, and perform continuation prediction on the rewritten text sample based on a pre-trained language model to generate an enhanced text sample with the prediction type of continuation prediction.
[0072] To improve the model's recall and fully leverage the classification model's generalization ability, a second text sample labeled as matching the text review type is obtained from the text samples. This second text sample is then rewritten based on preset prompts to obtain a third text sample. Any two third text samples are concatenated to obtain a fourth text sample. Finally, the fourth text sample is further refined using a pre-trained language model to generate an enhanced text sample with a prediction type of "continuation prediction".
[0073] like Figure 3 As shown, firstly, several different prompt templates are designed. A second text sample is randomly sampled, and then rewritten based on a preset prompt template to obtain a third text sample. Finally, the third text sample is concatenated according to a defined prompt. Available prompt templates include... Figure 3 As shown, its core idea is to construct a prompt, listing two existing second text samples that conform to the text review type in a list format, and using these as prompts, expecting the pre-trained language model to continue generating a third text sample that conforms to the text review type, that is, to generate an enhanced text sample with the prediction type of continuation prediction.
[0074] Taking the pre-trained language model ERNIE 3.0 as an example, the ERNIE 3.0 model has two parts: an understanding network and a generation network. During pre-training, the understanding task and the generation task can be performed simultaneously. Here, the generation network is used to continue writing the fourth text sample to generate an enhanced text sample with the prediction type of continuation prediction.
[0075] S204, obtain the labels and confidence scores of the enhanced text samples based on the first classification model.
[0076] S205, the enhanced text samples are filtered according to the prediction type, label and confidence of the enhanced text samples, and the text sample set of the i-th round is updated according to the filtered enhanced text samples to obtain the text sample set of the i+1-th round.
[0077] S206, train the first classification model based on the text sample set of the (i+1)th round, obtain the second classification model after the (j+1)th round of training, and continue to obtain the text sample set of the next round to train the second classification model until the training ends and the target classification model is generated.
[0078] For a description of steps S204 to S206, please refer to the content in the above embodiments, which will not be repeated here.
[0079] In this embodiment, text samples are masked, and mask prediction is performed on the masked text samples based on a pre-trained language model to generate enhanced text samples with a prediction type of mask prediction. The text samples are then rewritten based on preset prompts, and continuation prediction is performed on the rewritten text samples based on the pre-trained language model to generate enhanced text samples with a prediction type of continuation prediction. This disclosure avoids introducing noise during model training, increases the diversity of training data, thereby expanding the boundaries of model training, fully exploring the generalization ability of the classification model, and improving the accuracy of the classification model.
[0080] Figure 4 This is a flowchart of a training method for a classification model applicable to text review according to an embodiment of the present disclosure, such as... Figure 4 As shown, the method includes the following steps:
[0081] S401, for any text review type among multiple text review types, obtain the i-th round text sample set and the first classification model trained in the j-th round corresponding to the text review type, where i and j are positive integers.
[0082] S402, based on the pre-trained language model, perform different types of predictions on the text samples in the i-th round of text sample set to obtain enhanced text samples of different prediction types.
[0083] For a description of steps S401 to S402, please refer to the content in the above embodiments, which will not be repeated here.
[0084] S403, obtain the labels and confidence scores of the enhanced text samples based on the first classification model.
[0085] Optionally, the first classification model in this embodiment can be a binary classification model. Based on the first classification model, the enhanced text samples are classified to determine whether they conform to the current text review type, thereby obtaining the labels and confidence levels of the enhanced text samples.
[0086] In some implementations, the label of an enhanced text sample indicates that the enhanced text sample conforms to the text moderation type; in other implementations, the label of an enhanced text sample indicates that the enhanced text sample does not conform to the text moderation type.
[0087] S404, in response to the prediction type of the enhanced text sample being mask prediction, the enhanced text sample is filtered based on the label and confidence of the enhanced text sample to generate the first enhanced text sample.
[0088] In some implementations, the M tags with the highest confidence in the enhanced text samples are identified as the third enhanced text sample that conforms to the text review type, and the N tags with the highest confidence in the enhanced text samples are identified as the fourth enhanced text sample that does not conform to the text review type. The third and fourth enhanced text samples are then determined as the first enhanced text samples. M and N are positive integers.
[0089] For example, the enhanced text sample with the highest confidence level can be identified as the enhanced text sample that conforms to the text review type, and the enhanced text sample with the highest confidence level but not conforming to the text review type can be identified as the first enhanced text sample.
[0090] It should be noted that the purpose of this data augmentation process is to learn why a text sample conforms to the text review type and where the keywords are located. For example, if a text sample is modified by changing the mask part, resulting in two augmented texts, one conforming to the text review type and the other not, and these two are very similar, inputting them into the classification model will help the classification model learn why the label changes when only the mask part is changed. This data augmentation process can improve the accuracy of the classification model.
[0091] S405, in response to the prediction type of the enhanced text sample being continuation prediction, the enhanced text sample is filtered based on the label of the enhanced text sample to generate a second enhanced text sample.
[0092] In some implementations, there may be duplicates in the augmented text samples. To reduce the amount of computation and speed up the training process, the augmented text samples can be merged to remove duplicates and obtain the fifth augmented text sample. The fifth augmented text sample whose label matches the text review type is identified as the second augmented text sample.
[0093] It should be noted that the purpose of this data augmentation process is to generate more violating samples (text samples labeled as conforming to the text review type) and filter out samples that are predicted to be non-violating (text samples labeled as not conforming to the text review type), in order to improve the model's recall rate.
[0094] S406, add the first enhanced text sample and the second enhanced text sample to the text sample set of the i-th round to obtain the text sample set of the (i+1)-th round.
[0095] S407, train the first classification model based on the text sample set of the (i+1)th round, obtain the second classification model after the (j+1)th round of training, and continue to obtain the text sample set of the next round to train the second classification model until the training ends and the target classification model is generated.
[0096] For a description of steps S406 to S407, please refer to the content in the above embodiments, which will not be repeated here.
[0097] In this embodiment, labels and confidence levels of augmented text samples are obtained based on a first classification model. Responding to the prediction type of the augmented text sample being mask prediction, the augmented text samples are filtered based on their labels and confidence levels to generate a first augmented text sample. Responding to the prediction type of the augmented text sample being continuation prediction, the augmented text samples are filtered based on their labels to generate a second augmented text sample. This disclosure uses the classification model trained in the previous round to score and generate labels for the augmented data samples, which avoids introducing noise during model training. The pre-trained language model, trained on massive amounts of data during the pre-training phase, has the ability to generate data with rich semantics. Utilizing it for data augmentation can improve the diversity of training data, thereby expanding the boundaries of the classification model and fully exploring its generalization ability.
[0098] Figure 5 This is a flowchart of a training method for a classification model applicable to text review according to an embodiment of the present disclosure, such as... Figure 5As shown in this embodiment, for any text review type among multiple text review types, the i-th round text sample set and the j-th round trained first classification model corresponding to the text review type are obtained; the text samples are masked, and the masked text samples are predicted based on the pre-trained language model to generate enhanced text samples with a prediction type of mask prediction; the text samples are rewritten based on preset prompt words, and the rewritten text samples are predicted for continuation based on the pre-trained language model to generate enhanced text samples with a prediction type of continuation prediction. The labels and confidence scores of the enhanced text samples are obtained based on the first classification model; in response to the prediction type of the enhanced text samples being mask prediction, the enhanced text samples are filtered based on the labels and confidence scores to generate a first enhanced text sample; in response to the prediction type of the enhanced text samples being continuation prediction, the enhanced text samples are filtered based on the labels to generate a second enhanced text sample; the first and second enhanced text samples are added to the i-th round text sample set to obtain the (i+1)-th round text sample set. The first classification model is trained based on the text sample set of round i+1, and the second classification model after round j+1 training is obtained. The second classification model is then trained based on the text sample set of the next round until the training ends and the target classification model is generated.
[0099] This disclosure uses the classification model trained in the previous round to score and generate labels for augmented data samples, which can avoid introducing noise during model training. The pre-trained language model has been trained on massive amounts of data during the pre-training stage and has the ability to generate data with rich semantics. Using it for data augmentation can improve the diversity of training data, thereby expanding the boundaries of the classification model and fully exploring the generalization ability of the classification model.
[0100] Figure 6 This is a structural diagram of a training apparatus for a classification model applicable to text review, according to an embodiment of the present disclosure, as follows: Figure 6 As shown, the training device 600 for the classification model suitable for text review includes:
[0101] The first acquisition module 610 is used to acquire the i-th round text sample set and the first classification model trained in the j-th round for any text review type among multiple text review types, where i and j are positive integers;
[0102] The second acquisition module 620 is used to make different types of predictions on text samples in the i-th round of text sample set based on the pre-trained language model, so as to obtain enhanced text samples of different prediction types.
[0103] The third acquisition module 630 is used to acquire the labels and confidence scores of the enhanced text samples based on the first classification model;
[0104] The update module 640 is used to filter the enhanced text samples according to the prediction type, label and confidence of the enhanced text samples, and update the text sample set of the i-th round according to the filtered enhanced text samples to obtain the text sample set of the i+1-th round.
[0105] The training module 650 is used to train the first classification model based on the text sample set of the (i+1)th round, obtain the second classification model after the (j+1)th round of training, and continue to obtain the text sample set of the next round to train the second classification model until the training ends and the target classification model is generated.
[0106] In some implementations, the second acquisition module 620 is further configured to: mask the text sample, and perform mask prediction on the masked text sample based on a pre-trained language model to generate an enhanced text sample with a prediction type of mask prediction; and / or rewrite the text sample based on preset prompt words, and perform continuation prediction on the rewritten text sample based on a pre-trained language model to generate an enhanced text sample with a prediction type of continuation prediction.
[0107] In some implementations, the second acquisition module 620 is further configured to: mask the text sample according to a preset coverage ratio to generate a first text sample, the first text sample including one or more masks; input the first text sample into a pre-trained language model, and predict one or more masks in the first text sample based on the pre-trained language model to generate an enhanced text sample.
[0108] In some implementations, the second acquisition module 620 is also used to: acquire a second text sample whose label matches the text review type; rewrite the second text sample based on preset prompt words to acquire a third text sample; concatenate any two third text samples to acquire a fourth text sample; and continue writing the fourth text sample based on a pre-trained language model to generate an enhanced text sample.
[0109] In some implementations, the update module 640 is further configured to: in response to the prediction type of the enhanced text sample being mask prediction, filter the enhanced text sample based on the label and confidence of the enhanced text sample to generate a first enhanced text sample; in response to the prediction type of the enhanced text sample being continuation prediction, filter the enhanced text sample based on the label of the enhanced text sample to generate a second enhanced text sample; and add the first enhanced text sample and the second enhanced text sample to the text sample set of the i-th round to obtain the text sample set of the (i+1)-th round.
[0110] In some implementations, the labels include those that conform to the text review type and those that do not conform to the text review type. The update module 640 is also used to: obtain the third enhanced text sample with the M highest confidence labels that conform to the text review type, and the fourth enhanced text sample with the N highest confidence labels that do not conform to the text review type; and determine the third enhanced text sample and the fourth enhanced text sample as the first enhanced text sample.
[0111] In some implementations, the update module 640 is also used to: merge the enhanced text samples to remove duplicate enhanced text samples and obtain a fifth enhanced text sample; and determine the fifth enhanced text sample whose label matches the text review type as the second enhanced text sample.
[0112] This disclosure can avoid introducing noise during model training, increase the diversity of training data, thereby expanding the boundaries of model training, fully exploring the generalization ability of classification models, and improving the accuracy of classification models.
[0113] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0114] Figure 7 This is a block diagram of an electronic device used to implement a training method for a classification model suitable for text review, according to embodiments of this disclosure. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device may also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0115] like Figure 7 As shown, device 700 includes a computing unit 701, which can perform various appropriate actions and processes based on a computer program stored in read-only memory (ROM) 702 or a computer program loaded from storage unit 708 into random access memory (RAM) 703. RAM 703 may also store various programs and data required for the operation of device 700. The computing unit 701, ROM 702, and RAM 703 are interconnected via bus 704. Input / output (I / O) interface 705 is also connected to bus 704.
[0116] Multiple components in device 700 are connected to I / O interface 705, including: input unit 706, such as keyboard, mouse, etc.; output unit 707, such as various types of monitors, speakers, etc.; storage unit 708, such as disk, optical disk, etc.; and communication unit 709, such as network card, modem, wireless transceiver, etc. Communication unit 709 allows device 700 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0117] The computing unit 701 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 701 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 701 performs the various methods and processes described above, such as a training method for a classification model suitable for text review. For example, in some embodiments, the training method for a classification model suitable for text review can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 708. In some embodiments, part or all of the computer program can be loaded and / or installed on device 700 via ROM 702 and / or communication unit 709. When the computer program is loaded into RAM 703 and executed by the computing unit 701, one or more steps of the training method for a classification model suitable for text review described above can be performed. Alternatively, in other embodiments, computing unit 701 may be configured by any other suitable means (e.g., by means of firmware) to perform a training method for a classification model suitable for text review.
[0118] Various embodiments of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field-programmable gate arrays (FPGAs), application-specific integrated circuits (ASICs), application-specific standard products (ASSPs), systems-on-a-chip (SoCs), payload-programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0119] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0120] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0121] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0122] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0123] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact via communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other. Servers can be cloud servers, servers in distributed systems, or servers incorporating blockchain technology.
[0124] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this disclosure can be achieved, and this is not limited herein.
[0125] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A training method for a classification model suitable for text moderation, wherein, include: For any text review type among multiple text review types, obtain the i-th round text sample set and the first classification model trained in the j-th round corresponding to the text review type, where i and j are positive integers; Based on the pre-trained language model, different types of predictions are made on the text samples in the i-th round of text sample set to obtain enhanced text samples of different prediction types, including mask prediction and continuation prediction. The labels and confidence scores of the enhanced text samples are obtained based on the first classification model; The enhanced text samples are filtered according to their prediction type, label, and confidence level. The i-th round text sample set is then updated based on the filtered enhanced text samples to obtain the (i+1)-th round text sample set. Different prediction types correspond to different filtering strategies. The first classification model is trained based on the (i+1)th round of text sample set to obtain the second classification model after the (j+1)th round of training, and the second classification model is trained based on the next round of text sample set until the training ends and the target classification model is generated. The process of making different types of predictions on text samples in the i-th round of text sample set based on a pre-trained language model to obtain enhanced text samples of different prediction types includes: The text sample is masked, and the masked text sample is predicted based on the pre-trained language model to generate an enhanced text sample with a prediction type of mask prediction. The text sample is rewritten based on preset prompts, and the rewritten text sample is then used to predict continuation based on the pre-trained language model, generating an enhanced text sample with the prediction type of continuation prediction.
2. The method according to claim 1, wherein, The process of masking the text sample and performing mask prediction on the masked text sample based on the pre-trained language model to generate enhanced text samples with a prediction type of mask prediction includes: The text sample is masked according to a preset coverage ratio to generate a first text sample, which includes one or more masks. The first text sample is input into the pre-trained language model, and one or more masks in the first text sample are predicted based on the pre-trained language model to generate an enhanced text sample with a prediction type of mask prediction.
3. The method according to claim 1, wherein, The text sample has a label. The process of rewriting the text sample based on preset prompt words and performing continuation prediction on the rewritten text sample based on the pre-trained language model to generate an enhanced text sample with the prediction type of continuation prediction includes: Obtain a second text sample whose label matches the text review type from the text sample; The second text sample is rewritten based on preset prompts to obtain the third text sample; Concatenate any two of the third text samples to obtain a fourth text sample; The fourth text sample is continued based on the pre-trained language model to generate an enhanced text sample with the prediction type of continuation prediction.
4. The method according to any one of claims 1-3, wherein, The process of filtering the enhanced text samples based on their prediction type, label, and confidence level, and updating the i-th round text sample set based on the filtered enhanced text samples to obtain the (i+1)-th round text sample set, includes: In response to the prediction type of the enhanced text sample being mask prediction, the enhanced text sample is filtered based on its label and confidence level to generate a first enhanced text sample; In response to the prediction type of the enhanced text sample being continuation prediction, the enhanced text sample is filtered based on its label to generate a second enhanced text sample; The first enhanced text sample and the second enhanced text sample are added to the i-th round text sample set to obtain the (i+1)-th round text sample set.
5. The method according to claim 4, wherein, The tags include those that conform to the text review type and those that do not. The step of filtering the enhanced text samples based on the tags and confidence levels to generate a first enhanced text sample includes: The M tags with the highest confidence in the enhanced text samples are identified as the third enhanced text sample that conforms to the text review type, and the N tags with the highest confidence in the enhanced text samples are identified as the fourth enhanced text sample that does not conform to the text review type, where M and N are positive integers; The third and fourth enhanced text samples are identified as the first enhanced text samples.
6. The method according to claim 5, wherein, The step of filtering the enhanced text samples based on their tags to generate a second enhanced text sample includes: The enhanced text samples are merged to remove duplicate enhanced text samples, resulting in a fifth enhanced text sample; The fifth enhanced text sample, whose label matches the text review type, is identified as the second enhanced text sample.
7. A training device for a classification model suitable for text moderation, wherein, include: The first acquisition module is used to acquire, for any text review type among multiple text review types, the i-th round text sample set corresponding to the text review type and the first classification model trained in the j-th round, where i and j are positive integers; The second acquisition module is used to perform different types of predictions on the text samples in the i-th round of text sample set based on the pre-trained language model, so as to obtain enhanced text samples of different prediction types, including mask prediction and continuation prediction. The third acquisition module is used to acquire the label and confidence level of the enhanced text sample based on the first classification model; The update module is used to filter the enhanced text samples according to the prediction type, label and confidence of the enhanced text samples, and update the i-th round text sample set according to the filtered enhanced text samples to obtain the i+1-th round text sample set. Different prediction types correspond to different filtering strategies. The training module is used to train the first classification model based on the text sample set of the (i+1)th round, obtain the second classification model after the (j+1)th round of training, and continue to obtain the text sample set of the next round to train the second classification model until the training ends and the target classification model is generated. The second acquisition module is further configured to: The text sample is masked, and the masked text sample is predicted based on the pre-trained language model to generate an enhanced text sample with a prediction type of mask prediction. The text sample is rewritten based on preset prompts, and the rewritten text sample is then used to predict continuation based on the pre-trained language model, generating an enhanced text sample with the prediction type of continuation prediction.
8. The apparatus according to claim 7, wherein, The second acquisition module is further configured to: The text sample is masked according to a preset coverage ratio to generate a first text sample, which includes one or more masks. The first text sample is input into the pre-trained language model, and the one or more masks in the first text sample are predicted based on the pre-trained language model to generate an enhanced text sample.
9. The apparatus according to claim 7, wherein, The second acquisition module is further configured to: Obtain a second text sample whose label matches the text review type from the text sample; The second text sample is rewritten based on preset prompts to obtain the third text sample; Concatenate any two of the third text samples to obtain a fourth text sample; The fourth text sample is continued based on the pre-trained language model to generate an enhanced text sample.
10. The apparatus according to any one of claims 7-9, wherein, The update module is also used for: In response to the prediction type of the enhanced text sample being mask prediction, the enhanced text sample is filtered based on its label and confidence level to generate a first enhanced text sample; In response to the prediction type of the enhanced text sample being continuation prediction, the enhanced text sample is filtered based on its label to generate a second enhanced text sample; The first enhanced text sample and the second enhanced text sample are added to the i-th round text sample set to obtain the (i+1)-th round text sample set.
11. The apparatus according to claim 10, wherein, The tags include those that conform to the text review type and those that do not conform to the text review type. The update module is further configured to: The M tags with the highest confidence in the enhanced text samples are identified as the third enhanced text sample that conforms to the text review type, and the N tags with the highest confidence in the enhanced text samples are identified as the fourth enhanced text sample that does not conform to the text review type, where M and N are positive integers; The third and fourth enhanced text samples are identified as the first enhanced text samples.
12. The apparatus according to claim 11, wherein, The update module is also used for: The enhanced text samples are merged to remove duplicate enhanced text samples, resulting in a fifth enhanced text sample; The fifth enhanced text sample, whose label matches the text review type, is identified as the second enhanced text sample.
13. An electronic device, comprising: At least one processor; as well as A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
14. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the steps of the method according to any one of claims 1-6.
15. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Method and device for training text auditing model
CN114970540A