Emotion reason sentence pair prediction model training method, prediction method and device
By adaptively selecting prompt templates and training classifiers, the relationship between emotion and cause is explicitly learned, which solves the problem of insufficient robustness and generalization of existing models in the task of extracting emotion cause pairs and improves the accuracy of emotion cause pair prediction.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2026-03-27
AI Technical Summary
In existing emotion cause pair extraction tasks, the models are inadequate in capturing and understanding the complex relationship between emotion and cause, lack robustness and generalization, and fail to fully utilize emotion type information, resulting in insufficient accuracy of prediction results.
By adaptively selecting prompt templates corresponding to text data, emotion, cause, and relationship templates are constructed. A classifier is trained using masked sample data to explicitly learn the relationship between emotion and cause. Combined with unsupervised learning clustering and multilayer perceptron optimization, the adaptability and accuracy of the model are improved.
Explicitly learning the relationship between emotion and its causes improves the robustness and generalization of the model, enhances the accuracy of emotion-cause prediction, and increases the model's diversity and effectiveness.
Smart Images

Figure CN120316262B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of text data processing, and in particular to an emotion cause sentence pair prediction model training method, a prediction method and equipment. BACKGROUND
[0002] In the field of natural language processing, emotion cause extraction (ECE) is an important research direction. The main goal of ECE is to determine the cause of a given emotion expressed in a text, but emotion cause extraction needs to be annotated first, and then the corresponding cause clause can be extracted. Therefore, some scholars redefine this task, i.e., emotion cause pair extraction (ECPE), which directly extracts all potential emotion clauses and corresponding cause clauses from unannotated documents. In the ECPE task, in addition to the traditional two-step method and end-to-end model, more and more researchers have proposed new methods, such as sequence labeling method machine reading comprehension method, prompt learning method, etc., among which the method using prompt learning is proposed in the last two or three years.
[0003] Currently, some scholars have proposed using a prompt tuning method in the emotion cause pair extraction task, which decomposes the task into emotion extraction, cause extraction, and emotion cause pair extraction three sub-tasks, and adds a unified prompt template to solve the problem of implicit relationship modeling and dependence on position information or dataset bias.
[0004] However, the existing emotion cause pair extraction task using the prompt tuning method implicitly learns the relationship between emotions and causes, which may result in insufficient performance of the model in capturing and understanding the complex relationship between emotions and causes; at the same time, some methods depend on position information or dataset bias (such as Figure 1 As shown, the cause clause is usually located near the emotion clause; as Figure 2 As shown, the influence of different document lengths on the model's reasoning of emotions and causes is studied), making the model lack robustness and generalization; in addition, these methods also fail to fully utilize emotion type information, thus resulting in the problems of insufficient robustness and generalization of the prediction model and insufficient accuracy of the emotion cause pair extraction result in the existing emotion cause pair extraction task using the prompt tuning method. SUMMARY
[0005] In view of this, the emotion cause sentence pair prediction model training method, prediction method and equipment provided by the embodiments of the present application eliminate or improve one or more defects in the prior art.
[0006] One aspect of the present application provides an emotion cause sentence pair prediction model training method, comprising:
[0007] According to the emotion classification labels corresponding to each of the text data and the prompt templates corresponding to each of the emotion classification labels, the prompt templates corresponding to each of the text data are adaptively selected to extract the mask sample data corresponding to each of the text data respectively; wherein the text data contains emotion sentences where the emotion words are located and a plurality of non-emotion sentences, and at least one of the non-emotion sentences is the reason sentence corresponding to the emotion words;
[0008] Based on each of the mask sample data, a classifier is trained to be an emotion reason sentence pair prediction model for predicting the emotion reason sentence pair of the text data, wherein the emotion reason sentence pair is used to represent the corresponding relationship between the emotion sentence and the reason sentence in the text data.
[0009] In some embodiments of the present application, before the step of adaptively selecting the prompt templates corresponding to each of the text data to extract the mask sample data corresponding to each of the text data according to the emotion classification labels corresponding to each of the text data and the prompt templates corresponding to each of the emotion classification labels, the method further comprises:
[0010] constructing a corresponding prompt template for each emotion classification label, wherein the prompt template includes an emotion template, a reason template, and a relationship template;
[0011] The emotion template is used to represent an emotion mask sentence corresponding to one of the emotion classification labels, and the emotion mask sentence is formed by masking the emotion words in the emotion sentence corresponding to the emotion classification label;
[0012] The reason template is used to represent a reason determination result mask sentence corresponding to one of the emotion classification labels, and the reason determination result mask sentence is formed by masking the determination result of whether each of the non-emotion sentences in the text data is the reason sentence corresponding to the emotion words in the text data;
[0013] The relationship template is used to represent a relationship mask sentence corresponding to one of the emotion classification labels, and the relationship mask sentence is a relationship expression sentence between the emotion classification label and the reason sentence after masking the non-emotion sentences associated with the emotion words in the text data;
[0014] Correspondingly, the mask sample data includes the emotion mask sentence, the reason determination result mask sentence, and the relationship mask sentence.
[0015] In some embodiments of the present application, before adaptively selecting the prompt template corresponding to each piece of text data to extract the mask sample data corresponding to each piece of text data respectively according to the emotion classification label corresponding to each piece of text data and the prompt template corresponding to each emotion classification label, the method further comprises:
[0016] performing clustering processing on each emotion word based on unsupervised learning to obtain clustering result data for representing a one-to-many mapping relationship between each emotion classification label and each emotion word;
[0017] determining the emotion classification label corresponding to each piece of text data respectively according to the clustering result data and the emotion words contained in each piece of text data.
[0018] In some embodiments of the present application, the clustering processing on each emotion word based on unsupervised learning to obtain clustering result data for representing a one-to-many mapping relationship between each emotion classification label and each emotion word comprises:
[0019] inputting each emotion word into a RoBERTa language model to make the RoBERTa language model output an embedding vector corresponding to each emotion word respectively, and obtaining an embedding matrix composed of the embedding vectors;
[0020] performing clustering processing on each emotion word based on a K-means clustering algorithm and the embedding matrix with each emotion classification label as a different cluster center to cluster each embedding vector into a different cluster, obtaining a corresponding relationship between the emotion classification label corresponding to each cluster and each embedding vector in the cluster, and generating clustering result data for representing a one-to-many mapping relationship between each emotion classification label and the emotion word corresponding to each embedding vector.
[0021] In some embodiments of the present application, the classifier comprises a mask language model, a Bayesian network and a multilayer perception machine, and an output end of the mask language model is connected to an input end of the Bayesian network, and an output end of the Bayesian network is connected to an input end of the multilayer perception machine.
[0022] Correspondingly, the training of the classifier based on each mask sample data to train the classifier as an emotion cause sentence pair prediction model for predicting the emotion cause sentence pair of the text data comprises:
[0023] perform feature vector extraction on the emotion mask sentence, the cause determination result mask sentence and the relationship mask sentence of each mask sample data based on the mask language model respectively, to obtain an emotion feature vector corresponding to the emotion mask sentence, a cause feature vector corresponding to the cause determination result mask sentence and a relationship feature vector corresponding to the relationship mask sentence of each mask sample data respectively;
[0024] perform multiple rounds of iteration on the Bayesian network and the multi-layer perceptron using the emotion feature vector, the cause feature vector and the relationship feature vector of each mask sample data, and in each iteration round, take the emotion-cause sentence pair corresponding to each text data as the label of the mask sample data corresponding to each text data, calculate the loss of the emotion-cause sentence pair prediction result data corresponding to the mask sample data output by the multi-layer perceptron according to the label of the mask sample data, and optimize the multi-layer perceptron based on the loss.
[0025] In some embodiments of the present application, the Bayesian network is used to perform feature extraction on the cause feature vector based on the emotion feature vector to obtain a target cause feature vector corresponding to the cause feature vector, perform feature extraction on the relationship feature vector based on the emotion feature vector and the cause feature vector to obtain a target relationship feature vector corresponding to the relationship feature vector, and then output the emotion feature vector, the target cause feature vector and the target relationship feature vector corresponding to each mask sample data respectively.
[0026] In some embodiments of the present application, the multi-layer perceptron is used to perform multi-element classification on the emotion feature vector, the target cause feature vector and the target relationship feature vector corresponding to each mask sample data output by the Bayesian network respectively, and output emotion-cause sentence pair prediction result data corresponding to each mask sample data respectively.
[0027] The second aspect of the present application provides an emotion-cause sentence pair prediction method, comprising:
[0028] According to the emotion classification label corresponding to the target text data and the prompt template corresponding to the emotion classification label, adaptively select the prompt template corresponding to the target text data to extract mask sample data corresponding to the target text data; wherein the target text data contains an emotion sentence where an emotion word is located and a plurality of non-emotion sentences, and at least one of each non-emotion sentence is a cause sentence corresponding to the emotion word;
[0029] input the mask sample data corresponding to the target text data into the emotion-cause sentence pair prediction model, so that the emotion-cause sentence pair prediction model correspondingly outputs an emotion-cause sentence pair corresponding to the target text data; wherein the emotion-cause sentence pair prediction model is trained in advance based on the emotion-cause sentence pair prediction model training method provided in the first aspect.
[0030] The third aspect of the present application provides an emotion-cause sentence pair prediction model training device, comprising:
[0031] The first adaptive mask module is configured to adaptively select the prompt template corresponding to each text data according to the emotion classification label corresponding to each text data and the prompt template corresponding to each emotion classification label, so as to extract the mask sample data corresponding to each text data, respectively; wherein the text data comprises an emotion sentence where an emotion word is located and a plurality of non-emotion sentences, and at least one of the non-emotion sentences is a cause sentence corresponding to the emotion word.
[0032] The classifier training module is configured to train a classifier based on each mask sample data, so as to train the classifier into an emotion-cause sentence pair prediction model for predicting an emotion-cause sentence pair of text data, wherein the emotion-cause sentence pair is used to represent the corresponding relationship between an emotion sentence and a cause sentence in text data.
[0033] The fourth aspect of the present application provides an emotion-cause sentence pair prediction device, comprising:
[0034] The second adaptive mask module is configured to adaptively select the prompt template corresponding to the target text data according to the emotion classification label corresponding to the target text data and the prompt template corresponding to the emotion classification label, so as to extract the mask sample data corresponding to the target text data; wherein the target text data comprises an emotion sentence where an emotion word is located and a plurality of non-emotion sentences, and at least one of the non-emotion sentences is a cause sentence corresponding to the emotion word.
[0035] The model prediction module is configured to input the mask sample data corresponding to the target text data into the emotion-cause sentence pair prediction model, so that the emotion-cause sentence pair prediction model correspondingly outputs an emotion-cause sentence pair corresponding to the target text data; wherein the emotion-cause sentence pair prediction model is trained in advance based on the emotion-cause sentence pair prediction model training method.
[0036] The fifth aspect of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the emotion-cause sentence pair prediction model training method and / or the emotion-cause sentence pair prediction method.
[0037] The sixth aspect of the present application provides a computer-readable storage medium, having stored thereon a computer program, which, when executed by a processor, implements the emotion-cause sentence pair prediction model training method and / or the emotion-cause sentence pair prediction method.
[0038] The seventh aspect of the present application provides a computer program product, comprising a computer program, which, when executed by a processor, implements the emotion-cause sentence pair prediction model training method and / or the emotion-cause sentence pair prediction method.
[0039] The emotion-cause sentence pair prediction model training method provided by the present application adaptively selects the prompt template corresponding to each text data according to the emotion classification label corresponding to each text data and the prompt template corresponding to each emotion classification label, to extract the mask sample data corresponding to each text data, respectively; wherein the text data contains an emotion sentence where the emotion word is located and a plurality of non-emotion sentences, and at least one of the non-emotion sentences is the cause sentence corresponding to the emotion word; and a classifier is trained based on each mask sample data, to train the classifier as an emotion-cause sentence pair prediction model for predicting the emotion-cause sentence pair of the text data. The emotion-cause sentence pair is used to represent the corresponding relationship between the emotion sentence and the cause sentence in the text data, can explicitly learn the relationship between the emotion and the cause in the text, can improve the diversity of the prompt template, can improve the adaptability, effectiveness and reliability of the emotion-cause sentence pair prediction model training process, and thus can improve the robustness and generalization of the model, to improve the accuracy of the emotion-cause sentence pair prediction result output by the emotion-cause sentence pair prediction model.
[0040] Additional advantages, objects, and features of the application will be set forth in part by the description that follows, and will become apparent to those skilled in the art upon examination of the following detailed description and drawings in which
[0041] Those skilled in the art will appreciate that the objects and advantages of the application can be implemented in the following detailed description and drawings. BRIEF DESCRIPTION OF DRAWINGS
[0042] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the principles of the application. The components in the drawings are not necessarily to scale, emphasis instead being placed upon illustrating the principles of the application. For purposes of clarity and a consistent approach, portions of the drawings may be exaggerated relative to the other portions, so as to highlight aspects of certain embodiments of the application. In the drawings:
[0043] Figure 1 is a diagram of the relative distance distribution of emotion clause and reason clause pairs in the ECPE dataset in the prior art.
[0044] Figure 2 is a diagram of the influence of different lengths of research documents on the extraction results of the model in the prior art.
[0045] Figure 3 is a first flowchart of the emotion-reason sentence pair prediction model training method in an embodiment of the present application.
[0046] Figure 4 is an example diagram of text data A in an embodiment of the present application.
[0047] Figure 5 is a second flowchart of the emotion-reason sentence pair prediction model training method in an embodiment of the present application.
[0048] Figure 6 is an example diagram of obtaining the mask sample data of the text data A using the prompt template in an embodiment of the present application.
[0049] Figure 7 is a third flowchart of the emotion-reason sentence pair prediction model training method in an embodiment of the present application.
[0050] Figure 8 is an example diagram of unsupervised clustering learning in an embodiment of the present application.
[0051] Figure 9 is a diagram of the prior art ignoring the correlation between emotion, reason, and their relationship pairing tasks.
[0052] Figure 10 is a technical architecture diagram of the emotion-reason sentence pair prediction model training method based on Bayesian and prompt learning provided by an application example of the present application. DETAILED DESCRIPTION
[0053] For the purpose of making the objectives, technical solutions and advantages of the present application clearer, further detailed description of the present application will be given below in conjunction with the embodiments and drawings. Herein, the illustrative embodiments of the present application and the description thereof are used to explain the present application but not to limit the present application.
[0054] It should also be noted that, in order not to obscure the present application with unnecessary details, only the structures and / or processing steps closely related to the solutions according to the present application are shown in the drawings, and other details not closely related to the present application are omitted.
[0055] It should be emphasized that the term "comprises / comprising" as used herein is used to indicate the presence of the stated features, elements, steps or components but does not preclude the presence or addition of one or more other features, elements, steps or components.
[0056] It should also be noted that, if not specifically stated, the term "connected" as used herein can not only mean direct connection but also indirect connection in the presence of an intermediate.
[0057] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. In the drawings, the same reference numerals represent the same or similar components, or the same or similar steps.
[0058] It should be noted that in the field of natural language processing, emotion cause extraction (ECE) is an important research direction. Traditional methods and techniques focus on the analysis of text sentiment polarity, i.e., determining the positive and negative emotions, which is of great significance and value for applications such as social media traffic monitoring, customer opinion feedback analysis, and mental health assessment suggestions. However, the process of delving into the reasons behind emotions is lacking, so subsequent research on emotion analysis focuses on determining the reasons behind emotions, rather than just discovering positive and negative emotions. The main goal of ECE is to determine the reasons for a given emotion expressed in the text, but emotion cause extraction requires emotion annotation before extracting the corresponding reason clauses. Therefore, some scholars redefine this task as emotion cause pair extraction (ECPE), which directly extracts all potential emotion clauses and corresponding reason clauses from unannotated documents.
[0059] Currently, in the ECPE task, in addition to the traditional two-step method and end-to-end model, more and more researchers have proposed new methods, such as sequence labeling method, machine reading comprehension method, and prompt learning method. Specifically, the methods to solve ECPE include two-step method, end-to-end method, joint learning method, graph convolution method, sequence labeling method, and machine reading comprehension method.
[0060] The two-step approach is typical of designing a pipeline model consisting of two classifiers. The first classifier is used to extract emotion clauses and reason clauses separately, and then, the candidate emotion-reason pairs are generated by applying the Cartesian product to the emotion set and the reason set. Finally, a filter is trained to remove those pairs that do not contain a causal relationship between the emotion and the reason. Although this method achieves good results, it has the problem of cascading errors, i.e., the errors that may exist when the first classifier extracts emotion clauses and reason clauses can be passed to the second classifier, thereby affecting the final result. At the same time, the two-step approach does not take advantage of the correlation between the two tasks, separating the two tasks.
[0061] Therefore, many people have proposed end-to-end methods. Some scholars have proposed an end-to-end framework that deeply captures the complex relationship between emotions and reasons through interactive attention mechanisms and fusion mechanisms; some scholars have proposed an end-to-end graph convolutional network (GCN) framework that extracts sentiment and reason features through clause-level and pair-level context encoders, uses GCN to model the dependency relationship between candidate pairs, and realizes the classification and labeling of candidate pairs; some scholars have restructured the extraction of emotion-reason pairs as a sequence labeling problem, combining the advantages of sequence labeling and sequence-to-sequence, and improving the accuracy and robustness of the model through content and pair labeling. Some scholars have ingeniously rephrased the ECPE task as a machine reading comprehension (MRC) problem and used the powerful features of MRC models to extract correct emotion-reason pairs. Some scholars have proposed a new graph-based method that accurately models sentiment-triggering paths using common sense knowledge to reveal the semantic dependencies between candidate clauses and sentiment clauses. Some scholars have jointly fused fine-grained and coarse-grained semantic features to model the coarse-grained semantic relationships between clauses to alleviate the problem of semantic feature extraction; some scholars have optimized the model through constraint learning and adjusting the classifier decision boundary to better learn representations from unbalanced data; some scholars have treated the ECPE task as a question-answering problem, predicting emotion clauses through fixed questions, and then predicting their potential reasons by using the predicted emotions as questions; some scholars have used multi-granularity information, including word-level, clause-level, and document-level information, to extract emotion-reason pairs; some scholars have formalized the ECPE task as a probability problem, derived the joint distribution of sentiment clauses and reason clauses through the total probability formula, and quantified their dependency strength using mutual information; some scholars have proposed a multi-task sequence labeling framework that encodes emotion distances into a new labeling scheme while extracting emotions and reasons, and uses auxiliary task outputs as inductive bias to optimize label distribution; some scholars have proposed a symmetric local search network (SLSN) model that simultaneously detects and matches emotions and reasons through local search; some scholars have proposed a dual questioning attention network that questions the candidate's emotions and situational reasons to obtain answers in terms of context and semantics to address the limitations of the ECPE task.
[0062] Unlike the fine-tuning method described above, the method of prompt learning is proposed in the last two or three years. Prompt learning has been widely used in sentiment analysis tasks before and has achieved good results. In recent years, scholars have first proposed the use of prompt tuning method in emotion-cause pair extraction task. By dividing the task into three sub-tasks of emotion extraction, cause extraction and emotion-cause pair extraction, and adding a unified prompt template, the problems of implicit relationship modeling and dependence on position information or dataset bias are solved. Then, scholars proposed a prompt template that fuses emotion categories to solve the bias problem of existing prompt methods that use one-to-one mapping to map label words to categories. Specifically, scholars have proposed an emotion-cause pair extraction method based on prompt learning, which integrates deep knowledge of emotion categories, excavates implicit knowledge of cause clauses, and establishes a connection with an external sentiment lexicon. The general prompt tuning method divides the emotion-cause analysis task into multiple targets and designs modules to alleviate position bias. However, existing methods do not fully understand the use of emotion category information and do not consider the objective dependency between emotion and cause.
[0063] That is, although prompt tuning technology has made some progress in the ECPE task, the current prompt template that fuses emotion categories is relatively single and fails to fully utilize emotion information and cause information. Although some scholars have proposed a prompt learning method that fuses emotion knowledge, the prompt template lacks diversity and fails to design specific prompts according to different emotion categories.
[0064] Therefore, in order to solve the problems of the existing emotion-cause pair extraction task using prompt tuning method, such as insufficient robustness and generalization of the prediction model and insufficient accuracy of the emotion-cause pair extraction result, the embodiments of the present application provide an emotion-cause sentence pair prediction model training method, an emotion-cause sentence pair prediction method, an emotion-cause sentence pair prediction model training device for executing the emotion-cause sentence pair prediction model training method, an emotion-cause sentence pair prediction device for executing the emotion-cause sentence pair prediction method, an entity device, a computer readable storage medium and a computer program product. The semantic relationship between emotion and cause in text data is utilized and different emotion categories are distinguished. According to different categories of emotion-cause pairs, prompt templates are adaptively selected to provide a better data basis for model training.
[0065] The embodiments are specifically described as follows.
[0066] Based on this, the embodiments of the present application provide an emotion-cause sentence pair prediction model training method that can be implemented by an emotion-cause sentence pair prediction model training device, as shown in Figure 3 The emotion-cause sentence pair prediction model training method specifically includes the following contents:
[0067] Step 100: adaptively selecting, according to the emotion classification label corresponding to each piece of text data and the prompt template corresponding to each emotion classification label, the prompt template corresponding to each piece of text data to extract the mask sample data corresponding to each piece of text data respectively; wherein the text data contains an emotion sentence where the emotion word is located and a plurality of non-emotion sentences, and at least one of the non-emotion sentences is a reason sentence corresponding to the emotion word.
[0068] In one or more embodiments of the present application, the text data is composed of a plurality of sentences divided by punctuation marks and / or conjunctions (such as "and" and the like), and the plurality of sentences are divided into emotion sentences and non-emotion sentences, wherein the emotion sentences refer to sentences containing emotion words, and the non-emotion sentences refer to other sentences in the text data other than the emotion sentences, and at least one reason sentence needs to be contained in the non-emotion sentences. It can be understood that the reason mentioned in the present application refers to the reason causing the emotion, and correspondingly, the reason sentence refers to the sentence composed of the reason causing the emotion corresponding to the emotion word. Of course, the emotion mentioned in the embodiments of the present application can be expressed as "emotion", which can be selected according to actual application situations.
[0069] In addition, the emotion reason sentence mentioned in the present application can be applied to the prediction of emotion reason sentence pairs in text data in multiple languages, such as Chinese, English, Japanese, etc.
[0070] In a specific example, the text data A is "Yesterday morning, a policeman visited the old man with the lost money and told him that the thief was caught. The old man was very happy and deposited the money in the bank" (Yesterday morning, a policeman visited the old man with the lost money and told him that the thief was caught. The old man was very happy and deposited the money in the bank), which is first divided into five sentences c1 to c5 according to punctuation marks and conjunctions "and", see Figure 4 , specifically as follows:
[0071] c1: Yesterday morning (Yesterday morning);
[0072] c2: a policeman visited the old man with the lost money (a policeman visited the old man with the lost money);
[0073] c3: and told him that the thief was caught
[0074] c4: The old man was very happy
[0075] c5: and deposited the money in the bank
[0076] In the sentence c4, the emotion word "happy" appears, so the sentence c4 is the emotion sentence in the text data A, and the sentences c1 to c3 and c5 are non-emotion sentences in the text data A. The non-emotion sentences need to contain at least one reason sentence. In the above example, the sentences c2 and c3 are the reason sentences corresponding to the emotion sentence c4, that is, the text data containing the emotion sentence in which the emotion word is located and the multiple non-emotion sentences, at least one of the non-emotion sentences being the reason sentence corresponding to the emotion word, can be used to train the classifier mentioned in the present application.
[0077] It can be understood that the emotion classification label refers to a label used to represent an emotion type. In the embodiments of the present application, the number and type of emotion classification labels can be set according to actual application requirements. In order to further improve the richness and rationality of the emotion classification label and make full use of the emotion category information, in an embodiment of the present application, the emotion classification label can be set to eight categories, which are:
[0078] (1) Good (good);
[0079] (2) Happiness (joy);
[0080] (3) Sadness (sorrow);
[0081] (4) Fear (fear);
[0082] (5) Anger (anger);
[0083] (6) Disgust (disgust);
[0084] (7) Surprise (surprise);
[0085] (8) None (none).
[0086] Based on this, the emotion classification label corresponding to the text data mentioned in step 100 of the present application can be pre-labeled by humans; in order to further improve the efficiency and automation of training data processing, the emotion classification label corresponding to the text data can also be pre-determined through the mapping relationship between the emotion words in the text data and the emotion classification label, and the construction process of the mapping relationship is described in detail in subsequent embodiments.
[0087] In one or more embodiments of the present application, each of the emotion classification labels is provided with a prompt template, so that the above-mentioned step 100 of the present application can determine the emotion classification label of a text data and the prompt template uniquely corresponding to the emotion classification label, and then take the prompt template as the prompt template corresponding to the text data, and further extract the mask sample data corresponding to the text data according to the prompt template. It can be understood that the mask sample data can refer to the sample data formed by masking the emotion words in the text data, the determination results of whether each of the non-emotion sentences is the reason sentence corresponding to the emotion word, and the reason sentence.
[0088] That is, the "adaptive selection" mentioned in the embodiments of the present application refers to the fact that the text data corresponds to an emotion classification label, and the emotion classification label is provided with a unique corresponding prompt template, so that the emotion reason sentence pair prediction model of the present application can dynamically select one of the prompt templates corresponding to the emotion classification label in the multiple prompt templates according to the emotion classification label corresponding to the text data. Therefore, the embodiments of the present application design diversified prompt templates for different emotion categories, and can adaptively select the most suitable prompt template according to the prompted emotion category, so as to better guide the language model to understand and extract emotions and reasons.
[0089] Step 200: training a classifier based on each of the mask sample data, so as to train the classifier as an emotion reason sentence pair prediction model for predicting the emotion reason sentence pair of the text data, wherein the emotion reason sentence pair is used to represent the corresponding relationship between the emotion sentence and the reason sentence in the text data.
[0090] In step 200, the emotion reason sentence pair prediction model is used to output emotion reason sentence pair prediction result data, which is recorded as the predicted emotion reason sentence pair of the text data. The emotion reason sentence pair is used to represent the corresponding relationship between the emotion sentence and the reason sentence in the text data, which can be expressed in the manner of emotion sentence first and reason sentence second. In one example, the emotion reason sentence pair in the above-mentioned text data A is (c4, c2) and (c4, c3).
[0091] As can be known from the above description, the emotion-cause sentence pair prediction model training method provided in the embodiments of the present application can explicitly learn the relationship between emotions and causes in the text, can improve the diversity of the prompt template, can improve the adaptability, effectiveness and reliability of the emotion-cause sentence pair prediction model training process, can improve the robustness and generalization of the model, and can improve the accuracy of the emotion-cause sentence pair prediction result output by the emotion-cause sentence pair prediction model.
[0092] In order to improve the application effectiveness, flexibility and reliability of the prompt template, and to further realize dynamic selection of different prompt templates to better adapt to the classifier training, in the emotion-cause sentence pair prediction model training method provided in the embodiments of the present application, referring to Figure 5 , the emotion-cause sentence pair prediction model training method further specifically includes the following content before step 100:
[0093] Step 010: constructing a corresponding prompt template for each emotion classification label, wherein the prompt template includes an emotion template, a cause template and a relationship template; the emotion template is used to represent an emotion mask sentence corresponding to one emotion classification label, the emotion mask sentence is formed by masking the emotion word in the emotion sentence corresponding to the emotion classification label; the cause template is used to represent a cause determination result mask sentence corresponding to one emotion classification label, the cause determination result mask sentence is formed by masking the determination result of whether each non-emotion sentence in the text data is a cause sentence corresponding to the emotion word in the text data; the relationship template is used to represent a relationship mask sentence corresponding to one emotion classification label, the relationship mask sentence is a relationship expression sentence between the emotion classification label and the cause sentence after masking the non-emotion sentence associated with the emotion word in the text data; correspondingly, the masked sample data includes the emotion mask sentence, the cause determination result mask sentence and the relationship mask sentence.
[0094] Specifically, the emotion template in the prompt template (Initial Template) is used to represent an emotion mask sentence corresponding to one emotion classification label, which can be written as "implies the emotion of [MASK]" (implies the emotion of [MASK]), where [MASK] is used to mask the emotion word in the emotion sentence, and the emotion word corresponds to one emotion classification label corresponding to the prompt template. Therefore, in subsequent step 100, the content of [MASK] can be directly determined according to the clustering result data representing the one-to-many mapping relationship between each emotion classification label and each emotion word.
[0095] In one example, see Figure 6 ,by Figure 4 Taking text data A as an example, if the current emotion category label is Happiness, then the [MASK] in the emotion template "implies the emotion of [MASK]" in the initial template is used to mask the word "happy" in text data A. If the current emotion category label is Sadness, then the [MASK] in the emotion template "implies the emotion of [MASK]" in the initial template is used to mask the word "sad" in text data containing the emotion word "sad".
[0096] Specifically, the reason template in the initial template is used to represent a reason determination result mask statement corresponding to the emotion category label. This reason determination result mask statement can be written as "Feeling happiness, [MASK] because of the sentence." ([MASK] because of a non-emotional sentence.) Here, "happiness" can be replaced with other emotion category labels. Here, "sentence" refers to each non-emotional sentence in the text data after it has been split, excluding the emotional sentence. If there is only one non-emotional sentence remaining after removing the emotional sentence, then there is only one reason determination result mask statement. If there are multiple non-emotional sentences remaining after removing the emotional sentence, then there are multiple reason determination result mask statements. In the cause determination result mask statement, the [MASK] is used to mask the "yes" or "no" in the determination result of whether each non-emotional statement in the text data is the cause statement corresponding to the emotional word in the text data. Therefore, in the subsequent step 100, the content of [MASK] can be directly determined based on the clustering result data that represents the one-to-many mapping relationship between each emotion classification label and each emotion word.
[0097] In one example, see Figure 6 ,by Figure 4As shown in the text data A, if the current emotion classification label is Happiness (joy), the reason judgment result mask statement in the prompt template (Initial Template) contains “[MASK] because of the“(c1)Yesterday morning””,”[MASK] because of the“(c2)apoliceman visited the old man with the lost money””,”[MASK] because of the“(c3)and told him that the thief was caught””and“[MASK] because of the“(c5)anddeposited the money in the bank””. Among them, the non-emotion sentences c1 and c5 are not the reason sentences corresponding to the emotion word “happy”, therefore, the [MASK] in the reason judgment result mask statement corresponding to the non-emotion sentences c1 and c5 is used to mask the words such as “no” or “not” used to express negation; in contrast, the non-emotion sentences c2 and c3 are the reason sentences corresponding to the emotion word “happy”, therefore the [MASK] in the reason judgment result mask statement corresponding to the non-emotion sentences c2 and c3 is used to mask the words such as “yes” used to express affirmation.
[0098] Specifically, referring to Figure 6 , the relationship template in the prompt template (Initial Template) is used to represent a relationship mask statement corresponding to the emotion classification label, which can be written as “The implied happiness emotion is related to [MASK].” (The implied emotion corresponding to the emotion classification label happiness is related to [MASK]), where [MASK] is used to mask the non-emotion sentences in the text data associated with the emotion word, for example, the non-emotion sentences c1, c2 and c3 in the foregoing example are masked respectively.
[0099] Correspondingly, referring to Figure 6 , the text data A is shown as an example, the mask sample data corresponding to the text data A includes: Figure 4
[0100] (1) Emotion: “[CLS] implies [MASK] emotion, which belongs to happiness, [SEP] (happy / joy / excited…)”; wherein “(happy / joy / excited…)” is used to represent the emotion word masked by [MASK] in the sentence, and [CLS] and [SEP] are used to mark the beginning and end of the sentence, respectively.
[0101] (2) Cause: “[CLS] Feeling happiness, [MASK] because of the sentence. [SEP] (yes / no)”; wherein “(yes / no)” is used to represent the content masked by [MASK] in the sentence.
[0102] (3) Relation: “[CLS] The implied happiness emotion is related to [MASK]. [SEP] (cl, c2, c3…).” wherein “(cl, c2, c3….)” is used to represent the content masked by [MASK] in the sentence.
[0103] To ensure the richness and rationality of the emotion label words and make full use of the emotion category information, further improving the effectiveness and reliability of the emotion cause sentence pair prediction model training process, in the emotion cause sentence pair prediction model training method provided in the embodiments of the present application, referring to Figure 5 , the step 100 of the emotion cause sentence pair prediction model training method further specifically includes the following content:
[0104] Step 020: Perform clustering processing on each emotion word based on unsupervised learning to obtain clustering result data for representing a one-to-many mapping relationship between each emotion classification label and each emotion word.
[0105] Step 030: According to the clustering result data and the emotion words contained in each text data, respectively determine the emotion classification label corresponding to each text data.
[0106] Specifically, to ensure the richness and rationality of the emotion label words and make full use of the emotion category information, the embodiments of the present application perform clustering analysis on all emotion categories according to the existing sentiment lexicon ontology.
[0107] To further ensure the richness and rationality of the emotion label words and make full use of the emotion category information, in the emotion reason sentence pair prediction model training method provided in the embodiments of the present application, referring to Figure 7 , the step 020 of the emotion reason sentence pair prediction model training method specifically includes the following content:
[0108] Step 021: input each emotion word into a RoBERTa language model, so that the RoBERTa language model outputs an embedding vector corresponding to each emotion word respectively, and an embedding matrix composed of each embedding vector is obtained.
[0109] Specifically, the embedding vector of each emotion word w i is obtained through a RoBERTa language model such as Chinese-RoBERTa model, that is, each emotion word is input into the RoBERTa language model and the average value e i of the last hidden state is obtained, and the embedding vectors of all emotion words are integrated into an embedding matrix.
[0110] e i =mean(RoBERTa(w i ))#(1)
[0111] Step 022: taking each emotion classification label as a different cluster center, performing clustering processing on each emotion word based on a K-means clustering algorithm and the embedding matrix, so as to cluster each embedding vector into different clusters, obtaining a corresponding relationship between each emotion classification label uniquely corresponding to each cluster and each embedding vector in the cluster, and generating clustering result data for representing a one-to-many mapping relationship between each emotion classification label and each emotion word corresponding to each embedding vector.
[0112] Specifically, referring to Figure 8 , each emotion word can be contained in a pre-acquired emotion ontology dictionary (also written as emotion / gestalt ontology dictionary), and the K-means clustering algorithm (also written as K-means clustering) can be used to perform clustering processing on the embedding matrix to produce clusters corresponding to each emotion classification label, thereby forming clustering result data (also referred to as label mapper). The objective function J of K-means clustering is:
[0113]
[0114] wherein k represents the number of clusters, such as k=8; represents the i-th sample of the j-th cluster, μ j represents the centroid of the j-th cluster.
[0115] In an example, the clustering result data (also referred to as a label mapper) for representing a one-to-many mapping relationship between each emotion classification label and each corresponding emotion word of each embedding vector is shown in Table 1.
[0116] Table 1
[0117] Serial number Emotion classification label Emotion word 1 Good (good) grateful... (English words for expressing good) 2 Happiness (happy) Happiness, happy, excited... (English words for expressing happiness) 3 Sadness (sad) Sadness, sorry, sorrow, cry... (English words for expressing sadness) 4 Fear (fear) Fear, panic, scared, afraid... (English words for expressing fear) 5 Anger (anger) Anger, offended, annoyed... (English words for expressing anger) 6 Disgust (disgust) Disgust, terrible, bothered... (English words for expressing disgust) 7 Surprise (surprise) Surprise, shocked, startled... (English words for expressing surprise) 8 None (none) no (for expressing not belonging to the above 7 categories of labels)
[0118] Further, the existing research ignores the correlation and mutual assistance potential between the three sub-tasks of emotion extraction, cause extraction, and emotion-cause pair extraction, that is, although scholars have separately processed the three sub-tasks, they have not fully considered the internal relationship between the three sub-tasks, and have ignored the possible interaction and influence between them.
[0119] Based on this, in order to further integrate emotion information into the cause extraction process, and simultaneously integrate emotion and cause information into the emotion-cause pair matching task, thereby enhancing the correlation and assistance between the three sub-tasks and improving the overall prediction effect, in the emotion-cause sentence pair prediction model training method provided in the embodiments of the present application, the classifier includes a masked language model, a Bayesian network, and a multi-layer perception machine, and the output end of the masked language model is connected to the input end of the Bayesian network, and the output end of the Bayesian network is connected to the input end of the multi-layer perception machine.
[0120] Correspondingly, referring to Figure 5 or Figure 7 , the step 200 of the emotion-cause sentence pair prediction model training method specifically includes the following content:
[0121] Step 210: based on the masked language model, respectively extracting feature vectors from each of the emotion mask sentences, the cause determination result mask sentences, and the relationship mask sentences of each of the mask sample data, to obtain an emotion feature vector corresponding to each of the emotion mask sentences, a cause feature vector corresponding to each of the cause determination result mask sentences, and a relationship feature vector corresponding to each of the relationship mask sentences of each of the mask sample data.
[0122] Step 220: Iterate the Bayesian network and the multilayer perceptron multiple times using the emotion feature vector, cause feature vector and relation feature vector of each of the masked sample data. In each iteration, the emotion cause statement pairs corresponding to each of the text data are used as the labels of the masked sample data corresponding to each of the text data. Calculate the loss of the predicted result data of the emotion cause statement corresponding to the masked sample data output by the multilayer perceptron based on the labels of the masked sample data, and optimize the multilayer perceptron based on the loss.
[0123] The Bayesian network is used to extract features from the cause feature vector based on the emotion feature vector to obtain the target cause feature vector corresponding to the cause feature vector, and to extract features from the relationship feature vector based on the emotion feature vector and the cause feature vector to obtain the target relationship feature vector corresponding to the relationship feature vector. Then, it outputs the emotion feature vector, the target cause feature vector and the target relationship feature vector corresponding to each of the masked sample data respectively.
[0124] The multilayer perceptron is used to perform multivariate classification on the emotion feature vector, the target cause feature vector, and the target relationship feature vector corresponding to each of the masked sample data output by the Bayesian network, and outputs the prediction result data of the emotion cause statement corresponding to each of the masked sample data.
[0125] To further illustrate the above embodiments, this application also provides a specific application example of a method for training a prediction model based on emotion-cause clauses. This method involves the cross-disciplinary application of machine learning and deep learning technologies, and can also be described as a method for emotion analysis and causal reasoning generation in social contexts. It can better model the causal dependency between emotions and cause clauses from a semantic perspective. Therefore, the method of this application utilizes the semantic relationship between emotion-cause pairs and distinguishes pairs of different emotion categories. Based on the different categories of emotion-cause pairs, sub-cue templates are dynamically selected to better adapt to three different sub-tasks. At the same time, the correlation between emotion extraction and cause extraction tasks is considered, and emotion information and cause information are fused to improve the accuracy and efficiency of emotion-cause reasoning.
[0126] The application instance proposes an emotion reason sentence pair prediction model training method based on Bayesian and prompt learning. The emotion reason sentence pair prediction model can also be called an adaptive emotion reason reasoning model. Specifically, the emotion reason reasoning is finely divided into three sub-tasks, namely emotion analysis, reason reasoning, and emotion reason pairing, and a corresponding sub-prompt template is constructed for each sub-task. Further, unsupervised learning clustering is performed on commonly used Chinese or English emotion categories, and the corresponding prompt template is dynamically selected according to different emotion categories. Finally, considering the objective correlation between the emotion analysis and reason reasoning sub-tasks, a Bayesian network is used for sub-task modeling, the emotion information is explicitly added to the reason reasoning, and the emotion and reason information are added to the emotion reason pairing for hypothesis verification, thereby ensuring the accuracy and reasonableness of emotion analysis and reason reasoning.
[0127] The current emotion reason reasoning technical solution has the following problems:
[0128] (1) Deficiency of prompt learning: the existing prompt template is too single, which makes it difficult to effectively integrate different emotion categories, and the emotion information and reason information are not fully utilized to improve the performance of the task.
[0129] (2) Ignoring the correlation between tasks: existing methods often process emotion extraction, reason extraction, and emotion-reason pair extraction independently, ignoring the correlation and mutual assistance between the three, resulting in insufficient information utilization, as shown in the following formula: Figure 9
[0130] Based on this, the technical overall scheme of the application instance contains four technical points of prompt learning, density estimation clustering, Bayesian network, and language model imitation dialogue. The emotion reason sentence pair prediction model training method based on Bayesian and prompt learning proposed by the application instance finely divides the emotion reason reasoning into three sub-tasks, namely emotion analysis, reason reasoning, and emotion reason pairing, and constructs a corresponding sub-prompt template for each sub-task. Further, unsupervised learning clustering is performed on commonly used Chinese and English emotion categories, and the corresponding prompt template is dynamically selected according to different emotion categories. Finally, considering the objective correlation between the emotion analysis and reason reasoning sub-tasks, a Bayesian network is used for sub-task modeling, the emotion information is explicitly added to the reason reasoning, and the emotion and reason information are added to the emotion reason pairing for hypothesis verification, thereby ensuring the accuracy and reasonableness of emotion analysis and reason reasoning.
[0131] Referring to Figure 10 The emotion reason sentence pair prediction model training method based on Bayesian and hint learning proposed by the application application instance specifically includes the following contents:
[0132] S1, corpus preprocessing, generating corresponding text semantic vectors for common emotion words / reason words / sentence numbers, etc., providing a basic semantic expression for subsequent reasoning.
[0133] In step S1, the corpus contains a plurality of typical events (Chinese) counted by a social media platform, a plurality of typical stories (English) collected in a biography, and a plurality of pairs of emotion reason sentence numbers. Among them, the candidate emotion and possible reason are described by a digital vector and a language label together, the digital vector corresponds to the emotion reason word in the corpus, and the sequence number of the single sentence where the emotion reason is located is used as the generation result of the model to judge the reasoning effect and speed of the model on the implied emotion reason in the text.
[0134] S2, introduce external knowledge base, use density estimation unsupervised clustering learning to optimize language model, improve the understanding ability of the model to the relationship between emotion and reason.
[0135] In step S2, the text semantic vectors of the keywords (emotion, reason and related person event) processed by the pre-trained language model Transformer and the target feature vectors of the sentence sequence numbers obtained by using the pointer network are combined to infer the possible candidate pairs of emotion sentences and reason sentences. Specifically, by means of social media emotion ontology library (Chinese) and character biography emotion ontology library (English), the idea of unsupervised clustering learning is used to count and sort common emotion words in Chinese and English, and the Chinese and English emotion word groups are mapped into the hint template of the language model to enhance the understanding and reasoning ability of the language model to the reason and emotion.
[0136] S3, considering the variable situation in emotion reason reasoning, modeling the logical relationship between emotion and reason by using Bayesian network, so as to effectively handle the evolving situation dependence in many aspects.
[0137] Wherein, w1, w2 and w3 represent different emotion words respectively, b1, b2 and b3 represent feature vectors corresponding to different emotion words respectively; C bys represents the reason feature vector output by the Bayesian network; R bys represents the relationship feature vector output by the Bayesian network, and [M]r represents the emotion reason sentence pair output by the emotion reason sentence pair prediction model.
[0138] In step S3, due to the variability of emotion reason and the uncertainty of context, the candidate emotion reason pairs generated by reasoning have obvious error and accidental correctness, therefore, the Bayesian network is proposed to hypothesis and verify the reasoning process before and after the emotion vector and the reason vector to ensure the accuracy of the result.
[0139] S4, compare and sort the candidate emotion reason sentence pairs in each data document to generate a maximum possibility emotion reason sentence pair vector, and finally use a classifier to obtain an emotion reason sentence pair.
[0140] In step S4, the multi-class emotion and corresponding reason are classified and paired using a multi-layer perception to obtain the final reasoning generation result.
[0141] Among them, the improvement contents provided by the application examples are as follows:
[0142] (1) Unsupervised clustering learning emotion dictionary: In order to ensure the richness and rationality of the emotion label words, and make full use of the emotion category information, the existing emotion vocabulary ontology is used to perform clustering analysis on all emotion categories.
[0143] (2) Adaptive selection of prompt templates: Different prompt templates are designed for different emotion categories, and the most suitable prompt template is adaptively selected according to the prompted emotion category, so as to better guide the language model to understand and extract emotions and reasons.
[0144] (3) Bayesian network modeling: The emotion information is integrated into the reason extraction process, and the emotion and reason information are integrated into the pairing task of the emotion reason pair, so as to enhance the relevance and auxiliary between the three sub-tasks, and improve the overall prediction effect.
[0145] Through the above three technical points, on the basis of the feasibility of large model automatic test, the idea of enhancing student model by teacher model is used, and the language model is used to simulate real dialogue, that is, human-computer interaction, so as to more flexibly and realistically identify and reason the dynamic emotion change and its reason in multi-round interaction, and provide an effective solution and measure for dialogue emotion reason analysis and reasoning in complex interaction scene. That is, through corpus preprocessing, external knowledge base optimization and Bayesian network modeling, the application examples of the present application significantly improve the understanding ability of the relationship between emotions and reasons, can effectively handle evolving situational dependence in variable situations, and finally generate understandable and explainable emotion reason sentence pairs.
[0146] Based on the foregoing embodiment of the emotion reason sentence pair prediction model training method, the present application further provides an embodiment of an emotion reason sentence pair prediction method which can be executed by an emotion reason sentence pair prediction device, and the emotion reason sentence pair prediction method specifically comprises the following contents:
[0147] Step 300: adaptively selecting the prompt template corresponding to the target text data according to the emotion classification label corresponding to the target text data and the prompt template corresponding to the emotion classification label, to extract the mask sample data corresponding to the target text data; wherein the target text data contains an emotion sentence where an emotion word is located and a plurality of non-emotion sentences, and at least one of each non-emotion sentence is a reason sentence corresponding to the emotion word.
[0148] Step 400: inputting the mask sample data corresponding to the target text data into an emotion-reason sentence pair prediction model, so that the emotion-reason sentence pair prediction model outputs the emotion-reason sentence pair corresponding to the target text data; wherein the emotion-reason sentence pair prediction model is obtained by pre-training based on the emotion-reason sentence pair prediction model training method.
[0149] The emotion-reason sentence pair prediction model training method mentioned in step 400 in the embodiments of the emotion-reason sentence pair prediction method provided by the present application can be used to execute the processing flow of the embodiments of the emotion-reason sentence pair prediction model training method in the above embodiments, and the functions thereof will not be repeated here. Please refer to the detailed description of the above emotion-reason sentence pair prediction model training method embodiments.
[0150] From the software level, the present application also provides an emotion-reason sentence pair prediction model training device for executing all or part of the emotion-reason sentence pair prediction model training method, which specifically includes the following contents:
[0151] The first adaptive mask module is configured to adaptively select the prompt template corresponding to each text data according to the emotion classification label corresponding to each text data and the prompt template corresponding to each emotion classification label, to extract the mask sample data corresponding to each text data, respectively; wherein the text data contains an emotion sentence where an emotion word is located and a plurality of non-emotion sentences, and at least one of each non-emotion sentence is a reason sentence corresponding to the emotion word.
[0152] The classifier training module is configured to train a classifier based on each mask sample data, to train the classifier as an emotion-reason sentence pair prediction model for predicting an emotion-reason sentence pair of text data, wherein the emotion-reason sentence pair is used to represent the corresponding relationship between an emotion sentence and a reason sentence in text data.
[0153] The embodiment of the mood reason sentence pair prediction model training device provided in the present application can be specifically used for executing the processing flow of the embodiment of the mood reason sentence pair prediction model training method in the above-mentioned embodiments, and the functions thereof will not be repeated here. Please refer to the detailed description of the embodiment of the mood reason sentence pair prediction model training method.
[0154] The part of the mood reason sentence pair prediction model training device for performing mood reason sentence pair prediction model training can be completed in a server or a client device. Specifically, it can be selected according to the processing capability of the client device, the limitation of the user's use scenario, and the like. The present application does not limit this. If all operations are completed in the client device, the client device can further include a processor for specific processing of mood reason sentence pair prediction model training.
[0155] The above-mentioned client device can have a communication module (i.e., a communication unit) and can be communicatively connected with a remote server to realize data transmission with the server. The server can include a server of a task scheduling center side, and can also include a server of an intermediate platform in other implementation scenarios, such as a server of a third-party server platform communicatively connected with the server of the task scheduling center. The server can include a single computer device, or a server cluster composed of multiple servers, or a server structure of a distributed device.
[0156] The server and the client device can use any suitable network protocol for communication, including a network protocol that has not been developed at the filing date of the present application. The network protocol can include, for example, TCP / IP protocol, UDP / IP protocol, HTTP protocol, HTTPS protocol, and the like. Of course, the network protocol can also include, for example, RPC protocol (Remote Procedure Call Protocol) and REST protocol (Representational State Transfer) used on the above-mentioned protocols.
[0157] From the software level, the present application further provides a mood reason sentence pair prediction device for executing all or part of the mood reason sentence pair prediction method, and the mood reason sentence pair prediction device specifically includes the following contents:
[0158] The second adaptive mask module is configured to adaptively select the prompt template corresponding to the target text data according to the emotion classification label corresponding to the target text data and the prompt template corresponding to the emotion classification label, so as to extract the mask sample data corresponding to the target text data; wherein the target text data comprises an emotion sentence in which an emotion word is located and a plurality of non-emotion sentences, and at least one of the non-emotion sentences is a reason sentence corresponding to the emotion word.
[0159] The model prediction module is configured to input the mask sample data corresponding to the target text data into an emotion-reason-sentence pair prediction model, so that the emotion-reason-sentence pair prediction model outputs an emotion-reason-sentence pair corresponding to the target text data; wherein the emotion-reason-sentence pair prediction model is obtained by pre-training based on the emotion-reason-sentence pair prediction model training method mentioned in the foregoing embodiments.
[0160] The embodiments of the present application also provide an electronic device, which can comprise a processor, a memory, a receiver and a transmitter. The processor is configured to execute the emotion-reason-sentence pair prediction model training method and / or the emotion-reason-sentence pair prediction method mentioned in the foregoing embodiments. The processor and the memory can be connected by a bus or other means, and the connection by the bus is taken as an example. The receiver can be connected with the processor and the memory by wired or wireless means.
[0161] The processor can be a central processing unit (CPU). The processor can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, or combinations thereof.
[0162] The memory is a non-transitory computer readable storage medium, which can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as the program instructions / modules corresponding to the emotion-reason-sentence pair prediction model training method and / or the emotion-reason-sentence pair prediction method in the embodiments of the present application. The processor executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory, that is, implements the emotion-reason-sentence pair prediction model training method and / or the emotion-reason-sentence pair prediction method in the foregoing method embodiments.
[0163] The memory can include a program storage area and a data storage area. The program storage area can store an operating system and applications required by at least one function. The data storage area can store data created by the processor and the like. In addition, the memory can include a high-speed random access memory and can also include a non-transitory memory such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid state memory device. In some embodiments, the memory can optionally include a memory that is remotely located with respect to the processor, which can be connected to the processor through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0164] The one or more modules are stored in the memory and, when executed by the processor, perform the emotion cause sentence pair prediction model training method and / or the emotion cause sentence pair prediction method in the embodiments.
[0165] In some embodiments of the present application, a user equipment can include a processor, a memory, and a transceiver unit that can include a receiver and a transmitter. The processor, the memory, the receiver, and the transmitter can be connected through a bus system. The memory is configured to store computer instructions, and the processor is configured to execute the computer instructions stored in the memory to control the transceiver unit to transceive signals.
[0166] As an implementation manner, the functions of the receiver and the transmitter in the present application can be implemented by a transceiver circuit or a transceiver dedicated chip. The processor can be implemented by a dedicated processing chip, a processing circuit, or a general-purpose chip.
[0167] As another implementation manner, the server provided by the embodiments of the present application can be implemented by using a general-purpose computer. That is, program codes for implementing the functions of the processor, the receiver, and the transmitter are stored in the memory, and the general-purpose processor implements the functions of the processor, the receiver, and the transmitter by executing the codes in the memory.
[0168] The embodiments of the present application also provide a computer readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the emotion cause sentence pair prediction model training method and / or the emotion cause sentence pair prediction method are implemented. The computer readable storage medium can be a tangible storage medium such as a random access memory (RAM), an internal memory, a read only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a floppy disk, a hard disk, a removable memory disk, a CD-ROM, or any other form of storage medium known in the technical field.
[0169] The embodiment of the present application further provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the aforementioned mood reason phrase pair prediction model training method and / or mood reason phrase pair prediction method.
[0170] Those of ordinary skill in the art will appreciate that the various illustrative components, systems and methods described in connection with the embodiments disclosed herein can be implemented as hardware, software, or a combination thereof. The various illustrative components, systems and methods disclosed herein can be implemented in the absence of any software. The actual software code with which the various illustrative components, systems and methods are implemented will vary depending on the particular application and the overall design constraints imposed on the overall system. Those of ordinary skill in the art will appreciate that different software codes can be used to carry out the described functions, and that they will produce the same or similar results. Moreover, the software itself can be presented in a variety of forms and organized in various ways. For example, the software can be organized in an object-oriented format, or it can be organized in a procedural format, or it can be organized in some other organizational structure. The software can also be presented for use on one or more computer-readable media, which can be volatile or non-volatile media, or a combination thereof. The computer-readable media can include, but is not limited to, magnetic storage media, optical storage media, and / or any other tangible medium that can be used to carry out the described functions.
[0171] It is to be understood that the specific configuration and processing described above and illustrated in the drawings is merely exemplary. For the sake of brevity, detailed descriptions of known methods and procedures are omitted so as to avoid obscuring the application. In the above embodiments, several specific steps are described and illustrated as examples. However, the method processes of the present application are not limited to the specific steps described and illustrated, and one of ordinary skill in the art will appreciate that various changes, modifications and additions can be made thereto, or the order of steps can be changed, without departing from the spirit of the present application.
[0172] In the present application, features described and / or illustrated with respect to one embodiment can be used in the same or a similar way in one or more other embodiments, and / or in combination with or in place of features of other embodiments.
[0173] The above only describes the preferred embodiments of the present application and is not intended to limit the present application. The embodiments of the present application can be variously changed and modified by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for training a predictive model of emotion-cause statements, characterized in that, include: Based on the emotion classification label corresponding to each text data and the prompt template corresponding to each emotion classification label, the prompt template corresponding to each text data is adaptively selected to extract the mask sample data corresponding to each text data respectively; wherein, the text data contains emotional sentences containing emotion words and multiple non-emotion sentences, and at least one of the non-emotion sentences is the reason sentence corresponding to the emotion word; A classifier is trained based on each of the masked sample data to become a prediction model for emotion-cause-cause pairs in text data, wherein the emotion-cause-cause pairs represent the correspondence between emotion statements and cause statements in the text data; the classifier includes a masked language model, a Bayesian network, and a multilayer perceptron, and the output of the masked language model is connected to the input of the Bayesian network, and the output of the Bayesian network is connected to the input of the multilayer perceptron; Correspondingly, the step of training a classifier based on each of the masked sample data to train the classifier into a mood cause statement pair prediction model for predicting mood cause statement pairs in text data includes: Based on the mask language model, feature vectors are extracted from the emotion mask statement, cause determination result mask statement, and relationship mask statement of each mask sample data to obtain the emotion feature vector corresponding to the emotion mask statement, the cause feature vector corresponding to the cause determination result mask statement, and the relationship feature vector corresponding to the relationship mask statement of each mask sample data. The Bayesian network and the multilayer perceptron are iterated multiple times using the emotion feature vector, cause feature vector, and relation feature vector of each of the masked sample data. In each iteration, the emotion cause statement pairs corresponding to each of the text data are used as the labels of the masked sample data corresponding to each of the text data. The loss of the emotion cause statement corresponding to the masked sample data output by the multilayer perceptron on the prediction result data is calculated based on the labels of the masked sample data, and the multilayer perceptron is optimized based on the loss.
2. The method for training a prediction model for emotion-cause statements according to claim 1, characterized in that, Before the step of adaptively selecting the prompt template corresponding to each text data based on the emotion classification label corresponding to each text data and the prompt template corresponding to each emotion classification label to extract the mask sample data corresponding to each text data, the method further includes: Construct corresponding prompt templates for each emotion category label, wherein the prompt templates include emotion templates, cause templates, and relationship templates; The emotion template is used to represent an emotion mask statement corresponding to an emotion category label. The emotion mask statement is formed by masking the emotion words in the emotion statement that correspond to the emotion category label. The reason template is used to represent a reason determination result mask statement corresponding to an emotion classification label. The reason determination result mask statement is formed by masking the determination results of whether each non-emotion statement in the text data is a reason statement corresponding to an emotion word in the text data. The relation template is used to represent a relation mask statement corresponding to an emotion category label. The relation mask statement is a statement expressing the relationship between the emotion category label and the masked cause statement after masking the non-emotion statements associated with the emotion words in the text data. Correspondingly, the mask sample data includes: the emotion mask statement, the cause determination result mask statement, and the relationship mask statement.
3. The method for training a prediction model for emotion-cause statements according to claim 1, characterized in that, Before the step of adaptively selecting the prompt template corresponding to each text data based on the emotion classification label corresponding to each text data and the prompt template corresponding to each emotion classification label to extract the mask sample data corresponding to each text data, the method further includes: Clustering based on unsupervised learning is performed on each emotion word to obtain clustering result data that represents the one-to-many mapping relationship between each emotion classification label and each emotion word. Based on the clustering results and the emotion words contained in each text data, the emotion classification label corresponding to each text data is determined.
4. The method for training a prediction model of emotion-cause statements according to claim 3, characterized in that, The unsupervised learning-based clustering process for each emotion word to obtain clustering result data representing the one-to-many mapping relationship between each emotion classification label and each emotion word includes: Each emotion word is input into the RoBERTa language model so that the RoBERTa language model outputs the embedding vector corresponding to each emotion word and obtains the embedding matrix composed of each embedding vector. Using preset emotion classification labels as different cluster centers, the emotion words are clustered based on the K-means clustering algorithm and the embedding matrix, so that each embedding vector is clustered into different clusters. This yields a unique correspondence between the emotion classification label and each embedding vector in each cluster, and generates clustering result data to represent the one-to-many mapping relationship between each emotion classification label and the emotion words corresponding to each embedding vector.
5. The method for training a prediction model of emotion-cause statements according to claim 1, characterized in that, The Bayesian network is used to extract features from the cause feature vector based on the emotion feature vector to obtain the target cause feature vector corresponding to the cause feature vector, and to extract features from the relationship feature vector based on the emotion feature vector and the cause feature vector to obtain the target relationship feature vector corresponding to the relationship feature vector, and then outputs the emotion feature vector, the target cause feature vector and the target relationship feature vector corresponding to each of the masked sample data respectively.
6. The method for training a prediction model for emotion-cause statements according to claim 5, characterized in that, The multilayer perceptron is used to perform multivariate classification on the emotion feature vector, the target cause feature vector, and the target relationship feature vector corresponding to each of the masked sample data output by the Bayesian network, and outputs the prediction result data of the emotion cause statement corresponding to each of the masked sample data.
7. A method for predicting emotional cause statements, characterized in that, include: Based on the emotion classification label corresponding to the target text data and the prompt template corresponding to the emotion classification label, the prompt template corresponding to the target text data is adaptively selected to extract the mask sample data corresponding to the target text data; wherein, the target text data contains emotional sentences containing emotion words and multiple non-emotion sentences, and at least one of the non-emotion sentences is the reason sentence corresponding to the emotion word; The masked sample data corresponding to the target text data is input into the emotion cause statement pair prediction model, so that the emotion cause statement pair prediction model outputs the emotion cause statement pair corresponding to the target text data; wherein, the emotion cause statement pair prediction model is pre-trained based on the emotion cause statement pair prediction model training method according to any one of claims 1 to 6.
8. 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 computer program, it implements the emotional cause statement pair prediction model training method as described in any one of claims 1 to 6, and / or implements the emotional cause statement pair prediction method as described in claim 7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the emotional cause statement pair prediction model training method as described in any one of claims 1 to 6, and / or implements the emotional cause statement pair prediction method as described in claim 7.
Citation Information
Patent Citations
Trusted network false information identification method and device
CN118747221A
KR20220140260A