Emotional reason pair extraction method based on instruction fine tuning and multi-task learning framework

By employing instruction fine-tuning and a multi-task learning framework in the emotion cause pair extraction task, a hierarchical instruction set is constructed and combined with a low-rank adaptive strategy, solving the problems of data sparsity and complex cause identification, and realizing an efficient and accurate ECPE model suitable for public opinion analysis and recommendation systems.

CN121881985APending Publication Date: 2026-04-17CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING UNIV OF POSTS & TELECOMM
Filing Date
2026-01-05
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as data sparsity, complex cause identification, insufficient utilization of multi-task knowledge, and inadequate model generalization and interpretability in emotion cause extraction tasks. In particular, they fail to effectively combine the potential of multi-task learning and instruction fine-tuning when using large language models.

Method used

We adopt an instruction-based fine-tuning and multi-task learning framework to reconstruct ECPE into a conditional sequence generation task. By constructing a hierarchical instruction set and structured sequence mapping, we combine a low-rank adaptive strategy to fine-tune the model and use constrained decoding to ensure the accuracy and legality of the generated sequence.

Benefits of technology

It improves the accuracy and robustness of emotion reasoning extraction, achieves end-to-end structured output, reduces training and deployment costs, and enhances model interpretability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121881985A_ABST
    Figure CN121881985A_ABST
Patent Text Reader

Abstract

The invention belongs to the field of natural language processing and text sentiment analysis, and relates to an emotion reason pair extraction method based on instruction fine tuning and a multi-task learning framework. The method comprises the following steps: firstly, constructing a main task instruction containing emotion cause pair extraction (ECPE) and an auxiliary task instruction set related to the ECPE; secondly, uniformly converting the annotation data and the auxiliary task annotation data into a training sample in a specified format; then performing instruction fine tuning on a pre-trained large language model (LLM) by using the training sample, so that the LLM can execute corresponding ECPE main tasks or auxiliary tasks according to different instructions; and finally, in a reasoning stage, inputting an ECPE main task instruction and a to-be-analyzed text into the LLM after fine tuning, and outputting an extracted emotion reason pair. According to the method, the ECPE and related auxiliary tasks are subjected to fusion learning through a unified instruction fine tuning framework, the deep understanding and generalization ability of LLM on emotion and reasons is enhanced, and the accuracy of the ECPE is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing and text sentiment analysis, specifically involving a method for extracting sentiment cause pairs based on instruction fine-tuning and a multi-task learning framework. Background Technology

[0002] Emotional Cause Pair Extraction (ECPE) is an important and challenging task in the field of sentiment analysis. Its goal is to identify the expressed emotion and the reasons for that emotion from text. Accurate ECPE is of critical value for various downstream applications such as understanding user opinions, public opinion monitoring, human-computer interaction, and mental health analysis.

[0003] Traditional ECPE methods can be broadly categorized into rule-based methods, traditional machine learning-based methods, and deep learning-based methods. Rule-based methods rely on manually constructed dictionaries and grammatical rules, resulting in limited generalization ability and high maintenance costs. Traditional machine learning-based methods typically treat ECPE as a sequence labeling or relation extraction problem, but feature engineering is complex. In recent years, deep learning-based methods, particularly those based on recurrent neural networks (RNNs), convolutional neural networks (CNNs), and attention mechanisms, have made significant progress on ECPE tasks. However, these methods generally face the following challenges:

[0004] (1) Data sparsity problem: High-quality ECPE labeled data is expensive to obtain and the amount of data is relatively limited, which can easily lead to model overfitting.

[0005] (2) Identification of complex causes: The cause may be far away from the emotional words in the text, or the expression of the cause may be obscure, requiring complex contextual understanding and reasoning ability.

[0006] (3) Insufficient utilization of multi-task knowledge: The ECPE task is highly related to tasks such as sentiment classification and causal clause extraction, but existing methods often handle these tasks independently and fail to effectively utilize the shared knowledge between tasks to promote each other. Although there have been attempts at multi-task learning (MTL), it usually requires designing specific model structures and loss functions for each task, and the integration and optimization are relatively complex.

[0007] (4) Model generalization ability and interpretability: Existing models show a significant performance decline when faced with new expressions or domain transfers, and the model decision-making process often lacks transparency.

[0008] In recent years, Large Language Models (LLMs), such as BERT and the GPT series, have demonstrated powerful capabilities in natural language understanding and generation tasks. LLMs learn rich linguistic knowledge and a certain level of reasoning ability through pre-training on massive amounts of text data. Instruction fine-tuning techniques further enhance LLMs' ability to follow human instructions to complete specific tasks, enabling them to perform a variety of different NLP tasks by understanding natural language instructions.

[0009] While LLM brings new opportunities to ECPE, how to effectively combine the powerful capabilities of LLM with the characteristics of ECPE tasks, and systematically utilize the knowledge of relevant tasks to further improve ECPE performance, especially within a unified and flexible framework, remains a problem worthy of exploration in current research. Existing research, although there have been attempts to apply LLM to ECPE, has mostly focused on fine-tuning single tasks or simple migrations from traditional MTL frameworks, failing to fully leverage the potential of instruction fine-tuning in unified multi-task learning.

[0010] Therefore, how to leverage the semantic understanding and generation capabilities of LLM to efficiently solve ECPE tasks within a unified, low-resource framework, and effectively integrate auxiliary task knowledge, is a pressing technical challenge that needs to be addressed. Summary of the Invention

[0011] To address the aforementioned technical problems, this invention provides a method for extracting sentiment cause pairs based on instruction fine-tuning and a multi-task learning framework. This method abandons the traditional sequence labeling paradigm, innovatively reconstructing ECPE into a conditional sequence generation task, and utilizing instruction fine-tuning technology to jointly optimize the main and auxiliary tasks within a unified semantic space.

[0012] The specific technical solution adopted in this invention includes the following steps:

[0013] S1. Construction steps of main task and auxiliary task instructions: Unlike traditional supervised learning that only inputs text, this invention first constructs a hierarchical instruction set. :

[0014] Main task instructions ( ): Directly define the target of ECPE, such as "extract (sentiment, cause) pairs from the text".

[0015] Auxiliary task instruction set ( Designed based on the "Chain of Thought" concept, this tool is used to break down complex tasks and includes the following three types of instructions:

[0016] Sentiment polarity classification instruction: Guide the model to focus on sentiment evaluation words in the text and establish... The probability distribution.

[0017] Causal Fragment Extraction Instructions: Guide the model to use attention mechanisms to locate potential objective causal descriptions and establish... The probability distribution.

[0018] Causal logic verification instruction: Construct a counterfactual reasoning scenario, requiring the model to determine whether a logical implication exists between a given emotion and its cause. .

[0019] S2, Structured Sequence Mapping Steps:

[0020] To adapt to the decoder-only architecture of LLM, this invention uniformly maps all heterogeneous data into structured triples. .

[0021] The specific serialization template is defined as follows:

[0022]

[0023]

[0024] in, Indicates splicing, The expected output is in JSON format (e.g., [{"emotion": "anger", "cause": "poor service attitude"}]). This unified format allows the model to be trained on different types of tasks within the same batch, achieving implicit knowledge transfer.

[0025] S3. Generative instruction fine-tuning steps:

[0026] This is the core computational process of the present invention. The ECPE task is modeled as an autoregressive language generation problem.

[0027] (1) Loss function design

[0028] The goal of the model is to maximize the performance of a given instruction. and input text Under the given conditions, generate the target sequence. The probability of [the loss function]. This invention uses a masked loss function, whose formula is defined as:

[0029]

[0030] in, This represents the total length of the target sequence Y; Indicates the target sequence in Tokens for a time step; y<t represents All historical token contexts generated before the moment (including the instruction ) Represents the conditional probability distribution of the model under the parameter ; is the masking factor.

[0031] This mechanism ensures that the model not only understands the instruction (as a Condition), but also focuses on learning how to "generate answers", preventing the model from spending computing power on memorizing the instruction itself.

[0032] (2) Parameter-efficient fine-tuning mechanism

[0033] To reduce the computational cost, the present invention adopts a Low-Rank Adaptation (LoRA) strategy. Keep the pre-trained weights frozen and unchanged, and only introduce trainable low-rank matrices and in the bypass of the attention layer of the Transformer. The forward propagation calculation formula is:

[0034]

[0035] Among them, represents that the matrix has rows and columns, is the input vector of the layer, is the projection matrix initialized to zero, is the projection matrix initialized with a Gaussian distribution; is the rank (Rank) of the low-rank matrix, satisfying ; <000​​​​​​​​​​​​​​​​​

[0039] Generate at each step of the cluster search At that time, the candidate word list Dynamically reduced to an effective subset .

[0040] P(w| , , )

[0041] in, Represents any candidate token in the valid subset. This means selecting the option that maximizes the conditional probability P. As the output at the current moment .

[0042] For example, after generating {"emotion":, It only includes quotation marks and text tokens, excluding syntactically illegal characters such as parentheses. Finally, the generated string is directly converted into a structured object by the parser.

[0043] The present invention has at least the following beneficial effects:

[0044] 1. Improved accuracy and robustness of extraction: Through a unified instruction fine-tuning framework, the model can better understand the semantic logic of the main task by leveraging auxiliary tasks. In particular, for implicit causes, LLM's reasoning ability significantly outperforms traditional rule-based or shallow feature-based models.

[0045] 2. It achieves end-to-end structured output: it directly generates results in JSON format, and ensures the grammatical validity of the output through constraint decoding, so that the ECPE model can be seamlessly integrated into downstream public opinion analysis or recommendation systems without the need for complex post-processing logic.

[0046] 3. Significantly reduced training and deployment barriers: Combined with LoRA technology, this invention enables fine-tuning of data for specific domains on a single consumer-grade graphics card, improving training speed and significantly reducing memory usage, making it highly valuable for engineering applications.

[0047] 4. Enhanced model interpretability: Auxiliary task instructions are not only used for training but also for diagnosis during the inference phase. For example, the model can be asked "Why did you extract this reason?", thereby leveraging the interpretability of LLM to verify the rationality of the extraction results. Attached Figure Description

[0048] Figure 1 This is a schematic diagram of the overall process of an embodiment of the present invention.

[0049] Figure 2 This is a schematic diagram of the structured sequence mapping steps in an embodiment of the present invention.

[0050] Figure 3 This is a schematic diagram of the model structure for fine-tuning using a low-rank adaptive strategy employed in an embodiment of the present invention.

[0051] Figure 4 This is a flowchart illustrating the constrained reasoning and extraction steps of an embodiment of the present invention. Detailed Implementation

[0052] 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 some embodiments of the present invention, and not all embodiments. 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.

[0053] A method for extracting sentiment cause pairs based on instruction fine-tuning and a multi-task learning framework includes:

[0054] Dataset description and cleaning process:

[0055] This example uses the publicly available Chinese benchmark dataset (Sina News dataset) released in 2019. This dataset is one of the earliest and most widely cited Chinese benchmarks in the ECPE field. The data comes from Sina News and contains 1945 Chinese documents. The text consists of formal news reports, with standard language and clear logic. Among the documents, 10.23% contain multiple pairs of emotion-cause pairs, while 89.77% contain only one pair.

[0056] To ensure the statistical reliability of the experimental results, this embodiment adopts two data splitting strategies: one is to randomly divide the dataset into training set, validation set and test set in a ratio of 8:1:1; the other is to adopt 10-fold cross-validation.

[0057] To adapt to the input requirements of large language models and ensure data quality, a cleaning process was performed on the obtained original public Chinese dataset: the encoding format of all texts was unified (e.g., UTF-8); irrelevant HTML tags, non-printable characters, and noise symbols were removed from the text; the dataset was traversed to filter out blank documents or invalid data items with missing annotation information (e.g., missing emotion words or cause fragments) to ensure the integrity of the training samples.

[0058] S1: Steps for constructing main and auxiliary task instructions:

[0059] This step aims to build a hierarchical instruction set. This transforms ECPE tasks and their subtasks into natural language instructions, rather than traditional classification labels. The instruction set is divided into main task instructions. and auxiliary task instruction set The auxiliary task instruction set includes: 1. Main task instructions ( ): Used to instruct the model to directly perform emotion-cause pair extraction. For example: "Analyze the text, extract all (emotion, cause) pairs, and output them in JSON format."

[0060] 2. Auxiliary task commands ( To enhance the model's understanding of the task, according to claim 5, this embodiment constructs... , , Three types of auxiliary commands:

[0061] (1) Emotional polarity classification instructions: guiding model establishment For example, "How do you determine the emotional tone of this sentence: positive, negative, or neutral?"

[0062] (2) Cause fragment localization instructions: guiding model establishment The probability distribution focuses on locating possible causal clauses, such as: "Find the objective causal fragments in the text that lead to the emotion."

[0063] (3) Causal logic verification instruction: establish The probability distribution is used to verify a given emotion. Reasons for being a candidate Is there a logical implication between them? Answer "yes" or "no".

[0064] S2: Structured sequence mapping steps:

[0065] To utilize generative models to uniformly handle the aforementioned multiple tasks, this step involves processing each sample from the original corpus... Mapped to structured triples .like Figure 2 As shown, for any input text and selected instructions The construction process follows the serialization template below:

[0066] 1. Input sequence construction: .in As the start symbol, As a separator, This is the end-of-line character.

[0067] 2. Target sequence construction: .

[0068] 3. Label Formatting: Expected Output It is uniformly formatted as a JSON string. For example, for the main task, if the text contains "feeling irritable (emotion) because of rain (cause)", then it is constructed as [{"emotion": "irritable", "cause": "rain"}]. This format enables the model to learn the generation of structured information during training.

[0069] S3: Generative-based Instruction Fine-tuning Step:

[0070] In this step, the pre-trained large language model is fine-tuned with the above-mentioned structured data. It includes the following steps:

[0071] 1. Loss Function Calculation: The autoregressive language modeling (CLM) objective function is adopted. During the training process, the loss function is minimized, and its loss function is defined as:

[0072]

[0073] Among them, the key is the introduction of a masking factor . When belongs to the instruction or the input part, ; only when corresponds to the expected output , 1. This ensures that the model only calculates the gradient for the "answer" part and ignores the prediction loss of the "question" part.

[0074] 2. Parameter-efficient Fine-tuning: To reduce the training cost, this embodiment adopts a low-rank adaptation strategy. As Figure 3 shown, most of the weights of the pre-trained model are frozen , and only low-rank matrices and that are trainable are paralleled in the Transformer attention module.

[0075] (1) The forward propagation calculation formula is: .

[0076] (2) Among them is a projection matrix initialized with a Gaussian distribution, is a projection matrix initialized to zero, ensuring that the model behavior in the initial training stage is consistent with the pre-trained model.

[0077] S4: Constrained Inference and Extraction Step:

[0078] In the inference stage, the target text to be analyzed is input into the fine-tuned model and main task instructions To prevent generative models from generating "illusions" or generating invalid content that does not conform to grammar, this step employs a structured constraint decoding strategy.

[0079] Specifically, such as Figure 4 As shown, each sentiment cause pair is generated using cluster search. At each time step, maintain a syntax constraint based on a trie or finite state machine (FSA). This constraint is determined based on the currently generated context. Based on predefined JSON syntax rules, a subset of valid candidate words is dynamically constructed. ( (for the model's full vocabulary) .

[0080] The token selection process follows the probability formula below:

[0081] P(w| , , )

[0082] in, Represents any candidate token in the valid subset. This means selecting the option that maximizes the conditional probability P. As the output at the current moment .

[0083] The generated sequences strictly conform to the JSON format and are finally restored to structured data by a standard parser to complete the extraction of emotion cause pairs.

[0084] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

[0085] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications, equivalent substitutions, or improvements can be made without departing from the spirit and scope of the present invention. These modifications or substitutions should still fall within the scope of the claims of the present invention.

Claims

1. A method for extracting emotion cause pairs based on instruction fine-tuning and a multi-task learning framework, characterized in that, Includes the following steps: S1. Main and auxiliary task instruction construction steps: Construct a hierarchical instruction set containing natural language instructions. The instruction set is divided into a main task instruction. and an auxiliary task instruction set The main task instruction is used to direct the model to directly extract emotion cause pairs, while the auxiliary task instructions... Used to instruct the model to recognize sentiment elements. Used to instruct the model to identify the cause fragment. Used to instruct the model to identify and verify causal logic; S2, Structured Sequence Mapping Steps: Obtain the original publicly available Chinese dataset. To ensure data quality, remove irrelevant special characters and noise, standardize the text encoding format, and filter out blank or incorrectly formatted invalid data items. Then, map each sample... According to its applicable instructions (in Mapped to structured triples in a uniform format ,in The source token sequence obtained after segmenting the input text. To serialize the target token sequence after the actual labeled emotional reasons according to the predefined syntax; S3. Generative instruction fine-tuning steps: Using a pre-trained Large Language Model (LLM) as a probabilistic generative model. Using the structured triplet Hybrid instruction tuning is performed on the model to optimize the model parameters by minimizing the loss function. This enables the model to learn the mapping relationship from instructions and text to structured output sequences. ; S4. Constrained Reasoning and Extraction Steps: In the reasoning phase, the target text to be analyzed is input into the fine-tuned model. and main task instructions The model generates structured text sequences representing emotion cause pairs based on an autoregressive mechanism, and then restores them to structured data through a parser.

2. The method for extracting emotion cause pairs based on instruction fine-tuning and a multi-task learning framework according to claim 1, characterized in that, In step S2, the construction of the structured triple follows a serialization template, specifically defined as: ; ; in, This represents a string concatenation operation. , , Special tokens representing the start, separator, and end of the sequence, respectively; the desired output sequence It is composed of JSON format strings representing emotional cause pairs after word segmentation.

3. The method for extracting emotion cause pairs based on instruction fine-tuning and a multi-task learning framework according to claim 1, characterized in that, The loss function described in step S3 The specific calculation formula is defined as follows: ; Among them, represents the total length (number of Tokens) of the target sequence Y; represents the Tokens of the target sequence at time steps; y<t represents all historical Token contexts generated before the moment (including the instruction and the input ); represents the conditional probability distribution of the model under the parameter ; is the masking factor (Loss Mask), which is used to ensure that the model only calculates the loss of the target sequence of the expected output , and ignores the prediction losses of the instruction and the input parts, so as to focus on the learning of the task completion ability.

4. The method for extracting emotion cause pairs based on instruction fine-tuning and a multi-task learning framework according to claim 1, characterized in that, In step S3, the model parameters are... The optimization employs a low-rank adaptation (LoRA) fine-tuning strategy, which specifically includes: Freeze most of the weights of the pre-trained model Only a trainable low-rank factorization matrix is ​​introduced in the attention module of the Transformer layer. and Its forward propagation calculation formula is defined as: ; in, The matrix has OK List, The input vector of the layer, This is the output vector; The projection matrix is ​​initialized to zero. The projection matrix is ​​initialized using a Gaussian distribution; Let be the rank of a low-rank matrix, satisfying ; This means much smaller than, This is a scaling constant used to balance the contributions of pre-trained weights and adapter weights; only the matrix is ​​updated during training. and This reduces the number of trainable parameters to less than 1% of the total number of parameters.

5. The method for extracting emotion cause pairs based on instruction fine-tuning and a multi-task learning framework according to claim 1, characterized in that, The auxiliary task instruction set mentioned in step S1 The auxiliary task modeling probability is defined as follows to guide the model in learning the substructure of the ECPE task: (1) Sentiment polarity classification task: modeling probability This is used to enhance the model's ability to encode text sentiment features; among which, Text labels representing the polarity of emotions (such as "positive" or "negative"); (2) Cause fragment localization task: modeling probability This is used to train the model's ability to locate potential causal clauses in complex contexts; where, To extract from the input text The extracted reason clause text sequence; (3) Causal logic verification task: modeling probability ,in For a given emotion, As a candidate reason, this task requires the model to output binary validation labels. (e.g., "yes" or "no") to verify Is there a logical implication between them? 6. The method for extracting emotion cause pairs based on instruction fine-tuning and a multi-task learning framework according to claim 1, characterized in that, The reasoning process described in step S4 employs a beam search strategy combined with structured constraint decoding; for each token in the generated emotion cause pair... At that time, a subset of valid candidate terms is dynamically constructed based on a predefined JSON syntax format. (in (This is the full vocabulary of the model), and the output is calculated using the following formula: P(w| , , ); in, Represents any candidate token in the valid subset. This means selecting the option that maximizes the conditional probability P. As the output at the current moment This ensures that the generated emotional cause-result sequence conforms to the predefined syntax and guarantees that the result can be directly parsed by a JSON parser.