Method and device for identifying discourse relations based on class relation words

By replacing noisy relation words in the discourse relation recognition model and establishing a loss function, the problem of low accuracy in discourse relation recognition in the prior art is solved, and more accurate discourse relation recognition is achieved.

CN115809330BActive Publication Date: 2026-06-16BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD
Filing Date
2021-09-15
Publication Date
2026-06-16

AI Technical Summary

Technical Problem

Existing methods for identifying textual relationships suffer from low accuracy due to the discretization of class-related terms.

Method used

By replacing noise with class-related words in the training samples during the training process of the relation classification model, a loss function oriented towards class-related words is established to strengthen the role of class-related words in the classification of discourse relations and improve the recognition accuracy.

Benefits of technology

It improves the accuracy of text relationship identification and achieves more precise text relationship identification results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115809330B_ABST
    Figure CN115809330B_ABST
Patent Text Reader

Abstract

The present disclosure provides a kind of based on class relation word optimization's passage relationship identification method and device, wherein, method includes: two passages are connected into a text;Text is input into relationship classification model to obtain the passage relationship of text;Wherein, relationship classification model is obtained by the following method training: two sample passages are connected into a text;With noise character, multiple class relation words in text are replaced, to obtain the text after replacement;The first relationship distribution for the passage relationship judgment of text is obtained, and the first score that text relationship label prediction is correct;The second score that text relationship label prediction is correct is obtained for the passage relationship judgment of the text after replacement;According to the first relationship distribution, the standard class label corresponding to the first relationship distribution, the first score and the second score determine the final information loss;Further judge the training result of model.The present disclosure is helpful to improve the passage relationship identification performance by facing the optimization objective function of class relation word.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and in particular to a method and apparatus for identifying discourse relations based on class relation word optimization. Background Technology

[0002] Textual relationship identification methods refer to the task of identifying the textual relationship between two given text segments. Specifically, given two text segments, such as (The weather is very nice today, but it was very bad yesterday), the prediction of the textual relationship between them is: transition. However, existing methods all add some words in the text as discrete features to the textual relationship classifier, resulting in low accuracy in textual relationship identification. Summary of the Invention

[0003] This disclosure provides a method and apparatus for identifying textual relationships based on class relation words optimization, which solves the defect in the prior art of discretizing class relation words, resulting in inaccurate classification of textual relationships, and achieves accurate classification of textual relationships by combining with a neural network model.

[0004] Firstly, this disclosure provides a method for identifying discourse relations based on class-related relation words optimization, including:

[0005] Extract the text relating the two passages;

[0006] Connect the two text segments related to the passage into a single text to be processed;

[0007] The text-to-text relationship is obtained from the text-to-text input relationship classification model;

[0008] The relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the discourse relations between the two texts.

[0009] According to the discourse relation recognition method based on relation word optimization provided in this disclosure, the relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and judging the training result based on the discourse relation prediction result of the two texts. Specifically, it includes:

[0010] Connect the two sample texts into one text;

[0011] The text is replaced with noise characters to obtain the replaced text;

[0012] Obtain the first relation distribution for determining the text's discourse relationships, and the first score for correctly predicting the text's relation labels;

[0013] Obtain the second score for correctly predicting the text relationship labels in the passage relationship determination of the replaced text;

[0014] Based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score determine the final information loss;

[0015] The training result of the model is determined based on the final information loss.

[0016] According to the text relation recognition method based on class relation word optimization provided in this disclosure, multiple class relation words in the text are replaced with noise characters to obtain the replaced text, specifically including:

[0017] Obtain the first m words and the last n words of each of the two paragraphs in the text as class relation words;

[0018] The noisy characters are used to replace the class-related words to obtain the replaced text.

[0019] According to the discourse relation recognition method based on class relation word optimization provided in this disclosure, the step of obtaining a first relation distribution for discourse relation judgment of the text and a first score for correct prediction of the text relation labels specifically includes:

[0020] The text is encoded to obtain a classification vector for the text;

[0021] The first relation distribution corresponding to the text is obtained based on the classification vector of the text; the labels in the first relation distribution that correctly judge the text relation are used as the first score for correctly predicting the text relation label.

[0022] According to the discourse relation recognition method based on class relation word optimization provided in this disclosure, the step of encoding the replaced text to obtain the classification vector of the replaced text specifically includes:

[0023] The replaced text is encoded to obtain a classification vector of the replaced text;

[0024] The second relation distribution corresponding to the replaced text is obtained based on the classification vector of the replaced text;

[0025] The labels in the second relation distribution corresponding to the replaced text that correctly judge the relation of the replaced text are used as the second score for correctly predicting the relation label of the replaced text.

[0026] According to the discourse relation recognition method based on class relation word optimization provided in this disclosure, the step of determining the final information loss based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score specifically includes:

[0027] The first relation distribution corresponding to the text is compared with the corresponding standard category label to determine the cross entropy, and the cross entropy is used as the first information loss;

[0028] The second information loss is determined based on the first score and the second score;

[0029] The final information loss is determined based on the first information loss and the second information loss.

[0030] According to the present disclosure, a text relation recognition method based on class relation word optimization is provided, wherein the second information loss is determined according to a first model;

[0031] The first model is:

[0032] Loss2=s2+δ-s1

[0033] Where Loss2 represents the second information loss, s2 represents the second score, s1 represents the first score, and δ represents a constant.

[0034] According to the present disclosure, a text relation recognition method based on class relation word optimization is provided, wherein the final information loss is determined according to a second model;

[0035] The second model is:

[0036] Loss final =Loss1+λ*Loss2

[0037] Among them, Loss final Let λ represent the final information loss, Loss1 represent the first information loss, Loss2 represent the second information loss, and λ represent the weight.

[0038] According to the discourse relation recognition method based on class relation word optimization provided in this disclosure, the step of judging the training result of the model based on the final information loss specifically includes:

[0039] The final information loss is compared with a preset threshold.

[0040] If the final information loss exceeds the preset threshold, then model training is stopped.

[0041] If the final information loss is not greater than the preset threshold, then model training continues.

[0042] Secondly, this disclosure provides a discourse relation recognition device based on class relation word optimization, comprising:

[0043] The document relationship text acquisition module is used to acquire the relationship text between two documents;

[0044] The connection module is used to connect the two text segments related to each other into a single text segment to be processed.

[0045] The text relationship acquisition module is used to obtain the text relationship of the text to be processed from the text input relationship classification model;

[0046] The relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the discourse relations between the two texts.

[0047] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0048] Connect the two sample texts into one text;

[0049] The text is replaced with noise characters to obtain the replaced text;

[0050] Obtain the first relation distribution for determining the text's discourse relationships, and the first score for correctly predicting the text's relation labels;

[0051] Obtain the second score for correctly predicting the text relationship labels in the passage relationship determination of the replaced text;

[0052] Based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score determine the final information loss;

[0053] The training result of the model is determined based on the final information loss.

[0054] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0055] Obtain the first m words and the last n words of each of the two paragraphs in the text as class relation words;

[0056] The noisy characters are used to replace the class-related words to obtain the replaced text.

[0057] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0058] The text is encoded to obtain a classification vector for the text;

[0059] The first relation distribution corresponding to the text is obtained based on the classification vector of the text; the labels in the first relation distribution that correctly judge the text relation are used as the first score for correctly predicting the text relation label.

[0060] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0061] The replaced text is encoded to obtain a classification vector of the replaced text;

[0062] The second relation distribution corresponding to the replaced text is obtained based on the classification vector of the replaced text;

[0063] The labels in the second relation distribution corresponding to the replaced text that correctly judge the relation of the replaced text are used as the second score for correctly predicting the relation label of the replaced text.

[0064] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0065] The first relation distribution corresponding to the text is compared with the corresponding standard category label to determine the cross entropy, and the cross entropy is used as the first information loss;

[0066] The second information loss is determined based on the first score and the second score;

[0067] The final information loss is determined based on the first information loss and the second information loss.

[0068] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0069] The second information loss is determined based on the first model;

[0070] The first model is:

[0071] Loss2=s2+δ-s1

[0072] Where Loss2 represents the second information loss, s2 represents the second score, s1 represents the first score, and δ represents a constant.

[0073] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0074] The final information loss is determined according to the second model;

[0075] The second model is:

[0076] Loss final =Loss1+λ*Loss2

[0077] Among them, Loss final Let λ represent the final information loss, Loss1 represent the first information loss, Loss2 represent the second information loss, and λ represent the weight.

[0078] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module is further configured to:

[0079] The final information loss is compared with a preset threshold.

[0080] If the final information loss exceeds the preset threshold, then model training is stopped.

[0081] If the final information loss is not greater than the preset threshold, model training continues. Thirdly, this disclosure also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of any of the above-described methods for identifying discourse relations based on class-related relational words.

[0082] Fourthly, this disclosure also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the discourse relation recognition method based on class relation word optimization as described above.

[0083] This disclosure provides a method and apparatus for identifying textual relationships based on class-related relation words. During the training process of a relation classification model, noise replacement is applied to class-related relation words in the training samples to obtain a first relation distribution for textual relationship judgment and a first score for correctly predicting the textual relationship labels. A second score is obtained for correctly predicting the textual relationship labels after replacement. The final information loss is determined based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score. In other words, by establishing a loss function oriented towards class-related relation words, the role of class-related relation words in textual relationship classification is strengthened, improving the performance of textual relationship recognition and thus achieving more accurate textual relationship recognition results. Attached Figure Description

[0084] To more clearly illustrate the technical solutions in this disclosure or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0085] Figure 1 This is one of the flowcharts of the discourse relation recognition method based on class relation word optimization provided in this publication;

[0086] Figure 2 This is the second flowchart of the discourse relation recognition method based on class relation word optimization provided in this publication;

[0087] Figure 3 This is the training process of the publicly provided discourse relation model based on class relation word optimization;

[0088] Figure 4 This is a schematic diagram of the structure of the discourse relation recognition device based on class relation word optimization provided in this publication;

[0089] Figure 5 This is a schematic diagram of the structure of the electronic device provided in this disclosure. Detailed Implementation

[0090] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the embodiments of this disclosure, and not all embodiments. Based on the embodiments of this disclosure, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of the embodiments of this disclosure.

[0091] The following is combined with Figure 1 This disclosure describes a text relation recognition method based on class relation word optimization, comprising:

[0092] Step 100: Obtain the text relating the two passages;

[0093] Specifically, discourse relationship identification refers to the task of identifying the discourse relationship between two given text segments. For example, the first text segment states: "The weather is very nice today"; the second text segment states: "Yesterday was very bad." The predicted discourse relationship between these two text segments is: transition. Therefore, it is necessary to obtain the two text segments whose discourse relationship needs to be determined.

[0094] Step 200: Connect the two paragraphs of text related to each other into a single text to be processed;

[0095] Specifically, the two obtained passages are connected into a single text, that is, the two passages are connected into a sentence pair, and the relationship classification model is used to determine the relationship between the sentence pairs.

[0096] Step 300: Obtain the text-to-text relationships from the text-to-text input relationship classification model;

[0097] The relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the discourse relations between the two texts.

[0098] Specifically, this disclosure obtains two texts by replacing relation words used to predict textual relationships. Textual relationships are then predicted based on these two texts. The training effect of the relation classification model is judged based on the prediction results of these two texts, and the training effectiveness is then used to determine whether the model training is complete. Combined with... Figure 2 As shown, the first text segment states: "The weather is very nice today"; the second text segment states: "Yesterday was terrible." The predicted relationship between these two text segments is a contrast.

[0099] This disclosure provides a text relation recognition method based on class relation word optimization. During the training process of the relation classification model, class relation words in the training samples are replaced with noise to obtain two texts. The texts before and after replacement are used to determine the text relation, and the final information loss is determined based on the results of the text relation judgment. That is, this disclosure strengthens the role of class relation words in text relation classification by establishing a loss function oriented towards class relation words, improves the text relation recognition performance, and thus achieves more accurate text relation recognition results.

[0100] According to the present disclosure, a text relation recognition method based on relation word optimization is provided, wherein the relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and the training result is judged based on the result of text relation prediction of the two texts. Specifically, it includes: connecting two sample texts into one text.

[0101] The text is replaced with noise characters to obtain the replaced text;

[0102] Obtain the first relation distribution for determining the text's discourse relationships, and the first score for correctly predicting the text's relation labels;

[0103] Obtain the second score for correctly predicting the text relationship labels in the passage relationship determination of the replaced text;

[0104] Based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score determine the final information loss;

[0105] The training result of the model is determined based on the final information loss.

[0106] Specifically, since words at the beginning and end of a passage often resemble passage relation words, these are referred to as "class relation words" in this disclosure. By replacing these relation words, this disclosure enables the relation classification model to learn their importance. Specifically, this disclosure demonstrates that when the original sentence is input, the model can classify it correctly; however, when class relation words are masked, the model cannot classify it correctly, indicating that the model has learned the decisive role of class relations in passage relation classification. For example, in the text "Today the weather is very good, but yesterday it was very bad," the phrase "Today the weather is...good, but yesterday it was...bad" indicates a contrastive relationship between the two sentences. However, if these words are masked, the sentence becomes "...the weather is...,...but it was...", making it impossible to determine the relationship between the two sentences.

[0107] When determining whether a model has been trained successfully and is ready for classification, the information loss is used as the criterion. Therefore, during model training, the relational terms in the text formed by concatenating sample passages are first replaced. Then, the text formed by concatenating sample passages and the text with replaced relational terms are compared to determine the passage relationships, and the score is determined based on the correct prediction of the relational labels.

[0108] Then, based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score, the final information loss is determined; and the training result of the model is judged based on the final information loss.

[0109] Once it is determined that the relation classification model has learned the role of the relation words in the model, this relation judgment model is used to judge the relationship between the two paragraphs to be judged.

[0110] According to the text relation recognition method based on class relation word optimization provided in this disclosure, multiple class relation words in the text are replaced with noise characters to obtain the replaced text, specifically including:

[0111] Obtain the first m words and the last n words of each of the two paragraphs in the text as class relation words;

[0112] The noisy characters are used to replace the class-related words to obtain the replaced text.

[0113] Specifically, since the first m words and the last n words of each text segment are similar to discourse relation words, they are referred to as "relation words" in this disclosure. In the prior art, it has been proven that in two text segments, the first three words and the last word are often similar to discourse relation words.

[0114] In this disclosure, the first m words and the last n words of each text segment from two articles are obtained, and then the word vector of each of the first m words and the last n words is obtained. Assume the two texts in the two articles are "Today the weather is great, but yesterday was terrible." Taking m as 3 and n as 1 as an example, replacing these words with noise yields [M][M][M]The weather is [M], [M][M][M]But it's [M]. Here, [M] represents the noise character.

[0115] Combination Figure 2 As shown, according to the text relation recognition method based on class relation word optimization provided in this disclosure, the step of obtaining the first relation distribution for judging the text relation and the first score for correctly predicting the text relation labels specifically includes:

[0116] The text is encoded to obtain a classification vector for the text;

[0117] The first relation distribution corresponding to the text is obtained based on the classification vector of the text; the labels in the first relation distribution that correctly judge the text relation are used as the first score for correctly predicting the text relation label.

[0118] Specifically, after concatenating two text passages into a single text, BERT is used to encode the input text, resulting in the CLS vector CLS1 used for classification. BERT's language input representation comprises three components.

[0119] Word embeddings divide words into a finite set of common sub-words, striking a balance between word effectiveness and character flexibility. Segmentation embeddings encode word positional information into feature vectors; position embeddings are crucial for introducing word positional relationships into the model. Position encoding tensors are used to distinguish between two sentences, such as whether B follows A (in dialogue or question-and-answer scenarios). For a sentence pair, the first sentence has a feature value of 0, and the second sentence has a feature value of 1. The final embedding vector is the sum of these three vectors.

[0120] Input CLS1 into the relation classification model to predict the document relation distribution y1, where the prediction score for the correct label is s1. The specific formula is as follows:

[0121] y1 = softmax(W*CLS1)

[0122] s1=y 1,i The i-th label is the correct label for that sample.

[0123] Combination Figure 3 As shown, according to the discourse relation recognition method based on class relation word optimization provided in this disclosure, the step of encoding the replaced text to obtain the classification vector of the replaced text specifically includes:

[0124] The replaced text is encoded to obtain a classification vector of the replaced text;

[0125] The second relation distribution corresponding to the replaced text is obtained based on the classification vector of the replaced text;

[0126] The labels in the second relation distribution corresponding to the replaced text that correctly judge the relation of the replaced text are used as the second score for correctly predicting the relation label of the replaced text.

[0127] Specifically, the two text segments are concatenated into one text segment, and the first three words and the last word of each segment are replaced with a noise character [M]. The input is then encoded using BERT to obtain the CLS vector CLS2 for classification.

[0128] Using CLS2 as input to the relation classification model, the predicted document relation distribution y2 is calculated, where the prediction score for the correct label is s2. The specific formula is as follows:

[0129] y2 = softmax(W*CLS2)

[0130] s2=y 2,i The i-th label is the correct label for that sample.

[0131] Combination Figure 3 As shown, according to the document relation recognition method based on class relation word optimization provided in this disclosure, the step of determining the final information loss based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score specifically includes:

[0132] The first relation distribution corresponding to the text is compared with the corresponding standard category label to determine the cross entropy, and the cross entropy is used as the first information loss;

[0133] The second information loss is determined based on the first score and the second score;

[0134] The final information loss is determined based on the first information loss and the second information loss.

[0135] Specifically, for a given event, there are n possibilities, each with a probability p(xi). The information content of a particular possibility can then be calculated. With the definition of information content, entropy is used to represent the expected value of all information. Relative entropy, also known as KL divergence, is used to measure the difference between two separate probability distributions P(x) and Q(x) for the same random variable x. P(x) is often used to represent the true distribution of the sample, i.e., the standard class label as referred to in this disclosure, while Q(x) represents the distribution predicted by the model.

[0136] In machine learning network training, the input data and labels are often already determined, so the true probability distribution P(x) is also determined, and information entropy is a constant here. Since the KL divergence represents the difference between the true probability distribution P(x) and the predicted probability distribution Q(x), a smaller value indicates a better prediction result. Therefore, it is necessary to minimize the KL divergence. Cross-entropy equals KL divergence plus a constant (information entropy), which is also called entropy and is used to represent the expected amount of information. Expectation is the sum of the probabilities of each possible outcome in the experiment multiplied by its result. The amount of information is inversely proportional to the probability of the information occurring. The higher the probability, the less information; the lower the probability, the more information. Because the cross-entropy formula is easier to calculate than the KL divergence formula, the cross-entropy loss function is often used to calculate the loss in machine learning.

[0137] Specifically, in this disclosure, the first information loss adopts the following loss function:

[0138]

[0139] in, For standard category labels.

[0140] According to the present disclosure, a text relation recognition method based on class relation word optimization is provided, wherein the second information loss is determined according to a first model;

[0141] The first model is:

[0142] Loss2=s2+δ-s1

[0143] Where Loss2 represents the second information loss, s2 represents the second score, s1 represents the first score, and δ represents a constant.

[0144] According to the present disclosure, a text relation recognition method based on class relation word optimization is provided, wherein the final information loss is determined according to a second model;

[0145] The second model is:

[0146] Loss final =Loss1+λ*Loss2

[0147] Among them, Loss final Let λ represent the final information loss, Loss1 represent the first information loss, Loss2 represent the second information loss, and λ represent the weight.

[0148] Where λ is the weight of Loss2 (0 to 1), which is determined by the development set.

[0149] According to the discourse relation recognition method based on class relation word optimization provided in this disclosure, the step of judging the training result of the model based on the final information loss specifically includes:

[0150] The final information loss is compared with a preset threshold.

[0151] If the final information loss exceeds the preset threshold, then model training is stopped.

[0152] If the final information loss is not greater than the preset threshold, then model training continues.

[0153] Specifically, in this disclosure, since it is necessary to determine whether the relation classification model has learned the importance of class relation words based on the amount of information loss, the information loss function is compared with a preset threshold. If the information loss is greater than the preset threshold, it indicates that the relation classification model has learned the role of class relation words in the classification of discourse relations. Otherwise, if the information loss is less than the preset threshold, it indicates that the relation classification model has not learned the role of class relation words in the classification of discourse relations, and further training is required.

[0154] Combination Figure 4 This disclosure provides a discourse relation recognition device based on class relation word optimization, comprising:

[0155] The chapter relationship text acquisition module 41 is used to acquire the relationship text between two chapters;

[0156] Connection module 42 is used to connect the two text segments related to each other into a single text segment to be processed;

[0157] The text relationship acquisition module 43 is used to acquire the text relationship of the text to be processed from the text input relationship classification model;

[0158] The relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the discourse relations between the two texts. Since the apparatus provided in this embodiment can be used to execute the method described in the above embodiments, and its working principle and beneficial effects are similar, it will not be described in detail here. For specific details, please refer to the description of the above embodiments.

[0159] This disclosure provides a discourse relation recognition device based on class relation word optimization. During the training process of the relation classification model, class relation words in the training samples are replaced with noise to obtain two texts. The discourse relation of the text before and after replacement is judged, and the final information loss is determined based on the result of the discourse relation judgment. That is, this disclosure strengthens the role of class relation words in discourse relation classification by establishing a loss function oriented towards class relation words, improves the discourse relation recognition performance, and thus achieves more accurate discourse relation recognition results.

[0160] According to the discourse relation recognition device based on class relation word optimization provided in this disclosure, the discourse relation acquisition module 43 is further configured to:

[0161] Connect the two sample texts into one text;

[0162] The text is replaced with noise characters to obtain the replaced text;

[0163] Obtain the first relation distribution for determining the text's discourse relationships, and the first score for correctly predicting the text's relation labels;

[0164] Obtain the second score for correctly predicting the text relationship labels in the passage relationship determination of the replaced text;

[0165] Based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score determine the final information loss;

[0166] The training result of the model is determined based on the final information loss.

[0167] The document relation recognition device based on class relation word optimization provided in this embodiment of the disclosure, wherein the document relation acquisition module 43 is specifically used for:

[0168] Obtain the first m words and the last n words of each of the two paragraphs in the text as class relation words;

[0169] The noisy characters are used to replace the class-related words to obtain the replaced text.

[0170] The document relation recognition device based on class relation word optimization provided in this embodiment of the present disclosure, wherein the document relation acquisition module 43 is specifically used for:

[0171] The text is encoded to obtain a classification vector for the text;

[0172] The first relation distribution corresponding to the text is obtained based on the classification vector of the text; the labels in the first relation distribution that correctly judge the text relation are used as the first score for correctly predicting the text relation label.

[0173] The document relation recognition device based on class relation word optimization provided in this embodiment of the present disclosure, wherein the document relation acquisition module 43 is specifically used for:

[0174] The replaced text is encoded to obtain a classification vector of the replaced text;

[0175] The second relation distribution corresponding to the replaced text is obtained based on the classification vector of the replaced text;

[0176] The labels in the second relation distribution corresponding to the replaced text that correctly judge the relation of the replaced text are used as the second score for correctly predicting the relation label of the replaced text.

[0177] The document relation recognition device based on class relation word optimization provided in this embodiment of the present disclosure, wherein the document relation acquisition module 43 is specifically used for:

[0178] The first relation distribution corresponding to the text is compared with the corresponding standard category label to determine the cross entropy, and the cross entropy is used as the first information loss;

[0179] The second information loss is determined based on the first score and the second score;

[0180] The final information loss is determined based on the first information loss and the second information loss.

[0181] The document relation recognition device based on class relation word optimization provided in this embodiment of the disclosure, wherein the document relation acquisition module 43 is specifically used for:

[0182] The second information loss is determined based on the first model;

[0183] The first model is:

[0184] Loss2=s2+δ-s1

[0185] Where Loss2 represents the second information loss, s2 represents the second score, s1 represents the first score, and δ represents a constant.

[0186] The document relation recognition device based on class relation word optimization provided in this embodiment of the disclosure, wherein the document relation acquisition module 43 is specifically used for:

[0187] The final information loss is determined according to the second model;

[0188] The second model is:

[0189] Loss final =Loss1+λ*Loss2

[0190] Among them, Loss final Let λ represent the final information loss, Loss1 represent the first information loss, Loss2 represent the second information loss, and λ represent the weight.

[0191] The document relation recognition device based on class relation word optimization provided in this embodiment of the disclosure, wherein the document relation acquisition module 43 is specifically used for:

[0192] The final information loss is compared with a preset threshold.

[0193] If the final information loss exceeds the preset threshold, then model training is stopped.

[0194] If the final information loss is not greater than the preset threshold, then model training continues.

[0195] Figure 5 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 5 As shown, the electronic device may include a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, communications interface 520, and memory 530 communicate with each other via the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a text relation recognition method based on class relation word optimization. This method includes: acquiring two text segments with text relations; concatenating the two text segments with text relations into a text to be processed; inputting the text to be processed into a relation classification model to obtain the text relations of the text to be processed; wherein the relation classification model is obtained by replacing relation words in a text segment to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the text relations of the two texts.

[0196] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of this disclosure, essentially, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of software products. These computer software products are stored in a storage medium and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0197] On the other hand, this disclosure also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, which, when executed by a computer, enable the computer to execute a text relation recognition method based on class relation word optimization provided by the above methods. The method includes: acquiring two text relation segments; concatenating the two text relation segments into a text to be processed; inputting the text to be processed into a relation classification model to obtain the text relation of the text to be processed; wherein the relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the text relation of the two texts.

[0198] In another aspect, this disclosure also provides a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements a method for identifying discourse relations based on class relation word optimization provided above. The method includes: acquiring two discourse relation texts; concatenating the two discourse relation texts into a text to be processed; inputting the text to be processed into a relation classification model to obtain the discourse relations of the text to be processed; wherein the relation classification model is obtained by replacing relation words in a text to obtain two texts before and after the replacement, and judging the training result based on the result of discourse relation prediction of the two texts.

[0199] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0200] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0201] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this disclosure, and are not intended to limit them. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure.

Claims

1. A method for identifying a discourse relation based on a class relation word optimization, characterized in that, include: Extract the text relating the two passages; Connect the two text segments related to the passage into a single text to be processed; The text-to-text relationship is obtained from the text-to-text input relationship classification model; The relation classification model is obtained by replacing a text with relational words to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the text relations between the two texts; the first m words and the last n words of each text segment are relational words. The relation classification model is obtained by replacing a text with relational words to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the relationship between the two texts. Specifically, it includes: connecting two sample texts into one text. The text is replaced with noise characters to obtain the replaced text; Obtain the first relation distribution for determining the text's discourse relationships, and the first score for correctly predicting the text's relation labels; Obtain the second score for correctly predicting the text relationship labels in the passage relationship determination of the replaced text; Based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score determine the final information loss; The relation classification model is trained based on the final information loss to obtain the trained relation classification model. 2.The method of claim 1, wherein, The text is replaced with noise characters to obtain the replaced text, specifically including: Obtain the first m words and the last n words of each of the two paragraphs in the text as class relation words; The noisy characters are used to replace the class-related words to obtain the replaced text. 3.The method of claim 1, wherein, The step of obtaining the first relation distribution for determining the text's discourse relationships and the first score for correctly predicting the text relation labels specifically includes: The text is encoded to obtain a classification vector for the text; The first relation distribution corresponding to the text is obtained based on the classification vector of the text; the labels in the first relation distribution that correctly judge the text relation are used as the first score for correctly predicting the text relation label. 4.The method of claim 1, wherein, The process of encoding the replaced text to obtain a classification vector for the replaced text specifically includes: The replaced text is encoded to obtain a classification vector of the replaced text; The second relation distribution corresponding to the replaced text is obtained based on the classification vector of the replaced text; The labels in the second relation distribution corresponding to the replaced text that correctly judge the relation of the replaced text are used as the second score for correctly predicting the relation label of the replaced text. 5.The method of claim 1, wherein, The step of determining the final information loss based on the first relationship distribution, the standard category label corresponding to the first relationship distribution, the first score, and the second score specifically includes: The first relation distribution corresponding to the text is compared with the corresponding standard category label to determine the cross entropy, and the cross entropy is used as the first information loss; The second information loss is determined based on the first score and the second score; The final information loss is determined based on the first information loss and the second information loss. 6.The method of claim 5, wherein, The second information loss is determined based on the first model; The first model is: wherein, denotes a second information loss, denotes a second score, denotes a first score, denotes a constant. 7.The method of claim 5, wherein, The final information loss is determined according to the second model; The second model is: wherein, represents the final information loss, represents the first information loss, represents the second information loss, represents the weight. 8.The method of claim 1, wherein, The step of determining the training result of the model based on the final information loss specifically includes: The final information loss is compared with a preset threshold. If the final information loss exceeds the preset threshold, then model training is stopped. If the final information loss is not greater than the preset threshold, then model training continues.

9. A discourse relation recognition device based on class relation word optimization, characterized in that, include: The document relationship text acquisition module is used to acquire the relationship text between two documents; The connection module is used to connect the two text segments related to each other into a single text segment to be processed. The text relationship acquisition module is used to obtain the text relationship of the text to be processed from the text input relationship classification model; The relation classification model is obtained by replacing a text with relational words to obtain two texts before and after the replacement, and judging the training result based on the result of predicting the text relations between the two texts; the first m words and the last n words of each text segment are relational words. The chapter relationship acquisition module is also used for: Connect the two sample texts into one text; The text is replaced with noise characters to obtain the replaced text; Obtain the first relation distribution for determining the text's discourse relationships, and the first score for correctly predicting the text's relation labels; Obtain the second score for correctly predicting the text relationship labels in the passage relationship determination of the replaced text; Based on the first relation distribution, the standard category label corresponding to the first relation distribution, the first score, and the second score determine the final information loss; The training result of the model is determined based on the final information loss.

10. The discourse relation recognition device based on class relation word optimization according to claim 9, characterized in that, The chapter relationship acquisition module is also used for: Obtain the first m words and the last n words of each of the two paragraphs in the text as class relation words; The noisy characters are used to replace the class-related words to obtain the replaced text.

11. The discourse relation recognition device based on class relation word optimization according to claim 9, characterized in that, The chapter relationship acquisition module is also used for: The text is encoded to obtain a classification vector for the text; The first relation distribution corresponding to the text is obtained based on the classification vector of the text; the labels in the first relation distribution that correctly judge the text relation are used as the first score for correctly predicting the text relation label.

12. The discourse relation recognition device based on class relation word optimization according to claim 9, characterized in that, The chapter relationship acquisition module is also used for: The replaced text is encoded to obtain a classification vector of the replaced text; The second relation distribution corresponding to the replaced text is obtained based on the classification vector of the replaced text; The labels in the second relation distribution corresponding to the replaced text that correctly judge the relation of the replaced text are used as the second score for correctly predicting the relation label of the replaced text.

13. The discourse relation recognition device based on class relation word optimization according to claim 9, characterized in that, The chapter relationship acquisition module is also used for: The first relation distribution corresponding to the text is compared with the corresponding standard category label to determine the cross entropy, and the cross entropy is used as the first information loss; The second information loss is determined based on the first score and the second score; The final information loss is determined based on the first information loss and the second information loss.

14. The discourse relation recognition device based on class relation word optimization according to claim 13, characterized in that, The chapter relationship acquisition module is also used for: The second information loss is determined based on the first model; The first model is: in, This indicates the loss of the second piece of information. Indicates the second score. Indicates the first score. Represents a constant.

15. The discourse relation recognition device based on class relation word optimization according to claim 9, characterized in that, The chapter relationship acquisition module is also used for: The final information loss is determined according to the second model; The second model is: in, Indicates the final information loss. This indicates the loss of the first piece of information. This indicates the loss of the second piece of information. Indicates the weight.

16. The discourse relation recognition device based on class relation word optimization according to claim 9, characterized in that, The chapter relationship acquisition module is also used for: The final information loss is compared with a preset threshold. If the final information loss exceeds the preset threshold, then model training is stopped. If the final information loss is not greater than the preset threshold, then model training continues.

17. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the discourse relation recognition method based on class relation word optimization as described in any one of claims 1 to 8.

18. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the steps of the discourse relation recognition method based on class relation word optimization as described in any one of claims 1 to 8.