A sensitive word detection method, device and electronic equipment

CN122904040APending Publication Date: 2026-10-13CHINA TELECOM NETWORK SECURITY TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611311639.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-27
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

故而,导致传统方法难以识别采用变体使用方式的中文敏感词

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122904040A_ABST
    Figure CN122904040A_ABST
Patent Text Reader

Abstract

The application discloses a sensitive word detection method and device and electronic equipment, and relates to the technical field of computers, to improve the detection accuracy of various variant sensitive words. The method comprises the following steps: firstly, feature extraction is performed on the text to be detected to obtain a target semantic vector, and a target graph convolution vector is obtained based on target graph structure data; secondly, the target semantic vector and the target graph convolution vector are fused to obtain a target fusion vector; finally, sensitive word detection is performed based on the target fusion vector to obtain the probability that the text to be detected belongs to each type of sensitive word. Through the above method, the double-channel attention mechanism can focus on key information, the sensitive words are processed through the local attention mechanism and the global attention mechanism, the deep context semantic understanding ability and the structured relationship reasoning ability of the sensitive word variants can be possessed, and therefore the recognition accuracy of the variant sensitive words can be significantly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a sensitive word detection method, apparatus and electronic device. Background

[0002] At present, under the wave of digitalization, Chinese text data on the Internet is showing an exponential growth trend, and the complexity and diversity of its content ecology are increasingly prominent. In this context, accurate identification and classification of Chinese sensitive words involving politically sensitive, violent, vulgar and other contents has become a core demand for maintaining network content security and social stability.

[0003] However, in order to evade regulatory detection, a variety of variant usage methods for Chinese sensitive words have appeared on the network. For example, at the character form level, similar-shaped characters are used to replace specific Chinese sensitive words (such as replacing the character "婊" with "表" for display), or specific Chinese sensitive words are represented by splitting character radicals (such as representing the character "渣" as "氵+查"), or symbols are used for mixing, introducing letters, numbers, special symbols, etc. to represent specific Chinese sensitive words (such as representing the character "惨" as "ca3n"), and homophones can also be used to represent specific Chinese sensitive words (such as representing the word "和谐" as "河蟹").

[0004] In related technologies, the identification of Chinese sensitive words is usually carried out with the core of identifying the semantics of Chinese sensitive words. These variant usage methods are related to the original Chinese sensitive words at the visual or phonetic level, but have discrete differences from the original Chinese sensitive words at the text character sequence level. Therefore, it is difficult for traditional methods to identify Chinese sensitive words using variant usage methods.

[0005] In view of this, how to significantly improve the accuracy of identifying Chinese sensitive words that use variant usage methods is an urgent technical problem to be solved at present. Summary of the Invention

[0006] The embodiments of the present application provide a sensitive word detection method, apparatus and electronic device, so as to improve the detection accuracy of variant Chinese sensitive words.

[0007] In a first aspect, the present application provides a sensitive word detection method, where the method includes: Performing feature extraction on the to-be-detected text to obtain a target semantic vector, and obtaining a target graph convolution vector based on target graph structure data; wherein the target semantic vector is obtained based on a character embedding vector, a pinyin embedding vector and a glyph embedding vector, and the target graph structure data is constructed based on word nodes and each sensitive word type node; Fusing the target semantic vector and the target graph convolution vector to obtain a target fused vector; Sensitive word detection is performed based on target fusion vectors to obtain the probability that the text to be detected belongs to various sensitive word types.

[0008] The above method, through the dual-channel attention mechanism, can focus on key information. By processing sensitive words through local and global attention mechanisms, it can have the ability to understand deep contextual semantics and reason about the structured relationships of sensitive word variants, thereby significantly improving the recognition accuracy of variant sensitive words.

[0009] In one optional implementation, feature extraction is performed on the text to be detected to obtain a target semantic vector, including: Based on character embedding vectors, pinyin embedding vectors, and glyph embedding vectors, a target embedding vector sequence is obtained; A multi-head self-attention mechanism is used to process the target embedding vector sequence to obtain the hidden state sequence; The attention weights corresponding to each hidden state vector in the hidden state sequence are calculated based on the preset query vectors. The target semantic vector is obtained by weighted summation of each hidden state vector and its corresponding attention weight.

[0010] The above method employs a multi-head self-attention mechanism to extract global semantic information, which can dynamically distinguish the sensitivity of words based on the context. The resulting target semantic vector integrates the deep semantic information of the text and strengthens key features related to sensitive content.

[0011] In one alternative implementation, the target graph structure data is obtained in the following manner: Each word in the text to be detected is taken as a word node, and each sensitive word type is taken as a sensitive word type node. A first weight is determined between two word nodes, and a second weight is determined between a word node and a sensitive word type node. The first weight is obtained based on the inter-point mutual information and mixed phonetic-morphological similarity between the two word nodes. The mixed phonetic-morphological similarity characterizes the degree of phonetic-morphological similarity between the two words. The second weight is obtained based on a preset unit matrix, a preset weight factor, and statistical correlation. The statistical correlation is used to measure the strength of the statistical correlation between the word and the sensitive word type. The target graph structure data is obtained based on word nodes, sensitive word type nodes, first weight, and second weight.

[0012] Using the above method, a graph structure data that can display the "sound-form-meaning" relationship between sensitive words and their variants is constructed based on the comprehensive encirclement of semantics, pinyin and character similarity. This provides a structural basis for the classification of sensitive word variants.

[0013] In one optional implementation, obtaining the target graph convolution vector based on the target graph structure data includes: Based on the target graph structure data, determine the local attention weight between any word node and its neighboring nodes, and determine the global attention weight between any word node and sensitive word type nodes. Target fusion weights are obtained based on local attention weights and global attention weights; Based on the target fusion weights, feature aggregation is performed on word nodes to obtain the target graph convolution vector.

[0014] The above method introduces local and global attention into the graph convolution process, optimizes the information aggregation within the sensitive word variants, and injects the classification target as a priori attention, thereby improving the ability to focus on key features.

[0015] In one optional implementation, the target semantic vector and the target graph convolution vector are fused to obtain a target fused vector, including: The target semantic vector and the target graph convolution vector are projected separately to obtain the target semantic projection vector and the target graph convolution projection vector; wherein the target semantic projection vector and the target graph convolution projection vector have the same dimension. The target gating vector is obtained based on the target semantic projection vector and the target graph convolutional projection vector. The target semantic projection vector and the target graph convolutional projection vector are fused based on the target gating vector to obtain the target fused vector.

[0016] By employing the above method and using a gating mechanism to fuse semantic features and graph convolutional features, the dependence on semantic and structural information can be automatically adjusted according to the specific characteristics of the input text. This improves the sensitivity to character phonetic and morphological features, thereby enhancing the accuracy of identifying sensitive word variants.

[0017] Secondly, this application provides a sensitive word detection device, the device comprising: The processing module is used to extract features from the text to be detected, obtain the target semantic vector, and obtain the target graph convolution vector based on the target graph structure data. The target semantic vector is obtained based on character embedding vector, pinyin embedding vector and glyph embedding vector, and the target graph structure data is constructed based on word nodes and nodes of various sensitive word types. The fusion module is used to fuse the target semantic vector and the target graph convolution vector to obtain the target fused vector; The detection module is used to detect sensitive words based on the target fusion vector and obtain the probability that the text to be detected belongs to various types of sensitive words.

[0018] In one optional implementation, when performing feature extraction on the text to be detected to obtain the target semantic vector, the processing module is specifically used for: Based on character embedding vectors, pinyin embedding vectors, and glyph embedding vectors, a target embedding vector sequence is obtained; A multi-head self-attention mechanism is used to process the target embedding vector sequence to obtain the hidden state sequence; The attention weights corresponding to each hidden state vector in the hidden state sequence are calculated based on the preset query vectors. The target semantic vector is obtained by weighted summation of each hidden state vector and its corresponding attention weight.

[0019] In one alternative implementation, the target graph structure data is obtained in the following manner: Each word in the text to be detected is taken as a word node, and each sensitive word type is taken as a sensitive word type node. A first weight is determined between two word nodes, and a second weight is determined between a word node and a sensitive word type node. The first weight is obtained based on the inter-point mutual information and mixed phonetic-morphological similarity between the two word nodes. The mixed phonetic-morphological similarity characterizes the degree of phonetic-morphological similarity between the two words. The second weight is obtained based on a preset unit matrix, a preset weight factor, and statistical correlation. The statistical correlation is used to measure the strength of the statistical correlation between the word and the sensitive word type. The target graph structure data is obtained based on word nodes, sensitive word type nodes, first weight, and second weight.

[0020] In one optional implementation, when obtaining the target graph convolution vector based on the target graph structure data, the processing module is specifically used for: Based on the target graph structure data, determine the local attention weight between any word node and its neighboring nodes, and determine the global attention weight between any word node and sensitive word type nodes. Target fusion weights are obtained based on local attention weights and global attention weights; Based on the target fusion weights, feature aggregation is performed on word nodes to obtain the target graph convolution vector.

[0021] In one optional implementation, when fusing the target semantic vector and the target graph convolution vector to obtain the target fused vector, the fusion module is specifically used for: The target semantic vector and the target graph convolution vector are projected separately to obtain the target semantic projection vector and the target graph convolution projection vector; wherein the target semantic projection vector and the target graph convolution projection vector have the same dimension. The target gating vector is obtained based on the target semantic projection vector and the target graph convolutional projection vector. The target semantic projection vector and the target graph convolutional projection vector are fused based on the target gating vector to obtain the target fused vector.

[0022] Thirdly, this application provides an electronic device including a processor and a memory, wherein the memory stores program code that, when executed by the processor, causes the processor to perform the steps of the sensitive word detection method described in the first aspect.

[0023] Fourthly, this application provides a computer-readable storage medium including program code that, when run on an electronic device, causes the electronic device to perform the steps of the sensitive word detection method described in the first aspect.

[0024] Fifthly, this application provides a computer program product that, when invoked by a computer, causes the computer to execute the sensitive word detection method steps as described in the first aspect.

[0025] Furthermore, other features and advantages of this application will be set forth in the following description and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings: Figure 1 A schematic diagram of a suitable system architecture is provided for an embodiment of this application; Figure 2 A flowchart illustrating a sensitive word detection method provided in an embodiment of this application; Figure 3 An example diagram of target graph structure data provided in an embodiment of this application; Figure 4 This application provides a schematic diagram of the structure of a sensitive word detection device; Figure 5 This application provides a schematic diagram of the structure of an electronic device. Detailed Implementation

[0027] To make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solutions of the present application, rather than all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments recorded in the present application document without creative efforts shall fall within the protection scope of the technical solutions of the present application.

[0028] It should be noted that in the description of the present application, "a plurality of" is understood as "at least two". "And / or" describes the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. The connection between A and B may represent two cases: direct connection between A and B, and connection between A and B through C. In addition, in the description of the present application, terms such as "first" and "second" are only used for the purpose of distinguishing descriptions, and cannot be construed as indicating or implying relative importance, nor can they be construed as indicating or implying order.

[0029] In addition, in the technical solutions of the present application, the collection, dissemination, use and the like of data all comply with the requirements of relevant national laws and regulations.

[0030] The design idea of the embodiments of the present application is briefly introduced as follows: At present, under the wave of digitalization, Chinese text data on the Internet is showing an exponential growth trend, and the complexity and diversity of its content ecology are becoming increasingly prominent. In this context, accurate identification and classification of Chinese sensitive words involving politically sensitive, violent, vulgar and other content has become a core demand for maintaining network content security and social stability.

[0031] However, in order to evade supervision and detection, a variety of variant usage methods for Chinese sensitive words have appeared on the network. For example, at the character form level, similar-shaped characters are used to replace specific Chinese sensitive words (for example, replacing "biao" (a derogatory term) with "biao" (table) for display), or specific Chinese sensitive words are represented by splitting character radicals (for example, marking "zha" (scumbag) as "water radical + zha (check)"), or symbols are used for mixing, introducing letters, numbers and special symbols to represent specific Chinese sensitive words (for example, representing "can" (miserable) as "ca3n"), and homophones can also be used to represent specific Chinese sensitive words (for example, representing "hexie" (harmonious, as a euphemism for censorship) as "hexie" (river crab)).

[0032] In the related art, the recognition of Chinese sensitive words is usually carried out with the semantics of the Chinese sensitive words as the core. These variant usage methods are associated with the original Chinese sensitive words at the visual or phonetic level, but have discretized differences from the original Chinese sensitive words at the text character sequence level. Therefore, it is difficult for traditional methods to identify Chinese sensitive words that adopt variant usage methods.

[0033] In view of this, embodiments of this application provide a sensitive word detection method that can significantly improve the detection accuracy of variant Chinese sensitive words. The method includes: first, extracting features from the text to be detected to obtain a target semantic vector, and obtaining a target graph convolution vector based on target graph structure data; wherein the target semantic vector is obtained based on character embedding vectors, pinyin embedding vectors, and glyph embedding vectors, and the target graph structure data is constructed based on word nodes and nodes of various sensitive word types; then, fusing the target semantic vector and the target graph convolution vector to obtain a target fusion vector; finally, performing sensitive word detection based on the target fusion vector to obtain the probability that the text to be detected belongs to each type of sensitive word. Through the above method, the dual-channel attention mechanism can focus on key information, and the local and global attention mechanisms can process sensitive words, enabling deep contextual semantic understanding and structured relational reasoning for sensitive word variants, thereby significantly improving the recognition accuracy of variant sensitive words.

[0034] It should be noted that the acquisition, storage, use, and processing of data in this application embodiment all comply with the relevant provisions of national laws and regulations.

[0035] See Figure 1 The diagram shown illustrates a system architecture according to an embodiment of this application. This system architecture includes a target terminal 101 and a server 102. The target terminal 101 and the server 102 can interact via a communication network. The communication network can employ wireless communication or wired communication methods.

[0036] For example, the target terminal 101 can access the network and communicate with the server 102 through cellular mobile communication technology, wherein the cellular mobile communication technology includes, for example, 5th generation mobile networks (5G) technology.

[0037] Optionally, the target terminal 101 can access the network and communicate with the server 102 via short-range wireless communication, wherein the short-range wireless communication method includes, for example, Wireless Fidelity (Wi-Fi) technology.

[0038] This application embodiment does not impose any limitation on the number of communication devices involved in the above system architecture. For example, there may be more target terminals, or no target terminals, or other network devices may be included, such as... Figure 1 As shown, only the target terminal 101 and server 102 are described as examples. The following is a brief introduction to each of the above devices and their respective functions.

[0039] The target terminal 101 is a device that can provide voice and / or data connectivity to a user, and may be a device that supports limited and / or wireless connectivity.

[0040] For example, the target terminal 101 includes, but is not limited to: mobile phones, tablets, laptops, handheld computers, mobile internet devices (MID), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminal devices in industrial control, wireless terminal devices in autonomous driving, wireless terminal devices in smart grids, wireless terminal devices in transportation safety, wireless terminal devices in smart cities, or wireless terminal devices in smart homes, etc.

[0041] Furthermore, the target terminal 101 may have a related client installed, and this client may be software, such as an application (APP), browser, short video software, etc., or it may be a network element, mini-program, etc. In this embodiment of the application, the target terminal 101 may use the aforementioned client related to sensitive word detection to send the text to be detected to the server 102 for subsequent sensitive word detection methods.

[0042] Server 102 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence platforms.

[0043] It is worth noting that, in the embodiments of this application, the methods in these embodiments can be executed by an electronic device, which can be the target terminal 101 or the server 102. That is, the method can be executed by the terminal device 101 or the server 102 alone, or by the target terminal device 101 and the server 102 together. Furthermore, the executing entities for each method can be the same or different, and this embodiment of the application does not impose any restrictions on this.

[0044] For example, when the sensitive word detection method provided by the present application is executed solely by the target terminal 101, the target terminal 101 may directly perform feature extraction on the to-be-detected text to obtain a target semantic vector, and obtain a target graph convolution vector based on target graph structure data; then, the target semantic vector and the target graph convolution vector are fused to obtain a target fused vector; finally, sensitive word detection is performed based on the target fused vector to obtain the probability that the to-be-detected text belongs to each type of sensitive word category.

[0045] For another example, when the sensitive word detection method of the present application is executed jointly by the target terminal 101 and the server 102, the target terminal 101 may send the to-be-detected text to the server 102, and the server 102 performs feature extraction on the to-be-detected text to obtain a target semantic vector, and obtains a target graph convolution vector based on target graph structure data; then, the target semantic vector and the target graph convolution vector are fused to obtain a target fused vector; finally, sensitive word detection is performed based on the target fused vector to obtain the probability that the to-be-detected text belongs to each type of sensitive word category.

[0046] The sensitive word detection method provided by the exemplary embodiments of the present application is described below with reference to the accompanying drawings.

[0047] Refer to Figure 2 which shows a schematic diagram of the implementation process of a sensitive word detection method provided by the embodiment of the present application, and the specific implementation process of the method is as follows: S1: Perform feature extraction on the to-be-detected text to obtain a target semantic vector, and obtain a target graph convolution vector based on target graph structure data.

[0048] In the embodiment of the present application, sensitive words may be pre-collected from various channels first, and then the collected sensitive words are classified, so as to construct a sensitive word knowledge base, which facilitates subsequent sensitive word detection on the to-be-detected text based on the sensitive word knowledge base.

[0049] When pre-collecting sensitive words, relevant non-compliant terms and variant forms can be extracted from public lexicons, such as "Complete Collection of Chinese Sensitive Words", publicly published prohibited vocabulary and non-compliance lists of relevant institutions, and public content of Internet social platforms.

[0050] Then, preprocessing is performed on the pre-collected sensitive words, for example, regular expressions are used to remove non-text characters such as URLs, HTML tags, and emoticons, and format unification may also be performed, for example, converting traditional Chinese characters to simplified Chinese characters, and converting full-width characters to half-width characters, etc. In addition, stop word removal may also be performed, that is, deleting high-frequency but low-semantic-information stop words such as "de", "le", and "zai" that appear in the text, so as to enhance the density of key sensitive information.

[0051] Further, after preprocessing the pre-collected sensitive words, a sensitive word knowledge base with a clear type system can be constructed. As shown in Table 1 below, 7 types of sensitive words can be constructed in the embodiments of the present application. Certainly, other types of sensitive words can also be constructed according to actual needs, and the present application only takes the following 7 types of sensitive words as examples.

[0052] Table 1

[0053] In this way, by classifying the pre-collected sensitive words and constructing the sensitive word knowledge base, a semantic basis can be provided for subsequent construction of graph structure data and sensitive word detection tasks.

[0054] Further, after obtaining the to-be-detected text, preprocessing can also be performed first to obtain a standardized text, and then feature extraction is performed on the to-be-detected text to obtain a target semantic vector.

[0055] In order to realize sensitive word detection for near-shaped character substitution, symbol substitution, and homophonic substitution, in the embodiments of the present application, it is first necessary to extract a character embedding vector, a pinyin embedding vector, and a glyph embedding vector based on the to-be-detected text. That is, when performing feature extraction on the to-be-detected text, the target semantic vector can be obtained based on the character embedding vector, the pinyin embedding vector, and the glyph embedding vector. The character embedding vector can provide the basic direction of semantics (for example, identifying "attack"), the pinyin embedding vector can capture abnormal associations of homophones at the phonetic level (for example, identifying that "sha" meaning kill is replaced by "sha" meaning shark), and the glyph embedding vector can capture abnormal associations of near-shaped characters or split characters (for example, identifying that "zha" meaning dregs is split into "water radical + zha meaning check").

[0056] In an optional embodiment, after obtaining the character embedding vector, pinyin embedding vector and glyph embedding vector corresponding to the to-be-detected text, the character embedding vector, pinyin embedding vector and glyph embedding vector can be spliced to obtain a target embedding vector sequence. The target embedding vector sequence obtained by splicing can provide a rich feature basis of "pronunciation-glyph-meaning" for subsequent deep semantic understanding, or in other words, can perform sensitive word recognition from multiple dimensions of pronunciation, glyph and meaning.

[0057] Then, a multi-head self-attention mechanism is used to process the target embedding vector sequence to obtain the hidden state sequence. Specifically, in this embodiment, the target embedding vector sequence is input into a Transformer encoder with a preset number of layers (e.g., 12 layers) for processing. Through the multi-head attention mechanism, a hidden state sequence is generated. In the shallow layers of the Transformer encoder, more attention is paid to local syntax and phrase structure, while in the middle layers, more attention is paid to grammatical dependencies, and in the deep layers, more attention is paid to global semantics and usage intent. In this way, the sensitivity of words can be dynamically distinguished based on the text context. For example, for the word "gun," it is possible to further distinguish between the different contexts of "toy gun" (non-sensitive) and "buy a gun." In the real-time example of this application, the above hidden state sequence can be represented as: That is, each layer of the Transformer encoder outputs a hidden state for the target embedding vector sequence, and the hidden states output by each layer are combined to obtain the above hidden state sequence.

[0058] In this embodiment of the application, in order to further enhance the ability to identify sensitive words, a preset query vector q is introduced to calculate the attention weight corresponding to each hidden state vector in the hidden state sequence. Through the preset query vector, the semantic, pinyin and character shape associations of sensitive words can be further focused on in the hidden states of all words, so as to focus on words that are potentially related to sensitive content.

[0059] Specifically, in this embodiment, the attention weight corresponding to each hidden state vector can be calculated using the following formula (1):

[0060] in, Indicates attention weight; q represents the preset query vector; This represents the i-th hidden state vector; This represents each hidden state vector during the traversal process.

[0061] The attention weights corresponding to each hidden state vector are calculated using the above formula (1). Then, a weighted sum is performed based on each hidden state vector and the attention weights corresponding to each hidden state vector to obtain the target semantic vector representing the entire text.

[0062] Specifically, the target semantic vector mentioned above can be calculated using the following formula (2):

[0063] in, Indicates attention weight; This represents the hidden state vector.

[0064] The target semantic vector obtained in this way integrates the deep semantic information of the text and strengthens the key features related to sensitive content, providing a powerful global semantic representation for subsequent classification decisions.

[0065] In this application embodiment, in order to obtain the structural features of sensitive words and their variants, this application also adopts a graph attention mechanism to enhance the degree of sharing of key sensitive words across categories.

[0066] In one alternative implementation, first, the target graph structure data is constructed, see [reference]. Figure 3 As shown, in this target graph structure data, each word in the text to be detected is used as a word node. Each sensitive word type (i.e., the 7 sensitive word types in Table 1 above) is used as a sensitive word type node. Specifically, the text to be detected is segmented into words using a word segmentation tool (such as jieba segmentation), and then each word is initialized using a pre-trained 256-word vector. The sensitive word type node is obtained by averaging the word vectors of sensitive words belonging to each sensitive word type in the preset knowledge base.

[0067] There is a first weight between any two word nodes, and a second weight between each word node and a sensitive word type node. The first weight is obtained based on the inter-point mutual information and the mixed phonetic-speech similarity between the two word nodes, while the mixed phonetic-speech similarity represents the degree of phonetic-speech similarity between the two words.

[0068] Specifically, the first weight mentioned above can be calculated using the following formula (3):

[0069] in, Indicates the first weight; Learnable parameters representing the balance between semantics and phonetic similarity; PMI ( () represents the inter-node mutual information between two word nodes, used to measure the semantic co-occurrence strength between words; Indicates the similarity between mixed sounds and shapes; This represents two word nodes.

[0070] Secondly, the mutual information between the points mentioned above can be calculated using the following formula (4):

[0071] in, Indicates mutual information between points; Indicates the probability of two words appearing together; The word w j The probability of appearing in the text; The word w l The probability of appearing in the text; Then, the above-mentioned mixed phonetic similarity can be calculated using the following formula (5):

[0072] in, Indicates the similarity between mixed sounds and shapes; Indicates the preset weighting factor; The similarity between two pinyin strings is represented by the normalized Lewinstein edit distance. The similarity of character shapes is represented by calculating the dynamic time-normalized distance of the radical sequence.

[0073] Furthermore, the above-mentioned pinyin similarity can be calculated using the following formula (6):

[0074] in, Indicates the similarity of character shapes; EditDistance The distance represents the Lewinston distance between two Pinyin strings, which is the minimum number of single-character edit operations required for conversion. The smaller the distance, the more similar the Pinyin strings are. Pinyin(w) represents the pinyin string of the word w.

[0075] Optionally, the above glyph similarity can be calculated using the following formula (7):

[0076] in, Indicates the similarity of character shapes; DTW ( () indicates the dynamic time regularization distance of the radical sequence; StrokeSeq(w) represents the stroke sequence of the word w; MaxPossibleDTW represents the preset normalization factor.

[0077] Optionally, in this embodiment, there is a second weight between the word node and the sensitive word type node. The second weight can represent the degree of association between the word and the sensitive word type, and can inject effective sensitive word category supervision signals into the graph structure data.

[0078] Specifically, in this embodiment, the second weight between the word node and the sensitive word type node can be calculated using the following formula (8):

[0079] in, This represents a preset weighting factor, which can be set to 0.6 to balance the contribution ratio of prior knowledge and statistical evidence. This indicates the statistical correlation, used to measure the strength of the statistical association between words and sensitive word types in the training corpus. c t Indicates the type of sensitive word.

[0080] Furthermore, the above statistical correlation It can be calculated using the following formula (9):

[0081] in, Indicates the degree of statistical correlation; Words In the category marked as sensitive words The number of times it appears in the document; Indicates the category of sensitive words. Total number of documents; Words The probability of it appearing in the entire corpus; This represents a smoothing factor used to prevent division by zero errors and logarithmic overflow.

[0082] In summary, the first weight between any two word nodes can be calculated using formula (3), and the second weight between any word node and sensitive word type node can be calculated using formula (8). Then, each word node and sensitive word type node is used as a node in the graph structure data, the first weight is used as the edge weight between each word node, and the second weight is used as the edge weight between each word node and each sensitive word type node, thus constructing the target graph structure data.

[0083] In this embodiment, a dual-channel attention map convolution method is used to introduce local and global attention into the target graph structure data. Local attention can optimize the information aggregation within sensitive word variants, while global attention injects classification as a priori, improving the ability to focus on key features and make decisions.

[0084] First, a local attention mechanism is used to determine the local attention weights between any word node and its neighboring nodes, and a global attention mechanism is used to determine the global attention weights between any word node and sensitive word type nodes.

[0085] Specifically, the local attention mechanism can discover potential relationships between similar word nodes in the target graph structure data, strengthening the "sound-form-meaning" association between sensitive words and their variants. When determining the local attention weights, a word node is used as the central node, and other word nodes of the same type are used as neighboring nodes. Therefore, the local attention weights can be calculated using the following formula (10):

[0086] Where softmax represents the normalization operation; Represents a linear rectified function; Represents the attention vector between nodes; This represents a vector concatenation operation; This represents the word node vector projected onto the same dimension.

[0087] Furthermore, the global attention weights can be calculated using the following formula (11):

[0088] in, , This represents the word node vector and the sensitive word type node vector after projection onto the same dimension; Represents the global attention matrix; Softmax represents the normalization operation; d=256 represents the scaling factor.

[0089] The global attention weight and local attention weight can be calculated using the above method. Then, the two attention weights are dynamically fused using learnable weight parameters to obtain the target fusion weight. Specifically, the target fusion weight can be calculated using the following formula (12):

[0090] in, Identify learnable weight parameters; Represents local attention weights; This represents the global attention weight.

[0091] Furthermore, after obtaining the target fusion weights, feature aggregation can be performed on word nodes based on the target fusion weights to obtain the target graph convolution vector. Firstly, after obtaining the target fusion weights, word nodes can be updated, allowing for the extraction of sensitive features and the summarization of the original features of neighboring nodes. In this embodiment, the following formula (13) can be used to update word nodes:

[0092] in, Indicates the target fusion weight; W Indicates a shared transformation matrix; This represents the word node vector after projection.

[0093] Furthermore, after updating the word nodes, two layers of graph convolution can be used to process the updated word nodes to obtain the target graph convolution vector. In the first layer of graph convolution, the local patterns of direct neighbors and their association with the basic categories can be captured, while in the second layer of graph convolution, the complex structural information of multi-hop neighbors can be integrated to enhance the discriminative power of the representation. Therefore, the target graph convolution vector obtained by average pooling the second layer output of the word nodes can be expressed as shown in formula (14):

[0094] MeanPool represents average pooling; This represents the word node vector output by the second-layer graph convolution.

[0095] The aforementioned target graph convolutional vectors deeply integrate the local structural relationships between words with the global classification objective, achieving comprehensive feature learning from micro-level word-level relationships to macro-level category contributions, significantly improving the ability to capture sensitive words with complex variations.

[0096] S2: Fuse the target semantic vector and the target graph convolution vector to obtain the target fused vector.

[0097] In this embodiment of the application, after obtaining the target semantic vector and the target graph convolution vector, the two can be fused to obtain the target graph convolution vector.

[0098] When fusing the two, the target semantic vector and the target graph convolution vector need to be projected through a linear projection layer to obtain the target semantic projection vector and the target graph convolution projection vector, so that the target semantic projection vector and the target graph convolution projection vector have the same dimension.

[0099] Specifically, the target semantic vector can be projected using the following formula (15):

[0100] in, Represents the learnable projection matrix; This indicates the bias term.

[0101] Similarly, the convolution vector of the target image can be projected using the following formula (16):

[0102] in, Represents the learnable projection matrix; This indicates the bias term.

[0103] Furthermore, to avoid the problem that traditional feature splicing or fusion cannot adjust the information source weights according to input changes, this application adopts a gated fusion mechanism. This mechanism can dynamically perceive the characteristics of the input text and realize context-adaptive feature selection and fusion. Therefore, firstly, a target gate vector is generated based on the target semantic projection vector and the target graph convolutional projection vector, so that the target semantic projection vector and the target graph convolutional projection vector can be fused by feature weighting based on the target gate vector. Specifically, the target gate vector can be represented by the following formula (17):

[0104] in, This represents the sigmoid activation function; Represents the gate weight matrix; Represents the target semantic projection vector; Represents the convolutional projection vector of the target image; This indicates the gating bias term.

[0105] Furthermore, the target semantic projection vector and the target graph convolutional projection vector are fused using the target gating vector to obtain the target fused vector.

[0106] Specifically, the aforementioned target fusion vector can be represented by the following formula (18):

[0107] in, Represents the target gating vector; This represents the element-wise multiplication method; Represents the target semantic projection vector; This represents the convolutional projection vector of the target image.

[0108] By employing the gating mechanism described above, it becomes possible to adapt to different text styles and achieve stronger generalization capabilities.

[0109] S3: Sensitive word detection is performed based on the target fusion vector to obtain the probability that the text to be detected belongs to each type of sensitive word.

[0110] In this embodiment, after obtaining the target fusion vector using the aforementioned method, the target fusion vector can be input into the fully connected layer of the sensitive word detection model. The softmax function is then used to normalize the target fusion vector, thereby obtaining the final sensitive word type probability distribution. At this point, the probability of a word belonging to each sensitive word type is output. For example, word A has an 85% probability of being a politically sensitive word, a 10% probability of being a vulgar sensitive word, and a 5% probability of being an uncivilized sensitive word, etc. The sensitive word type with the highest probability is taken as the final sensitive word detection result.

[0111] Optionally, in this embodiment, the final probability distribution of sensitive word types can be represented by the following formula (19):

[0112] in, This indicates the predicted probability of each type of sensitive word; Indicates the number of sensitive word types; Represents the target fusion vector; This indicates a classification bias.

[0113] Furthermore, based on the same technical concept, embodiments of this application provide a sensitive word detection device, which is used to implement the above-described method flow of embodiments of this application. See also... Figure 4 As shown, the device includes: a processing module 401, a fusion module 402, and a detection module 403, wherein, The processing module 401 is used to extract features from the text to be detected, obtain the target semantic vector, and obtain the target graph convolution vector based on the target graph structure data; wherein, the target semantic vector is obtained based on character embedding vector, pinyin embedding vector and glyph embedding vector, and the target graph structure data is constructed based on word nodes and nodes of various sensitive word types; The fusion module 402 is used to fuse the target semantic vector and the target graph convolution vector to obtain the target fused vector; The detection module 403 is used to detect sensitive words based on the target fusion vector and obtain the probability that the text to be detected belongs to various types of sensitive words.

[0114] In an optional implementation, when performing feature extraction on the text to be detected to obtain the target semantic vector, the processing module 401 is specifically used for: Based on character embedding vectors, pinyin embedding vectors, and glyph embedding vectors, a target embedding vector sequence is obtained; A multi-head self-attention mechanism is used to process the target embedding vector sequence to obtain the hidden state sequence; The attention weights corresponding to each hidden state vector in the hidden state sequence are calculated based on the preset query vectors. The target semantic vector is obtained by weighted summation of each hidden state vector and its corresponding attention weight.

[0115] In one alternative implementation, the target graph structure data is obtained in the following manner: Each word in the text to be detected is taken as a word node, and each sensitive word type is taken as a sensitive word type node. A first weight is determined between two word nodes, and a second weight is determined between a word node and a sensitive word type node. The first weight is obtained based on the inter-point mutual information and mixed phonetic-morphological similarity between the two word nodes. The mixed phonetic-morphological similarity characterizes the degree of phonetic-morphological similarity between the two words. The second weight is obtained based on a preset unit matrix, a preset weight factor, and statistical correlation. The statistical correlation is used to measure the strength of the statistical correlation between the word and the sensitive word type. The target graph structure data is obtained based on word nodes, sensitive word type nodes, first weight, and second weight.

[0116] In one optional implementation, when obtaining the target graph convolution vector based on the target graph structure data, the processing module 401 is specifically used for: Based on the target graph structure data, determine the local attention weight between any word node and its neighboring nodes, and determine the global attention weight between any word node and sensitive word type nodes. Target fusion weights are obtained based on local attention weights and global attention weights; Based on the target fusion weights, feature aggregation is performed on word nodes to obtain the target graph convolution vector.

[0117] In an optional implementation, when fusing the target semantic vector and the target graph convolution vector to obtain the target fused vector, the fusion module 402 is specifically used for: The target semantic vector and the target graph convolution vector are projected separately to obtain the target semantic projection vector and the target graph convolution projection vector; wherein the target semantic projection vector and the target graph convolution projection vector have the same dimension. The target gating vector is obtained based on the target semantic projection vector and the target graph convolutional projection vector. The target semantic projection vector and the target graph convolutional projection vector are fused based on the target gating vector to obtain the target fused vector.

[0118] Based on the same technical concept, embodiments of this application also provide an electronic device that can implement the sensitive word detection method flow provided in the above embodiments of this application. In one embodiment, the electronic device can be a server, a terminal device, or other electronic devices. See also... Figure 5 As shown, the electronic device may include: At least one processor 501 and a memory 502 connected to at least one processor 501. In this embodiment, the specific connection medium between the processor 501 and the memory 502 is not limited. Figure 5 The example shown is the connection between processor 501 and memory 502 via bus 500. Bus 500 is... Figure 5 The connections between other components are indicated by thick lines and are for illustrative purposes only, not as limiting information. The Bus 500 can be divided into address bus, data bus, control bus, etc., for ease of representation. Figure 5 The term 501 is represented by a single thick line, but this does not imply that there is only one bus or one type of bus. Alternatively, the processor 501 can also be called a controller; there is no restriction on the name.

[0119] In this embodiment, memory 502 stores instructions executable by at least one processor 501. By executing the instructions stored in memory 502, at least one processor 501 can perform a sensitive word detection method as described above. Processor 501 can implement... Figure 5 The functions of each module in the device shown.

[0120] The processor 501 is the control center of the device. It can connect to various parts of the control device through various interfaces and lines. By running or executing instructions stored in memory 502 and calling data stored in memory 502, the processor can perform various functions and process data, thereby monitoring the device as a whole.

[0121] In one possible design, processor 501 may include one or more processing units. Processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into processor 501. In some embodiments, processor 501 and memory 502 may be implemented on the same chip; in some embodiments, they may also be implemented on separate chips.

[0122] Processor 501 can be a general-purpose processor, such as a CPU, digital signal processor, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor. The steps of a sensitive word detection method disclosed in the embodiments of this application can be directly manifested as execution by a hardware processor, or execution by a combination of hardware and software modules within the processor.

[0123] Memory 502, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 502 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory 502 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 502 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.

[0124] By designing and programming the processor 501, the code corresponding to the sensitive word detection method described in the foregoing embodiments can be embedded into the chip, thereby enabling the chip to execute the code during operation. Figure 2 The illustrated embodiment presents the steps of a sensitive word detection method. How to design and program the processor 501 is a technique well-known to those skilled in the art and will not be described further here.

[0125] Based on the same inventive concept, embodiments of this application also provide a storage medium storing computer instructions that, when executed on a computer, cause the computer to perform a sensitive word detection method as described above.

[0126] In some possible implementations, this application also provides that various aspects of a sensitive word detection method can be implemented as a program product including program code, which, when the program product is run on a device, causes the control device to perform the steps in a sensitive word detection method according to various exemplary embodiments of this application as described above.

[0127] It should be noted that although several units or sub-units of the device have been mentioned in the detailed description above, this division is merely exemplary and not mandatory. In fact, according to embodiments of this application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided and embodied by multiple units.

[0128] Furthermore, although the operations of the method of this application are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in that specific order, or that all the operations shown must be performed to achieve the desired result. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0129] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0130] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable sensitive word detection device to produce a server, such that the instructions, which execute via the processor of the computer or other programmable sensitive word detection device, generate instructions for implementing the process... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0131] Program code for performing the operations of this application can be written using any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0132] These computer program instructions can also be loaded onto a computer or other programmable sensitive word detection device, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable device for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0133] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.

Claims

1. A method for detecting sensitive words, characterized in that, The method includes: Feature extraction is performed on the text to be detected to obtain a target semantic vector, and a target graph convolution vector is obtained based on the target graph structure data; wherein, the target semantic vector is obtained based on character embedding vector, pinyin embedding vector and glyph embedding vector, and the target graph structure data is constructed based on word nodes and nodes of various sensitive word types; The target semantic vector and the target graph convolution vector are fused to obtain the target fused vector; Sensitive word detection is performed based on the target fusion vector to obtain the probability that the text to be detected belongs to various sensitive word types.

2. The method as described in claim 1, characterized in that, The step of extracting features from the text to be detected to obtain a target semantic vector includes: Based on the character embedding vector, the pinyin embedding vector, and the glyph embedding vector, a target embedding vector sequence is obtained; The target embedding vector sequence is processed using a multi-head self-attention mechanism to obtain a hidden state sequence; The attention weights corresponding to each hidden state vector in the hidden state sequence are calculated based on the preset query vectors. The target semantic vector is obtained by weighted summation based on each hidden state vector and its corresponding attention weight.

3. The method as described in claim 1, characterized in that, The target graph structure data is obtained in the following way: Each word in the text to be detected is taken as a word node, and each sensitive word type is taken as a sensitive word type node. A first weight is determined between two word nodes, and a second weight is determined between the word node and the sensitive word type node; wherein, the first weight is obtained based on the inter-point mutual information and mixed phonetic-morphological similarity between the two word nodes, the mixed phonetic-morphological similarity characterizes the degree of phonetic-morphological similarity between the two words, and the second weight is obtained based on a preset unit matrix, a preset weight factor and statistical correlation, the statistical correlation is used to measure the statistical correlation strength between the word and the sensitive word type; The target graph structure data is obtained based on the word nodes, the sensitive word type nodes, the first weight, and the second weight.

4. The method as described in claim 1, characterized in that, The process of obtaining the target graph convolution vector based on the target graph structure data includes: Based on the target graph structure data, determine the local attention weights of any word node and its neighboring nodes, and determine the global attention weights of any word node and sensitive word type nodes. Based on the local attention weights and the global attention weights, the target fusion weights are obtained; Based on the target fusion weights, feature aggregation is performed on the word nodes to obtain the target graph convolution vector.

5. The method as described in claim 1, characterized in that, The process of fusing the target semantic vector and the target graph convolution vector to obtain the target fused vector includes: The target semantic vector and the target graph convolution vector are projected to obtain the target semantic projection vector and the target graph convolution projection vector, respectively; wherein the target semantic projection vector and the target graph convolution projection vector have the same dimension. Based on the target semantic projection vector and the target graph convolutional projection vector, the target gate vector is obtained; The target semantic projection vector and the target graph convolutional projection vector are fused based on the target gating vector to obtain the target fused vector.

6. A sensitive word detection device, characterized in that, The device includes: The processing module is used to extract features from the text to be detected, obtain a target semantic vector, and obtain a target graph convolution vector based on the target graph structure data; wherein, the target semantic vector is obtained based on character embedding vector, pinyin embedding vector and glyph embedding vector, and the target graph structure data is constructed based on word nodes and nodes of various sensitive word types; The fusion module fuses the target semantic vector and the target graph convolution vector to obtain a target fusion vector; The detection module performs sensitive word detection based on the target fusion vector to obtain the probability that the text to be detected belongs to various sensitive word types.

7. The apparatus as claimed in claim 6, characterized in that, When performing feature extraction on the text to be detected to obtain the target semantic vector, the processing module is specifically used for: Based on the character embedding vector, the pinyin embedding vector, and the glyph embedding vector, a target embedding vector sequence is obtained; The target embedding vector sequence is processed using a multi-head self-attention mechanism to obtain a hidden state sequence; The attention weights corresponding to each hidden state vector in the hidden state sequence are calculated based on the preset query vectors. The target semantic vector is obtained by weighted summation based on each hidden state vector and its corresponding attention weight.

8. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the method as described in any one of claims 1-5.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-5.

10. A computer program product, characterized in that, The computer program product includes: computer program code, which, when run on a computer, causes the computer to perform the method described in any one of claims 1-5.