Emotion triadic extraction model optimization method, recognition method, device and storage medium
By constructing diverse perceptual loss functions and logical transformation relationships to optimize the sentiment triplet extraction model, the problem of recognition accuracy and robustness of existing sentiment triplet extraction models under complex expressions is solved, and more efficient text data triplet extraction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHAN UNIV OF TECH
- Filing Date
- 2025-05-26
- Publication Date
- 2026-07-24
AI Technical Summary
Existing sentiment triad extraction models cannot accurately identify the triads in text data when dealing with complex expressions, and fail to fully integrate semantic context and logical constraints in the sentiment polarity inference process, resulting in contradictory results and insufficient robustness.
By constructing diverse perceptual loss functions, combining preset logical transformation relationships and an initial set of sentiment triples, the sentiment triple extraction model is optimized, the deviation rate of the model output is calculated, and diverse perceptual loss functions are introduced during training to dynamically adjust the weights of each task and improve the model's generalization ability.
This improves the accuracy and robustness of the model in identifying emotion triples when dealing with complex emotional expressions, enabling it to better handle diverse emotional expressions and enhancing the model's generalization ability and overall learning performance.
Smart Images

Figure CN120688570B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of optimization technology for sentiment ternary extraction models, and in particular to an optimization method, identification method, device, and storage medium for sentiment ternary extraction models. Background Technology
[0002] With the deep integration of the internet and 5G communication technologies, social media, e-commerce platforms, and other platforms have generated a large amount of text data, including user comments and feedback. This text data contains rich information about user emotions and opinions, and how to automatically extract valuable emotional information from it has become an important research topic in the field of natural language processing. In the 21st century, the rise of deep learning technology, especially 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 ASTE triple extraction model can perform aspect sentiment triple extraction tasks. These models can output complete aspect sentiment triples, including triples for "aspect," "opinion," and "sentiment polarity," from a single input comment sentence. Although these models have made significant progress in many aspects, they still face difficulties in handling situations containing complex expressions.
[0003] In the process of sentiment polarity inference, the sentiment classification module of existing sentiment triple extraction models is usually independent of the triple extraction process. It fails to fully integrate semantic context and logical constraints, which may not be able to maintain the consistency of sentiment polarity correctly, resulting in contradictory results. At the same time, the models are not robust enough to diverse expressions, lack effective isolation of interference between triples, and have insufficient modeling of sentiment logical consistency. These problems together lead to a significant decrease in the performance of the models in complex language environments, and they cannot accurately identify triples in text data.
[0004] Therefore, there is an urgent need for an optimized method for the sentiment ternary extraction model that can solve the technical problem of the inability to accurately identify the ternaries in text data in existing technologies. Summary of the Invention
[0005] In view of this, it is necessary to provide an optimization method, recognition method, device and storage medium for the emotion triple extraction model, which can solve the technical problem of accurately recognizing triples in text data.
[0006] To address the aforementioned technical problems, this invention provides, on the one hand, a method for optimizing a three-element emotion extraction model, comprising: An initial set of sentiment triplets is obtained based on the sentiment triplet extraction model and text statements; The deviation rate of each element in the triplet output by the emotional triplet extraction model is calculated based on the initial set of emotional triplets and the preset logical transformation relationship. Construct a diverse perceptual loss function based on the deviation rate and the classification loss of each element; A composite loss function is constructed based on the original loss function of the diverse perception loss function and the sentiment ternary extraction model; The target sentiment ternary extraction model is optimized based on the composite loss function.
[0007] In one possible implementation, the preset logical transformation relationship includes transformation rules and logical result matching rules; the deviation rate of each element in the triplet output by the emotional triplet extraction model is calculated based on the initial set of emotional triplets and the preset logical transformation relationship, including: Based on the initial set of emotion triplets and the transformation rules, the text statements are transformed across groups and within groups to obtain variant statements; The variant statements are input into the sentiment triple extraction model to obtain a set of variant triples; The deviation rate of each element in the triplet output by the sentiment triplet extraction model is calculated based on the set of variant triplets and the logical result matching rules.
[0008] In one possible implementation, the text statement is subjected to cross-group and intra-group transformations based on the initial set of sentiment triples and transformation rules to obtain variant statements, including: Divide multiple triplets in the initial set of sentiment triplets into target triplets and other triplets; Determine the words corresponding to each element in the target triplet and each element in other triplets in the text statement to obtain the target triplet words and other triplet words; The other triplet words in the text sentence are transformed according to the cross-group transformation rules in the transformation rules to obtain the first variant sentence; The target triplet words in the text sentence are transformed according to the intra-group transformation rules in the transformation rules to obtain the second variant sentence; The first variant statement and the second variant statement together constitute a variant statement.
[0009] In one possible implementation, the deviation rate of the sentiment triple extraction model from each element in the triple is calculated based on the variant triple set and the logical result matching rule, including: Count the number of triplets in the variant triplets whose elements match the logical result matching rules, and obtain the statistical results for each element; The deviation rate of each element in the sentiment triplet extraction model is calculated based on the number of variant triplets in the variant triplet set and the statistical results of each element.
[0010] In one possible implementation, diverse perceptual loss functions are constructed based on the deviation rate and the classification loss of each element, including: The classification loss function for each element is constructed 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 allocation coefficient to perform weighted fusion of the classification loss functions of each element, thus obtaining the diverse perception loss function.
[0011] In one possible implementation, the formula for the diversity-perceived loss function is: , in, For the value of the multi-sensory loss function, For the first i Deviation rate of each element For the first i The classification loss function for each element.
[0012] In one possible implementation, the formula for the composite loss function is: , in, The value of the composite loss function. The original loss function for the sentiment triad extraction model is... For diverse perception loss functions, and It is a constant.
[0013] Secondly, the present invention also provides a method for extracting emotion triples, comprising: Get text data; The text data is input into the optimized target sentiment triple extraction model, and the sentiment triple results are output. The optimized target sentiment ternary extraction model is obtained according to any of the sentiment ternary extraction model optimization methods described above.
[0014] Thirdly, the emotion triplet recognition device includes a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the emotion triplet extraction model optimization method described above and / or the emotion triplet extraction method described above.
[0015] Fourthly, a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described sentiment triple extraction model optimization method and / or the above-described sentiment triple extraction method.
[0016] The beneficial effects of this invention are as follows: First, an initial set of sentiment triples is obtained based on the sentiment triple extraction model and the text statement. Then, the text statement is transformed according to a preset logical transformation relationship and the initial set of sentiment triples. The transformed result is input into the sentiment triple extraction model to verify the model's output and calculate the deviation rate of each element. By evaluating the consistency between input transformation and output, the robustness of the model under non-functional input transformation is assessed. This deviation rate can effectively reveal the potential defects of the model when processing semantically equivalent or logically related inputs. Next, a diverse perception loss function is constructed based on the deviation rate and the classification loss of each element. The model is subdivided according to different task dimensions, i.e., the dimensions of each element in the triple. The deviation rate of different task dimensions is mapped to the weight coefficient of each element. The diverse perception loss function is constructed by combining the classification loss function of each element to reflect the model's diverse comprehensive perception processing capability in each sub-task. Finally, a composite loss function is constructed based on the diverse perception loss function and the original loss function of the sentiment triple extraction model. The target sentiment triple extraction model is optimized based on the composite loss function. During model training, a diversity-aware loss function is introduced into the traditional model classification loss function. This allows the model to dynamically adjust the weights of different tasks during training, thereby improving the overall learning effect and enabling the model to accurately identify emotional triples in complex emotional expressions. This invention verifies the deviation rate of each element of the model by transforming the input text. A diversity-aware loss function is constructed based on the deviation rate, allowing the model to better handle diverse emotional expressions. By introducing a diversity-aware loss function on top of the original classification loss and dynamically adjusting the weights of each loss function, the model's generalization ability and ability to handle complex emotional expressions are improved. This allows the optimized model to accurately extract triples from complex text data. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying 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 effort.
[0018] Figure 1 A schematic flowchart of an embodiment of the emotion ternary extraction model optimization method provided by the present invention; Figure 2 For the present invention Figure 1 A schematic flowchart of an embodiment of step S101; Figure 3 For the present invention Figure 2 A flowchart illustrating an embodiment of step S201; Figure 4 For the present invention Figure 2 A flowchart illustrating an embodiment of step S203; Figure 5 For the present invention Figure 1 A schematic flowchart of an embodiment of step S103; Figure 6 A flowchart illustrating an embodiment of the emotion triplet extraction method provided by the present invention; Figure 7 A schematic diagram of an embodiment of the optimization device for the emotion ternary extraction model provided by the present invention. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0020] In the description of the embodiments of the present invention, unless otherwise stated, "a plurality of" means two or more.
[0021] The terms "first," "second," etc., used in the embodiments of this invention are for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, a technical feature defined with "first" or "second" may explicitly or implicitly include at least one of that feature.
[0022] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0023] This invention provides an optimization method, recognition method, device, and storage medium for an emotion ternary extraction model, which will be described below.
[0024] Figure 1 This is a schematic flowchart of an embodiment of the emotion ternary extraction model optimization method provided by the present invention, as shown below. Figure 1 As shown, the optimization method for the sentiment ternary extraction model includes: S101. Obtain an initial set of sentiment triplets based on the sentiment triplet extraction model and text statements; It should be noted that the sentiment ternary extraction model in this embodiment is not limited to a specific model structure and can be compatible with various types of sentiment ternary extraction models. For example, graph convolutional network models, generative models, sequence labeling models, etc. can all be optimized using the optimization method in this embodiment.
[0025] It should be further noted that the various sentiment ternary extraction models are optimized and trained through model management software on electronic terminals. These electronic terminals can perform text data processing and model management functions, and can be PCs, mobile terminals, portable terminals, etc.
[0026] It should be further explained that the core objective of the sentiment triad extraction model is to identify and extract triads from natural language text that include "aspect", "opinion", and "sentiment polarity". For example, in the sentence "The service at this restaurant is very good, but the food is so-so", two triads need to be extracted: ("service", "very good", positive) and ("food", "so-so", neutral).
[0027] S102. Calculate the deviation rate of each element in the triplet output by the emotional triplet extraction model based on the initial set of emotional triplets and the preset logical transformation relationship. It should be noted that the deviation rate is a quantitative indicator that measures the deviation of the model's output behavior when transforming according to the preset logical transformation 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 fails to meet the expected output under the variant input is counted. This embodiment designs a series of logical transformation relationships to transform the input text, so that the model can cover multiple language characteristics. The transformed text is input into the sentiment triplet extraction model to obtain the transformed text triplet. The transformed text triplet is verified according to the logical transformation relationship to see if it meets the expected result. The ratio of meeting the expected result is counted in turn. In this embodiment, the ratio of the triplet meeting the expected result in aspect, opinion, and sentiment polarity is counted separately as the deviation rate of the three elements: aspect, opinion, and sentiment polarity.
[0028] S103. Construct a diverse perceptual loss function based on the deviation rate and the classification loss of each element; Specifically, the model's extraction process of the sentiment triad is divided into classifications of different task dimensions, including aspect classification, opinion classification, and sentiment polarity classification. Therefore, each classification task may have different importance and difficulty during training. 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. Uncertainty weighting is introduced, and the classification loss of each task dimension is weighted and fused to ensure that different types of sentiment expression can be fully learned, thereby further improving the model's performance on the overall task and reducing the overfitting problem in specific situations, resulting in a more robust model when dealing with complex sentiment structures.
[0029] S104. Construct a composite loss function based on the original loss function of the diverse perception loss function and the sentiment ternary extraction model; Specifically, in the training process of the sentiment triple extraction model, in addition to relying on traditional ASTE loss, such as triple extraction and sentiment classification loss, this embodiment also introduces a variety of perceptual losses, and weights them according to the uncertainty of each task to obtain the final composite loss function.
[0030] S105. Optimize the target sentiment ternary extraction model based on the composite loss function.
[0031] It should be noted that the method of optimizing the sentiment ternary extraction model based on the composite loss function can be the backpropagation method or other optimization methods. There is no limitation here. In this embodiment, the parameters of the sentiment ternary extraction model are optimized by the backpropagation method, so that the model prioritizes the task dimension that is susceptible to diversity interference during the training process.
[0032] This embodiment obtains an initial set of sentiment triples based on the sentiment triple extraction model and the text statement. The text statement is then transformed according to a preset logical transformation relationship and the initial set of sentiment triples. The transformed result is input into the sentiment triple extraction model to verify the model's output. The deviation rate of each element in the model is calculated. By evaluating the consistency between input transformation and output, the robustness of the model under non-functional input transformations is assessed. This deviation rate effectively reveals potential defects in the model when processing semantically equivalent or logically related inputs. A diverse perception loss function is constructed based on the deviation rate and the classification loss of each element. The model is subdivided according to different task dimensions, i.e., the dimensions of each element in the triples. The deviation rate of different task dimensions is mapped to the weight coefficient of each element. Combined with the classification loss function of each element, a diverse perception loss function is constructed to reflect the model's comprehensive perception processing capability across various sub-tasks. A composite loss function is constructed based on the diverse perception loss function and the original loss function of the sentiment triple extraction model. The target sentiment triple extraction model is then optimized based on the composite loss function. During model training, a diversity-aware loss function is introduced into the traditional model classification loss function. This allows the model to dynamically adjust the weights of different tasks during training, thereby improving the overall learning effect and enabling the model to accurately identify emotional triples in complex emotional expressions. This embodiment verifies the deviation rate of each element of the model by transforming the input text. A diversity-aware loss function is constructed based on the deviation rate, allowing the model to better handle diverse emotional expressions. By introducing the diversity-aware loss function on top of the original classification loss and dynamically adjusting the weights of each loss function, the model's generalization ability and ability to handle complex emotional expressions are improved. This allows the optimized model to accurately extract triples from complex text data.
[0033] In some embodiments of the present invention, the preset logical transformation relationship includes transformation rules; such as... Figure 2 As shown, Figure 2 Provided by the present invention Figure 1 A flowchart of one embodiment of step S101 includes: S201. Based on the initial set of sentiment triplets and transformation rules, perform cross-group transformation and intra-group transformation on the text statements to obtain variant statements; S202. Input the variant statements into the sentiment triple extraction model to obtain a set of variant triples; S203. Calculate the deviation rate of each element in the triplet output by the sentiment triplet extraction model based on the variant triplet set and the logical result matching rules.
[0034] It should be noted that the preset logical transformation relationship includes transformation rules and logical result matching rules. The input text is transformed by the transformation rules, and the output result of the transformed model is matched by the logical result matching rules. The transformation rules and logical result matching rules have a one-to-one correspondence.
[0035] In some embodiments of the present invention, such as Figure 3 As shown, Figure 3 Provided by the present invention Figure 2 A flowchart of one embodiment of step S201 includes: S301. Divide multiple triplets in the initial set of emotion triplets into target triplets and other triplets; S302. Determine the words corresponding to each element of the target triplet and each element of other triplets in the text statement, and obtain the target triplet words and other triplet words. S303. Based on the cross-group transformation rules in the transformation rules, transform the other triplet words in the text statement to obtain the first variant statement; S304. Transform the target triplet words in the text statement according to the intra-group transformation rules in the transformation rules to obtain the second variant statement; S305, the first variant statement and the second variant statement together form a variant statement.
[0036] Specifically, the transformation rules between and within triplets are designed from the perspective of potential unexpected changes in the output of a triplet. The cross-triplet transformation rules include: Rule 1: Replace the opinion items of other triples with synonyms; Rule 2: Reverse the emotional polarity of the other triplets; Rule 3 introduces new triplets with opposite emotional polarities; Rule 4: Replace the aspect and opinion items of other triples with unknowns.
[0037] For example, given the text statement "The service at this restaurant is very good, but the food is so-so," inputting this text statement into the sentiment triplet extraction model yields an initial set of sentiment triples containing two triples: ("service", "very good", positive) and ("food", "so-so", neutral). Using ("food", "so-so", neutral) as the target triplet and ("service", "very good", positive) as the other triplets, for rule 1, the opinion item of the other triplets is "very good." Replacing "very good" in the text statement with the synonym "good" results in a new variant statement: "The service at this restaurant is good, but the food is so-so." For rule 2, the sentiment polarity of the other triplets is "positive." Replacing "very good" in the text statement with "very bad" results in a new variant statement: "The service at this restaurant is bad, but the food is so-so." This process continues, resulting in multiple cross-triad first variant statements.
[0038] Furthermore, the inter-group transformation rules include: Rule 5: Replace the aspect terms of the target triple with synonyms; Rule 6: Replace the opinion items of the target triple with synonyms; Rule 7: Replace the aspect and opinion items of the target triple with synonyms; Rule 8: Replace the sentiment term of the target triple with antonyms.
[0039] For rule 5, the aspect term of the target triple is "food". Replacing "food" in the text statement with the synonym "ingredients" yields a new variant statement: "The service at this restaurant is good, but the ingredients are average". For rule 6, the opinion term of the target triple is "average". Replacing "average" in the text statement with "ordinary" yields a new variant statement: "The service at this restaurant is poor, but the food is average". And so on, resulting in multiple cross-triple first variant statements.
[0040] This embodiment transforms the input text through logical changes, improving the model's accuracy and robustness under diverse emotional expressions.
[0041] In some embodiments of the present invention, the preset logical transformation relationship further includes logical result matching rules; such as Figure 4 As shown, Figure 4 Provided by the present invention Figure 2 A flowchart of one embodiment of step S203 includes: S401. Count the number of triples in the statistical variant triplets whose elements meet the logical result matching rules, and obtain the statistical results of each element. S402. Calculate the deviation rate of each element in the sentiment triplet extraction model based on the number of variant triplets in the variant triplet set and the statistical results of each element.
[0042] Specifically, the logical result matching rules and transformation rules have a one-to-one correspondence. Combining the transformation rules, a series of cross-group logical result matching rules and intra-group logical result matching rules are obtained. Among them, the cross-group logical result matching rules corresponding to the cross-group transformation rules are as follows: Rule 1: For opinion items in other triples, synonym replacement is performed. The extraction result of the target triple in the variant statement output is not affected. Rule 2 reverses the sentiment polarity of other triples, and the extraction result of the target triple in the variant statement output is not affected; Rule 3 introduces new triples with opposite sentiment polarity, and the extraction results of the target triples output by the variant statement are not affected; Rule 4 replaces the aspect and opinion items of other triples with unknowns, and the extraction results of the target triples output by the variant statement are not affected.
[0043] Furthermore, the inter-group logical result matching rule corresponding to the inter-group transformation rule is as follows: Rule 5 replaces the aspect items of the target triple with synonyms, and the opinion items and sentiment polarity of the target triple output by the variant statement are not affected; Rule 6 replaces the opinion items of the target triple with synonyms, and the aspect items and sentiment polarity of the target triple output by the variant statement are not affected; Rule 7 replaces the aspect and opinion items of the target triple with synonyms, and the sentiment polarity of the target triple output by the variant statement is not affected; Rule 8 replaces the sentiment term of the target triple with antonyms, and the sentiment polarity of the target triple output by the variant statement is reversed.
[0044] Furthermore, for Rule 1, the new variant statement "The service at 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). If the target triple remains unchanged and satisfies the cross-group logical result matching rule, then the case is a positive case and does not deviate from the expectation. If the obtained target triple changes, then the triple is counted as a deviation case. In this embodiment, deviation statistics are performed on each element in the triple, that is, the aspect item, opinion item and sentiment polarity in the target triple are judged in turn to see if they satisfy the logical result matching rule. Deviation cases are counted according to each element, and finally the deviation rate of each element is obtained.
[0045] In some embodiments of the present invention, such as Figure 5 As shown, Figure 5 Provided by the present invention Figure 1A flowchart of one embodiment of step S103 includes: S501. Construct a classification loss function for each element based on binary cross-entropy; Specifically, in the sentiment triad extraction model, the input text is divided into n words. The output triplet is represented as Where a represents the aspect term, o represents the opinion term, s represents the sentiment polarity, and m represents the number of triples in the model output. The representation sequences of the aspect term, opinion term, and sentiment polarity in the last hidden layer of the model are respectively expressed as: , in, 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, and the length of the sequence is represented in the last hidden layer; Based on 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, This represents the implicit layer of aspects, opinions, and emotional polarity. m The number of triples. This represents the hidden layer representation of the corresponding aspect, opinion, and sentiment polarity in the first triplet. This represents the hidden layer representation of the aspect, opinion, and sentiment polarity in the second triplet. For the first m The hidden representation of the corresponding aspect item, opinion item, and sentiment polarity in each triplet; Three discriminators and a sigmoid activation function are introduced to identify aspect terms, opinion terms, and sentiment polarity in the hidden layer representation: , in, The identification results are for aspect items, opinion items, and sentiment polarity. This represents the implicit layer of aspects, opinions, and emotional polarities. Based on the identification results and actual results for aspect items, opinion items, and sentiment polarity, three binary cross-entropy (BCE) losses are obtained, and their calculation formulas are as follows:
[0046] in, The identification results are for aspect items, opinion items, and sentiment polarity. The true results for aspects, opinions, and emotional polarities.
[0047] S502. Based on the classification loss function of each element, the deviation rate of each element is used as the weight allocation coefficient to perform weighted fusion of the classification loss functions of each element to obtain the diverse perception loss function.
[0048] The formula for the multi-sensory loss function is: , in, For the value of the multi-sensory loss function, a For aspects, o For comments, s For emotional polarity, For the first i Deviation rate of each element For the first i The classification loss function for each element.
[0049] Specifically, the emotion ternary extraction model involves multiple sub-tasks, including aspect recognition, consciousness recognition, and emotion memory classification. Each task may have different importance and difficulty during training. By mapping the deviation rate to dynamic weight coefficients, the loss functions of each task are weighted and fused to balance the contribution of each task.
[0050] This embodiment constructs corresponding loss functions for each aspect, opinion, and sentiment polarity using binary cross-entropy. By using the deviation rate of each element as a weight coefficient, the contribution of different elements to the total loss is dynamically adjusted, enhancing the model's attention to 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 for the composite loss function is: , in, The value of the composite loss function. The original loss function for the sentiment triad extraction model is... For diverse perception loss functions, and It is a constant.
[0052] It should be noted that during the training of the sentiment triad extraction model, while using the original loss function of the sentiment triad extraction model, a diversity perception loss function is introduced. The loss function is further weighted and fused according to the uncertainty of each task, thereby improving the overall training effect. Especially when dealing with complex emotional expressions, the trained model can accurately identify sentiment triads.
[0053] Furthermore, this invention also provides a method for extracting emotion triples, combined with Figure 6 Let's take a look. Figure 6 A flowchart illustrating an embodiment of the emotion triplet extraction method provided by the present invention is shown below. Figure 5 As shown, it includes: S601, Obtain text data; S602. Input the text data into the optimized target sentiment triplet extraction model and output the sentiment triplet results. The optimized target sentiment ternary extraction model is obtained based on the aforementioned sentiment ternary extraction model optimization method.
[0054] In an embodiment of the present invention, firstly, the text data to be processed is obtained; then, the optimized target sentiment triple extraction model is used to process the text data, and the sentiment triple result of the text data is 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 components shown, and more or fewer components may be implemented instead.
[0056] In some embodiments, processor 701 may be a central processing unit (CPU), a microprocessor, or other data processing chip, used to run program code stored in memory 702 or process data, such as the emotion triplet extraction method of the present invention.
[0057] In some embodiments of the present invention, processor 701 may be a single server or a group of servers. 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, public cloud, hybrid cloud, community cloud, distributed cloud, internal cloud, multi-cloud, etc., or any combination thereof.
[0058] In some embodiments, memory 702 may be an internal storage unit of the emotion triplet recognition device 700, such as a hard disk or memory of the emotion triplet recognition device 700. In other embodiments, memory 702 may also be an external storage device of the emotion triplet recognition device 700, such as a pluggable hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the emotion triplet recognition device 700.
[0059] Furthermore, the memory 702 may include both internal storage units of the emotion triplet recognition device 700 and external storage devices. The memory 702 is used to store the application software and various types of data installed on the emotion triplet recognition device 700.
[0060] In some embodiments, display 703 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, or an OLED (Organic Light-Emitting Diode) touchscreen. Display 703 is used to display information from the emotion triplet recognition device 700 and to display a visual user interface. Components 701-703 of the emotion triplet 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 triplet recognition program in the memory 702, the following steps can be implemented on the emotion triplet extraction model: Get text data; The text data is input into the optimized target sentiment triple extraction model, and the sentiment triple results are output. The optimized target sentiment ternary extraction model is obtained based on the aforementioned sentiment ternary extraction model optimization method.
[0062] It should be understood that when the processor 701 executes the emotion triad extraction model program in the memory 702, in addition to the functions mentioned above, it can also perform other functions, as can be found in the description of the corresponding method embodiments above.
[0063] Furthermore, this embodiment of the invention does not specifically limit the type of the mentioned emotional triad extraction model device 700. The emotional triad extraction model device 700 can be a portable emotional triad extraction model device such as a mobile phone, tablet computer, personal digital assistant (PDA), wearable device, or laptop computer. Exemplary embodiments of portable emotional triad extraction model devices include, but are not limited to, portable emotional triad extraction model devices running iOS, Android, Microsoft, or other operating systems. The aforementioned portable emotional triad extraction model device can also be other portable emotional triad extraction model devices. It should also be understood that in some other embodiments of the invention, the emotional triad extraction model device 700 may not be a portable emotional triad extraction model device, but rather a desktop computer with a touch-sensitive surface (e.g., a touch panel).
[0064] Accordingly, embodiments of the present invention also provide a computer-readable storage medium for storing computer-readable programs or instructions. When the programs or instructions are executed by a processor, they can implement the steps or functions in the emotion ternary extraction model optimization method provided in the above-described method embodiments.
[0065] Those skilled in the art will understand that all or part of the processes of the methods described in the above embodiments can be implemented by a computer program instructing related hardware (such as a processor, controller, etc.), and the computer program can be stored in a computer-readable storage medium. The computer-readable storage medium may be a disk, optical disk, read-only memory, or random access memory, etc.
[0066] The above provides a detailed description of the emotion ternary extraction model optimization method, recognition method, device, and storage device provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. An optimization method for the three-element emotion extraction model, characterized in that, include: An initial set of sentiment triplets is obtained based on the sentiment triplet extraction model and text statements; The deviation rate of each element in the triplet output by the emotional triplet extraction model is calculated based on the initial set of emotional triplets and the preset logical transformation relationship. Construct a diverse perceptual loss function based on the deviation rate and the classification loss of each element; A composite loss function is constructed based on the original loss function of the diverse perception loss function and the sentiment ternary extraction model; The target sentiment ternary extraction model is optimized based on the composite loss function. The preset logical transformation relationship includes transformation rules and logical result matching rules; Based on the initial set of sentiment triples and the preset logical transformation relationship, the deviation rate of each element in the triples output by the sentiment triple extraction model includes: Based on the initial set of emotion triplets and the transformation rules, the text statement is transformed across groups and within groups to obtain variant statements; The variant statements are input into the sentiment triple extraction model to obtain a set of variant triples; The deviation rate of each element in the triplet output by the sentiment triplet extraction model is calculated based on the set of variant triplets and the logical result matching rules. Based on the initial set of sentiment triples and transformation rules, cross-group and intra-group transformations are performed on the text statements to obtain variant statements, including: Divide multiple triplets in the initial set of sentiment triplets into target triplets and other triplets; Determine the words corresponding to each element in the target triplet and each element in other triplets in the text statement to obtain the target triplet words and other triplet words; The other triplet words in the text sentence are transformed according to the cross-group transformation rules in the transformation rules to obtain the first variant sentence; The target triplet words in the text sentence are transformed according to the intra-group transformation rules in the transformation rules to obtain the second variant sentence; The first variant statement and the second variant statement together constitute a variant statement.
2. The method for optimizing the sentiment ternary extraction model according to claim 1, characterized in that, The deviation rate of the sentiment triplet extraction model from each element in the triplet is calculated based on the variant triplet set and the logical result matching rules, including: Count the number of triplets in the variant triplets whose elements match the logical result matching rules, and obtain the statistical results for each element; The deviation rate of each element in the sentiment triplet extraction model is calculated based on the number of variant triplets in the variant triplet set and the statistical results of each element.
3. The method for optimizing the sentiment ternary extraction model according to claim 2, characterized in that, Based on the deviation rate and the classification loss of each element, a diverse perceptual loss function is constructed, including: The classification loss function for each element is constructed 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 allocation coefficient to perform weighted fusion of the classification loss functions of each element, thus obtaining the diverse perceptual loss function.
4. The method for optimizing the sentiment ternary extraction model according to claim 3, characterized in that, The formula for the multi-sensory loss function is: , in, For the value of the multi-sensory loss function, For the first i Deviation rate of each element For the first i The classification loss function for each element.
5. The method for optimizing the sentiment ternary extraction model according to claim 1, characterized in that, The formula for the composite loss function is: , in, The value of the composite loss function. The original loss function for the sentiment triad extraction model is... For diverse perceptual loss functions, and It is a constant.
6. A method for extracting emotion triples, characterized in that, include: Get text data; The text data is input into the optimized target sentiment triplet extraction model, and the sentiment triplet results are output. The optimized target sentiment ternary extraction model is obtained by the sentiment ternary extraction model optimization method according to any one of claims 1 to 5.
7. 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 5 and / or the emotion triple extraction method according to claim 6.
8. 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 triple extraction model optimization method according to any one of claims 1 to 5 and / or the emotion triple extraction method according to claim 6.