A BERT-based illegal text recognition algorithm and device
By combining keyword matching with probability distribution analysis and similarity filtering of the BERT model, the problem of low accuracy and efficiency in the identification of illegal text in existing technologies is solved, and efficient and low-cost illegal text identification is achieved.
Patent Information
- Application Number
- CN202110246185.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-05
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2041-03-05
AI Technical Summary
In existing technologies, keyword matching algorithms have a high false alarm rate when identifying illegal text on the Internet, and sentiment analysis models have high training costs and insufficient robustness, resulting in low accuracy and efficiency in identifying illegal text.
We employ a BERT-based algorithm for identifying inappropriate text, combining keyword matching and sentiment analysis. Through probability distribution analysis, threshold filtering, and similarity filtering, we utilize the BERT text recognition model to classify and label sensitive text.
It improves the accuracy and efficiency of identifying illegal text, reduces manpower and time costs, and decreases the number of false alarms.
Smart Images

Figure CN113011171B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, specifically to the field of big data and deep learning technology, and provides a BERT-based illegal text recognition algorithm and device. Background Art
[0002] The Internet is an important tool for people to obtain information. With the development of the Internet, the threshold for publishing information on the Internet is getting lower and lower, resulting in a large number of illegal texts on the Internet that are not suitable for display to users. Illegal text recognition is to find those illegal texts in a massive amount of text.
[0003] In the prior art, keyword matching algorithms are generally used to identify illegal texts on the Internet. The keyword matching algorithm requires presetting some sensitive words, and then extracting sentences containing sensitive words as sensitive texts through the keyword matching algorithm. However, when using the keyword matching algorithm to identify sensitive texts, it is just a simple screening of sensitive texts. Since the contexts in which sensitive words are located are different, sensitive texts may not necessarily be illegal texts. Therefore, the recognition results of the keyword matching algorithm will contain a large amount of non-illegal texts, and the number of false positives is large.
[0004] In order to reduce the number of false positives of illegal texts, in the prior art, sentiment analysis methods are also used on the basis of keyword matching algorithms to further determine whether the sensitive text identified by the keyword matching algorithm is illegal text by judging the positive and negative sentiment tendencies of sensitive texts. The sentiment analysis model identifies illegal texts by performing sentiment analysis on the text. Although it can greatly reduce the number of false positive sentences, the sentiment analysis model is highly robust and requires the collection of a large number of sentences containing illegal words (including positive and negative sentences) to train the sentiment analysis model. Therefore, the time cost of data collection and annotation is relatively high. Summary of the invention
[0005] The present application provides a BERT-based illegal text recognition algorithm and device to provide a text recognition method and device with higher accuracy and higher recognition efficiency.
[0006] In a first aspect, the present application provides a BERT-based illegal text recognition algorithm, wherein the BERT-based illegal text recognition algorithm comprises:
[0007] Get the text to be recognized;
[0008] Using a keyword matching algorithm to identify the text to be identified, to obtain sensitive text, where the sensitive text refers to the text to be identified that contains at least one preset keyword;
[0009] Input the sensitive text into a pre-established BERT text recognition model to obtain a probability distribution corresponding to the sensitive text, wherein the probability distribution includes a non-violation probability and at least one violation probability;
[0010] If there is a violation probability in the probability distribution corresponding to the sensitive text that is in a preset violation interval and is greater than the non-violation probability, the sensitive text is marked as a violation text;
[0011] If in the probability distribution corresponding to the sensitive text, both the non-violation probability and any one of the violation probabilities are less than the determination threshold, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference, the sensitive text is marked as pending text; the determination threshold is the lower limit of the preset violation interval;
[0012] Extracting a feature vector of the pending text, and performing a non-violation benchmark operation and at least one violation benchmark operation on the feature vector to obtain a non-violation similarity and at least one violation similarity;
[0013] It is determined whether the value of the non-violation similarity is greater than the value of any violation similarity. If the value of the non-violation similarity is greater than the value of any violation similarity, the pending text is marked as a non-violation text; if the value of the non-violation similarity is less than or equal to the value of any violation similarity, the pending text is marked as a violation text.
[0014] Optionally, the non-violation benchmark operation is to perform similarity calculation on the feature vector and the non-violation benchmark vector, and the non-violation benchmark vector is Where ai is the vectorized non-violation text, and m is the number of non-violation texts;
[0015] The violation benchmark operation is to calculate the similarity between the feature vector and the violation benchmark vector. The violation benchmark vector is Where bi is the vectorized violation text and n is the number of violation texts.
[0016] Optionally, the BERT text recognition model is established by the following steps:
[0017] Acquire a text to be recognized, and mark the text to be recognized as an illegal text or a non-illegal text;
[0018] Randomly divide the offending texts into two sets, and randomly divide the non-offending texts into two sets;
[0019] A training set is established by using one set of illegal texts and one set of non-illegal texts; a test set is established by using another set of illegal texts and another set of non-illegal texts;
[0020] Using the training set, the neural network model is trained using label back propagation and gradient descent.
[0021] The test set is used to test the accuracy of the trained neural network model and obtain the BERT text recognition model.
[0022] Optionally, before the step of inputting the sensitive text into the pre-established BERT text recognition model, the method further includes: pre-processing the sensitive text;
[0023] The pre-processing is:
[0024] Removing punctuation marks and English characters from the sensitive text to obtain a pure Chinese text;
[0025] Converting the Traditional Chinese characters in the pure Chinese text into Simplified Chinese characters to obtain a Simplified Chinese text;
[0026] The simplified Chinese text is vectorized to obtain preprocessed sensitive text.
[0027] The second aspect of the present application provides a BERT-based illegal text recognition device, wherein the BERT-based illegal text recognition device is used to execute the BERT-based illegal text recognition algorithm, including:
[0028] A data acquisition module, used to acquire text to be recognized;
[0029] A keyword matching module, used to identify the text to be identified by using a keyword matching algorithm to obtain sensitive text;
[0030] A preliminary classification module, storing a pre-established BERT text recognition model, for inputting sensitive text into the pre-established BERT text recognition model to obtain a probability distribution corresponding to the sensitive text;
[0031] a violation text marking module, used to determine whether there is a violation probability in a preset violation interval and greater than a non-violation probability in the probability distribution corresponding to the sensitive text; if there is a violation probability in a preset violation interval and greater than a non-violation probability in the probability distribution corresponding to the sensitive text, the sensitive text is marked as a preliminary violation text; and, further used to determine whether there is a non-violation probability and any one of the violation probabilities are less than a determination threshold in the probability distribution corresponding to the sensitive text, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference; if there is a non-violation probability and any one of the violation probabilities are less than a determination threshold in the probability distribution corresponding to the sensitive text, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference, the sensitive text is marked as pending text;
[0032] The similarity filtering module is used to extract the feature vector of the pending text, and perform a non-violation benchmark operation and at least one violation benchmark operation on the feature vector to obtain a non-violation similarity and at least one violation similarity; and is also used to determine whether the value of the non-violation similarity is greater than the value of any violation similarity. If the value of the non-violation similarity is greater than the values of all violation similarities, the pending text is marked as a non-violation text; if the value of the non-violation similarity is less than or equal to the value of any violation similarity, the pending text is marked as a violation text.
[0033] Optionally, a BERT model building module is also included, which is used to generate the pre-established BERT text recognition model.
[0034] A third aspect of the present application provides a computer device, including:
[0035] Memory for storing computer programs;
[0036] A processor is used to implement the steps of a BERT-based illegal text recognition algorithm provided in the first aspect of the present application when executing the computer program.
[0037] The fourth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is processed and executed, the steps of a BERT-based illegal text recognition algorithm provided in the first aspect of the present application are implemented.
[0038] The present application provides a BERT-based illegal text recognition algorithm and device. The BERT-based illegal text recognition device is used to execute the steps of the BERT-based illegal text recognition algorithm, identifying the text to be recognized by using a keyword matching algorithm to obtain sensitive text; inputting the sensitive text into a pre-established BERT text recognition model to obtain a probability distribution corresponding to the sensitive text; performing probability distribution analysis and threshold filtering on the sensitive text to obtain a portion of illegal text; and performing probability distribution analysis on the sensitive text to obtain pending text, that is, text that cannot be accurately classified by the BERT text recognition model, and determining whether the pending text mark is illegal text by performing similarity filtering on the pending text.
[0039] The illegal text recognition algorithm provided in the embodiment of the present application, combined with the keyword matching algorithm, effectively improves the accuracy of illegal text recognition through probability distribution analysis and threshold filtering, as well as error correction of similarity filtering. Compared with a single sentiment classification method, it has lower manpower and time costs and higher text recognition efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0041] Figure 1 A flowchart of a BERT-based illegal text recognition algorithm provided in an embodiment of the present application;
[0042] Figure 2 A schematic diagram of the process of establishing the BERT text recognition model provided in an embodiment of the present application;
[0043] Figure 3 A schematic diagram of the structure of a BERT-based illegal text recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] like Figure 1 As shown, it is a flow chart of a BERT-based illegal text recognition algorithm provided in an embodiment of the present application, and the BERT-based illegal text recognition algorithm includes steps S101 to S109.
[0045] Step S101, obtaining text to be recognized.
[0046] The text to be identified is text data crawled from the Internet, including illegal text and non-illegal text. The purpose of the embodiment of the present application is to find illegal text from the text to be identified.
[0047] Step S102: using a keyword matching algorithm to identify the text to be identified, to obtain sensitive text.
[0048] The sensitive text refers to the text to be identified that contains at least one preset keyword.
[0049] Step S103: input the sensitive text into a pre-established BERT text recognition model to obtain a probability distribution corresponding to the sensitive text.
[0050] Among them, the probability distribution includes a non-violation probability and at least one violation probability. The BERT text recognition model can output the probability distribution corresponding to the sensitive text based on the sensitive text. The non-violation probability represents the probability value of the sensitive text being a non-violation text, and the violation probability represents the probability value of the sensitive text being a violation text. It should be noted that the violation text can be set to multiple categories as needed, and the corresponding violation probability can also exist in multiple categories. For example, in one scenario, the violation text is subdivided into text A and text B, and correspondingly, the violation probability is also subdivided into text A probability and text B probability.
[0051] like Figure 2 As shown, it is a schematic diagram of the process of establishing the BERT text recognition model provided in an embodiment of the present application; the BERT text recognition model is established through steps S201 to S205:
[0052] Step S201, obtaining a text to be recognized, and marking the text to be recognized as a violation text or a non-violation text.
[0053] For example, the text A in the text to be recognized is marked as 0, the text B is marked as 1, and the non-violation text is marked as 2.
[0054] Step S202: randomly divide the illegal texts into two groups, and randomly divide the non-illegal texts into two groups.
[0055] In the case where the illegal text is subdivided into text A and text B, the user needs to randomly divide text A into two sets, such as set 1 and set 2, and randomly divide text B into two sets, such as set 3 and set 4. Then, set 1 and set 3 are merged to form one illegal text set, and set 2 and set 4 are merged to form another illegal text set.
[0056] Step S203, using one set of illegal texts and one set of non-illegal texts to establish a training set; using another set of illegal texts and another set of non-illegal texts to establish a test set.
[0057] Step S204, using the training set, and adopting label back propagation and gradient descent method to train the neural network model.
[0058] During training, the neural network model converts the training set data into vectors, and then calculates the neural network parameters to give a probability distribution for each data. The correctness of the probability distribution depends on the label (0, 1, 2). Then the neural network model performs backpropagation according to the label and uses the gradient descent method to adjust the parameters of the neural network, so that the next prediction result of the neural network model will be more accurate.
[0059] Step S205, using the test set to test the accuracy of the trained neural network model to obtain the BERT text recognition model.
[0060] After training, the neural network model can make very accurate predictions on the data in the training set, that is, in the probability distribution of the output corresponding to text A, the value of the probability of text A is the largest, the value of the probability of non-violation in the probability distribution of the output corresponding to text B is the largest, and the probability of text B is the largest in the probability distribution of the output corresponding to text B. Then, in order to evaluate the generalization ability of the neural network model, the data in the test set is used for prediction (the neural network model is no longer trained at this time). The purpose is to verify the model's prediction effect on unseen data, thereby judging the pros and cons of the model, and obtaining the BERT text recognition model while meeting the accuracy of the neural network model.
[0061] Step S104: if there is a violation probability in the preset violation interval and greater than the non-violation probability in the probability distribution corresponding to the sensitive text, the sensitive text is marked as a violation text.
[0062] In order to more clearly illustrate the technical solution protected by the embodiment of the present application, an example is given for illustration. The illegal text is subdivided into text A and text B, the output probability distribution is (A text probability, B text probability, non-violation probability), and the illegal interval is subdivided into text A interval [0.40, 0.934] and text B interval [0.40, 0.952].
[0063] For example, the probability distribution corresponding to the sensitive text is (0.12, 0.51, 0.37), in which there is a violation probability (B text probability) that is in the preset violation interval (B text interval) and is greater than the violation probability of the non-violation probability, so the sensitive text is marked as violation text.
[0064] For another example, the probability distribution corresponding to the sensitive text is (0.35, 0.49, 0.16). There is a violation probability that is in the preset violation interval and is greater than the non-violation probability, so the sensitive text is marked as violation text.
[0065] For another example, the probability distribution corresponding to sensitive text is (0.94, 0.0.02, 0.04). There is a violation probability (B text probability) that is greater than the non-violation probability, but it exceeds the preset violation interval (B text interval), so the sensitive text is marked as non-violation text. It should be noted that the upper limit of the violation interval set here is a threshold filtering method. For example, in this example, the threshold of the A text threshold filtering is 0.934, and the threshold of the B text threshold filtering is 0.952.
[0066] For another example, the probability distribution corresponding to the sensitive text is (0.14, 0.0.41, 0.45). There is no violation probability that is within the preset violation interval and greater than the non-violation probability, so the sensitive text is marked as non-violation text.
[0067] In the embodiment of the present application, the main purpose is to identify illegal texts. When it is determined that sensitive texts are non-illegal texts, the sensitive texts may not be marked and the corresponding data on the Internet may be directly released.
[0068] Step S105: If in the probability distribution corresponding to the sensitive text, both the non-violation probability and any one of the violation probabilities are smaller than the determination threshold, and the difference between the non-violation probability and any one of the violation probabilities is smaller than a preset difference, the sensitive text is marked as pending text.
[0069] Among them, the determination threshold is the preset lower limit of the violation interval. In the embodiment of the present application, the lower limit of the violation interval is 0.40, and the preset difference is 0.5.
[0070] In order to more clearly illustrate the technical solution protected by the embodiment of the present application, an example is given for illustration. The illegal text is subdivided into text A and text B, the output probability distribution is (A text probability, B text probability, non-violation probability), and the illegal interval is subdivided into text A interval [0.40, 0.934] and text B interval [0.40, 0.952].
[0071] For example, the probability distribution corresponding to the sensitive text is (0.32, 0.35, 0.33), the non-violation probability and the violation probability are both less than 0.4, and the non-violation probability is close to the violation probability, and the difference between the non-violation probability and any violation probability is less than 0.5, then the sensitive text is marked as pending text.
[0072] Step S106 , extracting a feature vector of the pending text, and performing a non-violation benchmark operation and at least one violation benchmark operation on the feature vector to obtain a non-violation similarity and at least one violation similarity.
[0073] The non-violation benchmark operation is to perform similarity calculation on the feature vector and the non-violation benchmark vector; and the violation benchmark operation is to perform similarity calculation on the feature vector and the violation benchmark vector.
[0074] Specifically, before training the BERT text recognition model, the text to be recognized (marked as illegal text and non-illegal text) will be converted into vectors for model training. The non-illegal benchmark vector is obtained by summing and averaging the vectors corresponding to all non-illegal texts, and the illegal benchmark vector is obtained by the same method. The specific expression is as follows:
[0075] The non-violating reference vector is Where ai is the vectorized non-violation text, m is the number of non-violation texts; the violation benchmark vector is Where bi is the vectorized violation text and n is the number of violation texts.
[0076] Step S107 , determining whether the value of the non-violation similarity is greater than the value of any violation similarity.
[0077] Step S108: If the value of the non-violation similarity is greater than the value of any violation similarity, the pending text is marked as a non-violation text.
[0078] Step S109: if the value of the non-violation similarity is less than or equal to the value of any violation similarity, the pending text is marked as a violation text.
[0079] By comparing the value of the non-violation similarity with the value of any violation similarity, if the value of the non-violation similarity is the largest, the pending text is marked as a non-violation text; if the value of the non-violation similarity is not the largest, that is, there is at least one violation text whose similarity value is greater than the value of the non-violation similarity, the pending text is marked as a violation text.
[0080] Furthermore, before the step of inputting the sensitive text into the pre-established BERT text recognition model, it also includes: preprocessing the sensitive text; specifically: removing punctuation marks and English characters from the sensitive text to obtain a pure Chinese text; converting Traditional Chinese in the pure Chinese text into Simplified Chinese to obtain a Simplified Chinese text; and vectorizing the Simplified Chinese text to obtain the preprocessed sensitive text.
[0081] The second aspect of the embodiment of the present application provides a BERT-based illegal text recognition device, which is used to execute a BERT-based illegal text recognition algorithm provided by the first aspect of the embodiment of the present application. For the details that are not disclosed in the recognition device provided by the second aspect of the embodiment of the present application, please refer to the illegal text recognition algorithm provided by the first aspect of the embodiment of the present application.
[0082] like Figure 3 , which is a schematic diagram of a BERT-based illegal text recognition device provided in an embodiment of the present application. The BERT-based illegal text recognition device includes a data acquisition module, a keyword matching module, a preliminary classification module, an illegal text marking module and a similarity filtering module.
[0083] The data acquisition module is used to acquire the text to be recognized.
[0084] The keyword matching module is used to identify the text to be identified by using a keyword matching algorithm to obtain sensitive text.
[0085] The preliminary classification module stores a pre-established BERT text recognition model and is used to input the sensitive text into the pre-established BERT text recognition model to obtain the probability distribution corresponding to the sensitive text.
[0086] A violation text marking module is used to determine whether there is a violation probability in a preset violation interval and greater than a non-violation probability in the probability distribution corresponding to the sensitive text; if there is a violation probability in a preset violation interval and greater than the non-violation probability in the probability distribution corresponding to the sensitive text, the sensitive text is marked as a preliminary violation text; and, further used to determine whether there is a non-violation probability and any one of the violation probabilities are less than a determination threshold in the probability distribution corresponding to the sensitive text, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference; if there is a non-violation probability and any one of the violation probabilities are less than a determination threshold in the probability distribution corresponding to the sensitive text, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference, the sensitive text is marked as pending text.
[0087] The similarity filtering module is used to extract the feature vector of the pending text, and perform a non-violation benchmark operation and at least one violation benchmark operation on the feature vector to obtain a non-violation similarity and at least one violation similarity; and is also used to determine whether the value of the non-violation similarity is greater than the value of any violation similarity. If the value of the non-violation similarity is greater than the values of all violation similarities, the pending text is marked as a non-violation text; if the value of the non-violation similarity is less than or equal to the value of any violation similarity, the pending text is marked as a violation text.
[0088] Furthermore, the BERT-based illegal text recognition device also includes a BERT model building module for generating the pre-established BERT text recognition model.
[0089] Furthermore, the BERT-based illegal text identification device also includes a preprocessing module, which is used to preprocess the sensitive text to obtain the preprocessed sensitive text.
[0090] A third aspect of an embodiment of the present application provides a computer device, including: a memory for storing a computer program; and a processor for implementing the steps of a BERT-based illegal text recognition algorithm provided in the first aspect of the embodiment of the present application when executing the computer program.
[0091] The fourth aspect of the embodiments of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is processed and executed, the steps of a BERT-based illegal text recognition algorithm provided in the first aspect of the embodiments of the present application are implemented.
[0092] The embodiment of the present application provides a BERT-based illegal text recognition algorithm and device. The BERT-based illegal text recognition device is used to execute the steps of the BERT-based illegal text recognition algorithm, identify the text to be recognized by using a keyword matching algorithm to obtain sensitive text; input the sensitive text into a pre-established BERT text recognition model to obtain a probability distribution corresponding to the sensitive text; perform probability distribution analysis and threshold filtering on the sensitive text to obtain a part of illegal text; and perform probability distribution analysis on the sensitive text to obtain pending text, that is, text that cannot be accurately classified by the BERT text recognition model, and determine whether the pending text is marked as illegal text by performing similarity filtering on the pending text.
[0093] The illegal text recognition algorithm provided in the embodiment of the present application, combined with the keyword matching algorithm, effectively improves the accuracy of illegal text recognition through probability distribution analysis and threshold filtering, as well as error correction of similarity filtering. Compared with a single sentiment classification method, it has lower manpower and time costs and higher text recognition efficiency.
[0094] The present application is described in detail above in conjunction with specific implementation methods and exemplary examples, but these descriptions cannot be understood as limiting the present application. Those skilled in the art understand that, without departing from the spirit and scope of the present application, a variety of equivalent replacements, modifications or improvements can be made to the technical solution of the present application and its implementation methods, all of which fall within the scope of the present application. The scope of protection of the present application shall be subject to the attached claims.
Claims
1. A BERT-based illegal text recognition algorithm, characterized in that: The BERT-based illegal text recognition algorithm includes: Get the text to be recognized; Using a keyword matching algorithm to identify the text to be identified, to obtain sensitive text, where the sensitive text refers to the text to be identified that contains at least one preset keyword; Input the sensitive text into a pre-established BERT text recognition model to obtain a probability distribution corresponding to the sensitive text, wherein the probability distribution includes a non-violation probability and at least one violation probability; If there is a violation probability in the probability distribution corresponding to the sensitive text that is in a preset violation interval and is greater than the non-violation probability, the sensitive text is marked as a violation text; If in the probability distribution corresponding to the sensitive text, both the non-violation probability and any one of the violation probabilities are less than the determination threshold, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference, the sensitive text is marked as pending text; the determination threshold is the lower limit of the preset violation interval; Extracting a feature vector of the pending text, and performing a non-violation benchmark operation and at least one violation benchmark operation on the feature vector to obtain a non-violation similarity and at least one violation similarity; Determine whether the value of the non-violation similarity is greater than the value of any violation similarity. If the value of the non-violation similarity is greater than the value of any violation similarity, mark the pending text as a non-violation text; if the value of the non-violation similarity is less than or equal to the value of any violation similarity, mark the pending text as a violation text; The BERT text recognition model is established by the following steps: Acquire a text to be recognized, and mark the text to be recognized as an illegal text or a non-illegal text; Randomly divide the offending texts into two sets, and randomly divide the non-offending texts into two sets; A training set is established by using one set of illegal texts and one set of non-illegal texts; a test set is established by using another set of illegal texts and another set of non-illegal texts; Using the training set, the neural network model is trained using label back propagation and gradient descent. Use the test set to test the accuracy of the trained neural network model and obtain the BERT text recognition model; The non-violation benchmark operation is to calculate the similarity between the feature vector and the non-violation benchmark vector. ,in, is the vectorized non-violating text, is the number of non-violating texts; The violation benchmark operation is to calculate the similarity between the feature vector and the violation benchmark vector. The violation benchmark vector is ,in, is the vectorized offending text, is the number of offending texts.
2. The BERT-based illegal text recognition algorithm according to claim 1, characterized in that: Before the step of inputting the sensitive text into the pre-established BERT text recognition model, the method further includes: pre-processing the sensitive text; The pre-processing is: Removing punctuation marks and English characters from the sensitive text to obtain a pure Chinese text; Converting the Traditional Chinese characters in the pure Chinese text into Simplified Chinese characters to obtain a Simplified Chinese text; The simplified Chinese text is vectorized to obtain preprocessed sensitive text.
3. A BERT-based illegal text recognition device, characterized in that: The BERT-based illegal text recognition device is used to execute the BERT-based illegal text recognition algorithm according to any one of claims 1 to 2, comprising: A data acquisition module, used to acquire text to be recognized; A keyword matching module, used to identify the text to be identified by using a keyword matching algorithm to obtain sensitive text; A preliminary classification module, storing a pre-established BERT text recognition model, for inputting sensitive text into the pre-established BERT text recognition model to obtain a probability distribution corresponding to the sensitive text; a violation text marking module, used to determine whether there is a violation probability in a preset violation interval and greater than a non-violation probability in the probability distribution corresponding to the sensitive text; if there is a violation probability in a preset violation interval and greater than a non-violation probability in the probability distribution corresponding to the sensitive text, the sensitive text is marked as a preliminary violation text; and, further used to determine whether there is a non-violation probability and any one of the violation probabilities are less than a determination threshold in the probability distribution corresponding to the sensitive text, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference; if there is a non-violation probability and any one of the violation probabilities are less than a determination threshold in the probability distribution corresponding to the sensitive text, and the difference between the non-violation probability and any one of the violation probabilities is less than a preset difference, the sensitive text is marked as pending text; A similarity filtering module is used to extract the feature vector of the pending text, and perform a non-violation benchmark operation and at least one violation benchmark operation on the feature vector to obtain a non-violation similarity and at least one violation similarity; and is also used to determine whether the value of the non-violation similarity is greater than the value of any violation similarity, if the value of the non-violation similarity is greater than the values of all violation similarities, then mark the pending text as a non-violation text; if the value of the non-violation similarity is less than or equal to the value of any violation similarity, then mark the pending text as a violation text; The method further includes a BERT model building module for generating the pre-established BERT text recognition model, wherein the BERT text recognition model is established by the following steps: Acquire a text to be recognized, and mark the text to be recognized as an illegal text or a non-illegal text; Randomly divide the offending texts into two sets, and randomly divide the non-offending texts into two sets; A training set is established by using one set of illegal texts and one set of non-illegal texts; a test set is established by using another set of illegal texts and another set of non-illegal texts; Using the training set, the neural network model is trained using label back propagation and gradient descent. Use the test set to test the accuracy of the trained neural network model and obtain the BERT text recognition model; The non-violation benchmark operation is to calculate the similarity between the feature vector and the non-violation benchmark vector. ,in, is the vectorized non-violating text, is the number of non-violating texts; The violation benchmark operation is to calculate the similarity between the feature vector and the violation benchmark vector. The violation benchmark vector is ,in, is the vectorized offending text, is the number of offending texts.
4. The BERT-based illegal text recognition device according to claim 3, characterized in that: It also includes a preprocessing module, which is used to preprocess the sensitive text to obtain the preprocessed sensitive text.
5. A computer device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of a BERT-based illegal text recognition algorithm as described in any one of claims 1 to 2 when executing the computer program.
6. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is processed and executed, the steps of a BERT-based illegal text recognition algorithm as described in any one of claims 1-2 are implemented.
Citation Information
Patent Citations
Text content auditing method and system based on sensitive word
CN106445998A
Sensitive word and sentence recognition model processing method and related equipment thereof
CN112417887A
