Aspect emotion tetrad extraction method and device, equipment and medium
Through the combination of natural language processing and large language model, a category dictionary is constructed and prompt words are injected, which solves the problems of high cost, poor versatility and instability of emotional quadruple extraction in the prior art, and achieves efficient and accurate extraction effects.
Patent Information
- Application Number
- CN202411645161.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-03-11
AI Technical Summary
The prior art has high cost, poor versatility and instability in emotional quad extraction, especially when facing massive data.
Through a natural language processing-based method, part-of-speech analysis and dependency characterization of user comment data sets, the aspect words are automatically extracted and the aspect category dictionary is constructed, combined with the application programming interface (API) of the large language model, and the aspect category dictionary is injected with the prompt word to achieve efficient extraction of emotional quadruples.
The efficiency and accuracy of the large language model in terms of emotional quad extraction is achieved, which reduces artificial intervention and improves the universality and applicability of the model.
Smart Images

Figure CN119597932A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a method, device, equipment and medium for extracting sentiment quadruple. Background Art
[0002] With the rapid development of information technology and the popularization of the Internet, the emergence of massive data and information has brought unprecedented convenience to users. The need to automatically identify and extract emotions or opinions from text comments has emerged. This task is usually achieved through natural language processing, which can be called sentiment analysis. It has been widely used in e-commerce, social media, audio and video entertainment and other fields. The recommendation system based on comments can accurately capture user preferences and provide personalized recommendations by analyzing user feedback, thereby improving user satisfaction and platform stickiness.
[0003] By analyzing the four-tuple information of comments, the recommendation system can more accurately understand the user's specific preferences and emotional tendencies in a certain aspect, so that when making recommendations, it can not only consider the user's historical behavior and interest preferences, but also integrate the user's emotional information to provide more accurate and personalized recommendations. For example, when the system recommends a certain mobile phone, it can analyze the user's comments and point out that the reason for recommending the phone is that its "battery life" and "screen display" are highly praised by users. This explanatory nature not only increases the credibility of the recommendation, but also helps users make more informed decisions.
[0004] Existing aspect category extraction methods are divided into two categories: those based on supervised learning and those based on unsupervised learning. However, supervised learning requires a large amount of labeled data, rich domain experience and expertise, which will incur high additional costs, while unsupervised methods have poor versatility and adaptability, and are prone to performance degradation when faced with the complexity and diversity of language. To solve the above problems, the existing technology based on the large language model quadruple extraction method can automatically capture fine-grained sentiment information in the text and efficiently extract aspect sentiment quadruple through deep learning of large-scale corpora.
[0005] However, directly using a large language model for aspect category quadruple extraction also has the following problems:
[0006] (1) As a general model, the large language model needs to design targeted prompt words for specific tasks in order to complete related tasks.
[0007] (2) Due to the lack of expert knowledge about aspect words and aspect categories, the large prediction model is unstable and will infer aspect words and aspect categories in the input sentences based on its own training corpus, which will in turn expand the scope of aspect categories and affect the extraction effect.
[0008] (3) Faced with massive amounts of data, large language models are costly.
[0009] In view of this, there is an urgent need to provide a method for extracting aspect sentiment quadruple with better applicability and accuracy. Summary of the invention
[0010] In order to overcome the problems existing in the related art, the present disclosure provides a method, device, equipment and medium for extracting aspect emotion quadruple to solve the technical problems in the related art.
[0011] One or more embodiments of the present specification provide a method for extracting emotion quadruple, comprising the following steps:
[0012] Based on the user review dataset, the text is analyzed for part of speech and dependency characterization through natural language processing methods, aspect words are automatically extracted based on extraction rules, and aspect words are classified according to classification rules to obtain a preset number of aspect category dictionaries;
[0013] Constructing a dictionary containing a preset aspect category and setting a prompt word for detailed task description information, wherein the detailed task description information includes an execution flow of a large language model extraction aspect sentiment quadruple task and quadruple extraction logic; and
[0014] The prompt words and the comment dataset to be extracted are input into the large language model, and the aspect category dictionary is automatically called according to the form of the prompt words and injected into the large language model to realize the extraction of sentiment quadruple in user comments.
[0015] One or more embodiments of the present specification provide a device for extracting emotion quadruple, including:
[0016] The dictionary construction module is used to perform part-of-speech analysis and dependency characterization of text based on the user comment data set through natural language processing methods, automatically extract aspect words based on extraction rules, and classify aspect words according to classification rules to obtain a preset number of aspect category dictionaries;
[0017] The prompt word setting module is used to build a prompt word containing a dictionary of calling preset aspect categories and setting detailed task description information. The detailed task description information includes the execution process and quadruple extraction logic of the large language model extraction aspect emotion quadruple task, as well as
[0018] The quadruple extraction module is used to input the prompt words and the comment data set to be extracted into the large language model, automatically call the aspect category dictionary built by the dictionary construction module according to the form of the prompt words, and inject it into the large language model to realize the extraction of sentiment quadruple in user comments.
[0019] One or more embodiments of the present specification provide a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aspect emotion quadruple extraction method as described above when executing the computer program.
[0020] One or more embodiments of the present specification provide a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for extracting aspect emotion quadruplets as described above is implemented.
[0021] The present invention provides a method, device, equipment and medium for extracting aspect sentiment quadruple, which has the advantages of extracting aspect words from user comment texts in a data set based on an unsupervised method and a natural language processing method, being able to automatically construct aspect category dictionaries for comment texts in different fields, and automatically injecting the aspect category dictionary into the prompt words in the large language model through an application programming interface connected to a commercial large language model through constructed prompt words, thereby enabling the large language model to efficiently and more accurately extract sentiment quadruple from user comments, reducing human intervention and improving the versatility and applicability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0023] Figure 1 A flowchart of a method for extracting emotion quadruple provided in one or more embodiments of this specification;
[0024] Figure 2 A block diagram of a device for extracting emotion quadruple provided in one aspect of one or more embodiments of this specification;
[0025] as well as
[0026] Figure 3 A schematic diagram of the structure of a computer device provided for one or more embodiments of this specification. DETAILED DESCRIPTION
[0027] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below in conjunction with the drawings in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0028] The present invention is described in detail below in conjunction with specific implementation methods and the accompanying drawings.
[0029] Method Embodiment
[0030] According to an embodiment of the present invention, a method for extracting sentiment quadruple is provided, such as Figure 1 As shown, it is a flow chart of the aspect emotion quadruple extraction method provided in this embodiment. According to the aspect emotion quadruple extraction method of the embodiment of the present invention, the steps are as follows:
[0031] Step S1, based on the user comment dataset, performs part-of-speech analysis and dependency characterization on the text through natural language processing methods, automatically extracts aspect words based on extraction rules, and classifies the aspect words according to classification rules to obtain a preset number of aspect category dictionaries, wherein the user comment dataset can be user comment information in various fields such as e-commerce, social media, and audio-visual entertainment.
[0032] Step S2, constructing a dictionary containing calling preset aspect categories and setting prompt words for detailed task description information, wherein the detailed task description information includes the execution flow of the task of extracting aspect emotion quadruple from a large language model and the quadruple extraction logic.
[0033] Step S3, inputting the prompt words and the comment data set to be extracted into the large language model, automatically calling the aspect category dictionary according to the form of the prompt words and injecting them into the large language model to realize the extraction of the sentiment quadruple in the user comments.
[0034] The aspect sentiment quadruple extraction method provided in this embodiment extracts aspect words from user comment texts in a data set based on an unsupervised method and a natural language processing method, and can automatically construct aspect category dictionaries for comment texts in different fields. By accessing the application programming interface (API) of a commercial large language model, the aspect category dictionary is automatically injected into the large language model through the constructed prompt words, thereby enabling the large language model to efficiently and more accurately extract sentiment quadruple from user comments, reducing human intervention and improving the versatility and applicability of the model.
[0035] In this embodiment, the aspect sentiment quadruple refers to a quadruple consisting of aspect terms, aspect categories, opinion terms, and sentiment polarity (aspect, category, opinion, sentiment). In the actual extraction process, aspect terms, aspect categories, opinion terms, and sentiment polarity are derived from the semantic analysis of the comments. In some comments, when the user implicitly expresses his opinion on a certain aspect category, there is no explicit aspect term in the text, so the aspect term is "Null", and the extraction result of sentiment polarity is selected between the three results of positive, neutral, and negative.
[0036] In order to speed up the processing efficiency of part-of-speech analysis and dependency characterization of text, this embodiment needs to clean and standardize the user comment information in the data set to ensure that the data center only retains letters, numbers and punctuation marks, and excludes irrelevant information from the files of the original data set, and then analyzes and filters out the information in each comment that can be used for part-of-speech analysis and dependency characterization, such as four items related to users, products, and user text comments, including comment ID, product information, comment content text, and overview (user evaluation summary) (reviewID, asin, reviewText, summary).
[0037] In this embodiment, the review data set can be preprocessed and cleaned by a data processor. The processor first loads a complete review data set, such as a user review data set where each review is represented by: (user ID, product ID, user name, effective evaluation rate, user review text for the item, user rating for the item, evaluation summary, evaluation timestamp, and review time), and filters out four items related to the review ID, product, and user text review in each review, namely (reviewID, asin, reviewText, summary). Then, the filtered content is added to the list in order to form a complete data list with four items. The data processor will return the data list. The specific process of data processing by the data processor is as follows:
[0038] (1) First, load the comment data file in JSON format.
[0039] (2) Parse each review and extract the reviewerID, asin, reviewText, and summary.
[0040] (3) The extracted contents are sequentially added to a list to obtain a list containing all comment data.
[0041] In this embodiment, according to the dependency relationship between text words, a set of dependency-based rules are designed to extract potential aspect words, and these rules constitute general unsupervised aspect word extraction rules. For example, if a noun is directly modified by an adjective, the noun is likely to be an aspect word that describes the attributes of an item. Similarly, if a noun subject is followed by an adjective complement, the complement may also imply a certain point of view or evaluation of the user, thus becoming part of the aspect word. A preset dictionary is made based on the designed unsupervised extracted aspect words, among which is the most likely summary that can comprehensively cover all aspects covered in the product reviews in the dataset, and the specific implementation is as follows.
[0042] According to the list of the preprocessed comment data, in step S1, part of speech analysis and dependency characterization are performed on each column of the list by a natural language processing method, aspect words are automatically extracted based on the extraction rules, and the aspect words are classified according to the classification rules to obtain a preset number of aspect category dictionaries, which may include the following steps:
[0043] Step A1, based on the preprocessed review data, identify the part of speech and syntactic relationship between text words through natural language processing methods, analyze the regular connection between aspect and sentiment words in the reviews, that is, the dependency relationship, and extract aspect sentiment pair data based on the constructed unsupervised aspect word extraction rules, wherein the unsupervised aspect word extraction rules are to extract aspect sentiment pair data describing the connection between item attributes and user opinions based on the explicit description in the reviews; wherein the natural language processing method can be implemented through the spaCy tool.
[0044] In this embodiment, the part of speech can be classified according to existing part of speech, including noun, predicate, object, etc. The dependency relationship can include three types of relationships that can cover the connection between item attributes or user opinions, including adjective modification of noun (amod), the association between noun subject and adjective complement (nsubj+acomp), and the direct object of verb (dobj); among them,
[0045] Nouns describe the characteristics of products. Nouns and words that describe them constitute aspect sentiment pairs, which include the use of adjectives to modify nouns (amod) and the association of noun subjects with adjective complements (nsubj+acomp) to modify characteristics. For example, in the review text "Amazing sound and quality", the nouns sound and quality are two aspects of the product that users think are amazing, which express the user's point of view and can even determine the user's emotions.
[0046] The predicate and object describe the function of the product. The predicate and object are considered as aspects. The predicate also contains the user's emotions, that is, the direct object dependency (dobj) of the verb is used. For example, in the comment text "If you are recording human voice, this will eliminate sonic booms", the verb eliminate and the noun sonic booms form a verb direct object relationship. It can be seen that this product is used to reduce sonic booms, and elimination contains user emotions.
[0047] Step A2: Based on the aspect words automatically extracted by the extraction rules in step A1, the aspect words that meet the threshold condition are determined according to the frequency threshold, and then the aspect words are merged according to the word meaning similarity to obtain new aspect words, and the most frequently appearing new aspect words are selected as aspect categories, and a preset number of aspect categories are filtered based on the filtering rules and added to the aspect category dictionary.
[0048] In this embodiment, after automatically extracting aspect words according to dependency relationships, an aspect category dictionary is obtained through the following processing steps. The specific process is as follows.
[0049] Count the number of occurrences of the selected aspect words in the extraction results and arrange them in descending order. Select the aspect words that appear in the first n order, where n is a natural number greater than 1 and can be set to 100. Use the large language model to merge the synonymous aspect words into new aspect words based on word semantic similarity; select the most frequently occurring words as aspect categories based on the new aspect words and construct an aspect category dictionary. In this way, multiple aspect words describing the same aspect of the object are summarized, and new aspect categories are established and added to the preset dictionary. Finally, the screening results are controlled to be between 10-20 and preset as the aspect category dictionary. Taking Musical_Instrument as an example, the aspect category dictionary constructed by the above steps for this data set is [Instruments_parts, Usabililty, Quality, Feature, Price, Package, Design, Setup, Issue, Size, Effect, Weight, Service].
[0050] For different data sets, this embodiment first uses the method based on step S1 to extract knowledge and form an aspect category dictionary. Finally, a preset aspect category dictionary is designed, and prompt words with detailed task descriptions are involved, the process and details of the task are gradually explained to the large language model, and the format information of the task output is repeatedly declared. In order to accurately guide the large language model to perform the extraction task of aspect emotion quadruple, the designed prompt words need to contain prompts for calling the preset aspect category dictionary and involving detailed task descriptions, and the process and details of the task are gradually explained to the large language model.
[0051] The prompt words designed in this embodiment include the execution process of the large language model extraction aspect emotion quadruple task, quadruple extraction logic and output format specification. The prompt words designed in this embodiment include the role of the model, the specification of the model output format, the extraction logic of the quadruple content in the input data and the reference to the corresponding aspect category dictionary constructed for each data set through step S1.
[0052] In this embodiment, the prompt words should be concise, universal, and able to guide the expected output of the language model. Refer to Table 1 below, which is the prompt word structure, including task overview, dataset theme, extraction task and specific execution steps for implementing the task, output format specifications and other key considerations to ensure that the model can maintain consistency and efficiency when processing different types of comments.
[0053] Referring to Table 1, the prompt words include:
[0054] The system information section first defines the role of the large language model: an AI assistant for the sentiment quadruple extraction task, and also defines the output format [AT, AC, OP, ST].
[0055] A clear definition of the main content of the project: aspect-sentiment quadruple extraction.
[0056] Detailed task description: Design a method to call the aspect category dictionary to complete the task, and introduce the extraction logic of the four items in the quadruple. In particular, in the description of the extraction logic of the aspect category, the preset aspect category dictionary is described as the more likely result, and the results not summarized in the aspect category dictionary are also allowed. The model can infer by itself, and defines the sentiment polarity set: (positive, negative, neutral).
[0057] Emphasis on output format: The output format of the quadruple is emphasized to ensure the uniformity and readability of the output format.
[0058] Table 1. Prompt word structure
[0059]
[0060]
[0061]
[0062] The large language model used in this embodiment can be a generative pre-trained model (GPT model) developed by OpenAI. The model performs a single task, that is, calling the model to perform a task on a single comment. In this embodiment, the temperature of the model is set to 0.1, the maximum output token is set to 256, and other parameters use the default settings to reduce the creativity of the model and ensure the stability of the model output. Finally, the model outputs the aspect sentiment quadruple extracted from the incoming comment text.
[0063] It should be noted in this embodiment that the sample data used to build and train the model should be sample data related to the task, used to verify and adjust the effect of the prompt words, and the sample data should cover various situations and contexts of the task to ensure the universality and applicability of the prompt words. The model should be verified and evaluated by designing a validation set to continuously adjust and optimize the prompt words and model parameters to improve the quality and efficiency of the results generated by the language processing model, including evaluating the accuracy, fluency and consistency of the generated text with the task objectives.
[0064] In this embodiment, the data in the comment data set needs to be cleaned and standardized first, and then the comment data set to be extracted is batch processed to solve the problem of data loss caused by server errors or network errors due to execution breakpoints during the execution of the quadruple extraction task. The sub-batch processing tasks after batch processing are input into the large language model to complete the quadruple extraction of each comment, and the obtained results are saved as binary files. In particular, the quadruple extraction task process uses a batch processing mechanism and an abnormal reconnection mechanism to reduce the impact of abnormalities on data extraction.
[0065] In a specific embodiment, the batch processing mechanism is used as follows: every 100 comments in the comment data set are processed as a batch, and then the quadruple in each comment is extracted using the model designed in the big language, and the obtained results are temporarily stored in batch data groups. After all batch processing tasks are processed, the batch files are merged to form the final data. In the main program, the retry mechanism between services improves the fault recovery capability of the entire system to cope with unstable network transmission and save task resource consumption and time consumption.
[0066] In this embodiment, in order to optimize the storage of quadruple, the quadruple results extracted by the large language model are sorted and summarized, and invalid data are removed to obtain the aspect emotion quadruple data set, which can be specifically achieved by the following steps:
[0067] 1) Based on the binary file storing the extraction results, read the binary file, extract the user information and item information, filter out the empty data output by the large language model, and use regular expressions to match the remaining valid data with all data in the [AT, AC, OP, ST] format in the large language model output.
[0068] 2) Write the user information, item information, and regular expression matching results into a JSON file with the header (user, item, quad).
[0069] 3) Read the JSON file, filter out invalid information, split the quad into independent quads, and write them into a CSV format file with the header (user, item, AT, AC, OP, ST).
[0070] The aspect sentiment quadruple extraction method of this embodiment uses aspect sentiment quadruple to extract information in the information extraction link of the review-based recommendation system, and introduces a large language model as an analysis tool, which can more accurately and efficiently understand the user's specific preferences and emotional tendencies in a certain aspect.
[0071] Device Embodiment
[0072] According to an embodiment of the present invention, a device for extracting emotion quadruple is provided. Figure 2 As shown, it is a block diagram of aspect emotion quadruple extraction provided by this embodiment. The aspect emotion quadruple extraction according to the embodiment of the present invention includes:
[0073] The dictionary construction module 10 is used to perform part-of-speech analysis and dependency characterization on the text based on the user comment data set through natural language processing methods, automatically extract aspect words based on extraction rules, and classify the aspect words according to classification rules to obtain a preset number of aspect category dictionaries, wherein the user comment data set can be user comment information in various fields such as e-commerce, social media, and audio-visual entertainment.
[0074] The prompt word setting module 20 is used to construct a prompt word containing a dictionary for calling preset aspect categories and setting detailed task description information, wherein the detailed task description information includes the execution flow of the large language model extraction aspect emotion quadruple task and the quadruple extraction logic.
[0075] The quadruple extraction module 30 is used to input the prompt words constructed by the prompt word setting module 20 and the comment data set to be extracted into the large language model, automatically call the aspect category dictionary constructed by the dictionary construction module 10 according to the form of the prompt words, and inject it into the large language model to realize the extraction of emotional quadruple in user comments.
[0076] The aspect sentiment quadruple extraction device provided in this embodiment has a dictionary construction module 10 that extracts aspect words from user comment texts in a data set based on unsupervised methods and natural language processing methods, and can automatically construct aspect category dictionaries for comment texts in different fields. The quadruple extraction module 30 automatically injects the aspect category dictionary into the prompt words in the large language model through the application programming interface (API) of the commercial large language model and the prompt words constructed by the prompt word setting module 20, thereby enabling the large language model to efficiently and more accurately extract sentiment quadruple from user comments, reducing human intervention and improving the versatility and applicability of the model.
[0077] In this embodiment, the aspect sentiment quadruple refers to a quadruple consisting of aspect terms, aspect categories, opinion terms, and sentiment polarity (aspect, category, opinion, sentiment). In the actual extraction process, aspect terms, aspect categories, opinion terms, and sentiment polarity are obtained by analyzing the semantics of the comments. In many cases, there are none, so the aspect terms are "Null", and the extraction results of sentiment polarity are selected between the three results of positive, neutral, and negative.
[0078] In order to speed up the processing efficiency of part-of-speech analysis and dependency characterization of text, the data processing module 40 of this embodiment is used to clean and standardize the user comment information in the data set, ensure that the data center only retains letters, numbers and punctuation marks, exclude irrelevant information from the files of the original data set, and then filter out the information in each comment that can be used for part-of-speech analysis and dependency characterization, such as four items related to users, products, and user text comments, including review ID, product information, review content text, and overview (reviewID, asin, reviewText, summary).
[0079] In this embodiment, the review data set is preprocessed and cleaned by the data processing module 40. The processor first loads the complete review data set, such as each review in the user review data set represented by: (user ID, product ID, user name, effective evaluation rate, user review text for the item, user rating for the item, evaluation summary, evaluation timestamp, and review time), and filters out the four contents of each review, namely, review ID, product information, review content text, and summary, namely (reviewID, asin, reviewText, and summary). Then, the above filtered contents are added to the list in order to form a complete data list with four items. The data processor will return the data list. The specific process of data processing by the data processor is as follows:
[0080] (1) First, load the comment data file in JSON format.
[0081] (2) Parse each review and extract the reviewerID, asin, reviewText, and summary.
[0082] (3) The extracted contents are sequentially added to a list to obtain a list containing all comment data.
[0083] In this embodiment, according to the dependency relationship between text words, a set of dependency-based rules are designed to extract potential aspect words, and these rules constitute unsupervised aspect word extraction rules. For example, if a noun is directly modified by an adjective, the noun is likely to be an aspect word that describes the attributes of an item. Similarly, if a noun subject is followed by an adjective complement, the complement may also imply a certain point of view or evaluation of the user, thus becoming part of the aspect word. A preset dictionary is made based on the designed unsupervised extracted aspect words, among which is the most likely summary that can comprehensively cover all aspects covered in the product reviews in the dataset, and the specific implementation is as follows.
[0084] According to the list of the preprocessed comment data, the dictionary construction module 10 performs part-of-speech analysis and dependency characterization on each column of the list through a natural language processing method, automatically extracts aspect words based on the extraction rules, and classifies the aspect words according to the classification rules to obtain a preset number of aspect category dictionaries. Therefore, the dictionary construction module 10 is configured to perform the following steps:
[0085] Step A1, based on the preprocessed review data, identify the part of speech and syntactic relationship between text words through natural language processing methods, analyze the regular connection between aspect and sentiment words in the reviews, that is, the dependency relationship, and extract aspect sentiment pair data according to preset aspect word extraction rules, wherein the unsupervised aspect word extraction rule is to extract aspect sentiment pair data describing the connection between item attributes and user opinions based on the explicit description in the reviews; wherein the natural language processing method can be implemented through the spaCy tool.
[0086] In this embodiment, the part of speech can be classified according to existing part of speech, including noun, predicate, object, etc. The dependency relationship can include three types of relationships that can cover the connection between item attributes or user opinions, including adjective modification of noun (amod), the association between noun subject and adjective complement (nsubj+acomp), and the direct object of verb (dobj); among them,
[0087] Step A2: Based on the aspect words extracted by the extraction rules in step A1, determine the aspect words that meet the threshold condition according to the frequency threshold, then merge the aspect words according to the semantic similarity and obtain new aspect words, select the most frequently appearing new aspect words as aspect categories, and filter a preset number of aspect categories based on the filtering rules and add them to the aspect category dictionary.
[0088] In this embodiment, the automatic extraction of aspect words by the dictionary construction module 10 based on the extraction rules is specifically implemented by the following process:
[0089] The number of occurrences of the selected aspect words in the extraction results is counted and arranged in descending order. The first n aspect words that appear in the order are selected, where n is a natural number greater than 1. The large language model is used to merge the synonymous aspect words into new aspect words based on word semantic similarity. According to the new aspect words, the most frequently occurring words are selected as aspect categories and constructed into an aspect category dictionary. In this way, multiple aspect words that describe the same aspect of the object are summarized, and new aspect categories are established and added to the preset dictionary.
[0090] For different data sets, this embodiment first uses the knowledge extracted based on the dictionary building module 10 and forms an aspect category dictionary. Finally, a preset aspect category dictionary is designed, and prompt words with detailed task descriptions are involved, the process and details of the task are gradually explained to the large language model, and the format information of the task output is repeatedly declared. In order to accurately guide the large language model to perform the extraction task of the aspect emotion quadruple, the designed prompt words need to contain prompts for calling the preset aspect category dictionary and involving detailed task descriptions, and the process and details of the task are gradually explained to the large language model.
[0091] The prompt words designed in this embodiment include the execution process of the large language model extraction aspect emotion quadruple task, quadruple extraction logic, and output format specification. The prompt words designed in this embodiment include the role of the model, the specification of the model output format, the extraction logic of the quadruple content in the input data, and the reference to the corresponding aspect category dictionary constructed for each data set through step S1.
[0092] In this embodiment, the prompt words should be concise, targeted, and able to guide the expected output of the language model. Refer to Table 1 below for the prompt word structure, including task overview, dataset theme, extraction task and specific execution steps for implementing the task, output format specifications, and other key considerations to ensure that the model can maintain consistency and efficiency when processing different types of comments.
[0093] Prompt words include:
[0094] The system information section first defines the role of the large language model: an AI assistant for the sentiment quadruple extraction task, and also defines the output format [AT, AC, OP, ST].
[0095] Clear definition of the main content of the project: Aspect polarity quadruple extraction.
[0096] Detailed task description: Design a method to call the aspect category dictionary to complete the task, and introduce the extraction logic of the four items in the quadruple. In particular, in the description of the extraction logic of the aspect category, the preset aspect category dictionary is described as the more likely result, and the results not summarized in the aspect category dictionary are also allowed. The model can infer by itself, and defines the sentiment polarity set: (positive, negative, neutral).
[0097] Emphasis on output format: The output format of the quadruple is emphasized to ensure the uniformity and readability of the output format.
[0098] The large language model used in this embodiment can be a generative pre-trained model (GPT model) developed by OpenAI. The model performs a single task, that is, calling the model to perform a task on a single comment. In this embodiment, the temperature of the model is set to 0.1, the maximum output token is set to 256, and other parameters use the default settings to reduce the creativity of the model and ensure the stability of the model output. Finally, the model outputs the quadruple extracted from the incoming comment text.
[0099] In this embodiment, a data processing module 50 is further provided to clean and standardize the data in the comment data set, and in order to solve the problem of data loss caused by server errors or network errors caused by execution breakpoints during the execution of the quadruple extraction task, the comment data set to be extracted is batch processed, and the sub-batch processing tasks after batch processing are input into the large language model to complete the quadruple extraction of each comment, and the obtained results are saved as binary files. In particular, the quadruple extraction task process uses a batch processing mechanism and an abnormal reconnection mechanism to reduce the impact of abnormalities on data extraction.
[0100] In order to optimize the storage of quadruple, this embodiment further includes a storage optimization module 60: used to sort out and summarize the quadruple results extracted by the large language model, remove invalid data, and obtain the aspect emotion quadruple data set, which can be specifically achieved by the following steps:
[0101] 1) Based on the binary file storing the extraction results, read the binary file, extract the user information and item information, filter the empty data output by the large language model, and use regular expressions to match the remaining valid data with all data in the [AT, AC, OP, ST] format in the large language model output.
[0102] 2) Write the user information, item information, and regular expression matching results into a JSON file with the header (user, item, quad).
[0103] 3) Read the JSON file, filter out invalid information, split the quad into independent quads, and write them into a CSV format file with the header (user, item, AT, AC, OP, ST).
[0104] The embodiment of the present invention is an apparatus embodiment corresponding to the above-mentioned method embodiment. The specific operations of the processing steps of each module can be understood by referring to the description of the method embodiment, which will not be repeated here.
[0105] like Figure 3 As shown, the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for extracting aspect emotion quadruplets in the above-mentioned embodiment is implemented.
[0106] 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 method for extracting aspect emotion quadruple in the above-mentioned embodiment is implemented; or when the computer program is executed by a processor, the method for extracting aspect emotion quadruple in the above-mentioned embodiment is implemented.
[0107] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0108] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device or system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment. The device and system embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0109] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and the contents not described in detail in the specification of the present invention belong to the common knowledge of those skilled in the art.
Claims
1. A method for extracting aspect sentiment quadruple, characterized in that The following steps are involved: Based on the user review dataset, the text is analyzed for part of speech and dependency characterization through natural language processing methods, aspect words are automatically extracted based on extraction rules, and aspect words are classified according to classification rules to obtain a preset number of aspect category dictionaries; Construct a dictionary containing preset aspect categories and set prompt words for detailed task description information, including the execution process and quadruple extraction logic of the large language model extraction aspect sentiment quadruple task; as well as The prompt words and the comment dataset to be extracted are input into the large language model, and the aspect category dictionary is automatically called according to the form of the prompt words and injected into the large language model to realize the extraction of sentiment quadruple in user comments.
2. The aspect emotion quadruple extraction method as claimed in claim 1, characterized in that: It also includes steps for processing the user comment data set: The user comment dataset is cleaned and standardized, and irrelevant information is excluded from the files of the original dataset. The information used for part-of-speech analysis and dependency relationship characterization in each comment is then analyzed and determined.
3. The aspect emotion quadruple extraction method as claimed in claim 2, characterized in that: The specific steps for processing the user comment dataset are as follows: (1) First load the review data file; (2) Parse each review and extract the review ID, product information, review text, and overview; (3) The extracted contents are sequentially added to a list to obtain a list containing all comment data.
4. The method for extracting aspect emotion quadruple according to any one of claims 2 or 3, characterized in that: The natural language processing method is used to perform part-of-speech analysis and dependency characterization on each column of data in the list, and aspect words are automatically extracted based on the extraction rules. The aspect words are classified according to the classification rules to obtain a preset number of aspect category dictionaries, which specifically include the following steps: Step A1: Based on the preprocessed review data, the part of speech and syntactic relationship between text words are identified by natural language processing methods, the regular connection between aspect and sentiment words in the review is analyzed, that is, the dependency relationship, and aspect sentiment pair data is extracted based on the constructed unsupervised aspect word extraction rule, wherein the unsupervised aspect word extraction rule is to extract aspect sentiment pair data describing the connection between item attributes and user opinions based on the explicit description in the review; Step A2: Based on the aspect words extracted by the extraction rules in step A1, determine the aspect words that meet the threshold condition according to the frequency threshold, then merge the aspect words according to the semantic similarity to obtain new aspect words, and select the most frequently appearing new aspect words as aspect categories.
5. The aspect emotion quadruple extraction method as claimed in claim 1, characterized in that: The prompt words specifically include task overview, dataset theme, extraction task and specific execution steps for implementing the task, output format specifications and other key considerations.
6. The aspect emotion quadruple extraction method according to claim 1, characterized in that: The temperature of the large language model is set to 0.1 and the maximum output token is set to 256.
7. The aspect emotion quadruple extraction method according to claim 1, characterized in that: The method also includes batch processing the comment data set to be extracted, inputting the sub-batch processing tasks after batch processing into the large language model to complete the quadruple extraction of each comment, and sorting and summarizing the extracted quadruple results, removing invalid data, and obtaining the aspect sentiment quadruple data set.
8. A device for extracting aspect sentiment quadruple, characterized in that include: The dictionary construction module is used to perform part-of-speech analysis and dependency characterization of text based on the user comment data set through natural language processing methods, automatically extract aspect words based on extraction rules, and classify aspect words according to classification rules to obtain a preset number of aspect category dictionaries; The prompt word setting module is used to build a prompt word containing a dictionary of calling preset aspect categories and setting detailed task description information. The detailed task description information includes the execution process and quadruple extraction logic of the large language model extraction aspect emotion quadruple task, as well as The quadruple extraction module is used to input the prompt words and the comment data set to be extracted into the large language model, automatically call the aspect category dictionary built by the dictionary construction module according to the form of the prompt words, and inject it into the large language model to realize the extraction of sentiment quadruple in user comments.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the emotion quadruple extraction method as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the emotion quadruple extraction method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Movie comment viewpoint emotion tendency analysis method
CN110825876A
Improved utterance parsing
CN114902230A
Comment text viewpoint prediction method, system and equipment and storage medium
CN117592514A
Discourse parsing
US20210342548A1
Cited By
Task execution method and device of intelligent agent, equipment, medium and product
CN120278141A