Text review method, device, equipment and storage medium
Through the sensitive word filtering and semantic evaluation of the text review method, combined with keyword filtering and semantic expansion, it solves the limitations of text content review in the existing technology, improves the accuracy and comprehensiveness of identifying sensitive information, and ensures text security. sex.
Patent Information
- Application Number
- CN202410805963.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2044-06-21
AI Technical Summary
When reviewing text content in the existing technology, keyword-based filtering cannot effectively identify content with pun semantics or obscure expressions, causing harmful information to slip through the net. Semantic evaluation based on preset rules is not effective in complex and changeable language environments. limited.
Using the text review method, sensitive words are replaced in the text to be reviewed through the sensitive word filtering network, and the text is input into the semantic filtering network for semantic evaluation and semantic expansion. Keyword filtering and semantic evaluation are combined to improve the comprehensiveness and accuracy of the review.
It improves the comprehensiveness and accuracy of the review of sensitive information contained in text content, ensures the security risk assessment of text under different semantic environments, and reduces the leakage of harmful information.
Smart Images

Figure CN118378631B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a text review method, apparatus, device and storage medium. Background Art
[0002] In the field of artificial intelligence, especially in the application of natural language processing (NLP) technology, the output security and compliance issues of language models are becoming increasingly prominent. With the widespread use of large pre-trained language models, the text content they generate may contain sensitive information, such as hate speech, false information, and privacy violations, which may have a negative impact on both society and individuals.
[0003] In the related art, the review of sensitive information contained in text content is achieved by filtering based on keywords or semantic evaluation based on preset rules. However, the current review mechanism for reviewing text content has limitations. Filtering based on keywords cannot effectively identify content with double meanings or obscure expressions, which can easily lead to the leakage of harmful information. Semantic evaluation based on preset rules has limited effect when dealing with complex and changing language environments. Summary of the invention
[0004] The purpose of this application is to provide a text review method, device, equipment and storage medium, aiming to improve the comprehensiveness and accuracy of the review of sensitive information contained in the text content.
[0005] The present application provides a text review method, including:
[0006] Obtain the text to be reviewed generated by the text generation network;
[0007] Inputting the text to be reviewed into a sensitive word filtering network of a text review network, replacing sensitive words contained in the text to be reviewed, and obtaining a sensitive word filtered text;
[0008] Inputting the sensitive word filtering text into the semantic filtering network of the text review network, performing semantic evaluation on the sensitive word filtering text and performing semantic evaluation after semantic expansion to obtain a semantic evaluation result; the semantic evaluation result represents the sensitivity of the semantic features of the sensitive word filtering text before and after the semantic expansion;
[0009] According to the semantic evaluation result, a corresponding text review result is generated.
[0010] In some embodiments, the sensitive word filtering network includes a context semantic recognition layer, a sensitive word screening layer and a sensitive word replacement layer, and the sensitive word filtering network of the text review network inputs the text to be reviewed into the sensitive word filtering network, replaces the sensitive words contained in the text to be reviewed, and obtains the sensitive word filtered text, including:
[0011] Inputting the text to be reviewed into the context semantic recognition layer, performing context semantic recognition on the text to be reviewed, and obtaining a context semantic recognition result;
[0012] Inputting the context semantic recognition result and the text to be reviewed into the sensitive word screening layer, screening the text to be reviewed for sensitive words according to the context semantic recognition result to obtain original sensitive words;
[0013] The context semantic recognition result and the original sensitive word are input into the sensitive word replacement layer, a plurality of semantically similar words of the original sensitive word are generated according to the context semantic recognition result, a target replacement word is generated according to the original sensitive word and the plurality of semantically similar words, and the original sensitive word in the text to be reviewed is replaced with the target replacement word to obtain the sensitive word filtered text.
[0014] In some embodiments, the sensitive word screening layer includes a sensitive word extraction sublayer, a feature association analysis sublayer, and a sensitive word screening sublayer, and the context semantic recognition result and the text to be reviewed are input into the sensitive word screening layer, and the text to be reviewed is screened for sensitive words according to the context semantic recognition result to obtain the original sensitive words, including:
[0015] Inputting the text to be reviewed into the sensitive word extraction sublayer, extracting sensitive words from the text to be reviewed, and obtaining a plurality of candidate sensitive words;
[0016] Inputting the context semantic recognition result and the candidate sensitive word into the feature association analysis sublayer, performing feature association analysis on the context semantic recognition result and the candidate sensitive word, and obtaining feature association information between the context semantic recognition result and the candidate sensitive word,
[0017] The feature association information and the candidate sensitive words are input into the sensitive word screening sublayer, and the candidate sensitive words are screened according to the feature association information to obtain the original sensitive words.
[0018] In some embodiments, the semantic filtering network includes a word embedding layer, a semantic expansion layer and a semantic evaluation layer, and the sensitive word filtering text is input into the semantic filtering network of the text review network, and the sensitive word filtering text is semantically evaluated and semantically evaluated after semantic expansion to obtain a semantic evaluation result, including:
[0019] Inputting the sensitive word filtering text into the word embedding layer, embedding the sensitive word filtering text into words, and obtaining a word embedding vector;
[0020] Inputting the word embedding vector into the semantic extension layer, performing semantic extension on the word embedding vector, and obtaining a semantic extension vector;
[0021] The word embedding vector and the semantic extension vector are input into the semantic evaluation layer, and semantic evaluation is performed on the word embedding vector and the semantic extension vector to obtain the semantic evaluation result.
[0022] In some embodiments, inputting the word embedding vector into the semantic extension layer, performing semantic extension on the word embedding vector, and obtaining the semantic extension vector includes:
[0023] Obtaining a number of random vectors; the random vectors obey a Gaussian distribution;
[0024] The word embedding vector and the random vector are input into the semantic extension layer, and the word embedding vector and the random vector are fitted to obtain the semantic extension vector.
[0025] In some embodiments, inputting the word embedding vector and the semantic extension vector into the semantic evaluation layer, performing semantic evaluation on the word embedding vector and the semantic extension vector, and obtaining the semantic evaluation result includes:
[0026] In the semantic evaluation layer, the semantic evaluation scores corresponding to the word embedding vector and the semantic extension vector are calculated according to the similarity distance between the word embedding vector and the semantic extension vector and the preset semantic feature;
[0027] Determining whether the semantic evaluation scores all reach a preset score value;
[0028] If all of them are achieved, output a semantic evaluation result that the semantic feature does not contain sensitive information;
[0029] Otherwise, the semantic evaluation result indicating that the semantic feature has sensitive information is output.
[0030] In some embodiments, generating a corresponding text review result according to the semantic evaluation result includes:
[0031] Determining whether the semantic evaluation result indicates that the semantic feature contains sensitive information;
[0032] If not, generate and output the text review result of the sensitive word filtering text;
[0033] If yes, determining whether the number of times the to-be-examined text is generated reaches a preset number threshold;
[0034] If it is not reached, adjusting the temperature coefficient of the text generation network; returning to the step of obtaining the text to be reviewed generated by the text generation network;
[0035] If achieved, a text review result is generated without outputting the sensitive word filtered text.
[0036] The present application also provides a text review device, including:
[0037] The first module is used to obtain the text to be reviewed generated by the text generation network;
[0038] The second module is used to input the text to be reviewed into the sensitive word filtering network of the text review network, replace the sensitive words contained in the text to be reviewed, and obtain a sensitive word filtered text;
[0039] The third module is used to input the sensitive word filtering text into the semantic filtering network of the text review network, perform semantic evaluation on the sensitive word filtering text and perform semantic evaluation after semantic expansion to obtain a semantic evaluation result; the semantic evaluation result represents the sensitivity of the semantic features of the sensitive word filtering text before and after semantic expansion;
[0040] The fourth module is used to generate corresponding text review results based on the semantic evaluation results.
[0041] An embodiment of the present application also provides an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned text review method when executing the computer program.
[0042] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned text review method is implemented.
[0043] The beneficial effects of the present application are as follows: first, the text to be reviewed is input into the sensitive word filtering network of the text review network, the sensitive words contained in the text to be reviewed are replaced to obtain the sensitive word filtered text, and then the sensitive word filtered text is input into the semantic filtering network of the text review network, the sensitive word filtered text is subjected to semantic evaluation and semantic evaluation after semantic expansion to obtain a semantic evaluation result that characterizes the sensitivity of the semantic features of the sensitive word filtered text before and after semantic expansion, and a corresponding text review result is generated based on the semantic evaluation result. Since keyword filtering and semantic evaluation are simultaneously used to conduct text security review of the text to be reviewed, and the sentences of the text after keyword filtering are subjected to semantic evaluation in the current semantic environment and semantic evaluation after semantic expansion to determine the security risks of the sentences of the text after keyword filtering in different semantic environments, the comprehensiveness and accuracy of the review of sensitive information contained in the text content can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a flowchart of the text review method provided in the embodiment of the present application.
[0045] Figure 2 It is a flowchart of the specific method of step S102 provided in an embodiment of the present application.
[0046] Figure 3 It is a flowchart of the specific method of step S202 provided in an embodiment of the present application.
[0047] Figure 4 It is a flowchart of the specific method of step S103 provided in an embodiment of the present application.
[0048] Figure 5 It is a flowchart of the specific method of step S403 provided in an embodiment of the present application.
[0049] Figure 6 It is a flowchart of the specific method of step S104 provided in an embodiment of the present application.
[0050] Figure 7 It is a structural diagram of the text review device provided in an embodiment of the present application.
[0051] Figure 8 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application.
[0052] Fig. 9 It is a structural diagram of the text review network provided in the embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0054] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.
[0055] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0056] First, some nouns involved in this application are analyzed:
[0057] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0058] Natural language processing (NLP): NLP uses computers to process, understand and apply human languages (such as Chinese, English, etc.). NLP is a branch of artificial intelligence and an interdisciplinary subject between computer science and linguistics. It is often referred to as computational linguistics. Natural language processing includes grammatical analysis, semantic analysis, and text understanding. Natural language processing is often used in technical fields such as machine translation, handwritten and printed character recognition, speech recognition and text-to-speech conversion, information intent recognition, information extraction and filtering, text classification and clustering, public opinion analysis and opinion mining. It involves data mining related to language processing, machine learning, knowledge acquisition, knowledge engineering, artificial intelligence research, and linguistic research related to language computing.
[0059] Information Extraction: A text processing technology that extracts specified types of entity, relationship, event and other factual information from natural language text and forms structured data output. Information extraction is a technology that extracts specific information from text data. Text data is composed of some specific units, such as sentences, paragraphs, and chapters. Text information is composed of some small specific units, such as characters, words, phrases, sentences, paragraphs, or a combination of these specific units. Extracting noun phrases, names, place names, etc. from text data are all text information extraction. Of course, the information extracted by text information extraction technology can be various types of information.
[0060] At present, the review of sensitive information contained in text content is achieved through keyword filtering or semantic evaluation based on preset rules. However, the current review mechanism for reviewing text content has limitations. Keyword filtering cannot effectively identify content with double meanings or obscure expressions, which can easily lead to the leakage of harmful information. Semantic evaluation based on preset rules has limited effect when dealing with complex and changing language environments.
[0061] Based on this, the embodiments of the present application provide a text review method, apparatus, device and storage medium, aiming to improve the comprehensiveness and accuracy of the review of sensitive information contained in the text content.
[0062] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0063] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0064] The text review method provided in the embodiment of the present application relates to the field of artificial intelligence technology. The text review method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or can be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN) and cloud servers that provide basic cloud computing services such as big data and artificial intelligence platforms; the software can be an application that implements a text classification method, etc., but is not limited to the above forms.
[0065] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronic devices, network personal computers (Personal Computer, PC), minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0066] See also Figure 1 , Figure 1 is a flowchart of a text review method provided in an embodiment of the present application. In some embodiments of the present application, Figure 1 The method may specifically include but is not limited to steps S101 to S104. Figure 1 These four steps are introduced in detail.
[0067] Step S101, obtaining the text to be reviewed generated by the text generation network.
[0068] It is understandable that the text generation network is a natural language processing tool driven by artificial intelligence technology, which can generate corresponding text to be reviewed as an answer based on the patterns and statistical laws seen in the pre-training stage, such as ChatGPT. In actual application, users generate input text through smart terminals, and the text generation network generates corresponding text to be reviewed based on the semantics of the input text. The text to be reviewed generated by the text generation network needs to be reviewed before it can be displayed to the user to prevent the censored text from being affected by the input text and containing sensitive information such as hate speech, false information or privacy infringement.
[0069] Step S102: input the text to be reviewed into the sensitive word filtering network of the text review network, replace the sensitive words contained in the text to be reviewed, and obtain the sensitive word filtered text.
[0070] In step S102, the text to be reviewed is input into the sensitive word filtering network of the text review network, and the sensitive word filtering network is used to select sensitive words for the reviewed text. The selected sensitive word pairs are subjected to multiple rounds of contextual semantic recognition in different context scenarios to identify the changes in the sensitivity of each sensitive word in different context scenarios, and the selected sensitive words are optimized into safer and more reasonable word expressions. The optimized word expressions are used to replace the selected sensitive words to obtain sensitive word filtered text, thereby achieving preliminary screening of the text to be reviewed and quickly identifying and optimizing obviously harmful sensitive words.
[0071] In a specific embodiment, Fig. 9 As shown, the text review network can be an end-to-end network model including a sensitive word filtering network and a semantic filtering network. The sensitive word filtering network can be used to replace sensitive words contained in the text to be reviewed, and the semantic filtering network can be used to perform semantic evaluation on the sensitive word filtered text and semantic evaluation after semantic expansion. The sensitive word filtering network can be obtained by training a preset sensitive word filtering network for note sensitive word recognition and replacement based on sample text with sensitive word annotations and a word set with replacement words, and the semantic filtering network can be obtained by training a preset semantic filtering network for pair-wise loss based on a sentence set consisting of paired sensitive sentences and non-sensitive sentences.
[0072] In a specific embodiment, the sensitive word filtering network includes a context semantic recognition layer, a sensitive word screening layer, and a sensitive word replacement layer. Figure 2 , Figure 2 is a flowchart of a specific method of step S102 provided in an embodiment of the present application. Step S102 may specifically include but is not limited to steps S201 to S203. Figure 2 These three steps are introduced in detail.
[0073] Step S201 , inputting the text to be reviewed into the context semantic recognition layer, performing context semantic recognition on the text to be reviewed, and obtaining a context semantic recognition result.
[0074] In step S201, the text to be reviewed is input into the context semantic recognition layer, the context semantic recognition layer is used to perform recognition processing on the text to be reviewed, and context semantic encoding processing is performed on multiple text keywords in the text to be reviewed to obtain a context semantic feature vector. The sensitivity and sensitivity change degree of the multiple text keywords contained in the text to be reviewed in different context scenarios are determined based on the context semantic feature vector, so as to distinguish between context semantic feature vectors with strong sensitive features and context semantic feature vectors without strong sensitive features, and obtain a context semantic recognition result.
[0075] Optionally, the contextual semantic recognition layer may include but is not limited to a bidirectional long short-term memory network layer, a recurrent neural network layer, or other deep learning network layers.
[0076] Step S202: input the context semantic recognition result and the text to be reviewed into a sensitive word screening layer, and screen the text to be reviewed for sensitive words according to the context semantic recognition result to obtain original sensitive words.
[0077] In step S202, the context semantic recognition result and the text to be reviewed are input into the sensitive word screening layer, and the sensitive word screening layer is used to screen the text to be reviewed for sensitive words. A preset number of similar candidate keywords of the context semantic feature vector are obtained from large to small according to the similarity represented by the context semantic recognition result, and the preset number of similar candidate keywords are used as original sensitive words.
[0078] In a specific embodiment, the sensitive word screening layer includes a sensitive word extraction sublayer, a feature association analysis sublayer, and a sensitive word screening sublayer. Figure 3 , Figure 3 is a flowchart of a specific method of step S202 provided in an embodiment of the present application. Step S202 may specifically include but is not limited to steps S301 to 303. Figure 3 These three steps are introduced in detail.
[0079] Step S301: input the text to be reviewed into the sensitive word extraction sublayer, extract sensitive words from the text to be reviewed, and obtain a plurality of candidate sensitive words.
[0080] In step S301, the text to be reviewed is input into the sensitive word extraction sublayer, and the sensitive word extraction sublayer is used to extract sensitive words from the text to be reviewed. The text to be reviewed is segmented to obtain multiple segmented words, and the text to be reviewed is subjected to topic extraction to obtain topic word feature information. The topic words corresponding to the topic word feature information and the high-frequency words corresponding to the high-frequency semantic feature information are used as multiple candidate sensitive words.
[0081] Step S302: input the context semantic recognition result and the candidate sensitive words into the feature association analysis sublayer, perform feature association analysis on the context semantic recognition result and the candidate sensitive words, and obtain feature association information between the context semantic recognition result and the candidate sensitive words.
[0082] Among them, the feature association information represents the similarity between the candidate sensitive word and the context semantic feature vector, which can be described by angular distance, cosine distance, Euclidean distance or Manhattan distance.
[0083] In step S302, the candidate sensitive words and the contextual semantic recognition results are input into the feature association analysis sublayer, and the feature association analysis sublayer is used to extract word features of multiple candidate sensitive words to obtain candidate word feature vectors corresponding to each of the multiple candidate sensitive words. The vector distance information between the candidate word feature vector corresponding to each candidate sensitive word and the contextual semantic feature vector in the contextual semantic recognition result is calculated, thereby obtaining the feature association information between the contextual semantic recognition result and the candidate sensitive words.
[0084] Step S303: input the feature association information and the candidate sensitive words into the sensitive word screening sublayer, and screen the candidate sensitive words according to the feature association information to obtain the original sensitive words.
[0085] In step S303, feature association information and candidate sensitive words are input into the sensitive word screening sublayer, and the sensitive word screening sublayer is used to calculate the angular distance between each candidate word feature vector and the context semantic feature vector in the candidate word feature vectors corresponding to the multiple candidate keywords of the text to be reviewed, and the angular distance is used as the probability that the candidate keyword corresponding to the candidate word feature vector belongs to the original sensitive word. According to the order of probability from large to small, a preset number of candidate keywords among the multiple candidate keywords are determined as the original sensitive words.
[0086] Step S203: input the context semantic recognition result and the original sensitive word into the sensitive word replacement layer, generate multiple semantically similar words of the original sensitive word according to the context semantic recognition result, generate a target replacement word according to the original sensitive word and the multiple semantically similar words, and use the target replacement word to replace the original sensitive word in the text to be reviewed to obtain a sensitive word filtered text.
[0087] In step S203, the context semantic recognition result and the original sensitive words are input into the sensitive word replacement layer, and the sensitive word replacement layer is used to calculate the angular distance between each sensitive word feature vector and the context semantic feature vector in the sensitive word feature vectors corresponding to the multiple original sensitive words of the text to be reviewed, and the angular distance between each replacement word feature vector and the context semantic feature vector is calculated according to the replacement word feature vectors corresponding to the multiple candidate replacement words in the candidate replacement word set, and the difference between the two angular distances is used as the probability that the replacement word corresponding to the replacement word feature vector belongs to the synonym or the synonym of the original sensitive word corresponding to the original sensitive word, and according to the order of probability from large to small, the replacement word with the highest probability is used to correspond to the corresponding original sensitive word, thereby generating a sensitive word filtering text.
[0088] Step S103, inputting the sensitive word filtered text into the semantic filtering network of the text review network, performing semantic evaluation on the sensitive word filtered text and performing semantic evaluation after semantic expansion to obtain a semantic evaluation result.
[0089] Among them, the semantic evaluation result represents the sensitivity of the semantic features of the sensitive word filtering text before and after the semantic expansion.
[0090] In a specific embodiment, the training of the sensitive word filtering network specifically includes: using sample texts with sensitive word annotations and word sets with replacement words to perform supervised learning training on a preset sensitive word filtering network, so that the degree of deviation between the target replacement words selected by the sensitive word filtering network and the replacement words corresponding to the sensitive words in the sample text meets the training end conditions.
[0091] In another specific embodiment, the training of the sensitive word filtering network specifically also includes: using sensitive information update data to update sample texts with sensitive word annotations and word sets with replacement words, and using the updated sample texts and word sets to perform supervised learning training on the sensitive word filtering network, so that the degree of deviation between the target replacement words selected by the sensitive word filtering network and the replacement words corresponding to the sensitive words in the sample text meets the training end conditions.
[0092] In step S103, the sensitive word filtered text is input into the semantic filtering network of the text review network, and the semantic filtering network is used to perform semantic expansion on the sensitive word filtered text to obtain the semantic expanded text. The sensitive word filtered text and the semantic expanded text are semantically evaluated to determine the sensitivity of the sentences in the sensitive word filtered text in the current semantic environment and in other semantic environments, and obtain the semantic evaluation results, thereby ensuring that the sentences in the sensitive word filtered text are not harmful in a variety of different semantic environments, improving the security of the network output text, and ensuring that the network output text will not cause harmful behavior.
[0093] In a specific embodiment, the semantic filtering network includes a word embedding layer, a semantic expansion layer, and a semantic evaluation layer. Figure 4 , Figure 4 is a flowchart of a specific method of step S103 provided in an embodiment of the present application. Step S103 may specifically include but is not limited to steps S401 to S403. Figure 4 These three steps are introduced in detail.
[0094] Step S401: input the sensitive word filtering text into the word embedding layer, perform word embedding on the sensitive word filtering text, and obtain a word embedding vector.
[0095] In step S401, the sensitive word filtering text is input into the word embedding layer, and the sensitive word filtering text is embedded using the word embedding layer, and a trained embedding vector is assigned to each sentence of each sensitive word filtering text. For example, these vector representations can be initialized by using embedding vectors trained on sample texts using pre-trained models such as Word2Vec or FastText to obtain word embedding vectors corresponding to each sentence of the sensitive word filtering text.
[0096] Step S402: input the word embedding vector into the semantic expansion layer, perform semantic expansion on the word embedding vector, and obtain a semantic expansion vector.
[0097] In step S402, the word embedding vector is input into the semantic expansion layer, and the semantic expansion layer is used to perform semantic expansion on the word embedding vector, and a normally distributed noise signal is randomly added to each dimension of the word embedding vector to obtain a semantic expansion vector.
[0098] In a specific embodiment, step S402 specifically includes: obtaining a plurality of random vectors, wherein the random vectors obey a Gaussian distribution, inputting the word embedding vector and the random vector into a semantic extension layer, fitting the word embedding vector and the random vector, and obtaining a semantic extension vector. Exemplarily, for an n-dimensional word embedding vector, a plurality of random vectors are randomly sampled from an n-dimensional Gaussian distribution, and the sampled random vectors are respectively added to the n-dimensional word embedding vector to obtain a plurality of semantic extension vectors to simulate the potential semantic changes of the sentence corresponding to the word embedding vector in a variety of different semantic environments.
[0099] Step S403: input the word embedding vector and the semantic extension vector into the semantic evaluation layer, perform semantic evaluation on the word embedding vector and the semantic extension vector, and obtain a semantic evaluation result.
[0100] In a specific embodiment, see Figure 5 , Figure 5 is a flowchart of a specific method of step S403 provided in an embodiment of the present application. Step S403 may specifically include but is not limited to steps S501 to S504. Figure 5 These four steps are introduced in detail.
[0101] Step S501, in the semantic evaluation layer, the semantic evaluation scores corresponding to the word embedding vector and the semantic extension vector are calculated according to the similarity distance between the word embedding vector and the semantic extension vector and the preset semantic feature.
[0102] Step S502, determine whether the semantic evaluation scores have all reached a preset score value. If they have, execute step S503; otherwise, execute step S504.
[0103] Step S503: If all the above conditions are met, output a semantic evaluation result indicating that the semantic feature does not contain sensitive information.
[0104] Step S504: On the contrary, outputting the semantic evaluation result of the semantic feature having sensitive information.
[0105] In step S501 to step S504, the word embedding vector and the semantic extension vector are input into the semantic evaluation layer, and the semantic evaluation layer is used to perform semantic evaluation on the word embedding vector and the semantic extension vector, and the similarity between the word embedding vector and the predefined semantic feature vector is determined, and the similarity between the semantic extension vector and the predefined semantic feature vector is determined, wherein the semantic feature vector includes a sensitive sentence feature vector and a non-sensitive sentence feature vector, and the determined similarity is used as the probability that the sentence corresponding to the word embedding vector and the sentence corresponding to the semantic extension vector belong to the sentence containing sensitive semantics, and the sentence corresponding to the word embedding vector and the sentence corresponding to the semantic extension vector are scored according to the size of the probability to obtain corresponding semantic evaluation scores, and when the semantic evaluation scores corresponding to the sentence corresponding to the word embedding vector and the sentence corresponding to the semantic extension vector both reach the preset score value, it is determined that the sensitive word filtering text does not have the risk of containing sensitive semantics, and the semantic evaluation result that the semantic feature does not have sensitive information is output, otherwise, it is determined that the sensitive word filtering text has the risk of containing sensitive semantics, and the semantic evaluation result that the semantic feature has sensitive information is output.
[0106] In a specific embodiment, the training process of the semantic filtering network specifically includes: using a sentence set consisting of paired sensitive sentences and non-sensitive sentences to perform pair-wise loss training on a preset semantic filtering network, performing score interpolation between the semantic feature vectors corresponding to the sensitive sentences and the semantic feature vectors corresponding to the non-sensitive sentences, fitting the semantic evaluation scores of all the semantic feature vectors, and thus training the semantic filtering network.
[0107] Step S104, generating corresponding text review results according to the semantic evaluation results.
[0108] In step S104, based on the semantic evaluation result, the sensitivity of the sentences in the sensitive word filtering text in the current semantic environment and in other semantic environments is determined. This can be done by assigning corresponding security scores to the sensitivity of the sentences in the sensitive word filtering text in the current semantic environment and in other semantic environments, and statistically analyzing the distribution of these security scores to determine whether there are sentences with a security score less than a preset score threshold (i.e., unsafe). If so, it indicates that the semantics of the sentence has a greater risk and is prone to produce unsafe semantics in different semantic environments. The potential risks of the sentences in the sensitive word filtering text are quantitatively evaluated, and corresponding text review results are generated. For example, when there are potential risks in the sentences in the sensitive word filtering text, the sensitive word filtering text is not output or the relevant sentences of the sensitive word filtering text are further optimized before being output.
[0109] In a specific embodiment, see Figure 6 , Figure 6is a flowchart of a specific method of step S104 provided in an embodiment of the present application. Step S104 may specifically include but is not limited to steps S601 to S605. Figure 6 These five steps are introduced in detail.
[0110] Step S601, determining whether the semantic evaluation result indicates that the semantic feature contains sensitive information.
[0111] If not, execute step S602; if yes, execute step S603.
[0112] Step S602, generating and outputting text review results of the sensitive word filtered text.
[0113] Step S603, determining whether the number of times the text to be reviewed is generated reaches a preset number threshold.
[0114] If not, execute step S604; if reached, execute step S605.
[0115] Step S604, adjusting the temperature coefficient of the text generation network; returning to the step of obtaining the text to be reviewed generated by the text generation network.
[0116] Step S605, generating a text review result without outputting the sensitive word filtered text.
[0117] In step S601 to step S605, if the semantic evaluation result indicates that the semantic feature does not contain sensitive information (for example, the security scores obtained from the semantic features before and after the semantic expansion of the sensitive word filtering text all reach the preset score threshold), a text review result for outputting the sensitive word filtering text is generated, and the content of the sensitive word filtering text is allowed to be output; if the semantic evaluation result indicates that the semantic feature contains sensitive information (for example, the security scores obtained from the semantic features before and after the semantic expansion of the sensitive word filtering text all fail to reach the preset score threshold), when the number of times the text to be reviewed is generated reaches the preset number threshold, it indicates that the input text has a very strong unsafe inducing effect, and a text review result for not outputting the sensitive word filtering text is generated, and the content of the sensitive word filtering text is prohibited from being output; when the number of times the text to be reviewed is generated does not reach the preset number threshold, the temperature coefficient of the text generation network is adjusted to increase the randomness of the text generation network in generating the text to be reviewed, and the text to be reviewed and the semantic evaluation result are iteratively generated until the semantic evaluation result indicates that the semantic feature does not contain sensitive information or the number of times the text to be reviewed is generated reaches the preset number threshold.
[0118] See also Figure 7 The present application also provides a text review device that can implement the above text review method. The device includes:
[0119] The first module 701 is used to obtain the text to be reviewed generated by the text generation network;
[0120] The second module 702 is used to input the text to be reviewed into the sensitive word filtering network of the text review network, replace the sensitive words contained in the text to be reviewed, and obtain the sensitive word filtered text;
[0121] The third module 703 is used to input the sensitive word filtering text into the semantic filtering network of the text review network, perform semantic evaluation on the sensitive word filtering text and semantic evaluation after semantic expansion to obtain a semantic evaluation result; the semantic evaluation result represents the sensitivity of the semantic features of the sensitive word filtering text before and after semantic expansion;
[0122] The fourth module 704 is used to generate corresponding text review results according to the semantic evaluation results.
[0123] The specific implementation of the text review device is basically the same as the specific implementation of the above-mentioned text review method, and will not be repeated here.
[0124] Figure 8 It is a block diagram of an electronic device according to an exemplary embodiment.
[0125] Refer to the following Figure 8 The electronic device 800 according to this embodiment of the present disclosure is described. Figure 8 The electronic device 800 shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0126] like Figure 8 As shown, the electronic device 800 is in the form of a general computing device. The components of the electronic device 800 may include, but are not limited to: at least one processing unit 810, at least one storage unit 820, a bus 830 connecting different system components (including the storage unit 820 and the processing unit 810), a display unit 840, etc.
[0127] The storage unit stores program codes, which can be executed by the processing unit 810, so that the processing unit 810 executes the steps described in the above text review method section of this specification according to various exemplary embodiments of the present disclosure.
[0128] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 8201 and / or a cache memory unit 8202 , and may further include a read-only memory unit (ROM) 8203 .
[0129] The storage unit 820 may also include a program / utility 8204 having a set (at least one) of program modules 8205, such program modules 8205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0130] Bus 830 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0131] The electronic device 800 may also communicate with one or more external devices 800' (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 800, and / or communicate with any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 850. Furthermore, the electronic device 800 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 860. The network adapter 860 may communicate with other modules of the electronic device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0132] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the above-mentioned text review method is implemented.
[0133] The text review method, device, equipment and storage medium provided in the embodiment of the present application first input the text to be reviewed into the sensitive word filtering network of the text review network, replace the sensitive words contained in the text to be reviewed to obtain the sensitive word filtered text, and then input the sensitive word filtered text into the semantic filtering network of the text review network, perform semantic evaluation on the sensitive word filtered text and semantic evaluation after semantic expansion to obtain a semantic evaluation result that characterizes the sensitivity of the semantic features of the sensitive word filtered text before and after semantic expansion, and generate a corresponding text review result based on the semantic evaluation result. Since keyword filtering and semantic evaluation are used simultaneously to perform text security review on the text to be reviewed, and the sentences of the text after keyword filtering are semantically evaluated in the current semantic environment and semantically evaluated after semantic expansion to determine the security risks of the sentences of the text after keyword filtering in different semantic environments, the comprehensiveness and accuracy of the review of sensitive information contained in the text content can be improved.
[0134] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, or a network device, etc.) to execute the above method according to the implementation of the present disclosure.
[0135] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0136] Computer readable storage media may include data signals propagated in baseband or as part of a carrier wave, wherein readable program codes are carried. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The readable storage medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, device, or device. The program codes contained on the readable storage medium may be transmitted using any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination thereof.
[0137] Program code for performing the operations of the present disclosure may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0138] Those skilled in the art will appreciate that the above modules can be distributed in the device according to the description of the embodiment, or can be changed accordingly and only used in one or more devices different from the embodiment. The modules of the above embodiments can be combined into one module, or further divided into multiple sub-modules.
[0139] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the embodiment of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiment of the present disclosure.
[0140] The exemplary embodiments of the present disclosure are specifically shown and described above. It should be understood that the present disclosure is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present disclosure is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended claims.
Claims
1. A text review method, characterized in that: include: Obtain the text to be reviewed generated by the text generation network; Inputting the text to be reviewed into a sensitive word filtering network of a text review network, replacing sensitive words contained in the text to be reviewed, and obtaining a sensitive word filtered text; Inputting the sensitive word filtering text into the semantic filtering network of the text review network, performing semantic evaluation on the sensitive word filtering text and performing semantic evaluation after semantic expansion to obtain a semantic evaluation result; the semantic evaluation result represents the sensitivity of the semantic features of the sensitive word filtering text before and after the semantic expansion; Generating corresponding text review results according to the semantic evaluation results; The sensitive word filtering network includes a context semantic recognition layer, a sensitive word screening layer and a sensitive word replacement layer. The sensitive word filtering network of the text review network inputs the text to be reviewed into the sensitive word filtering network, replaces the sensitive words contained in the text to be reviewed, and obtains the sensitive word filtered text, including: Inputting the text to be reviewed into the context semantic recognition layer, performing context semantic recognition on the text to be reviewed, and obtaining a context semantic recognition result; Inputting the context semantic recognition result and the text to be reviewed into the sensitive word screening layer, screening the text to be reviewed for sensitive words according to the context semantic recognition result to obtain original sensitive words; Inputting the context semantic recognition result and the original sensitive word into the sensitive word replacement layer, generating a plurality of semantically similar words of the original sensitive word according to the context semantic recognition result, generating a target replacement word according to the original sensitive word and the plurality of semantically similar words, and replacing the original sensitive word in the to-be-examined text with the target replacement word to obtain the sensitive word filtered text; The sensitive word screening layer includes a sensitive word extraction sublayer, a feature association analysis sublayer and a sensitive word screening sublayer. The context semantic recognition result and the text to be reviewed are input into the sensitive word screening layer, and the text to be reviewed is screened for sensitive words according to the context semantic recognition result to obtain original sensitive words, including: Inputting the text to be reviewed into the sensitive word extraction sublayer, extracting sensitive words from the text to be reviewed, and obtaining a plurality of candidate sensitive words; Inputting the context semantic recognition result and the candidate sensitive word into the feature association analysis sublayer, performing feature association analysis on the context semantic recognition result and the candidate sensitive word, and obtaining feature association information between the context semantic recognition result and the candidate sensitive word, The feature association information and the candidate sensitive words are input into the sensitive word screening sublayer, and the candidate sensitive words are screened according to the feature association information to obtain the original sensitive words.
2. The text review method according to claim 1, characterized in that: The semantic filtering network includes a word embedding layer, a semantic expansion layer and a semantic evaluation layer. The sensitive word filtering text is input into the semantic filtering network of the text review network, and the sensitive word filtering text is subjected to semantic evaluation and semantic evaluation after semantic expansion to obtain a semantic evaluation result, including: Inputting the sensitive word filtering text into the word embedding layer, embedding the sensitive word filtering text into words, and obtaining a word embedding vector; Inputting the word embedding vector into the semantic extension layer, performing semantic extension on the word embedding vector, and obtaining a semantic extension vector; The word embedding vector and the semantic extension vector are input into the semantic evaluation layer, and semantic evaluation is performed on the word embedding vector and the semantic extension vector to obtain the semantic evaluation result.
3. The text review method according to claim 2, characterized in that: The step of inputting the word embedding vector into the semantic extension layer and performing semantic extension on the word embedding vector to obtain the semantic extension vector includes: Obtaining a number of random vectors; the random vectors obey a Gaussian distribution; The word embedding vector and the random vector are input into the semantic extension layer, and the word embedding vector and the random vector are fitted to obtain the semantic extension vector.
4. The text review method according to claim 2, characterized in that: The step of inputting the word embedding vector and the semantic extension vector into the semantic evaluation layer, performing semantic evaluation on the word embedding vector and the semantic extension vector, and obtaining the semantic evaluation result includes: In the semantic evaluation layer, the semantic evaluation scores corresponding to the word embedding vector and the semantic extension vector are calculated according to the similarity distance between the word embedding vector and the semantic extension vector and the preset semantic feature; Determining whether the semantic evaluation scores all reach a preset score value; If all of them are achieved, output a semantic evaluation result that the semantic feature does not contain sensitive information; Otherwise, the semantic evaluation result indicating that the semantic feature has sensitive information is output.
5. The text review method according to claim 1, characterized in that: Generating corresponding text review results according to the semantic evaluation results includes: Determining whether the semantic evaluation result indicates that the semantic feature contains sensitive information; If not, generate and output the text review result of the sensitive word filtering text; If yes, determining whether the number of times the to-be-examined text is generated reaches a preset number threshold; If it is not reached, adjusting the temperature coefficient of the text generation network; returning to the step of obtaining the text to be reviewed generated by the text generation network; If achieved, a text review result is generated without outputting the sensitive word filtered text.
6. A text review device, characterized in that: include: The first module is used to obtain the text to be reviewed generated by the text generation network; The second module is used to input the text to be reviewed into the sensitive word filtering network of the text review network, replace the sensitive words contained in the text to be reviewed, and obtain a sensitive word filtered text; The third module is used to input the sensitive word filtering text into the semantic filtering network of the text review network, perform semantic evaluation on the sensitive word filtering text and perform semantic evaluation after semantic expansion to obtain a semantic evaluation result; the semantic evaluation result represents the sensitivity of the semantic features of the sensitive word filtering text before and after semantic expansion; The fourth module is used to generate corresponding text review results according to the semantic evaluation results; The sensitive word filtering network includes a context semantic recognition layer, a sensitive word screening layer and a sensitive word replacement layer. The sensitive word filtering network of the text review network inputs the text to be reviewed into the sensitive word filtering network, replaces the sensitive words contained in the text to be reviewed, and obtains the sensitive word filtered text, including: Inputting the text to be reviewed into the context semantic recognition layer, performing context semantic recognition on the text to be reviewed, and obtaining a context semantic recognition result; Inputting the context semantic recognition result and the text to be reviewed into the sensitive word screening layer, screening the text to be reviewed for sensitive words according to the context semantic recognition result to obtain original sensitive words; Inputting the context semantic recognition result and the original sensitive word into the sensitive word replacement layer, generating a plurality of semantically similar words of the original sensitive word according to the context semantic recognition result, generating a target replacement word according to the original sensitive word and the plurality of semantically similar words, and replacing the original sensitive word in the to-be-examined text with the target replacement word to obtain the sensitive word filtered text; The sensitive word screening layer includes a sensitive word extraction sublayer, a feature association analysis sublayer and a sensitive word screening sublayer. The context semantic recognition result and the text to be reviewed are input into the sensitive word screening layer, and the text to be reviewed is screened for sensitive words according to the context semantic recognition result to obtain original sensitive words, including: Inputting the text to be reviewed into the sensitive word extraction sublayer, extracting sensitive words from the text to be reviewed, and obtaining a plurality of candidate sensitive words; Inputting the context semantic recognition result and the candidate sensitive word into the feature association analysis sublayer, performing feature association analysis on the context semantic recognition result and the candidate sensitive word, and obtaining feature association information between the context semantic recognition result and the candidate sensitive word, The feature association information and the candidate sensitive words are input into the sensitive word screening sublayer, and the candidate sensitive words are screened according to the feature association information to obtain the original sensitive words.
7. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the text review method according to any one of claims 1 to 5 when executing the computer program.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the text review method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Text desensitization method and device
CN110633577A
Short text auditing method and device fusing variant word recognition
CN112287684A
Text content auditing method for Chinese novel field
CN114139533A
Sensitive word detection method and device, electronic equipment and readable storage medium
CN114860897A
Text auditing model training method and device and text auditing method and device
CN116010606A
