How to train an end-to-end sensitive text recall model, How to recall sensitive text
The end-to-end sensitive text recall model, trained with iterative methods and neural networks, addresses the challenge of poor generalization in existing text recall systems, effectively identifying and blocking sensitive texts, including similar expressions, to enhance user experience and compliance.
Patent Information
- Application Number
- JP2023524462
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2022-06-06
- Filing Date
- 2022-10-10
- Publication Date
- 2024-11-11
- Estimated Expiration
- 2042-10-10
AI Technical Summary
Existing text recall methods struggle with poor generalization ability, failing to effectively identify and block semantically similar sensitive texts, leading to regulatory risks and user dissatisfaction.
A method for training an end-to-end sensitive text recall model using positive and negative sample data, iterative training with human evaluation and multi-sample splice sampling, and a neural network architecture including LSTM layers and pooling layers to enhance generalization and recall accuracy.
The method improves the model's ability to recognize and recall sensitive texts, including semantically similar expressions, thereby enhancing user experience and compliance in applications.
Smart Images

Figure 0007580593000005 
Figure 0007580593000006 
Figure 0007580593000007
Abstract
Description
Priority information
[0001] This application is filed based on a Chinese patent application with Chinese patent application number "2022106332414" and filing date on June 6, 2022, and claims priority to the Chinese patent application, the entire contents of which are hereby incorporated by reference into this application. [Technical field]
[0002] The present disclosure relates to the field of data processing technology, specifically to the field of artificial intelligence technology such as deep learning, and more specifically to a method for training an end-to-end sensitive text recall model, a sensitive text recall method. [Background technology]
[0003] Text in applications is one of the main ways to convey information to users, but sensitive text containing harmful and illegal information can bring bad user experience, regulatory risks, harm social climate, and ultimately lead to users abandoning application products. Word list recall can promptly recall sensitive text in text information, thereby ensuring product safety and improving user experience. Summary of the Invention
[0004] The present disclosure provides a method for training an end-to-end sensitive text recall model, a sensitive text recall method, an apparatus, a device, and a storage medium.
[0005] According to an embodiment of a first aspect of the present disclosure, there is provided a method for training an end-to-end sensitive text recall model, the method including: obtaining a preset word list and a first random text corpus in a sensitive text block scene, where text corresponding to a term in the preset word list is sensitive text; constructing positive sample data according to the preset word list and constructing negative sample data according to the first random text corpus; performing iterative training on an initial text classification model based on the positive sample data and the negative sample data by a human evaluation manner and a multi-sample splice sampling manner to obtain a text classification model whose model indicator reaches a target standard after training is completed; and generating an end-to-end sensitive text recall model based on model parameters of the text classification model whose model indicator reaches the target standard, where the end-to-end sensitive text recall model has obtained word list recall ability through learning.
[0006] In some embodiments, the step of performing iterative training on an initial text classification model based on the positive sample data and the negative sample data through a human evaluation scheme and a multi-sample splice sampling scheme includes the steps of: dividing the positive sample data and the negative sample data into a training set and a validation set as training samples; training a text classification model based on the training set and the validation set to obtain an optimal model; obtaining a test set, evaluating the optimal model based on the test set to obtain a model evaluation result; updating the training samples based on the model evaluation result and the test set through a human evaluation scheme and a multi-sample splice sampling scheme; and re-dividing the updated training samples into a training set and a validation set, and training a text classification model based on the training set and the validation set to obtain an optimal model until a model index reaches a target standard after training is completed.
[0007] In some embodiments, the test set includes a recall sample and a second random text corpus, and evaluating the optimal model based on the test set to obtain a model evaluation result includes inputting the recall sample from the test set into the optimal model and obtaining a first prediction result output from the optimal model; determining a recall rate of the optimal model based on the first prediction result and actual label information corresponding to the recall sample; inputting the second random text corpus from the test set into the optimal model and obtaining a second prediction result output from the optimal model; and determining a precision rate of the optimal model based on the second prediction result and actual label information corresponding to the second random text corpus.
[0008] In some embodiments, updating the training samples using a human evaluation and multi-sample splice sampling scheme based on the model evaluation results and the test set includes: in response to the recall being less than a first threshold, obtaining a first human evaluation of the examples predicted to be negative examples from the first prediction results, and adding examples of the recall samples that are mispredicted to be negative examples from the recall samples to a sample set to be updated based on the first human evaluation; and / or in response to the precision being less than a second threshold, obtaining a second human evaluation of the examples predicted to be positive examples from the second prediction results, and adding a text corpus of examples of the second random text corpus that are mispredicted to be positive examples from the second random text corpus to a sample set to be updated based on the second human evaluation; splicing every N samples in the sample set to be updated into one sample, and updating the sample obtained after splicing to the training sample, where N is an integer greater than 1.
[0009] In some embodiments, N is 3.
[0010] In some embodiments, the text classification model includes a first long short-term memory network (LSTM) layer, an average pooling layer, a second LSTM layer, a max pooling layer, a splice concat layer, a reduced dropout layer, and a classification layer, where the first LSTM layer extracts text features of samples, the average pooling layer pools the text features to obtain first path features, the second LSTM layer performs feature extraction on a last hidden layer output of the first LSTM layer and inputs the extracted features to the max pooling layer, the max pooling layer pools the output of the second LSTM layer to obtain second path features, the splice concat layer splices the first path features and the second path features to obtain splice features, the reduced dropout layer performs a dropout operation on the splice features, and the classification layer classifies features of the reduced dropout layer output to obtain a classification prediction value.
[0011] According to an embodiment of a second aspect of the present disclosure, there is provided a method for sensitive text recall, the method including the steps of: obtaining a target text; and predicting the target text based on a pre-trained end-to-end sensitive text recall model to determine whether to recall the target text, the end-to-end sensitive text recall model having acquired word list recall capability through training, the end-to-end sensitive text recall model being trained using the method described in the first aspect.
[0012] In some embodiments, predicting the target text based on the pre-trained end-to-end sensitive text recall model and determining whether to recall the target text includes: extracting text features of the target text through the first long short-term memory network (LSTM) layer; pooling the text features through the average pooling layer to obtain first path features; performing feature extraction on a last hidden layer output of the first LSTM layer through the second LSTM layer and inputting the extracted features to the max pooling layer; pooling the output of the second LSTM layer through the max pooling layer to obtain second path features; splicing the first path features and the second path features to obtain splice features and performing a Dropout operation on the splice features through the reduced Dropout layer; classifying features of the reduced Dropout layer output through the classification layer to obtain a classification prediction value; and determining whether to recall the target text based on the prediction value.
[0013] According to an embodiment of a third aspect of the present disclosure, there is provided an apparatus for training an end-to-end sensitive text recall model, the apparatus including: an acquisition module for acquiring a preset word list and a first random text corpus in a sensitive text block scene, where a text corresponding to a term in the preset word list is a sensitive text; a construction module for constructing positive sample data based on the preset word list, where the construction module constructs negative sample data based on the first random text corpus; and a processing module for performing iterative training on an initial text classification model based on the positive sample data and the negative sample data by a human evaluation manner and a multi-sample splice sampling manner, to obtain a text classification model whose model indicator reaches a target standard after training is completed, and generating an end-to-end sensitive text recall model based on model parameters of the text classification model whose model indicator reaches the target standard, where the end-to-end sensitive text recall model has word list recall ability through learning.
[0014] In some embodiments, the processing module specifically performs the steps of: dividing the positive sample data and the negative sample data into a training set and a validation set as training samples; training a text classification model based on the training set and the validation set to obtain an optimal model; obtaining a test set; evaluating the optimal model based on the test set to obtain a model evaluation result; updating the training samples based on the model evaluation result and the test set through a human evaluation manner and a multi-sample splice sampling manner; re-dividing the updated training samples into a training set and a validation set; and training a text classification model based on the training set and the validation set to obtain an optimal model until the model index reaches a target standard after training is completed.
[0015] In some embodiments, the test set includes a recall sample and a second random text corpus, and the processing module specifically inputs the recall sample from the test set into the optimal model, obtains a first prediction result output from the optimal model, and determines a recall rate of the optimal model based on the first prediction result and actual label information corresponding to the recall sample; inputs the second random text corpus from the test set into the optimal model, obtains a second prediction result output from the optimal model, and determines a precision rate of the optimal model based on the second prediction result and actual label information corresponding to the second random text corpus.
[0016] In some embodiments, the processing module specifically, in response to the recall being smaller than a first threshold, obtain a first human evaluation of the examples of the first prediction results that are predicted to be negative examples, and add the examples of the recall samples that are mispredicted to be negative examples to a sample set to be updated based on the first human evaluation; and / or, in response to the precision being smaller than a second threshold, obtain a second human evaluation of the examples of the second prediction results that are predicted to be positive examples, and add the text corpus of the examples of the second random text corpus that are mispredicted to be positive examples to a sample set to be updated based on the second human evaluation, splice every N samples in the sample set to be updated into one sample, and update the sample obtained after the splicing process to the training sample, where N is an integer greater than 1.
[0017] In some embodiments, N is 3.
[0018] In some embodiments, the text classification model includes a first long short-term memory network (LSTM) layer, an average pooling layer, a second LSTM layer, a max pooling layer, a splice concat layer, a reduced dropout layer, and a classification layer, where the first LSTM layer extracts text features of samples, the average pooling layer pools the text features to obtain first path features, the second LSTM layer performs feature extraction on a last hidden layer output of the first LSTM layer and inputs the extracted features to the max pooling layer, the max pooling layer pools the output of the second LSTM layer to obtain second path features, the splice concat layer splices the first path features and the second path features to obtain splice features, the reduced dropout layer performs a dropout operation on the splice features, and the classification layer classifies features of the reduced dropout layer output to obtain a classification prediction value.
[0019] According to a fourth embodiment of the present disclosure, there is provided a sensitive text recall apparatus, comprising: an acquisition module for acquiring a target text; and a prediction module for predicting the target text based on a pre-trained end-to-end sensitive text recall model to determine whether to recall the target text, where the end-to-end sensitive text recall model has obtained word list recall ability through learning, and the end-to-end sensitive text recall model is trained using a method according to any embodiment of the first aspect of the present disclosure.
[0020] In some embodiments, the prediction module specifically extracts text features of the target text through the first long short-term memory network (LSTM) layer, pools the text features through the average pooling layer to obtain first path features, performs feature extraction on the last hidden layer output of the first LSTM layer through the second LSTM layer, inputs the extracted features into the max pooling layer, pools the output of the second LSTM layer through the max pooling layer to obtain second path features, splices the first path features and the second path features to obtain splice features, performs a Dropout operation on the splice features through the reduced Dropout layer, classifies the features of the reduced Dropout layer output through the classification layer to obtain a predicted value of classification, and determines whether to recall the target text based on the predicted value.
[0021] According to an embodiment of a fifth aspect of the present disclosure, there is provided an electronic device comprising at least one processor and a memory communicatively connected to the at least one processor, the memory storing instructions executable by the at least one processor, the instructions being executed by the at least one processor such that the at least one processor is capable of performing a method according to any of the embodiments of the first or second aspect.
[0022] According to an embodiment of a sixth aspect of the present disclosure, there is provided a non-transitory computer readable storage medium having stored thereon computer instructions, the computer instructions causing the computer to perform a method according to any of the embodiments of the first or second aspect.
[0023] The present disclosure 7 According to an embodiment of the aspect ,Ko A computer program is provided, M When executed on a computer, the method according to any one of the first and second aspects of the present invention causes the computer to Law Run it.
[0024] According to the technology disclosed herein, positive sample data and negative sample data are constructed based on a word list and a large amount of actual data, and an iterative training process is performed on a text classification model based on the constructed positive sample data and negative sample data to generate an end-to-end sensitive text recall model, so that the end-to-end sensitive text recall model can learn the word list recall ability, thereby improving the knowledge generalization ability of the end-to-end sensitive text recall model and improving the recall ability of the model for sensitive text, so that the end-to-end sensitive text recall model can be used to realize word list recall and improve the word list generalization ability.
[0025] It should be understood that the contents described in this section are not intended to identify key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will be readily understood through the following description. [Brief description of the drawings]
[0026] The drawings are used for a better understanding of the present technical solution, and are not intended to limit the present disclosure. [Figure 1] FIG. 1 is a schematic diagram according to a first embodiment of the present disclosure. [Diagram 2] 1 is a schematic flowchart of model training provided by an embodiment of the present disclosure. [Diagram 3] FIG. 11 is a schematic diagram according to a second embodiment of the present disclosure. [Figure 4] FIG. 1 is a schematic diagram of the architecture of a text classification model provided by an embodiment of the present disclosure. [Diagram 5] FIG. 11 is a schematic diagram according to a third embodiment of the present disclosure. [Figure 6] FIG. 1 is a schematic diagram of a training apparatus for an end-to-end sensitive text recall model provided by an embodiment of the present disclosure. [Figure 7] 1 is a schematic diagram of a sensitive text recall device provided by an embodiment of the present disclosure; [Figure 8] FIG. 2 is a block diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0027] Hereinafter, exemplary embodiments of the present disclosure will be described in conjunction with the drawings, and various details of the embodiments of the present disclosure will be included therein for ease of understanding, and they should be regarded as merely exemplary. Therefore, it should be recognized that those skilled in the art can make various changes and modifications to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for clarity and conciseness, the following description omits the description of well-known functions and structures. In the description of the present disclosure, unless otherwise stated, " / " means "or", for example, the description A / B can represent A or B, and "and / or" in this specification describes the related relationship of related objects and represents that three relationships can exist. For example, the description A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0028] Using word list blocking text to block sensitive information (such as information that violates relevant laws and regulations) in text is an important means to eliminate harmful information, but the generalizability of the word list policy used in the related technology is poor. For example, "we love XX" can be used as a term to recall the text "we love XX, we love YY", but cannot recall the text that is very similar in meaning to the above text "we love XX very much". Therefore, the embodiment of the present disclosure proposes a method for training an end-to-end sensitive text recall model, and can build a sensitive text recall model with high knowledge generalization ability, and based on this model, end-to-end text prediction and recall can be realized, and semantically similar expression text can be effectively recalled.
[0029] Referring to Fig. 1, Fig. 1 is a schematic diagram of a method for training an end-to-end sensitive text recall model according to a first embodiment of the present disclosure. As shown in Fig. 1, the method can include, but is not limited to, the following steps S101 to S104.
[0030] Step S101, obtain a preset word list in a sensitive text block scene and a first random text corpus.
[0031] In an embodiment of the present disclosure, the pre-defined word list includes corresponding sensitive text terms, which may include multi-word terms and single-word terms, and the first random text corpus includes, but is not limited to, text captured by the pre-defined word list or text with normal human evaluation results.
[0032] For example, a pre-defined word list is obtained, which consists of terms corresponding to sensitive text that needs to be blocked in a sensitive text blocking scene, and a first random text corpus is obtained according to the actual situation.
[0033] Step S102: constructing positive sample data based on a preset word list, and constructing negative sample data based on a first random text corpus.
[0034] For example, delimiters of multi-word terms and single-word terms in a preset word list are removed, and the remaining text is used as a model positive sample to evaluate the proportion of harmful corpus in the first random text corpus. If the proportion of harmful corpus in the first random corpus is equal to or less than a preset threshold (e.g., 1%), the text in the first random text corpus is directly randomly extracted as a negative sample. If the proportion of harmful corpus in the first random corpus is greater than the preset threshold, the first random text corpus is examined to remove harmful corpus in the first random text corpus. If the proportion of harmful corpus in the first random corpus is equal to or less than the preset threshold, the text in the first random corpus after processing is randomly extracted as a negative sample.
[0035] Step S103: based on the positive sample data and the negative sample data, perform iterative training on the initial text classification model through a human evaluation method and a multi-sample splice sampling method, and obtain a text classification model whose model index reaches the target standard after the training is completed.
[0036] In the embodiment of the present disclosure, the text classification model includes, but is not limited to, TextCNN (Text Convolutional Neural Networks), FastText (FastText Classification), and BERT (Bidirectional Encoder Representations from Transformers). The multi-sample splice sampling method is a method for resolving text based on human learning. What? evaluation was done It refers to splicing a preselected number (e.g., three) of multiple marked-up texts into one sample. What? evaluation was done Splice three pieces of marked up text into one sample.
[0037] For example, iterative training is performed on the initial text classification model based on the positive sample data and the negative sample data, and during the iterative training, the current model's indicators are calculated every preset number of training steps (e.g., 100 steps) to evaluate the effectiveness of the current model, the training samples are updated using a multi-sample splice sampling method, the model's loss value is calculated based on the loss function, the gradient is inversely calculated based on the loss value to optimize the model parameters, and the updated training samples are used to train the model after parameter optimization. The above steps are repeated until the model's indicators reach the target standard, and this model is regarded as the text classification model.
[0038] In the embodiments of the present disclosure, the target indicator refers to a preset indicator for determining whether the model achieves the target effect, and the model indicator includes, but is not limited to, the model precision and the model recall.
[0039] In the embodiment of the present disclosure, the formula for calculating the precision rate can be expressed as follows:
number
[0040] where accuracy is the precision, TP is the number of samples where the model predicts positive samples as positive samples, FN is the number of samples where the model predicts positive samples as negative samples, FP is the number of samples where the model predicts negative samples as positive samples, and TN is the number of samples where the model predicts negative samples as negative samples.
[0041] In the embodiment of the present disclosure, the formula for the recall can be expressed as follows:
number
[0042] Recall is the recall rate, TP is the number of samples for which the model predicts positive samples as positive samples, and FN is the number of samples for which the model predicts positive samples as negative samples.
[0043] In an embodiment of the present disclosure, the calculation formula for the loss value can be expressed as follows:
number
[0044] where L is the loss value, i is the ith sample, yi is the label of sample i, positive samples are 1, negative samples are 0, and pi is the probability of predicting sample i as a positive sample.
[0045] Step S104, generate an end-to-end sensitive text recall model based on the model parameters of the text classification model whose model indicators reach the target standard.
[0046] In the embodiment of the present disclosure, the end-to-end sensitive text recall model has already learned the word list recall capability.
[0047] For example, based on the model parameters of the text classification model whose model indicators reach the target standard, a pre-configured neural network model structure is used to generate an end-to-end sensitive text recall model.
[0048] In the embodiment of the present disclosure, the pre-configured neural network model structure may be the same as the above text classification model.
[0049] By implementing the embodiments of the present disclosure, an end-to-end sensitive text recall model can be generated by performing iterative training on the text classification model based on the constructed positive sample data and negative sample data, thereby improving the knowledge generalization ability of the end-to-end sensitive text recall model and improving the recall ability of the model for sensitive text.
[0050] In the embodiment of the present disclosure, the text classification model can learn the word list recall ability by constructing positive and negative samples. However, since the generalization ability of the neural network is high and it may recall many texts that do not meet the word list recall needs, the embodiment of the present disclosure designs a model training flow in an offline training environment to ensure that the model can learn the appropriate generalization ability more accurately. As an example, refer to FIG. 2, which is a schematic flowchart of the model training provided by the embodiment of the present disclosure. As shown in FIG. 2, the embodiment of the present disclosure trains the classification model by constructing positive and negative samples, and in the model iteration process, the model adds the samples that the model misrecalls to the positive / negative samples in a human evaluation manner based on the model's precision and recall indicators, thereby improving the model indicator.
[0051] For example, refer to Fig. 3, which is a schematic diagram of a model training method according to a second embodiment of the present disclosure. As shown in Fig. 3, the implementation process of performing iterative training on the initial text classification model based on the positive sample data and the negative sample data through a human evaluation manner and a multi-sample splice sampling manner can include, but is not limited to, the following steps S301 to S305.
[0052] In step S301, the positive sample data and the negative sample data are divided into a training set and a validation set as training samples.
[0053] For example, the positive sample data and the negative sample data are randomly divided at a preset ratio to obtain a training set and a validation set.
[0054] In some embodiments, for example, the ratio of the number of sample data in the training set and the validation set is 9:1, and the positive samples and negative samples are randomly divided in the above ratio, so that 90% of the positive sample data and 90% of the negative sample data are used as the training set, and the remaining 10% of the positive sample data and 10% of the negative sample data are used as the validation set.
[0055] Step S302: Train a text classification model based on the training set and the validation set to obtain an optimal model.
[0056] For example, a text classification model is trained based on a training set, and the model is tested for the precision and recall effects of the current training step model at each preset training step (e.g., 100 steps) using a validation set, and the precision and recall effects of different training step models are compared to obtain an optimal model obtained by training using the current training set and the validation set.
[0057] Step S303: obtain a test set, evaluate an optimal model based on the test set, and obtain a model evaluation result.
[0058] For example, obtain a test set containing a recall set and random data, recall the test set based on the optimal model obtained in the previous step, calculate the current index of the model based on the model output, and take this index as the evaluation result of the optimal model.
[0059] In some embodiments, the test set may include a recall sample and a second random text corpus, and the step of evaluating the optimal model based on the test set and obtaining a model evaluation result may include: inputting the recall sample from the test set into the optimal model and obtaining a first prediction result output from the optimal model; determining a recall rate of the optimal model based on the first prediction result and actual label information corresponding to the recall sample; inputting the second random text corpus from the test set into the optimal model and obtaining a second prediction result output from the optimal model; and determining a precision rate of the optimal model based on the second prediction result and actual label information corresponding to the second random text corpus.
[0060] In an embodiment of the present disclosure, the recall sample is pre-acquired to test the recall ability of the model, and the acquisition manner of the second random text corpus may be the same as the acquisition manner of the first random text corpus.
[0061] Note that the text in the first random text corpus is different from the text in the second random text corpus.
[0062] As an example, a text obtained by a preset word list or a text whose artificial screening result is normal can be randomly divided into two parts, one part as a first random text corpus and the other part as a second random text corpus, to ensure that the text in the first random text corpus is different from the text in the second random text corpus.
[0063] For example, a recall sample from the test set is input as input data into the optimal model to predict label information of each sample in the recall sample, the predicted label information of each sample is obtained as a first prediction result, and the recall of the optimal model is calculated based on the first prediction result and actual label information corresponding to the recall sample using the above-mentioned recall calculation formula; a second random text corpus from the test set is input as input data into the optimal model to predict label information of each sample in the second random text corpus, the predicted label information of each sample is obtained as a second prediction result, and the precision of the optimal model is calculated based on the second prediction result and actual label information corresponding to the second random text corpus using the above-mentioned precision calculation formula.
[0064] In the embodiment of the present disclosure, the formula for calculating the precision rate can be expressed as follows:
number
[0065] Precision is the accuracy rate, TP is the number of samples that predict positive samples as positive samples, and FP is the number of samples that predict negative samples as positive samples.
[0066] Step S304: updating the training samples according to the model evaluation results and the test set through human evaluation and multi-sample splice sampling methods.
[0067] For example, if the model evaluation results do not meet the expected results, the training samples are updated by predicting data that are positive examples using a human evaluation model and adding data that is actually classified as negative examples to the training samples.
[0068] In some embodiments, the step of updating the training samples through the human evaluation and multi-sample splice sampling scheme based on the model evaluation results and the test set may include: in response to the recall being less than a first threshold, obtaining a first human evaluation result predicted to be a negative example from the first prediction results, and adding a sample from the recall sample that is mispredicted to be a negative example from the first human evaluation result to the sample set to be updated; and / or in response to the precision being less than a second threshold, obtaining a second human evaluation result predicted to be a positive example from the second prediction results, and adding a text corpus from the second random text corpus that is mispredicted to be a positive example from the second human evaluation result to the sample set to be updated; splicing every Nth sample in the sample set to be updated into one sample, and updating the sample obtained by the splicing process as the training sample, where N is an integer greater than 1.
[0069] In some embodiments, N is 3. In some embodiments, in response to the recall of the current model being less than a first threshold, obtain a first prediction result in which the model prediction is a negative example, perform human evaluation on the samples predicted to be negative examples from the first prediction result, select positive samples from the samples that are mispredicted to be negative examples, add the positive samples that are mispredicted to be negative examples to a sample set to be updated, splice every third sample in the sample set to be updated into one sample, update the sample obtained by performing the splicing process as a training sample, and in response to the precision of the current model being equal to or greater than a second threshold, do not process the second prediction result.
[0070] In some other embodiments, in response to the recall of the current model being equal to or greater than a first threshold, the first prediction result is not processed. In response to the precision of the current model being less than a second threshold, a second prediction result is obtained in which the model prediction is a positive example, a sample predicted to be a positive example in the second prediction result is manually evaluated, a negative sample in the second prediction result that is mispredicted to be a positive example is selected from the samples, a negative sample that is mispredicted to be a positive example is added to a sample set to be updated, every third sample in the sample set to be updated is spliced into one sample, and the sample obtained by performing the splicing process is updated as a training sample.
[0071] In some other embodiments, in response to the recall rate of the current model being smaller than a first threshold, a first prediction result in which the model prediction is a negative example is obtained, a sample predicted to be a negative example from the first prediction result is evaluated by a human, a positive sample from the above samples that is mispredicted as a negative example is selected, and the positive sample mispredicted as a negative example is added to the sample set to be updated; in response to the precision rate of the current model being smaller than a second threshold, a second prediction result in which the model prediction is a positive example is obtained, a sample predicted to be a positive example from the second prediction result is evaluated by a human, a negative sample from the above samples that is mispredicted as a positive example is selected, and the negative sample mispredicted as a positive example is added to the sample set to be updated; every third sample in the sample set to be updated is spliced into one sample, and the sample obtained by performing the splicing process is updated to the training sample.
[0072] In some other embodiments, in response to the recall rate of the current model being equal to or greater than the first threshold, if the precision rate of the current model is equal to or greater than the second threshold, it is determined that the index of the current model has reached the target standard. Step S305: repartitioning the updated training samples into a training set and a validation set, and training a text classification model based on the training set and the validation set until the model index reaches the target standard after training is completed, thereby obtaining an optimal model.
[0073] For example, the updated training samples are re-divided according to a preset ratio to obtain new training sets and validation sets, and the new training sets and validation sets are used to execute step S302 again, and the subsequent steps are executed according to the actual situation to retrain the text classification model until the model indicators after training reach the target standard.
[0074] It should be noted that, according to an embodiment of the present disclosure, a text classification model can be trained offline using model version iteration to obtain an end-to-end sensitive text recall model, which can be deployed on a server to directly recognize text in linked applications to recall sensitive text, thereby achieving end-to-end sensitive text recall.
[0075] In an embodiment of the present disclosure, the text classification model may include a first long short-term memory network LSTM layer, an average pooling layer, a second LSTM layer, a max pooling layer, a splice Concat layer, a reduction Dropout layer, and a classification layer. As an example, refer to Figure 4, which is a schematic diagram of the architecture of a text classification model provided by an embodiment of the present disclosure. As shown in Figure 4, the first LSTM layer extracts the text features of the samples, the mean-pooling layer pools the text features to obtain the first path features, the second LSTM layer extracts features from the output of the last hidden layer in the first LSTM layer (i.e., hn shown in Figure 4) and inputs the extracted features into the max-pooling layer, which pools the output of the second LSTM layer to obtain the second path features, the Concat layer splices the first path features and the second path features to obtain the spliced features, the Dropout layer performs a Dropout operation on the spliced features, and the classification layer classifies the features output from the Dropout layer to obtain classified prediction values.
[0076] In addition, the Dropout layer can effectively prevent the occurrence of overfitting. The Dropout function is a special activation function. During the training phase of the text classification model, the ratio of the number of weights activated by the Dropout layer to the total number of weights in this Dropout layer should be ensured to be the retention probability keep_prob (generally 0.5), and during the prediction phase, keep_prob=1.
[0077] Referring to Fig. 5, Fig. 5 is a schematic diagram of a sensitive text recall method according to a third embodiment of the present disclosure. As shown in Fig. 5, the method can include, but is not limited to, the following steps S501 to S502:
[0078] In step S501, the text to be processed is acquired.
[0079] For example, text information in a related application can be acquired as the text to be processed.
[0080] Step S502: predicting the target text based on the pre-trained end-to-end sensitive text recall model to determine whether the target text is recalled.
[0081] In an embodiment of the present disclosure, the end-to-end sensitive text recall model has already been trained to have word list recall capability, and the end-to-end sensitive text recall model is trained in a manner provided by any of the embodiments of the present disclosure.
[0082] For example, the processed text may be input to a pre-trained end-to-end sensitive text recall model to predict the text and determine whether the text contains sensitive text, thereby determining whether the processed text should be recalled.
[0083] By implementing the embodiments of the present disclosure, a target text can be predicted based on a pre-trained end-to-end sensitive text recall model to determine whether to recall the target text, thereby improving the recall for sensitive text.
[0084] Referring to Fig. 6, Fig. 6 is a schematic diagram of an apparatus for training an end-to-end sensitive text recall model provided by an embodiment of the present disclosure. As shown in Fig. 6, the apparatus includes an acquisition module 601, a construction module 602 and a processing module 603.
[0085] The acquisition module 601 acquires a preset word list and a first random text corpus in a sensitive text block scene, and the text corresponding to the terms in the preset word list is the sensitive text. The construction module 602 constructs positive sample data according to the preset word list and constructs negative sample data according to the first random text corpus. The processing module 603 performs iterative processing training on the initial text classification model according to the positive sample data and the negative sample data through a human evaluation manner and a multi-sample splice sampling manner to obtain a text classification model whose model indicator reaches a target standard after training is completed. And generates an end-to-end sensitive text recall model based on the model parameters of the text classification model whose model indicator reaches the target standard, and the end-to-end sensitive text recall model has already obtained word list recall ability through learning.
[0086] In some embodiments, the processing module 603 specifically performs the steps of: dividing the positive sample data and the negative sample data into a training set and a validation set as training samples; training a text classification model according to the training set and the validation set to obtain an optimal model; obtaining a test set; evaluating the optimal model according to the test set to obtain a model evaluation result; updating the training samples according to the model evaluation result and the test set through a human evaluation manner and a multi-sample splice sampling manner; re-dividing the updated training samples into a training set and a validation set; and training a text classification model according to the training set and the validation set until the model indicator reaches the target standard after training is completed to obtain an optimal model.
[0087] In some embodiments, the test set includes a recall sample and a second random text corpus, and the processing module 603 specifically inputs the recall sample from the test set into an optimal model, obtains a first prediction result output from the optimal model, and determines a recall rate of the optimal model based on the first prediction result and actual label information corresponding to the recall sample; inputs the second random text corpus from the test set into the optimal model, obtains a second prediction result output from the optimal model, and determines a precision rate of the optimal model based on the second prediction result and actual label information corresponding to the second random text corpus.
[0088] In some embodiments, the processing module 603 specifically: in response to the recall being smaller than a first threshold, obtain a first human evaluation result that is predicted to be a negative example from the first prediction result, and add a sample from the recall sample that is mispredicted to be a negative example from the first human evaluation result to the sample set to be updated based on the first human evaluation result; and / or in response to the precision being smaller than a second threshold, obtain a second human evaluation result that is predicted to be a positive example from the second prediction result, and add a text corpus from the second random text corpus that is mispredicted to be a positive example from the second human evaluation result to the sample set to be updated, splice every N samples in the sample set to be updated into one sample, and update the sample obtained by performing the splicing process to a training sample, where N is an integer greater than 1.
[0089] In some embodiments, N is 3.
[0090] In some embodiments, the text classification model includes a first long short-term memory network (LSTM) layer, an average pooling layer, a second LSTM layer, a max pooling layer, a splice concat layer, a reduction dropout layer, and a classification layer, in which the first LSTM layer extracts text features of the samples, the average pooling layer pools the text features to obtain first path features, the second LSTM layer extracts features from the output of the last hidden layer in the first LSTM layer and inputs the extracted features to a max pooling layer, the max pooling layer pools the output of the second LSTM layer to obtain second path features, the splice concat layer splices the first path features and the second path features to obtain splice features, the reduction dropout layer performs a dropout operation on the splice features, and the classification layer classifies the features output from the reduction dropout layer to obtain classified prediction values.
[0091] According to the device of the embodiment of the present disclosure, an iterative training process can be performed on the text classification model based on the constructed positive sample data and negative sample data to obtain a text recall model, thereby improving the knowledge generalization ability of the text recall model and improving the recall ability of the model for sensitive text.
[0092] Referring to Fig. 7, Fig. 7 is a schematic diagram of a sensitive text recall device provided by an embodiment of the present disclosure. As shown in Fig. 7, the device includes an acquisition module 701 and a prediction module 702. The acquisition module 701 acquires a target text, and the prediction module 702 predicts the target text based on a pre-trained end-to-end sensitive text recall model to determine whether to recall the target text, where the end-to-end sensitive text recall model has already acquired word list recall ability through learning, and the end-to-end sensitive text recall model is trained by the method described in any of the embodiments of the present disclosure.
[0093] In some embodiments, the prediction module 702 specifically extracts text features of the target text through a first long short-term memory network (LSTM) layer, pools the text features through an average pooling layer to obtain a first path feature, extracts features from the output of the last hidden layer in the first LSTM layer through a second LSTM layer, inputs the extracted features into a max pooling layer, pools the output of the second LSTM layer through the max pooling layer to obtain a second path feature, splices the first path feature and the second path feature to obtain a spliced feature, performs a Dropout operation on the spliced feature through a reduced Dropout layer, classifies the features output from the reduced Dropout layer through a classification layer to obtain a classified prediction value, and determines whether to recall the target text based on the prediction value.
[0094] According to the device of the embodiment of the present disclosure, the target text can be predicted based on a pre-trained end-to-end sensitive text recall model to determine whether to recall the target text, thereby improving the recall for the sensitive text.
[0095] The specific manner of performing the operations of each module in the apparatus of the above embodiment has already been described in detail in the embodiment relating to the method, and will not be described in detail here.
[0096] According to an embodiment of the present disclosure, the present disclosure provides an electronic device, a computer-readable storage medium, experience and a computer program product are further provided.
[0097] As shown in FIG. 8, a block diagram of an electronic device according to an embodiment of the present disclosure. The electronic device can be used to realize any of the end-to-end sensitive text recall model training method or sensitive text recall method of the embodiment of the present 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 can also represent various forms of mobile devices, such as personal digital processing, mobile phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the description herein and / or the implementation of the present disclosure as sought.
[0098] As shown in FIG. 8, the electronic device includes one or more processors 801, memory 802, and interfaces for connecting each component including high speed and low speed interfaces. Each component may be connected to each other by different buses, mounted on a common motherboard, or mounted in other manners as needed. The processor is capable of processing instructions executed within the electronic device, including instructions stored in the memory for displaying graphical information of a GUI on an external input / output device (such as a display device coupled to the interface). In other embodiments, multiple processors and / or multiple buses may be used, if needed. , multiple It can be used with any number of memories. Similarly, multiple electronic devices can be connected, each providing a portion of the required operations (e.g., a server array, a blade server, or a multi-processor system). In FIG. 8, one processor 801 is taken as an example.
[0099] The memory 802 is a non-transitory computer-readable storage medium provided by the present disclosure. The memory stores instructions executed by at least one processor, causing the at least one processor to perform the method for training an end-to-end sensitive text recall model or the method for sensitive text recall provided by the present disclosure. The non-transitory computer-readable storage medium of the present disclosure stores computer instructions for a computer to perform the method for training an end-to-end sensitive text recall model or the method for sensitive text recall provided by the present application.
[0100] The memory 802 is a non-transitory computer-readable storage medium and stores non-transitory software programs, non-transitory computer-executable programs and modules, such as computer instructions / modules (e.g., the acquisition module 601, the construction module 602 and the processing module 603 shown in FIG. 6) corresponding to the method for training an end-to-end sensitive text recall model in the embodiment of the present disclosure, or computer instructions / modules (e.g., the acquisition module 701 and the prediction module 702 shown in FIG. 7) corresponding to the sensitive text recall method. The processor 801 executes the non-transitory software programs, instructions and modules stored in the memory 802 to perform various functional applications and data processing of the server, i.e., to realize the method for training an end-to-end sensitive text recall model or the sensitive text recall method in the embodiment of the above method.
[0101] The memory 802 may include a storage program area and a storage data area. The storage program area may store an operating system, an application required for at least one function. The storage data area may store data generated by using the method for training an end-to-end sensitive text recall model or the electronic device of the sensitive text recall method, and the like. The memory 802 may also include a high-speed random access memory, and may further include a non-transient memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory 802 may selectively include a memory configured remotely with respect to the processor 801, and these remote memories may be connected to the method for training an end-to-end sensitive text recall model or the electronic device of the sensitive text recall method via a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0102] The electronic device of the method for training an end-to-end sensitive text recall model or the method for sensitive text recall may further include an input device 803 and an output device 804. The processor 801, the memory 802, the input device 803, and the output device 804 may be connected via a bus or other methods, and FIG. 8 takes the connection via a bus as an example.
[0103] The input device 803 can receive input numeric or character information and generate key signal inputs for user settings and function control of the end-to-end sensitive text recall model training method or the electronic device of the sensitive text recall method, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, a wand, one or more mouse buttons, a track ball, a joystick, etc. The output device 804 can include a display device, an auxiliary lighting device (e.g., LED), a haptic feedback device (e.g., vibration motor), etc. The display device can include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device can be a touch screen.
[0104] Various embodiments of the systems and techniques described herein may be realized in digital electronic circuitry systems, integrated circuit systems, application specific integrated circuits (ASICs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments may include being embodied in one or more computer programs that may be executed and / or interpreted by a programmable system having at least one programmable processor, which may be a special purpose or general purpose programmable processor, and that may receive data and instructions from and transmit data and instructions to a storage system, at least one input device, and at least one output device.
[0105] These computing programs (also referred to as programs, software, software applications, or code) include the implementation of these computing programs in machine instructions for a programmable processor, in high level process and / or object oriented programming languages, and / or in assembly / machine languages. As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., magnetic disks, optical disks, memories, programmable logic devices (PLDs)) used to provide machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions that are machine-readable signals. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0106] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user, and a keyboard and pointing device (e.g., a mouse or trackball) by which a user can provide input to the computer. Other types of devices can also provide interaction with a user, for example, the feedback provided to the user can be any form of sensing feedback (e.g., vision feedback, auditory feedback, or haptic feedback) and can receive input from the user in any form (including acoustic, speech, or tactile input).
[0107] The systems and techniques described herein may be implemented in a computing system with a back-end component (e.g., a data server), or a computing system with a middleware component (e.g., an application server), or a computing system with a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with the embodiments of the systems and techniques described herein), or a computing system with any combination of such back-end, middleware, and front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0108] The computer system may include a client and a server. The client and the server are generally remote from each other and typically interact with each other via a communication network. The relationship between the client and the server is generated by a computer program that is executed on a corresponding computer and has a client-server relationship with each other. The server may be a cloud server, also called a cloud computing server or cloud host, which is a host product in a cloud computing service system and solves the defects of the traditional physical host and VPS service (abbreviated as "Virtual Private Server", or "VPS"), such as difficulty in management and weak business scalability. The server may be a server of a distributed system or a server incorporating blockchain.
[0109] According to the technical solution of the embodiment of the present disclosure, a text recall model can be obtained by performing iterative training on the text classification model based on the constructed positive sample data and negative sample data, thereby improving the knowledge generalization ability of the text recall model and improving the recall ability of the model for sensitive text.
[0110] The above description of the method for training the end-to-end sensitive text recall model can be applied to the apparatus, electronic device, and computer-readable storage medium of the embodiments of the present disclosure. Body The present invention also applies to computer programs, and the description thereof will be omitted here.
[0111] It should be understood that steps can be rearranged, added, or deleted using various types of flows shown above. For example, each step described in the present disclosure can be performed in parallel, sequentially, or in a different order, but is not limited herein as long as the technical solution disclosed in the present disclosure can achieve the desired results. The above specific embodiments do not limit the scope of protection of the present disclosure.
[0112] It should be understood that those skilled in the art can make various modifications, combinations, subcombinations, and substitutions according to design requirements and other factors. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present disclosure should be included within the protection scope of the present disclosure.
Claims
1. Obtaining a preset word list and a first random text corpus in a sensitive text block scene, where text corresponding to a term in the preset word list is sensitive text; constructing positive sample data based on the predefined word list and constructing negative sample data based on the first random text corpus; According to the positive sample data and the negative sample data, iteratively train the initial text classification model through a human evaluation method and a multi-sample splice sampling method to obtain a text classification model whose model index reaches a target standard after training; generating an end-to-end sensitive text recall model based on the model parameters of the text classification model whose model indicators reach a target standard, the end-to-end sensitive text recall model having acquired word list recall ability through training; A method for training an end-to-end sensitive text recall model, including:
2. performing an iterative training process on an initial text classification model based on the positive sample data and the negative sample data through a human evaluation scheme and a multi-sample splice sampling scheme; Dividing the positive sample data and the negative sample data into a training set and a validation set as training samples; training a text classification model based on the training set and the validation set to obtain an optimal model; obtaining a test set and evaluating the optimal model based on the test set to obtain a model evaluation result; updating the training samples according to the model evaluation results and the test set through human evaluation and multi-sample splice sampling; Re-dividing the updated training samples into a training set and a validation set, and training a text classification model based on the training set and the validation set until the model index reaches a target standard after the training is completed, thereby obtaining an optimal model; 2. The method for training an end-to-end sensitive text recall model of claim 1, comprising:
3. the test set includes a recall sample and a second random text corpus, and evaluating the best fit model based on the test set to obtain a model evaluation result; inputting the recall sample of the test set into the optimal model and obtaining a first prediction result output from the optimal model; determining a recall rate of the optimal model based on the first prediction result and actual label information corresponding to the recall sample; inputting the second random text corpus of the test set into the best-fit model and obtaining a second prediction result output from the best-fit model; determining a fit rate of the optimal model based on the second prediction result and actual label information corresponding to the second random text corpus; The method for training an end-to-end sensitive text recall model of claim 2, comprising:
4. updating the training samples according to the model evaluation results and the test set through a human evaluation scheme and a multi-sample splice sampling scheme; In response to the recall rate being less than a first threshold, obtaining a first human evaluation result of the first prediction result of the examples that are predicted to be negative examples, and adding samples of the recall samples that are mispredicted to be negative examples to a sample set to be updated based on the first human evaluation result; and / or in response to the precision being less than a second threshold, obtaining a second human evaluation of the examples predicted to be positive examples from the second prediction results, and obtaining text corpora mispredicted to be positive examples from the second random text corpus based on the second human evaluation; 4. The method of claim 3, further comprising: splicing every N samples in the sample set to be updated into one sample, and updating the sample obtained after the splicing process to the training sample, where N is an integer greater than 1.
5. The method for training an end-to-end sensitive text recall model of claim 4, wherein N is 3.
6. the text classification model includes a first long short-term memory network (LSTM) layer, an average pooling layer, a second LSTM layer, a max pooling layer, a spliced concat layer, a reduced dropout layer, and a classification layer; The first LSTM layer extracts text features of the samples; the average pooling layer pools the text features to obtain first path features; The second LSTM layer performs feature extraction on the output of the last hidden layer of the first LSTM layer, and inputs the extracted features to the max pooling layer; the max pooling layer pools the output of the second LSTM layer to obtain second path features; the splice concat layer splices the first path feature and the second path feature to obtain a splice feature; the reduced Dropout layer performs a Dropout operation on the splice feature; The method for training an end-to-end sensitive text recall model according to claim 1 , wherein the classification layer performs classification processing on the features output from the reduced Dropout layer to obtain a classification prediction value.
7. obtaining a text to be processed; predicting the target text based on a pre-trained end-to-end sensitive text recall model to determine whether the target text is recalled; Including, The end-to-end sensitive text recall model is trained to obtain word list recall capability, and the end-to-end sensitive text recall model is trained according to the method of claim 1.
8. predicting the target text based on the pre-trained end-to-end sensitive text recall model to determine whether to recall the target text, extracting text features of the target text through a first LSTM layer; pooling the text features through an average pooling layer to obtain first path features; performing feature extraction on the output of the last hidden layer of the first LSTM layer through a second LSTM layer, and inputting the extracted features into a max pooling layer; pooling the output of the second LSTM layer through the max pooling layer to obtain second path features; splicing the first path feature and the second path feature to obtain a splice feature, and performing a Dropout operation on the splice feature via the reduced Dropout layer; processing the features of the output of the reduced Dropout layer through a classification layer to obtain a predicted classification value; determining whether to recall the subject text based on the predicted value; 8. The method of claim 7, comprising:
9. An acquisition module for acquiring a preset word list and a first random text corpus in a sensitive text block scene, wherein text corresponding to a term in the preset word list is sensitive text; a construction module for constructing positive sample data based on the predefined word list, and a construction module for constructing negative sample data based on the first random text corpus; According to the positive sample data and the negative sample data, an iterative training process is performed on the initial text classification model through a human evaluation method and a multi-sample splice sampling method, and a text classification model whose model index reaches a target standard after training is completed is obtained; A processing module for generating an end-to-end sensitive text recall model based on the model parameters of the text classification model whose model indicators reach a target standard, the end-to-end sensitive text recall model being trained to have word list recall ability; An apparatus for training an end-to-end sensitive text recall model, comprising:
10. an acquisition module for acquiring a text to be processed; a prediction module for predicting the target text based on a pre-trained end-to-end sensitive text recall model to determine whether the target text is recalled; Equipped with The end-to-end sensitive text recall model is trained to obtain word list recall capability, and the end-to-end sensitive text recall model is trained according to the method of any one of claims 1 to 6.
11. At least one processor; a memory communicatively coupled to the at least one processor; Equipped with An electronic device comprising: an input / output section for inputting a first input / output signal to the at least one processor; and a second input / output section for outputting a first input / output signal to the at least one processor; and a memory for storing instructions executable by the at least one processor; the memory storing instructions executable by the at least one processor;
12. A non-transitory computer-readable storage medium having computer instructions stored thereon, comprising: A non-transitory computer readable storage medium having computer instructions that cause a computer to perform the method of any one of claims 1 to 6 or the method of claims 7 or 8.
13. A computer program which, when executed by a computer, causes the computer to perform the method according to any one of claims 1 to 6, or the method according to claim 7 or 8.
Citation Information
Patent Citations
Text auditing method, text auditing model, equipment and storage medium
CN112487149A
Sensitive word recognition method and device
CN114239591A
Data classifying device, computer program, and data classification method
JP2010072779A
Call center term management system for obtaining symptom of NG word and method therefor
JP2015061116A
