Aspect-level emotion tetrad extraction method based on adaptive multi-template prompt learning
By employing an adaptive multi-template prompting learning method, we construct various sentiment element templates and combine them with a multi-task learning framework. This addresses the issues of template uniformity and insufficient semantic relationships in end-to-end generative methods, enabling efficient and accurate aspect-level sentiment quadruple extraction.
Patent Information
- Application Number
- CN202511774238.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-28
- Publication Date
- 2026-02-13
AI Technical Summary
Existing end-to-end generative methods face limitations in aspect-level sentiment quadruple extraction, such as the singleness of the target sequence template and insufficient modeling of semantic relationships between sentiment elements, leading to a decline in model performance and accuracy.
An adaptive multi-template prompting learning method is adopted. By constructing single-element full permutation templates, pair-level templates, and complete relationship templates, and combining a multi-task learning framework and constraint decoding strategy, the template combination and semantic relationship modeling of sentiment elements are dynamically optimized to improve the robustness and accuracy of the model.
It improves the efficiency and accuracy of aspect-level sentiment quadruple extraction, can adapt to complex text expressions, reduces information redundancy and contradictions, and enhances the overall performance and robustness of the model.
Smart Images

Figure CN121524696A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of deep learning, and particularly relates to an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning. BACKGROUND
[0002] With the rapid development of information technology and the continuous rise of Internet penetration rate, the number of user-generated content has grown rapidly, giving birth to massive text data resources worldwide. Especially on e-commerce platforms, social media, online forums and other diversified network channels, user-generated review content is particularly rich. These reviews not only record personal consumption behavior and social activities, but also reflect consumers' attitudes and emotional tendencies towards goods, services and social events on a broad level. As an important part of large-scale unstructured data, user reviews contain a lot of potential value and are an important data support for enterprises to understand user needs, improve product design and develop marketing strategies.
[0003] Traditional sentiment analysis methods rely on a large amount of manual annotation and rule setting. However, in the context of the explosive growth of text data, relying on manual analysis has been difficult to meet the requirements of efficiency and accuracy. On the one hand, manual annotation is time-consuming and labor-intensive, and cannot meet the real-time needs; on the other hand, the analysis process is easily affected by subjective bias, resulting in a decrease in the credibility of the conclusions. Therefore, how to make full use of natural language processing and artificial intelligence technology to realize the automatic extraction and analysis of emotional information has become a focus problem in the academic and industrial communities. At the same time, this task requires a balance between high accuracy and real-time performance in practical applications, which further promotes the rapid development of technology in the field of sentiment analysis.
[0004] In academic research and practical application, aspect-level sentiment analysis is attracting much attention because it can capture more detailed sentiment information of text. Unlike traditional sentiment analysis, which mainly provides overall evaluation of positive, negative or neutral, aspect-level sentiment analysis can achieve fine-grained analysis by analyzing specific aspects and their sentiment tendencies involved in the text. This method has broad industry application prospects: in the e-commerce field, aspect-level sentiment analysis can help enterprises dig deeper into consumers' specific feedback on product attributes (such as price, quality, appearance), guide enterprises to optimize product design, improve service quality, and develop precise marketing strategies, thereby improving consumer satisfaction and experience. In the field of information monitoring, in social media and news platforms, aspect-level sentiment analysis can analyze users' specific emotional attitudes towards hot events, brand activities or policy changes, providing strong support for enterprise brand management, public information monitoring and government scientific decision-making. In the fields of finance, medical care, education, etc., aspect-level sentiment analysis has shown important potential to support decision-making and optimize customer experience. For example, in finance, analyzing investors' sentiment towards specific market events, and in education, analyzing students' feedback on course content or teaching methods.
[0005] In sentiment analysis tasks, aspect sentiment quad prediction (ASQP) is an important fine-grained natural language understanding task that requires extracting four types of core sentiment information, including aspect terms, aspect categories, opinion terms, and sentiment polarities from text, thereby presenting the sentiment content of the text in the form of four-tuples. For example, the sentence "The food is very good, but the service is poor" can extract two four-tuples: (food, taste, very good, positive) and (service, attitude, poor, negative). ASQP meets the needs of higher-level sentiment analysis in multiple fields by providing more complete and structured sentiment information.
[0006] For four-tuple extraction, current research methods mainly include pipeline methods and end-to-end generative methods. Pipeline methods decompose the extraction of four-tuples into multiple independent sub-tasks and complete them step by-step in a pipeline manner. The advantage of this method is that it can fully utilize the optimization capabilities of single-task models, but its inherent defects are also very obvious: errors accumulate and propagate between tasks, leading to a decline in overall performance; in addition, the independent optimization of multiple sub-task models cannot efficiently capture the complex relationships between sentiment elements, resulting in high overall complexity of the model and difficulty in meeting the needs of actual large-scale scenarios.
[0007] End-to-end generative methods directly map text to structured sentiment quadruple outputs with pre-trained language models, which have become the mainstream solution to the quadruple extraction task. Generative methods convert quadruple extraction into a sequence-to-sequence generation task, directly generate structured outputs by constructing special target sequence templates and using pre-trained language models. This kind of method avoids the error accumulation problem of traditional pipeline methods and significantly improves the extraction performance.
[0008] However, end-to-end generative methods face two key challenges: on the one hand, the limitation of the single nature of the target sequence template. Existing methods usually rely on a single fixed template to convert input and output. This mechanism cannot fully capture different text expression patterns and sentiment features, which significantly limits the performance of the model. Especially when the expression of the input text is complex and diverse, the fixed template is more difficult to adapt to the needs of the actual scene. On the other hand, the lack of modeling of semantic relationships between sentiment elements. The sentiment information in the text often involves the mutual association of various aspects, categories, opinion terms, and sentiment polarities. The existing generative method lacks systematicity in template design, and information redundancy and contradiction between different templates are common. Simply increasing the number of templates may introduce noise, leading to a decrease in modeling efficiency and accuracy, and thus the efficiency of sentiment quadruple extraction is low. SUMMARY
[0009] The present application provides an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning, which can improve the efficiency and accuracy of aspect-level sentiment quadruple extraction based on adaptive multi-template prompt learning.
[0010] To achieve the above-mentioned purpose, the present application provides an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning, which comprises: The aspect, category, opinion, and sentiment polarity are marked by using a preset marker to obtain sentiment element markers, and a template pool is constructed using the sentiment element markers, the template pool including single-element full permutation templates, paired-level templates, and complete relationship templates; According to a preset template selection algorithm, templates are selected from the template pool to construct an initial detection model; According to a multi-task learning framework, the initial detection model is jointly trained, and a target detection model is obtained after training; According to a preset constraint decoding strategy, the target detection model is used to extract sentiment from the text to be detected to obtain a sentiment detection result.
[0011] To solve the above-mentioned problems, the present application also provides an aspect-level sentiment quadruple extraction device based on adaptive multi-template prompt learning, which comprises: An initial detection model construction module is configured to label aspects, categories, opinions and sentiment polarities by using preset label symbols to obtain sentiment element labels, and to construct a template pool by using the sentiment element labels, the template pool including single-element full permutation templates, pair-level templates and complete relationship templates; and an initial detection model is constructed by selecting templates from the template pool according to a preset template selection algorithm. An initial detection model training module is configured to jointly train the initial detection model according to a multi-task learning framework, and to obtain a target detection model after the training is completed. A sentiment detection result acquisition module is configured to extract sentiment from a text to be detected by using the target detection model according to a preset constraint decoding strategy, and to obtain a sentiment detection result.
[0012] To solve the above problems, the present application further provides an electronic device, which comprises: at least one processor; and a memory in communication with the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning described above.
[0013] To solve the above problems, the present application further provides a computer readable storage medium, which stores at least one computer program, and the at least one computer program is executed by a processor in an electronic device to implement the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning described above.
[0014] The present application labels aspects, categories, opinions and sentiment polarities by using preset label symbols to obtain sentiment element labels, and constructs single-element full permutation templates, pair-level templates and complete relationship templates by using the sentiment element labels, which can adapt to complex text expressions and improve the diversity of template types. Furthermore, an initial detection model is constructed by selecting one or more templates from the single-element full permutation templates, pair-level templates and complete relationship templates according to a preset template selection algorithm, which dynamically optimizes template combinations by the template selection algorithm, reduces information redundancy and contradictions, and improves modeling efficiency. In addition, the initial detection model is jointly trained according to a multi-task learning framework, and a target detection model is obtained after the training is completed, which can enhance the modeling capability between sentiment element semantic relationships by jointly training the model by the multi-task learning framework, and further improve the overall performance and robustness of the model. Finally, sentiment is extracted from a text to be detected by using the target detection model according to a preset constraint decoding strategy, and a sentiment detection result is obtained, which can improve the efficiency and accuracy of sentiment extraction. BRIEF DESCRIPTION OF DRAWINGS
[0015] Figure 1 A flowchart of an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application is shown in FIG. 1. Figure 2 A structural flowchart of an example of an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application is shown in FIG. 2. Figure 3 A template selection algorithm diagram of an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application is shown in FIG. 3. Figure 4 A constraint decoding strategy principle diagram of an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application is shown in FIG. 4. Figure 5 A functional module diagram of an aspect-level sentiment quadruple extraction device based on adaptive multi-template prompt learning provided by an embodiment of the present application is shown in FIG. 5. Figure 6 A structural diagram of an electronic device for implementing an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application is shown in FIG. 6.
[0016] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0017] It should be understood that the specific embodiments described herein are merely intended to explain the present application and are not intended to limit the present application.
[0018] The embodiment of the present application provides an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning. The execution subject of the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning includes but is not limited to at least one of the electronic devices capable of being configured to execute the method provided by the embodiment of the present application, such as a server and a terminal. In other words, the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning can be executed by software or hardware installed in a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be a stand-alone server, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution networks (CDN), and big data and artificial intelligence platforms, etc. basic cloud computing services.
[0019] Referring to Figure 1 Fig. 1 shows a flowchart of an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning according to an embodiment of the present disclosure. In this embodiment, the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning includes the following steps. S1, marking aspects, categories, opinions, and sentiment polarities using preset marking symbols to obtain sentiment element labels, and constructing a template pool using the sentiment element labels, the template pool including single-element full permutation templates, pair-level templates, and complete relationship templates.
[0020] It can be understood that the preset marking symbols are core elements in sentiment classification tasks, including: Aspect (a, aspect / attribute), Category (c, category / domain), Opinion (o, opinion / evaluation word), and Sentiment polarity (s, sentiment polarity). For example, given an input sentence composed of The purpose of aspect-level sentiment quadruple extraction is to extract all sentiment quadruples where , , , respectively represent aspect terms, aspect categories, opinion terms, and sentiment polarities. Aspects and opinions are usually specific text spans in a sentence , categories are predefined category sets to which aspects a belong , sentiment polarities belong to a sentiment category set , and correspond to positive, neutral, and negative, respectively.
[0021] Specifically, the construction method of the single-element full permutation template includes: Full permutation combination based on aspects, categories, opinions, and sentiment polarities to obtain permutation combination information, and extracting the combination order in the permutation combination information to obtain the order information of the sentiment elements; The sentiment element marking symbols and the sentiment elements are connected as a pair, and the connected pair is embedded into the order information of the corresponding sentiment elements to obtain the single-element full permutation template.
[0022] It can be understood that there are 4! = 24 permutation methods based on full permutation combination of aspects, categories, opinions, and sentiment polarities.
[0023] Exemplarily, the construction of the single-element full-permutation template can be as follows: input: The food is great and the environment is even better. Target sequence: [A] food [C] food quality [O] great [S] great [SSEP] [A] environment [C] ambience general [O] better [S] great. Wherein the special mark "[SSEP]" represents a splicing symbol.
[0024] Further, the construction method of the pair-level template comprises: According to the preset local logical rules, the aspects, categories, opinions and sentiment polarities are paired with each other to obtain a plurality of pair information; A single pair-level template is constructed by using each pair information, and a pair-level template is obtained by collecting the single pair-level templates corresponding to each pair information in the plurality of pair information.
[0025] It can be understood that the preset local logical rules refer to a rule set set for common logical relationships and causal relationships between sentiment elements, which is used to guide how to combine aspects (Aspect), categories (Category), opinions (Opinion) and sentiment polarities (Sentiment) during template construction, so as to ensure that the generated relationship conforms to human expression habits and semantic logic. For example, the aspect and the opinion ([AO]) reflect the association between the characteristics of a specific entity and the corresponding evaluation; the category and the sentiment polarity ([CS]) embody the overall sentiment tendency of a certain category; the aspect and the sentiment polarity ([AS]) express the sentiment judgment of a specific entity; and the category and the opinion ([CO]) associate the category with the evaluation expression.
[0026] Further, the construction method of the complete relationship template comprises: Obtaining sentiment element semantic information of aspects, categories, opinions and sentiment polarities; Based on the sentiment element semantic information, a complete relationship is recombined by using a preset disambiguation reconstruction algorithm to obtain a complete relationship template.
[0027] It can be understood that the preset paraphrase reconstruction algorithm refers to a regularized algorithm for recombining and interpreting the semantic information of emotional elements (aspects a, categories c, opinions o, and sentiment polarities s), and the role is to reconstruct scattered marked elements into a complete and reasonable emotional relationship expression according to preset logical relationships and language habits. For example, input: The food is great and the environment is even better. Target sequence: [CSAO] food quality is great because food is great [SSEP] ambience general is great because environment is better.
[0028] S2, according to the preset template selection algorithm, select templates from the template pool to construct an initial detection model.
[0029] It can be understood that the preset template selection algorithm refers to a two-stage template selection method, aiming to balance the performance of a single template and the complementarity between templates, and select a set of templates most suitable for the characteristics of the pre-trained language model from the previously constructed template set.
[0030] Specifically, the initial detection model is constructed by selecting templates from the template pool according to the preset template selection algorithm, comprising: Step 1, calculate the individual performance scores of single-element full permutation templates, paired-level templates and complete relationship templates respectively, to obtain single-element full permutation template performance scores, paired-level template performance scores and complete relationship template performance scores; Step 2, calculate the semantic correlation between multiple templates according to the probability distribution similarity calculation method; Step 3, calculate the complementarity score according to the single-element full permutation template performance score, the paired-level template performance score, the complete relationship template performance score and the semantic correlation between multiple templates; Step 4, select a preset number of templates to construct an initial detection model according to the complementarity score using a greedy algorithm.
[0031] Further, the semantic correlation between multiple templates is calculated according to the probability distribution similarity calculation method, comprising: The semantic correlation between multiple templates is calculated using the following formula : Wherein, is the training set, is the total number of samples in the training set, is the number of elements in the set, JS divergence, the probability distribution of the first template, the probability distribution of the first template.
[0032] Exemplarily, according to a preset template selection algorithm, one or more than one template is selected from a single-element full permutation template, a pair-level template and a complete relationship template to construct an initial detection model, and the following implementation steps can be adopted: The first stage: calculating the generation ability of each template on the training set, that is, the individual performance of the template. For a template set wherein is the number of templates, given an input sentence and its corresponding sentiment element quadruple label, the corresponding target sequence is constructed by the template , a pre-trained language model is used to obtain a conditional generation score , and the individual performance score of the template on the training set is calculated: The second stage, measure the semantic difference between templates. For template , after the target sequence is constructed using the template, the target sequence is input into the pre-trained language model to obtain the corresponding hidden state matrix and perform average pooling to generate a dimensional vector . In order to convert the vector into a probability distribution, the Softmax function is used to normalize it to generate a probability distribution , and the calculation formula is: In this way a discrete probability distribution representation is formed, reflecting the semantic weight of the template on each hidden dimension. Considering that the difference in semantic expression of the template will directly affect the model to obtain diversified perspectives, in order to capture the difference in semantic expression between templates, the present application adopts Jensen-Shannon (JS) divergence to calculate the semantic gap between two templates and , let and be the probability distribution corresponding to the two templates respectively, then the corresponding JS divergence can be expressed as: wherein, is the intermediate probability distribution, that is, and the average value of the semantic correlation between the template and To obtain stable and reliable correlation estimates, the average semantic correlation between the templates and is calculated on the training set : where denotes the average correlation of all instances between the templates and . In this way, a complete template correlation matrix is constructed. The symmetry of JS divergence can measure both the difference between templates and the complementarity indirectly, that is, templates with lower correlation can provide more diverse perspectives, which is particularly important for capturing the four-tuple information comprehensively.
[0033] After calculating the single-template performance score vector and the inter-template semantic correlation matrix , the complementarity score between any two templates and can be calculated as: An equal weight strategy is adopted to attach equal importance to the individual performance and complementary contribution of the templates, so as to balance between performance and diversity.
[0034] Based on the above scoring mechanism, an efficient greedy algorithm is used to select optimal templates. The algorithm first selects the template with the highest single-template score as the initial set, and then gradually adds the candidate template with the strongest complementarity to the selected templates until the predetermined number is reached.
[0035] S3, jointly training the initial detection model according to the multi-task learning framework, and obtaining the target detection model after training.
[0036] It can be understood that the multi-task learning framework refers to a machine learning method that simultaneously learns multiple related tasks in the same training process by sharing model parameters or feature representations, thereby improving the generalization ability and overall performance of the model.
[0037] Specifically, the joint training of the initial detection model according to the multi-task learning framework, and obtaining the target detection model after training, includes: obtaining a preset input text, and using a pre-trained language model to perform T5 encoding to obtain a context-sensitive representation feature code; Based on the selected template, a static embedded representation is generated using the embedding layer of the T5 encoder; The static embedding representation is used as the query of the attention mechanism, the context-sensitive representation feature encoding is used as the key and value of the attention mechanism, and the dynamic embedding representation of the template is calculated using the attention function. The fused representation is obtained by concatenating the dynamic embedding representation with the context-sensitive representation feature encoding; Based on the fusion representation, a single-element cross-entropy loss function is constructed using a single-element permutation template; a pair-level cross-entropy loss function is constructed using a pair-level template; and a complete relation cross-entropy loss function is constructed using a complete relation template. A joint training loss function is obtained by integrating the single-element cross-entropy loss function, the paired-level cross-entropy loss function, and the complete relation cross-entropy loss function. The initial detection model is jointly trained using a joint training loss function, and the target detection model is obtained after training.
[0038] For example, the initial detection model can be jointly trained according to a multi-task learning framework to obtain an object detection model. This can be implemented using the following steps: Given input text The corresponding context-sensitive representation feature encoding is obtained by encoding with the pre-trained language model T5. : in, For text Length, For the hidden layer dimension, This indicates the encoder for T5. For the selected template... Static embedding representation is obtained using the embedding layer of T5. : To enable template representations to adapt to specific text contexts, this invention employs an attention mechanism to compute context-aware template embeddings. As a query As keys and values, utilize attention functions Calculate the dynamic embedding of the template : Then, the template embedding is integrated with the text representation, and... Treat it as an additional token, with splicing construction fusion representation : To guide the model to learn better in the emotion quadruple extraction task, the application adopts a multi-task learning framework to design a joint training strategy. According to the different template types selected by the input text, three sub-tasks can be divided, which are full permutation template prediction, pairing level template prediction and overall relationship prediction. Let the sample numbers of the three sub-tasks in the data set be L, M and N, under the condition of given fusion representation , the probability of the model generating the target sequence is , and the cross-entropy loss of each sub-task can be defined as: In order to balance the gradient contribution between sub-tasks, the first hyperparameter , the second hyperparameter and the third hyperparameter are introduced, so as to define the overall joint training loss function, that is, the balanced contribution loss : .
[0039] S4, according to the preset constraint decoding strategy, using the target detection model to extract emotions from the text to be detected, and obtaining the emotion detection result.
[0040] It can be understood that the preset constraint decoding strategy refers to the rules or patterns defined in advance in the model inference process, and the candidate output is filtered or limited when generating each token (token), so that the finally generated sequence strictly meets the pre-defined format or structure requirements.
[0041] Exemplarily, according to the preset constraint decoding strategy, using the target detection model to extract emotions from the text to be detected, and obtaining the emotion detection result, the following implementation steps can be implemented: Based on the majority voting aggregation mechanism, the results generated by the selected template subset are integrated to obtain the final emotion element quadruple set . Specifically, for the input sentence , the pre-trained language model generates prediction results based on the selected templates and performs constraint decoding. Each template extracts the emotion element quadruple set which may contain one or more emotion element quadruples. The final aggregation result can be obtained by the following formula: Wherein, is the total number of selected templates; representing a single sentiment quadruple, the final quadruple result each quadruple in the result set to be predicted by all templates occurs more than half (i.e. ).
[0042] The present application uses preset mark symbols to mark aspects, categories, opinions and sentiment polarity to obtain sentiment element marks, and uses the sentiment element marks to construct single-element full permutation templates, paired-level templates and complete relationship templates, which can adapt to complex text expressions and improve the diversity of template types. Furthermore, according to a preset template selection algorithm, one or more templates are selected from the single-element full permutation templates, the paired-level templates and the complete relationship templates to construct an initial detection model, the template combination is dynamically optimized through the template selection algorithm, which reduces information redundancy and contradictions and can improve the modeling efficiency of the model. In addition, the initial detection model is jointly trained according to a multi-task learning framework, and a target detection model is obtained after the training. Through the multi-task learning framework, the modeling capability between the semantic relationships of the sentiment elements can be enhanced, and the overall performance and robustness of the model can be improved. Finally, according to a preset constraint decoding strategy, the target detection model is used to extract sentiment from the text to be detected to obtain a sentiment detection result, which can improve the efficiency and accuracy of sentiment extraction.
[0043] Referring to Figure 2 Fig. 1, which is a structural flowchart of an example of an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application.
[0044] Referring to Figure 3 Fig. 2, which is a template selection algorithm diagram of the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application. Referring to Figure 4 Fig. 3, which is a constraint decoding strategy principle diagram of the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning provided by an embodiment of the present application.
[0045] As Figure 5 shown in Fig. 4, which is a functional module diagram of an aspect-level sentiment quadruple extraction device based on adaptive multi-template prompt learning provided by an embodiment of the present application.
[0046] The aspect-level sentiment quadruple extraction device 100 based on adaptive multi-template prompt learning provided by the present application can be installed in an electronic device. According to the functions to be implemented, the aspect-level sentiment quadruple extraction device 100 based on adaptive multi-template prompt learning can include an initial detection model construction module 101, an initial detection model training module 102 and a sentiment detection result acquisition module 103.
[0047] The module can also be referred to as a unit, which refers to a series of computer program segments capable of being executed by an electronic device processor and capable of completing a fixed function, which is stored in the memory of the electronic device.
[0048] In the embodiment, the functions of each module / unit are as follows: The initial detection model construction module 101 is configured to label aspects, categories, opinions and sentiment polarity by using a preset marker symbol to obtain sentiment element labels, and construct a template pool by using the sentiment element labels, wherein the template pool includes single-element full permutation templates, paired templates and complete relationship templates; and select templates from the template pool according to a preset template selection algorithm to construct an initial detection model.
[0049] The initial detection model training module 102 is configured to jointly train the initial detection model according to a multi-task learning framework, and obtain a target detection model after the training is completed.
[0050] The sentiment detection result acquisition module 103 is configured to extract sentiment from the text to be detected by using the target detection model according to a preset constraint decoding strategy, and obtain a sentiment detection result.
[0051] As Figure 6 As shown in FIG. 1, which is a structural schematic diagram of an electronic device for implementing an aspect-level sentiment four-tuple extraction method based on adaptive multi-template prompt learning according to an embodiment of the present application.
[0052] The electronic device can include a processor 10, a memory 11, a communication bus 12 and a communication interface 13, and can further include a computer program stored in the memory 11 and executable on the processor 10, such as an aspect-level sentiment four-tuple extraction method program based on adaptive multi-template prompt learning.
[0053] In some embodiments, the processor 10 can be composed of integrated circuits, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same function or different functions, including one or more combinations of central processing units (CPUs), microprocessors, digital processing chips, graphics processors and various control chips. The processor 10 is the control core of the electronic device, which connects all components of the electronic device through various interfaces and lines, executes or runs programs or modules stored in the memory 11 (such as an aspect-level sentiment four-tuple extraction method program based on adaptive multi-template prompt learning), and calls data stored in the memory 11 to perform various functions and process data of the electronic device.
[0054] The memory 11 includes at least one type of readable storage medium, including flash memory, mobile hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), magnetic memory, disk, optical disk, etc. The memory 11 can be an internal storage unit of an electronic device in some embodiments, such as a mobile hard disk of the electronic device. The memory 11 can also be an external storage device of an electronic device in other embodiments, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 11 can include both an internal storage unit and an external storage device of an electronic device. The memory 11 can be used not only to store application software and various data installed in an electronic device, such as a code of an aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning, but also to temporarily store data that has been output or will be output.
[0055] The communication bus 12 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable connection and communication between the memory 11 and at least one processor 10, etc.
[0056] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface can include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the electronic device and other electronic devices. The user interface can be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface can also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, and an OLED (Organic Light-Emitting Diode) touch, etc. The display can also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visualized user interface.
[0057] Figure 6Only the electronic device with components is shown, and those skilled in the art can understand that Figure 6 The structure shown does not constitute a limitation on the electronic device, and can include fewer or more components than shown, or combine certain components, or different component arrangements.
[0058] For example, although not shown, the electronic device can also include a power supply (such as a battery) to power each component. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, so that functions such as charge management, discharge management, and power consumption management can be achieved through the power management device. The power supply can also include one or more direct current or alternating current power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and any other components. The electronic device can also include various sensors, Bluetooth modules, Wi-Fi modules, and the like, which are not described here.
[0059] It should be understood that the embodiments are only for illustration and are not limited in the scope of the patent application by this structure.
[0060] The aspect-level sentiment quadruple extraction method program based on adaptive multi-template prompt learning stored in the memory 11 of the electronic device is a combination of multiple instructions, which, when running in the processor 10, can achieve: The aspect, category, opinion, and sentiment polarity are marked using a preset marker symbol to obtain sentiment element marking, and a template pool is constructed using the sentiment element marking, including single-element full permutation templates, paired templates, and complete relationship templates; According to a preset template selection algorithm, templates are selected from the template pool to construct an initial detection model; According to a multi-task learning framework, the initial detection model is jointly trained, and after training, a target detection model is obtained; According to a preset constraint decoding strategy, the target detection model is used to extract sentiment from the text to be detected to obtain a sentiment detection result.
[0061] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the related steps in the corresponding embodiments of the drawings, which is not described here.
[0062] Further, the modules / units integrated in the electronic device 1 are stored in a computer readable storage medium if realized in the form of software function units and sold or used as independent products. The computer readable storage medium can be volatile or non-volatile. For example, the computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0063] The application further provides a computer readable storage medium, which stores a computer program, and the computer program can realize the following when executed by a processor of an electronic device: The aspect, category, opinion and sentiment polarity are marked by using preset mark symbols to obtain sentiment element marks, and a template pool is constructed by using the sentiment element marks, the template pool including single element full permutation templates, pairing level templates and complete relationship templates; According to a preset template selection algorithm, templates are selected from the template pool to construct an initial detection model; According to a multi-task learning framework, the initial detection model is jointly trained, and a target detection model is obtained after training; According to a preset constraint decoding strategy, sentiment extraction is performed on the text to be detected by using the target detection model, and a sentiment detection result is obtained.
[0064] In several embodiments provided in the application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and the division of the modules is merely a logical function division, and there can be another division manner in actual implementation.
[0065] The modules illustrated as separate components can or can not be physically separated, and the components illustrated as modules can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments.
[0066] In addition, each functional module in each embodiment of the application can be integrated in one processing unit, or each unit can be physically present independently, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software function modules.
[0067] It will be obvious to a person skilled in the art that the application is not limited to the details of the above-described exemplary embodiments but can be implemented in other embodiments without departing from the scope of the application.
[0068] The embodiments should therefore be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the description given above, which is intended to be illustrative only and not restrictive; therefore all changes coming within the meaning and equivalency range of the claims are intended to be embraced therein. Any reference signs in the claims should not be construed as limiting the scope of the claims.
[0069] The blockchain referred to in the present application is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. Blockchain, in essence, is a decentralized database, a series of data blocks associated using cryptographic methods, each data block containing a batch of network transaction information, used to verify the validity of the information (anti-fake) and generate the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer, etc.
[0070] The embodiments of the present application can acquire and process related data based on artificial intelligence technology. Among them, artificial intelligence (Artificial Intelligence, AI) is to use digital computers or digital computer controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Theory, method, technology and application system.
[0071] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices stated in the system claims can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and not to indicate any particular order.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the present application.
Claims
1. An aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning, characterized in that, The method comprises: The method comprises: According to a preset template selection algorithm, templates are selected from the template pool to construct an initial detection model; According to a multi-task learning framework, the initial detection model is jointly trained, and a target detection model is obtained after training is completed; According to a preset constraint decoding strategy, the target detection model is used for emotion extraction on the text to be detected, and emotion detection results are obtained.
2. The aspect-level sentiment quadruple extraction method based on adaptive multi-template cue learning according to claim 1, wherein, The construction method of the single-element full permutation template comprises: According to a preset local logical rule, the aspect, the category, the opinion and the sentiment polarity are paired with each other to obtain a plurality of pairing information; Each pairing information is used to construct a single pairing level template, and a pairing level template is obtained by summarizing the single pairing level template corresponding to each pairing information in the plurality of pairing information.
3. The aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning according to claim 1 or 2, characterized in that, The construction method of the complete relationship template comprises: Obtain the semantic information of the aspect, the category, the opinion and the sentiment polarity; Based on the semantic information of the aspect, the category, the opinion and the sentiment polarity, a preset disambiguation reconstruction algorithm is used to reconstruct the complete relationship to obtain the complete relationship template.
4. The aspect-level sentiment quadruple extraction method based on adaptive multi-template cue learning according to claim 3, wherein, The method comprises: Step 1, the performance scores of the single-element full permutation template, the pairing level template and the complete relationship template are calculated respectively to obtain the performance scores of the single-element full permutation template, the pairing level template and the complete relationship template; Step 2, the semantic correlation between the plurality of templates is calculated according to a probability distribution similarity calculation method; 5. The aspect-level sentiment quadruple extraction method based on adaptive multi-template cue learning according to claim 1, wherein, Step 3, the complementarity score is calculated according to the performance scores of the single-element full permutation template, the pairing level template and the complete relationship template and the semantic correlation between the plurality of templates; Step 4, a preset number of templates are selected to construct the initial detection model according to the complementarity score using a greedy algorithm. The method comprises: The method comprises: According to the selected template, a static embedding representation is generated by using an embedding layer of the T5 encoder; 6. The aspect-level sentiment quadruple extraction method based on adaptive multi-template cue learning according to claim 5, wherein, The static embedding representation is used as a query of an attention mechanism, the context-sensitive representation feature code is used as a key and a value of the attention mechanism, and a dynamic embedding representation of the template is calculated by using an attention function; The semantic correlation between a plurality of templates is calculated using the following formula : wherein, is the training set, is the total number of samples in the training set, is the number of elements in the set, is the JS divergence, is the probability distribution of the th template, is the probability distribution of the th template.
7. The aspect-level sentiment quadruple extraction method based on adaptive multi-template cue learning according to any one of claim 1, wherein, The dynamic embedding representation and the context-sensitive representation feature code are spliced to obtain a fusion representation; According to the fusion representation, a single-element cross-entropy loss function is constructed by using a single-element full permutation template; according to the fusion representation, a pair-level cross-entropy loss function is constructed by using a pair-level template; and according to the fusion representation, a complete relationship cross-entropy loss function is constructed by using a complete relationship template; The single-element cross-entropy loss function, the pair-level cross-entropy loss function and the complete relationship cross-entropy loss function are integrated to obtain a joint training loss function; The initial detection model is trained by using the joint training loss function, and a target detection model is obtained after the training is completed.
8. An aspect-level sentiment quadruple extraction device based on adaptive multi-template cue learning, characterized in that, The device is used to implement the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning according to any one of claims 1 to 7, and the device comprises: An initial detection model construction module is configured to mark aspects, categories, opinions and sentiment polarities by using preset mark symbols to obtain sentiment element marks, and to construct a template pool by using the sentiment element marks, wherein the template pool comprises a single-element full permutation template, a pair-level template and a complete relationship template; and the initial detection model is constructed by selecting templates from the template pool according to a preset template selection algorithm. An initial detection model training module is configured to train the initial detection model according to a multi-task learning framework, and to obtain a target detection model after the training is completed. A sentiment detection result acquisition module is configured to perform sentiment extraction on a text to be detected by using the target detection model according to a preset constraint decoding strategy, and to obtain a sentiment detection result.
9. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected to the at least one processor in communication; wherein The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to execute the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning according to any one of claims 1 to 7.
10. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the aspect-level sentiment quadruple extraction method based on adaptive multi-template prompt learning according to any one of claims 1 to 7.