Emotion reason statement pair prediction model training method, prediction method and equipment

By adaptively selecting prompt templates and using a Bayesian network with multi-layer perceptron for feature extraction, the method addresses the limitations of existing emotion cause extraction methods, improving the accuracy and robustness of emotion cause pair prediction.

CN120316262AActive Publication Date: 2025-07-15BEIJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202510435017.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-08
Publication Date
2025-07-15
Estimated Expiration
2045-04-08

AI Technical Summary

Technical Problem

In the Existing Emotional Causes, the model lacks performance in capturing and understanding the complex relationship between emotions and causes, lacks robustness and generalization, and fails to make full use of emotion type information, resulting in insufficient accuracy of prediction results.

Method used

Through adaptive selection of prompt templates, based on emotion classification labels and clustering processing of unsupervised learning, emotions, reasons and relationship templates are constructed, and the classifier is trained using mask language model, Bayesian network and multi-layer perceptron to explicitly learn the relationship between emotions and causes, and improve the adaptability and accuracy of the model.

Benefits of technology

The relationship between emotions and causes is explicitly learned, which improves the robustness and generalization of the model, enhances the accuracy of emotional causes for prediction results, and adapts to the diverse needs of different emotional categories.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120316262A_ABST
    Figure CN120316262A_ABST
Patent Text Reader

Abstract

The invention provides an emotion reason statement pair prediction model training method, prediction method and equipment, and the training method comprises the steps: obtaining a prediction model according to emotion classification tags corresponding to text data and prompt templates corresponding to the emotion classification tags; adaptively selecting a prompt template of each piece of text data to respectively extract mask sample data of each piece of text data; the text data comprises an emotional statement where the emotional word is located and a plurality of non-emotional statements, and at least one of the non-emotional statements is a reason statement corresponding to the emotional word; and training a classifier based on each piece of mask sample data so as to train the classifier into an emotional reason statement pair prediction model used for predicting emotional reason statement pairs of the text data. According to the method, the relation between the emotion and the reason in the text can be learned explicitly, the diversity of the prompt template can be improved, the adaptability, effectiveness and reliability of the emotion reason statement to the prediction model training process can be improved, and then the robustness and generalization of the model can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of text data processing, and in particular to a method, a prediction method, and a device for training an emotion cause statement pair prediction model. Background Art

[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 the text. However, emotion cause extraction requires prior annotation of emotions in order to extract the corresponding cause clauses. Therefore, some scholars have redefined this task, namely 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 models, more and more researchers have proposed new methods, such as sequence labeling method, machine reading comprehension method, prompting learning method, etc. Among them, the method using prompting learning was proposed in the past two or three years.

[0003] Currently, some scholars have proposed using the prompting tuning method for the emotion cause pair extraction task. By decomposing the task into three subtasks: emotion extraction, cause extraction, and emotion cause pair extraction, and adding a unified prompting template, it is possible to solve the problems of implicit relationship modeling and dependence on position information or dataset bias.

[0004] However, the existing emotion cause pair extraction tasks using the prompting tuning method implicitly learn the relationship between emotions and causes, which may lead to insufficient performance of the model in capturing and understanding the complex relationship between emotions and causes. At the same time, some methods rely on position information or dataset bias (as Figure 1 shown, the cause clause is usually located near the emotion clause; as Figure 2 shown, studying the influence of different document lengths on the model's inference of emotions and causes), making the model lack robustness and generalization ability. In addition, these methods also fail to make full use of emotion type information, resulting in the problems of insufficient robustness and generalization ability of the existing prediction model using the prompting tuning method and insufficient accuracy of the emotion cause pair extraction results. Summary of the Invention

[0005] In view of this, the embodiments of the present application provide a method, a prediction method, and a device for training an emotion cause statement pair prediction model to eliminate or improve one or more defects existing in the prior art.

[0006] One aspect of the present application provides a method for training an emotion cause statement pair prediction model, including:

[0007] According to the emotion classification labels corresponding to each text data and the prompt templates corresponding to each of the emotion classification labels, adaptively select the prompt templates corresponding to each text data to respectively extract the masked sample data corresponding to each text data; wherein, the text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of the non-emotion statements is a reason statement corresponding to the emotion word.

[0008] Train a classifier based on each of the masked sample data to train the classifier into an emotion reason statement pair prediction model for predicting the emotion reason statement pair of text data, where the emotion reason statement pair is used to represent the corresponding relationship between the emotion statement and the reason statement in the text data.

[0009] In some embodiments of the present application, before the step of adaptively selecting the prompt templates corresponding to each text data according to the emotion classification labels corresponding to each text data and the prompt templates corresponding to each of the emotion classification labels to respectively extract the masked sample data corresponding to each text data, it further includes:

[0010] Construct corresponding prompt templates for each emotion classification label, where the prompt template includes an emotion template, a reason template, and a relationship template.

[0011] The emotion template is used to represent an emotion masked statement corresponding to an emotion classification label, and the emotion masked statement is formed by masking the emotion word corresponding to the emotion classification label in the emotion statement.

[0012] The reason template is used to represent a reason determination result masked statement corresponding to an emotion classification label, and the reason determination result masked statement is formed by masking the determination results of whether each non-emotion statement in the text data is a reason statement corresponding to the emotion word in the text data.

[0013] The relationship template is used to represent a relationship masked statement corresponding to an emotion classification label, and the relationship masked statement is a relationship expression statement between the emotion classification label and the masked reason statement formed by masking the non-emotion statement associated with the emotion word in the text data.

[0014] Correspondingly, the masked sample data includes: the emotion masked statement, the reason determination result masked statement, and the relationship masked statement.

[0015] In some embodiments of the present application, before adaptively selecting the hint templates corresponding to each text data according to the emotion classification labels corresponding to each text data and the hint templates corresponding to each emotion classification label, respectively, to extract the masked sample data corresponding to each text data, it further includes:

[0016] Performing clustering processing on each emotion word based on unsupervised learning to obtain clustering result data for representing the many-to-one mapping relationship between each emotion classification label and each emotion word;

[0017] Determining the emotion classification label corresponding to each text data according to the clustering result data and the emotion words included in each text data.

[0018] In some embodiments of the present application, the performing clustering processing on each emotion word based on unsupervised learning to obtain clustering result data for representing the many-to-one mapping relationship between each emotion classification label and each emotion word includes:

[0019] Inputting each emotion word into the RoBERTa language model respectively, so that the RoBERTa language model outputs the embedding vectors corresponding to each emotion word respectively, and obtaining an embedding matrix composed of each embedding vector;

[0020] Using each preset emotion classification label as a different cluster center respectively, performing clustering processing on each emotion word based on the K-means clustering algorithm and the embedding matrix, so as to cluster each embedding vector into different clusters, obtaining the corresponding relationship between the emotion classification label uniquely corresponding to each cluster and each embedding vector in the cluster, and generating clustering result data for representing the many-to-one mapping relationship between each emotion classification label and each emotion word corresponding to each embedding vector.

[0021] In some embodiments of the present application, the classifier includes a masked language model, a Bayesian network, and a multi-layer perceptron, 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 perceptron;

[0022] Correspondingly, training the classifier based on each masked sample data to train the classifier into an emotion cause statement pair prediction model for predicting the emotion cause statement pair of text data includes:

[0023] Based on the masked language model, feature vectors are respectively extracted from the emotion masked statements, the cause determination result masked statements, and the relationship masked statements of each of the masked sample data, so as to obtain the emotion feature vectors corresponding to the emotion masked statements of each of the masked sample data, the cause feature vectors corresponding to the cause determination result masked statements, and the relationship feature vectors corresponding to the relationship masked statements;

[0024] The Bayesian network and the multi-layer perceptron are iterated multiple rounds using the emotion feature vectors, the cause feature vectors, and the relationship feature vectors of each of the masked sample data. In each iteration round, the emotion-cause statement pairs corresponding to each of the text data are respectively used as the labels of the masked sample data corresponding to each of the text data. The loss of the prediction result data of the emotion-cause statement pair corresponding to the masked sample data output by the multi-layer perceptron is calculated according to the labels of the masked sample data, and the multi-layer perceptron is optimized based on this loss.

[0025] In some embodiments of the present application, the Bayesian network is used to extract features from the cause feature vectors based on the emotion feature vectors to obtain the target cause feature vectors corresponding to the cause feature vectors, and to extract features from the relationship feature vectors based on the emotion feature vectors and the cause feature vectors to obtain the target relationship feature vectors corresponding to the relationship feature vectors, and then respectively output the emotion feature vectors, the target cause feature vectors, and the target relationship feature vectors corresponding to each of the masked sample data.

[0026] In some embodiments of the present application, the multi-layer perceptron is used to perform multi-class classification on the emotion feature vectors, the target cause feature vectors, and the target relationship feature vectors respectively output by the Bayesian network for each of the masked sample data, and respectively output the prediction result data of the emotion-cause statement pairs corresponding to each of the masked sample data.

[0027] The second aspect of the present application provides a method for predicting emotion-cause statement pairs, including:

[0028] According to 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 masked sample data corresponding to the target text data; wherein, the target text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of the non-emotion statements is the cause statement corresponding to the emotion word;

[0029] Input the masked sample data corresponding to the target text data into the emotion cause statement pair prediction model, so that the emotion cause statement pair prediction model correspondingly 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 provided in the foregoing first aspect.

[0030] The third aspect of the present application provides an emotion cause statement pair prediction model training device, including:

[0031] A first adaptive masking module, configured to adaptively select the hint template corresponding to each text data according to the emotion classification label corresponding to each text data and the hint template corresponding to each emotion classification label, so as to extract the masked sample data corresponding to each text data respectively; wherein, the text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of each non-emotion statement is the reason statement corresponding to the emotion word.

[0032] A classifier training module, configured to train a classifier based on each masked sample data, so as to train the classifier into an emotion cause statement pair prediction model for predicting the emotion cause statement pair of text data, wherein the emotion cause statement pair is used to represent the corresponding relationship between the emotion statement and the reason statement in the text data.

[0033] The fourth aspect of the present application provides an emotion cause statement pair prediction device, including:

[0034] A second adaptive masking module, configured to adaptively select the hint template corresponding to the target text data according to the emotion classification label corresponding to the target text data and the hint template corresponding to the emotion classification label, so as to extract the masked sample data corresponding to the target text data; wherein, the target text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of each non-emotion statement is the reason statement corresponding to the emotion word.

[0035] A model prediction module, configured to input the masked sample data corresponding to the target text data into the emotion cause statement pair prediction model, so that the emotion cause statement pair prediction model correspondingly 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.

[0036] The fifth aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the method for training the prediction model of the emotional cause statement pair is implemented, and / or the method for predicting the emotional cause statement pair is implemented.

[0037] The sixth aspect of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method for training the prediction model of the emotional cause statement pair is implemented, and / or the method for predicting the emotional cause statement pair is implemented.

[0038] The seventh aspect of the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the method for training the prediction model of the emotional cause statement pair is implemented, and / or the method for predicting the emotional cause statement pair is implemented.

[0039] The method for training the prediction model of the emotional cause statement pair provided by the present application adaptively selects the hint template corresponding to each text data according to the emotional classification label corresponding to each text data and the hint template corresponding to each emotional classification label to respectively extract the masked sample data corresponding to each text data; wherein, the text data includes an emotional statement where an emotional word is located and multiple non-emotional statements, and at least one of each non-emotional statement is a cause statement corresponding to the emotional word; based on each masked sample data, a classifier is trained to train the classifier into an emotional cause statement pair prediction model for predicting the emotional cause statement pair of the text data, where the emotional cause statement pair is used to represent the corresponding relationship between the emotional statement and the cause statement in the text data, can explicitly learn the relationship between emotions and causes in the text, can improve the diversity of hint templates, can improve the adaptability, effectiveness, and reliability of the training process of the emotional cause statement pair prediction model, and further can improve the robustness and generalization of the model, so as to improve the accuracy of the prediction result of the emotional cause statement pair output by the emotional cause statement pair prediction model.

[0040] Additional advantages, objects, and features of the present application will be partially described below, and will become partially apparent to those of ordinary skill in the art after studying the following. Or they can be learned through the practice of the present application. The objects and other advantages of the present application can be realized and obtained through the structure specifically pointed out in the specification and the drawings.

[0041] Those skilled in the art will understand that the objects and advantages that can be achieved by the present application are not limited to the above specific descriptions, and the above and other objects that the present application can achieve will be more clearly understood according to the following detailed description. Description of the Drawings

[0042] The accompanying drawings described herein are used to provide a further understanding of the present application, form a part of the present application, and do not limit the present application. The components in the drawings are not drawn to scale, but are only for showing the principles of the present application. For the convenience of showing and describing some parts of the present application, the corresponding parts in the drawings may be enlarged, that is, may become larger relative to other components in the exemplary device actually manufactured according to the present application. In the drawings:

[0043] Figure 1 It is a schematic diagram of the relative distance distribution of pairs composed of emotional clauses and causal clauses in the ECPE dataset in the prior art.

[0044] Figure 2 It is a schematic diagram of the influence of different lengths of research documents on the model extraction results in the prior art.

[0045] Figure 3 It is the first schematic flowchart of the method for training an emotional cause statement pair prediction model in an embodiment of the present application.

[0046] Figure 4 It is an example schematic diagram of text data A in an embodiment of the present application.

[0047] Figure 5 It is the second schematic flowchart of the method for training an emotional cause statement pair prediction model in an embodiment of the present application.

[0048] Figure 6 It is an example schematic diagram of obtaining masked sample data of text data A by using a prompt template in an embodiment of the present application.

[0049] Figure 7 It is the third schematic flowchart of the method for training an emotional cause statement pair prediction model in an embodiment of the present application.

[0050] Figure 8 It is an example schematic diagram of unsupervised clustering learning in an embodiment of the present application.

[0051] Figure 9 It is a schematic diagram of the prior art ignoring the correlation between the three tasks of emotion, cause, and their relationship pairing.

[0052] Figure 10 It is a schematic diagram of the technical architecture of the method for training an emotional cause statement pair prediction model based on Bayesian and prompt learning provided for the application example of the present application. Detailed implementation manners

[0053] To make the objectives, technical solutions and advantages of this application more clear and understandable, the following further elaborates on this application in conjunction with the embodiments and the accompanying drawings. Herein, the illustrative embodiments of this application and their descriptions are used to explain this application, but do not limit this application.

[0054] Herein, it should also be noted that in order to avoid obscuring this application with unnecessary details, only the structures and / or processing steps closely related to the solution of this application are shown in the drawings, while other details less relevant to this application are omitted.

[0055] It should be emphasized that the term "including / containing" when used herein refers to the presence of features, elements, steps or components, but does not exclude the presence or addition of one or more other features, elements, steps or components.

[0056] Herein, it should also be noted that if not otherwise specified, the term "connection" in this text can not only refer to a direct connection, but also represent an indirect connection with an intermediate.

[0057] In the following, embodiments of this application will be described with reference to the 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 are dedicated to the analysis of the emotional polarity of text, that is, determining whether the emotion is positive or negative, which is of great significance and value for applications such as social media traffic monitoring, customer opinion feedback analysis, and mental health assessment recommendations. However, the process of delving into the reasons behind the emotions is lacking. Subsequently, the research focus of emotion analysis has shifted to determining the reasons behind the emotions, rather than just discovering whether the emotion is positive or negative. The main goal of ECE is to determine the reasons for a given emotion expressed in the text. However, emotion cause extraction requires prior annotation of the emotion in order to extract the corresponding cause clauses. Therefore, some scholars have redefined this task, namely emotion cause pair extraction (ECPE), which directly extracts all potential emotion clauses and corresponding cause clauses from unannotated documents.

[0059] Currently, in the ECPE task, in addition to the traditional two-step method and end-to-end models, more and more researchers have proposed new methods, such as sequence labeling method, machine reading comprehension method, prompting learning method, and so on. Specifically, the methods for solving ECPE include: two-step method, end-to-end method, joint learning method, graph convolution method, sequence annotation method, machine reading comprehension method, and so on.

[0060] Typically, the two-step method designs a pipeline model consisting of two classifiers. The first classifier is used to extract emotion clauses and reason clauses respectively. Then, by applying the Cartesian product to the emotion set and the reason set, they are paired to generate a set of candidate emotion-reason pairs (which can also be written as: emotion-reason pairs or emotion-reason statement pairs). Finally, a filter is trained to remove those pairs that do not contain the causal relationship between emotion and reason. Although this method has achieved good results, it has the problem of cascading errors, that is, the errors that may occur when the first classifier extracts emotion clauses and reason clauses, and these errors may be transmitted to the second classifier, thus affecting the final result. At the same time, the two-step method does not utilize the correlation between the two tasks and separates the two tasks.

[0061] As a result, 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 an interactive attention mechanism and a fusion mechanism; some scholars have proposed an end-to-end graph convolutional network (GCN) framework that extracts emotion and reason features through clause-level and pairwise-level context encoders, uses GCN to model the dependencies of candidate pairs, and realizes the classification and annotation of candidate pairs; some scholars have reconstructed the emotion-reason pair extraction as a sequence labeling problem, combined the advantages of sequence labeling and sequence-to-sequence, and improved the accuracy and robustness of the model through content and pairing labeling. Some scholars have cleverly reformulated the ECPE task as a machine reading comprehension (MRC) problem and used the powerful functions of the MRC model to extract the correct emotion-reason pairs. Some scholars have proposed a new graph-based method that precisely models the emotional trigger path by using common sense knowledge to reveal the semantic dependencies between candidate clauses and emotional 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 semantic feature extraction problem; some scholars have optimized the model through constraint learning and adjusting the classifier decision boundary so that it can better learn representations from imbalanced data; some scholars have regarded the ECPE task as a question-and-answer problem, predicted the emotion clause by fixing the question, and then used the predicted emotion as a question to predict its potential cause; some scholars have utilized multi-granularity information, including word-level, clause-level, and document-level information, for the extraction of emotion-reason pairs; some scholars have formalized the ECPE task as a probability problem, derived the joint distribution of emotional clauses and reason clauses through the total probability formula, and quantified the dependence strength between them using mutual information; some scholars have proposed a multi-task sequence labeling framework that simultaneously extracts emotions and reasons by encoding emotion distances into a new labeling scheme and uses the output of the auxiliary task as an inductive bias to optimize the 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-question attention network that obtains contextual and semantic answers by questioning the emotions and contextual reasons of candidates to address the limitations in the ECPE task.

[0062] Different from the above fine-tuning method, the method of prompt learning was proposed in the recent two or three years. Prompt learning has been widely applied in sentiment analysis tasks before and achieved relatively good results. Therefore, in recent years, some scholars first proposed using the prompt tuning method in the emotion cause pair extraction task. By decomposing the task into three subtasks: 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 were solved. Then, some scholars proposed a prompt template that fuses emotion categories, which solved the deviation problem existing in the existing prompt method that uses a one-to-one mapping relationship to map label words to categories. Specifically, some scholars proposed an emotion-cause pair extraction method based on prompt learning, which mined the implicit knowledge of the cause clause by integrating the deep knowledge of emotion categories and established an association with an external emotion word library. Among them, the general prompt tuning method decomposes the emotion cause analysis task into multiple objectives and designs modules to alleviate position bias. However, the existing methods do not fully understand and utilize emotion category information, nor do they consider the objective dependence between emotions and causes.

[0063] That is to say, although the prompt tuning technology has made certain 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, its prompt template lacks diversity and fails to design specific prompts according to different emotion categories.

[0064] Based on this, to solve the problems such as insufficient robustness and generalization of the prediction model and insufficient accuracy of the emotion-cause pair extraction results in the existing emotion-cause pair extraction task using the prompt tuning method, the embodiments of the present application respectively provide an emotion-cause statement pair prediction model training method, an emotion-cause statement pair prediction method, an emotion-cause statement pair prediction model training device for executing the emotion-cause statement pair prediction model training method, an emotion-cause statement pair prediction device for executing the emotion-cause statement pair prediction method, an entity device, a computer-readable storage medium, and a computer program product. By using the semantic relationship between emotions and causes in the text data and distinguishing pairs of different emotion categories, and adaptively selecting prompt templates according to different categories of emotion-cause pairs, a better data basis is provided for model training.

[0065] Specifically, it is described in detail through the following embodiments.

[0066] Based on this, the embodiments of the present application provide an emotion-cause statement pair prediction model training method that can be implemented by an emotion-cause statement pair prediction model training device. Refer to Figure 3 and the emotion-cause statement pair prediction model training method specifically includes the following content:

[0067] Step 100: According to the emotion classification labels corresponding to each text data and the prompt templates corresponding to each of the emotion classification labels, adaptively select the prompt templates corresponding to each text data to respectively extract the masked sample data corresponding to each text data; wherein, the text data includes an emotion statement containing an emotion word and multiple non-emotion statements, and at least one of the non-emotion statements is a reason statement corresponding to the emotion word.

[0068] In one or more embodiments of the present application, the text data is composed of multiple statements separated by punctuation marks and / or conjunctions (such as "and", etc.). The multiple statements are divided into emotion statements and non-emotion statements. The emotion statement refers to a statement containing an emotion word, and the non-emotion statement refers to other statements in the text data except the emotion statement. And among the non-emotion statements, at least one reason statement needs to be included. It can be understood that the reason mentioned in the present application refers to the reason for the emotion. Correspondingly, the reason statement refers to a statement composed of the reasons for the emotion corresponding to the emotion word. Of course, the emotion mentioned in the embodiments of the present application can be expressed by "sentiment", and can be specifically selected according to the actual application situation.

[0069] In addition, the emotion reason statement pair prediction model training method mentioned in the present application can be applied to the prediction of emotion reason statement pairs in text data of 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). First, according to the punctuation marks and the conjunction "and", the text data is split into 5 statements c1 to c5, 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] Among them, the emotion word "happy" appears in statement c4. Therefore, statement c4 is the emotion statement in this text data A, and statements c1 to c3 and c5 are non-emotion statements in this text data A. And at least one reason statement needs to be included in the non-emotion statements. As can be seen from the above example, statements c2 and c3 are both reason statements corresponding to the emotion statement c4. That is to say, the text data that can satisfy the above-mentioned emotion statement containing the emotion word and multiple non-emotion statements, and at least one of each of the non-emotion statements is the reason statement corresponding to the emotion word can be used to train the classifier mentioned in this application.

[0077] It can be understood that the emotion classification label refers to the label used to represent the emotion type. In the embodiments of this 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 labels and make full use of the emotion category information, in an embodiment of this application, the emotion classification labels can be set to eight categories, namely:

[0078] (1) Good;

[0079] (2) Happiness;

[0080] (3) Sadness;

[0081] (4) Fear;

[0082] (5) Anger;

[0083] (6) Disgust;

[0084] (7) Surprise;

[0085] (8) None.

[0086] Based on this, the emotion classification labels corresponding to the text data mentioned in step 100 of the present application can be pre-labeled manually; in order to further improve the efficiency and automation of training data processing, the emotion classification labels corresponding to the text data can also be determined in advance through the mapping relationship between the emotion words in the text data and the emotion classification labels. The construction process of this mapping relationship will be described in detail in the subsequent embodiments.

[0087] In one or more embodiments of the present application, each of the emotion classification labels is correspondingly provided with a prompt template. Therefore, in step 100 of the present application above, when determining the emotion classification label of a text data and the prompt template uniquely corresponding to this emotion classification label, this prompt template can be used as the prompt template corresponding to this text data, and then the masked sample data corresponding to this text data can be extracted according to this prompt template. It can be understood that the masked sample data can refer to the sample data formed after masking the emotion words in the text data, the determination results of whether each non-emotion statement is the reason statement corresponding to this emotion word, and the reason statement.

[0088] That is to say, the "adaptive selection" mentioned in the embodiments of the present application means that since the text data corresponds to an emotion classification label and the emotion classification label is provided with a uniquely corresponding prompt template, the emotion reason statement pair prediction device of the present application can dynamically select a uniquely corresponding prompt template from 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 to better guide the language model to understand and extract emotions and reasons.

[0089] Step 200: Train a classifier based on each of the masked sample data to train the classifier into an emotion reason statement pair prediction model for predicting the emotion reason statement pair of the text data, where the emotion reason statement pair is used to represent the corresponding relationship between the emotion statement and the reason statement in the text data.

[0090] In step 200, the emotion reason statement pair prediction model is used to output emotion reason statement pair prediction result data, and this emotion reason statement pair prediction result data is recorded as the emotion reason statement pair of the predicted text data. The emotion reason statement pair is used to represent the corresponding relationship between the emotion statement and the reason statement in the text data, and can be expressed in the way that the emotion statement is before and the reason statement is after. In an example, the emotion reason statement pairs in the above text data A are (c4, c2) and (c4, c3).

[0091] As can be seen from the above description, the method for training an emotion-cause statement pair prediction model provided by the embodiments of the present application can explicitly learn the relationship between emotions and causes in the text, improve the diversity of the prompt templates, improve the adaptability, effectiveness, and reliability of the training process of the emotion-cause statement pair prediction model, improve the robustness and generalization of the model, so as to improve the accuracy of the prediction result of the emotion-cause statement pair output by the emotion-cause statement pair prediction model.

[0092] In order to improve the application effectiveness, flexibility, and reliability of the prompt templates, and further achieve dynamic selection of different prompt templates to better adapt to the classifier training, in a method for training an emotion-cause statement pair prediction model provided by the embodiments of the present application, refer to Figure 5 , before step 100 of the method for training an emotion-cause statement pair prediction model, the following specific content is further included:

[0093] Step 010: Construct corresponding prompt templates for each emotion classification label. Among them, the prompt template includes an emotion template, a cause template, and a relationship template; the emotion template is used to represent an emotion mask statement corresponding to an emotion classification label, and the emotion mask statement is formed by masking the emotion word corresponding to the emotion classification label in the emotion statement; the cause template is used to represent a cause determination result mask statement corresponding to an emotion classification label, and the cause determination result mask statement is formed by masking the determination results of whether each non-emotion statement in the text data is a cause statement corresponding to the emotion word in the text data; the relationship template is used to represent a relationship mask statement corresponding to an emotion classification label, and the relationship mask statement is a relationship expression statement between the emotion classification label and the masked cause statement formed by masking the non-emotion statement associated with the emotion word in the text data; correspondingly, the masked sample data includes: the emotion mask statement, the cause determination result mask statement, and the relationship mask statement.

[0094] Specifically, the emotion template in the prompt template (Initial Template) is used to represent an emotion mask statement corresponding to an emotion classification label. This emotion mask statement 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 statement, and this emotion word corresponds to a unique emotion classification label of this prompt template. Therefore, in the subsequent step 100, the content of [MASK] can be directly determined according to the clustering result data used to represent the one-to-many mapping relationship between each emotion classification label and each emotion word.

[0095] In one example, refer to Figure 6 , taking Figure 4 the text data A shown as an example. If the current emotion classification label is Happiness (happy), then the [MASK] in the emotion template "implies the emotion of [MASK]" in the prompt template (Initial Template) is used to mask "happy" in the text data A. If the current emotion classification label is Sadness (sad), then the [MASK] in the emotion template "implies the emotion of [MASK]" in the prompt template (Initial Template) is used to mask "sad" in the text data containing the emotion word "sad".

[0096] Specifically, the reason template in the prompt template (Initial Template) is used to represent a reason determination result masking statement corresponding to a said emotion classification label. The reason determination result masking statement can be written as "Feeling happiness, [MASK] because of the sentence." ([MASK] feels the emotion corresponding to the emotion classification label happiness because of a non-emotion sentence). Here, "happiness" can be replaced with other emotion classification labels. Here, "sentence" is used to refer to each non-emotion sentence except the emotion sentence after the text data is split. If there is only one non-emotion sentence left in the text data except the emotion sentence, then there is only one such emotion reason determination result masking statement. If there are multiple non-emotion sentences left in the text data except the emotion sentence, then there are also multiple such emotion reason determination results masking statements. Among them, the [MASK] in the reason determination result masking statement is used to mask "yes" (yes) or "no" (no) in the determination result of whether each non-emotion sentence in the said text data is the reason sentence corresponding to the emotion word in the text data. Therefore, in the subsequent step 100, the content of [MASK] can be directly determined according to the clustering result data representing the many-to-one mapping relationship between each emotion classification label and each said emotion word.

[0097] In one example, refer to Figure 6 , taking Figure 4Taking the text data A shown as an example, if the current emotion classification label is Happiness (happy), the cause determination result mask statements in the Initial Template include "[MASK] because of the " (c1) "Yesterday morning", "[MASK] because of the " (c2) "a policeman 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) "and deposited the money in the bank". Among them, neither non-emotional statements c1 and c5 are the cause statements corresponding to the emotion word "happy". Therefore, the [MASK] in the cause determination result mask statements corresponding to non-emotional statements c1 and c5 is used to mask words such as "no" or "not" that are used to express negation. Correspondingly, both non-emotional statements c2 and c3 are the cause statements corresponding to the emotion word "happy". Therefore, the [MASK] in the cause determination result mask statements corresponding to non-emotional statements c2 and c3 is used to mask words such as "yes" that are used to express affirmation.

[0098] Specifically, referring to Figure 6 , the relationship template in the Initial Template is used to represent the relationship mask statement corresponding to a said emotion classification label. This relationship mask statement can be written as "The implied happiness emotion is related to [MASK]." (The emotion corresponding to the implied emotion classification label happiness is related to [MASK]). Here, the [MASK] is used to mask the non-emotional statements in the text data that are associated with the emotion word. For example, the non-emotional statements c1, c2, and c3 in the aforementioned example are masked respectively.

[0099] Correspondingly, referring to Figure 6 , taking Figure 4 the text data A shown as an example, the masked sample data corresponding to the text data A includes:

[0100] (1) Emotion mask statement (emotion): "[CLS] implies [MASK] emotion, which belongs to happiness, [SEP] (happy / joy / excited...)" ; where "(happy / joy / excited...)" is used to represent the emotion word masked by [MASK] in this sentence, and [CLS] and [SEP] are used to mark the beginning and end of the sentence respectively.

[0101] (2) Cause determination result mask statement (cause): [CLS] Feeling happiness, [MASK] because of the sentence. [SEP] (yes / no); where "(yes / no)" is used to represent the content masked by [MASK] in this sentence.

[0102] (3) Relationship mask statement (relation): [CLS] The implied happiness emotion is related to [MASK]. [SEP] (cl, c2, c3...). Where "(cl, c2, c3...)" is used to represent the content masked by [MASK] in this sentence.

[0103] In order to ensure the richness and rationality of emotion label words, and make full use of emotion category information to further improve the effectiveness and reliability of the emotion cause statement in the prediction model training process, in the emotion cause statement pair prediction model training method provided in the embodiments of the present application, refer to Figure 5 Before step 100 of the emotion cause statement pair prediction model training method, the following specific content is further included:

[0104] Step 020: Perform clustering processing on each emotion word based on unsupervised learning to obtain clustering result data representing the one-to-many mapping relationship between each emotion classification label and each of the emotion words.

[0105] Step 030: Determine the emotion classification label corresponding to each text data according to the clustering result data and the emotion words included in each text data respectively.

[0106] Specifically, in order to ensure the richness and rationality of emotion label words, and make full use of emotion category information, the embodiments of the present application perform clustering analysis on all emotion categories according to the existing emotion vocabulary ontology.

[0107] To further ensure the richness and rationality of emotion label words and make full use of emotion category information, in the method for training an emotion cause statement pair prediction model provided in the embodiments of this application, refer to Figure 7 Step 020 of the method for training an emotion cause statement pair prediction model specifically includes the following content:

[0108] Step 021: Input each emotion word into the RoBERTa language model respectively, so that the RoBERTa language model outputs the embedding vectors corresponding to each of the emotion words respectively, and obtain an embedding matrix composed of each of the embedding vectors.

[0109] Specifically, use a RoBERTa language model such as the Chinese-RoBERTa model to obtain the embedding vector of each emotion word w i , that is, input each emotion word into the RoBERTa language model and obtain the average value e i of the last hidden state, and integrate the embedding vectors of all emotion words into an embedding matrix.

[0110] e i = mean(RoBERTa(w i ))#(1)

[0111] Step 022: Use each preset emotion classification label as a different cluster center respectively, and perform clustering processing on each of the emotion words based on the K-means clustering algorithm and the embedding matrix, so as to cluster each of the embedding vectors into different clusters, obtain the corresponding relationship between the emotion classification label uniquely corresponding to each cluster and each of the embedding vectors in the cluster, and generate clustering result data representing the one-to-many mapping relationship between each emotion classification label and each of the emotion words corresponding to each of the embedding vectors respectively.

[0112] Specifically, refer to Figure 8 , each of the emotion words can be included in a pre-obtained emotion ontology dictionary (which can also be written as: emotion / sense ontology dictionary), and the K-means clustering algorithm (which can also be written as K-means clustering) can be used to perform clustering processing on the embedding matrix to generate clusters corresponding to each emotion classification label respectively, and further form clustering result data (which can also be called a label mapper). The objective function J of K-means clustering is:

[0113]

[0114] where k represents the number of clusters, such as k = 8; represents the i-th sample in the j-th cluster, and μ j represents the centroid of the j-th cluster.

[0115] In one example, the clustering result data (which can also be called a label mapper) used to represent the one-to-many mapping relationship between each emotion classification label and each corresponding emotion word of each of the embedding vectors is shown in Table 1.

[0116] Table 1

[0117] Serial number Emotion classification label Emotion word 1 Good grateful... (English words used to represent good) 2 Happiness Happiness, happy, excited... (English words used to represent happiness) 3 Sadness Sadness, sorry, sorrow, cry... (English words used to represent sadness) 4 Fear Fear, panic, scared, afraid... (English words used to represent fear) 5 Anger Anger, offended, annoyed... (English words used to represent anger) 6 Disgust Disgust, terrible, bothered... (English words used to represent disgust) 7 Surprise Surprise, shocked, startled... (English words used to represent surprise) 8 None no (used to indicate not belonging to the above 7 types of labels)

[0118] Furthermore, existing research has overlooked the correlation and the potential for mutual assistance between the three subtasks of emotion extraction, reason extraction, and emotion-reason pair extraction. That is, although some scholars have processed these three subtasks separately, they have not fully considered the internal connections between these tasks and have ignored the possible interactions and influences between them.

[0119] Based on this, on the basis of improving the diversity of the prompt templates to improve the adaptability, effectiveness, and reliability of the training process of the emotion-reason statement pair prediction model, in order to further incorporate emotion information into the reason extraction process and at the same time incorporate emotion and reason information into the pairing task of emotion-reason pairs, thereby enhancing the relevance and assistance between the three subtasks and improving the overall prediction effect, in the emotion-reason statement 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 perceptron, 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 perceptron;

[0120] Correspondingly, referring to Figure 5 or Figure 7 , step 200 of the emotion-reason statement pair prediction model training method specifically includes the following content:

[0121] Step 210: Based on the masked language model, feature vectors are extracted from the emotion masked statement, the reason determination result masked statement, and the relationship masked statement of each of the masked sample data, so as to obtain the emotion feature vector corresponding to the emotion masked statement, the reason feature vector corresponding to the reason determination result masked statement, and the relationship feature vector corresponding to the relationship masked statement of each of the masked sample data;

[0122] Step 220: Use the emotion feature vectors, the cause feature vectors, and the relationship feature vectors of each of the masked sample data to perform multiple rounds of iteration on the Bayesian network and the multi-layer perceptron. In each iteration round, use the emotion-cause statement pairs corresponding to each of the text data as the labels of the masked sample data corresponding to each of the text data. Calculate the loss of the emotion-cause statement pair prediction result data corresponding to the masked sample data output by the multi-layer perceptron based on the labels of the masked sample data, and optimize the multi-layer perceptron based on this loss.

[0123] Among them, the Bayesian network is used to perform feature extraction on the cause feature vector based on the emotion feature vector to obtain the target cause feature vector corresponding to the cause feature vector, and perform feature extraction on 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 respectively output the emotion feature vector, the target cause feature vector, and the target relationship feature vector corresponding to each of the masked sample data.

[0124] The multi-layer perceptron is used to perform multi-class classification on the emotion feature vector, the target cause feature vector, and the target relationship feature vector respectively output by the Bayesian network for each of the masked sample data, and respectively output the emotion-cause statement pair prediction result data corresponding to each of the masked sample data.

[0125] To further illustrate the above embodiments, the present application also provides a specific application example of a method for training an emotion-cause statement pair prediction model, which relates to the cross-technology application field of machine learning and deep learning, and can also be called a method for emotion analysis and cause inference generation in a social scenario. It can better model the causal dependence relationship between emotions and cause clauses from a semantic perspective. Therefore, the method of the present application utilizes the semantic relationship between emotions and causes, and distinguishes pairs of different emotion categories. According to different categories of emotion-cause pairs, sub-prompt templates are dynamically selected to better adapt to three different sub-tasks. At the same time, considering the relevance between the emotion extraction and cause extraction tasks, the emotion information and cause information are fused to improve the accuracy and efficiency of emotion-cause reasoning.

[0126] The application example of this application proposes a training method for an emotion cause sentence pair prediction model based on Bayesian and prompting learning. This emotion cause sentence pair prediction model can also be called an adaptive emotion cause reasoning model. Specifically, emotion cause reasoning is finely divided into three subtasks, namely emotion analysis, cause reasoning, and emotion-cause pairing, and corresponding sub-prompt templates are constructed for each subtask. Further, unsupervised learning clustering is performed on common Chinese or English emotion word categories, and corresponding prompt templates are dynamically selected according to different emotion categories. Finally, considering the objective correlation between the emotion analysis and cause reasoning subtasks, a Bayesian network is used for subtask modeling, emotion information is explicitly added to the cause reasoning, and emotion and cause information are added to the emotion-cause pairing for hypothesis verification, so as to ensure the accuracy and rationality of emotion analysis and cause reasoning.

[0127] The existing technical solutions for emotion cause reasoning have the following problems:

[0128] (1) Insufficiency of prompting learning: The existing prompt templates are too single, making it difficult to effectively integrate different emotion categories and failing to fully utilize emotion information and cause information to improve the performance of the task.

[0129] (2) Ignoring the correlation between tasks: Existing methods often independently process emotion extraction, cause extraction, and emotion-cause pair extraction, ignoring the correlation and mutual assistance between the three, resulting in insufficient information utilization. As Figure 9 shown, the MLM Head (Masked Language Modeling Head) is an important part of the BERT model, mainly used to predict masked words.

[0130] Based on this, the overall technical solution of the application example of this application includes four technical points: prompting learning, density estimation clustering, Bayesian network, and language model imitation dialogue. The training method for the emotion cause sentence pair prediction model based on Bayesian and prompting learning proposed in the application example of this application finely divides emotion cause reasoning into three subtasks, namely emotion analysis, cause reasoning, and emotion-cause pairing, and constructs corresponding sub-prompt templates for each subtask. Further, unsupervised learning clustering is performed on common Chinese and English emotion word categories, and corresponding prompt templates are dynamically selected according to different emotion categories. Finally, considering the objective correlation between the emotion analysis and cause reasoning subtasks, a Bayesian network is used for subtask modeling, emotion information is explicitly added to the cause reasoning, and emotion and cause information are added to the emotion-cause pairing for hypothesis verification, so as to ensure the accuracy and rationality of emotion analysis and cause reasoning.

[0131] See Figure 10, the training method for the emotion cause sentence pair prediction model based on Bayesian and prompting learning proposed by the application example of this application specifically includes the following content:

[0132] S1. Corpus preprocessing, generating corresponding text semantic vectors for common emotion words / cause words / sentence numbers, etc., providing a basic semantic expression for subsequent reasoning.

[0133] In step S1, the corpus includes multiple typical events (in Chinese) statistically collected from social media platforms, typical stories (in English) collected from biographies, and multiple pairs of serial number pairs of sentences where emotions and causes are located. Among them, the candidate emotions and possible causes are both described by digital vectors and language labels. The digital vectors correspond to the emotion cause words in the corpus, and the serial numbers of the single sentences where the emotions and causes are located are used as the generation results of the model to judge the reasoning effect and speed of the model for the emotions and causes contained in the text.

[0134] S2. Introduce an external knowledge base, and use density estimation unsupervised clustering learning to optimize the language model, improving the model's understanding ability of the relationship between emotions and causes.

[0135] In step S2, combine the text semantic vectors of keywords (emotions, causes, and related person events) processed by the pre-trained language model Transformer and the target feature vectors for obtaining the task sentence numbers using a pointer network, and infer the possible candidate pairings of emotion sentences and cause sentences. Specifically, with the help of a social media emotion ontology library (in Chinese) and a biography emotional ontology library (in English), use the idea of unsupervised clustering learning to count and sort common emotion words in Chinese and English, and map Chinese and English emotion word groups to the prompt templates of the language model to enhance the language model's understanding and reasoning ability of cause emotions.

[0136] S3. Considering the variable situations in emotion cause reasoning, use a Bayesian network to model the logical relationship between emotions and causes, so as to effectively handle evolving context dependencies in multiple aspects.

[0137] Among them, w1, w2, and w3 respectively represent different emotion words, and b1, b2, and b3 respectively represent the feature vectors corresponding to different emotion words; C bys represents the cause 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 cause sentence pair output by the emotion cause sentence pair prediction model.

[0138] In step S3, due to the variability of emotion causes and the uncertainty of the context, the candidate emotion cause pairings generated by reasoning have obvious errors and accidental correctness. Therefore, a Bayesian network is proposed to conduct hypothesis verification on the front and back reasoning processes of emotion vectors and cause vectors to ensure the accuracy of the results.

[0139] S4. Compare and sort the candidate emotional cause statement pairs in each data document to generate a vector of the most likely emotional cause statement pairs, and finally use a classifier to obtain the emotional cause statement pairs.

[0140] In step S4, a multi-layer perceptron is used to classify and pair multiple types of emotions and corresponding causes to obtain the final inference generation result.

[0141] Among them, the improvement contents provided by the application examples of the present application are as follows:

[0142] (1) Unsupervised clustering to learn the emotion dictionary: To ensure the richness and rationality of emotion label words and make full use of emotion category information, the embodiments of the present application adopt the existing sentiment vocabulary ontology to perform clustering analysis on all emotion categories.

[0143] (2) Adaptive selection of prompt templates: Design diverse prompt templates for different emotion categories and adaptively select the most suitable prompt template according to the prompted emotion category to better guide the language model to understand and extract emotions and reasons.

[0144] (3) Bayesian network modeling: Incorporate emotion information into the reason extraction process, and at the same time incorporate emotion and reason information into the pairing task of emotional cause pairs, thereby enhancing the relevance and assistance between the three subtasks and improving the overall prediction effect.

[0145] Through the improvement of the above three technical points, on the basis of the feasibility of large model automated testing, drawing on the idea of using a teacher model to enhance the student model, a language model is used to simulate real conversations, that is, human-computer interaction, so as to be able to more flexibly and realistically identify and reason about the dynamic emotion changes and their causes in multi-round interactions, providing an effective solution and measure for the analysis and reasoning of dialogue emotional causes in complex interaction scenarios. That is to say, the application examples of the present application significantly improve the understanding ability of the relationship between emotions and reasons through corpus preprocessing, external knowledge base optimization, and Bayesian network modeling, can effectively handle the evolving context dependence in changing situations, and finally generate understandable and interpretable emotional cause statement pairs.

[0146] Based on the foregoing embodiments of the method for training an emotional cause statement pair prediction model, the present application also provides an embodiment of a method for predicting an emotional cause statement pair that can be executed by an emotional cause statement pair prediction device. The method for predicting an emotional cause statement pair specifically includes the following contents:

[0147] Step 300: 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 the masked sample data corresponding to the target text data; wherein, the target text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of the non-emotion statements is a reason statement corresponding to the emotion word.

[0148] Step 400: Input the masked sample data corresponding to the target text data into the emotion reason statement pair prediction model, so that the emotion reason statement pair prediction model correspondingly outputs the emotion reason statement pair corresponding to the target text data; wherein, the emotion reason statement pair prediction model is pre-trained based on the emotion reason statement pair prediction model training method.

[0149] The emotion reason statement pair prediction model training method mentioned in Step 400 in the embodiment of the emotion reason statement pair prediction method provided by this application can specifically be used to execute the processing flow of the embodiment adopting the emotion reason statement pair prediction model training method in the above-mentioned embodiment, and its functions will not be elaborated herein. Reference can be made to the detailed description of the embodiment of the emotion reason statement pair prediction model training method.

[0150] From a software perspective, this application also provides an emotion reason statement pair prediction model training device for executing all or part of the content in the emotion reason statement pair prediction model training method. The emotion reason statement pair prediction model training device specifically includes the following:

[0151] The first adaptive masking module is used 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 masked sample data corresponding to each text data respectively; wherein, the text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of the non-emotion statements is a reason statement corresponding to the emotion word.

[0152] The classifier training module is used to train a classifier based on each masked sample data to train the classifier into an emotion reason statement pair prediction model for predicting the emotion reason statement pair of text data, wherein the emotion reason statement pair is used to represent the corresponding relationship between the emotion statement and the reason statement in the text data.

[0153] The embodiments of the emotional cause statement pair prediction model training device provided in this application can specifically be used to execute the processing flow of the embodiments of the emotional cause statement pair prediction model training method in the above embodiments. Its functions will not be elaborated here, and reference can be made to the detailed description of the embodiments of the emotional cause statement pair prediction model training method above.

[0154] The part of the emotional cause statement pair prediction model training device for training the emotional cause statement pair prediction model can be completed in the server or the client device. Specifically, it can be selected according to the processing capabilities of the client device and the limitations of the user usage scenario, etc. This application does not make any limitations in this regard. If all operations are completed in the client device, the client device may further include a processor for the specific processing of the emotional cause statement pair prediction model training.

[0155] The above-mentioned client device may have a communication module (i.e., a communication unit), which can communicate with a remote server to achieve data transmission with the server. The server may include a server on the task scheduling center side, and in other implementation scenarios, it may also include a server of an intermediate platform, such as a server of a third-party server platform having a communication link with the task scheduling center server. The server may include a single computer device, or a server cluster composed of multiple servers, or a server structure of a distributed device.

[0156] Any suitable network protocol can be used for communication between the above-mentioned server and the client device side, including network protocols not yet developed on the filing date of this application. The network protocol may, for example, include TCP / IP protocol, UDP / IP protocol, HTTP protocol, HTTPS protocol, etc. Of course, the network protocol may, for example, also include the RPC protocol (Remote Procedure Call Protocol) and REST protocol (Representational State Transfer) used on top of the above protocols.

[0157] From a software level, this application also provides an emotional cause statement pair prediction device for executing all or part of the content in the emotional cause statement pair prediction method. The emotional cause statement pair prediction device specifically includes the following content:

[0158] The second adaptive masking 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 masked sample data corresponding to the target text data; wherein, the target text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of the non-emotion statements is a reason statement corresponding to the emotion word.

[0159] The model prediction module is configured to input the masked sample data corresponding to the target text data into the emotion reason statement pair prediction model, so that the emotion reason statement pair prediction model outputs the emotion reason statement pair corresponding to the target text data; wherein, the emotion reason statement pair prediction model is pre-trained based on the emotion reason statement pair prediction model training method mentioned in the foregoing embodiments.

[0160] An embodiment of the present application further provides an electronic device, which may include a processor, a memory, a receiver, and a transmitter. The processor is configured to execute the emotion reason statement pair prediction model training method and / or the emotion reason statement pair prediction method mentioned in the foregoing embodiments. The processor and the memory may be connected through a bus or other means. Taking the connection through the bus as an example, the receiver may be connected to the processor and the memory in a wired or wireless manner.

[0161] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSPs), application specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. chips, or combinations of the above types of chips.

[0162] The memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer-executable programs, and modules, such as program instructions / modules corresponding to the emotion reason statement pair prediction model training method and / or the emotion reason statement 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 statement pair prediction model training method and / or the emotion reason statement pair prediction method in the above method embodiments.

[0163] The memory may include a program storage area and a data storage area. The program storage area may store an operating system and application programs required for at least one function. The data storage area may store data created by the processor and the like. In addition, the memory may include high-speed random access memory and may also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0164] The one or more modules are stored in the memory and, when executed by the processor, perform the method for training a prediction model for emotional cause statement pairs and / or the method for predicting emotional cause statement pairs in the embodiments.

[0165] In some embodiments of the present application, the user equipment may include a processor, a memory, and a transceiver unit. The transceiver unit may include a receiver and a transmitter. The processor, the memory, the receiver, and the transmitter may be connected through a bus system. The memory is used to store computer instructions, and the processor is used to execute the computer instructions stored in the memory to control the transceiver unit to transmit and receive signals.

[0166] As an implementation manner, the functions of the receiver and the transmitter in the present application may be considered to be implemented through a transceiver circuit or a dedicated transceiver chip, and the processor may be considered to be implemented through a dedicated processing chip, a processing circuit, or a general-purpose chip.

[0167] As another implementation manner, it may be considered to use a general-purpose computer to implement the server provided in the embodiments of the present application. That is, the 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 further provide a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the foregoing method for training a prediction model for emotional cause statement pairs and / or the method for predicting emotional cause statement pairs are implemented. The computer-readable storage medium may be a tangible storage medium, such as a random access memory (RAM), a 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 storage disk, a CD-ROM, or any other form of storage medium known in the art.

[0169] The embodiment of the present application also provides a computer program product, including a computer program, which when executed by a processor, is configured to implement the steps of the foregoing method for training a prediction model with emotional cause statement pairs and / or the method for predicting emotional cause statement pairs.

[0170] Those of ordinary skill in the art should understand that the various exemplary components, systems, and methods described in connection with the embodiments disclosed herein can be implemented in hardware, software, or a combination of both. Specifically, whether to implement in hardware or software depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a functional card, etc. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium or transmitted via a data signal carried in a carrier wave on a transmission medium or a communication link.

[0171] It should be clear that the present application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order between steps after understanding the spirit of the present application.

[0172] In the present application, the features described and / or illustrated for one embodiment can be used in the same way or in a similar way in one or more other embodiments, and / or combined with the features of other embodiments or replace the features of other embodiments.

[0173] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, various changes and modifications can be made to the embodiments of the present application. 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 an emotional cause statement pair prediction model, characterized in that Including: According to the emotion classification labels corresponding to each text data and the prompt templates corresponding to each of the emotion classification labels, adaptively select the prompt templates corresponding to each text data to respectively extract the masked sample data corresponding to each text data; wherein, the text data includes an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of the non-emotion statements is a reason statement corresponding to the emotion word; Train a classifier based on each of the masked sample data to train the classifier into an emotion reason statement pair prediction model for predicting the emotion reason statement pair of text data, wherein the emotion reason statement pair is used to represent the corresponding relationship between the emotion statement and the reason statement in the text data.

2. The method for training an emotional cause statement prediction model according to claim 1, wherein Before the step of adaptively selecting the prompt templates corresponding to each text data according to the emotion classification labels corresponding to each text data and the prompt templates corresponding to each of the emotion classification labels to respectively extract the masked sample data corresponding to each text data, it further includes: Construct corresponding prompt templates for each emotion classification label respectively, wherein the prompt template includes an emotion template, a reason template, and a relationship template; The emotion template is used to represent an emotion masked statement corresponding to an emotion classification label, and the emotion masked statement is formed by masking the emotion word corresponding to the emotion classification label in the emotion statement; The reason template is used to represent a reason determination result masked statement corresponding to an emotion classification label, and the reason determination result masked statement is formed by masking the determination result of whether each non-emotion statement in the text data is a reason statement corresponding to the emotion word in the text data; The relationship template is used to represent a relationship masked statement corresponding to an emotion classification label, and the relationship masked statement is a relationship expression statement between the emotion classification label and the masked reason statement formed by masking the non-emotion statement associated with the emotion word in the text data; Correspondingly, the masked sample data includes: the emotion masked statement, the reason determination result masked statement, and the relationship masked statement.

3. The method for training an emotion cause statement pair prediction model according to claim 1, wherein Before the step of adaptively selecting the prompt templates corresponding to each text data according to the emotion classification labels corresponding to each text data and the prompt templates corresponding to each of the emotion classification labels to respectively extract the masked sample data corresponding to each text data, it further includes: Perform clustering processing on each emotion word based on unsupervised learning to obtain clustering result data for representing the one-to-many mapping relationship between each emotion classification label and each of the emotion words; According to the clustering result data and the emotion words included in each text data respectively, determine the emotion classification labels corresponding to each text data respectively.

4. The method for training an emotional cause statement pair prediction model according to claim 3, wherein The step of performing clustering processing on each emotion word based on unsupervised learning to obtain clustering result data for representing the one-to-many mapping relationship between each emotion classification label and each of the emotion words includes: Each emotion word is input into the RoBERTa language model respectively, so that the RoBERTa language model outputs the embedding vectors corresponding to each of the emotion words respectively, and an embedding matrix composed of the embedding vectors is obtained; Using each of the preset emotion classification labels as different cluster centers respectively, clustering each of the emotion words based on the K-means clustering algorithm and the embedding matrix, so as to cluster each of the embedding vectors into different clusters, obtaining the corresponding relationship between the emotion classification label uniquely corresponding to each cluster and each of the embedding vectors in the cluster, and generating clustering result data for representing the one-to-many mapping relationship between each emotion classification label and each of the emotion words corresponding to the embedding vectors respectively.

5. The method for training the emotional cause statement pair prediction model according to claim 2, characterized in that, The classifier includes a masked language model, a Bayesian network and a multi-layer perceptron, 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 perceptron; Correspondingly, training the classifier based on each of the masked sample data to train the classifier into an emotion cause statement pair prediction model for predicting the emotion cause statement pair of text data includes: Based on the masked language model, respectively extracting feature vectors from the emotion masked statement, the cause determination result masked statement and the relationship masked statement of each of the masked sample data, so as to obtain the emotion feature vector corresponding to the emotion masked statement corresponding to each of the masked sample data, the cause feature vector corresponding to the cause determination result masked statement, and the relationship feature vector corresponding to the relationship masked statement; Using the emotion feature vectors, the cause feature vectors and the relationship feature vectors of each of the masked sample data to perform multiple rounds of iteration on the Bayesian network and the multi-layer perceptron, and in each iteration round, taking the emotion cause statement pair corresponding to each of the text data as the label of each of the masked sample data corresponding to the text data, calculating the loss of the emotion cause statement pair prediction result data corresponding to the masked sample data output by the multi-layer perceptron according to the label of the masked sample data, and optimizing the multi-layer perceptron based on the loss.

6. The method for training an emotional cause statement prediction model according to claim 5, characterized in that The Bayesian network is used to perform feature extraction on the cause feature vector based on the emotion feature vector to obtain the target cause feature vector corresponding to the cause feature vector, and perform feature extraction on 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 respectively output the emotion feature vector, the target cause feature vector and the target relationship feature vector corresponding to each of the masked sample data.

7. The method for training an emotional cause statement pair prediction model according to claim 6, wherein The multi-layer perceptron is used to perform multi-class classification on the emotion feature vectors, the target cause feature vectors, and the target relationship feature vectors respectively corresponding to each of the masked sample data respectively output by the Bayesian network, and respectively output the prediction result data of the emotion cause statement pairs respectively corresponding to each of the masked sample data.

8. A method for predicting emotional cause statement pairs, characterized in that, It includes: 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 the masked sample data corresponding to the target text data; wherein, the target text data contains an emotion statement where an emotion word is located and multiple non-emotion statements, and at least one of each of the non-emotion statements is a cause statement corresponding to the emotion word. Input the masked sample data corresponding to the target text data into the emotion cause statement pair prediction model, so that the emotion cause statement pair prediction model correspondingly 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 7.

9. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the emotion cause statement pair prediction model training method according to any one of claims 1 to 7, and / or implements the emotion cause statement pair prediction method according to claim 8.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the emotion cause statement pair prediction model training method according to any one of claims 1 to 7, and / or implements the emotion cause statement pair prediction method according to claim 8.

Citation Information

Patent Citations

  • Emotional reason extraction method based on attention mechanism

    CN114116974A

  • Mongolian multi-modal sentiment analysis method based on T-M BERT pre-training model

    CN114153973A

  • Feedback mechanism-based emotion reason extraction method

    CN118504552A

  • Trusted network false information identification method and device

    CN118747221A

  • Pipe vibration damping mount

    KR1020240059235A

Cited By

  • Robot voice processing method and system

    CN120564721A