Chinese implicit hate speech detection method with two-stage knowledge-driven prompt tuning

By combining graph convolutional networks and self-attention mechanisms with external knowledge to construct an extended word mapper, the problem of insufficient accuracy in Chinese implicit hate language detection in existing technologies is solved, and efficient implicit hate language detection is achieved.

CN119917667BActive Publication Date: 2025-11-11YANGZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510085413.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-20
Publication Date
2025-11-11
Estimated Expiration
2045-01-20

AI Technical Summary

Technical Problem

Existing dictionary-based deep learning methods are inadequate in detecting implicit hate language in Chinese, struggling to effectively distinguish irrational tags and affecting model accuracy.

Method used

We employ graph convolutional networks combined with self-attention mechanisms to extract grammatical structure features. We construct an extended word mapper using a two-stage knowledge-driven prompt optimization method, including external knowledge retrieval and refinement strategies, to generate an optimized extended word mapper. This mapper is then trained in a continuous optimal prompt space and detected by combining semantic features and grammatical structure.

Benefits of technology

It significantly improves the performance of Chinese implicit hate language detection, reduces noise interference, balances automatic template generation and detection performance, successfully extracts complex grammatical features, and achieves efficient classification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119917667B_ABST
    Figure CN119917667B_ABST
Patent Text Reader

Abstract

This invention discloses a two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese. The method includes: 1) extracting grammatical structure features of the input text using a graph convolutional network incorporating an attention mechanism; 2) training in a continuous optimal prompt space to obtain soft prompt templates; 3) constructing an extended word mapper by fusing external knowledge, and using a two-stage concatenated strategy for expansion and refinement to generate an optimized extended word mapper; 4) selecting a small number of samples from the training set to train a prompt optimization model, combining the soft prompt templates and the extended word mapper to extract semantic features, and concatenating these features with the generated grammatical structure features to form a comprehensive feature set, thereby achieving implicit hate language detection in Chinese. This invention optimizes the extended word mapper through external knowledge optimization and concatenated expansion and refinement, integrates grammatical features extracted by an attention mechanism and a graph convolutional network, and mines the latent knowledge of the pre-trained language model, achieving high performance in detecting implicit hate language in Chinese.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of implicit hate language in Chinese and short text classification research, and in particular to a two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese. Background Technology

[0002] In recent years, dictionary-based deep learning methods have been widely used in the field of hate speech detection. These methods perform well in detecting explicit hate speech (which typically contains obvious hateful or abusive language), but often fall short in detecting implicit hate speech. Research on implicit hate speech detection has evolved from early feature-engineering-based methods to neural network models, and more recently, it has further developed into methods based on pre-trained language models (PLMs), such as BERT and HateBERT. These methods have demonstrated significant performance advantages in hate speech detection tasks.

[0003] In recent years, PLM-based prompting optimization algorithms have achieved remarkable performance in few-shot learning tasks. The core element of prompting optimization methods is a set of label words. These label words are the words with the highest predicted probability in the current context, often referred to as the expanded word mapper. Existing prompting optimization methods construct the expanded word mapper by introducing expansion or refinement strategies. Expanding label words typically involves extracting relevant words from category names and aggregating these labels into the final expanded word mapper. Refining label words, on the other hand, involves extracting useful label words from external knowledge bases to improve model accuracy. However, in practical applications, some unreasonable label words are difficult to distinguish, inevitably negatively impacting model accuracy. Summary of the Invention

[0004] The purpose of this invention is to overcome the limitations of existing technologies and provide a two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese. It employs a graph convolutional network (GCN) combined with an automatic attention mechanism (ATT) to extract grammatical structure information from Chinese comment texts, deeply exploring the syntactic meaning behind the text. Furthermore, it proposes a concatenated extended word mapper construction method based on a combination of expansion and refinement, transforming the task of detecting implicit hate language in Chinese into a cloze test task on a constructed soft prompt template. This significantly improves the performance of implicit hate language detection in Chinese and achieves an efficient classification objective.

[0005] The objective of this invention is achieved as follows: a two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese, comprising the following steps:

[0006] 1) To address the characteristics of implicit hate language in Chinese, a graph convolutional network incorporating an attention mechanism is used to extract the grammatical structure features of the input text;

[0007] 2) Training is performed in a continuous optimal cue space to obtain soft cue templates;

[0008] 3) An extended word mapper is constructed by integrating external knowledge, and a two-stage concatenation strategy is used for expansion and refinement to generate an optimized extended word mapper;

[0009] 4) Select a small number of samples from the training set to train and construct a cue optimization model. Combine the soft cue templates and extended word mappers mentioned in steps 2) and 3) to extract semantic features, and concatenate them with the grammatical structure features generated in step 1) to form a comprehensive feature, thereby realizing the detection of implicit hate language in Chinese.

[0010] As a further limitation of the present invention, step 1) specifically includes:

[0011] Step 1.1) By combining a hybrid model of graph convolutional network (GCN) and self-attention mechanism (ATT), we analyze the grammatical structure, focus on the linear relationship between sentence components, and capture grammatical information by utilizing part-of-speech tagging and the dependency relationship between words.

[0012] Step 1.2) The generated dependency graph G is used as input to the graph convolutional network GCN to extract the syntactic features of each node. The graph convolutional network GCN aggregates the information of each node in the graph structure through convolution operations, and combines it with the information of its neighboring nodes to generate node feature representations. The operation representation of GCN is as follows:

[0013]

[0014] in, A is an adjacency matrix with added self-loops, allowing each node to re-aggregate information from its neighbors while retaining and utilizing its own information; A is the adjacency matrix of the dependency graph. yes degree matrix; H (l) This represents the node feature matrix of the l-th layer, and the initial layer H... (0) For input node features; W (l) σ is the weight matrix of the l-th layer; σ is the nonlinear activation function.

[0015] Step 1.3) After extracting syntactic features using the Graph Convolutional Network (GCN), the node features are processed using the ATT (Automatic Attention) mechanism. The ATT mechanism dynamically focuses on different parts of the input sequence and weights the features by calculating attention weights to capture contextual dependencies. In this way, the model can adjust the feature representation of each node based on global contextual information.

[0016] As a further limitation of the present invention, step 1.1) specifically includes:

[0017] Step 1.1.1) Use the Language Technology Platform (LTP) to perform word segmentation on the Chinese comment text x, and obtain the segmentation result CWS = LTP.CWS(x); calculate the part-of-speech tag for each word using POS = LTP.POS(CWS) and assign the part-of-speech category to the word; identify the grammatical relationship between words through dependency relation analysis DEP = LTP.DEP(CWS);

[0018] Step 1.1.2) Constructs a dependency graph G = (V, E); derives the node set V from the part-of-speech tagging:

[0019] V = {POS i |i=1,2,...,n} (1)

[0020] Where n represents the number of words in text x that have been separated by the word segmentation operation;

[0021] The edge set E is determined by dependencies:

[0022] E={(x k ,x l )|x k ,x l ∈x and a dependency relationship DEP kl exists} (2)

[0023] Among them, the edges (x) in the edge set k ,x l ) consists of two nodes x k and x l It is composed of nodes, each representing a part-of-speech tag in the dependency graph.

[0024] As a further limitation of the present invention, step 2) specifically includes:

[0025] Step 2.1) Design a soft template based on a two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese, and train it in a continuous optimal prompt space, as shown below:

[0026] T = {u i ],...,x,...,[u n [mask]} (4)

[0027] Where u i This represents the i-th learnable tag;

[0028] The constructed cue template T is input into the encoder of the pre-trained language model to generate hidden vector h. i ,...,h x ,...,hn ,h mask At this point, the soft suggestion template T is represented as:

[0029] T = {h i ],...,[h x ],...,[h n ],[h mask ]} (5)

[0030] Step 2.2) Introduce a Bidirectional Long Short-Term Memory (BiLSTM) network model as the neural network to hide the vector h. i The modeling process is described as follows:

[0031]

[0032] Finally, the model uses a loss function L to measure the difference between the output of model M and the target value given input x and mask, and selects the optimal variable value h. The loss function is as follows:

[0033]

[0034] As a further limitation of the present invention, step 3) specifically includes:

[0035] Step 3.1) During the suggestion optimization process, the difference between the text space and the label space is alleviated by mapping expanded words to categories; the automatic selection of label words or the mapping relationship of expanded words is realized, expressed in the following form:

[0036]

[0037] Among them, v i y represents a word in the expanded word mapper; y represents the corresponding tag, where y=0 indicates non-hate language, associated with the tag word "friendly", and conversely, y=1 indicates hate language, corresponding to the tag word "malicious".

[0038] Step 3.2) In the construction of the extended word mapper, a two-stage knowledge-based approach is adopted to detect implicit hate language in Chinese; the two stages refer to the concatenation of the extended word mapper's expansion and refinement strategies.

[0039] As a further limitation of the present invention, step 3.2) specifically includes:

[0040] Step 3.2.1) When expanding knowledge retrieval, the WantWords reverse dictionary is used to achieve semantic-to-lexical retrieval by matching descriptions or meanings with related words; based on the category information "friendly comments" and "malicious comments", N1 reverse-matched words are retrieved as the expanded tag word set V. y ;

[0041] Using the category names y, namely "friendly" and "malicious", as anchor words, calculate the value of each extended tag word V. y The distance dist(V) between the category name y and the embedding space y Extract the top N2 words with the highest cosine similarity to the category name y, and further optimize the selection of extended tag words;

[0042] Step 3.2.2) In the process of refining the expanded words, the expanded tag words are optimized through probability calculation; the distribution probability of each tag word is calculated; cosine similarity is used to represent the distribution probability of candidate tag words in the two categories; this reflects the distribution characteristics of tag words in the two categories, expressed as:

[0043]

[0044] Where i∈{0,1}, P(v|y0) represents the probability of candidate label v in the “friendly” category, and similarly, P(v|y1) represents the probability of candidate label v in the “offensive” category; then, the standard deviation of each candidate label is calculated based on the following formula;

[0045]

[0046] Where μ is the average probability of the tag word across all categories, expressed as:

[0047]

[0048] The final expanded word mapper is constructed by selecting the top N3 tags based on their standard deviations, sorting them from largest to smallest.

[0049] As a further limitation of the present invention, step 4) specifically includes:

[0050] Step 4.1) Concatenate the syntactic structure features obtained in Step 1) and the semantic features jointly constructed in Steps 2) and 3) along the dimension to obtain the comprehensive feature vector:

[0051] F com =[f syn ,h] (12)

[0052] Where [·,·] denotes the concatenation operation of eigenvectors, f syn Indicates syntactic structural features;

[0053] Step 4.2) Input the concatenated integrated feature vector into the multilayer perceptron (MLP) to obtain the probability of each labeled word in the extended word mapper; update the original probability calculation formula to P(y|x)=P([mask]=v|Fcom )

[0054] Step 4.3) During model training, the model parameters θ are updated using the cross-entropy loss function, which can be visualized as:

[0055]

[0056] in, N represents the standard cross-entropy loss function; a The sample size is used as a normalization factor, and the average loss is calculated; the summation represents the cumulative loss over all samples; y represents the true label; the first half of formula (13) The difference between the model prediction and the true label is calculated; term α‖θ‖ 2 θ is the regularization term, where α is a parameter controlling the weight of the regularization term, and |θ| 2 This represents the squared L2 norm of the model parameter θ.

[0057] Compared with the prior art, the present invention adopts the above technical solution and has the following advantages: (1) The present invention utilizes the construction method of the extended and refined extended word mapper with serial connection of external knowledge, which effectively reduces the interference of irrelevant noise words; (2) The present invention can simultaneously take into account the automatic generation and detection performance of templates; (3) In view of the characteristics of implicit hate language in Chinese, the present invention integrates attention mechanism and graph convolutional network, and combines the syntactic structure information of Chinese sentences to successfully extract complex grammatical features in Chinese; The present invention has achieved the best performance on four benchmark datasets, demonstrating its superiority. Attached Figure Description

[0058] Figure 1 Overall framework diagram of the present invention. Detailed Implementation

[0059] like Figure 1 The method for detecting implicit hate language in Chinese, which involves two stages of knowledge-driven prompting and optimization, includes the following steps:

[0060] 1) To address the characteristics of implicit hate language in Chinese, a graph convolutional network incorporating an attention mechanism is used to extract the grammatical structure features of the input text;

[0061] Step 1.1) By combining a hybrid model of graph convolutional network (GCN) and self-attention mechanism (ATT), the grammatical structure is analyzed in depth. This method not only focuses on the linear relationship between sentence components, but also uses part-of-speech tagging of words and their dependencies to comprehensively capture grammatical information.

[0062] Step 1.1.1) Use the Language Technology Platform (LTP) to perform word segmentation on the Chinese comment text x, and obtain the segmentation result CWS = LTP.CWS(x); then, calculate the part-of-speech tag for each word using POS = LTP.POS(CWS) and assign the word to the appropriate part-of-speech category, such as noun, verb, adjective, etc.; next, identify the grammatical relationships between words through dependency relation analysis DEP = LTP.DEP(CWS), such as subject-verb relationship and modifier-headword relationship;

[0063] Step 1.1.2) Based on the above analysis, a dependency graph G = (V, E) was constructed;

[0064] The node set V is derived from part-of-speech tagging:

[0065] V = {POS i |i=1,2,...,n} (1)

[0066] Here, n represents the number of words in text x that have been separated by the word segmentation operation;

[0067] The edge set E is determined by dependencies:

[0068] E={(x k ,x l )|x k ,x l ∈x and a dependency relationship DEP kl exists} (2)

[0069] Among them, the edges (x) in the edge set k ,x l ) consists of two nodes x k and x l It is composed of nodes, each representing a part-of-speech tag in the dependency graph;

[0070] The dependency graph G generated in step 1.2) will be used as input to the GCN to extract the syntactic features of each node. The GCN aggregates the information of each node in the graph structure through convolutional operations, combining it with the information of its neighboring nodes to generate a more expressive node feature representation. The operation of the graph convolutional network GCN is represented as follows:

[0071]

[0072] in, A is an adjacency matrix with added self-loops, allowing each node to re-aggregate information from its neighbors while retaining and utilizing its own information; A is the adjacency matrix of the dependency graph. yes degree matrix; H(l) This represents the node feature matrix of the l-th layer, and the initial layer H... (0) For input node features; W (l) σ is the weight matrix of the l-th layer; σ is the non-linear activation function, which is ELU chosen in this method.

[0073] Step 1.3) After extracting syntactic features using GCN, ATT is further used to process the node features. ATT can dynamically focus on different parts of the input sequence and weight the features by calculating attention weights to capture more complex contextual dependencies. In this way, the model can adjust the feature representation of each node based on global context information, thereby improving the expressive power of the extracted syntactic structure features.

[0074] 2) Training is performed in a continuous optimal cue space to obtain more flexible soft cue templates;

[0075] Step 2.1) Design a soft template based on a two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese, and train it in a continuous optimal prompt space, as shown below:

[0076] T = {u i ],...,x,...,[u n [mask]} (4)

[0077] Where u i This represents the i-th learnable tag;

[0078] The constructed cue template T is then fed into the encoder of the pre-trained language model to generate the hidden vector h. i ,...,h x ,...,h n ,h mask At this point, the soft suggestion template T is represented as:

[0079] T = {h i ],...,[h x ],...,[h n ],[h mask ]} (5)

[0080] Step 2.2) Introduce a Bidirectional Long Short-Term Memory (BiLSTM) network model as the neural network to hide the vector h. i The modeling process is described as follows:

[0081]

[0082] Finally, the model uses a loss function L to measure the difference between the output of model M and the target value given input x and mask, and selects the optimal variable value h. The loss function is as follows:

[0083]

[0084] 3) An extended word mapper is constructed by integrating external knowledge, and a two-stage concatenation strategy is used for expansion and refinement to finally generate an optimized extended word mapper;

[0085] Step 3.1) During the suggestion optimization process, mapping expanded words to categories effectively alleviated the difference between the text space and the label space; it realized the automatic selection of label words or the mapping relationship of expanded words, and its expression form is as follows:

[0086]

[0087] Here v i y represents a word in the expanded word mapper; y represents the corresponding tag, where y=0 indicates non-hate language, associated with the tag word "friendly", and conversely, y=1 indicates hate language, corresponding to the tag word "malicious".

[0088] Step 3.2) In the construction of the extended word mapper, a two-stage knowledge-based approach is proposed to detect implicit hate language in Chinese; the two stages here refer to the concatenation of the extended word mapper's expansion and refinement strategies.

[0089] Step 3.2.1) When expanding knowledge retrieval, the WantWords reverse dictionary is used to achieve semantic-to-lexical retrieval by matching descriptions or meanings with related words; based on the category information "friendly comments" and "malicious comments", N1 reverse-matched words are retrieved as the expanded tag word set V. y ;

[0090] Using the category names y (i.e., "friendly" and "malicious") as anchor words, calculate the value of each extended tag word V. y The distance dist(V) between the category name y and the embedding space y Through this process, the top N2 words with the highest cosine similarity to the category name y are extracted, and the selection of extended tag words is further optimized.

[0091] Step 3.2.2) In the process of refining the expanded words, the expanded tag words are optimized through probability calculation; the distribution probability of each tag word is calculated to ensure that its relevance in its own category is significantly enhanced, while its relevance in other categories is significantly weakened, thereby improving the tag word's discriminative ability and task adaptability;

[0092] Since high similarity indicates a strong correlation and higher probability between candidate tags and categories, cosine similarity is used to represent the probability distribution of candidate tags between the two categories. This method reflects the distribution characteristics of tags across the two categories and can be expressed as:

[0093]

[0094] Where i∈{0,1}, P(v|y0) represents the probability of candidate label v in the “friendly” category, and similarly, P(v|y1) represents the probability of candidate label v in the “offensive” category; then, the standard deviation of each candidate label is calculated based on the following formula;

[0095]

[0096] Where μ is the average probability of the tag word across all categories, expressed as:

[0097]

[0098] The final expanded word mapper is constructed by selecting the top N3 tags based on their standard deviations, sorting them from largest to smallest.

[0099] The final expanded word mapper is constructed by selecting the top N3 tags that are highly correlated with their respective categories and lowly correlated with other categories based on the standard deviation. A large standard deviation indicates that the tag is highly similar to the category words of its own category and significantly different from the category words of other categories, which is called high correlation. Conversely, when the standard deviation is small, it indicates low correlation.

[0100] 4) Select a small number of samples from the training set to train and construct a cue optimization model. Combine the soft cue templates and extended word mappers mentioned in steps 2) and 3) to extract semantic features, and concatenate them with the grammatical structure features generated in step 1) to form a comprehensive feature, thereby realizing the detection of implicit hate language in Chinese.

[0101] Step 4.1) Concatenate the syntactic structure features obtained in Step 1) and the semantic features jointly constructed in Steps 2) and 3) along the dimension to obtain the comprehensive feature vector:

[0102] F com =[f syn ,h] (12)

[0103] Where [·,·] denotes the concatenation operation of eigenvectors, f syn Indicates syntactic structural features;

[0104] Step 4.2) Input the concatenated integrated feature vector into a multilayer perceptron (MLP) to obtain the probability of each labeled word in the extended word mapper; therefore, update the original probability calculation formula to P(y|x)=P([mask]=v|F com );

[0105] Step 4.3) During model training, the model parameters θ are updated using the cross-entropy loss function, which can be visualized as:

[0106]

[0107] in, N represents the standard cross-entropy loss function; a The sample size is used as a normalization factor, and the average loss is calculated; the summation represents the cumulative loss over all samples; y represents the true label; the first half of formula (13) The difference between the model prediction and the true label is calculated; term α‖θ‖ 2 θ is the regularization term, where α is a parameter controlling the weight of the regularization term, and |θ| 2 This represents the flat L2 norm of the model parameter θ.

[0108] To verify the performance of this invention in detecting implicit hate language in Chinese, experiments were conducted on four Chinese datasets; these datasets were all divided into two categories: "friendly" and "malicious".

[0109] The ToxiCN dataset includes not only objective analyses and affirmative statements but also samples of direct and indirect hate speech. This design ensures the dataset contains hate speech lacking obvious malicious vocabulary, aligning perfectly with the present invention's target of implicit hate language. The ProsCons dataset consists of online comments from a social network, with annotations categorized as "offensive" and "sarcastic." Since implicit hate language often exhibits characteristics similar to sarcasm, the "sarcastic" category in the ProsCons dataset provides effective support for Chinese implicit hate language detection. Furthermore, this invention selects comments from highly controversial posts on a social network to construct a new Chinese dataset, "Chinese Implicit Hate Speech" (CIHS). Through manual annotation, implicit hate language is more accurately differentiated, with comments exhibiting obvious hatred and implicit hatred uniformly categorized as "hateful," while well-intentioned or objective comments are categorized as "friendly." Considering that the semantics of comments may change with context, the original post content corresponding to each comment was added to the CIHS dataset, forming an extended version of the CIHS_con dataset; data preprocessing and statistical analysis were performed on the above four datasets, and the results are summarized in Table 1.

[0110] Table 1 Dataset Statistics

[0111]

[0112] To ensure a true measurement of the detection effectiveness, two representative evaluation metrics, Accuracy and F1, were selected and defined as follows:

[0113]

[0114] here,

[0115]

[0116] Where tp is the number of malicious comments correctly predicted by the algorithm, fp is the number of comments predicted as malicious but actually being friendly, fn is the number of comments predicted as friendly but actually being malicious, tn is the number of friendly comments correctly predicted, N is the total number of predicted web comments, and the F1 score is the harmonic mean of precision and recall.

[0117] To demonstrate the performance of the test results, the two-stage knowledge-driven cue tuning method for Chinese implicit hate language detection (T-KPT) of this invention was compared with other traditional baseline methods on four datasets. These baseline methods include: 1) deep neural network-based methods: sentiment feature-based hate language detection method (SKS); 2) pre-trained language model-based methods: HateBERT, contrastive learning method through generated machine sentences (ConPrompt); 3) large language model-based methods: Llama; 4) cue learning-based methods: cue learning (PL), soft template cue fine-tuning (Soft), cue learning based on external knowledge (KPT), an upgraded version of cue learning based on external knowledge (KPT++), and cue learning-based Chinese implicit hate language detection (T-KPT_M).

[0118] In the experiments, 20 positive and 20 negative instances were randomly selected from the training set to represent small-sample scenarios in the model cue learning method and the large language model method. The number of positive and negative training samples for the deep neural network and the pre-trained language model on the datasets ToxiCN, ProsCons, CIHS, and CIHS_con were 1600, 800, 1600, and 1600, respectively. The results of the dataset tests are shown in Table 2. Table 2 shows that the method of this invention outperforms other methods in all four metrics on the four datasets.

[0119] Table 2 Experimental Results

[0120]

[0121] This invention proposes a Chinese implicit hate language detection method based on two-stage knowledge-driven prompt tuning. By combining graph convolutional networks and self-attention mechanisms, it captures the grammatical structure of Chinese input sentences and introduces external knowledge to construct an extended word mapper. Compared with existing knowledge-driven prompt tuning methods, this invention innovates in two dimensions: expansion and refinement, to more efficiently construct the extended word mapper for label prediction. Extensive experimental results on four datasets further validate the significant effectiveness of this method.

[0122] This invention is not limited to the above embodiments. Based on the technical solutions disclosed in this invention, those skilled in the art can make some substitutions and modifications to some of the technical features without creative effort, and all such substitutions and modifications are within the protection scope of this invention.

Claims

1. A two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese, characterized in that, Includes the following steps: 1) To address the characteristics of implicit hate language in Chinese, a graph convolutional network incorporating an attention mechanism is used to extract the grammatical structure features of the input text; 2) Training is performed in a continuous optimal cue space to obtain soft cue templates; 3) An extended word mapper is constructed by integrating external knowledge, and a two-stage concatenation strategy is used for expansion and refinement to generate an optimized extended word mapper; Step 3.1) During the suggestion optimization process, the difference between the text space and the label space is alleviated by mapping expanded words to categories; the automatic selection of label words or the mapping relationship of expanded words is realized, expressed in the following form: Among them, v i y represents a word in the expanded word mapper; y represents the corresponding tag, where y=0 indicates non-hate language, associated with the tag word "friendly", and conversely, y=1 indicates hate language, corresponding to the tag word "malicious". Step 3.2) In the construction of the extended word mapper, a two-stage knowledge-based approach is adopted to detect implicit hate language in Chinese; the two stages refer to the concatenation of the extended word mapper's expansion and refinement strategies. Step 3.2.1) When expanding knowledge retrieval, the WantWords reverse dictionary is used to achieve semantic-to-lexical retrieval by matching descriptions or meanings with related words; based on the category information "friendly comments" and "malicious comments", N1 reverse-matched words are retrieved as the expanded tag word set V. y ; Using the category names y, namely "friendly" and "malicious", as anchor words, calculate the value of each extended tag word V. y The distance dist(V) between the category name y and the embedding space y Extract the top N2 words with the highest cosine similarity to the category name y, and further optimize the selection of extended tag words; Step 3.2.2) In the process of refining the expanded words, the expanded tag words are optimized through probability calculation; the distribution probability of each tag word is calculated; cosine similarity is used to represent the distribution probability of candidate tag words in the two categories; this reflects the distribution characteristics of tag words in the two categories, expressed as: Where i∈{0,1}, P(v|y0) represents the probability of candidate label v in the "friendly" category, and similarly, P(v|y1) represents the probability of candidate label v in the "offensive" category; then, the standard deviation of each candidate label is calculated based on the following formula; Where μ is the average probability of the tag word across all categories, expressed as: The final expanded word mapper is constructed by selecting the top N3 tags based on the standard deviation, sorting them from largest to smallest. 4) Select a small number of samples from the training set to train and construct a cue optimization model. Combine the soft cue templates and extended word mappers mentioned in steps 2) and 3) to extract semantic features, and concatenate them with the grammatical structure features generated in step 1) to form a comprehensive feature, thereby realizing the detection of implicit hate language in Chinese.

2. The Chinese implicit hate language detection method with two-stage knowledge-driven prompt optimization according to claim 1, characterized in that, Step 1) specifically includes: Step 1.1) By combining a hybrid model of graph convolutional network (GCN) and self-attention mechanism (ATT), we analyze the grammatical structure, focus on the linear relationship between sentence components, and capture grammatical information by utilizing part-of-speech tagging and the dependency relationship between words. Step 1.2) The generated dependency graph G is used as input to the graph convolutional network GCN to extract the syntactic features of each node. The graph convolutional network GCN aggregates the information of each node in the graph structure through convolution operations, and combines it with the information of its neighboring nodes to generate node feature representations. The operation representation of GCN is as follows: in, A is an adjacency matrix with added self-loops, allowing each node to re-aggregate information from its neighbors while retaining and utilizing its own information; A is the adjacency matrix of the dependency graph. yes degree matrix; H (l) This represents the node feature matrix of the l-th layer, and the initial layer H... (0) For input node features; W (l) σ is the weight matrix of the l-th layer; σ is the nonlinear activation function. Step 1.3) After extracting syntactic features using the Graph Convolutional Network (GCN), the node features are processed using the ATT (Automatic Attention) mechanism. The ATT mechanism dynamically focuses on different parts of the input sequence and weights the features by calculating attention weights to capture contextual dependencies. In this way, the model can adjust the feature representation of each node based on global contextual information.

3. The Chinese implicit hate language detection method with two-stage knowledge-driven prompt optimization according to claim 2, characterized in that, Step 1.1) specifically includes: Step 1.1.1) Use the Language Technology Platform (LTP) to perform word segmentation on the Chinese comment text x, and obtain the segmentation result CWS = LTP.CWS(x); calculate the part-of-speech tag for each word using POS = LTP.POS(CWS) and assign the part-of-speech category to the word; identify the grammatical relationship between words through dependency relation analysis DEP = LTP.DEP(CWS); Step 1.1.2) Constructs a dependency graph G = (V, E); derives the node set V from the part-of-speech tagging: V={POS i |i=1,2,...,n} (1) Where n represents the number of words in text x that have been separated by the word segmentation operation; The edge set E is determined by dependencies: E={(x k ,x l )|x k ,x l ∈x and a dependency relationship DEP kl exists} (2) Among them, the edges (x) in the edge set k x l ) consists of two nodes x k and x l It is composed of nodes, each representing a part-of-speech tag in the dependency graph.

4. The Chinese implicit hate language detection method with two-stage knowledge-driven prompt optimization according to claim 1, characterized in that, Step 2) specifically includes: Step 2.1) Design a soft template based on a two-stage knowledge-driven prompt optimization method for detecting implicit hate language in Chinese, and train it in a continuous optimal prompt space, as shown below: T={[u i ],...,x,...,[u n ],[mask]} (4) Where u i This represents the i-th learnable tag; The constructed cue template T is input into the encoder of the pre-trained language model to generate hidden vector h. i , ..., h x , ..., h n h mask At this point, the soft suggestion template T is represented as: T={[h i ],...,[h x ],...,[h n ],[h mask ]} (5) Step 2.2) Introduce a Bidirectional Long Short-Term Memory (BiLSTM) network model as the neural network to hide the vector h. i The modeling process is described as follows: Finally, the model uses a loss function L to measure the difference between the output of model M and the target value given input x and mask, and selects the optimal variable value h. The loss function is as follows:

5. The Chinese implicit hate language detection method with two-stage knowledge-driven prompt optimization according to claim 1, characterized in that, Step 4) specifically includes: Step 4.1) Concatenate the syntactic structure features obtained in Step 1) and the semantic features jointly constructed in Steps 2) and 3) along the dimension to obtain the comprehensive feature vector: F com =[f syn ,h] (12) Where [·, ·] denotes the concatenation operation of feature vectors, f syn Indicates syntactic structural features; Step 4.2) Input the concatenated integrated feature vector into the multilayer perceptron (MLP) to obtain the probability of each labeled word in the extended word mapper; update the original probability calculation formula to P(y|x)=P([mask]=v|F com ); Step 4.3) During model training, the model parameters θ are updated using the cross-entropy loss function, which can be visualized as: in, N represents the standard cross-entropy loss function; a The sample size is used as a normalization factor, and the average loss is calculated; the summation represents the cumulative loss over all samples; y represents the true label; the first half of formula (13) The difference between the model prediction and the true label is calculated; term α‖θ‖ 2 θ is the regularization term, where α is a parameter controlling the weight of the regularization term, and |θ| 2 This represents the squared L2 norm of the model parameter θ.

Citation Information

Patent Citations

  • Chinese click bait detection method based on soft prompt learning

    CN117421420A

  • Soft knowledge prompts for language models

    US20240273294A1