Emotion ternary extraction model optimization method, recognition method, equipment and storage medium
By constructing a diverse perception loss function and a composite loss function to optimize the sentiment ternary extraction model, the problem of inaccurate recognition of complex expressions by the existing model is solved, the robustness and generalization ability of the model are improved, and accurate triple extraction of complex text data is achieved.
Patent Information
- Application Number
- CN202510683821.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-05-26
AI Technical Summary
Existing sentiment triple extraction models cannot accurately identify triples in text data when processing complex expressions, and fail to fully integrate semantic context and logical constraints in the process of sentiment polarity inference, resulting in inconsistent results and insufficient robustness.
By constructing a diverse perception loss function, combining the preset logical transformation relationship and the initial emotion triple set, the emotion triple extraction model is optimized, the deviation rate of the model output is calculated, and the diversity perception loss function and the original loss function are introduced to construct a composite loss function to dynamically adjust the weights during model training.
The accuracy and robustness of the model in processing complex emotional expressions have been improved, and it can better identify triplets of diverse emotional expressions, thereby enhancing the generalization ability of the model.
Smart Images

Figure CN120688570A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of optimization of emotion ternary extraction models, and in particular to an emotion ternary extraction model optimization method, recognition method, device and storage medium. Background Art
[0002] With the deep integration of the internet and 5G communication technologies, social media, e-commerce platforms, and other platforms have generated massive amounts of textual data, including user comments and feedback. This textual data contains rich information about user sentiment and opinions. Automatically extracting valuable sentiment information from this data has become a key research topic in natural language processing. Since the 21st century, the rise of deep learning technologies, particularly the widespread application of models such as recurrent neural networks, convolutional neural networks, and self-attention mechanisms, has significantly improved the performance of text sentiment analysis. In particular, the triple extraction model (ASTE) is capable of extracting aspect-sentiment triplets. These models, given a single comment sentence as input, can output complete aspect-sentiment triplets, including triplets for "aspect," "opinion," and "sentiment polarity." While these models have made significant progress in many areas, they still face difficulties in handling complex expressions.
[0003] In the process of sentiment polarity inference, the sentiment classification modules of various existing sentiment triple extraction models are usually independent of the triple extraction process, failing to fully integrate semantic context and logical constraints. They may not be able to correctly maintain the consistency of sentiment polarity, resulting in contradictory results. At the same time, they are not robust enough to diverse expressions, lack effective isolation of interference between triples, and insufficient modeling of sentiment logic consistency. These problems together lead to a significant decline in the performance of the model in complex language environments and are unable to accurately identify triples in text data.
[0004] Therefore, there is an urgent need for an optimization method for the sentiment ternary extraction model that can solve the technical problem that the existing technology cannot accurately identify the triples of text data. Summary of the Invention
[0005] In view of this, it is necessary to provide a sentiment ternary extraction model optimization method, recognition method, device and storage medium that can solve the technical problem of accurately identifying triples of text data.
[0006] In order to solve the above technical problems, on the one hand, the present invention provides a method for optimizing a sentiment ternary extraction model, comprising: Obtain the initial sentiment triple set based on the sentiment triple extraction model and text sentences; Calculating the deviation rate of each element in the triple output by the emotion triple extraction model according to the initial emotion triple set and the preset logical transformation relationship; Constructing a diverse perception loss function based on the deviation rate and the classification loss of each element; Constructing a composite loss function based on the diverse perception loss function and the original loss function of the emotion ternary extraction model; The target emotion ternary extraction model is optimized according to the composite loss function.
[0007] In one possible implementation, the preset logical transformation relationship includes a transformation rule and a logical result matching rule; and calculating the deviation rate of each element in the triple output by the emotional triple extraction model according to the initial emotional triple set and the preset logical transformation relationship includes: Performing cross-group conversion and intra-group conversion on the text sentences according to the initial sentiment triple set and the conversion rules to obtain variant sentences; Inputting the variant sentences into a sentiment triple extraction model to obtain a set of variant triples; The deviation rate of each element in the triple output by the sentiment triple extraction model is calculated according to the variant triple set and the logical result matching rule.
[0008] In one possible implementation, the text sentences are subjected to cross-group conversion and intra-group conversion according to the initial sentiment triple set and the conversion rules to obtain variant sentences, including: Divide multiple triplets in the initial sentiment triple set into target triplets and other triplets; Determine the words corresponding to each element in the target triple and each element in other triples in the text sentence, and obtain the target triple words and other triple words; Convert other triples of words in the text sentence according to the cross-group conversion rule in the conversion rule to obtain a first variant sentence; transforming the target triplet words in the text sentence according to the intra-group transformation rule in the transformation rule to obtain a second variant sentence; The first variant statement and the second variant statement constitute a variant statement.
[0009] In one possible implementation, calculating the deviation rate of the sentiment triple extraction model for each element in the triple according to the variant triple set and the logical result matching rule includes: Counting the number of triples whose elements in the variant triples meet the logical result matching rule to obtain a statistical result of each element; The deviation rate of each element of the sentiment triple extraction model is calculated according to the number of variant triples in the variant triple set and the statistical results of each element.
[0010] In one possible implementation, a diverse perception loss function is constructed based on the deviation rate and the classification loss of each element, including: Construct the classification loss function of each element based on binary cross entropy; Based on the classification loss function of each element, the deviation rate of each element is used as the weight distribution coefficient, and the classification loss function of each element is weightedly fused to obtain the diverse perception loss function.
[0011] In one possible implementation, the formula of the diversity perception loss function is: , in, is the value of the diverse perception loss function, For the i The deviation rate of the elements, For the i The classification loss function for each element.
[0012] In one possible implementation, the formula of the composite loss function is: , in, is the composite loss function value, is the original loss function of the emotional triple extraction model, is the diversity perception loss function, and is a constant.
[0013] In a second aspect, the present invention further provides a method for extracting sentiment triples, comprising: Get text data; Input the text data into the optimized target sentiment triple extraction model, and output the sentiment triple result; The optimized target emotion ternary extraction model is obtained according to the emotion ternary extraction model optimization method according to any one of claims 1 to 7.
[0014] In the third aspect, an emotion triplet recognition device includes a processor, a memory, and a computer program stored in the memory and runnable on the processor. When the processor executes the program, it implements the above-mentioned emotion triplet extraction model optimization method and / or the above-mentioned emotion triplet extraction method.
[0015] In a fourth aspect, a computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the above-mentioned sentiment ternary extraction model optimization method and / or the above-mentioned sentiment triple extraction method.
[0016] The beneficial effects of the present invention are as follows: first, an initial set of emotion triples is obtained according to the emotion triple extraction model and the text sentence; then, the text sentence is transformed according to the preset logical transformation relationship and the initial emotion triple set, the transformed result is input into the emotion triple extraction model, the output result of the model is verified, and the deviation rate of each element of the model is calculated. By evaluating the behavioral robustness of the model under non-functional input transformation through input transformation and output consistency, the deviation rate can effectively reveal the potential defects of the model when processing semantically equivalent or logically related inputs; then, a diverse perception loss function is constructed according to the deviation rate and the classification loss of each element, the model is subdivided according to different task dimensions, that is, the dimensions of each element in the triple, the deviation rates of different task dimensions are mapped to weight coefficients of each element, and the diverse perception loss function is constructed in combination with the classification loss function of each element to reflect the diversity comprehensive perception processing capability of the model on each subtask; finally, a composite loss function is constructed according to the diverse perception loss function and the original loss function of the emotion triple extraction model, and the target emotion triple extraction model is optimized according to the composite loss function. During the model training process, a diversity-aware loss function is introduced into the traditional model classification loss function, so that the model can dynamically adjust the weights of different tasks during the training process, thereby improving the overall learning effect and enabling the model to accurately identify emotional triples when complex emotional expressions occur. The present invention verifies the deviation rate of each element of the model by transforming the input text, and constructs a diversity-aware loss function based on the deviation rate, so that the model can better handle diversified emotional expressions. On the basis of the original classification loss, a diversity-aware loss function is introduced, and the weights of each loss function are dynamically adjusted, thereby improving the model's generalization ability and ability to handle complex emotional expressions, so that the optimized model can accurately extract triples from complex text data. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A schematic flow chart of an embodiment of the method for optimizing the emotion ternary extraction model provided by the present invention; Figure 2 For the present invention Figure 1 A flow chart of an embodiment of step S101; Figure 3 For the present invention Figure 2 A flow chart of an embodiment of step S201; Figure 4 For the present invention Figure 2 A flow chart of an embodiment of step S203; Figure 5 For the present invention Figure 1 A flow chart of an embodiment of step S103; Figure 6 A schematic flow chart of an embodiment of the emotion triple extraction method provided by the present invention; Figure 7 A schematic structural diagram of an embodiment of the optimization device for the emotion ternary extraction model provided by the present invention. DETAILED DESCRIPTION
[0019] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making any creative efforts shall fall within the scope of protection of the present invention.
[0020] In the description of the embodiments of the present invention, unless otherwise specified, “a plurality of” means two or more.
[0021] The terms "first," "second," and so on, used in the embodiments of the present invention are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature designated as "first" or "second" may explicitly or implicitly include at least one such feature.
[0022] References herein to "embodiments" mean that a particular feature, structure, or characteristic described in connection with the embodiments may be included in at least one embodiment of the present invention. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it constitute a separate or alternative embodiment that is mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0023] The present invention provides an emotion ternary extraction model optimization method, recognition method, device and storage medium, which are described below respectively.
[0024] Figure 1 A flow chart of an embodiment of the method for optimizing the emotion ternary extraction model provided by the present invention is shown as follows: Figure 1 As shown in Figure 2, the optimization method for the sentiment ternary extraction model includes: S101, obtaining an initial set of sentiment triples based on the sentiment triple extraction model and the text sentence; It should be noted that the emotion ternary extraction model in this embodiment is not limited to a specific model structure and is compatible with various types of emotion ternary extraction models. For example, models based on graph convolutional network models, generative models, sequence labeling models, etc. can all be optimized through the optimization method of this embodiment.
[0025] It should be further explained that each emotional ternary extraction model is optimized and trained through the model management software on the electronic terminal, wherein the electronic terminal can realize text data processing and model management functions, and can be a PC, mobile terminal, portable terminal, etc.
[0026] It's important to note that the core goal of the sentiment triple extraction model is to identify and extract triplets consisting of aspects, opinions, and sentiment polarity from natural language text. For example, in the sentence "This restaurant has excellent service, but average food," two triplets need to be extracted: ("service," "excellent," positive) and ("food," "average," neutral).
[0027] S102, calculating the deviation rate of each element in the triple output by the emotion triple extraction model according to the initial emotion triple set and the preset logical transformation relationship; It should be noted that the deviation rate is a quantitative indicator to measure the behavioral deviation of the model in converting the output according to the preset logical change relationship. It is defined as the proportion of the model output that violates the expected logical transformation relationship. For each logical transformation relationship, the number of cases in which the model does not meet the expected output under the variant input is counted. In this embodiment, a series of logical change relationships are designed to convert the input text, so that the model can cover a variety of language characteristics. The converted text is input into the sentiment ternary extraction model to obtain the converted text triples. The converted text triples are verified according to the logical change relationship to see whether they meet the expected results. The ratios of compliance with the expected results are counted in turn. In this embodiment, the ratios of the triples that meet the expected results in aspect items, opinion items and sentiment polarity are counted respectively as the deviation rates of the three elements: aspect items, opinion items and sentiment polarity.
[0028] S103. Construct a diverse perception loss function based on the deviation rate and the classification loss of each element; Specifically, the model's extraction process of emotional ternaries is divided into classifications of different task dimensions, including aspect item classification, opinion item classification, and emotional polarity classification. Therefore, each classification task may have different importance and difficulty during the training process. In order to balance the contribution of each task, the deviation rate of different task dimensions is mapped to the dynamic weight of each task dimension, and uncertainty weighting is introduced. The classification losses of each task dimension are weighted and fused to ensure that different types of emotional expressions can be fully learned, further improving the model's performance on the overall task and reducing the overfitting problem in specific situations, so that the model is more robust in dealing with complex emotional structures.
[0029] S104, constructing a composite loss function based on the diverse perception loss function and the original loss function of the emotion ternary extraction model; Specifically, in the training process of the emotional triple extraction model, not only traditional ASTE losses, such as triple extraction and emotional classification losses, are relied upon, but in this embodiment, diverse perception losses are also introduced, and weighted according to the uncertainty of each task to obtain the final composite loss function.
[0030] S105. Optimize the target emotion ternary extraction model according to the composite loss function.
[0031] It should be noted that the method of optimizing the emotional ternary extraction model according to the composite loss function can be the back propagation method or other optimization methods, which are not limited here. This embodiment optimizes the parameters of the emotional ternary extraction model through the back propagation method, so that the model gives priority to task dimensions that are susceptible to diversity interference during the training process.
[0032] This embodiment obtains an initial set of sentiment triples based on the sentiment ternary extraction model and text sentences; transforms the text sentences according to a preset logical transformation relationship and the initial set of sentiment triples, inputs the transformed results into the sentiment ternary extraction model, verifies the output results of the model, and calculates the deviation rate of each element of the model. By evaluating the behavioral robustness of the model under non-functional input transformations through input transformation and output consistency, the deviation rate can effectively reveal the potential defects of the model when processing semantically equivalent or logically related inputs; constructs a diverse perception loss function based on the deviation rate and the classification loss of each element, subdivides the model according to different task dimensions, i.e., the dimensions of each element in the triple, maps the deviation rates of different task dimensions to weight coefficients of each element, and constructs a diverse perception loss function in combination with the classification loss functions of each element to reflect the diverse comprehensive perception processing capabilities of the model in each subtask; constructs a composite loss function based on the diverse perception loss function and the original loss function of the sentiment ternary extraction model, and optimizes the target sentiment ternary extraction model based on the composite loss function. During the training process of the model, a diversity-aware loss function is introduced into the traditional model classification loss function, so that the model can dynamically adjust the weights of different tasks during the training process, thereby improving the overall learning effect and enabling the model to accurately identify emotional triples when complex emotional expressions occur. This embodiment verifies the deviation rate of each element of the model by transforming the input text, and constructs a diversity-aware loss function based on the deviation rate, so that the model can better handle diversified emotional expressions. On the basis of the original classification loss, a diversity-aware loss function is introduced, and the weights of each loss function are dynamically adjusted to improve the generalization ability of the model and its ability to handle complex emotional expressions, so that the optimized model can accurately extract triples from complex text data.
[0033] In some embodiments of the present invention, the preset logical transformation relationship includes a transformation rule; Figure 2 As shown, Figure 2 The present invention provides Figure 1 A flow chart of an embodiment of step S101 in FIG. 1 includes: S201, performing cross-group conversion and intra-group conversion on the text sentence according to the initial sentiment triple set and the transformation rule to obtain a variant sentence; S202, inputting the variant sentence into the sentiment triple extraction model to obtain a set of variant triples; S203. Calculate the deviation rate of each element in the triple output by the sentiment triple extraction model according to the variant triple set and the logical result matching rule.
[0034] It should be noted that the preset logical transformation relationship includes transformation rules and logical result matching rules. The input text is transformed through the transformation rules, and the output results of the converted model are matched through the logical result matching rules. The transformation rules and the logical result matching rules are in a one-to-one correspondence.
[0035] In some embodiments of the present invention, Figure 3 As shown, Figure 3 The present invention provides Figure 2 The flowchart of an embodiment of step S201 in FIG. 1 includes: S301, dividing multiple triples in the initial emotion triple set into target triples and other triples; S302, determining the words corresponding to each element in the target triple and each element in other triples in the text sentence, and obtaining the target triple words and other triple words; S303: convert other triples of words in the text sentence according to the cross-group conversion rule in the conversion rule to obtain a first variant sentence; S304: convert other triples of words in the text sentence according to the intra-group conversion rule in the conversion rule to obtain a second variant sentence; S305. The first variant statement and the second variant statement constitute a variant statement.
[0036] Specifically, the transformation rules between and within triples are designed from the perspective of potentially causing unexpected changes in the output of a triple. The cross-group transformation rules include: Rule 1: Replace the opinion items of other triples with synonyms; Rule 2, reverse the sentiment polarity of other triples; Rule 3, introduces new triples with opposite sentiment polarity; Rule 4, use unknown to replace the aspect items and opinion items of other triples.
[0037] For example, the text sentence is "The service in this restaurant is good, but the food is average". The text sentence is input into the sentiment triple extraction model, and the initial sentiment triple set contains two triplets, namely ("service", "very good", positive) and ("food", "average", neutral). ("food", "average", neutral) is used as the target triplet, and ("service", "very good", positive) is used as the other triplet. For rule 1, the opinion item of the other triplet is "very good". Replace "very good" in the text sentence with the synonym "good", and obtain a new variant sentence "The service in this restaurant is good, but the food is average"; for rule 2, the sentiment polarity of the other triplet is "positive". Replace "very good" in the text sentence with "very bad", and obtain a new variant sentence "The service in this restaurant is very bad, but the food is average". And so on, multiple first variant sentences across groups are obtained.
[0038] Furthermore, the inter-group transformation rules include: Rule 5, perform synonym replacement on the aspect items of the target triple; Rule 6, replace synonyms for the opinion items of the target triples; Rule 7, perform synonym replacement on the aspect item and opinion item of the target triple; Rule 8: Replace the target triple’s sentiment item with antonyms.
[0039] For rule 5, the aspect item of the target triple is "food". Replace "food" in the text sentence with the synonym "ingredients" to obtain a new variant sentence "The service in this restaurant is good, but the ingredients are average"; for rule 6, the opinion item of the target triple is "average". Replace "average" in the text sentence with "ordinary" to obtain a new variant sentence "The service in this restaurant is poor, but the food is average". And so on, multiple first variant sentences across groups are obtained.
[0040] This embodiment transforms the input text through logical change relationships to improve the accuracy and robustness of the model under diverse emotional expressions.
[0041] In some embodiments of the present invention, the preset logical transformation relationship also includes a logical result matching rule; Figure 4 As shown, Figure 4 The present invention provides Figure 2 A flow chart of an embodiment of step S203 in FIG. 1 includes: S401, counting the number of triples whose elements in the variant triples meet the logical result matching rule, and obtaining the statistical results of each element; S402. Calculate the deviation rate of each element of the sentiment triple extraction model according to the number of variant triples in the variant triple set and the statistical results of each element.
[0042] Specifically, the logical result matching rules and the transformation rules are in a one-to-one correspondence. Combining the transformation rules, we can obtain a series of cross-group logical result matching rules and intra-group logical result matching rules. The cross-group logical result matching rules corresponding to the cross-group transformation rules are: Rule 1: Synonym replacement is performed on the opinion items of other triples, and the extraction result of the target triple output by the variant sentence is not affected; Rule 2: Reverse the sentiment polarity of other triples, but the extraction result of the target triple output by the variant sentence will not be affected; Rule 3 introduces new triples with opposite sentiment polarity, and the extraction results of the target triples output by the variant sentence are not affected; Rule 4, uses unknown to replace the aspect items and opinion items of other triples, and the extraction results of the target triples output by the variant sentence are not affected.
[0043] Furthermore, the inter-group logical result matching rule corresponding to the inter-group transformation rule is: Rule 5: Synonym replacement is performed on the aspect items of the target triples. The opinion items and sentiment polarity of the target triples output by the variant sentences remain unchanged. Rule 6: Synonym replacement is performed on the opinion item of the target triple. The aspect item and sentiment polarity of the target triple output by the variant sentence remain unchanged. Rule 7: Synonym replacement is performed on the aspect item and opinion item of the target triple. The sentiment polarity of the target triple output by the variant sentence remains unchanged. Rule 8 replaces the target triple's sentiment item with antonyms, and the sentiment polarity of the target triple output by the variant sentence is reversed.
[0044] Furthermore, for rule 1, the new variant sentence "The service in this restaurant is good, but the food is average" is input into the sentiment triple extraction model to obtain triples ("service", "good", positive) and ("food", "average", neutral), where the target triple remains unchanged and meets the cross-group logical result matching rule, which means that the case is a positive case and does not deviate from expectations. When the obtained target triple changes, the triple is counted as a deviation case. In this embodiment, deviation statistics are performed on each element in the triple, that is, whether the aspect item, opinion item and sentiment polarity in the target triple is judged in turn to meet the logical result matching rule, and the deviation case statistics are performed according to each element, and finally the deviation rate of each element is obtained.
[0045] In some embodiments of the present invention, Figure 5 As shown, Figure 5 The present invention provides Figure 1A flow chart of an embodiment of step S103 in FIG. 1 includes: S501. Constructing a classification loss function for each element based on binary cross entropy; Specifically, in the sentiment ternary extraction model, the input text is divided into n words. , the output triple is represented as , where a is the aspect item, o is the opinion item, s is the sentiment polarity, and m is the number of triplets output by the model. The representation sequences of the aspect item, opinion item, and sentiment polarity in the last hidden layer of the model are expressed as: , in, is the representation sequence of aspect items, opinion items and sentiment polarity in the last hidden layer, l 1 ,l 2 and l 3 represents the aspect item, opinion item and sentiment polarity respectively. In the last hidden layer, it represents the length of the sequence; According to the representation sequence of aspect items, opinion items and sentiment polarity, the hidden layer representation of aspect items, opinion items and sentiment polarity is obtained as follows: , in, is the hidden layer representation of aspect items, opinion items and sentiment polarity, m is the number of triplets, is the hidden layer representation of the corresponding aspect item, opinion item and sentiment polarity in the first triple, is the hidden layer representation of the corresponding aspect item, opinion item and sentiment polarity in the second triplet, For the m The hidden layer representation of the corresponding aspect item, opinion item and sentiment polarity in the triples; Three discriminators and sigmoid activation function are introduced to identify aspect terms, opinion terms and sentiment polarity in the hidden layer representation: , in, is the recognition result of aspect item, opinion item and sentiment polarity, is the latent representation of aspect items, opinion items and sentiment polarity; According to the recognition results and true results of aspect items, opinion items and sentiment polarity, three recognition binary cross entropy (BCE) losses are obtained, and their calculation formula is:
[0046] in, is the recognition result of aspect item, opinion item and sentiment polarity, are the true results of aspect items, opinion items, and sentiment polarity.
[0047] S502: Based on the classification loss function of each element, the deviation rate of each element is used as a weight distribution coefficient, and the classification loss function of each element is weightedly fused to obtain a diverse perception loss function.
[0048] The formula of the diverse perception loss function is: , in, is the value of the diverse perception loss function, a For aspect items, o is the opinion item, s For emotional polarity, For the i The deviation rate of the elements, For the i The classification loss function for each element.
[0049] Specifically, the extraction task of the emotional ternary extraction model involves multiple subtasks, including aspect recognition, consciousness recognition, and emotional memory classification. Each task may have different importance and difficulty during the training process. By mapping the deviation rate into a dynamic weight coefficient, the loss function of each task is weighted and fused to balance the contribution of each task.
[0050] This embodiment uses binary cross entropy to construct corresponding loss functions for various aspects, opinion items, and sentiment polarity. By using the deviation rate of each element as a weight coefficient, the contribution of different elements to the total loss is dynamically adjusted, thereby enhancing the model's focus on difficult-to-classify or key elements and effectively balancing the training and learning of different tasks.
[0051] In some embodiments of the present invention, the formula of the composite loss function is: , in, is the composite loss function value, is the original loss function of the emotional triple extraction model, is the diversity perception loss function, and is a constant.
[0052] It should be noted that during the training of the emotional ternary extraction model, while using the original loss function of the emotional ternary extraction model, a diversity-aware loss function is introduced, and the loss function is further weighted and fused according to the uncertainty of each task, thereby improving the overall training effect. In particular, when processing complex emotional expressions, the trained model can accurately identify emotional triplets.
[0053] In addition, the present invention also provides a method for extracting emotional triples, combining Figure 6Come and see, Figure 6 A flow chart of an embodiment of the emotion triple extraction method provided by the present invention is shown as follows: Figure 5 As shown, including: S601, obtaining text data; S602: Input the text data into the optimized target sentiment triple extraction model, and output the sentiment triple result; The optimized target emotion ternary extraction model is obtained according to the emotion ternary extraction model optimization method according to any one of claims 1 to 7.
[0054] In an embodiment of the present invention, first, the text data to be processed is obtained; then, the text data is processed using the optimized target sentiment triple extraction model, and the sentiment triple result of the text data can be output.
[0055] like Figure 7 As shown, the present invention also provides an emotion triplet recognition device 700. The emotion triplet recognition device 700 includes a processor 701, a memory 702 and a display 703. Figure 7 Only some components of the emotion triplet recognition device 700 are shown, but it should be understood that it is not required to implement all of the shown components, and more or fewer components may be implemented instead.
[0056] In some embodiments, the processor 701 may be a central processing unit (CPU), a microprocessor, or other data processing chip, configured to execute program codes or process data stored in the memory 702 , such as the emotion triple extraction method of the present invention.
[0057] In some embodiments of the present invention, processor 701 may be a single server or a server group. The server group may be centralized or distributed. In some embodiments, processor 701 may be local or remote. In some embodiments, processor 701 may be implemented on a cloud platform. In one embodiment, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an internal cloud, multiple clouds, or any combination thereof.
[0058] In some embodiments, the memory 702 may be an internal storage unit of the emotion triple recognition device 700, such as a hard disk or memory of the emotion triple recognition device 700. In other embodiments, the memory 702 may also be an external storage device of the emotion triple recognition device 700, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the emotion triple recognition device 700.
[0059] Furthermore, the memory 702 may include both an internal storage unit and an external storage device of the emotion triplet recognition device 700. The memory 702 is used to store application software installed in the emotion triplet recognition device 700 and various data.
[0060] In some embodiments, the display 703 can be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. The display 703 is used to display information from the emotion triple recognition device 700 and to display a visual user interface. Components 701-703 of the emotion triple recognition device 700 communicate with each other via a system bus.
[0061] In some embodiments of the present invention, when the processor 701 executes the emotion triple recognition program in the memory 702, the following steps may be implemented for the emotion triple extraction model: Get text data; Input the text data into the optimized target sentiment triple extraction model, and output the sentiment triple result; The optimized target emotion ternary extraction model is obtained according to the above-mentioned emotion ternary extraction model optimization method.
[0062] It should be understood that: when the processor 701 executes the emotion ternary extraction model program in the memory 702, in addition to the above functions, it can also implement other functions. For details, please refer to the description of the corresponding method embodiment above.
[0063] Furthermore, the embodiment of the present invention does not specifically limit the type of the emotion ternary extraction model device 700 mentioned. The emotion ternary extraction model device 700 may be a portable emotion ternary extraction model device such as a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, laptop computer, etc. Exemplary embodiments of portable emotion ternary extraction model devices include but are not limited to portable emotion ternary extraction model devices equipped with IOS, Android, Microsoft or other operating systems. The above-mentioned portable emotion ternary extraction model device may also be other portable emotion ternary extraction model devices. It should also be understood that in some other embodiments of the present invention, the emotion ternary extraction model device 700 may not be a portable emotion ternary extraction model device, but may be a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0064] Correspondingly, an embodiment of the present invention also provides a computer-readable storage medium, which is used to store computer-readable programs or instructions. When the program or instructions are executed by a processor, it can implement the steps or functions in the emotion ternary extraction model optimization method provided by the above-mentioned method embodiments.
[0065] Those skilled in the art will appreciate that all or part of the process flow of the above-described method embodiment can be implemented by instructing related hardware (such as a processor, controller, etc.) through a computer program, and the computer program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a magnetic disk, an optical disk, a read-only memory, or a random access memory.
[0066] The above is a detailed introduction to the emotion ternary extraction model optimization method, recognition method, equipment and storage device provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. The optimization method of the emotional ternary extraction model is characterized by: include: Obtain the initial sentiment triple set based on the sentiment triple extraction model and text sentences; Calculating the deviation rate of each element in the triple output by the emotion triple extraction model according to the initial emotion triple set and the preset logical transformation relationship; Constructing a diverse perception loss function based on the deviation rate and the classification loss of each element; Constructing a composite loss function based on the diverse perception loss function and the original loss function of the emotion ternary extraction model; The target emotion ternary extraction model is optimized according to the composite loss function.
2. The method for optimizing the emotional ternary extraction model according to claim 1, characterized in that: The preset logical transformation relationship includes a transformation rule and a logical result matching rule; the deviation rate of each element in the triple output by the emotional triple extraction model according to the initial emotional triple set and the preset logical transformation relationship includes: Performing cross-group conversion and intra-group conversion on the text sentence according to the initial sentiment triple set and the conversion rule to obtain a variant sentence; Inputting the variant sentences into a sentiment triple extraction model to obtain a set of variant triples; The deviation rate of each element in the triple output by the sentiment triple extraction model is calculated according to the variant triple set and the logical result matching rule.
3. The method for optimizing the emotional ternary extraction model according to claim 2, characterized in that: Performing cross-group conversion and intra-group conversion on the text sentence according to the initial sentiment triple set and the conversion rule to obtain variant sentences, including: Divide multiple triplets in the initial sentiment triple set into target triplets and other triplets; Determine the words corresponding to each element in the target triple and each element in other triples in the text sentence, and obtain the target triple words and other triple words; Convert other triples of words in the text sentence according to the cross-group conversion rule in the conversion rule to obtain a first variant sentence; transforming the target triplet words in the text sentence according to the intra-group transformation rule in the transformation rule to obtain a second variant sentence; The first variant statement and the second variant statement constitute a variant statement.
4. The method for optimizing the emotional ternary extraction model according to claim 1, wherein: Calculating the deviation rate of each element in the triplet by the sentiment triple extraction model according to the variant triplet set and the logical result matching rule includes: Counting the number of triples whose elements in the variant triples meet the logical result matching rule to obtain a statistical result of each element; The deviation rate of each element of the sentiment triple extraction model is calculated according to the number of variant triples in the variant triple set and the statistical results of each element.
5. The method for optimizing the emotional ternary extraction model according to claim 4, characterized in that: A diverse perception loss function is constructed based on the deviation rate and the classification loss of each element, including: Construct the classification loss function of each element based on binary cross entropy; Based on the classification loss function of each element, the deviation rate of each element is used as the weight distribution coefficient, and the classification loss function of each element is weightedly fused to obtain the diverse perception loss function.
6. The method for optimizing the emotional ternary extraction model according to claim 5, characterized in that: The formula of the diversity perception loss function is: , in, is the value of the diverse perception loss function, For the i The deviation rate of the elements, For the i The classification loss function of the elements.
7. The method for optimizing the emotional ternary extraction model according to claim 1, wherein: The formula of the composite loss function is: , in, is the composite loss function value, is the original loss function of the sentiment ternary extraction model, is the diversity perception loss function, and is a constant.
8. A method for extracting emotional triples, characterized in that: include: Get text data; Input the text data into the optimized target sentiment triple extraction model, and output the sentiment triple result; The optimized target emotion ternary extraction model is obtained according to the emotion ternary extraction model optimization method according to any one of claims 1 to 7.
9. An emotion triplet recognition device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, it implements the emotion triple extraction model optimization method according to any one of claims 1 to 7 and / or the emotion triple extraction 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 a processor, the method for optimizing the emotion triple extraction model according to any one of claims 1 to 7 and / or the method for extracting emotion triples according to claim 8 are implemented.
Citation Information
Patent Citations
Triple extraction model training method, triple extraction method, device and equipment
CN115033717A
Multi-label sentiment classification method and system based on non-autoregression model
CN118113871A
Text data emotion triple extraction method and device and computer equipment
CN118569247A
Attribute-level emotion triple extraction method based on pairing information enhancement
CN118916446A
Intelligent voice reading method and system based on sentiment analysis
CN119047477A