Chinese recessive hatred language detection method with two-stage knowledge-driven prompt tuning
Through a two-stage knowledge-driven prompt tuning method, combined with the graph convolution network and self-attention mechanism, an extended word mapper was built, which solved the problem that unreasonable label words affect the accuracy of the model in Chinese implicit hatred language detection, and achieved efficient Chinese implicit hatred language detection.
Patent Information
- Application Number
- CN202510085413.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2045-01-20
AI Technical Summary
The prior art lacks performance in detecting Chinese implicit hatred language, especially because unreasonable label words are difficult to distinguish, resulting in negative impact on model accuracy.
A two-stage knowledge-driven prompt tuning method is adopted, and a grammatical structure feature is extracted in combination with graph convolution network and self-attention mechanism, and an extended word mapper is constructed through external knowledge. A two-stage series strategy is used for expansion and refinement, and the optimized extended word mapper is finally generated.
It significantly improves the performance of Chinese implicit hatred language detection, reduces interference from irrelevant noise words, takes into account the automatic generation and detection performance of templates, and achieves the best performance on four benchmark data sets.
Smart Images

Figure CN119917667A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the research field of Chinese implicit hate language and short text classification, and in particular to a two-stage knowledge-driven prompt tuning Chinese implicit hate language detection method Background Art
[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 (usually containing obvious hateful or insulting words), but often fail to detect implicit hate speech. Research on the detection of implicit hate speech has evolved from early feature engineering-based methods to neural network models, and more recently to methods based on pre-trained language models (PLMs), such as BERT and HateBERT. These methods have shown significant performance advantages in the task of hate speech detection.
[0003] In recent years, prompt tuning algorithms based on PLM have achieved excellent performance in small sample learning tasks. In the prompt tuning method, the core element is a set of label words. These label words are the words with the highest prediction probability of PLM in the current context, which are usually called extended word mappers. Existing prompt tuning methods construct extended word mappers by introducing expansion or refinement strategies. The strategy of expanding label words usually extracts relevant words from category names and aggregates these label words into the final extended word mapper. The core idea of refining label words is to extract useful label words from external knowledge bases to improve the accuracy of the model. However, in practical applications, some unreasonable label words are difficult to distinguish, which inevitably has a negative impact on the accuracy of the model. Summary of the invention
[0004] The purpose of the present invention is to overcome the limitations of the prior art and provide a two-stage knowledge-driven prompt tuning method for detecting Chinese implicit hate language. The method uses a graph convolutional network (GCN) combined with a self-attention mechanism (ATT) to extract grammatical structure information from Chinese review texts and deeply explore the syntactic meaning behind the texts. The method proposes a serial extended word mapper construction method based on the combination of expansion and refinement, which transforms the Chinese implicit hate language detection task into a cloze task on the constructed soft prompt template, significantly improving the performance of Chinese implicit hate language detection and achieving efficient classification goals.
[0005] The object of the present invention is achieved by: a two-stage knowledge-driven prompt tuning Chinese implicit hate language detection method, comprising the following steps:
[0006] 1) Aiming at the characteristics of implicit hate language in Chinese, a graph convolutional network combined with an attention mechanism is used to extract the grammatical structure features of the input text;
[0007] 2) Training in a continuous optimal prompt space to obtain a soft prompt template;
[0008] 3) Construct an extended word mapper by integrating external knowledge, and adopt a two-stage series strategy to expand and refine it to generate an optimized extended word mapper;
[0009] 4) A small number of samples are selected from the training set for training to construct a prompt tuning model, and the soft prompt templates mentioned in steps 2) and 3) are combined with the extended word mapper to extract semantic features, which are then concatenated 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, the step 1) specifically comprises:
[0011] Step 1.1) By combining the hybrid model of graph convolutional network GCN and self-attention mechanism ATT, the grammatical structure is analyzed, the linear relationship between sentence components is focused on, and the part-of-speech tagging of words and their dependencies are used to capture grammatical information;
[0012] Step 1.2) The generated dependency graph G is used as the input of the graph convolutional network GCN to extract the grammatical features of each node; the graph convolutional network GCN aggregates the information of each node in the graph structure through convolution operations, combines the information of its adjacent nodes, and generates a node feature representation; the operation of GCN is expressed as:
[0013]
[0014] in, is the adjacency matrix with self-loops added, allowing each node to reaggregate information from its neighbors while retaining and utilizing its own information; A is the adjacency matrix of the dependency graph; yes The degree matrix of (l) represents the node feature matrix of the lth layer, the initial layer H (0) is the input node feature; W (l) is the weight matrix of the lth layer; σ is the nonlinear activation function;
[0015] Step 1.3) After using the graph convolutional network GCN to extract grammatical features, the self-attention mechanism ATT is used to process the node features; the self-attention mechanism ATT dynamically pays attention to different parts of the input sequence, and the features are weighted by calculating the attention weights to capture contextual dependencies; in this way, the model can adjust the feature representation of each node based on the global context information.
[0016] As a further limitation of the present invention, the step 1.1) specifically comprises:
[0017] Step 1.1.1) Use the language technology platform LTP to perform word segmentation on the Chinese review text x, and obtain the word segmentation result CWS=LTP.CWS(x); calculate the part-of-speech tag of each word through POS=LTP.POS(CWS) and assign the part-of-speech category to the word; identify the grammatical relationship between words through dependency 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 tags:
[0019] V={POS i |i=1,2,...,n} (1)
[0020] Where n represents the number of words separated by the word segmentation operation in the text x;
[0021] The edge set E is determined by the dependencies:
[0022] E={(x k ,x l )|x k ,x l ∈x and a dependency relationship DEP kl exists} (2)
[0023] Among them, the edge (x k ,x l ) is composed of two nodes x k and x l Each node represents a part-of-speech tag in the dependency graph.
[0024] As a further limitation of the present invention, the step 2) specifically comprises:
[0025] Step 2.1) Design a soft template based on the two-stage knowledge-driven prompt tuning method for Chinese implicit hate language detection and train it in a continuous optimal prompt space, which is expressed as:
[0026] T={[u i ],...,x,...,[u n ],[mask]} (4)
[0027] where u i represents the i-th learnable marker;
[0028] The constructed prompt template T is input into the encoder of the pre-trained language model to generate a hidden vector h i ,...,h x ,...,hn ,h mask ; At this time, the soft prompt template T is expressed as:
[0029] T={[h i ],...,[h x ],...,[h n ],[h mask ]} (5)
[0030] Step 2.2) Introduce the BiLSTM model as a neural network for the hidden vector h i Modeling is performed, which is expressed as:
[0031]
[0032] Finally, the model uses the loss function L to measure the gap between the output result of the model M when given the input x and mask and the target value, and selects the optimal variable value h. The loss function is as follows:
[0033]
[0034] As a further limitation of the present invention, the step 3) specifically comprises:
[0035] Step 3.1) During the prompt tuning process, the difference between the text space and the label space is alleviated by mapping the extended words to the categories; the automatic selection of label words or the mapping relationship of the extended words is realized, and the expression is:
[0036]
[0037] Among them, v i represents a word in the extended word mapper; y represents the corresponding label, where y = 0 represents non-hate language, which is associated with the "friendly" label word, and on the contrary, y = 1 represents hate language, which corresponds to the "malicious" label;
[0038] Step 3.2) In the construction of the extended word mapper, a two-stage knowledge-based approach is used to detect Chinese implicit hate language; the two stages refer to the concatenation of the expansion and refinement strategies of the extended word mapper.
[0039] As a further limitation of the present invention, the step 3.2) specifically includes:
[0040] Step 3.2.1) When performing knowledge retrieval expansion, the WantWords reverse dictionary is used to achieve retrieval from semantics to vocabulary by matching descriptions or meanings with related words; based on the category information "friendly comments" and "malicious comments", N1 reverse matching words are retrieved as the expanded label word set V y ;
[0041] Take the category name y, i.e., “friendly” and “malicious”, as the anchor word and calculate each extended label word V y The distance dist(V y ,y); extract the top N2 words with the highest cosine similarity to the category name y to further optimize the selection of extended label words;
[0042] Step 3.2.2) In the process of refining the extended words, the extended label words are optimized by probability calculation; the distribution probability of each label word is calculated; the cosine similarity is used to represent the distribution probability of the candidate label words in the two categories; the distribution characteristics of the label words in the two categories are reflected, which is expressed as:
[0043]
[0044] Where i∈{0,1}, P(v|y0) represents the probability of the candidate label word v in the "friendly" category. Similarly, P(v|y1) similarly represents the probability of the candidate label word v in the "offensive" category. Then, the standard deviation of each candidate label word is calculated based on the following formula:
[0045]
[0046] Among them, μ is the average probability of the label word in all categories, expressed as:
[0047]
[0048] The standard deviation is used to represent the words, and the words are sorted from large to small according to the standard deviation. The first N3 label words are selected to construct the final extended word mapper.
[0049] As a further limitation of the present invention, the step 4) specifically comprises:
[0050] Step 4.1) Concatenate the grammatical structure features obtained in step 1) and the semantic features jointly constructed in steps 2) and 3) along the dimension to obtain a comprehensive feature vector:
[0051] F com =[f syn ,h] (12)
[0052] where [·,·] represents the concatenation operation of feature vectors, and f syn Indicates grammatical structural features;
[0053] Step 4.2) Input the concatenated comprehensive feature vector into the multi-layer perceptron MLP to obtain the probability of each label 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, represents the standard cross entropy loss function; N a is the number of samples used as a normalization factor to average the loss; the sum represents the cumulative loss over all samples; y represents the true label; the first half of formula (13) Calculate the difference between the model prediction and the true label; the term α‖θ‖ 2 is the regularization term, where α is a parameter that controls the weight of the regularization term, and ‖θ‖ 2 Represents the squared L2 norm of the model parameter θ.
[0057] The present invention adopts the above technical scheme, and compared with the prior art, the beneficial effects are as follows: (1) The present invention utilizes the construction method of the expansion and refinement expansion word mapper of the serial connection of external knowledge, which effectively reduces the interference of introducing irrelevant noise words; (2) The present invention can take into account both the automatic generation and detection performance of templates; (3) The present invention integrates the attention mechanism and the graph convolutional network according to the characteristics of implicit hate language in Chinese, combines the syntactic structure information of Chinese sentences, and successfully extracts the complex grammatical features in Chinese; The present invention has achieved the best performance on four benchmark datasets, demonstrating its superiority. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 The overall framework diagram of the present invention. DETAILED DESCRIPTION
[0059] like Figure 1 A two-stage knowledge-driven prompt tuning method for detecting implicit hate language in Chinese is shown, comprising the following steps:
[0060] 1) Aiming at the characteristics of implicit hate language in Chinese, a graph convolutional network combined with an attention mechanism is used to extract the grammatical structure features of the input text;
[0061] Step 1.1) A hybrid model combining graph convolutional networks (GCN) and self-attention mechanisms (ATT) is used to deeply analyze the grammatical structure. This method not only focuses on the linear relationship between sentence components, but also uses the part-of-speech tags of words and their dependencies to fully capture grammatical information.
[0062] Step 1.1.1) Use the language technology platform LTP to perform word segmentation on the Chinese review text x, and obtain the word segmentation result CWS = LTP.CWS (x); then, calculate the part-of-speech tag of each word through POS = LTP.POS (CWS), and assign the appropriate part-of-speech category to the word, such as noun, verb, adjective, etc.; then, through dependency analysis DEP = LTP.DEP (CWS), identify the grammatical relationship between words, such as subject-predicate relationship and modifier-center relationship;
[0063] Step 1.1.2) Based on the above analysis, a dependency graph G = (V, E) is constructed;
[0064] The node set V is derived from the part-of-speech tags:
[0065] V={POS i |i=1,2,...,n} (1)
[0066] Here n represents the number of words separated by the word segmentation operation in the text x;
[0067] The edge set E is determined by the dependencies:
[0068] E={(x k ,x l )|x k ,x l ∈x and a dependency relationship DEP kl exists} (2)
[0069] Among them, the edge (x k ,x l ) is composed of two nodes x k and x l Each node represents a part-of-speech tag in the dependency graph;
[0070] The dependency graph G generated in step 1.2) will be used as the input of GCN to extract the grammatical features of each node; GCN aggregates the information of each node in the graph structure through convolution operations, and combines the information of its adjacent nodes to generate a more expressive node feature representation; the operation of the graph convolution network GCN is expressed as:
[0071]
[0072] in, is the adjacency matrix with self-loops added, allowing each node to reaggregate information from its neighbors while retaining and utilizing its own information; A is the adjacency matrix of the dependency graph; yes The degree matrix of(l) represents the node feature matrix of the lth layer, the initial layer H (0) is the input node feature; W (l) is the weight matrix of the lth layer; σ is the nonlinear activation function, and ELU is selected in this method;
[0073] Step 1.3) After using GCN to extract grammatical features, ATT is further used to process the node features; ATT can dynamically focus on different parts of the input sequence, weight the features by calculating attention weights, and capture more complex contextual dependencies; in this way, the model can adjust the feature representation of each node based on the global context information, thereby improving the expressive power of the extracted grammatical structure features.
[0074] 2) Train in a continuous optimal prompt space to obtain a more flexible soft prompt template;
[0075] Step 2.1) Design a soft template based on the two-stage knowledge-driven prompt tuning method for Chinese implicit hate language detection and train it in a continuous optimal prompt space, which is expressed as:
[0076] T={[u i ],...,x,...,[u n ],[mask]} (4)
[0077] where u i represents the i-th learnable marker;
[0078] The constructed hint 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 time, the soft prompt template T is expressed as:
[0079] T={[h i ],...,[h x ],...,[h n ],[h mask ]} (5)
[0080] Step 2.2) Introduce the BiLSTM model as the neural network for the hidden vector h i Modeling is performed, which is expressed as:
[0081]
[0082] Finally, the model uses the loss function L to measure the gap between the output result of the model M when given the input x and mask and the target value, and selects the optimal variable value h. The loss function is as follows:
[0083]
[0084] 3) Construct an extended word mapper by integrating external knowledge, and adopt a two-stage series strategy to expand and refine it, and finally generate an optimized extended word mapper;
[0085] Step 3.1) In the prompt tuning process, by mapping the expansion words to categories, the difference between the text space and the label space is effectively alleviated; the automatic selection of label words or the mapping relationship of expansion words is realized, and its expression is:
[0086]
[0087] Herev i represents a word in the extended word mapper; y represents the corresponding label, where y = 0 represents non-hate language, which is associated with the "friendly" label word, and on the contrary, y = 1 represents hate language, which corresponds to the "malicious" label;
[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 series connection of the expansion and refinement strategies of the extended word mapper;
[0089] Step 3.2.1) When performing knowledge retrieval expansion, the WantWords reverse dictionary is used to achieve retrieval from semantics to vocabulary by matching descriptions or meanings with related words; based on the category information "friendly comments" and "malicious comments", N1 reverse matching words are retrieved as the expanded label word set V y ;
[0090] Take the category name y (i.e., “friendly” and “malicious”) as the anchor word and calculate each extended label word V y The distance dist(V y ,y); through this process, the first N2 words with the highest cosine similarity to the category name y are extracted to further optimize the selection of extended label words;
[0091] Step 3.2.2) In the process of refining the extended words, the extended label words are optimized through probability calculation; the distribution probability of each label word is calculated to ensure that its relevance in the category to which it belongs is significantly enhanced, while its relevance in other categories is significantly weakened, thereby improving the distinguishing ability and task adaptability of the label words;
[0092] Since high similarity indicates a strong correlation and higher probability between the candidate label words and the category, cosine similarity is used to represent the distribution probability of the candidate label words in the two categories; this method reflects the distribution characteristics of the label words in the two categories, which can be expressed as:
[0093]
[0094] Where i∈{0,1}, P(v|y0) represents the probability of the candidate label word v in the "friendly" category. Similarly, P(v|y1) similarly represents the probability of the candidate label word v in the "offensive" category. Then, the standard deviation of each candidate label word is calculated based on the following formula:
[0095]
[0096] Among them, μ is the average probability of the label word in all categories, expressed as:
[0097]
[0098] The standard deviation is used to represent the words, and the words are sorted from large to small according to the standard deviation. The first N3 label words are selected to construct the final extended word mapper.
[0099] According to the standard deviation, the top N3 label words with high correlation with their respective categories and low correlation with other categories are selected to construct the final extended word mapper; a large standard deviation indicates that the label word has a high similarity with the category word of its category and a significant difference with the category words of other categories, which is called high correlation; conversely, when the standard deviation is small, it indicates low correlation.
[0100] 4) A small number of samples are selected from the training set for training to construct a prompt tuning model, and the soft prompt templates and extended word mappers mentioned in steps 2) and 3) are combined to extract semantic features, and the semantic features are combined 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 grammatical structure features obtained in step 1) and the semantic features jointly constructed in steps 2) and 3) along the dimension to obtain a comprehensive feature vector:
[0102] F com =[f syn ,h] (12)
[0103] where [·,·] represents the concatenation operation of feature vectors, and f syn Indicates grammatical structural features;
[0104] Step 4.2) Input the concatenated comprehensive feature vector into the multi-layer perceptron (MLP) to obtain the probability of each label word in the extended word mapper; therefore, the original probability calculation formula is updated 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, represents the standard cross entropy loss function; N a is the number of samples used as a normalization factor to average the loss; the sum represents the cumulative loss over all samples; y represents the true label; the first half of formula (13) Calculate the difference between the model prediction and the true label; the term α‖θ‖ 2 is the regularization term, where α is a parameter that controls the weight of the regularization term, and ‖θ‖ 2 represents the flat L2 norm of the model parameters θ.
[0108] In order to verify the performance of the present invention in detecting implicit hate language in Chinese, experiments were conducted on four Chinese datasets; these datasets were divided into two categories: "friendly" and "malicious";
[0109] Among them, the ToxiCN dataset not only contains objective analysis and affirmative statements, but also covers direct or indirect hate speech samples; this design makes the dataset contain hate speech that lacks obvious malicious words, which is highly consistent with the goal of the present invention against implicit hate language; the ProsCons dataset is composed of online comments on Sina Weibo, in which the annotations are divided into "offensive" and "sarcastic"; because implicit hate language often has characteristics similar to sarcastic speech, the "sarcastic" category in the ProsCons dataset provides effective support for the Chinese implicit hate language detection task. In addition, the present invention selects comments from controversial posts on Weibo and constructs a new Chinese dataset "Chinese Implicit HateSpeech" (CIHS). Through manual annotation, implicit hate language is more accurately distinguished, and comments showing obvious hatred and implicit hatred are uniformly classified as "hateful" categories, while well-intentioned or objective comments are classified as "friendly" categories. Considering that the semantics of comments may change depending on the context, the original post content corresponding to each comment is added to the CIHS dataset to form 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] In order to ensure that the detection effect can be truly measured, two representative evaluation indicators, Accuracy and F1, are selected. The specific definitions are 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 to be malicious but are in fact friendly, fn is the number of comments predicted to be friendly but are in fact malicious, tn is the number of friendly comments that have been correctly predicted, N is the total number of predicted web comments, and the F1 score is the harmonic mean of precision and recall.
[0117] In order to demonstrate the performance of the test results, other traditional baseline methods are used to compare with the two-stage knowledge-driven prompt tuning Chinese implicit hate language detection method (T-KPT) of the present invention on four data sets. These baseline methods include 1) methods based on deep neural networks: sentiment feature-based hate language detection method (SKS); 2) methods based on pre-trained language models: HateBERT, contrastive learning method by generating machine sentences (ConPrompt); 3) methods based on large language models: Llama; 4) methods based on prompt learning: prompt learning (PL), soft template prompt fine-tuning (Soft), prompt learning based on external knowledge (KPT), upgraded version of prompt learning based on external knowledge (KPT++), and Chinese implicit hate language detection based on prompt learning (T-KPT_M).
[0118] In the experiment, 20 positive and negative samples were randomly selected in the training set to model the small sample scenario in the hint learning method and the large language model method, and the number of positive and negative sample training for the deep neural network and pre-trained language model was 1600, 800, 1600 and 1600 on the datasets ToxiCN, ProsCons, CIHS and CIHS_con respectively. The results of the dataset test are shown in Table 2, from which it can be seen that the method of the present invention is superior to other methods in all four indicators on the four datasets.
[0119] Table 2 Experimental results
[0120]
[0121] This paper proposes a Chinese implicit hate language detection method based on two-stage knowledge-driven prompt tuning. By combining graph convolutional networks with self-attention mechanisms, the grammatical structure of Chinese input sentences is captured, and external knowledge is introduced to construct an extended word mapper. Compared with the existing knowledge-driven prompt tuning methods, this paper makes innovative designs in the two dimensions of expansion and refinement to more efficiently construct an extended word mapper for label prediction. A large number of experimental results on four datasets further verify the remarkable effectiveness of this method.
[0122] The present invention is not limited to the above-mentioned embodiments. On the basis of the technical solution disclosed in the present invention, technicians in this field can make some substitutions and deformations to some technical features therein according to the disclosed technical content without creative labor, and these substitutions and deformations are all within the protection scope of the present invention.
Claims
1. A two-stage knowledge-driven prompt-tuned Chinese implicit hate language detection method, characterized in that: The following steps are involved: 1) Aiming at the characteristics of implicit hate language in Chinese, a graph convolutional network combined with an attention mechanism is used to extract the grammatical structure features of the input text; 2) Training in a continuous optimal prompt space to obtain a soft prompt template; 3) Construct an extended word mapper by integrating external knowledge, and adopt a two-stage series strategy to expand and refine it to generate an optimized extended word mapper; 4) A small number of samples are selected from the training set for training to construct a prompt tuning model, and the soft prompt templates mentioned in steps 2) and 3) are combined with the extended word mapper to extract semantic features, which are then concatenated 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 two-stage knowledge-driven prompt-tuned Chinese implicit hate language detection method according to claim 1 is characterized in that: The step 1) specifically includes: Step 1.1) By combining the hybrid model of graph convolutional network GCN and self-attention mechanism ATT, the grammatical structure is analyzed, the linear relationship between sentence components is focused on, and the part-of-speech tagging of words and their dependencies are used to capture grammatical information; Step 1.2) The generated dependency graph G is used as the input of the graph convolutional network GCN to extract the grammatical features of each node; the graph convolutional network GCN aggregates the information of each node in the graph structure through convolution operations, combines the information of its adjacent nodes, and generates a node feature representation; the operation of GCN is expressed as: in, is the adjacency matrix with self-loops added, allowing each node to reaggregate information from its neighbors while retaining and utilizing its own information; A is the adjacency matrix of the dependency graph; yes The degree matrix of (l) represents the node feature matrix of the lth layer, the initial layer H (0) is the input node feature; W (l) is the weight matrix of the lth layer; σ is the nonlinear activation function; Step 1.3) After using the graph convolutional network GCN to extract grammatical features, the self-attention mechanism ATT is used to process the node features; the self-attention mechanism ATT dynamically pays attention to different parts of the input sequence, and the features are weighted by calculating the attention weights to capture contextual dependencies; in this way, the model can adjust the feature representation of each node based on the global context information.
3. The two-stage knowledge-driven prompt-tuned Chinese implicit hate language detection method according to claim 2 is characterized in that: The step 1.1) specifically includes: Step 1.1.1) Use the language technology platform LTP to perform word segmentation on the Chinese review text x, and obtain the word segmentation result CWS=LTP.CWS(x); calculate the part-of-speech tag of each word through POS=LTP.POS(CWS) and assign the part-of-speech category to the word; identify the grammatical relationship between words through dependency 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 tags: V={POS i |i=1,2,...,n} (1) Where n represents the number of words separated by the word segmentation operation in the text x; The edge set E is determined by the dependencies: E={(x k ,x l )|x k ,x l ∈x and a dependency relationship DEP kl exists} (2) Among them, the edge in the edge set (x k ,x l ) is composed of two nodes x k and x l Each node represents a part-of-speech tag in the dependency graph.
4. The two-stage knowledge-driven prompt-tuned Chinese implicit hate language detection method according to claim 1 is characterized in that: The step 2) specifically includes: Step 2.1) Design a soft template based on the two-stage knowledge-driven prompt tuning method for Chinese implicit hate language detection and train it in a continuous optimal prompt space, which is expressed as: T={[u i ],...,x,...,[u n ],[mask]} (4) where u i represents the i-th learnable marker; The constructed prompt template T is input into the encoder of the pre-trained language model to generate a hidden vector h i , ..., h x , ..., h n ,h mask ; At this time, the soft prompt template T is expressed as: T={[h i ],...,[h x ],...,[h n ],[h mask ]} (5) Step 2.2) Introduce the BiLSTM model as the neural network for the hidden vector h i Modeling is performed, which is expressed as: Finally, the model uses the loss function L to measure the gap between the output result of the model M when given the input x and mask and the target value, and selects the optimal variable value h. The loss function is as follows:
5. The two-stage knowledge-driven prompt-tuned Chinese implicit hate language detection method according to claim 1 is characterized in that: The step 3) specifically includes: Step 3.1) During the prompt tuning process, the difference between the text space and the label space is alleviated by mapping the extended words to the categories; the automatic selection of label words or the mapping relationship of the extended words is realized, and the expression is: Among them, v i represents a word in the extended word mapper; y represents the corresponding label, where y=0 represents non-hate language, which is associated with the "friendly" label word, and on the contrary, y=1 represents hate language, which corresponds to the "malicious" label; Step 3.2) In the construction of the extended word mapper, a two-stage knowledge-based approach is used to detect Chinese implicit hate language; the two stages refer to the concatenation of the expansion and refinement strategies of the extended word mapper.
6. The two-stage knowledge-driven prompt-tuned Chinese implicit hate language detection method according to claim 5 is characterized in that: The step 3.2) specifically includes: Step 3.2.1) When performing knowledge retrieval expansion, the WantWords reverse dictionary is used to achieve retrieval from semantics to vocabulary by matching descriptions or meanings with related words; based on the category information "friendly comments" and "malicious comments", N1 reverse matching words are retrieved as the expanded label word set V y ; Take the category name y, i.e. "friendly" and "malicious", as the anchor word and calculate each extended label word V y The distance dist(V y ,y); extract the top N2 words with the highest cosine similarity to the category name y to further optimize the selection of extended label words; Step 3.2.2) In the process of refining the extended words, the extended label words are optimized by probability calculation; the distribution probability of each label word is calculated; the cosine similarity is used to represent the distribution probability of the candidate label words in the two categories; the distribution characteristics of the label words in the two categories are reflected, which is expressed as: Where i∈{0,1}, P(v|y0) represents the probability of the candidate label word v being in the "friendly" category. Similarly, P(v|y1) similarly represents the probability of the candidate label word v being in the "offensive" category. Then, the standard deviation of each candidate label word is calculated based on the following formula: Among them, μ is the average probability of the label word in all categories, expressed as: The standard deviation is used to represent the words, and the words are sorted from large to small according to the standard deviation. The first N3 label words are selected to construct the final extended word mapper.
7. The two-stage knowledge-driven prompt-tuned Chinese implicit hate language detection method according to claim 1 is characterized in that: The step 4) specifically includes: Step 4.1) Concatenate the grammatical structure features obtained in step 1) and the semantic features jointly constructed in steps 2) and 3) along the dimension to obtain a comprehensive feature vector: F com =[f syn ,h] (12) where [·,·] represents the concatenation operation of feature vectors, and f syn Indicates grammatical structural features; Step 4.2) Input the concatenated comprehensive feature vector into the multi-layer perceptron MLP to obtain the probability of each label 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, represents the standard cross entropy loss function; N a is the number of samples used as a normalization factor to average the loss; the sum represents the cumulative loss over all samples; y represents the true label; the first half of formula (13) Calculate the difference between the model prediction and the true label; the term α||θ|| 2 is the regularization term, where α is a parameter that controls the weight of the regularization term, and ||θ|| 2 Represents the squared L2 norm of the model parameter θ.
Citation Information
Patent Citations
Click bait detection method for prompting learning only by utilizing title
CN117033639A
Chinese click bait detection method based on soft prompt learning
CN117421420A
Method for detecting hidden hatred language based on soft prompt tuning
CN119128149A
Soft knowledge prompts for language models
US20240273294A1