A small number of samples and fine-grained sentiment analysis method based on large language model
By generating and reasoning about enhanced training datasets and utilizing information reasoning methods of large language models, the difficulties faced by generative models in understanding ABSA rules and extracting sentiment information in scenarios with few samples are solved, achieving higher accuracy and robustness.
Patent Information
- Application Number
- CN202410919788.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2044-07-10
AI Technical Summary
Existing generative models cannot effectively understand ABSA rules in few-sample scenarios, resulting in non-standard generated formats or the inclusion of incorrect sentiment elements. They also fail to effectively extract sentiment information from short comments, affecting the accuracy of few-sample fine-grained sentiment analysis.
By constructing multiple original text label pairs, generating new text using a cross-over and incremental approach, combining a large language model for information reasoning, enhancing the training dataset, and using the thought chain method to obtain implicit information in the text, the pre-trained language model is fine-tuned to improve the model's performance in few-sample scenarios.
The model's generalization ability and robustness in small-sample scenarios are improved, and it can more accurately extract emotional elements from short comments, thereby improving the accuracy of small-sample fine-grained sentiment analysis.
Smart Images

Figure CN119597913B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, and in particular to a method, apparatus, device and readable storage medium for fine-grained sentiment analysis of a small number of samples based on a large language model. Background Art
[0002] Existing fine-grained sentiment analysis (ABSA) mostly uses generative methods. PARAPHRASE refines the fine-grained sentiment analysis task into a paraphrase generation process that utilizes label semantic information; DLO achieves dataset-level data enhancement by considering the impact of quaternion order in the template on model performance; ILO achieves instance-level data enhancement by selecting an appropriate template for each instance; although existing generative methods have achieved good results under full supervision settings, the fine-grained sentiment analysis task in few-sample scenarios is still challenging; Varia et al. use instruction fine-tuning and multi-task learning to solve the five subtasks involved in fine-grained sentiment analysis in few-sample scenarios in a unified way at one time.
[0003] Existing research uses a pre-trained language model (T5) to design question-answering templates and extracts sentiment elements from the generated sentences, which brings about a new paradigm for analyzing sentiment in a generative manner. However, due to the scarcity of labeled data used to guide adjustment or contextual learning, this trained generative model cannot well understand the rules of ABSA in few-sample scenarios, resulting in the model sometimes generating unexpected answers, which are either non-standard in format or contain incorrect sentiment elements, resulting in the inability to extract correct fine-grained sentiment information from online reviews. In addition, the ABSA dataset contains many short comments with no or little information. These short comment texts will affect the model's prediction of correct sentiment elements. Existing technologies have not paid attention to extracting sentiment elements from short comments, resulting in low model prediction accuracy, which in turn affects the precision of few-sample fine-grained sentiment analysis. Summary of the Invention
[0004] To this end, the technical problem to be solved by the present invention is to overcome the problem in the prior art that due to the scarcity of labeled data used to guide adjustment or contextual learning, the trained generative model cannot well understand the rules of ABSA in a few-sample scenario, resulting in a non-standard model generation format or containing erroneous sentiment elements, resulting in the inability to extract correct fine-grained sentiment information from online reviews; and the problem that no attention is paid to extracting sentiment elements from short reviews, resulting in low accuracy of model prediction, thereby affecting the accuracy of few-sample fine-grained sentiment analysis.
[0005] To solve the above technical problems, the present invention provides a small-sample fine-grained sentiment analysis method based on a large language model, comprising:
[0006] Acquire a data set and divide the data set into an original training set and an original test set; construct a plurality of original text label pairs based on the original text set and the original label set in the original training set; wherein each original text label pair includes an original text and its corresponding original label; each original label includes one or more quadruplets; the quadruplet is a sentiment quadruplet consisting of an aspect term, an aspect category, a sentiment polarity, and an opinion word;
[0007] If the original label in the current original text label pair contains a quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in a cross-wise manner to generate each newly added text corresponding to the current original text label pair; if the original label in the current original text label pair contains multiple quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in an incremental manner to generate each newly added text corresponding to the current original text label pair;
[0008] Based on the designed label determination prompt, the original text corresponding to the current original text label pair is compared with each newly added text, and the newly added emotional element corresponding to each newly added text is determined, thereby determining the label of each newly added text, and constructing each newly added text label pair corresponding to the current original text label pair;
[0009] Each original text label pair and its corresponding newly added text label pair are used as each enhanced text label pair, and an enhanced training set is constructed;
[0010] Based on the questions in the designed information reasoning prompt based on the thought chain, the large language model is used to obtain the corresponding answers to each question in turn, thereby inferring the implicit information of the corresponding augmented text for each augmented text label in the augmented training set;
[0011] Based on the enhanced training set and the implicit information of the enhanced text corresponding to each enhanced text label in the enhanced training set, a target training set is obtained;
[0012] Based on the designed input templates of each fine-grained sentiment analysis subtask, each text and the implicit information of each text in the target training set are converted into each input sequence of each fine-grained sentiment analysis subtask; based on the designed output templates of each fine-grained sentiment analysis subtask, each label in the target training set is converted into each output sequence of each fine-grained sentiment analysis subtask; the pre-trained language model is fine-tuned using each input sequence and each output sequence of each fine-grained sentiment analysis subtask to obtain a sentiment analysis model based on the pre-trained language model.
[0013] Preferably, the various text generation prompts designed include:
[0014] The first text generation prompt is to replace the aspect terms in the current original text with new aspect terms based on the original tags corresponding to the current original text; wherein the new aspect terms are synonyms of the aspect terms in the current original text;
[0015] The second text generation prompt and the third text generation prompt are based on the original label corresponding to the current original text, and use the new opinion word to replace the opinion word in the current original text; among them, in the second text generation prompt, the new opinion word is a synonym of the semantics of the opinion word in the current original text; in the third text generation prompt, the new opinion word is an antonym of the semantics of the opinion word in the current original text.
[0016] Preferably, if the original label in the current original text label pair contains a quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in a cross-wise manner to generate each newly added text corresponding to the current original text label pair, including:
[0017] If the original label in the current original text label pair contains a four-tuple, then according to the first text generation prompt, the second text generation prompt, and the third text generation prompt, the aspect terms or opinion words of the original comment text in the current original text are modified to generate the first new text, the second new text, and the third new text corresponding to the current original text label pair;
[0018] Intersecting a first newly added text corresponding to the current original text label pair obtained by using the first text generation prompt with a second newly added text corresponding to the current original text label pair obtained by using the second text generation prompt to obtain a fourth newly added text corresponding to the current original text label pair; wherein the aspect terms of the fourth newly added text are the aspect terms obtained by using the first text generation prompt, and the opinion words of the fourth newly added text are the opinion words obtained by using the second text generation prompt;
[0019] Intersecting a first newly added text corresponding to the current original text label pair obtained by using the first text generation prompt with a third newly added text corresponding to the current original text label pair obtained by using the third text generation prompt to obtain a fifth newly added text corresponding to the current original text label pair; wherein the aspect terms of the fifth newly added text are the aspect terms obtained by using the first text generation prompt, and the opinion words of the fifth newly added text are the opinion words obtained by using the third text generation prompt;
[0020] The first newly added text, the second newly added text, the third newly added text, the fourth newly added text and the fifth newly added text are newly added texts corresponding to the current original text label pair.
[0021] Preferably, if the original label in the current original text label pair contains multiple quadruplets, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in an incremental manner to generate each newly added text corresponding to the current original text label pair, including:
[0022] Select a first text generation prompt and a second text generation prompt; based on the first text generation prompt, modify the first aspect term of the original text in the current original text label pair to obtain a first newly added text corresponding to the current original text label pair; based on the second text generation prompt, modify the first opinion word of the first newly added text corresponding to the current original text label pair to obtain a second newly added text corresponding to the current original text label pair; based on the first text generation prompt, modify the second aspect term of the second newly added text corresponding to the current original text label pair to obtain a third newly added text corresponding to the current original text label pair; based on the second text generation prompt, modify the second opinion word of the third newly added text corresponding to the current original text label pair to obtain a fourth newly added text corresponding to the current original text label pair;
[0023] The modification is performed incrementally in sequence until all aspects of terms and opinion words in the original text of the current original text label pair are replaced, thereby obtaining each newly added text of the current original text label pair.
[0024] Preferably, the large language model is used to sequentially obtain answers to the questions in the information reasoning prompt based on the designed thought chain, thereby inferring the implicit information of the enhanced text corresponding to each enhanced text label in the enhanced training set, including:
[0025] The designed information reasoning based on thought chain includes: a first question, a first answer, a second question, and a second answer. The first question is the content of any enhanced text; the first answer is a simple understanding of the content of the current enhanced text using the large language model; the second question is the content of the current enhanced text with background knowledge added to it; the second answer is a simple answer to the content of the current enhanced text with background knowledge added using the large language model.
[0026] The content of the second answer is the implicit information of the current enhanced text; the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set is inferred in sequence.
[0027] Preferably, the fine-grained sentiment analysis subtasks include: aspect term extraction, aspect extraction and sentiment classification, target aspect sentiment detection, aspect-level sentiment triple extraction, and aspect-level sentiment quadruple extraction.
[0028] Preferably, after obtaining the sentiment analysis model based on the pre-trained language model, the method further includes:
[0029] Based on any text in the original test set, according to the designed information reasoning prompts based on thought chains, the large language model is used to infer the implicit information of the current text;
[0030] Determine the current fine-grained sentiment analysis subtask that needs to be executed; based on the designed input template of the current fine-grained sentiment analysis subtask, convert the current text and the implicit information of the current text into the input sequence of the current fine-grained sentiment analysis subtask;
[0031] The input sequence of the current fine-grained sentiment analysis subtask is input into the sentiment analysis model based on the pre-trained language model, and the output sequence corresponding to the sentiment element label of the current text is output. The sentiment element label corresponding to the current text is predicted based on the designed output template of the current fine-grained sentiment analysis subtask.
[0032] The present invention also provides a small sample fine-grained sentiment analysis device based on a large language model, comprising:
[0033] Data acquisition module: acquires a data set and divides the data set into an original training set and a test set; constructs multiple original text label pairs based on the original text set and the original label set in the original training set; wherein each original text label pair includes an original text and its corresponding original label; each original label includes one or more quadruples;
[0034] Data enhancement module: If the original label in the current original text label pair contains a quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in a cross manner to generate each newly added text corresponding to the current original text label pair; if the original label in the current original text label pair contains multiple quadruple, then based on the various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in an incremental manner to generate each newly added text of the current original text label pair; based on the designed label determination prompts, the original text corresponding to the current original text label pair is compared with each newly added text to determine the newly added emotional element corresponding to each newly added text, thereby determining the label of each newly added text, and constructing each newly added text label pair corresponding to the current original text label pair; each original text label pair and its corresponding each newly added text label pair are used as each enhanced text label pair, and an enhanced training set is constructed;
[0035] Information Enhancement Module: Based on the questions in the designed thought chain-based information reasoning prompt, the large language model is used to obtain the corresponding answers to each question in turn, thereby inferring the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set; based on the enhanced training set and the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set, the target training set is obtained;
[0036] Model construction module: Based on the designed input templates of each fine-grained sentiment analysis subtask, each text and the implicit information of each text in the target training set are converted into each input sequence of each fine-grained sentiment analysis subtask; based on the designed output templates of each fine-grained sentiment analysis subtask, each label in the target training set is converted into each output sequence of each fine-grained sentiment analysis subtask; the pre-trained language model is trained using each input sequence and each output sequence of each fine-grained sentiment analysis subtask to obtain a sentiment analysis model based on the pre-trained language model.
[0037] The present invention also provides a small sample fine-grained sentiment analysis device based on a large language model, comprising:
[0038] memory for storing computer programs;
[0039] A processor is configured to implement the steps of the above-described method for fine-grained sentiment analysis of a small number of samples based on a large language model when executing the computer program.
[0040] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for fine-grained sentiment analysis of a small number of samples based on a large language model are implemented.
[0041] The above technical solution of the present invention has the following beneficial effects compared with the prior art:
[0042] The present invention discloses a method for fine-grained sentiment analysis based on a large language model for small-sample data. The method utilizes the generation and reasoning capabilities of the large language model to enhance text data from both the quantitative and information perspectives. Quantity enhancement involves using the large language model to quantitatively enhance each original text in the original training set. First, various designed texts are used to generate prompts. Then, based on the number of quadruple pairs in the labels corresponding to different original texts, a crossover or incremental approach is selected to generate multiple enhanced texts. Labels are then used to determine prompts and labels for the newly generated multiple enhanced texts, ultimately obtaining an enhanced training dataset. Information enhancement involves using the large language model to enhance information for each enhanced text. A designed information reasoning method based on chain of thought (CoT) is used to infer implicit information (information not explicitly expressed in the text) from the text. During the training phase, data enhancement aims to improve the generalization, robustness, and performance of the model by transforming and expanding the existing data, thereby enabling the model to better understand the ABSA rules in small-sample scenarios and learn more knowledge during the training phase. Information enhancement aims to obtain information from short comments, thereby improving the accuracy and effectiveness of model predictions and enhancing the precision of small-sample fine-grained sentiment analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below based on specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0044] Figure 1 This is a framework diagram of a small number of sample fine-grained sentiment analysis method based on a large language model provided by the present invention;
[0045] Figure 2 It is a text generation graph based on a cross-method;
[0046] Figure 3 It is a text generation graph based on incremental method;
[0047] Figure 4 This is a schematic diagram of a small-sample fine-grained sentiment analysis device based on a large language model provided by the present invention. DETAILED DESCRIPTION
[0048] The present invention will be further described below with reference to the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, the embodiments are not intended to limit the present invention.
[0049] Reference Figure 1 As shown, the present invention provides a small sample fine-grained sentiment analysis method based on a large language model; specifically comprising:
[0050] S1: Get the dataset and divide it into the original training set and the original test set ; Based on the original training set The original text collection in and the original tag set , construct multiple original text label pairs, Indicates the original text label pairs; wherein each original text label pair includes an original text and its corresponding original label; each original label includes one or more quadruples; the quadruples are sentiment quadruples consisting of aspect terms (AT), aspect categories (AC), sentiment polarity (SP) and opinion words (OT);
[0051] Among them, all texts in this invention are review texts;
[0052] S2: Based on the designed various text generation prompts, modify the aspect terms or opinion words of the original text in the current original text label pair, thereby generating various new texts corresponding to the current original text label pair;
[0053] Among them, the various text generation prompts designed include:
[0054] The first text generation prompt is to replace the aspect terms in the current original text with new aspect terms based on the original tags corresponding to the current original text; wherein the new aspect terms are synonyms of the aspect terms in the current original text;
[0055] The second text generation prompt and the third text generation prompt are based on the original label corresponding to the current original text, and use the new opinion word to replace the opinion word in the current original text; wherein, in the second text generation prompt, the new opinion word is a synonym of the opinion word in the current original text; and in the third text generation prompt, the new opinion word is an antonym of the opinion word in the current original text;
[0056] To maintain data balance and diversity, we designed two methods: crossover and increment, based on the number of quadruple groups in the labels. The specific implementation methods are as follows:
[0057] Reference Figure 2 As shown, if the original label in the current original text label pair contains a four-tuple, then according to the first text generation prompt, the second text generation prompt, and the third text generation prompt, the aspect terms or opinion words of the original comment text in the current original text are modified to generate the first new text, the second new text, and the third new text corresponding to the current original text label pair;
[0058] Intersecting a first newly added text corresponding to the current original text label pair obtained by using the first text generation prompt with a second newly added text corresponding to the current original text label pair obtained by using the second text generation prompt to obtain a fourth newly added text corresponding to the current original text label pair; wherein the aspect terms of the fourth newly added text are the aspect terms obtained by using the first text generation prompt, and the opinion words of the fourth newly added text are the opinion words obtained by using the second text generation prompt;
[0059] Intersecting a first newly added text corresponding to the current original text label pair obtained by using the first text generation prompt with a third newly added text corresponding to the current original text label pair obtained by using the third text generation prompt to obtain a fifth newly added text corresponding to the current original text label pair; wherein the aspect terms of the fifth newly added text are the aspect terms obtained by using the first text generation prompt, and the opinion words of the fifth newly added text are the opinion words obtained by using the third text generation prompt;
[0060] The first new text, the second new text, the third new text, the fourth new text and the fifth new text are new texts corresponding to the current original text label pair;
[0061] The above process is that when the number of quadruplets is 1, three new text and label pairs are generated using the first text generation prompt, the second text generation prompt, the third text generation prompt, and the label determination prompt. Then, two new text and label pairs are obtained by cross-combining these three new text and label pairs.
[0062] Reference Figure 3 As shown, if the original label in the current original text label pair contains multiple quadruplets, the first text generation prompt and the second text generation prompt are selected; based on the first text generation prompt, the first aspect term of the original text in the current original text label pair is modified to obtain the first newly added text corresponding to the current original text label pair; based on the second text generation prompt, the first opinion word of the first newly added text corresponding to the current original text label pair is modified to obtain the second newly added text corresponding to the current original text label pair; based on the first text generation prompt, the second aspect term of the second newly added text corresponding to the current original text label pair is modified to obtain the third newly added text corresponding to the current original text label pair; based on the second text generation prompt, the second opinion word of the third newly added text corresponding to the current original text label pair is modified to obtain the fourth newly added text corresponding to the current original text label pair;
[0063] Modify incrementally in sequence until all aspects of terms and opinion words in the original text of the current original text label pair are replaced, thereby obtaining each newly added text of the current original text label pair;
[0064] The above process is that when the number of quadruplets is greater than 1, only the first text generation prompt, the second text generation prompt and the label determination prompt are used to continuously generate new text and label pairs in an incremental manner;
[0065] Based on the designed label determination prompt, the original text corresponding to the current original text label pair is compared with each newly added text, and the newly added emotional element corresponding to each newly added text is determined, thereby determining the label of each newly added text, and constructing each newly added text label pair corresponding to the current original text label pair;
[0066] Each original text label pair and its corresponding newly added text label pair are used as each enhanced text label pair, and an enhanced training set is constructed. ;
[0067] Among them, S2 is for data enhancement. The purpose of data enhancement is to improve the generalization ability, robustness and performance of the model by transforming and expanding the existing data; at the same time, it allows the model to learn more knowledge during the training phase;
[0068] S3: Based on the questions in the designed thought chain-based information reasoning prompt, the large language model is used to obtain the corresponding answers to each question in turn, thereby inferring the implicit information of the corresponding augmented text for each augmented text label in the augmented training set; Represents a collection of augmented texts; Table enhancement tag collection; represents a set of enhanced text label pairs;
[0069] The information reasoning prompts designed based on thought chains include: a first question, a first answer, a second question, and a second answer. The first question is the content of any enhanced text; the first answer is a simple understanding of the content of the current enhanced text using a large language model; the second question is the content of the current enhanced text with background knowledge added to it; the second answer is a simple answer to the content of the current enhanced text with background knowledge added using a large language model (LLM).
[0070] The content of the second answer is the implicit information of the current enhanced text; the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set is inferred in sequence;
[0071] Based on the enhanced training set and the implicit information of the enhanced text corresponding to each enhanced text label in the enhanced training set, the target training set is obtained. ; represents the target training text set; target training label set; Target training implicit information collection;
[0072] In order to use the LLM to gradually infer the implicit information of the text (information not clearly expressed in the sentence), a thought chain-based information inference prompt is designed. It is mainly divided into two steps: the first step requires the LLM to briefly understand the sentence, that is, the first question is used to require the LLM to briefly understand the sentence and obtain the LLM's reply as the first answer; the second step adds some background knowledge and infers the implicit information based on the answer output of the LLM in the first step. That is, the second question is used to add some background knowledge on this basis, and the implicit information of the text is inferred based on the first answer to obtain the second answer. The background knowledge is content related to the current enhanced text;
[0073] In a specific embodiment of the present invention, the field to which the current enhanced text belongs is used as the background knowledge of the current enhanced text. The specific rules of information reasoning prompts based on the thought chain are shown in Table 1. According to Table 1, it can be translated into the content shown in Table 2.
[0074] Table 1 Information reasoning tips based on thought chain
[0075] Question 1: Given the text "Original Review Text", what is your understanding of the text? Keep your answers short. –Answer 1: {LLM response} Question 2: The text "Original Review Text" is a comment from the restaurant field. "Answer 1" What does the sentenceimply ? answer briefly. –Answer 2: {LLM response}
[0076] Table 2 Translation of information reasoning prompts based on thought chain
[0077] Question 1: Given the original text, what is your understanding of it? Keep your answer brief. -First answer: {LLM response} Second question: The text "Original review text" is a review from the restaurant domain; what does the sentence "First answer" mean? Simple answer. -Second answer: {LLM response}
[0078] Assuming that the selected review text is "THE SERVICE IS AMAZING, I've had different waiters and they were all nice, which is a rare thing in the local area.", the implicit information reasoning process of the current review text is shown in Table 3. According to Table 3, it can be translated into the content shown in Table 4.
[0079] Table 3 Implicit information reasoning of review text
[0080] Question 1: Given the text "THE SERVICE IS AMAZING , i 've had different waiters and they were all nice , which is arare thing in local .", what is your understanding of the text? Keep your answers short. –Answer 1: {The sentence expresses a positive opinion about the service, mentioning the speaker's experience with multiple friendly waiters.} Question 2: The text "THE SERVICE IS AMAZING , i 've had different waiters and they were all nice , which is a rarething in local ." is a comment from the restaurant field. "The sentence expresses a positive opinion about the service, mentioning the speaker's experience with multiple friendly waiters." What does the sentence imply ? answerbriefly. –Answer 2: {The service is very good and the waiters were friendly.}
[0081] Table 4 Translation of implicit information inference of review text
[0082] Question 1: Considering the sentence "The service was fantastic. I had different waiters and they were all very nice, which is rare in this area," what is your understanding of the text? Keep your answer brief. – First answer: This sentence expresses a positive view of service and mentions the speaker's experiences with several friendly waiters. Question 2: "The service was excellent. I had different waiters and they were all very nice, which is rare in this area." This is a restaurant review. "This sentence expresses a positive view of the service and mentions the speaker's experience with several friendly waiters." What does this sentence mean? Simple answer. – Answer 2: {The service was good and the waiters were friendly.}
[0083] Among them, by enhancing the information of the comment text through LLM, it is possible to obtain the information of short comments, and then extract emotional elements from the short comments, improve the accuracy of model prediction, and increase the precision of small-sample fine-grained sentiment analysis;
[0084] S4: Based on the designed input templates of each ABSA subtask, each text and implicit information of each text in the target training set is converted into each input sequence of each ABSA subtask; based on the designed output templates of each ABSA subtask, each label in the target training set is converted into each output sequence of each ABSA subtask; the pre-trained language model is fine-tuned using each input sequence and each output sequence of each ABSA subtask to obtain a sentiment analysis model based on the pre-trained language model; wherein, the ABSA subtasks include: aspect term extraction, aspect extraction and sentiment classification, target aspect sentiment detection, aspect-level sentiment triple extraction, and aspect-level sentiment quadruple extraction; the input templates and output templates of each designed ABSA subtask are shown in Table 5 and Table 6 respectively;
[0085] Table 5 Input templates for the five ABSA subtasks
[0086] ABSA Subtasks Input Template Aspect Term Extraction (AE) Given the text: $Review Text, what are the aspect terms in it? Aspect Extraction and Sentiment Classification (AESC) Given the text: $Review Text, what are the aspect terms and their sentiments? Implicit information:$Implicit Information Target Aspect Sentence Detection (TASD) Given the text: $Review Text, what are the aspect terms, sentiments and categories? Implicitinformation: $Implicit Information Aspect-Level Sentiment Triple Extraction (ASTE) Given the text: $Review Text, what are the aspect terms, opinionterms and sentiments? Implicitinformation: $Implicit Information Aspect-Level Sentiment Quadruple Extraction (ASQP) Given the text: $Review Text, what are the aspect terms, opinion terms, sentiments and categories?Implicit information: $Implicit Information
[0087] Table 6 Output templates for the five ABSA subtasks
[0088] ABSA Subtasks Output Template Aspect Term Extraction (AE) $AT Aspect Extraction and Sentiment Classification (AESC) $AT is $SP Target Aspect Sentence Detection (TASD) $AT is $SP indicates $AC is $SP Aspect-Level Sentiment Triple Extraction (ASTE) $AT is $OT indicates it is $SP Aspect-Level Sentiment Quadruple Extraction (ASQP) $AT is $OT indicates $AC is $SP
[0089] Taking the complex ASQP task as an example, its input template is: "Given the text: $Review Text, what are the aspect terms, opinion terms, sentiments and categories? Implicit information: $Implicit Information"; the output template is "$AT is $OT indicates $AC is $SP", where if the aspect term is empty, it is replaced by "it", and the sentiment polarity "Positive", "Negative" and "Neutral" are replaced by "good", "bad" and "ok" respectively;
[0090] The input template is designed to better utilize the review text and its corresponding implicit information (to guide the model), rather than simply concatenating them as input; the output template is designed to better utilize the semantic information in the label, rather than simply providing structured output.
[0091] When fine-tuning the pre-trained language model using each input sequence and each output sequence of each ABSA subtask to obtain a sentiment analysis model based on the pre-trained language model, the loss function of the fine-tuning process is The expression is:
[0092]
[0093]
[0094] Where M represents the total number of subtasks; x t Represents the input sequence corresponding to the t-th subtask, which is composed of the target training text set T Aug The target text and target training implicit information set T corresponding to the t-th subtask implicit The target text corresponding to the t-th subtask is used as the input text corresponding to the t-th subtask; i represents the i-th word in the output sequence, which consists of the label corresponding to the current target text in the target training label set; n represents the length of the output sequence; θ represents the set of model parameters; p represents the probability;
[0095] S5: S2-S4 is the training phase. After the training phase, the sentiment analysis model based on the pre-trained language model is obtained, and the testing phase includes:
[0096] Based on any text in the original test set, according to the information reasoning prompts based on the designed thinking chain, the implicit information of the current text is inferred using the large language model; Combined with the designed information reasoning prompts based on thinking chain, the target test set D is obtained test ;
[0097] Determine the current ABSA subtask that needs to be executed; based on the designed input template of the current ABSA subtask, convert the current text and the implicit information of the current text into the input sequence of the current ABSA subtask;
[0098] Input the input sequence of the current ABSA subtask into the sentiment analysis model based on the pre-trained language model, output the output sequence corresponding to the sentiment element label of the current text, and predict the sentiment element label corresponding to the current text based on the designed output template of the current ABSA subtask; wherein the sentiment element label is a collective term for the results of all subtask predictions;
[0099] During the testing phase, the prediction results of different subtasks are different (the predicted result of task one may be one element, and the predicted result of task two may be three elements); taking the most complex emotion quadruple extraction in the present invention as an example, the goal of the emotion analysis model (QAIE model) based on the pre-trained language model provided by the present invention is to predict the emotion quadruple.
[0100] In order to verify that the sentiment analysis model based on the pre-trained language model (QAIE model) provided by the present invention has better performance in completing the five ABSA subtasks, comparisons are made with the existing methods in three benchmark datasets with three data volume settings of k=5, k=10, and k=20 and five ABSA subtasks. The specific results are shown in Table 7 below.
[0101] Table 7 Comparison of experimental results
[0102]
[0103] The framework for fine-grained sentiment analysis based on a large language model for small-sample data is the first to introduce a large language model into small-sample fine-grained sentiment analysis. It leverages the generation and reasoning capabilities of the large language model to enhance text data from both quantitative and information perspectives, primarily consisting of two phases: training and testing.
[0104] The training phase includes: quantity enhancement and information enhancement. Quantity enhancement involves using a large language model to enhance the quantity of each original text in the original training set. First, various designed texts are used to generate prompts. Then, based on the number of quadruple pairs in the labels corresponding to different original texts, a crossover or incremental approach is selected to generate multiple enhanced texts. Then, the labels are used to determine the prompts and the labels of the newly generated multiple enhanced texts, ultimately generating an enhanced training dataset. Information enhancement involves using a large language model to enhance the information of each enhanced text. A designed information reasoning method based on Chain of Thought (CoT) is used to infer the implicit information (information not explicitly expressed in the text) of the text.
[0105] During the training phase, data augmentation aims to improve the model's generalization, robustness, and performance by transforming and expanding existing data. This allows the model to better understand ABSA rules in low-sample scenarios and learn more during the training phase. Information augmentation aims to capture information from short reviews, thereby improving the model's prediction accuracy and enhancing the precision of low-sample, fine-grained sentiment analysis.
[0106] The testing phase involves: for each text in the original test set, obtaining its corresponding implicit information through information enhancement to obtain the target test set. Then, the current text and its corresponding implicit information are combined into the instruction input template and input into the model to extract the emotional elements in the current text.
[0107] Even with limited data, the model can still predict the sentiment elements of the review text well. At the same time, the generative method assisted by the large language model provided by the present invention achieves better performance indicators than the existing baseline method. The evaluation indicator used in the experiment is F1-Score, and the larger the value, the better the sentiment prediction effect. Table 7 shows that the performance indicators obtained by using the generative method based on the large language model provided are better than the generative baseline method in five fine-grained sentiment tasks and multiple few-sample settings. This shows the effectiveness and superiority of the proposed method, and also shows that the model has considerable application prospects in fine-grained sentiment analysis in natural language processing.
[0108] Reference Figure 4 As shown, a specific embodiment of the present invention further provides a small sample fine-grained sentiment analysis device based on a large language model, including:
[0109] Data acquisition module 100: Acquire a data set and divide the data set into an original training set and a test set; construct multiple original text label pairs based on the original text set and the original label set in the original training set; wherein each original text label pair includes an original text and its corresponding original label; each original label includes one or more quadruples;
[0110] Data enhancement module 200: Based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified, thereby generating each newly added text corresponding to the current original text label pair; wherein, if the original label in the current original text label pair contains a quadruple, then based on the designed various text generation prompts, combined with the cross method, the newly added text corresponding to the current original text label pair is obtained; if the original label in the current original text label pair contains multiple quadruple, then N types of text generation prompts are selected from the designed various text generation prompts, and each newly added text of the current original text label pair is generated in an incremental manner; based on the designed label determination prompt, the original text corresponding to the current original text label pair is compared with each newly added text, and the newly added emotional element corresponding to each newly added text is determined, thereby determining the label of each newly added text, and constructing each newly added text label pair corresponding to the current original text label pair; each original text label pair and its corresponding each newly added text label pair are used as each enhanced text label pair, and an enhanced training set is constructed;
[0111] Information enhancement module 300: Based on the questions in the designed thought chain-based information reasoning prompt, the large language model is used to sequentially obtain the corresponding answers to each question, thereby inferring the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set; based on the enhanced training set and the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set, a target training set is obtained;
[0112] Model construction module 400: Based on the designed input templates of each ABSA subtask, each text and implicit information of each text in the target training set is converted into each input sequence of each ABSA subtask; based on the designed output templates of each ABSA subtask, each label in the target training set is converted into each output sequence of each ABSA subtask; and the pre-trained language model is trained using each input sequence and each output sequence of each ABSA subtask to obtain a sentiment analysis model based on the pre-trained language model.
[0113] The device of this embodiment is used to implement the aforementioned small-sample fine-grained sentiment analysis method based on a large language model. Therefore, the specific implementation methods of the small-sample fine-grained sentiment analysis device based on a large language model can be seen in the embodiment part of the small-sample fine-grained sentiment analysis method based on a large language model in the previous text. For example, the data acquisition module 100, the data enhancement module 200, the information enhancement module 300, and the model construction module 400 are respectively used to implement S1 to S4 in the above-mentioned small-sample fine-grained sentiment analysis method based on a large language model. Therefore, its specific implementation methods can refer to the description of the corresponding embodiments of each part, and will not be repeated here.
[0114] A specific embodiment of the present invention further provides a small sample fine-grained sentiment analysis device based on a large language model, comprising:
[0115] A memory for storing a computer program; a processor for implementing the steps of the above-mentioned method for fine-grained sentiment analysis of a small number of samples based on a large language model when executing the computer program.
[0116] A specific embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned methods for fine-grained sentiment analysis of a small number of samples based on a large language model are implemented.
[0117] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0118] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0119] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0120] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0121] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the implementation methods. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all implementation methods here. Obvious variations or modifications arising therefrom remain within the scope of protection of the present invention.
Claims
1. A small sample fine-grained sentiment analysis method based on a large language model, characterized by: include: Obtain the data set and divide it into the original training set and the original test set; Based on the original text set and the original label set in the original training set, a plurality of original text label pairs are constructed; wherein each original text label pair includes an original text and its corresponding original label; each original label includes one or more quadruplets; the quadruplet is a sentiment quadruplet consisting of an aspect term, an aspect category, a sentiment polarity, and an opinion word; If the original label in the current original text label pair contains a quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in a cross-wise manner to generate each newly added text corresponding to the current original text label pair; if the original label in the current original text label pair contains multiple quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in an incremental manner to generate each newly added text corresponding to the current original text label pair; Based on the designed label determination prompt, the original text corresponding to the current original text label pair is compared with each newly added text, and the newly added emotional element corresponding to each newly added text is determined, thereby determining the label of each newly added text, and constructing each newly added text label pair corresponding to the current original text label pair; Each original text label pair and its corresponding newly added text label pair are used as each enhanced text label pair, and an enhanced training set is constructed; Based on the questions in the designed information reasoning prompt based on the thought chain, the large language model is used to obtain the corresponding answers to each question in turn, thereby inferring the implicit information of the corresponding augmented text for each augmented text label in the augmented training set; Based on the enhanced training set and the implicit information of the enhanced text corresponding to each enhanced text label in the enhanced training set, a target training set is obtained; Based on the designed input templates of each fine-grained sentiment analysis subtask, each text and the implicit information of each text in the target training set are converted into each input sequence of each fine-grained sentiment analysis subtask; based on the designed output templates of each fine-grained sentiment analysis subtask, each label in the target training set is converted into each output sequence of each fine-grained sentiment analysis subtask; the pre-trained language model is fine-tuned using each input sequence and each output sequence of each fine-grained sentiment analysis subtask to obtain a sentiment analysis model based on the pre-trained language model.
2. The method for fine-grained sentiment analysis based on a small number of samples and a large language model according to claim 1, characterized in that: The various text generation prompts designed include: The first text generation prompt is to replace the aspect terms in the current original text with new aspect terms based on the original tags corresponding to the current original text; wherein the new aspect terms are synonyms of the aspect terms in the current original text; The second text generation prompt and the third text generation prompt are based on the original label corresponding to the current original text, and use the new opinion word to replace the opinion word in the current original text; among them, in the second text generation prompt, the new opinion word is a synonym of the semantics of the opinion word in the current original text; in the third text generation prompt, the new opinion word is an antonym of the semantics of the opinion word in the current original text.
3. The method for fine-grained sentiment analysis based on a small number of samples and a large language model according to claim 2, characterized in that: If the original label in the current original text label pair contains a quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in a cross-wise manner to generate each new text corresponding to the current original text label pair, including: If the original label in the current original text label pair contains a four-tuple, then according to the first text generation prompt, the second text generation prompt, and the third text generation prompt, the aspect terms or opinion words of the original comment text in the current original text are modified to generate the first new text, the second new text, and the third new text corresponding to the current original text label pair; Intersecting a first newly added text corresponding to the current original text label pair obtained by using the first text generation prompt with a second newly added text corresponding to the current original text label pair obtained by using the second text generation prompt to obtain a fourth newly added text corresponding to the current original text label pair; wherein the aspect terms of the fourth newly added text are the aspect terms obtained by using the first text generation prompt, and the opinion words of the fourth newly added text are the opinion words obtained by using the second text generation prompt; Intersecting a first newly added text corresponding to the current original text label pair obtained by using the first text generation prompt with a third newly added text corresponding to the current original text label pair obtained by using the third text generation prompt to obtain a fifth newly added text corresponding to the current original text label pair; wherein the aspect terms of the fifth newly added text are the aspect terms obtained by using the first text generation prompt, and the opinion words of the fifth newly added text are the opinion words obtained by using the third text generation prompt; The first newly added text, the second newly added text, the third newly added text, the fourth newly added text and the fifth newly added text are newly added texts corresponding to the current original text label pair.
4. The method for fine-grained sentiment analysis based on a small number of samples and a large language model according to claim 2, characterized in that: If the original label in the current original text label pair contains multiple quadruplets, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in an incremental manner to generate each new text corresponding to the current original text label pair, including: Select a first text generation prompt and a second text generation prompt; based on the first text generation prompt, modify the first aspect term of the original text in the current original text label pair to obtain a first newly added text corresponding to the current original text label pair; based on the second text generation prompt, modify the first opinion word of the first newly added text corresponding to the current original text label pair to obtain a second newly added text corresponding to the current original text label pair; based on the first text generation prompt, modify the second aspect term of the second newly added text corresponding to the current original text label pair to obtain a third newly added text corresponding to the current original text label pair; based on the second text generation prompt, modify the second opinion word of the third newly added text corresponding to the current original text label pair to obtain a fourth newly added text corresponding to the current original text label pair; The modification is performed incrementally in sequence until all aspects of terms and opinion words in the original text of the current original text label pair are replaced, thereby obtaining each newly added text of the current original text label pair.
5. The method for fine-grained sentiment analysis based on a small number of samples and a large language model according to claim 1, characterized in that: According to the questions in the information reasoning prompt based on the designed thinking chain, the large language model is used to obtain the answers corresponding to each question in turn, thereby inferring the implicit information of the enhanced text corresponding to each enhanced text label in the enhanced training set, including: The designed information reasoning based on thought chain includes: a first question, a first answer, a second question, and a second answer. The first question is the content of any enhanced text; the first answer is a simple understanding of the content of the current enhanced text using the large language model; the second question is the content of the current enhanced text with background knowledge added to it; the second answer is a simple answer to the content of the current enhanced text with background knowledge added using the large language model. The content of the second answer is the implicit information of the current enhanced text; the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set is inferred in sequence.
6. The method for fine-grained sentiment analysis based on a small number of samples and a large language model according to claim 1, characterized in that: The fine-grained sentiment analysis subtasks include: aspect term extraction, aspect extraction and sentiment classification, target aspect sentiment detection, aspect-level sentiment triple extraction, and aspect-level sentiment quadruple extraction.
7. The method for fine-grained sentiment analysis based on a small number of samples and a large language model according to claim 1, characterized in that: After obtaining the sentiment analysis model based on the pre-trained language model, it also includes: Based on any text in the original test set, according to the designed information reasoning prompts based on thought chains, the large language model is used to infer the implicit information of the current text; Determine the current fine-grained sentiment analysis subtask that needs to be executed; based on the designed input template of the current fine-grained sentiment analysis subtask, convert the current text and the implicit information of the current text into the input sequence of the current fine-grained sentiment analysis subtask; The input sequence of the current fine-grained sentiment analysis subtask is input into the sentiment analysis model based on the pre-trained language model, and the output sequence corresponding to the sentiment element label of the current text is output. The sentiment element label corresponding to the current text is predicted based on the designed output template of the current fine-grained sentiment analysis subtask.
8. A small sample fine-grained sentiment analysis device based on a large language model, characterized in that: include: Data acquisition module: obtains the data set and divides the data set into the original training set and the test set; Based on the original text set and the original label set in the original training set, a plurality of original text label pairs are constructed; wherein each original text label pair includes an original text and its corresponding original label; and each original label includes one or more quadruplets; Data enhancement module: If the original label in the current original text label pair contains a quadruple, then based on the designed various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in a cross manner to generate each newly added text corresponding to the current original text label pair; if the original label in the current original text label pair contains multiple quadruple, then based on the various text generation prompts, the aspect terms or opinion words of the original text in the current original text label pair are modified in an incremental manner to generate each newly added text of the current original text label pair; based on the designed label determination prompts, the original text corresponding to the current original text label pair is compared with each newly added text to determine the newly added emotional element corresponding to each newly added text, thereby determining the label of each newly added text, and constructing each newly added text label pair corresponding to the current original text label pair; each original text label pair and its corresponding each newly added text label pair are used as each enhanced text label pair, and an enhanced training set is constructed; Information Enhancement Module: Based on the questions in the designed thought chain-based information reasoning prompt, the large language model is used to obtain the corresponding answers to each question in turn, thereby inferring the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set; based on the enhanced training set and the implicit information of the enhanced text corresponding to each enhanced text label pair in the enhanced training set, the target training set is obtained; Model construction module: Based on the designed input templates of each fine-grained sentiment analysis subtask, each text and the implicit information of each text in the target training set are converted into each input sequence of each fine-grained sentiment analysis subtask; based on the designed output templates of each fine-grained sentiment analysis subtask, each label in the target training set is converted into each output sequence of each fine-grained sentiment analysis subtask; the pre-trained language model is trained using each input sequence and each output sequence of each fine-grained sentiment analysis subtask to obtain a sentiment analysis model based on the pre-trained language model.
9. A small sample fine-grained sentiment analysis device based on a large language model, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of a method for fine-grained sentiment analysis of a small number of samples based on a large language model as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of a small-sample fine-grained sentiment analysis method based on a large language model as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Construction method of unified generation framework for aspect-level sentiment analysis
CN115455976A
Fine-grained emotion element extraction method and system
CN117892719A