Abuse language detection method, device and storage medium

Through the combination of cross-language comparison loss and multilingual pre-trained models, the problem of language differences in language abuse detection is solved, the detection accuracy and efficiency are improved, and the effective transfer of cross-language knowledge is achieved.

CN116821339BActive Publication Date: 2024-12-06INST OF AUTOMATION CHINESE ACAD OF SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310737400.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-20
Publication Date
2024-12-06
Estimated Expiration
2043-06-20

Smart Images

  • Figure CN116821339B_ABST
    Figure CN116821339B_ABST
Patent Text Reader

Abstract

The present application provides a method, device and storage medium for detecting language abuse. The method includes: inputting a language text to be processed into a language abuse detection model to obtain a category prediction probability of the language text to be processed; the language abuse detection model is trained based on cross-language contrast loss, classification cross entropy loss of the source language text and classification cross entropy loss of the target language text, and the target language text is a parallel translation obtained by translating the source language text. The language abuse detection method, device and storage medium provided in the present application train the language abuse detection model by learning intrinsic relationships from texts in different languages, thereby improving the model's cross-language knowledge transfer capability and the accuracy of language abuse detection results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of natural language processing, and in particular to a method, device and storage medium for detecting language abuse. Background Art

[0002] Due to the linguistic diversity of social media platforms, detecting abusive language in multiple languages ​​is important for maintaining a positive, healthy and harmonious online environment. Abusive Language Detection aims to use natural language processing technology to identify malicious content created by some online users, and can effectively identify and review abusive language in online communities.

[0003] Most existing abusive language detection methods are based on deep learning technology to learn semantic word embedding to handle the complexity of natural language structure, and use pre-trained language models to detect abusive language. This method requires a large amount of annotated data for the target language to train the model, but the existing annotated data for abusive language is scarce. Using existing data resources and existing abusive language detection methods to detect abusive language will result in low accuracy of the abusive language detection results. Summary of the invention

[0004] The embodiments of the present application provide a method, device and storage medium for detecting abuse language, so as to solve the technical problem of low accuracy of detecting abuse language in the prior art.

[0005] In a first aspect, an embodiment of the present application provides a method for detecting abusive language, including:

[0006] Get the language text to be processed;

[0007] The language text to be processed is input into a language abuse detection model to obtain a category prediction probability of the language text to be processed; the language abuse detection model is trained based on the following steps:

[0008] The language abuse detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text.

[0009] In some embodiments, the training of the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text includes:

[0010] The target loss function is obtained by weighted summing the cross-language contrast loss, the categorical cross entropy loss of the source language text, and the categorical cross entropy loss of the target language text.

[0011] The abusive language detection model is trained by minimizing the objective loss function.

[0012] In some embodiments, the objective loss function is expressed as follows:

[0013]

[0014] Among them, Loss represents the target loss function value; λ represents the loss weight parameter; represents the categorical cross entropy loss of the source language text; represents the classification cross entropy loss of the target language text; L XCL represents the cross-lingual contrastive loss.

[0015] In some embodiments, before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes:

[0016] A cross-language contrastive loss is calculated based on the semantic representation of the source language text and the semantic representation of the target language text using a contrastive learning algorithm; the cross-language contrastive loss is used to measure the similarity between the source language text and the target language text.

[0017] In some embodiments, before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes:

[0018] Calculating the category prediction probability of the source language text based on the vector representation of the source language text and the fully connected neural network parameters, and calculating the category prediction probability of the target language text based on the vector representation of the target language text and the fully connected neural network parameters;

[0019] The classification cross entropy loss of the source language text is calculated based on the category prediction probability of the source language text, and the classification cross entropy loss of the target language text is calculated based on the category prediction probability of the target language text.

[0020] In some embodiments, the method further comprises:

[0021] Use machine translation models to translate source language text into target language text;

[0022] The source language text and the target language text are input into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text.

[0023] In some embodiments, the step of inputting the source language text and the target language text into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text includes:

[0024] Inputting the source language text into the multilingual pre-training model for semantic recognition to obtain the semantic representation of each word in the source language text, and inputting the target language text into the multilingual pre-training model for semantic recognition to obtain the semantic representation of each word in the target language text;

[0025] Average pooling is performed on the semantic representation of each word in the source language text to obtain the semantic representation of the source language text, and average pooling is performed on the semantic representation of each word in the target language text to obtain the semantic representation of the target language text.

[0026] In a second aspect, an embodiment of the present application provides a device for detecting language abuse, including:

[0027] An acquisition module, used for acquiring the language text to be processed;

[0028] The detection module is used to input the language text to be processed into an abuse language detection model to obtain the category prediction probability of the language text to be processed; the abuse language detection model is trained based on the following steps:

[0029] The language abuse detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text.

[0030] In a third aspect, an embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for detecting abusive language as described in the first aspect above is implemented.

[0031] In a fourth aspect, an embodiment of the present application further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method for detecting language abuse as described in the first aspect above.

[0032] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program, which, when executed by a processor, implements the method for detecting abusive language as described in the first aspect above.

[0033] The abuse language detection method, device and storage medium provided in the embodiments of the present application obtain the category prediction probability of the language text to be processed by inputting the language text to be processed into the abuse language detection model, and the abuse language detection model is trained based on the following steps: the abuse language detection model is trained by jointly using cross-language contrast loss, classification cross entropy loss of source language text and classification cross entropy loss of target language text, and the target language text is a parallel translation obtained by translating the source language text, and the cross-language knowledge transfer capability of the abuse language detection model is improved by learning the intrinsic relationship from different language texts, so that more accurate detection results can be obtained by using the model for abuse language detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.

[0035] Figure 1 is a flow chart of a method for detecting language abuse provided in an embodiment of the present application;

[0036] Figure 2 is a schematic diagram of an abuse language detection model for an example scenario of an abuse language detection method provided in an embodiment of the present application;

[0037] Figure 3 is a structural diagram of a language abuse detection device provided in an embodiment of the present application;

[0038] Figure 4 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0039] Most of the existing abusive language detection methods are based on deep learning technology to learn semantic word embedding to deal with the complexity of natural language structure. For example, three neural network models, Convolutional Neural Networks (CNN), Long Short-Term Memory (LSTM) and FastText, are used for abusive language detection. With the successful application of the Transformer structure in many downstream tasks in the field of natural language processing, a series of Transformer-based pre-trained language models have been introduced into the field of abusive language detection. For example, by using the grammatical and contextual information embedding in different Transformer encoder layers of the pre-trained language model BERT (Bidirectional Encoder Representation from Transformers) model to capture information at different levels, the performance of the abusive language detection system can be enhanced.

[0040] Due to the linguistic diversity of social media platforms, it is necessary to further detect abusive language in multiple languages. Therefore, based on aligned multilingual word embeddings, many studies have explored abusive language detection in multilingual scenarios. For example, based on deep learning and using multilingual embedding representations such as LASER, MUSE, and mBERT, a wide range of multi-model and multi-scenario evaluations have been conducted on the problem of multilingual abusive language detection.

[0041] However, existing abusive language detection methods require a large amount of annotated data based on the target language to train the model, but the field of abusive language detection faces the problem of scarce language annotated data. Therefore, the existing technology lacks more effective solutions to deal with the semantic differences between different languages, and the performance and reliability of existing abusive language detection methods are insufficient, resulting in low accuracy of abusive language detection.

[0042] Based on the above technical problems, an embodiment of the present application proposes a method for detecting language abuse, by inputting a language text to be processed into an language abuse detection model to obtain a category prediction probability of the language text to be processed, wherein the language abuse detection model is trained based on the following steps: the language abuse detection model is trained jointly by cross-language contrast loss, classification cross entropy loss of source language text, and classification cross entropy loss of target language text, and the cross-language knowledge transfer capability of the language abuse detection model is improved by learning intrinsic relationships from texts of different languages, so that more accurate detection results can be obtained by using the model for language abuse detection.

[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0044] Figure 1 is a flow chart of the method for detecting language abuse provided in an embodiment of the present application, such as Figure 1 As shown, the embodiment of the present application provides a method for detecting abusive language. The method includes:

[0045] Step 101: Obtain language text to be processed.

[0046] Step 102: input the language text to be processed into a language abuse detection model to obtain a category prediction probability of the language text to be processed; the language abuse detection model is trained based on the following steps:

[0047] The language abuse detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text.

[0048] Specifically, in the embodiment of the present application, the language text to be processed is the original language text to be processed. Directly inputting the language text to be processed into the abuse language detection model and outputting the category prediction probability of the language text to be processed can reduce complexity and avoid errors caused by translation, thereby improving the accuracy of abuse language detection.

[0049] Abusive language refers to malicious content created by some online users on social media platforms, for example, speech that attacks the race, ethnicity, gender, orientation, etc. of the target group.

[0050] The abusive language detection model is used to detect or classify abusive language. The input of the model is the language text to be processed, and the output is the category prediction probability of the language text to be processed. The category prediction probability may refer to the probability that the language text to be processed is abusive language, or may further refer to the probability that the language text to be processed is a certain category of abusive language.

[0051] For example, the language text to be processed is input into the abuse language detection model, and the probability value of the language text to be processed being abuse language is output.

[0052] For another example, the language text to be processed is input into the abuse language detection model, and the probability value of the language text to be processed being category A of the abuse language is output, where the categories of the abuse language include four categories: A, B, C and D.

[0053] In an embodiment of the present application, during the training phase of the language abuse detection model, the semantic representation of the source language text and the semantic representation of the target language text are first obtained, and the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text are calculated based on the semantic representation of the source language text and the semantic representation of the target language text. Then, the language abuse detection model is trained based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text.

[0054] The source language text refers to an original training text in a source language, and the target language text refers to a parallel translation obtained by translating the source language text.

[0055] For example, the source language text is translated using a machine translation model to obtain the target language text, and the semantic vector of the source language text and the semantic vector of the target language text are calculated using a pre-trained language model; then the cross-language contrast loss is calculated based on the semantic vector of the source language text and the semantic vector of the target language text using a contrastive learning algorithm; the category prediction probability is calculated based on the semantic vector of the source language text and the semantic vector of the target language text, and the classification cross entropy loss of the corresponding text is calculated based on the category prediction probability; then the cross-language contrast loss and the classification cross entropy loss of the two texts are used to jointly train the abuse language detection model. The language text to be processed is input into the trained abuse language detection model, and the probability that the language text to be processed is a certain category of the abuse language is output.

[0056] For another example, a source language text is translated using a machine translation model to obtain a target language text, and a pre-trained language model is used to calculate the semantic vector of the source language text and the semantic vector of the target language text; then a contrastive learning algorithm is used to calculate the cross-language contrast loss based on the semantic vector of the source language text and the semantic vector of the target language text; a category prediction probability is calculated based on the semantic vector of the source language text and the semantic vector of the target language text, and a classification cross entropy loss of the corresponding text is calculated based on the category prediction probability; then a weighted sum of the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text is obtained, and the abuse language detection model is trained by minimizing the target loss function. The language text to be processed is input into the trained abuse language detection model, and the probability that the language text to be processed is a certain category of the abuse language is output.

[0057] The method for detecting language abuse provided in the embodiment of the present application obtains the category prediction probability of the language text to be processed by inputting the language text to be processed into the language abuse detection model. The language abuse detection model is obtained by joint training based on cross-language contrast loss, classification cross entropy loss of source language text and classification cross entropy loss of target language text, so as to achieve learning of intrinsic relations from different language texts, improve the cross-language knowledge transfer capability of the language abuse detection model, and obtain more accurate detection results for language abuse detection using the model.

[0058] In some embodiments, the method further comprises:

[0059] Use machine translation models to translate source language text into target language text;

[0060] The source language text and the target language text are input into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text.

[0061] Specifically, a machine translation model (transformer) is used to translate the source language text into the target language as an enhancement to the source language text data.

[0062] The machine translation model may be a model such as GNMT, OPUS-MT, or NLLB.

[0063] Specifically, after obtaining the target language text, the source language text and the target language text are input into a multilingual pre-trained language model (PLMs), and the source language text and the target language text are mapped to a shared language representation to generate a semantic representation of the source language text and a semantic representation of the target language text.

[0064] The multilingual pre-training model may be a model such as LASER, mBERT, or XLM.

[0065] For example, for source language text Use machine translation model to translate it into target language text Then the text Input into the mBERT model, the source language text and the target language text share parameters in the encoder module of the mBERT model to obtain the semantic representation of the source language text and the semantic representation of the target language text

[0066] For another example, for the source language text Use machine translation model to translate it into target language text Then the text Input into the XLM model, the source language text and the target language text share parameters in the encoder module of the XLM model to obtain the semantic representation of the source language text and the semantic representation of the target language text

[0067] The method for detecting language abuse provided in the embodiment of the present application uses a machine translation model to enhance the source language text and obtain a parallel translation of the source language text, so that the information in the source language text is retained as much as possible during the translation process, and the translation error is reduced. The language abuse detection model is trained in parallel with the source language text and the target language text, thereby improving the accuracy of the model in detecting language abuse. The semantic representation of the source language text and the semantic representation of the target language text are generated using a multilingual pre-training model. Since the multilingual pre-training model learns the commonalities and differences between multiple languages, the multilingual pre-training model can map input texts from different languages ​​to a shared language representation, and then perform unified processing and prediction to adapt to natural language processing tasks in multiple languages, thereby improving the multilingual detection and cross-language knowledge transfer capabilities of the language abuse detection model, and improving the accuracy and efficiency of language abuse detection.

[0068] In some embodiments, the step of inputting the source language text and the target language text into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text includes:

[0069] Inputting the source language text into the multilingual pre-training model for semantic recognition to obtain the semantic representation of each word in the source language text, and inputting the target language text into the multilingual pre-training model for semantic recognition to obtain the semantic representation of each word in the target language text;

[0070] Average pooling is performed on the semantic representation of each word in the source language text to obtain the semantic representation of the source language text, and average pooling is performed on the semantic representation of each word in the target language text to obtain the semantic representation of the target language text.

[0071] Specifically, in the multilingual pre-training model, semantic recognition is performed on the source language text, and different levels of information are captured through the grammatical and contextual information in the source language text to obtain word-level semantic representation in the source language text, that is, the semantic representation of each word in the source language text; at the same time, semantic recognition is performed on the target language text, and different levels of information are captured through the grammatical and contextual information in the target language text to obtain word-level semantic representation in the target language text, that is, the semantic representation of each word in the target language text.

[0072] Then, the word-level semantic representation in the source language text and the word-level semantic representation in the target language text are average pooled respectively to obtain the semantic representation of the source language text and the semantic representation of the target language text.

[0073] For example, Figure 2 is a schematic diagram of an abuse language detection model for an example scenario of an abuse language detection method provided in an embodiment of the present application, such as Figure 2 As shown, for the source language text Use machine translation model to translate it into target language text Then the text Input a multilingual pre-trained model such as the XLM model to generate a series of word-level semantic representations, and average pool the word-level semantic representations corresponding to the source language text to obtain the semantic representation vector of the source language text. The word-level semantic representation corresponding to the target language text is averaged and pooled to obtain the semantic representation vector of the target language text. and The expressions are:

[0074]

[0075]

[0076] in, is the semantic representation vector of the i-th source language text; is the semantic representation vector of the i-th target language text; AveragePool is the average pooling operation; XLM is the operation of generating word-level semantic representation based on the XLM model; is the i-th source language text; is the i-th target language text.

[0077] The method for detecting language abuse provided in the embodiment of the present application utilizes a multilingual pre-trained model to extract the semantic representation of each word in the source language text and the semantic representation of each word in the target language text, and then obtains the semantic representation of the source language text and the semantic representation of the target language text through average pooling, so that words in different languages ​​can be mapped to the same semantic space, so as to share knowledge between different languages, improve the multilingual detection and cross-language knowledge transfer capabilities of the language abuse detection model, and thus improve the accuracy and efficiency of language abuse detection.

[0078] In some embodiments, before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes:

[0079] A cross-language contrastive loss is calculated based on the semantic representation of the source language text and the semantic representation of the target language text using a contrastive learning algorithm; the cross-language contrastive loss is used to measure the similarity between the source language text and the target language text.

[0080] Specifically, a contrastive learning algorithm is used to calculate the cross-language contrastive loss based on the semantic representation of the source language text and the semantic representation of the target language text. First, the cosine similarity of the semantic representation of the source language text and the semantic representation of the target language text is calculated, and then the cross-language contrastive loss is calculated based on the cosine similarity.

[0081] The cross-language contrast loss is used to measure the similarity between the source language text and the target language text. The smaller the cross-language contrast loss is, the higher the similarity between the source language text and the target language text is.

[0082] For example, Figure 2 As shown in Figure 1, after obtaining the semantic representation of the source language text and the semantic representation of the target language text through the multilingual pre-training model, it is necessary to obtain the cross-language contrast loss through cross-language contrast learning. Assuming that a training batch contains N training samples, after data augmentation, the batch of training samples consisting of the source language text and the target language text can be expressed as The model converts each pair Consider it as a positive pair and use contrastive learning to make its corresponding vector representation As similar as possible. The cross-lingual contrast loss is calculated as follows:

[0083]

[0084]

[0085] Among them, L XCL is the cross-language contrast loss; N is the number of training samples in a batch; for and The cosine similarity of ; τ is an adjustable scaling parameter; is the semantic representation vector of the i-th source language text; is the semantic representation vector of the i-th target language text; is the semantic representation vector of the jth source language text; is the semantic representation vector of the jth target language text.

[0086] The method for detecting abusive language provided in the embodiment of the present application uses a contrastive learning algorithm to optimize the semantic representation of the source language text and the semantic representation of the target language text, and maps the source language and target language representations into the same vector space, thereby improving cross-language semantic consistency and generalization capabilities, making it possible to build a high-performance abusive language detection model in the absence of target language data, thereby improving the accuracy of abusive language detection.

[0087] In some embodiments, before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes:

[0088] Calculating the category prediction probability of the source language text based on the vector representation of the source language text and the fully connected neural network parameters, and calculating the category prediction probability of the target language text based on the vector representation of the target language text and the fully connected neural network parameters;

[0089] The classification cross entropy loss of the source language text is calculated based on the category prediction probability of the source language text, and the classification cross entropy loss of the target language text is calculated based on the category prediction probability of the target language text.

[0090] Specifically, in an embodiment of the present application, a two-layer fully connected neural network is used to map the vector representation of the source language text and the vector representation of the target language text to the sample label space to construct a classifier, and the source language text and the target language text share the fully connected neural network parameters.

[0091] First, the category prediction probability of the source language text, that is, the predicted label of the source language text, is calculated based on the vector representation of the source language text and the fully connected neural network parameters, and the category prediction probability of the target language text, that is, the predicted label of the target language text, is calculated based on the vector representation of the target language text and the fully connected neural network parameters. Then, the classification cross entropy loss of the source language text is calculated based on the category prediction probability of the source language text, and the classification cross entropy loss of the target language text is calculated based on the category prediction probability of the target language text.

[0092] For example, Figure 2 As shown in Figure 1, after obtaining the vector representation of the source language text and the vector representation of the target language text, a fully connected neural network is used to calculate the category prediction probability of the text and the corresponding classification cross entropy loss. and target language text The shared fully connected neural network parameters are used to calculate their category prediction probabilities respectively. The calculation formulas for the category prediction probabilities of the source language text and the target language text are:

[0093]

[0094]

[0095] in, is the category prediction probability of the i-th source language text; is the category prediction probability of the i-th target language text; is the semantic representation vector of the i-th source language text; is the semantic representation vector of the i-th target language text; W 1 、b 1 , W 2 and b 2 are the parameters of the fully connected neural network; Relu and Softmax are activation functions.

[0096] Assuming that a training batch contains N training samples, the classification cross entropy loss of the source language text is calculated based on the category prediction probability of the source language text, and the classification cross entropy loss of the target language text is calculated based on the category prediction probability of the target language text. The calculation formulas for the classification cross entropy loss of the source language text and the classification cross entropy loss of the target language text are respectively:

[0097]

[0098]

[0099] in, is the categorical cross entropy loss of the source language text; is the classification cross entropy loss of the target language text; N is the number of training samples; C is the number of categories to be classified; y i,j is the actual probability that the i-th training sample belongs to the j-th category; The predicted probability that the i-th source language text belongs to the j-th category; The predicted probability that the i-th target language text belongs to the j-th category.

[0100] The method for detecting language abuse provided in the embodiment of the present application uses shared neural network parameters to calculate the category prediction probability of the source language text and the category prediction probability of the target language text, thereby improving the performance and generalization ability of the language abuse detection model.

[0101] In some embodiments, the training of the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text includes:

[0102] The target loss function is obtained by weighted summing the cross-language contrast loss, the categorical cross entropy loss of the source language text, and the categorical cross entropy loss of the target language text.

[0103] The abusive language detection model is trained by minimizing the objective loss function.

[0104] Specifically, the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text are weightedly summed to obtain the target loss function, and the language abuse detection model is jointly trained by minimizing the target loss function.

[0105] For example, a is assigned to the cross-language contrast loss, b is assigned to the classification cross entropy loss of the source language text, and c is assigned to the classification cross entropy loss of the target language text, where the sum of a, b, and c is 1. The three losses are weighted and summed based on the assigned weights to obtain the final target loss function. The language abuse detection model is trained with the goal of minimizing the target loss function.

[0106] For another example, the cross-language contrast loss and the classification cross entropy loss of the source language text are both assigned a weight value of a, and the classification cross entropy loss of the target language text is assigned a weight value of 1-2a. The three losses are weighted and summed based on the assigned weights to obtain the final target loss function. The language abuse detection model is trained with the goal of minimizing the target loss function.

[0107] The method for detecting language abuse provided in the embodiment of the present application obtains a target loss function by weighted summing up the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text. The language abuse detection model is trained based on the target loss function, so that the influence of different factors on the training of the language abuse detection model can be reasonably controlled, and the language abuse detection capability and cross-language knowledge transfer capability of the language abuse detection model are improved, thereby improving the accuracy of language abuse detection.

[0108] In some embodiments, the objective loss function is expressed as follows:

[0109]

[0110] Among them, Loss represents the target loss function value; λ represents the loss weight parameter; represents the categorical cross entropy loss of the source language text; represents the classification cross entropy loss of the target language text; L XCL represents the cross-lingual contrastive loss.

[0111] Specifically, Figure 2As shown in the figure, after obtaining the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the abuse language detection model is jointly trained. First, the cross-language contrast loss and the classification cross entropy loss of the source language text are both assigned weights of The classification cross entropy loss of the target language text is assigned a weight value of λ, and the three losses are weightedly summed based on the weight to obtain the target loss function Loss, and the abuse language detection model is trained by minimizing Loss.

[0112] The method for detecting language abuse provided in the embodiment of the present application adopts cross-language transfer learning (including multi-language word embedding, shared neural network architecture, transfer learning strategy and other methods) to share models and knowledge between different languages ​​to accelerate the learning process in the target language and improve the generalization ability of the model. It can be applied to various language abuse detection scenarios, has the ability of multi-language detection and cross-language knowledge transfer, and improves the accuracy and efficiency of language abuse detection.

[0113] Figure 3 is a schematic diagram of the structure of a language abuse detection device provided in an embodiment of the present application, such as Figure 3 As shown, an embodiment of the present application provides an apparatus for detecting language abuse, including an acquisition module 301 and a detection module 302 .

[0114] The acquisition module 301 is used to acquire the language text to be processed.

[0115] The detection module 302 is used to input the language text to be processed into the abuse language detection model to obtain the category prediction probability of the language text to be processed; the abuse language detection model is trained based on the following steps:

[0116] The language abuse detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text.

[0117] In some embodiments, the training of the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text includes:

[0118] The target loss function is obtained by weighted summing the cross-language contrast loss, the categorical cross entropy loss of the source language text, and the categorical cross entropy loss of the target language text.

[0119] The abusive language detection model is trained by minimizing the objective loss function.

[0120] In some embodiments, the objective loss function is expressed as follows:

[0121]

[0122] Among them, Loss represents the target loss function value; λ represents the loss weight parameter; represents the categorical cross entropy loss of the source language text; represents the classification cross entropy loss of the target language text; L XCL represents the cross-lingual contrastive loss.

[0123] In some embodiments, before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes:

[0124] A cross-language contrastive loss is calculated based on the semantic representation of the source language text and the semantic representation of the target language text using a contrastive learning algorithm; the cross-language contrastive loss is used to measure the similarity between the source language text and the target language text.

[0125] In some embodiments, the calculating the classification cross entropy loss of the source language text and the classification cross entropy loss of the target language text based on the semantic representation of the source language text and the semantic representation of the target language text includes:

[0126] Calculating the category prediction probability of the source language text based on the vector representation of the source language text and the fully connected neural network parameters, and calculating the category prediction probability of the target language text based on the vector representation of the target language text and the fully connected neural network parameters;

[0127] The classification cross entropy loss of the source language text is calculated based on the category prediction probability of the source language text, and the classification cross entropy loss of the target language text is calculated based on the category prediction probability of the target language text.

[0128] In some embodiments, the method further comprises:

[0129] Use machine translation models to translate source language text into target language text;

[0130] The source language text and the target language text are input into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text.

[0131] In some embodiments, the step of inputting the source language text and the target language text into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text includes:

[0132] Inputting the source language text into the multilingual pre-training model for semantic recognition to obtain the semantic representation of each word in the source language text, and inputting the target language text into the multilingual pre-training model for semantic recognition to obtain the semantic representation of each word in the target language text;

[0133] Average pooling is performed on the semantic representation of each word in the source language text to obtain the semantic representation of the source language text, and average pooling is performed on the semantic representation of each word in the target language text to obtain the semantic representation of the target language text.

[0134] Specifically, the above-mentioned language abuse detection device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned language abuse detection method embodiment, and can achieve the same technical effects. The parts and beneficial effects of this embodiment that are the same as those of the method embodiment will not be described in detail here.

[0135] It should be noted that the division of units / modules in the above embodiments of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, the functional units in the various embodiments of the present application may be integrated into a processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above integrated units may be implemented in the form of hardware or in the form of software functional units.

[0136] Figure 4 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Figure 4 As shown, the electronic device may include: a processor 401, a communications interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communications interface 402 and the memory 403 communicate with each other via the communication bus 404. The processor 401 may call the logic instructions in the memory 403 to execute the abuse language detection method, which includes:

[0137] Get the language text to be processed;

[0138] The language text to be processed is input into a language abuse detection model to obtain a category prediction probability of the language text to be processed; the language abuse detection model is trained based on the following steps:

[0139] The language abuse detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text.

[0140] Specifically, the processor 401 can be a central processing unit (CPU), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or a complex programmable logic device (CPLD), and the processor can also adopt a multi-core architecture.

[0141] The logic instructions in the memory 403 can be implemented in the form of software functional units and can be stored in a processor-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), disk or optical disk and other media that can store program codes.

[0142] In some embodiments, a computer program product is further provided. The computer program product includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can perform the abusive language detection method provided by each of the above method embodiments. The method includes:

[0143] Get the language text to be processed;

[0144] The language text to be processed is input into a language abuse detection model to obtain a category prediction probability of the language text to be processed; the language abuse detection model is trained based on the following steps:

[0145] The language abuse detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text.

[0146] Specifically, the above-mentioned computer program product provided in the embodiment of the present application can implement all the method steps implemented by the above-mentioned method embodiments, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.

[0147] In some embodiments, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program is used to enable a computer to execute the method for detecting abusive language provided by each of the above method embodiments, the method comprising:

[0148] Get the language text to be processed;

[0149] The language text to be processed is input into a language abuse detection model to obtain a category prediction probability of the language text to be processed; the language abuse detection model is trained based on the following steps:

[0150] The language abuse detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text.

[0151] Specifically, the above-mentioned computer-readable storage medium provided in the embodiment of the present application can implement all the method steps implemented by the above-mentioned method embodiments, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as the method embodiment will not be described in detail here.

[0152] It should be noted that the computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc.), optical storage (such as CD, DVD, BD, HVD, etc.), and semiconductor storage (such as ROM, EPROM, EEPROM, non-volatile memory (NAND FLASH), solid-state drive (SSD)), etc.

[0153] In this application, "determine B based on A" means that the factor A should be considered when determining B. It is not limited to "B can be determined based on A alone", but should also include: "determine B based on A and C", "determine B based on A, C and E", "determine C based on A, and further determine B based on C", etc. In addition, it can also include taking A as a condition for determining B, for example, "when A meets the first condition, use the first method to determine B"; for example, "when A meets the second condition, determine B", etc.; for example, "when A meets the third condition, determine B based on the first parameter", etc. Of course, it can also be a condition that takes A as a factor for determining B, for example, "when A meets the first condition, use the first method to determine C, and further determine B based on C", etc.

[0154] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.

[0155] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer executable instructions. These computer executable instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0156] These processor executable instructions may also be stored in a processor readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the processor readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0157] These processor-executable instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0158] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for detecting abusive language, It is characterized in that include: Get the language text to be processed; The language text to be processed is input into a language abuse detection model to obtain a category prediction probability of the language text to be processed; the language abuse detection model is trained based on the following steps: The abuse language detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text, and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text; Before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes: Calculating a cross-language contrastive loss using a contrastive learning algorithm based on the semantic representation of the source language text and the semantic representation of the target language text; the cross-language contrastive loss is used to measure the similarity between the source language text and the target language text; Before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes: Calculating the category prediction probability of the source language text based on the vector representation of the source language text and the fully connected neural network parameters, and calculating the category prediction probability of the target language text based on the vector representation of the target language text and the fully connected neural network parameters; The classification cross entropy loss of the source language text is calculated based on the category prediction probability of the source language text, and the classification cross entropy loss of the target language text is calculated based on the category prediction probability of the target language text.

2. The method for detecting abusive language according to claim 1, It is characterized in that The training of the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text includes: The target loss function is obtained by weighted summing the cross-language contrast loss, the categorical cross entropy loss of the source language text, and the categorical cross entropy loss of the target language text. The abusive language detection model is trained by minimizing the objective loss function.

3. The method for detecting abusive language according to claim 2, It is characterized in that The expression of the objective loss function is as follows: Among them, Loss represents the target loss function value; λ represents the loss weight parameter; represents the categorical cross entropy loss of the source language text; represents the classification cross entropy loss of the target language text; L XCL represents the cross-lingual contrastive loss.

4. The method for detecting abusive language according to claim 1, It is characterized in that The method further comprises: Use machine translation models to translate source language text into target language text; The source language text and the target language text are input into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text.

5. The method for detecting abusive language according to claim 4, It is characterized in that The step of inputting the source language text and the target language text into a multilingual pre-training model to obtain a semantic representation of the source language text and a semantic representation of the target language text includes: Inputting the source language text into a multilingual pre-training model for semantic recognition to obtain a semantic representation of each word in the source language text, and inputting the target language text into a multilingual pre-training model for semantic recognition to obtain a semantic representation of each word in the target language text; Average pooling is performed on the semantic representation of each word in the source language text to obtain the semantic representation of the source language text, and average pooling is performed on the semantic representation of each word in the target language text to obtain the semantic representation of the target language text.

6. A device for detecting language abuse, It is characterized in that include: An acquisition module, used for acquiring the language text to be processed; The detection module is used to input the language text to be processed into an abuse language detection model to obtain the category prediction probability of the language text to be processed; the abuse language detection model is trained based on the following steps: The abuse language detection model is trained based on cross-language contrast loss, categorical cross entropy loss of source language text, and categorical cross entropy loss of target language text; the target language text is a parallel translation obtained by translating the source language text; Before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes: Calculating a cross-language contrastive loss using a contrastive learning algorithm based on the semantic representation of the source language text and the semantic representation of the target language text; the cross-language contrastive loss is used to measure the similarity between the source language text and the target language text; Before training the abuse language detection model based on the cross-language contrast loss, the classification cross entropy loss of the source language text, and the classification cross entropy loss of the target language text, the method further includes: Calculating the category prediction probability of the source language text based on the vector representation of the source language text and the fully connected neural network parameters, and calculating the category prediction probability of the target language text based on the vector representation of the target language text and the fully connected neural network parameters; The classification cross entropy loss of the source language text is calculated based on the category prediction probability of the source language text, and the classification cross entropy loss of the target language text is calculated based on the category prediction probability of the target language text.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, It is characterized in that When the processor executes the program, the method for detecting abusive language according to any one of claims 1 to 5 is implemented.

8. A non-transitory computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method for detecting abusive language according to any one of claims 1 to 5 is implemented.