Chinese fraudulence detection model training method, Chinese fraudulence detection method, Chinese fraudulence detection equipment and medium

By establishing pinyin-to-word vector conversion rules and parallel feature extraction in the Chinese offensiveness detection model, the problem of homophonic text detection is solved, detection efficiency and accuracy are improved, and it is suitable for complex Chinese environments.

CN118569253APending Publication Date: 2024-08-30CHINA TELECOM CORP LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410704133.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing Chinese offensiveness detection methods are difficult to effectively detect offensive speech containing homophonic text, resulting in reduced detection efficiency.

Method used

By establishing the conversion rules from Chinese Pinyin to language model word vectors in the Chinese offensiveness detection model, the parallel pre-trained language model is used to extract Chinese text and Pinyin features, and the two are fused, and iterative training is based on the classification network to improve detection performance. .

Benefits of technology

It improves the training efficiency and detection accuracy of the Chinese offensive detection model, weakens the impact of homophonic text on detection results, and enhances the adaptability and accuracy in complex Chinese environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569253A
    Figure CN118569253A
Patent Text Reader

Abstract

The invention provides a training method, a detection method, a device and a medium for a Chinese fraudulence detection model, and the method comprises the steps: obtaining a training data set, each piece of data in the training data set comprising a segment of to-be-detected text with no harmonic annotation or weak harmonic annotation, and a dichotomy label for determining whether the to-be-detected text has fraudulence; on a pre-training language model in the Chinese fraudulence detection model, establishing a conversion rule from Chinese pinyin to a language model word vector; extracting Chinese character features and pinyin features of each to-be-detected character by using a parallel pre-training language model based on a conversion rule; fusing the Chinese character features and the pinyin features of each to-be-detected character; and performing iterative training on the fused features of each to-be-detected character and the corresponding dichotomy label based on a classification network in the Chinese fraudulence detection model, and taking the Chinese fraudulence detection model as a trained Chinese fraudulence detection model when a loss function of the classification network reaches a stable value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to natural language processing technology, and in particular to a training method for a Chinese offensiveness detection model, a Chinese offensiveness detection method, a device, an electronic device, and a computer-readable storage medium. Background Art

[0002] With the widespread popularity of social media platforms, the scope and scale of online discussions have continued to expand. However, a small number of users have abused the anonymity provided by online social media and engaged in unacceptable social behaviors in real life, resulting in the continuous emergence of offensive language.

[0003] There are two types of methods for detecting offensive Chinese words: traditional manual detection and automated detection. Traditional manual detection is to manually determine whether the target text is offensive. This method is time-consuming and labor-intensive, has a long review cycle, and is subject to subjectivity. Automated detection can be divided into word library matching detection methods and deep learning-based detection methods. Among them, most automated detection is currently based on word library matching. For example, using improved machine learning methods to expand the word library makes the detection more sensitive. For another example, first use the word library for matching, and then use the deep learning model to perform further precise detection operations on the matching results. Although there are many ways to expand the word library or optimize word library matching at this stage, word library detection still has problems such as inflexible word library expansion, poor reuse ability, and high false positive rate. Detection methods based on deep learning are considered to be one of the important ways to solve such problems. However, in the process of using deep learning technology to solve the problem of Chinese offensiveness detection, the most common obstacle is that offensive Chinese speech on the Internet often uses homophonic text to evade the review of offensiveness detection systems. There are few existing data sets for Chinese offensiveness detection, and there is an even lack of data sets containing a certain proportion of homophonic data. Directly using existing data sets to train deep learning algorithm models is also difficult to detect offensive speech containing homophonic text.

[0004] How to effectively detect offensive speech containing homophonic text is a problem that needs to be solved. Summary of the invention

[0005] The present invention provides a training method for a Chinese offensiveness detection model, a Chinese offensiveness detection method, a device, an electronic device, and a computer-readable storage medium, so as to at least solve the problem in the related art that offensive speech containing homophonic text cannot be effectively detected, resulting in reduced offensiveness detection efficiency. The technical solution of the present invention is as follows:

[0006] According to a first aspect of an embodiment of the present invention, a method for training a Chinese offensiveness detection model is provided, comprising:

[0007] Acquire a training data set, where each piece of data in the training data set includes: a piece of text to be detected without homophonic annotation or with weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive;

[0008] Based on the pre-trained language model in the Chinese offensive detection model, establish the conversion rules from Chinese pinyin to language model word vectors;

[0009] Based on the conversion rule, using the parallel pre-trained language model, simultaneously extracting Chinese character features and pinyin features of each to-be-detected character in the training data set;

[0010] Fusion of Chinese character features and Pinyin features of each of the characters to be detected;

[0011] Based on the classification network in the Chinese offensive detection model, the fused features of each to-be-detected text and the corresponding binary classification labels are iteratively trained, and the Chinese offensive detection model when the loss function of the classification network reaches a stable value is used as the trained Chinese offensive detection model.

[0012] Optionally, the conversion rules from Chinese pinyin to language model word vectors are established on the pre-trained language model in the Chinese offensiveness detection model, including:

[0013] Obtain the pinyin constituting the Chinese characters excluding the tones to form a pinyin sequence;

[0014] Get the symbols and serial numbers commonly used in Chinese expressions to form a character sequence;

[0015] The pinyin sequence and the character sequence are converted into a corresponding language dictionary according to the mapping rule of the language model, and the language dictionary is used as a conversion rule from Chinese pinyin to a language model word vector.

[0016] Optionally, based on the conversion rule, using the parallel pre-trained language model to simultaneously extract Chinese character features and pinyin features of each to-be-detected character in the training data set includes:

[0017] Convert each to-be-detected text in the training data set into pinyin without tones;

[0018] Based on the conversion rule, each of the characters to be detected and the corresponding pinyin are converted to obtain the converted characters to be detected and pinyin;

[0019] The converted characters and pinyin to be detected are used as two branches and simultaneously input into a parallel pre-trained language model for feature extraction to obtain corresponding Chinese character features and pinyin features.

[0020] Optionally, the fusing of the Chinese character features and the pinyin features of each of the characters to be detected includes:

[0021] Transpose and calculate the outer product of the Chinese character features and the pinyin features of each of the characters to be detected to obtain preliminary fusion features;

[0022] Determine the weight of the Chinese character feature and the weight of the pinyin feature by using an attention mechanism;

[0023] Using the weight of the Chinese character feature and the corresponding Chinese character feature to perform weighting, and using the weight of the Pinyin feature and the corresponding Pinyin feature to perform weighting;

[0024] The weighted result of the Chinese character feature and the weighted result of the pinyin feature are superimposed to obtain a final fusion feature.

[0025] Optionally, the Chinese character features and the pinyin features of each of the characters to be detected are transposed and outer-producted to obtain preliminary fusion features, including:

[0026] Performing a matrix transposition on the Chinese character features of each of the characters to be detected to obtain a matrix-transposed Chinese character feature; multiplying the matrix-transposed Chinese character feature with the corresponding pinyin feature to obtain a preliminary fusion feature; or

[0027] Perform matrix transposition on the pinyin features of each of the characters to be detected to obtain the pinyin features after matrix transposition; multiply the pinyin features after matrix transposition with the corresponding Chinese character features to obtain preliminary fusion features.

[0028] Optionally, the using of the attention mechanism to determine the weight of the Chinese character feature and the weight of the pinyin feature includes:

[0029] Calculating the outer product of the Chinese character features after the matrix transposition and the Chinese character features; superimposing the outer product with the preliminary fusion features to form a dual-channel Chinese character feature; performing convolution and pooling calculations on the dual-channel Chinese character features to obtain a weight range of the Chinese character features; using an activation function sigmoid to map the weight range of the Chinese character features to 0 to 1; and

[0030] Calculate the outer product of the pinyin feature and the pinyin feature after the matrix transposition; superimpose the outer product with the preliminary fusion feature to form a dual-channel pinyin feature; perform convolution and pooling calculations on the dual-channel pinyin feature to obtain the weight range of the pinyin feature; use the activation function sigmoid to map the weight range of the pinyin feature to 0 to 1.

[0031] Optionally, the classification network in the Chinese offensive detection model is used to iteratively train the fused features of each to-be-detected text and the corresponding binary classification label, and the Chinese offensive detection model when the loss function of the classification network reaches a stable value is used as the trained Chinese offensive detection model, including:

[0032] Performing offensive detection on the fused features of each of the to-be-detected texts based on the classification network in the Chinese offensive detection model;

[0033] Iterative training is performed based on the detection result of offensiveness detection and the binary classification label of whether the text to be detected is offensive. During the iterative training process, the detection result is compared with the binary classification label, and the difference in the comparison is used as the classification loss function of the classification network. Based on the classification loss function, the parameters of the classification network are adjusted through the back propagation mechanism until the loss function reaches a stable value. The Chinese offensiveness detection model obtained is used as the trained Chinese offensiveness detection model.

[0034] Optionally, the method further includes:

[0035] Obtaining a verification data set, the verification data set including: a set ratio of homophonic texts in the text to be detected, and a binary classification label of whether all the text to be detected is offensive;

[0036] All the characters to be detected in the verification data set and the corresponding binary classification labels of whether the characters to be detected are offensive are input into the trained Chinese offensive detection model for verification testing to obtain the test performance indicators of the Chinese offensive detection model, and the test performance indicators include: accuracy, precision and recall.

[0037] According to a second aspect of an embodiment of the present invention, a method for detecting offensiveness of Chinese characters is provided, comprising:

[0038] Get a piece of text to be detected;

[0039] The Chinese offensiveness detection is performed on the text to be detected based on the Chinese offensiveness detection model to obtain a Chinese offensiveness detection result, wherein the Chinese offensiveness detection model is based on the conversion rule from Chinese pinyin to language model word vector, uses a parallel pre-trained language model, extracts Chinese text features and pinyin features of each text to be detected in the training data set, and fuses the extracted Chinese text features and pinyin features, and iteratively trains the fused features and the corresponding binary classification labels of the text to be detected.

[0040] According to a third aspect of an embodiment of the present invention, there is provided a training device for a Chinese offensiveness detection model, comprising:

[0041] A first acquisition module is used to acquire a training data set, where each piece of data in the training data set includes: a section of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive;

[0042] Establish a module for establishing the conversion rules from Chinese pinyin to language model word vectors based on the pre-trained language model in the Chinese offensive detection model;

[0043] An extraction module, for simultaneously extracting Chinese character features and pinyin features of each to-be-detected character in the training data set based on the conversion rule and using the parallel pre-trained language model;

[0044] A fusion module, used for fusing the Chinese character features and the pinyin features of each of the characters to be detected;

[0045] The training module is used to iteratively train the fused features of each to-be-detected text and the corresponding binary classification labels based on the classification network in the Chinese offensive detection model, and use the Chinese offensive detection model when the loss function of the classification network reaches a stable value as the trained Chinese offensive detection model.

[0046] Optionally, the establishing module includes:

[0047] A pinyin sequence acquisition module is used to acquire the pinyins that constitute Chinese characters without tones to form a pinyin sequence;

[0048] A character sequence acquisition module is used to acquire symbols and serial numbers commonly used in Chinese expressions to form a character sequence;

[0049] The pinyin conversion module is used to convert the pinyin sequence and the character sequence into a corresponding language dictionary according to the mapping rules of the language model, and the language dictionary is used as a conversion rule from Chinese pinyin to a language model word vector.

[0050] Optionally, the extraction module includes:

[0051] A first conversion module, used for converting each to-be-detected text in the training data set into pinyin without tone;

[0052] A second conversion module is used to convert each of the characters to be detected and the corresponding pinyin respectively based on the conversion rule to obtain the converted characters to be detected and the pinyin;

[0053] The feature extraction module is used to take the converted characters and pinyin to be detected as two branches and simultaneously input them into a parallel pre-trained language model for feature extraction to obtain corresponding Chinese character features and pinyin features.

[0054] Optionally, the fusion module includes:

[0055] A feature determination module, used for performing transposition and outer product calculation on the Chinese character features and pinyin features of each of the characters to be detected to obtain preliminary fusion features;

[0056] A weight determination module, used to determine the weight of the Chinese character feature and the weight of the pinyin feature by using an attention mechanism;

[0057] A weighting module, used for weighting the Chinese character feature with the corresponding Chinese character feature, and for weighting the phonetic feature with the corresponding phonetic feature;

[0058] The superposition module is used to superimpose the weighted result of the Chinese character feature and the weighted result of the pinyin feature to obtain a final fusion feature.

[0059] Optionally, the feature determination module includes: a first transposition module and a first calculation module; and / or, a second transposition module and a second calculation module;

[0060] The first transposition module is used to perform matrix transposition on the Chinese character features of each of the characters to be detected to obtain the Chinese character features after matrix transposition;

[0061] The first calculation module is used to multiply the Chinese character features after the matrix transposition by the corresponding pinyin features to obtain preliminary fusion features; or

[0062] The second transposition module is used to perform matrix transposition on the phonetic features of each of the characters to be detected to obtain the phonetic features after matrix transposition;

[0063] The second calculation module is used to multiply the pinyin features after the matrix transposition by the corresponding Chinese character features to obtain preliminary fusion features.

[0064] Optionally, the weight determination module includes:

[0065] A first outer product calculation module, used to calculate the outer product of the Chinese character features after matrix transposition and the Chinese character features;

[0066] A first feature superposition module, used for superimposing the outer product with the preliminary fusion feature to form a dual-channel Chinese character feature;

[0067] A first pooling calculation module is used to perform convolution and pooling calculations on the Chinese character features of the dual channels to obtain a weight range of the Chinese character features;

[0068] A first mapping module is used to map the weight range of the Chinese character feature to 0 to 1 using an activation function sigmoid; and

[0069] The second outer product calculation module is used to calculate the outer product of the phonetic feature and the phonetic feature after the matrix is ​​transposed;

[0070] A second superposition module is used to superimpose the outer product with the preliminary fusion feature to form a dual-channel pinyin feature;

[0071] A second pooling calculation module is used to perform convolution and pooling calculations on the pinyin features of the dual channels to obtain a weight range of the pinyin features;

[0072] The second mapping module is used to map the weight range of the pinyin feature to 0 to 1 using the activation function sigmoid.

[0073] Optionally, the training module includes:

[0074] A detection module, configured to perform offensive detection on the fused features of each of the characters to be detected based on the classification network in the Chinese offensive detection model;

[0075] The iterative training module is used to perform iterative training based on the detection result of offensiveness detection and the binary classification label of whether the text to be detected is offensive. During the iterative training process, the detection result is compared with the binary classification label, and the difference in the comparison is used as the classification loss function of the classification network. Based on the classification loss function, the parameters of the classification network are adjusted through the back propagation mechanism until the Chinese offensiveness detection model obtained when the loss function reaches a stable value is used as the trained Chinese offensiveness detection model.

[0076] Optionally, the device further comprises:

[0077] The second acquisition module is used to acquire a verification data set, wherein the verification data set includes: a set ratio of homophonic texts in the text to be detected, and a binary classification label of whether all the text to be detected is offensive;

[0078] The verification module is used to input all the characters to be detected in the verification data set and the corresponding binary classification labels of whether the characters to be detected are offensive into the trained Chinese offensive detection model for verification, and obtain the detection performance indicators of the Chinese offensive detection model, wherein the detection performance indicators include: accuracy, precision and recall.

[0079] According to a fourth aspect of an embodiment of the present invention, there is provided a device for detecting offensiveness of Chinese characters, comprising:

[0080] An acquisition module is used to acquire a piece of text to be detected;

[0081] The detection module is used to perform Chinese offensive detection on the text to be detected based on the Chinese offensive detection model to obtain a Chinese offensive detection result, wherein the Chinese offensive detection model is based on the conversion rule from Chinese pinyin to language model word vector, using a parallel pre-trained language model to extract Chinese text features and pinyin features of each text to be detected in the training data set, and fuse the extracted Chinese text features and pinyin features, and iteratively train the fused features with the corresponding binary classification labels of the text to be detected.

[0082] According to a fifth aspect of an embodiment of the present invention, there is provided an electronic device, including:

[0083] processor;

[0084] a memory for storing instructions executable by the processor;

[0085] The processor is configured to execute the instructions to implement the training of the Chinese offensiveness detection model as described above or the Chinese offensiveness detection method as described above.

[0086] According to a sixth aspect of an embodiment of the present invention, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the training of the Chinese offensiveness detection model as described above or the Chinese offensiveness detection method as described above.

[0087] According to a seventh aspect of an embodiment of the present invention, a computer program product is provided, comprising a computer program or instructions, which, when executed by a processor of an electronic device, implements the training of the Chinese offensiveness detection model as described above or the Chinese offensiveness detection method as described above.

[0088] The technical solution provided by the embodiments of the present invention brings at least the following beneficial effects:

[0089] In an embodiment of the present invention, a training data set is obtained, wherein each piece of data in the training data set includes: a piece of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive; a conversion rule from Chinese pinyin to a language model word vector is established on a pre-trained language model in a Chinese offensive detection model; based on the conversion rule, the parallel pre-trained language model is used to simultaneously extract Chinese text features and pinyin features of each text to be detected in the training data set; the Chinese text features and pinyin features of each text to be detected are fused; based on the classification network in the Chinese offensive detection model, the fused features of each text to be detected and the corresponding binary classification label are iteratively trained, and the Chinese offensive detection model when the loss function of the classification network reaches a stable value is used as the trained Chinese offensive detection model. That is to say, the embodiment of the present invention constructs a conversion rule from Chinese pinyin to language model word vector based on the training of the Chinese offensiveness detection model, and realizes the feature extraction of Chinese pinyin data directly by the language model; and based on multimodal learning, a parallel pre-trained language model network is proposed, and simultaneous feature extraction of data of two modalities is realized; and the two extracted features are fused, which solves the fusion problem of data features of the two modalities and avoids the influence of redundant features, thereby realizing higher performance of Chinese offensiveness detection, especially weakening the influence of homophonic text on the detection results, thereby improving the training efficiency of the Chinese offensiveness detection model.

[0090] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0091] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention, and do not constitute an improper limitation of the present invention. In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art description will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0092] Figure 1 It is a flow chart of a method for training a Chinese offensiveness detection model provided by an embodiment of the present invention.

[0093] Figure 2 The flowchart of a method for detecting offensive Chinese characters is provided in an embodiment of the present invention.

[0094] Figure 34 is a diagram showing an application example of a method for detecting offensive Chinese characters provided by the present invention.

[0095] Figure 4 4 is a block diagram of a training device for a Chinese offensiveness detection model provided by an embodiment of the present invention.

[0096] Figure 5 It is a block diagram of a building module provided by an embodiment of the present invention.

[0097] Figure 6 It is another block diagram of a training device for a Chinese offensiveness detection model provided by an embodiment of the present invention.

[0098] Figure 7 4 is a block diagram of a Chinese offensiveness detection device provided by an embodiment of the present invention.

[0099] Figure 8 It is a block diagram of an electronic device provided by an embodiment of the present invention.

[0100] Fig. 9 It is a block diagram of a device for training a Chinese offensiveness detection model or detecting Chinese offensiveness provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0101] In order to enable ordinary persons in the art to better understand the technical solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings.

[0102] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Instead, they are merely examples of devices and methods consistent with some aspects of the present invention as detailed in the appended claims.

[0103] Technical terms:

[0104] Offensive detection in Chinese: Offensive detection is a technical means to identify sensitive, threatening, insulting and negative comments in text. At present, there are many studies and applications on offensive detection in English. Offensive detection in Chinese usually converts Chinese into English and then uses English offensive detection methods for detection, which may cause semantic loss and ambiguity.

[0105] Chinese homophones: refers to words or syllables that are similar or identical in pronunciation in Chinese.

[0106] Natural Language Processing: Natural Language Processing (NLP) is an interdisciplinary field that applies the characteristics and laws of human language to computer science and artificial intelligence. By analyzing, understanding and generating human language, computers can better understand human language. Natural language processing can be applied to many fields, such as machine translation, text classification, intelligent customer service, etc.

[0107] Large language model: A language model is an artificial intelligence system that can learn and understand the rules and structure of natural language to complete specific tasks. Large language models refer to language models with huge parameters and training data, such as the GPT large model released by OpenAI, the Wenxin large model released by Baidu, and the Xingchen semantic large model released by China Telecom. Multimodal learning: Multimodality is the expression or perception of things from multiple modalities. Generally, there are three types of information: different multimedia data describing the same object, the same type of media data from different sensors, and information with different data structure characteristics or representation forms. Multimodal learning is a general term for algorithms that use multiple modalities for parallel or serial learning to improve their own performance.

[0108] On the basis of understanding the above technical terms, please refer to the following embodiments.

[0109] Figure 1 is a flow chart of a method for training a Chinese offensive detection model provided by an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:

[0110] Step 101: obtaining a training data set, wherein each piece of data in the training data set includes: a piece of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive;

[0111] Step 102: establishing a conversion rule from Chinese pinyin to a language model word vector on the pre-trained language model in the Chinese offensiveness detection model;

[0112] Step 103: Based on the conversion rule, using the parallel pre-trained language model, simultaneously extracting Chinese character features and pinyin features of each to-be-detected character in the training data set;

[0113] Step 104: fusing the Chinese character features and the pinyin features of each of the characters to be detected;

[0114] Step 105: Iteratively train the fused features of each to-be-detected text and the corresponding binary classification labels based on the classification network in the Chinese offensive detection model, and use the Chinese offensive detection model when the loss function of the classification network reaches a stable value as the trained Chinese offensive detection model.

[0115] The training method of the Chinese offensive detection model described in the present invention can be applied to terminals, servers, etc., without limitation herein. The terminal implementation device can be electronic devices such as smart phones, laptops, tablet computers, desktop computers, personal digital assistants (PDAs) and wearable devices. The server can be an independent server or a server cluster, or a server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, intermediate services, domain name services, security services, content distribution networks, or a big data and artificial intelligence platform, etc., without limitation herein.

[0116] Combine the following Figure 1 , the specific implementation steps of a training method for a Chinese offensiveness detection model provided by an embodiment of the present invention are described in detail.

[0117] In step 101, a training data set is obtained, where each piece of data in the training data set includes: a piece of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected has offensiveness.

[0118] In this step, the training data set obtained is suitable for data for offensive detection of Chinese. Usually, each piece of data in the training data set may include a piece of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive. The binary classification label in this step is manually marked according to the detection requirements, and a public data set that meets the standards can also be used to replace the acquisition process in this step, which is not limited in this embodiment. Among them, the text to be detected in each piece of data in the training data set should not appear or try to avoid homophonic text.

[0119] It should be noted that, in this embodiment, when there is no homophonic or weak homophonic annotation in the training set (that is, during the training process, it is unknown whether there are homophonic annotations in the training data set), the performance on the test set can be good.

[0120] In step 102, a conversion rule from Chinese pinyin to a language model word vector is established on the pre-trained language model in the Chinese offensiveness detection model.

[0121] In this step, first, the pinyin constituting the Chinese characters excluding tones is obtained to form a pinyin sequence; and the symbols and serial numbers commonly used in Chinese expressions are obtained to form a character sequence; then, the pinyin sequence and the character sequence are converted into a corresponding language dictionary according to the mapping rules of the language model, and the language dictionary is used as a conversion rule from Chinese pinyin to the language model word vector.

[0122] In this step, a conversion rule from Chinese pinyin to language model word vector is constructed on the pre-trained language model in the Chinese offensiveness detection model, so as to directly extract Chinese pinyin features through the conversion rule. The specific process includes:

[0123] First, enumerate the pinyin without tones that make up Chinese characters to form a pinyin sequence. This step can not only identify homophones, but also homophones. Secondly, enumerate the common punctuation marks, serial numbers, etc. in Chinese expressions to form a character sequence, which can also be called a special character sequence. Finally, convert the pinyin sequence and character sequence into the corresponding language dictionary according to the mapping rules of the language model. The language dictionary is used to realize the conversion of Chinese pinyin to the language model word vector, which makes it easier for the language model to directly extract pinyin features from Chinese pinyin.

[0124] In this step, the conversion rules from Chinese pinyin to language model word vectors for the pre-trained language model are constructed. By enumerating the pinyin without tones, a one-to-one mapping between Chinese pinyin and word vectors is achieved. Thus, the pre-trained language model can directly extract the features of Chinese pinyin. Compared with the text features, the individual pinyin features of Chinese are more sensitive to homophones and have better applicability and expressiveness when processing Chinese texts.

[0125] In step 103, based on the conversion rule, the parallel pre-trained language model is used to simultaneously extract Chinese character features and pinyin features of each character to be detected in the training data set.

[0126] This step includes: converting each to-be-detected text in the training data set into a pinyin without tone; based on the conversion rule, converting each to-be-detected text and the corresponding pinyin respectively to obtain the converted to-be-detected text and pinyin; taking the converted to-be-detected text and pinyin as two branches, and simultaneously inputting them into a parallel pre-trained language model for feature extraction to obtain corresponding Chinese text features and pinyin features.

[0127] That is to say, in this step, based on multimodal learning, a parallel pre-trained language model network is constructed so that the features of the two modal data of Chinese text and Pinyin are extracted simultaneously and directly. The network is composed of two pre-trained language models in parallel, which process Chinese text and Pinyin data respectively. In particular, the two pre-trained language models can be ordinary, lightweight language models, or large language models. The two pre-trained language models can adopt the same or similar structure, or different or dissimilar structures. They each accept text or Pinyin sequence as input, and output high-dimensional features, text features and Pinyin features respectively.

[0128] In step 104, the Chinese character features and the pinyin features of each of the characters to be detected are fused.

[0129] In this step, firstly, the Chinese character features and pinyin features of each of the characters to be detected are transposed and outer product calculated to obtain preliminary fusion features.

[0130] Specifically, in this step, in one embodiment, the Chinese character features of each of the characters to be detected may be subjected to matrix transposition to obtain the Chinese character features after matrix transposition; the Chinese character features after matrix transposition are multiplied with the corresponding pinyin features to obtain preliminary fusion features, as shown in the following formula:

[0131]

[0132] Among them, F c represents the initial fusion feature, that is, the feature after initial fusion, represents the text features after matrix transposition, F pinyin Represents phonetic features.

[0133] In another embodiment, the pinyin features of each of the characters to be detected may be subjected to matrix transposition to obtain the pinyin features after matrix transposition; the pinyin features after matrix transposition are multiplied by the corresponding Chinese character features to obtain preliminary fusion features, as shown in the following formula:

[0134]

[0135] in, represents the pinyin features after matrix transposition, F wenzi Represents text features.

[0136] Secondly, the attention mechanism is used to determine the weights of the Chinese character features and the weights of the pinyin features.

[0137] In this step, the process of using the attention mechanism to determine the weight of the Chinese character features includes:

[0138] First, the outer product of the Chinese text features and the Chinese text features after matrix transposition is calculated; the outer product is superimposed on the preliminary fusion features to form a dual-channel Chinese text feature; then, convolution and pooling calculations are performed on the dual-channel Chinese text features to obtain the weight range of the Chinese text features; and the activation function sigmoid is used to map the weight range of the Chinese text features to 0 to 1.

[0139] In this step, the process of using the attention mechanism to determine the weight of the pinyin feature includes:

[0140] First, the outer product of the pinyin feature and the pinyin feature after the matrix transposition is calculated; the outer product is superimposed on the preliminary fusion feature to form a dual-channel pinyin feature; then, the dual-channel pinyin feature is convolved and pooled to obtain the weight range of the pinyin feature; the activation function sigmoid is used to map the weight range of the pinyin feature to 0 to 1.

[0141] That is to say, in this step, in order to further extract high-level features, suppress noise, and balance the weights of the above two features (Chinese and Pinyin), the attention mechanism is used to calculate the weights of the two features:

[0142]

[0143]

[0144] where a pinyin , a hanwen are the weights of pinyin features and text features respectively.

[0145] Below is a pinyin Take the calculation of as an example, first, calculate the transposed pinyin feature and phonetic feature F pinyin The outer product of the initial fusion feature F c Superimpose to form a dual-channel feature. pinyin It is used for convolution and pooling calculations, and then the activation function (sigmoid) is used to limit the range of weights to 0 to 1. Among them, Sigmoid is often used as an activation function of neural networks to map variables between 0 and 1.

[0146] Again, the weight of the Chinese character feature is weighted with the corresponding Chinese character feature, and the weight of the pinyin feature is weighted with the corresponding pinyin feature, as shown in the following formula:

[0147] F = a pinyin F pinyin +a wenzi F wenzi

[0148] Among them, F represents the final fused feature, and the pinyin feature weight a pinyin and phonetic feature F pinyin Perform dot multiplication calculation, text feature weight a wenzi and text feature F wenzi Perform dot product calculation.

[0149] Finally, the weighted results of the Chinese character features and the weighted results of the pinyin features are superimposed to obtain the final fusion features.

[0150] This step is to superimpose the results of the two dot product calculations to form a dual-channel final fusion feature F.

[0151] In this step, the fusion of feature calculations is utilized, through calculations such as feature transposition, outer product and addition, which not only combines the contextual information within the modality, but also pays attention to the difference information between the modalities, and obtains the dynamic weights of different modal data. While fusing the features of Chinese characters and pinyin, it can also reduce the interference of redundant features and improve the final offensiveness detection efficiency.

[0152] In step 105, the fused features of each to-be-detected text and the corresponding binary classification labels are iteratively trained based on the classification network in the Chinese offensive detection model, and the Chinese offensive detection model when the loss function of the classification network reaches a stable value is used as the trained Chinese offensive detection model.

[0153] In this step, offensiveness detection is performed on the fused features of each to-be-detected text based on the classification network in the Chinese offensiveness detection model; iterative training is performed based on the detection result of offensiveness detection and the binary classification label of whether the to-be-detected text is offensive. During the iterative training process, the detection result is compared with the binary classification label, and the difference in the comparison is used as the classification loss function of the classification network. Based on the classification loss function, the parameters of the classification network are adjusted through the back propagation mechanism until the Chinese offensiveness detection model obtained when the loss function reaches a stable value is used as the trained Chinese offensiveness detection model.

[0154] Among them, in this step, the classification network can be composed of several convolutional layers, pooling layers and full connections, so that the function of feature screening and offensive detection can be automatically completed. The input of the classification network training is the final fusion feature F, and it is iteratively trained in combination with the binary classification label of whether the text to be detected is offensive. The training process jointly updates the parameters of the Chinese offensive detection model through a specific loss function and optimization algorithm. Among them, the cross entropy loss function, the binary cross entropy loss function or the mean square error loss function can be used as the loss function. Newton's method, SGD, AdaGrad or Adam can be used as the optimization algorithm. However, in practical applications, it is not limited to this, and other loss functions and optimization algorithms can also be used.

[0155] The following is an example of the binary cross entropy loss function and the Adamu optimization algorithm. Adam is a first-order optimization algorithm that can replace the traditional stochastic gradient descent process. It can iteratively update the weights of the neural network based on the training data:

[0156]

[0157] Among them, N represents the number of samples, y i represents the label of sample i, offensive ones are marked as positive class 1, and inoffensive ones are marked as negative class 0, p i It represents the probability that sample i is predicted to be a positive class.

[0158] In an embodiment of the present invention, a training data set is obtained, wherein each piece of data in the training data set includes: a piece of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive; a conversion rule from Chinese pinyin to a language model word vector is established on a pre-trained language model in a Chinese offensive detection model; based on the conversion rule, the parallel pre-trained language model is used to simultaneously extract Chinese text features and pinyin features of each text to be detected in the training data set; the Chinese text features and pinyin features of each text to be detected are fused; based on the classification network in the Chinese offensive detection model, the fused features of each text to be detected and the corresponding binary classification label are iteratively trained, and the Chinese offensive detection model when the loss function of the classification network reaches a stable value is used as the trained Chinese offensive detection model. That is to say, the embodiment of the present invention constructs a conversion rule from Chinese pinyin to language model word vector based on the training of the Chinese offensiveness detection model, and realizes the feature extraction of Chinese pinyin data directly by the language model; and based on multimodal learning, a parallel pre-trained language model network is proposed, and simultaneous feature extraction of data of two modalities is realized; and the two extracted features are fused, which solves the fusion problem of data features of the two modalities and avoids the influence of redundant features, thereby realizing higher performance of Chinese offensiveness detection, especially weakening the influence of homophonic text on the detection results, thereby improving the training efficiency of the Chinese offensiveness detection model.

[0159] Optionally, in another embodiment, based on the above embodiment, the method may further include: obtaining a verification data set, the verification data set including: a set proportion of homophonic texts in the characters to be detected, and binary classification labels of whether all the characters to be detected are offensive; inputting all the characters to be detected in the verification data set and the corresponding binary classification labels of whether the characters to be detected are offensive into the trained Chinese offensive detection model for verification testing, and obtaining test performance indicators of the Chinese offensive detection model, the test performance indicators including: accuracy, precision and recall.

[0160] In this embodiment, a verification data set is first obtained, and the acquisition method is similar to the process of obtaining the training data set. The difference is that there is no homophonic annotation in the training data set or only weak homophonic annotation in the training data set, while the verification data set includes a data set with a certain amount of unknown homophonic. The data set should include a sufficient amount of data, and each piece of data should contain at least one paragraph of text to be detected and a binary classification label of whether the text to be detected is offensive. In other words, the verification data set includes data with a certain proportion of homophonic texts in the text to be detected, which can be homophonic texts in the text to be detected itself, or homophonic texts generated by method conversion, etc., which are not limited in this embodiment.

[0161] That is to say, in this embodiment, after the training data set is used to train the Chinese offensive detection model, the accuracy of the trained Chinese offensive detection model can be further tested using the verification data set, which can be specifically explained by taking accuracy, precision and recall as examples.

[0162] Its accuracy can be determined by the following formula:

[0163]

[0164] The accuracy can be determined by the following formula:

[0165]

[0166] The recall rate can be determined by the following formula:

[0167]

[0168] Among them, based on the above formula, TP is the number of positive classes predicted as positive classes, TN is the number of negative classes predicted as negative classes, FP is the number of negative classes predicted as positive classes, and FN is the number of positive classes predicted as negative classes. Among them, accuracy, precision, and recall are the main indicators for verifying the Chinese offensiveness detection model.

[0169] The embodiment of the present invention verifies the accuracy of the trained Chinese offensive detection model, so that the Chinese offensive detection model can be easily deployed on a specific platform to achieve functions such as not limited to Chinese offensive detection, Chinese offensive text shielding and modification, etc.

[0170] The present invention implements a data set construction method through a training data set without homophonic data and a verification data set with homophonic data, laying a foundation for the training and verification of a Chinese offensive detection model; constructs a conversion rule from Chinese pinyin to a language model word vector on a pre-trained language model, which helps the language model to directly extract Chinese pinyin features; constructs a parallel pre-trained language model network, and realizes the parallel and simultaneous extraction of features of two modal data, namely, Chinese characters and pinyin; and performs a fusion scheme for the features of the two modal data, and realizes efficient fusion of the two modal data by calculating dynamic weights, avoiding the interference of redundant features, fully combining the pinyin features of Chinese characters, and having a strong ability to resist homophonic interference without the support of a sensitive word library, and having high detection efficiency.

[0171] See also Figure 2 , is a flow chart of a method for detecting offensive Chinese characters provided by an embodiment of the present invention, the method comprising:

[0172] Step 201: Obtain a piece of text to be detected;

[0173] Step 202: Perform Chinese offensiveness detection on the text to be detected based on the Chinese offensiveness detection model to obtain a Chinese offensiveness detection result, wherein the Chinese offensiveness detection model is based on a conversion rule from Chinese pinyin to a language model word vector, and uses a parallel pre-trained language model to extract Chinese text features and pinyin features of each text to be detected in a training data set, and fuse the extracted Chinese text features and pinyin features, and iteratively train the fused features with the corresponding binary classification labels of the text to be detected.

[0174] The Chinese offensiveness detection model in this embodiment is detailed in the trained Chinese offensiveness detection model in the above embodiment, which will not be described in detail here.

[0175] This application uses the Chinese offensive detection model to directly perform Chinese offensive detection on the text to be detected, and realizes the direct extraction of Chinese pinyin features by the Chinese offensive detection model. Compared with Chinese text features, Chinese pinyin features have higher sensitivity when processing common homophonic texts. Therefore, this embodiment adds an algorithm for Chinese pinyin features, which can more accurately detect offensive texts hidden in homophonic texts, improve the adaptability and accuracy of the model in a complex Chinese environment; can simultaneously extract features of different modes of the same language, thereby playing an important role in multimodal data processing. The network structure of the model can simultaneously process data of different modes, not limited to different representation methods, different encoding methods, etc., to obtain a more comprehensive and accurate feature representation. The parallel pre-trained network structure also has good scalability and adaptability. According to specific needs, sub-networks of different modes can be flexibly added or replaced to adapt to different application scenarios and data types; it can fuse features from parallel pre-trained language model networks, and play an important role in multimodal data processing. The collaborative fusion classification network obtains dynamic weights through methods such as transposition calculation and convolution calculation, reducing the influence of redundant features on the final classification results, thereby improving classification performance.

[0176] It should be noted that, for the method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that this implementation disclosure is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the present invention.

[0177] Please also refer to Figure 3 , which is an application example diagram of a Chinese offensiveness detection method provided by the present invention. This embodiment can weaken the influence of homophonic sounds and specifically includes the following steps:

[0178] Step 301: Construct a data set: Use COLDataset as the initial data set. COLDataset contains 31,049 pieces of data. Each piece of data contains a piece of text to be detected, a binary label to determine whether the text to be detected is offensive, and a category identifier for the text to be detected. The category identifier includes gender, region, and race. 25,726 pieces of data are randomly and evenly selected to form the training set COLDataset-T, and 5,323 pieces of data are used to form the homophonic validation set COLDataset-V. In particular, 2,661 pieces of data are randomly and evenly selected from the validation set COLDataset-V for homophonic text processing. Homophonic text processing refers to randomly selecting 1 to 3 characters in the text to be detected and replacing them with homophonic text.

[0179] Step 302: Construct the conversion rules from Chinese pinyin to word vectors based on the pre-trained language model.

[0180] Taking the BERT model as an example, the characters on the BERT model are one-to-one corresponding, so the BERT character sequence (Table 1), special character sequence (Table 2) and pinyin sequence (Table 3) are enumerated to build the pinyin dictionary vocab_pinyin.txt, which can also be called a language dictionary. The conversion of Chinese pinyin to word vectors on the BERT model is realized. After the Chinese pinyin is converted to the word vector, the data features of the Chinese pinyin can be directly extracted using BERT.

[0181] Table 1

[0182] [PAD] [UNK] [CLS] [SEP] [MASK]

[0183] Table 2

[0184]

[0185]

[0186]

[0187]

[0188] Table 3

[0189]

[0190]

[0191]

[0192] Step 303: Based on multimodal learning, a parallel pre-trained language model network is constructed. Taking the BERT language model as an example, two BERT language models are used and combined in parallel to form a feature extraction network. During network training, the input is the text to be detected and the binary classification label corresponding to the text. The text to be detected is first converted into pinyin without tone, and the text and pinyin are respectively converted into two inputs that conform to the BERT model using the corresponding dictionary; the two branches simultaneously extract features from the text and pinyin inputs to obtain the text feature F wenzi and phonetic feature F pinyin , see above for details.

[0193] Step 304: Input the extracted features into the collaborative fusion classification network for further fusion and classification.

[0194] Specifically, first, perform partial transposition and outer product calculation on the obtained features to obtain preliminary fusion features:

[0195]

[0196] Among them, F c represents the features after preliminary fusion, represents the text features after matrix transposition, F pinyin In particular, F c In the present invention, it can also be equivalently expressed as:

[0197]

[0198] in represents the pinyin features after matrix transposition, F wenzi Represents text features.

[0199] Secondly, in order to further extract high-level features, suppress noise, and balance the weights of the above two features, the attention mechanism is used to calculate the weights of the two features:

[0200]

[0201]

[0202] Among them, a pinyin , a hanzi are the weights of pinyin features and text features, respectively. pinyin As an example, first calculate the transposed pinyin features and phonetic feature F pinyin The outer product of and the initial fusion feature F c Superimpose to form a dual-channel feature. pinyinIt is used for convolution and pooling calculations, and then the sigmoid function is used to limit the range of weights to 0 to 1. Among them, the sigmoid function is often used as an activation function of a neural network to map variables between 0 and 1.

[0203] Again, apply the above weights to the original features:

[0204] F = a pinyin F pinyin +a wenzi F wenzi

[0205] Where F represents the final fused feature, and the pinyin feature weight a pinyin and phonetic feature F pinyin Perform dot multiplication calculation, text feature weight a wenzi and text feature F wenzi Perform a dot product calculation and superimpose the results of the two dot product calculations to form a dual-channel final fusion feature F.

[0206] Finally, as a preferred method, the classification network consists of a convolution layer with a convolution kernel size of 2*1, a step size of 2*1, and an input and output dimension of 1, an activation layer, and a fully connected layer with an input node of 768 and an output node of 2; the input of the classification network training is the final fusion feature F, combined with the binary classification label of whether the text to be detected is offensive; Adam is used to jointly update the parameters of the classification network and the multimodal feature extraction network; the cross entropy loss function is used as the classification loss function of the network:

[0207]

[0208] Among them, N represents the number of samples, y i represents the label of sample i, the positive class is 1, the negative class is 0, and p i It represents the probability that sample i is predicted to be a positive class.

[0209] The model was trained using the COLDataset-T dataset until the loss function no longer decreased, and a Chinese offensiveness detection method that weakened the influence of homophony was tested using the COLDataset-V dataset. Preferably, the accuracy Acc, precision Pre, and recall Pec were used as the standards for training and testing performance. The specific calculation formulas for the accuracy Acc, precision Pre, and recall Pec are detailed above and will not be repeated here.

[0210] Finally, after calculation, the accuracy rate was 86.3%, the precision rate was 98.3%, and the recall rate was 73.7% on the training set, and the accuracy rate was 81.9%, the precision rate was 72.8%, and the recall rate was 86.8% on the validation set. As shown in Table 4, compared with the detection using only Chinese characters and pinyin, each indicator performed better.

[0211] Table 4

[0212]

[0213] The present invention provides a conversion rule from Chinese Pinyin to language model word vector, which can realize the direct extraction of Chinese Pinyin features by mainstream language models. Compared with Chinese text features, Chinese Pinyin features have higher sensitivity when processing common homophonic texts. Therefore, the algorithm model with Chinese Pinyin features can more accurately detect offensive texts hidden in homophonic texts, and improve the adaptability and accuracy of the algorithm model in complex Chinese environments.

[0214] The present invention provides a parallel pre-trained language model network structure, which makes it possible to extract features of different modes of the same language at the same time, thereby playing an important role in multimodal data processing. The network structure can simultaneously process data of different modes, not limited to different representation methods, different encoding methods, etc., to obtain a more comprehensive and accurate feature representation. The parallel pre-trained network structure also has good scalability and adaptability, and is not only suitable for ordinary, lightweight language models, but also for large language models. According to specific needs, sub-networks of different modes can be flexibly added or replaced to adapt to different application scenarios and data types.

[0215] The present invention provides a fusion scheme using feature calculation, which can fuse features from parallel pre-trained language model networks and play an important role in multimodal data processing. Dynamic weights are obtained by using transposition calculation, convolution calculation and other methods in the fusion scheme, which reduces the influence of redundant features on the final classification results, thereby improving classification performance.

[0216] Figure 4 is a block diagram of a training device for a Chinese offensive detection model provided by an embodiment of the present invention. Figure 4 The device includes: a first acquisition module 401, a building module 402, an extraction module 403, a fusion module 404 and a training module 405, wherein:

[0217] The first acquisition module 401 is used to acquire a training data set, where each piece of data in the training data set includes: a piece of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive;

[0218] Establishing module 402, for establishing a conversion rule from Chinese pinyin to a language model word vector on the pre-trained language model in the Chinese offensiveness detection model;

[0219] An extraction module 403 is used to extract Chinese character features and pinyin features of each to-be-detected character in the training data set simultaneously based on the conversion rule and using the parallel pre-trained language model;

[0220] A fusion module 404 is used to fuse the Chinese character features and the pinyin features of each of the characters to be detected;

[0221] The training module 405 is used to iteratively train the fused features of each to-be-detected text and the corresponding binary classification labels based on the classification network in the Chinese offensive detection model, and use the Chinese offensive detection model when the loss function of the classification network reaches a stable value as the trained Chinese offensive detection model.

[0222] Optionally, the establishment module 402 includes: a pinyin sequence acquisition module 501, a character sequence acquisition module 502, and a pinyin conversion module 503, and its structure block diagram is as follows: Figure 5 As shown,

[0223] The pinyin sequence acquisition module 501 is used to acquire the pinyins that constitute Chinese characters without tones to form a pinyin sequence;

[0224] The character sequence acquisition module 502 is used to acquire the symbols and serial numbers commonly used in Chinese expressions to form a character sequence;

[0225] The pinyin conversion module 503 is used to convert the pinyin sequence and the character sequence into a corresponding language dictionary according to the mapping rule of the language model, and the language dictionary is used as the conversion rule from Chinese pinyin to the language model word vector.

[0226] Optionally, the extraction module includes: a first conversion module, a second conversion module, and a feature extraction module, wherein:

[0227] A first conversion module, used for converting each to-be-detected text in the training data set into pinyin without tone;

[0228] A second conversion module is used to convert each of the characters to be detected and the corresponding pinyin respectively based on the conversion rule to obtain the converted characters to be detected and the pinyin;

[0229] The feature extraction module is used to take the converted characters and pinyin to be detected as two branches and simultaneously input them into a parallel pre-trained language model for feature extraction to obtain corresponding Chinese character features and pinyin features.

[0230] Optionally, the fusion module includes:

[0231] A feature determination module, used for performing transposition and outer product calculation on the Chinese character features and pinyin features of each of the characters to be detected to obtain preliminary fusion features;

[0232] A weight determination module, used to determine the weight of the Chinese character feature and the weight of the pinyin feature by using an attention mechanism;

[0233] A weighting module, used for weighting the Chinese character feature with the corresponding Chinese character feature, and for weighting the phonetic feature with the corresponding phonetic feature;

[0234] The superposition module is used to superimpose the weighted result of the Chinese character feature and the weighted result of the pinyin feature to obtain a final fusion feature.

[0235] Optionally, the feature determination module includes: a first transposition module and a first calculation module; and / or, a second transposition module and a second calculation module;

[0236] The first transposition module is used to perform matrix transposition on the Chinese character features of each of the characters to be detected to obtain the Chinese character features after matrix transposition;

[0237] The first calculation module is used to multiply the Chinese character features after the matrix transposition by the corresponding pinyin features to obtain preliminary fusion features; or

[0238] The second transposition module is used to perform matrix transposition on the phonetic features of each of the characters to be detected to obtain the phonetic features after matrix transposition;

[0239] The second calculation module is used to multiply the pinyin features after the matrix transposition by the corresponding Chinese character features to obtain preliminary fusion features.

[0240] Optionally, the weight determination module includes:

[0241] A first outer product calculation module, used to calculate the outer product of the Chinese character features after matrix transposition and the Chinese character features;

[0242] A first feature superposition module, used for superimposing the outer product with the preliminary fusion feature to form a dual-channel Chinese character feature;

[0243] A first pooling calculation module is used to perform convolution and pooling calculations on the Chinese character features of the dual channels to obtain a weight range of the Chinese character features;

[0244] A first mapping module is used to map the weight range of the Chinese character feature to 0 to 1 using an activation function sigmoid; and

[0245] The second outer product calculation module is used to calculate the outer product of the phonetic feature and the phonetic feature after the matrix is ​​transposed;

[0246] A second superposition module is used to superimpose the outer product with the preliminary fusion feature to form a dual-channel pinyin feature;

[0247] A second pooling calculation module is used to perform convolution and pooling calculations on the pinyin features of the dual channels to obtain a weight range of the pinyin features;

[0248] The second mapping module is used to map the weight range of the pinyin feature to 0 to 1 using the activation function sigmoid.

[0249] Optionally, the training module includes:

[0250] A detection module, configured to perform offensive detection on the fused features of each of the characters to be detected based on the classification network in the Chinese offensive detection model;

[0251] The iterative training module is used to perform iterative training based on the detection result of offensiveness detection and the binary classification label of whether the text to be detected is offensive. During the iterative training process, the detection result is compared with the binary classification label, and the difference in the comparison is used as the classification loss function of the classification network. Based on the classification loss function, the parameters of the classification network are adjusted through the back propagation mechanism until the Chinese offensiveness detection model obtained when the loss function reaches a stable value is used as the trained Chinese offensiveness detection model.

[0252] Optionally, the device further includes: a second acquisition module 601 and a verification module 602, whose structural block diagram is as follows: Figure 6 As shown,

[0253] The second acquisition module 601 is used to acquire a verification data set, wherein the verification data set includes: a set ratio of homophonic texts in the text to be detected, and a binary classification label of whether all the text to be detected is offensive;

[0254] The verification module 602 is used to input all the characters to be detected in the verification data set and the corresponding binary classification labels of whether the characters to be detected are offensive into the trained Chinese offensive detection model for verification, and obtain the detection performance indicators of the Chinese offensive detection model, and the detection performance indicators include: accuracy, precision and recall.

[0255] See also Figure 7 , is a block diagram of a Chinese offensive detection device provided by an embodiment of the present invention, comprising: an acquisition module 701 and a detection module 702, wherein:

[0256] The acquisition module 701 is used to acquire a piece of text to be detected;

[0257] The detection module 702 is used to perform Chinese offensive detection on the text to be detected based on the Chinese offensive detection model to obtain a Chinese offensive detection result, wherein the Chinese offensive detection model is based on the conversion rule from Chinese pinyin to language model word vector, using a parallel pre-trained language model to extract Chinese text features and pinyin features of each text to be detected in the training data set, and fuse the extracted Chinese text features and pinyin features, and iteratively train the fused features with the corresponding binary classification labels of the text to be detected.

[0258] Optionally, an embodiment of the present invention further provides an electronic device, including:

[0259] processor;

[0260] a memory for storing instructions executable by the processor;

[0261] The processor is configured to execute the instructions to implement the training of the Chinese offensiveness detection model as described above or the Chinese offensiveness detection method as described above.

[0262] Optionally, an embodiment of the present invention further provides a computer-readable storage medium, which, when instructions in the computer-readable storage medium are executed by a processor of an electronic device, enables the electronic device to perform the training of the Chinese offensiveness detection model as described above or the Chinese offensiveness detection method as described above.

[0263] Optionally, an embodiment of the present invention further provides a computer program product, including a computer program or instructions, which, when executed by a processor of an electronic device, implements the training of the Chinese offensiveness detection model as described above or the Chinese offensiveness detection method as described above.

[0264] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0265] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0266] Figure 8 800 is a block diagram of an electronic device 800 provided in an embodiment of the present invention. For example, the electronic device 800 may be a mobile terminal or a server, and the electronic device is a mobile terminal as an example for explanation in the embodiment of the present invention. For example, the electronic device 800 may be a mobile phone, a computer, a digital broadcast terminal, a message transceiver device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0267] Reference Figure 8 , the electronic device 800 may include one or more of the following components: a processing component 802 , a memory 804 , a power component 806 , a multimedia component 808 , an audio component 810 , an input / output (I / O) interface 812 , a sensor component 814 , and a communication component 816 .

[0268] The processing component 802 generally controls the overall operation of the electronic device 800, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 802 may include one or more processors 820 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 802 may include one or more modules to facilitate the interaction between the processing component 802 and other components. For example, the processing component 802 may include a multimedia module to facilitate the interaction between the multimedia component 808 and the processing component 802.

[0269] The memory 804 is configured to store various types of data to support operations on the device 800. Examples of such data include instructions for any application or method operating on the electronic device 800, contact data, phone book data, messages, pictures, videos, etc. The memory 804 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0270] The power supply component 806 provides power to the various components of the electronic device 800. The power supply component 806 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 800.

[0271] The multimedia component 808 includes a screen that provides an output interface between the electronic device 800 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front camera and / or a rear camera. When the device 800 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and the rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0272] The audio component 810 is configured to output and / or input audio signals. For example, the audio component 810 includes a microphone (MIC), and when the electronic device 800 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 804 or sent via the communication component 816. In some embodiments, the audio component 810 also includes a speaker for outputting audio signals.

[0273] I / O interface 812 provides an interface between processing component 802 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: home button, volume button, start button, and lock button.

[0274] The sensor assembly 814 includes one or more sensors for providing various aspects of status assessment for the electronic device 800. For example, the sensor assembly 814 can detect the open / closed state of the device 800, the relative positioning of components, such as the display and keypad of the electronic device 800, and the sensor assembly 814 can also detect the position change of the electronic device 800 or a component of the electronic device 800, the presence or absence of contact between the user and the electronic device 800, the orientation or acceleration / deceleration of the electronic device 800, and the temperature change of the electronic device 800. The sensor assembly 814 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 814 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0275] The communication component 816 is configured to facilitate wired or wireless communication between the electronic device 800 and other devices. The electronic device 800 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 816 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0276] In an embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the training of the Chinese offensiveness detection model shown above or the Chinese offensiveness detection method as described above.

[0277] In an embodiment, a computer-readable storage medium is also provided. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device 800 can perform the training of the Chinese offensiveness detection model described above or the Chinese offensiveness detection method described above. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0278] In an embodiment, a computer program product is also provided, including a computer program or instructions. When the computer program or instructions are executed by the processor 820 of the electronic device 800, the electronic device 800 executes the training of the Chinese offensiveness detection model described above or the Chinese offensiveness detection method described above.

[0279] Fig. 9 900 is a block diagram of a device 900 for training a Chinese offensiveness detection model or detecting Chinese offensiveness provided by an embodiment of the present invention. For example, the device 900 may be provided as a server. Fig. 9, the apparatus 900 includes a processing component 922, which further includes one or more processors, and a memory resource represented by a memory 932 for storing instructions, such as an application, that can be executed by the processing component 922. The application stored in the memory 932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 922 is configured to execute the instructions to perform the above method.

[0280] The device 900 may also include a power supply component 926 configured to perform power management of the device 900, a wired or wireless network interface 950 configured to connect the device 900 to a network, and an input / output (I / O) interface 958. The device 900 may operate based on an operating system stored in the memory 932, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, or the like.

[0281] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art that are not disclosed by the present invention. The specification and examples are to be considered exemplary only, and the true scope and spirit of the present invention are indicated by the following claims.

[0282] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

Claims

1. A training method for a Chinese offensive detection model, characterized in that: include: Acquire a training data set, where each piece of data in the training data set includes: a piece of text to be detected without homophonic annotation or with weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive; Based on the pre-trained language model in the Chinese offensive detection model, establish the conversion rules from Chinese pinyin to language model word vectors; Based on the conversion rule, using the parallel pre-trained language model, simultaneously extracting Chinese character features and pinyin features of each to-be-detected character in the training data set; Fusion of Chinese character features and Pinyin features of each of the characters to be detected; Based on the classification network in the Chinese offensive detection model, the fused features of each to-be-detected text and the corresponding binary classification labels are iteratively trained, and the Chinese offensive detection model when the loss function of the classification network reaches a stable value is used as the trained Chinese offensive detection model.

2. The training method of the Chinese offensive detection model according to claim 1, characterized in that: The conversion rules from Chinese pinyin to language model word vectors are established on the pre-trained language model in the Chinese offensive detection model, including: Obtain the pinyin constituting the Chinese characters excluding the tones to form a pinyin sequence; Get the symbols and serial numbers commonly used in Chinese expressions to form a character sequence; The pinyin sequence and the character sequence are converted into a corresponding language dictionary according to the mapping rule of the language model, and the language dictionary is used as a conversion rule from Chinese pinyin to a language model word vector.

3. The training method of the Chinese offensive detection model according to claim 1, characterized in that: The method of simultaneously extracting Chinese character features and pinyin features of each to-be-detected character in the training data set based on the conversion rule and utilizing the parallel pre-trained language model comprises: Convert each to-be-detected text in the training data set into pinyin without tones; Based on the conversion rule, each of the characters to be detected and the corresponding pinyin are converted to obtain the converted characters to be detected and pinyin; The converted characters and pinyin to be detected are used as two branches and simultaneously input into a parallel pre-trained language model for feature extraction to obtain corresponding Chinese character features and pinyin features.

4. The training method of the Chinese offensive detection model according to claim 1, characterized in that: The fusing of the Chinese character features and the pinyin features of each of the characters to be detected includes: Transpose and calculate the outer product of the Chinese character features and the pinyin features of each of the characters to be detected to obtain preliminary fusion features; Determine the weight of the Chinese character feature and the weight of the pinyin feature by using an attention mechanism; Using the weight of the Chinese character feature and the corresponding Chinese character feature to perform weighting, and using the weight of the Pinyin feature and the corresponding Pinyin feature to perform weighting; The weighted result of the Chinese character feature and the weighted result of the pinyin feature are superimposed to obtain a final fusion feature.

5. The training method of the Chinese offensive detection model according to claim 4, characterized in that: The transposition and outer product calculation of the Chinese character features and the pinyin features of each of the characters to be detected are performed to obtain preliminary fusion features, including: Performing a matrix transposition on the Chinese character features of each of the characters to be detected to obtain a matrix-transposed Chinese character feature; multiplying the matrix-transposed Chinese character feature with the corresponding pinyin feature to obtain a preliminary fusion feature; or Perform matrix transposition on the pinyin features of each of the characters to be detected to obtain the pinyin features after matrix transposition; multiply the pinyin features after matrix transposition with the corresponding Chinese character features to obtain preliminary fusion features.

6. The training method of the Chinese offensive detection model according to claim 4, characterized in that: The method of using the attention mechanism to determine the weight of the Chinese character feature and the weight of the pinyin feature includes: Calculating the outer product of the Chinese character features after the matrix transposition and the Chinese character features; superimposing the outer product with the preliminary fusion features to form a dual-channel Chinese character feature; performing convolution and pooling calculations on the dual-channel Chinese character features to obtain a weight range of the Chinese character features; using an activation function sigmoid to map the weight range of the Chinese character features to 0 to 1; and Calculate the outer product of the pinyin feature and the pinyin feature after the matrix transposition; superimpose the outer product with the preliminary fusion feature to form a dual-channel pinyin feature; perform convolution and pooling calculations on the dual-channel pinyin feature to obtain the weight range of the pinyin feature; use the activation function sigmoid to map the weight range of the pinyin feature to 0 to 1.

7. The method for training a Chinese offensive detection model according to claim 1, characterized in that: The classification network in the Chinese offensive detection model is used to iteratively train the fused features of each to-be-detected text and the corresponding binary classification labels, and the Chinese offensive detection model when the loss function of the classification network reaches a stable value is used as the trained Chinese offensive detection model, including: Performing offensive detection on the fused features of each of the to-be-detected texts based on the classification network in the Chinese offensive detection model; Iterative training is performed based on the detection result of offensiveness detection and the binary classification label of whether the text to be detected is offensive. During the iterative training process, the detection result is compared with the binary classification label, and the difference in the comparison is used as the classification loss function of the classification network. Based on the classification loss function, the parameters of the classification network are adjusted through the back propagation mechanism until the loss function reaches a stable value. The Chinese offensiveness detection model obtained is used as the trained Chinese offensiveness detection model.

8. The method for training a Chinese offensive detection model according to any one of claims 1 to 7, characterized in that: The method further comprises: Obtaining a verification data set, the verification data set including: a set ratio of homophonic texts in the text to be detected, and a binary classification label of whether all the text to be detected is offensive; All the characters to be detected in the verification data set and the corresponding binary classification labels of whether the characters to be detected are offensive are input into the trained Chinese offensive detection model for verification testing to obtain the test performance indicators of the Chinese offensive detection model, and the test performance indicators include: accuracy, precision and recall.

9. A method for detecting offensiveness of Chinese characters, characterized in that: include: Get a piece of text to be detected; The Chinese offensiveness detection is performed on the text to be detected based on the Chinese offensiveness detection model to obtain a Chinese offensiveness detection result, wherein the Chinese offensiveness detection model is based on the conversion rule from Chinese pinyin to language model word vector, uses a parallel pre-trained language model, extracts Chinese text features and pinyin features of each text to be detected in the training data set, and fuses the extracted Chinese text features and pinyin features, and iteratively trains the fused features and the corresponding binary classification labels of the text to be detected.

10. A training device for a Chinese offensive detection model, characterized in that: include: A first acquisition module is used to acquire a training data set, where each piece of data in the training data set includes: a section of text to be detected without homophonic annotation or weak homophonic annotation, and a binary classification label of whether the text to be detected is offensive; Establish a module for establishing the conversion rules from Chinese pinyin to language model word vectors based on the pre-trained language model in the Chinese offensive detection model; An extraction module, for simultaneously extracting Chinese character features and pinyin features of each to-be-detected character in the training data set based on the conversion rule and using the parallel pre-trained language model; A fusion module, used for fusing the Chinese character features and the pinyin features of each of the characters to be detected; The training module is used to iteratively train the fused features of each to-be-detected text and the corresponding binary classification labels based on the classification network in the Chinese offensive detection model, and use the Chinese offensive detection model when the loss function of the classification network reaches a stable value as the trained Chinese offensive detection model.

11. A device for detecting offensive Chinese characters, characterized in that: include: An acquisition module is used to acquire a piece of text to be detected; The detection module is used to perform Chinese offensive detection on the text to be detected based on the Chinese offensive detection model to obtain a Chinese offensive detection result, wherein the Chinese offensive detection model is based on the conversion rule from Chinese pinyin to language model word vector, using a parallel pre-trained language model to extract Chinese text features and pinyin features of each text to be detected in the training data set, and fuse the extracted Chinese text features and pinyin features, and iteratively train the fused features with the corresponding binary classification labels of the text to be detected.

12. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the training of the Chinese offensiveness detection model as described in any one of claims 1 to 8 or the Chinese offensiveness detection method as described in claim 9.

13. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform the training of the Chinese offensiveness detection model as described in any one of claims 1 to 8 or the Chinese offensiveness detection method as described in claim 9.