Chinese hatred speech detection method fusing multi-dimensional emotional characteristics

By integrating multidimensional emotional characteristics and BiLSTM output and RoBERTa sentence characteristics in Chinese hate speech detection, the problem of poor Chinese hate speech detection in the prior art is solved, and more efficient understanding of emotional and context in Chinese text is achieved, which significantly improves detection accuracy and robustness.

CN119903224AActive Publication Date: 2025-04-29CHINA THREE GORGES UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411811817.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-04-29
Estimated Expiration
2044-12-10

AI Technical Summary

Technical Problem

The existing technology lacks hate speech detection methods for Chinese social media, and the application of foreign language technology cannot effectively adapt to the special grammar and context of Chinese, resulting in poor recognition results.

Method used

The Chinese hate speech detection method that integrates multidimensional emotional characteristics is adopted. By fusing the output of BiLSTM with the RoBERTa sentence characteristics, the model's understanding of local and global information is enhanced, and the model is optimized using the focus loss function to solve the problem of data category imbalance.

Benefits of technology

It significantly improves the accuracy and robustness of Chinese hate speech detection, can more effectively deal with complex emotional and contextual relationships in Chinese texts, and improves the ability to identify obscure hate speech.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119903224A_ABST
    Figure CN119903224A_ABST
Patent Text Reader

Abstract

The invention discloses a Chinese hatred speech detection method fusing multi-dimensional emotional characteristics. The method comprises the following steps: S1, sorting and constructing a social media data set; s2, performing data preprocessing on the data set in the step S1 to obtain input data of the hatred speech detection model; s3, building, training and verifying a hatred speech detection model; the network structure of the hatred speech detection model comprises a text coding layer, an emotion feature layer, a BiLSTM layer and a classification layer; s4, testing and identifying the comments in the social media by using the hatred speech detection model; according to the method, output of BiLSTM and RoBERTa sentence features are fused, so that the understanding ability of the model to local and global information is enhanced. Meanwhile, in order to solve the problem of data category imbalance, the model is optimized by adopting a focus loss function, and the attention of samples difficult to classify is increased by reducing the weight of samples easy to classify, so that the robustness of the model is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to Chinese hate speech detection in natural language processing, and in particular to a Chinese hate speech detection method integrating multi-dimensional sentiment features. Background Art

[0002] With the booming development of social media, the way people communicate has changed. At the same time, the convenience and anonymity of speaking on the Internet have tempted people to be free from the constraints of reality, resulting in the spread of hate speech, which has brought great instability to society. Therefore, it is of great significance to develop an efficient and accurate hate speech detection method.

[0003] In the early hate speech detection methods, the main method was to use manually extracted features combined with machine learning methods to classify hate speech. However, traditional machine learning methods can only mine shallow features of hate speech, and the detection effect is too dependent on the selection of features. After the emergence of deep learning technology, especially pre-trained models such as BERT and RoBERTa, they have been widely used in hate speech detection due to their excellent text processing capabilities. With the rise of Internet pop culture, various words have been given new meanings, and some common words can also become a means of attacking and insulting others in specific contexts, which poses a challenge to traditional detection methods.

[0004] Recent studies have shown that hate speech often contains negative emotions towards a specific group, so the introduction of sentiment analysis technology provides a new perspective for detecting such implicit hate speech. Farha and Magdy combined CNN and BiLSTM and incorporated sentiment information to build a multi-task learning model, which effectively improved the ability to identify hate speech in Arabic tweets; Rajamanickam et al. also introduced sentiment features into the multi-task learning model to obtain auxiliary knowledge to detect abusive speech in English tweets. Although existing studies have considered sentiment features, most of them only consider the single feature of sentiment polarity related to sentiment analysis tasks, and do not consider other sentiment features such as sentiment intensity, negative words and punctuation. Moreover, most related tasks are aimed at the English field, and there are few related studies on Chinese texts. There are also great differences in expression between Chinese and English. At the same time, most of the existing hate speech datasets have the problem of unbalanced data category distribution. Therefore, it is necessary to propose a Chinese hate speech detection method that integrates multi-dimensional sentiment features to solve the above problems. Summary of the invention

[0005] The technical problem to be solved by the present invention is to provide a Chinese hate speech detection method that integrates multi-dimensional emotional features, aiming to solve the problem that the existing technology lacks a hate speech detection method for Chinese social media, and the application of foreign language technology cannot effectively adapt to the special grammar and context of Chinese, resulting in poor recognition effect; it has the characteristic of enhancing the detection model's ability to understand local and global information by fusing the output of BiLSTM with RoBERTa sentence features.

[0006] In order to solve the above technical problems, the technical solution adopted by the present invention is: A Chinese hate speech detection method integrating multi-dimensional sentiment features includes the following steps: S1, organize and construct social media datasets; S2, performing data preprocessing on the data set in step S1 to obtain input data for a hate speech detection model; S3, builds, trains and verifies the hate speech detection model; the network structure of the hate speech detection model includes a text encoding layer, a sentiment feature layer, a BiLSTM layer and a classification layer; S4, using hate speech detection models to test and identify comments in social media, including: S401, a comparative experiment with existing Chinese hate speech detection models on a public dataset; S402, ablation experiments on hate speech detection models; S403, performing parameter analysis on the hate speech detection model.

[0007] Preferably, in step S1, organizing and constructing the social media dataset includes: The publicly available TOXICN and COLDataset Chinese hate speech detection datasets are used, and the training set and test set are randomly divided into two parts in a ratio of 8:2.

[0008] Preferably, the data preprocessing method in step S2 includes using the stuttering word segmentation method to segment the text content to adapt to the extraction of emotional features of hate speech.

[0009] Preferably, in step S3, the RoBERTa pre-trained model is used as a benchmark module to build a hate speech detection model, the pre-processed hate speech text is used as the input of the sentiment feature module, and the original text is used as the input of the text encoding layer to train the hate speech detection model.

[0010] Preferably, step S4 includes inputting the content to be detected into a trained hate speech detection model to identify whether the input content is hate speech.

[0011] Preferably, in step S3, the text encoding layer is composed of RoBERTa, and the text is input into RoBERTa, and the word vector and sentence embedding vector of the text are obtained after processing.

[0012] Preferably, step S3 comprises: For a given input text, use the sentiment dictionary to extract sentiment words , emotional intensity , emotional polarity And other auxiliary features , the four types of features are concatenated to obtain the emotional features of the text .

[0013] Preferably, the BiLSTM layer in step S3 is composed of a bidirectional long short-term memory network BiLSTM, and the word vectors and sentiment features of the text are concatenated and input into the BiLSTM network, and after processing, context-dependent features that integrate both forward and backward directions are obtained.

[0014] Preferably, in step S3, the training of the hate speech detection model includes: S301, extract text features of hate speech: For a given sentence S= , represents the i-th word in the text sequence, and n represents the number of words in the text sequence; Judging by n-grams and insult dictionaries Is it an insult? If so, further classify the target group of the insult; Add the toxicity embedding to the word embedding to get the enhanced representation of the word embedding, The enhancement is expressed as ; Combining the segment embedding and position embedding of the text, the corresponding word vector matrix is ​​obtained through the Transformer module training in RoBERTa V ; Take the Pooler layer output of RoBERTa As a feature representation of the entire sentence; S302, extract sentiment features of hate speech: For a given sentence S= , represents the i-th word in the text sequence, n represents the number of words in the text sequence, and the scores of each word and the entire text in all emotions are summarized to obtain a rich representation; According to the sentiment dictionary, the word-level score s( ,e), Combine the sentiment intensity and sentiment polarity scores in the sentiment dictionary to weight and sum the word-level scores to obtain the sentiment vocabulary , emotional intensity , emotional polarity ; Use the sentiment dictionary to count the frequency of use of punctuation marks, emoticons, emotional words, degree words, negative words, personal pronouns, and advocacy words in the text to obtain other auxiliary features , the four types of features are concatenated to obtain the emotional features of the text ; S303, obtaining deep context-dependent features: The word vector matrix output by RoBERTa V Emotional characteristics Concatenate to get vector , then Input into BiLSTM, calculate through the long short-term memory network in two different directions, and finally merge the calculation results of the two different directions and output them, save the output at each moment, and connect the results to get H ; After obtaining the output vector of the BiLSTM layer module, it is combined with the sentence feature Then, the MLP layer is used to combine the features and map the output vector to the sample label space. SoftMax is used for normalization to calculate the approximate probability value of each label. y .

[0015] The beneficial effects of the present invention are as follows: The present invention provides a Chinese hate speech detection method integrating multi-dimensional sentiment features. The model is trained using a public Chinese hate speech dataset collected from social networks. The RoBERTa pre-training model is combined with a sentiment dictionary to extract word-level, sentence-level features and sentiment features of the text. By fusing the output of BiLSTM with the RoBERTa sentence features, the model's ability to understand local and global information is enhanced. At the same time, in order to solve the problem of data category imbalance, the model is optimized using a focal loss function, which increases the attention of difficult-to-classify samples by reducing the weight of easy-to-classify samples, thereby improving the robustness of the model. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a flow chart of the present invention; Figure 2 This is a model architecture diagram of the present invention; Figure 3 This is a diagram of the text encoding layer model architecture of the present invention; Figure 4 This is a graph showing the experimental results of the TOXICN dataset parameter analysis in the present invention; Figure 5This is a graph showing the experimental results of the COLDataset parameter analysis in the present invention. DETAILED DESCRIPTION

[0017] Embodiment 1: like Figure 1 As shown, a Chinese hate speech detection method integrating multi-dimensional sentiment features includes the following steps: S1, organize and construct social media datasets; S2, performing data preprocessing on the data set in step S1 to obtain input data for a hate speech detection model; S3, builds, trains and verifies the hate speech detection model; the network structure of the hate speech detection model includes a text encoding layer, a sentiment feature layer, a BiLSTM layer and a classification layer; S4, using hate speech detection models to test and identify comments in social media, including: S401, a comparative experiment with existing Chinese hate speech detection models on a public dataset; S402, ablation experiments on hate speech detection models; S403, performing parameter analysis on the hate speech detection model.

[0018] Preferably, in step S1, organizing and constructing the social media dataset includes: The publicly available TOXICN and COLDataset Chinese hate speech detection datasets are used, and the training set and test set are randomly divided into two parts in a ratio of 8:2.

[0019] Preferably, the data preprocessing method in step S2 includes using the stuttering word segmentation method to segment the text content to adapt to the extraction of emotional features of hate speech.

[0020] Preferably, in step S3, the RoBERTa pre-trained model is used as a benchmark module to build a hate speech detection model, the pre-processed hate speech text is used as the input of the sentiment feature module, and the original text is used as the input of the text encoding layer to train the hate speech detection model.

[0021] Preferably, step S4 includes inputting the content to be detected into a trained hate speech detection model to identify whether the input content is hate speech.

[0022] Preferably, in step S3, the text encoding layer is composed of RoBERTa, and the text is input into RoBERTa, and the word vector and sentence embedding vector of the text are obtained after processing.

[0023] Preferably, step S3 comprises: For a given input text, use the sentiment dictionary to extract sentiment words , emotional intensity , emotional polarity And other auxiliary features , the four types of features are concatenated to obtain the emotional features of the text .

[0024] Preferably, the BiLSTM layer in step S3 is composed of a bidirectional long short-term memory network BiLSTM, and the word vectors and sentiment features of the text are concatenated and input into the BiLSTM network, and after processing, context-dependent features that integrate both forward and backward directions are obtained.

[0025] Preferably, in step S3, the training of the hate speech detection model includes: S301, extract text features of hate speech: For a given sentence S= , represents the i-th word in the text sequence, and n represents the number of words in the text sequence; Add "[CLS]" and "[SEP]" segmentation tokens at the beginning and end of the text sequence, respectively, to convert the text sequence into a specific format that can be processed by the RoBERTa model. The embedding of each token is ∈ , which is a vector representation in k-dimensional space; according to Figure 2 In the example above, the category representations of non-toxic terms and sexist terms are set to and ; judged by n-gram and insult dictionary Is it an insulting word? If so, further divide the target group it attacks. Then randomly initialize the category representation to C = ,in ∈ , refers to non-toxic terms, and m is the number of categories in the insult dictionary. In the TOXICN dataset, m=5, and in the CLOD dataset, m=3. Toxicity embedded in The calculation formula is: ; Second, the toxicity embedding is added to the word embedding to obtain the enhanced representation of the word embedding; The enhancement is expressed as = + ,in [0 1] is the weight coefficient for controlling the embedding of toxic knowledge; again, combining the segment embedding and position embedding of the text, the corresponding word vector matrix is ​​obtained through the Transformer module training in RoBERTa V = ∈ ; like Figure 3 As shown, finally, take the Pooler layer output of RoBERTa As a feature representation of the entire sentence; S302, extract sentiment features of hate speech: For a given sentence S= , represents the i-th word in the text sequence, n represents the number of words in the text sequence, and the scores of each word and the entire text in all emotions are summarized to obtain a rich representation; For a specific emotion e, if the emotion word In the sentiment dictionary belongs to sentiment e, and when calculating its word-level score s( ,e) not only considers its word frequency, but also considers the degree value of the degree word in the context of the word and the relationship between the degree word and the sentiment word Since the number of occurrences of negative words may directly change the meaning of the sentence, for example, double negation means affirmation, the number of occurrences of negative words in the window is also considered when extracting sentiment word features.

[0026] In practical applications, the sentiment dictionary ontology is used to match and calculate the value of sentiment vocabulary features. ,e) is calculated as: ; ; Where windows is the window size of the context, neg is the number of occurrences of the negative word and deg( )for degree value within the sentiment lexicon; is the distance weight, dis is and The distance is calculated as follows: ; ; The text-level score for a specific sentiment e is calculated by summing the scores of each word in the text belonging to sentiment e, denoted as s( ,e), the calculation method is as follows: ; Finally, connect All scores of the sentiments are used to obtain sentiment vocabulary features , calculated as follows, where ⊕ is the concatenation operator, and ; ; In order to accurately quantify the intensity of emotion, we first obtain the emotion word according to the calculation process of emotion word features. The word-level score s( ,e); Secondly, the word-level score of emotional intensity is obtained by weighting according to the intensity score in the emotional dictionary Finally, the text-level score of the intensity perception of a specific emotion e is calculated by summing up the word-level score of the emotion intensity of each word in the text belonging to emotion e , and its calculation formula is as follows: ; in Representing words strength score; if In the dictionary, you can find it by searching the sentiment dictionary ,otherwise 0; The emotional intensity feature of the text is obtained by connecting the intensity scores of all sentiment words , and its calculation formula is: ; in, ; In addition to the above-mentioned sentiment-level features, the coarse-grained sentiment score of the text is also considered. Usually, the sentiment score is a positive or negative value, representing the degree of positive or negative polarity of the entire text. The word-level score s( ,e), weighted according to the polarity scores in the BosonNLP sentiment dictionary, and then summed up the polarity scores of all sentiment words in the text. Assume that the dimension of the sentiment score is , we can get the sentiment polarity feature , and its calculation formula is as follows: ; in, Represents the sentiment polarity score of a word. If In the dictionary, we can get ,otherwise 0.

[0027] Since the above features do not explicitly use information other than sentiment words, a set of auxiliary features is used to capture the sentiment information contained in non-word elements; the Wikipedia emoticon list is divided into five categories of emotions: happy, angry, surprised, sad and neutral, and the frequency of use of emoticons is counted using this list; the HowNet sentiment dictionary is used to count the frequency of use of sentiment words, degree words, negative words, personal pronouns and advocacy words. Assume that there is auxiliary features, other auxiliary features can be extracted ; Finally, the above four features are connected to obtain , the calculation formula is: ; in , ; S303, obtaining deep context-dependent features: The word vector matrix output by RoBERTa V Emotional characteristics Concatenate to get vector , then Input into BiLSTM, calculate through the long short-term memory network in two different directions, and finally merge the calculation results of the two different directions and output them, save the output at each moment, and connect the results to get H ; The calculation formula is as follows: ; ; in, represents the output of the forward LSTM, Represents the output of backward LSTM; After obtaining the output vector of the BiLSTM layer module, it is combined with the sentence feature Then, the MLP layer is used to combine the features and map the output vector to the sample label space. SoftMax is used for normalization to calculate the approximate probability value of each label. y , the calculation formula is:

[0028] ; in, is the parameter matrix, is the bias vector; In order to solve the problem of class imbalance, focal loss is used as the loss function to measure the difference between the true value and the predicted value. The calculation method is as follows: ; in, is a non-negative adjustable focusing parameter used to distinguish easy samples from difficult samples; is a weight factor that balances the importance of positive and negative samples; t is the index of the non-zero element in the true label; is the predicted probability of category t.

[0029] Embodiment 2: In step S4, the hate speech detection model is used to test and identify comments in social media as follows: Step 4.1: On a public dataset, a comparative experiment is conducted with the existing Chinese hate speech detection algorithm, using precision, recall, and F1-score as evaluation indicators. The experimental results are shown in Tables 1 and 2.

[0030] Table 1: Results of each model on the TOXICN dataset (unit: %);

[0031] Table 2: Results of each model on the COLDataset dataset (unit: %);

[0032] Step 4.2: Conduct an ablation experiment on the Chinese hate speech detection model as follows: (1) w / o EMO: means removing the emotional feature module in the model.

[0033] (2) w / o SE: indicates removing the sentence embedding features of RoBERTa in the model.

[0034] (3) w / o EMO+SE: means removing the sentence embedding and sentiment feature modules of RoBERTa from the model at the same time.

[0035] The experimental results are shown in Tables 3 and 4.

[0036] Table 3: Ablation experiment results of TOXICN dataset (unit: %);

[0037] Table 4: Ablation experiment results of COLDataset (unit: %);

[0038] It can be seen from Tables 1 to 4 that the method of the present invention integrates multi-dimensional sentiment features, considers character and sentence features at the same time, improves the model's ability to recognize hate speech, and uses the focal loss function to alleviate the problem of data category imbalance, thereby obtaining better detection results.

[0039] Step 4.3: Analyze the parameters of the hate speech detection model. The main parameters include the size of the context extraction window and the Dropout value in the feature module. The experimental results are as follows: Figure 4 and Figure 5 As shown in the figure, it can be found that in the TOXICN dataset and the COLDataset dataset, when the windows is set to 2 and the Dropout values ​​are 0.6 and 0.1 respectively, the model detection performance reaches the best.

[0040] In summary, the present invention provides a method for detecting Chinese hate speech that integrates multi-dimensional emotional features. The method uses RoBERTa to extract character features and sentence features of the input text, and uses tools such as emotional dictionaries to extract multi-dimensional emotional features including emotional vocabulary, emotional polarity, emotional intensity, punctuation and emoticons of the text; then the character features and emotional features are spliced ​​and input into the BiLSTM network to learn deeper contextual semantic information; finally, in order to obtain semantic information at different levels, the output results of BiLSTM are connected with the sentence features of RoBERTa to achieve efficient fusion of local and global information, improve the representation ability of the model, and help to better handle the complex relationship between emotions and context in Chinese text. At the same time, in order to solve the problem of data category imbalance, the model is optimized using a focal loss function, which increases the attention of difficult-to-classify samples by reducing the weight of easy-to-classify samples, thereby improving the robustness of the model. The present invention not only realizes the innovative application of pre-trained models and emotional features in the field of Chinese hate speech detection, but also significantly improves the model's ability to recognize implicit hate speech through the introduction of multi-dimensional emotional features.

Claims

1. A Chinese hate speech detection method integrating multi-dimensional sentiment features, characterized in that: The following steps are involved: S1, organize and construct social media datasets; S2, performing data preprocessing on the data set in step S1 to obtain input data for a hate speech detection model; S3, builds, trains and verifies the hate speech detection model; the network structure of the hate speech detection model includes a text encoding layer, a sentiment feature layer, a BiLSTM layer and a classification layer; S4, using hate speech detection models to test and identify comments in social media, including: S401, a comparative experiment with existing Chinese hate speech detection models on a public dataset; S402, ablation experiments on hate speech detection models; S403, performing parameter analysis on the hate speech detection model.

2. According to the method for detecting Chinese hate speech integrating multi-dimensional emotional features according to claim 1, it is characterized in that: In step S1, the social media dataset is collated and constructed including: The publicly available TOXICN and COLDataset Chinese hate speech detection datasets are used, and the training set and test set are randomly divided into two parts in a ratio of 8:

2.

3. The Chinese hate speech detection method integrating multi-dimensional emotional features according to claim 2 is characterized in that: The data preprocessing method in step S2 includes using the stuttering word segmentation method to segment the text content to adapt to the extraction of emotional features of hate speech.

4. The method for detecting Chinese hate speech by integrating multi-dimensional emotional features according to claim 3, characterized in that: In step S3, the RoBERTa pre-trained model is used as a benchmark module to build a hate speech detection model, the pre-processed hate speech text is used as the input of the sentiment feature module, and the original text is used as the input of the text encoding layer to train the hate speech detection model.

5. The method for detecting Chinese hate speech by integrating multi-dimensional emotional features according to claim 4, characterized in that: Step S4 includes inputting the content to be detected into a trained hate speech detection model to identify whether the input content is hate speech.

6. The Chinese hate speech detection method integrating multi-dimensional emotional features according to claim 1 is characterized in that: In step S3, the text encoding layer is composed of RoBERTa. The text is input into RoBERTa and the word vector and sentence embedding vector of the text are obtained after processing.

7. The method for detecting Chinese hate speech by integrating multi-dimensional emotional features according to claim 1, characterized in that: Step S3 includes: For a given input text, use the sentiment dictionary to extract sentiment words , emotional intensity , emotional polarity And other auxiliary features , the four types of features are concatenated to obtain the emotional features of the text .

8. The method for detecting Chinese hate speech integrating multi-dimensional emotional features according to claim 1, characterized in that: In step S3, the BiLSTM layer is composed of a bidirectional long short-term memory network BiLSTM. The word vectors and sentiment features of the text are concatenated and input into the BiLSTM network. After processing, context-dependent features that integrate both forward and backward directions are obtained.

9. The method for detecting Chinese hate speech by integrating multi-dimensional emotional features according to claim 1, characterized in that: In step S3, the training of the hate speech detection model includes: S301, extract text features of hate speech: For a given sentence S= , represents the i-th word in the text sequence, and n represents the number of words in the text sequence; Judging by n-grams and insult dictionaries Is it an insult? If so, further classify the target group of the insult; Add the toxicity embedding to the word embedding to get the enhanced representation of the word embedding, The enhancement is expressed as ; Combining the segment embedding and position embedding of the text, the corresponding word vector matrix is ​​obtained through the Transformer module training in RoBERTa V ; Take the Pooler layer output of RoBERTa As a feature representation of the entire sentence; S302, extract sentiment features of hate speech: For a given sentence S= , represents the i-th word in the text sequence, n represents the number of words in the text sequence, and the scores of each word and the entire text in all emotions are summarized to obtain a rich representation; According to the sentiment dictionary, the word-level score s( ,e), Combine the sentiment intensity and sentiment polarity scores in the sentiment dictionary to weight and sum the word-level scores to obtain the sentiment vocabulary , emotional intensity , emotional polarity ; Use the sentiment dictionary to count the frequency of use of punctuation marks, emoticons, emotional words, degree words, negative words, personal pronouns, and advocacy words in the text to obtain other auxiliary features , the four types of features are concatenated to obtain the emotional features of the text ; S303, obtaining deep context-dependent features: The word vector matrix output by RoBERTa V Emotional characteristics Concatenate to get vector , then Input into BiLSTM, calculate through the long short-term memory network in two different directions, and finally merge the calculation results of the two different directions and output them, save the output at each moment, and connect the results to get H ; After obtaining the output vector of the BiLSTM layer module, it is combined with the sentence feature Then, the MLP layer is used to combine the features and map the output vector to the sample label space. SoftMax is used for normalization to calculate the approximate probability value of each label. y .

Citation Information

Patent Citations

  • Voice emotion recognition method and device based on artificial intelligence, equipment and medium

    CN116844573A

  • Hatred speech detection method and system based on semantic enhancement and storage medium

    CN118520070A

  • Contrastive learning method based on implications for detecting implicit hate expression, apparatus and computer program for performing the method

    US20240135243A1