A training method of a model for recognizing text and a text recognition method
By combining neural network training models with text topic and fragment recognition methods, the system automatically identifies illegal text, solving the accuracy and efficiency problems caused by manual annotation and achieving efficient and accurate illegal text recognition.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BAIDU COM TIMES TECH (BEIJING) CO LTD
- Filing Date
- 2023-03-13
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, the identification of illegal texts relies on manual annotation, which makes the annotation results highly susceptible to subjective factors, making it difficult to guarantee accuracy. Furthermore, manual annotation is inefficient and cannot meet the rapidly growing needs of information flow recommendation systems.
By using methods to automatically identify illegal text, a neural network-trained model is employed, combined with text topic and fragment recognition, to reduce reliance on manual annotation. Similar text mining and multi-angle recognition are used to improve the accuracy and timeliness of identification.
It improves the accuracy and timeliness of identifying illegal text, reduces labor costs, enhances the model's generalization ability and ability to identify illegal text, and reduces the need for manual annotation.
Smart Images

Figure CN116434244B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of artificial intelligence technology, and more particularly to the field of text recognition and machine learning technology. Background Technology
[0002] With the improvement of people's living standards and the rapid development of science and technology, the ways people obtain information are gradually changing. For example, in recent years, the demand for text, image, and video products has grown rapidly. However, text, image, and video products often contain some inappropriate or illegal text. This illegal text not only fails to bring revenue to users or content publishing platforms, but also greatly reduces the user's reading experience and damages the platform's product ecosystem. Summary of the Invention
[0003] This disclosure provides a method for training a model for recognizing text, as well as a text recognition method.
[0004] A first aspect of this disclosure provides a method for training a model for recognizing text, comprising:
[0005] Identify similar texts to the violating text, and treat each text segment containing the violating content in the violating text and the similar texts as a positive sample;
[0006] Set the topic label of each positive sample as the violation topic, and set the sample label of each positive sample as the violation fragment. The topic label is the label of the text topic of the text to which the text fragment belongs.
[0007] Obtain non-violation text, and take each text segment in the non-violation text that does not contain violation content as a negative sample. Set the topic tag of each negative sample to a non-violation topic and set the sample tag of each negative sample to a non-violation segment.
[0008] Using the text topic to which each sample belongs and the topic label of each text topic, a first neural network is trained to obtain a topic recognition model. The topic recognition model is used to identify whether a text topic is an illegal topic.
[0009] Using each sample and its corresponding sample label, a second neural network is trained to obtain a fragment recognition model, which is used to identify whether a text fragment is an illegal fragment.
[0010] A second aspect of this disclosure is to obtain the subject of a text to be identified and to segment the text to be identified.
[0011] The topic identification model is used to identify whether the topic to be identified is an illegal topic, wherein the topic identification model is a model obtained by training the first neural network through the method described in any one of the first aspects;
[0012] The fragment recognition model is used to identify whether each fragment of the text to be identified is a violation fragment; the fragment recognition model is a model obtained by training a second neural network using the method described in any of the first aspects;
[0013] If the topic to be identified is a violation topic, and the text to be identified contains violation segments, then the text to be identified is determined to be violation text.
[0014] A third aspect of this disclosure provides a training apparatus for a model for recognizing text, comprising:
[0015] The determination module is used to determine similar texts of the violating text, and to take each text fragment containing the violating content in the violating text and the similar texts as a positive sample;
[0016] The setting module is used to set the topic tag of each positive sample as the violation topic and the sample tag of each positive sample as the violation fragment, wherein the topic tag is the tag of the text topic of the text to which the text fragment belongs;
[0017] The acquisition module is used to acquire non-violation text, take each text segment in the non-violation text that does not contain violation content as a negative sample, set the topic tag of each negative sample as a non-violation topic, and set the sample tag of each negative sample as a non-violation segment.
[0018] The training module is used to train the first neural network using the text topic to which each sample belongs and the topic label of each text topic to obtain a topic recognition model. The topic recognition model is used to identify whether a text topic is an illegal topic.
[0019] The training module is also used to train a second neural network using each sample and its corresponding sample label to obtain a fragment recognition model, which is used to identify whether a text fragment is an illegal fragment.
[0020] A fourth aspect of this disclosure provides a text recognition device, comprising:
[0021] The acquisition module is used to acquire the subject of the text to be identified and to segment the text to be identified.
[0022] The identification module is used to identify whether the topic to be identified is a violation topic using a topic identification model, wherein the topic identification model is a model obtained by training a first neural network using the method described in any one of the first aspects;
[0023] The identification module is further configured to use a fragment identification model to identify whether each fragment of the text to be identified is a violation fragment; the fragment identification model is a model obtained by training a second neural network using the method described in any one of the first aspects;
[0024] The determination module is used to determine that the text to be identified is illegal text if the topic to be identified is an illegal topic and there are illegal segments in the text to be identified.
[0025] A fifth aspect of this disclosure provides an electronic device, including:
[0026] At least one processor; and
[0027] A memory communicatively connected to the at least one processor; wherein,
[0028] The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the method described in either the first or second aspect.
[0029] A sixth aspect of this disclosure provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method according to any one of the first or second aspects.
[0030] A seventh aspect of this disclosure provides a computer program product including a computer program that, when executed by a processor, implements the method according to either the first or second aspect.
[0031] 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
[0032] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein:
[0033] Figure 1 This is a flowchart of a training method for a model for recognizing text, provided in an embodiment of this disclosure;
[0034] Figure 2 This is a flowchart of a method for determining positive samples provided in an embodiment of this disclosure;
[0035] Figure 3 This is a flowchart of a method for determining negative samples provided in an embodiment of this disclosure;
[0036] Figure 4 This is a flowchart of a text recognition method provided in an embodiment of this disclosure;
[0037] Figure 5 This is an exemplary schematic diagram of a text recognition process provided in an embodiment of this disclosure;
[0038] Figure 6 This is a schematic diagram of the structure of a training device for a text recognition model provided in an embodiment of this disclosure;
[0039] Figure 7 This is a schematic diagram of the structure of a text recognition device provided in an embodiment of this disclosure;
[0040] Figure 8 This is a block diagram of an electronic device used to implement the training method for a model for recognizing text and the text recognition method of the embodiments of this disclosure. Detailed Implementation
[0041] 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.
[0042] Currently, the identification of illegal text mainly relies on manual annotation, where reviewers annotate sample text to determine if it is illegal, and then use the sample text and its annotations to train an identification model. The model is then used to identify whether the text to be identified is illegal.
[0043] Because the annotation results of text vary depending on the reviewer and the review environment, the annotation results are greatly affected by subjective factors, making it difficult to guarantee their accuracy, which in turn makes it difficult to guarantee the accuracy of the recognition model.
[0044] To improve the accuracy of identifying illegal text while reducing reliance on manual intervention, this disclosure provides a method for training a model for text recognition. This method is applied to electronic devices, such as servers, desktop computers, or laptops, which possess text processing capabilities. Figure 1 As shown, the method includes the following steps:
[0045] S101. Identify similar texts to the violating text, and treat each text fragment containing the violating content in the violating text and similar texts as a positive sample.
[0046] Optionally, from the abnormal text reviewed by the auditors, texts tagged with "inappropriate information" can be identified as violation texts based on the tags attached to each abnormal text. These tags may also include advertisements, etc.
[0047] Text similarity algorithms can be used to filter out texts from other texts that have a similarity to the violating text that is higher than a threshold, and these texts can be considered as similar texts.
[0048] In this embodiment, illegal text and similar text can be segmented into fragments, and fragments containing illegal content can be identified as positive samples. Specific methods can be found in the subsequent description. Illegal content can also be referred to as black market content.
[0049] S102. Set the topic label of each positive sample to the violation topic, and set the sample label of each positive sample to the violation fragment. The topic label is the label of the text topic of the text to which the text fragment belongs.
[0050] Where the text includes a title and body, the text topic includes the title of the text, and each text segment includes a title and / or part of the body. Where the text includes a title, summary and body, the text topic includes the title and summary of the text, and each text segment includes a title, summary and / or part of the body.
[0051] For example, text 1 includes: a title of "A text recognition method" and a summary of "Using a model to identify whether text violates regulations". The body text is "aaaaaaa.bbbbbbb.". Text 1 can be divided into fragment 1 as "A text recognition method; using a model to identify whether text violates regulations", fragment 2 as "aaaaaaa." and fragment 3 as "bbbbbbbb."; and the text topic of fragments 1, 2 and 3 is "A text recognition method; using a model to identify whether text violates regulations".
[0052] The format of topic tags and sample tags can be set according to actual needs. For example, the topic tag for positive samples can be set to 1, where 1 represents a violating topic. Similarly, the sample tag for positive samples can be set to 1, where 1 represents a violating segment.
[0053] S103. Obtain non-violation text, take each text segment in the non-violation text that does not contain violation content as a negative sample, set the topic label of each negative sample to non-violation topic, and set the sample label of each negative sample to non-violation segment.
[0054] Understandably, a text fragment that does not contain illegal content is a text fragment that does not contain inappropriate information.
[0055] For example, the topic label for negative samples can be set to 0, where 0 represents a non-violation topic. Similarly, the sample label for negative samples can be set to 0, where 0 represents a non-violation segment.
[0056] S101 and S103 can be executed sequentially or in parallel; this disclosure does not specifically limit this.
[0057] S104. Using the text topic to which each sample belongs and the topic label of each text topic, train the first neural network to obtain the topic recognition model. The topic recognition model is used to identify whether a text topic is an illegal topic.
[0058] The system can obtain the text topics of the texts containing positive samples and the text topics of the texts containing negative samples. These text topics are then input into a first neural network, which outputs whether the text topic is a violation. A preset loss function is then used to calculate the error between the output and the topic label, yielding the loss value. The network parameters of the first neural network are then adjusted using this loss value until the first neural network converges. This converged first neural network is then used as the topic recognition model.
[0059] For example, the first neural network can be a convolutional neural network (CNN) or a recurrent neural network (RNN), etc., and the embodiments disclosed herein do not specifically limit it.
[0060] S105. Using each sample and its corresponding label, train a second neural network to obtain a fragment recognition model. This fragment recognition model is used to identify whether a text fragment is an illegal fragment.
[0061] Each positive and negative sample can be input into the second neural network separately to obtain its output, which indicates whether the sample is a violation segment. Then, using a preset loss function, the error between the output and the sample label is calculated to obtain the loss value. The network parameters of the second neural network are then adjusted using the loss value until the second neural network converges. This converged second neural network is then used as the segment recognition model.
[0062] For example, the second neural network may be a long short-term memory network (LSTM) or a bidirectional encoder representation from transformers (BERT), etc., and the embodiments disclosed herein do not specifically limit it.
[0063] In this embodiment of the disclosure, the text topic is identified as a violation topic by the topic recognition model, and the included text fragments contain text to be identified as violation fragments by the fragment recognition model, which are considered violation text. S104 and S105 can be executed sequentially, or S104 and S105 can be executed in parallel, and this embodiment of the disclosure does not specifically limit this.
[0064] This disclosure can identify similar texts to the illegal text and treat each text segment containing the illegal content in the illegal text and similar texts as a positive sample; and treat each text segment in the non-illegal text that does not contain the illegal content as a negative sample. It also sets topic labels and sample labels for the positive and negative samples, trains a topic recognition model using text topics and topic labels, and trains a segment recognition model using positive and negative samples and sample labels. In other words, this disclosure can mine a large number of similar texts from a small number of illegal texts, divide a single text into multiple segments as training samples, and automatically generate labels, thus increasing the number of training samples and reducing reliance on manual annotation, thereby ensuring the generalization of the trained model and improving the model's recognition accuracy, thus improving the accuracy of illegal text recognition. Furthermore, compared to methods that perform overall text recognition, this disclosure can identify illegal text from both text topics and text segments, i.e., identify illegal text from multiple angles, improving the accuracy of identifying illegal text while reducing reliance on manual methods.
[0065] Furthermore, in related technologies, the annotation of illegal text requires training reviewers before they can annotate the text, resulting in a lack of timeliness in the annotation process. This, in turn, makes it difficult to guarantee the timeliness of the recognition model. Moreover, as the volume of text content in information flow recommendation systems increases, the number of reviewers also needs to increase exponentially to meet the large-scale text annotation demands, thus requiring significant human and material resources. However, since the embodiments of this disclosure do not require manual annotation of all training samples, it reduces labor costs and improves the timeliness of model training and practical use.
[0066] The training method of the text recognition model provided in the embodiments of this disclosure will be described in detail below:
[0067] In some embodiments of this disclosure, the method for determining similar text to the violating text in step S101 includes the following steps:
[0068] Step 1: Identify abnormally active authors based on the publication frequency of each author in the current training cycle and in the previous training cycles.
[0069] Among them, the training period can be set according to actual needs. For example, if each day is taken as a training period, then multiple training periods can be within the first 3 days, or within the first 5 days, etc.
[0070] For each author, it is possible to count the number of articles published by the author in each training period during the current training period and the previous N training periods, and determine whether the corresponding article publication frequencies of the author meet the condition of abnormal activity. If they meet, the author is determined to be an abnormally active author; otherwise, the author is determined to be a non-abnormally active author.
[0071] Among them, the condition of abnormal activity can include the following conditions:
[0072] Condition 1: In the nth - Nth training periods in the order from the current training period to the far past, the article publication frequency is 0 for all. Here, 0 < n < N, and n is an integer.
[0073] Condition 2: The article publication frequency in the current training period is not 0.
[0074] Condition 3: In the order from the current training period to the far past, in the current training period - nth training period, the article publication frequency is higher than the preset frequency.
[0075] The condition of abnormal activity can also include other conditions, which are not specifically limited in the embodiments of the present disclosure. The condition of abnormal activity can reflect that the author only publishes articles frequently recently, so the abnormally active author can also be called a recently active author.
[0076] Step 2: From the texts published by the abnormally active author during the current training period, screen out the texts with a similarity higher than the similarity threshold to the illegal texts as the first similar texts.
[0077] For each text published by an active author during the current training period, based on a preset similarity algorithm, calculate the similarity between the text and each illegal text. When the similarity between the text and any illegal text is greater than or equal to the threshold, determine the text as the first similar text. When the similarity between the text and each illegal text is less than the threshold, determine that the text is not the first similar text.
[0078] Among them, the preset similarity algorithm can be a text similarity algorithm such as the hash (simhash) algorithm or the Jaccard distance.
[0079] The similarity threshold can be set according to actual needs. For example, when the similarity value range is [0, 1], set the similarity threshold to 0.8.
[0080] Step 3: From the texts published by each author in the current training period, select texts whose publication time falls within the publication time period of the violation text set as the second similar texts.
[0081] Each training cycle can be divided into multiple time periods, such as half an hour per time period. Then, the time period in which each illegal text was published is obtained, and the time period with the most published times is counted as the time period for the collection of illegal texts.
[0082] Alternatively, the time period for the concentrated release of the illegal texts can be determined by other means, and this embodiment of the disclosure does not specifically limit this.
[0083] Step 4: From the texts published by each author in the current training period, select texts whose paragraphs overlap with those in the violating texts, and use them as the third similar texts.
[0084] For each text published by each author during the current training period, it can be determined whether the paragraphs included in that text overlap with the paragraphs included in each of the violating texts. If the paragraphs included in that text overlap with the paragraphs included in any of the violating texts, then that text is determined to be a third-degree similar text. If the paragraphs included in that text do not overlap with the paragraphs included in any of the violating texts, then that text is determined not to be a third-degree similar text.
[0085] The paragraphs included in the text are the natural paragraphs in the text.
[0086] Step 5: Remove duplicate text from the first, second, and third similar texts, and use the remaining text after deduplication as the similar text to the violating text.
[0087] Since the first, second, and third similar texts were obtained using different methods, there may be duplicate texts. Duplicate texts increase the time required for model training without providing any additional benefits. Therefore, these texts are deduplicated.
[0088] Because the posting frequency of abnormally active authors is uneven across training cycles, and violating texts exhibit short-term, high-frequency characteristics, abnormally active authors are highly likely to be violating authors. Therefore, texts with high similarity to violating texts selected from the current training cycle's posts by abnormally active authors are also likely to be violating texts. Furthermore, violating texts exhibit a concentrated posting time; therefore, texts with posting times close to those of violating texts are also likely violating texts. Additionally, texts containing the same paragraphs as violating texts may also be violating texts. Using the above method, this embodiment of the disclosure can use violating texts as seed data and mine similar texts that are highly likely to be violating texts based on the seed data, thereby automatically mining more violating texts. This approach does not rely on manual intervention, increases the training samples for the model, and improves the model's generalization ability.
[0089] In some embodiments of this disclosure, see Figure 2 The method described in S101 above, which treats each text fragment containing the violating content among the violating text and similar texts as a positive sample, includes the following steps:
[0090] S201. Segment the illegal text and similar text.
[0091] For each violating or similar text, the text can be divided into segments of a fixed length. For example, every three paragraphs can be divided into a segment, or every 500 words can be divided into a segment. This disclosure does not specifically limit the method of segmentation.
[0092] S202. Identify the suspected violation segments among the divided segments.
[0093] Segments containing inappropriate content within the S201 classification can be considered as suspected inappropriate segments. Specific methods will be described later.
[0094] S203. Using multiple text classification models, positive samples are selected from each suspected violation segment.
[0095] The publication time of the violation text obtained in S101 above belongs to the current training cycle. For example, if a training cycle is one day, the violation text can be a text containing inappropriate information that the reviewer reviewed today.
[0096] Multiple text classification models were developed by training a third neural network using positive and negative samples obtained from different historical training periods. Each text classification model was used to identify whether an input segment was a violation segment.
[0097] For example, each day can be used as a training cycle. The positive and negative samples obtained each day are used to train the third neural network to obtain a text classification model. When executing S203, the text classification models trained in the previous (n-1) days are obtained, and each text classification model is used to identify whether each suspected violation segment is a violation segment.
[0098] For example, the third neural network can be a text classification model such as FastText or TextCNN.
[0099] Using the above method, this embodiment of the present disclosure can first filter out suspected illegal segments from illegal text and similar text fragments, and then use multiple text classification models to further filter out positive samples from each suspected illegal segment. Through the two filtering processes, the accuracy of the filtered positive samples is improved. Moreover, using multiple text classification models for filtering further improves the accuracy of the filtered positive samples compared to using a single text classification model.
[0100] In some embodiments of this disclosure, the method for determining suspected illegal segments among the segments in S202 above may include the following steps:
[0101] Step 1: Cluster the paragraphs in the violating text and the paragraphs in similar texts to obtain multiple clusters.
[0102] Optionally, clustering can be based on text similarity algorithms such as the SimHash algorithm or JaCard distance, and this disclosure does not specifically limit this.
[0103] Step 2: Identify clusters with more than a preset threshold of paragraphs as suspected violation clusters.
[0104] Understandably, when the number of paragraphs included in a cluster exceeds a preset threshold, that is, when the cluster includes a large number of paragraphs, it indicates that the paragraphs in the violating text and similar text are concentrated in this cluster. Since the paragraphs in the violating text and similar text are likely violating paragraphs, the paragraphs included in this cluster are likely violating paragraphs. Therefore, this cluster is considered a suspected violating cluster.
[0105] When the number of paragraphs included in a cluster is less than or equal to a preset threshold, that is, the cluster includes fewer paragraphs, and the paragraphs in the violating text and similar text are likely to be violating paragraphs, these outlier paragraphs are likely to be non-violating paragraphs, so the cluster is not considered a suspected violating cluster.
[0106] Step 3: From the divided segments, identify those containing suspected violation paragraphs as suspected violation paragraphs. Suspected violation paragraphs are those included in the suspected violation cluster.
[0107] Since the suspected violation clusters include suspected violation paragraphs that are highly likely to be violation paragraphs, the segments containing suspected violation paragraphs are highly likely to be violation segments. Therefore, the segments containing suspected violation paragraphs are classified as suspected violation segments.
[0108] Using the above method, embodiments of this disclosure can cluster paragraphs in violating text and similar text to find clusters containing a large number of paragraphs. The paragraphs contained in these clusters are likely violating paragraphs, and therefore the segment to which these paragraphs belong is likely a violating segment. It is evident that, using the above method, embodiments of this disclosure can more accurately identify suspected violating segments.
[0109] In some embodiments of this disclosure, the method of clustering each paragraph in the illegal text and each paragraph in the similar text to obtain multiple clusters in step 1 above can be implemented as follows: using a first clustering algorithm, each paragraph in the illegal text and each paragraph in the similar text are clustered to obtain multiple first-level clusters. Then, for each first-level cluster, a second clustering algorithm is used to cluster each paragraph included in that first-level cluster to obtain multiple second-level clusters.
[0110] The first clustering algorithm and the second clustering algorithm are different. For example, the first clustering algorithm can be a clustering algorithm based on the SimHash algorithm, and the second clustering algorithm can be a clustering algorithm based on Jacard distance. Alternatively, the first clustering algorithm and the second clustering algorithm can also be other text clustering algorithms, which are not specifically limited in this embodiment.
[0111] Accordingly, the method of determining the clusters with more than a preset threshold of paragraphs as suspected violation clusters in step 2 above can be implemented as follows: the secondary clusters with more than a preset threshold of paragraphs are identified as suspected violation clusters.
[0112] Using the above method, the present invention can perform two clustering operations on paragraphs in the illegal text and similar text. The similarity between paragraphs included in the second-level cluster is generally higher than that of the first-level cluster. Therefore, the accuracy of identifying suspected illegal clusters from the second-level cluster is higher, which further improves the accuracy of identifying suspected illegal segments.
[0113] In some embodiments of this disclosure, the method of using multiple text classification models to filter positive samples from each suspected violation segment in S203 above includes the following steps:
[0114] Step (1): For each suspected violation segment, use multiple text classification models to identify whether the suspected violation segment is a violation segment.
[0115] Each suspected violation segment is input into multiple text classification models, and the identification result of each model is obtained. The identification result is used to indicate whether the suspected violation segment is indeed a violation segment.
[0116] Step (2): If the ratio between the number of times the suspected violation segment is identified as a violation segment and the number of text classification models is greater than the preset first ratio, then the suspected violation segment is taken as a positive sample.
[0117] The first preset ratio is greater than 0.5. When the ratio between the number of times the suspected violation segment is identified as a violation segment and the number of text classification models is greater than the first preset ratio, it means that most text classification models consider the suspected violation segment to be a violation segment, and therefore the suspected violation segment is taken as a positive sample.
[0118] In this embodiment of the disclosure, if the ratio between the number of times the suspected violation segment is identified as a violation segment and the number of text classification models is less than or equal to a preset first ratio, then the suspected violation segment is determined to be a non-positive sample.
[0119] The first preset ratio is greater than 0.5. When the ratio between the number of times the suspected violation segment is identified as a violation segment and the number of text classification models is less than or equal to the first preset ratio, it means that most text classification models consider the suspected violation segment to be a non-violation segment, and therefore determine that the suspected violation segment is not a positive sample.
[0120] This disclosure embodiment can utilize multiple text classification models to further clean the mined suspected violation segments, thereby filtering out suspected violation segments that are identified as violation segments by most text classification models and using them as positive samples. That is, filtering out suspected violation segments with higher confidence as positive samples, thereby improving the accuracy of determining positive samples.
[0121] In this embodiment of the disclosure, the identification result of the text classification model for the suspected violation segment includes the position of the violation content within the suspected violation segment. For example, the output of the text classification model is two arrays. Each element in the first array represents whether a character in the input suspected violation segment is the starting position of the violation content; that is, the first array marks the starting position of the violation content. Each element in the second array represents whether a character in the input suspected violation segment is the ending position of the violation content; that is, the second array marks the ending position of the violation content.
[0122] For example, the text classification model identifies the suspected violation fragment as [0,1,0,0,0,0,0,1,0,0] and [0,0,0,0,1,0,0,0,0,1]. Each element in these two arrays corresponds to a character in the suspected violation fragment. From the identification results, it can be seen that the second character in the suspected violation fragment is the starting position of the violation content, and the fifth character is the ending position of the violation content. Therefore, the first violation content is between the second and fifth characters. Similarly, the second violation content is between the eighth and tenth characters in the suspected violation fragment.
[0123] As can be seen, the location of the violation content in the input text fragment can be determined through the text classification model. Therefore, after obtaining the positive samples in S101 above, data augmentation can be performed on the positive samples. Specifically, for each positive sample, the violation content in the positive sample is determined based on the location of the violation content identified by multiple text classification models; at least one data augmentation process is performed on the violation content in the positive sample, and each data augmentation result is taken as a positive sample.
[0124] Each data augmentation process includes: deleting some text, inserting some text, replacing some text, reversing the order of some text, replacing some text with similar-looking characters, replacing some text with homophones, converting some text to pinyin, replacing some text with synonyms, splitting some text into radicals and / or inserting punctuation marks, etc.
[0125] Optionally, for each positive sample, the intersection of the violations identified by each text classification model for that positive sample can be taken as the violation content in that positive sample; or the union of the violations identified by each text classification model for that positive sample can be taken as the violation content in that positive sample; or the violation content identified by one of the text classification models for that positive sample can be taken as the violation content in that positive sample. Alternatively, the violation content in the positive sample can be determined in other ways, which are not specifically limited in this embodiment.
[0126] In this embodiment of the disclosure, for each positive sample, at least one data augmentation process can be performed on the illegal content in the positive sample, while keeping the content in other positions of the positive sample unchanged, and the new text fragment obtained after data augmentation is also used as a positive sample.
[0127] For example, a positive sample is: "This is a bad text." Here, "bad text" refers to the illegal content. Replacing some of the characters in the illegal content with similar-looking characters results in "This is a bad text"; replacing some of the characters in the illegal content with homophones results in "This is a bad text"; or converting some of the characters in the illegal content to pinyin results in "This is a bad text".
[0128] Optionally, data augmentation can be performed on each positive sample a preset number of times. During each data augmentation, at least one data augmentation process is applied to the violation content in the positive sample, and the selected data augmentation process is different each time.
[0129] For example, for each positive sample selected using multiple text classification models, each time data augmentation is performed on the positive sample, at least one data augmentation process is randomly selected, and the data augmentation process is performed on the illegal content in the positive sample. The result of this data augmentation is then used as a positive sample.
[0130] Currently, the identification of illegal texts relies entirely on manual annotation, and the forms of illegal texts change extremely quickly. Whenever a new form of illegal text appears, it is necessary to retrain the reviewers, resulting in poor timeliness of illegal text identification.
[0131] The embodiments of this disclosure can perform at least one data augmentation process on the illegal content in the positive samples, and use each data augmentation result as a positive sample. The positive samples obtained after data augmentation are used to train the model, so that the model has good generalization ability, strong adversarial ability to changes in illegal text, improve the recall ability of the model, and improve the timeliness and accuracy of illegal text identification.
[0132] In some embodiments of this disclosure, see Figure 3 The method described in S103 above, which treats each text segment in non-violation text that does not contain violation content as a negative sample, includes the following steps:
[0133] S301. Divide non-violation text into segments.
[0134] In this embodiment of the disclosure, the publication time of the non-violation text obtained in S103 belongs to the current training cycle. For example, if a training cycle is one day, texts that do not contain harmful information and are reviewed by the reviewers within the current training cycle can be obtained and used as non-violation texts.
[0135] For a detailed implementation of S301, please refer to S201 above.
[0136] S302. Using multiple text classification models, negative samples are selected from the segmented fragments.
[0137] The multiple text classification models are obtained by training a third neural network using positive and negative samples acquired from different historical training periods. Each text classification model is used to identify whether an input segment is a violation segment.
[0138] The method for determining multiple text classification models can be found in the relevant description in S203 above, and will not be repeated here.
[0139] By using the above method, the embodiments of this disclosure can utilize multiple text classification models to filter out negative samples from various segments of non-violation text, thereby improving the accuracy of the filtered negative samples compared to using a single text classification model.
[0140] In some embodiments of this disclosure, the above-mentioned method of using multiple text classification models to filter out negative samples from the divided segments can be implemented as follows: for each segment, multiple text classification models are used to identify whether the segment is a violation segment. If the ratio between the number of times the segment is identified as a non-violation segment and the number of text classification models is greater than a preset second ratio, then the segment is regarded as a negative sample.
[0141] The specific method for selecting negative samples from the segmented fragments using multiple text classification models can be found in the method for selecting positive samples using multiple text classification models described above, and will not be repeated here.
[0142] The preset second ratio is greater than 0.5. If the ratio between the number of times the segment is identified as a non-violation segment and the number of text classification models is less than or equal to the preset second ratio, then the segment is determined not to be a negative sample.
[0143] In this embodiment of the disclosure, the preset first ratio used to determine positive samples and the preset second ratio used to determine negative samples may be the same or different.
[0144] This disclosure embodiment can utilize multiple text classification models to clean up fragments in non-violation text, thereby filtering out text fragments that are identified as non-violation fragments by most text classification models and using them as negative samples. That is, it filters out text fragments with higher confidence from non-violation text as negative samples, thereby improving the accuracy of determining negative samples.
[0145] In some embodiments of this disclosure, after obtaining the positive and negative samples in the current training period, a text classification model can be trained using these samples. The specific training method includes the following steps:
[0146] Step 1: Input the positive and negative samples acquired during the current training cycle into the third neural network to obtain the recognition results of the third neural network. The recognition results indicate whether the input sample is a violation segment.
[0147] Step II: Based on the recognition results of the third neural network, train the third neural network and use the trained third neural network as a text classification model.
[0148] Determine the error between the recognition result of the third neural network and the sample label of the input sample to obtain the loss value. Using gradient descent, adjust the network parameters of the third neural network based on the loss value, and return to step I until the third neural network converges. Then, use the current third neural network as a text classification model.
[0149] Optionally, the convergence of the third neural network can be determined when the number of iterations during training reaches a preset number, or when the loss value calculated in the current iteration is less than a preset value, or when the difference between the loss value calculated in the current iteration and the loss value calculated in the previous iteration is less than a preset difference. Alternatively, other methods can be used to determine whether the third neural network has converged, and this embodiment of the disclosure does not specifically limit this method.
[0150] Using the above method, this embodiment of the present disclosure can train a text classification model using the positive and negative samples obtained in the current training cycle, so that when screening positive and negative samples in subsequent training cycles, the text classification model can be used for screening, thereby improving the timeliness of the text classification model used when screening positive and negative samples.
[0151] Based on the same inventive concept, this disclosure also provides a text recognition method, which is applied to an electronic device, such as a server, desktop computer, or laptop computer, etc., that has text recognition capabilities. The electronic device used for training the text recognition model and the electronic device used for the text recognition method may be the same device or different devices; this disclosure does not specifically limit this.
[0152] like Figure 4 As shown, the text recognition method provided in this embodiment includes the following steps:
[0153] S401. Obtain the subject of the text to be recognized and segment the text to be recognized.
[0154] The methods for obtaining the subject of the text to be identified and for segmenting the text into fragments can be referred to the above descriptions, and will not be repeated here.
[0155] The text to be recognized can be plain text published by the user on the network platform, text in images and text, text descriptions in videos, text recognized from images, or text converted from speech, etc. This disclosure does not specifically limit this.
[0156] S402. Use a topic recognition model to identify whether the topic to be identified is a violation topic.
[0157] The topic recognition model is a model obtained by training the first neural network using the training method described above for the model used to recognize text.
[0158] For example, the topic to be identified can be input into a topic recognition model to obtain the output result. The output result is 1 or 0, where 1 indicates that the topic to be identified is a violation topic; 0 indicates that the topic to be identified is a non-violation topic.
[0159] S403. Use a fragment recognition model to identify whether each fragment in the text to be recognized is a violation fragment.
[0160] The fragment recognition model is a model obtained by training the second neural network using the training method described above for the text recognition model.
[0161] The text to be recognized can be segmented, and each segment can be input into a segment recognition model to obtain the output of the segment recognition model for each segment. The output consists of two arrays: the first array contains elements indicating whether a character in the input segment is the start position of the violation; the second array contains elements indicating whether a character in the input segment is the end position of the violation.
[0162] If the segment recognition model outputs two arrays for a segment, and either the starting position or ending position of the illegal content is absent, or the starting position of the illegal content is not before the ending position of the illegal content, then the segment is determined to be non-illegal and does not contain illegal content. For example, if both arrays contain 0 elements, or if the first array indicates that the illegal content starts at the 8th character and the second array indicates that the illegal content ends at the 5th character, and 5 < 8, then the segment does not contain illegal content.
[0163] If the fragment recognition model outputs two arrays for a fragment, indicating the start and end positions of the illegal content, and the start position of the illegal content is before the end position of the illegal content, then the fragment is determined to contain illegal content, i.e., it is an illegal fragment.
[0164] S404. If the topic to be identified is a violation topic, and there are violation segments in the text to be identified, then the text to be identified is determined to be a violation text.
[0165] In this embodiment, S402 and S403 can be executed sequentially or in parallel. To improve the recognition efficiency of the text to be recognized, when the topic recognition model identifies that the topic to be recognized is not a violation topic, S403 can be omitted; similarly, when the fragment recognition model identifies that there are no violation fragments in the text to be recognized, S402 can be omitted; and the text to be recognized can be directly determined to be non-violation text.
[0166] In this embodiment of the disclosure, since neither the topic recognition model nor the fragment recognition model completely relies on manually labeled samples, the dependence on manual labeling is reduced. Therefore, the model has high accuracy, stability and timeliness, and also reduces labor costs.
[0167] Furthermore, compared to methods that identify the entire text, this disclosure embodiment can also identify text from two aspects: the text topic and the text fragments. Only when the topic of the text to be identified is a violation topic and it contains violation fragments is it determined to be violation text. That is, violation text is identified from multiple perspectives, improving the accuracy of identifying violation text. Therefore, this disclosure embodiment can improve the accuracy of identifying violation text while reducing reliance on manual labor.
[0168] In some embodiments of this disclosure, before obtaining the subject of the text to be identified in step S401 and segmenting the text, a preliminary determination of whether the text to be identified is illegal can be made based on the author of the text. The preliminary determination includes the following steps:
[0169] Step (1): Determine the author of the text to be identified and whether the author is in the preset whitelist.
[0170] The author who publishes the text to be identified is the author to be identified. The author to be identified can be represented by the author's name or by the Internet Protocol (IP) used by the author.
[0171] The preset whitelist includes pre-defined authors who have not violated regulations.
[0172] Step (2): If the author to be identified is not in the preset whitelist, determine whether the author to be identified is an abnormally active author based on the posting frequency of the author within the specified time period.
[0173] The specified time period can be divided into multiple time periods, and the posting frequency of the author to be identified within each time period can be determined. It can then be judged whether the posting frequency of the author to be identified meets the criteria for abnormal activity. If it does, the author is identified as an abnormally active author; otherwise, the author is identified as a non-abnormally active author. The criteria for abnormal activity are described above and will not be repeated here.
[0174] The specified time period can be set according to actual needs. For example, if the specified time period is the previous 5 days, the posting frequency of the author to be identified can be counted each day during the previous 5 days, and it can be determined whether the posting frequency during these 5 days meets the activity criteria.
[0175] Step (3): If the author to be identified is an abnormally active author, then execute the above steps of S401 to obtain the subject of the text to be identified and to segment the text to be identified.
[0176] In addition, if the author to be identified is not an abnormally active author, or if the author to be identified is within the preset whitelist, then the text to be identified is determined to be non-violation text.
[0177] Because the posting frequency of the author to be identified is uneven across different time periods, and the violating text exhibits short-term high-frequency characteristics, the author to be identified is very likely to be a violating author. Different authors have different posting habits, and there may be normal authors with short-term high posting frequencies; therefore, this embodiment of the disclosure sets up a whitelist for these authors. When the author to be identified is an abnormally active author and is not on the whitelist, it indicates that the author to be identified is very likely to be a violating author, therefore... Figure 4 This method further identifies the text to be identified, improving the accuracy of identifying illegal text.
[0178] If the author to be identified is not an abnormally active author, or is within a preset whitelist, then the author to be identified is likely not a violator. Therefore, the text to be identified can be directly determined to be non-violator text, without needing to use the model for identification, thus improving the identification efficiency of the text to be identified.
[0179] Furthermore, the embodiments disclosed herein can comprehensively determine whether the text to be identified is illegal text from multiple perspectives, including the author, the subject of the text, and the text fragments, thereby improving the accuracy and recall rate of illegal text identification.
[0180] After identifying inappropriate text, it's possible to set the option for the inappropriate text to fail review, thus directly removing it from the platform without further manual review, improving the efficiency of inappropriate text review. Furthermore, it reduces the possibility of inappropriate text being pushed to users in subsequent content distribution stages, ensuring the security of online text content.
[0181] Furthermore, after identifying the illegal text, it can be used as seed data so that similar text mining can be performed based on the illegal text in subsequent training cycles.
[0182] See Figure 5 The following describes the training method for the text recognition model and the overall process of the text recognition method provided in this disclosure, in conjunction with application scenarios:
[0183] First, data mining is performed. The cleaned segments of the non-violation text obtained after review are used as negative samples. Then, the violation text obtained after review is used as seed data, and similar texts are obtained through data expansion based on the violation text. The SimHash algorithm is used to cluster each paragraph in the violation text and each paragraph in the similar text, resulting in multiple first-level clusters. The Jacard distance algorithm is used to cluster each paragraph in the first-level clusters, resulting in multiple second-level clusters. Second-level clusters with more than a preset threshold of included paragraphs are identified as suspected violation clusters, and paragraphs within these suspected violation clusters are identified as suspected violation paragraphs.
[0184] Next, the training data is constructed as follows: The violating text and similar text are segmented into fragments. Fragments containing suspected violating paragraphs are designated as suspected violating fragments. Multiple text classification models are used to clean the suspected violating fragments, and the cleaned fragments are used as positive samples. Violating content in the positive samples is augmented with data, and the augmented fragments are also used as positive samples. Using the text topics and topic labels of the positive and negative samples, a CNN is trained to obtain a topic recognition model. Finally, using the positive and negative samples and sample labels, an LSTM is trained to obtain a fragment recognition model.
[0185] Next, violation text identification is performed. Specifically, for the text to be identified, the author is determined. If the author is not an abnormally active author or is within a preset whitelist, the text is considered non-violation text. If the author is an abnormally active author and is not within the preset whitelist, a topic identification model is used to determine if the topic of the text is a violation topic, and a fragment identification model is used to determine if the text contains violation fragments. If the topic is a violation topic and the text contains violation fragments, the text is considered violation text. If the topic is not a violation topic, or the text does not contain violation fragments, the text is considered non-violation text. Violation texts are then added to seed data for subsequent data mining.
[0186] This disclosed embodiment forms a closed-loop strategy encompassing sample mining, model training, and model recognition. The steps are clearly ordered and standardized, reducing manual intervention and the associated manpower and resources. Furthermore, because the fragment recognition model and topic recognition model can automatically iterate and further optimize recognition during the iteration process, the model's recognition accuracy and recall rate are improved.
[0187] The collection, storage, use, processing, transmission, provision, and disclosure of text information involved in the technical solution disclosed herein all comply with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0188] Based on the same inventive concept, corresponding to the above method embodiments, this disclosure also provides a training apparatus for a model for recognizing text, such as... Figure 6 As shown, the device includes: a determining module 601, a setting module 602, an acquiring module 603, and a training module 604;
[0189] The determination module 601 is used to determine similar texts of the violating text and to treat each text fragment containing the violating content in the violating text and similar texts as a positive sample;
[0190] The setting module 602 is used to set the topic label of each positive sample to the violation topic and the sample label of each positive sample to the violation fragment. The topic label is the label of the text topic of the text to which the text fragment belongs.
[0191] The acquisition module 603 is used to acquire non-violation text, take each text segment in the non-violation text that does not contain violation content as a negative sample, set the topic tag of each negative sample to a non-violation topic, and set the sample tag of each negative sample to a non-violation segment.
[0192] Training module 604 is used to train the first neural network using the text topic to which each sample belongs and the topic label of each text topic to obtain the topic recognition model. The topic recognition model is used to identify whether the text topic is an illegal topic.
[0193] The training module 604 is also used to train a second neural network using each sample and its corresponding sample label to obtain a fragment recognition model. The fragment recognition model is used to identify whether a text fragment is an illegal fragment.
[0194] In some embodiments of this disclosure, the publication time of the violating text belongs to the current training cycle; the determination module 601 is specifically used for:
[0195] Segment the illegal and similar texts;
[0196] Identify the suspected violation segments within each segment division;
[0197] Multiple text classification models are used to filter out positive samples from suspected violation segments. The multiple text classification models are models obtained by training a third neural network based on positive and negative samples obtained in different historical training periods.
[0198] In some embodiments of this disclosure, the determining module 601 is specifically used for:
[0199] For each suspected violation segment, multiple text classification models are used to identify whether the suspected violation segment is indeed a violation segment;
[0200] If the ratio between the number of times the suspected violation segment is identified as a violation segment and the number of text classification models is greater than a preset first ratio, then the suspected violation segment is treated as a positive sample.
[0201] In some embodiments of this disclosure, the determining module 601 is specifically used for:
[0202] The paragraphs in the violating text and the paragraphs in similar texts are clustered to obtain multiple clusters;
[0203] Clusters containing more than a preset threshold of paragraphs are identified as suspected violation clusters;
[0204] From the segmented segments, segments containing suspected violation paragraphs are designated as suspected violation segments, and suspected violation paragraphs are the paragraphs included in the suspected violation cluster.
[0205] In some embodiments of this disclosure, the determining module 601 is specifically used for:
[0206] Using the first clustering algorithm, each paragraph in the violating text and each paragraph in similar text are clustered to obtain multiple first-level clusters;
[0207] For each primary cluster, the second clustering algorithm is used to cluster the segments included in the primary cluster to obtain multiple secondary clusters;
[0208] Module 601 is specifically used for:
[0209] Secondary clusters containing more than a preset threshold of paragraphs are identified as suspected violation clusters.
[0210] In some embodiments of this disclosure, the text classification model's identification result for suspected infringing segments includes the location of the infringing content within the suspected infringing segment; the determination module 601 is further configured to:
[0211] For each positive sample, the illegal content in the positive sample is determined based on the location of the illegal content identified by multiple text classification models.
[0212] Perform at least one data augmentation process on the violation content in the positive sample, and treat each data augmentation result as a positive sample.
[0213] In some embodiments of this disclosure, the publication time of the non-violation text belongs to the current training period; the acquisition module 603 is specifically used for:
[0214] Divide non-violation text into segments;
[0215] Using multiple text classification models, negative samples are selected from the segmented fragments; the multiple text classification models are models obtained by training a third neural network based on positive and negative samples obtained in different historical training periods.
[0216] In some embodiments of this disclosure, the acquisition module 603 is specifically used for:
[0217] For each segment, multiple text classification models are used to identify whether the segment is a violation segment;
[0218] If the ratio between the number of times a segment is identified as a non-violation segment and the number of text classification models is greater than a preset second ratio, then the segment is treated as a negative sample.
[0219] In some embodiments of this disclosure, the training module 604 is further configured to:
[0220] The positive and negative samples obtained in the current training cycle are input into the third neural network to obtain the recognition result of the third neural network. The recognition result is used to indicate whether the input sample is a violation segment.
[0221] Based on the recognition results of the third neural network, the third neural network is trained, and the trained third neural network is used as a text classification model.
[0222] In some embodiments of this disclosure, the determining module 601 is specifically used for:
[0223] Based on the posting frequency of each author in the current training cycle and in the previous training cycles, identify abnormally active authors.
[0224] From the texts published by abnormally active authors during the current training period, texts with a similarity higher than the similarity threshold with the violating texts are selected as the first similar texts;
[0225] From the texts published by each author in the current training cycle, texts whose publication time falls within the publication time period of the violation text set are selected as the second most similar texts;
[0226] From the texts published by each author in the current training cycle, texts whose paragraphs overlap with those in the violating texts are selected as the third similar texts;
[0227] Remove duplicate text from the first, second, and third similar texts, and use the remaining text after deduplication as the similar text to the violating text.
[0228] Based on the same inventive concept, corresponding to the above method embodiments, this disclosure also provides a text recognition device, see [link to relevant documentation]. Figure 7The device includes: an acquisition module 701, an identification module 702, and a determination module 703;
[0229] The acquisition module 701 is used to acquire the subject of the text to be recognized and to segment the text to be recognized into fragments;
[0230] The identification module 702 is used to identify whether the topic to be identified is an illegal topic using a topic identification model. The topic identification model is a model obtained by training the first neural network using a training method for models used to identify text.
[0231] The recognition module 702 is also used to identify whether each segment of the text to be recognized is a violation segment using a segment recognition model; the segment recognition model is a model obtained by training a second neural network using a training method for a model used to recognize text.
[0232] The determination module 703 is used to determine that the text to be identified is illegal text if the topic to be identified is an illegal topic and there are illegal segments in the text to be identified.
[0233] In some embodiments of this disclosure, the determining module 703 is further configured to:
[0234] Before obtaining the subject of the text to be identified and segmenting the text to be identified, determine the author of the text to be identified and whether the author is in the preset whitelist.
[0235] If the author to be identified is not in the preset whitelist, the identification of the author as an abnormally active author will be determined based on the posting frequency of the author within the specified time period.
[0236] If the author to be identified is an abnormally active author, the acquisition module 701 is called to perform the steps of acquiring the subject of the text to be identified and segmenting the text to be identified.
[0237] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0238] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement embodiments of the present disclosure is shown. 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.
[0239] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. The RAM 803 may also store various programs and data required for the operation of the device 800. The computing unit 801, ROM 802, and RAM 803 are interconnected via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0240] Multiple components in electronic device 800 are connected to I / O interface 805, including: input unit 806, such as keyboard, mouse, etc.; output unit 807, such as various types of displays, speakers, etc.; storage unit 808, such as disk, optical disk, etc.; and communication unit 809, such as network card, modem, wireless transceiver, etc. Communication unit 809 allows electronic device 800 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0241] The computing unit 801 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 801 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 801 performs the various methods and processes described above, such as training methods for models for recognizing text and text recognition methods. For example, in some embodiments, the training methods for models for recognizing text and text recognition methods can be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 808. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 800 via ROM 802 and / or communication unit 809. When the computer program is loaded into RAM 803 and executed by the computing unit 801, one or more steps of the training methods for models for recognizing text and text recognition methods described above can be performed. Alternatively, in other embodiments, the computing unit 801 may be configured by any other suitable means (e.g., by means of firmware) to perform a training method for a model for recognizing text and a text recognition method.
[0242] 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), complex 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.
[0243] 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.
[0244] 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.
[0245] 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).
[0246] 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.
[0247] 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.
[0248] 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.
[0249] 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 model for identifying text, comprising: Determine similar texts of the illegal text; Segment the illegal text and the similar texts; Determine suspected illegal segments in each of the segmented segments; Use multiple text classification models to screen out positive samples from each suspected illegal segment; wherein, the release time of the illegal text belongs to the current training cycle, and the multiple text classification models are models obtained by training a third neural network based on positive and negative samples acquired within different historical training cycles; Set the topic label of each positive sample to the illegal topic, and set the sample label of each positive sample to the illegal segment, where the topic label is the label of the text topic to which the text segment belongs; Obtain non-illegal texts, use each text segment that does not contain illegal content in the non-illegal texts as a negative sample, set the topic label of each negative sample to the non-illegal topic, and set the sample label of each negative sample to the non-illegal segment; Use the text topic to which each sample belongs and the topic labels of each text topic to train a first neural network to obtain a topic recognition model, where the topic recognition model is used to identify whether the text topic is an illegal topic; Use each sample and the sample label corresponding to each sample to train a second neural network to obtain a segment recognition model, where the segment recognition model is used to identify whether a text segment is an illegal segment.
2. The method according to claim 1, wherein The using multiple text classification models to screen out positive samples from each suspected illegal segment includes: For each suspected illegal segment, use multiple text classification models to identify whether the suspected illegal segment is an illegal segment; If the ratio between the number of times the suspected illegal segment is identified as an illegal segment and the number of text classification models is greater than a preset first ratio, then use the suspected illegal segment as a positive sample.
3. The method according to claim 1, wherein The determining suspected illegal segments in each of the segmented segments includes: Cluster each paragraph in the illegal text and each paragraph in the similar texts to obtain multiple clusters; Determine a cluster with the number of included paragraphs greater than a preset threshold as a suspected illegal cluster; From each of the segmented segments, use the segment containing a suspected illegal paragraph as a suspected illegal segment, where the suspected illegal paragraph is the paragraph included in the suspected illegal cluster.
4. The method according to claim 3, wherein The clustering each paragraph in the illegal text and each paragraph in the similar texts to obtain multiple clusters includes: Use a first clustering algorithm to cluster each paragraph in the illegal text and each paragraph in the similar texts to obtain multiple first-level clusters; For each first-level cluster, use a second clustering algorithm to cluster each paragraph included in the first-level cluster to obtain multiple second-level clusters; The determining a cluster with the number of included paragraphs greater than a preset threshold as a suspected illegal cluster includes: Determine a second-level cluster with the number of included paragraphs greater than the preset threshold as a suspected illegal cluster.
5. The method according to claim 1, wherein The recognition result of the text classification model for the suspected illegal segment includes the position of the illegal content within the suspected illegal segment; After using each text segment containing illegal content in the illegal text and the similar texts as a positive sample, the method further includes: For each positive sample, determine the illegal content in the positive sample according to the positions of the illegal content in the positive sample identified by the multiple text classification models; Perform at least one data augmentation process on the illegal content in the positive sample, and use each data augmentation result as a positive sample.
6. The method according to claim 1, wherein The release time of the non-illegal text belongs to the current training cycle; the step of using each text segment that does not contain illegal content in the non-illegal text as a negative sample includes: Divide the non-illegal text into segments; Use multiple text classification models to screen out negative samples from the divided segments; wherein, the multiple text classification models are models obtained by training a third neural network based on positive and negative samples obtained in different historical training cycles.
7. The method according to claim 6, wherein, The step of using multiple text classification models to screen out negative samples from the divided segments includes: For each divided segment, use multiple text classification models to identify whether the segment is an illegal segment; If the ratio between the number of times the segment is identified as a non-illegal segment and the number of text classification models is greater than a preset second ratio, then use the segment as a negative sample.
8. The method according to any one of claims 1-7, the method further includes: Input the positive and negative samples obtained in the current training cycle into the third neural network respectively, and obtain the recognition result of the third neural network, where the recognition result is used to indicate whether the input sample is an illegal segment; Based on the recognition result of the third neural network, train the third neural network, and use the trained third neural network as a text classification model.
9. The method according to any one of claims 1-7, wherein The step of determining similar texts of the illegal text includes: Determine abnormal active authors according to the posting frequencies of each author in the current training cycle and multiple training cycles before the current training cycle; From the texts published by the abnormal active authors in the current training cycle, screen out texts with a similarity higher than a similarity threshold with the illegal text as the first similar texts; From the texts published by each author in the current training cycle, screen out texts whose release time is within the concentrated release time period of the illegal texts as the second similar texts; From the texts published by each author in the current training cycle, screen out texts whose included paragraphs overlap with the paragraphs included in the illegal text as the third similar texts; Remove duplicate texts from the first similar texts, the second similar texts and the third similar texts, and use the remaining texts after deduplication as the similar texts of the illegal text.
10. A text recognition method, including: Obtain the to-be-recognized theme of the to-be-recognized text, and divide the to-be-recognized text into segments; Use a theme recognition model to identify whether the to-be-recognized theme is an illegal theme, where the theme recognition model is a model obtained by training a first neural network by the method according to any one of claims 1-9; Use a segment recognition model to identify whether each segment included in the to-be-recognized text is an illegal segment; the segment recognition model is a model obtained by training a second neural network model by the method according to any one of claims 1-9; If the to-be-identified theme is a violation theme and there are violation segments in the to-be-identified text, then determine that the to-be-identified text is a violation text.
11. The method according to claim 10, before obtaining the to-be-identified theme of the to-be-identified text and segmenting the to-be-identified text, the method further includes: Determine the to-be-identified author of the to-be-identified text and determine whether the to-be-identified author is within a preset whitelist; If the to-be-identified author is not within the preset whitelist, then determine whether the to-be-identified author is an abnormally active author according to the posting frequency of the to-be-identified author within a specified time period; If the to-be-identified author is an abnormally active author, then perform the steps of obtaining the to-be-identified theme of the to-be-identified text and segmenting the to-be-identified text.
12. A training device for a model for text recognition, including: A determination module, configured to determine similar texts of the violation text, segment the violation text and the similar texts, determine suspected violation segments in each segmented segment, and use multiple text classification models to screen out positive samples from each suspected violation segment; wherein, the release time of the violation text belongs to the current training cycle, and the multiple text classification models are respectively models obtained by training a third neural network based on positive samples and negative samples obtained within different historical training cycles; A setting module, configured to set the theme label of each positive sample as a violation theme and set the sample label of each positive sample as a violation segment, where the theme label is a label of the text theme to which the text segment belongs; An acquisition module, configured to acquire non-violation texts, use each text segment that does not contain violation content in the non-violation texts as a negative sample, set the theme label of each negative sample as a non-violation theme, and set the sample label of each negative sample as a non-violation segment; A training module, configured to train a first neural network using the text theme to which each sample belongs and the theme labels of each text theme to obtain a theme recognition model, where the theme recognition model is used to identify whether the text theme is a violation theme; The training module is further configured to train a second neural network using each sample and the sample label corresponding to each sample to obtain a segment recognition model, where the segment recognition model is used to identify whether a text segment is a violation segment.
13. The device according to claim 12, wherein The determination module is specifically configured to: For each suspected violation segment, use multiple text classification models to identify whether the suspected violation segment is a violation segment; If the ratio between the number of times the suspected violation segment is identified as a violation segment and the number of text classification models is greater than a preset first ratio, then use the suspected violation segment as a positive sample.
14. A text recognition device, including: An acquisition module, configured to acquire the to-be-identified theme of the to-be-identified text and segment the to-be-identified text; An identification module, configured to use a theme recognition model to identify whether the to-be-identified theme is a violation theme, where the theme recognition model is a model obtained by training a first neural network by the method according to any one of claims 1-9. The recognition module is further configured to use a segment recognition model to recognize whether each segment included in the text to be recognized is a violation segment, and the segment recognition model is a model obtained by training a second neural network by using the method according to any one of claims 1-9; The determination module is configured to determine that the text to be recognized is a violation text if the subject to be recognized is a violation subject and there is a violation segment in the text to be recognized.
15. The apparatus according to claim 14, wherein the determination module is further configured to: Before obtaining the subject to be recognized of the text to be recognized and dividing the text to be recognized into segments, determine the author to be recognized of the text to be recognized, and determine whether the author to be recognized is within a preset whitelist; If the author to be recognized is not within the preset whitelist, determine whether the author to be recognized is an abnormally active author according to the posting frequency of the author to be recognized within a specified time period; If the author to be recognized is an abnormally active author, call the obtaining module to execute the steps of obtaining the subject to be recognized of the text to be recognized and dividing the text to be recognized into segments.
16. An electronic device, comprising: At least one processor; And A memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute the method according to any one of claims 1-9, 10 or 11.
17. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the method according to any one of claims 1-9, 10 or 11.
18. A computer program product, comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1-9, 10 or 11.