Emotion tetrad extraction method and device, equipment and storage medium

By encoding and clustering historical comment texts, generating dynamic topic prefix prompts, and training emotional quadruple extraction model, the shortcomings of ignoring topic information and static prompts in the existing technology are solved, and more efficient emotional quadruples are achieved. extract.

CN119476272APending Publication Date: 2025-02-18CHONGQING RURAL COMMERCIAL BANK CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411550138.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

The prior art ignores the topic information in text comments during the emotional quad extraction process, and relies on artificially designed static prompt words and cannot be dynamically tuned.

Method used

By encoding and clustering historical comment texts based on preset text encoding models, dynamic topic prefix prompts are generated, and these prompts are reparameterized using the reparameterization layer to generate parameterized vectors to train the target emotional quad extraction model .

Benefits of technology

Improve the accuracy of emotional quad extraction, allowing the model to dynamically focus and generate emotional quads related to the current context topic, achieving dynamic optimization of emotional quad extraction task.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119476272A_ABST
    Figure CN119476272A_ABST
Patent Text Reader

Abstract

The invention discloses an emotion tetrad extraction method and device, equipment and a storage medium, and relates to the technical field of natural language processing, and the method comprises the steps: carrying out the coding operation of a historical comment text based on a preset text coding model, and carrying out the clustering operation to obtain a plurality of center clusters; determining a corresponding target text according to the similarity between the encoded text and a center text of a corresponding target center cluster, and inputting the target text into a preset T5 generation model encoder to obtain a theme information prefix text; determining a weight coefficient corresponding to the coded text and the theme information prefix text, and performing weighted average to obtain a dynamic theme prefix prompt corresponding to the coded text; and re-parameterizing the dynamic topic prefix prompt to obtain a parameterization vector so as to train a preset T5 generation model encoder to obtain a target emotional tetrad extraction model, so that an emotional tetrad in the target comment text is extracted. In this way, extraction of the emotion tetrad in the text comments can be achieved.
Need to check novelty before this filing date? Find Prior Art

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 storage medium for extracting sentiment quadruple. Background Art

[0002] In the field of Aspect Based Sentiment Analysis (ABSA), aspect-level sentiment quadruple extraction is a most challenging task that comprehensively analyzes the causes of sentiment. It mainly revolves around the four elements of aspect, viewpoint, category, and emotion. The above four elements form a sentiment quadruple, namely (a, c, o, s), where a represents the evaluation object (aspect), c represents the category to which the evaluation object belongs, o represents the evaluation (viewpoint) of the object, and s represents the fine-grained emotion composed of a and o (such as positive, negative, neutral). The sentiment quadruple can fully understand the emotional stance of the target and carefully analyze the causes of the emotion. It is more practical and instructive in intention recognition, public opinion monitoring, and human-computer empathy dialogue. Recently, generative methods have attracted widespread attention in the field of sentiment quadruple extraction. These methods convert the labeling task into a generation task and use pre-trained generation models such as BART (a seq2seq denoising autoencoder based on the Transformer structure) or T5 (Text-to-Text Transfer Transformer) to directly generate sentiment quadruple, thereby simplifying the task processing and interaction process. However, the current related technologies focus on the design of model prompt words, which have the following shortcomings: First, the existing technologies rely on artificial prompt word design and static prompts, and cannot be dynamically tuned according to the task. Second, the existing technologies ignore the topic information in the text comments when extracting sentiment quadruple. Therefore, how to extract sentiment quadruple based on the topic information in text comments needs to be solved. Summary of the invention

[0003] In view of this, the purpose of the present invention is to provide a sentiment quadruple extraction method, device, equipment and storage medium, which can take into account the subject information in the text comments in the process of extracting the sentiment quadruple, thereby improving the accuracy of sentiment quadruple extraction. The specific scheme is as follows:

[0004] In a first aspect, the present application discloses a method for extracting sentiment quadruple, comprising:

[0005] Performing encoding operation on the historical comment text based on a preset text encoding model to obtain encoded text, and performing clustering operation on the encoded text to obtain a number of central clusters;

[0006] Determine the corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and input the target text into the preset T5 generation model encoder to obtain the topic information prefix text;

[0007] Determine a weight coefficient corresponding to the encoded text and the topic information prefix text, and perform weighted averaging on the topic information prefix text based on the weight coefficient to obtain a dynamic topic prefix prompt corresponding to the encoded text;

[0008] Re-parameterizing the dynamic topic prefix prompt using a preset re-parameterization layer to obtain a parameterized vector;

[0009] The preset T5 generative model encoder is trained based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract sentiment quadruple in the target review text based on the target sentiment quadruple extraction model.

[0010] Optionally, encoding the historical comment text based on a preset text encoding model to obtain an encoded text, and clustering the encoded text to obtain a plurality of central clusters, including:

[0011] Based on the Bert text encoding model, a CLS vector extraction operation is performed on the historical comment text to obtain an encoded text, and a K-Means++ clustering algorithm is used to perform a clustering operation on the encoded text to obtain several central clusters.

[0012] Optionally, determining a corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and inputting the target text into a preset T5 generative model encoder to obtain a topic information prefix text, includes:

[0013] Determine the cosine similarity value between each of the encoded texts in the target center cluster and the center text of the target center cluster, and determine the encoded text whose cosine similarity value is less than a preset threshold as the corresponding target text;

[0014] The target text is input into a preset T5 generative model encoder for text fine-tuning training to obtain a topic information prefix text.

[0015] Optionally, the determining of the weight coefficient corresponding to the encoded text and the topic information prefix text includes:

[0016] The encoded text and the topic information prefix text are input into an attention score calculation model to obtain a target attention score, and the target attention score is normalized to obtain a weight coefficient corresponding to the encoded text and the topic information prefix text.

[0017] Optionally, the re-parameterizing the dynamic topic prefix prompt by using a preset re-parameterization layer to obtain a parameterized vector includes:

[0018] Constructing a prompt transformation layer based on a multi-layer perceptron, and constructing a preset re-parameterization layer based on the prompt transformation layer and a preset word embedding matrix;

[0019] The dynamic topic prefix prompt is input into the preset reparameterization layer for reparameterization to obtain a parameterization vector.

[0020] Optionally, the step of training the preset T5 generative model encoder based on the parameterized vector to obtain a target emotion quadruple extraction model includes:

[0021] The parameterized vector is input into the preset T5 generative model encoder to train the first parameter consisting of the dynamic prefix encoder and the dynamic prefix in the T5 generative model encoder to obtain a target emotion quadruple extraction model.

[0022] Optionally, before inputting the target text into a preset T5 generative model encoder to obtain a topic information prefix text, the method further includes:

[0023] The historical comment text is used to train the second parameter in the initial T5 generative model encoder to obtain the preset T5 generative model encoder.

[0024] In a second aspect, the present application discloses a sentiment quadruple extraction device, comprising:

[0025] A text clustering module, used for encoding the historical comment text based on a preset text encoding model to obtain an encoded text, and performing a clustering operation on the encoded text to obtain a plurality of central clusters;

[0026] A prefix text acquisition module is used to determine the corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and input the target text into a preset T5 generation model encoder to obtain a topic information prefix text;

[0027] A prefix prompt acquisition module, used to determine the weight coefficient corresponding to the encoded text and the topic information prefix text, and perform weighted averaging on the topic information prefix text based on the weight coefficient to obtain a dynamic topic prefix prompt corresponding to the encoded text;

[0028] A topic parameterization module, used for re-parameterizing the dynamic topic prefix prompt using a preset re-parameterization layer to obtain a parameterized vector;

[0029] The sentiment quadruple extraction module is used to train the preset T5 generation model encoder based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract the sentiment quadruple in the target comment text based on the target sentiment quadruple extraction model.

[0030] In a third aspect, the present application discloses an electronic device, comprising:

[0031] Memory, used to store computer programs;

[0032] A processor is used to execute the computer program to implement the aforementioned emotion quadruple extraction method.

[0033] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program, which implements the aforementioned emotion quadruple extraction method when executed by a processor.

[0034] It can be seen that in this application, the historical comment text is encoded based on the preset text encoding model to obtain the encoded text, and the encoded text is clustered to obtain several central clusters; the corresponding target text is determined according to the similarity between the encoded text and the central text of the corresponding target central cluster, and the target text is input into the preset T5 generation model encoder to obtain the topic information prefix text; the weight coefficient corresponding to the encoded text and the topic information prefix text is determined, and the topic information prefix text is weighted averaged based on the weight coefficient to obtain the dynamic topic prefix prompt corresponding to the encoded text; the dynamic topic prefix prompt is re-parameterized using the preset re-parameterization layer to obtain a parameterized vector; the preset T5 generation model encoder is trained based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract the sentiment quadruple in the target comment text based on the target sentiment quadruple extraction model. That is, the target sentiment quadruple extraction model is generated by the topic prefix information extraction method; the model is enabled to dynamically focus on and generate sentiment quadruple related to the current context theme, so as to achieve dynamic optimization of the sentiment quadruple extraction task. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] In order to more clearly illustrate the embodiments of the present invention 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 embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0036] Figure 1 A flow chart of a method for extracting emotion quadruple disclosed in this application;

[0037] Figure 2 A flowchart of a specific sentiment quadruple extraction method disclosed in this application;

[0038] Figure 3 A flowchart of a specific sentiment quadruple extraction method disclosed in this application;

[0039] Figure 4 This is a schematic diagram of the structure of an emotion quadruple extraction device disclosed in this application;

[0040] Figure 5 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0042] See also Figure 1 As shown, the embodiment of the present application discloses a method for extracting emotion quadruple, including:

[0043] Step S11: encoding the historical comment text based on a preset text encoding model to obtain an encoded text, and clustering the encoded text to obtain a number of central clusters.

[0044] In this embodiment, the encoding operation on the historical comment text based on the preset text encoding model to obtain the encoded text, and the clustering operation on the encoded text to obtain a number of center clusters, includes: performing a CLS vector extraction operation on the historical comment text based on the Bert text encoding model to obtain the encoded text, and using the K-Means++ clustering algorithm to cluster the encoded text to obtain a number of center clusters. Specifically, firstly, the Bert text encoding model is used to encode the sentences in the original text X to obtain the encoded representation X of all the original texts. cls , the specific process is as follows:

[0045] X cls =BERT(X) cls ;

[0046] Among them, BERT(X) cls represents the CLS (classification) vector extracted after encoding the original text X through the BERT model. Then, the K-Means++ clustering algorithm is used to represent the encoded text Xcls Cluster into n central clusters. The text of each central cluster is represented by C j This process is represented as follows:

[0047] {C1,C2,……,C n} = f k-means ++(X) cls ;

[0048] Among them, C j represents the center representation of the jth cluster, f k-means ++ indicates K-Means++ clustering algorithm.

[0049] Step S12: Determine the corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and input the target text into the preset T5 generation model encoder to obtain the topic information prefix text.

[0050] In this embodiment, the method of determining the corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and inputting the target text into the preset T5 generative model encoder to obtain the topic information prefix text includes: determining the cosine similarity value between each encoded text in the target central cluster and the central text of the target central cluster, and determining the encoded text whose cosine similarity value is less than a preset threshold as the corresponding target text; inputting the target text into the preset T5 generative model encoder for text fine-tuning training to obtain the topic information prefix text. Specifically, the text representation of the i-th comment sentence is X i cls For example, in the semantic space, calculate X i cls The corresponding cluster center is represented by C j The cosine similarity σ i . Set a distance threshold λ. If the cosine similarity between the text representation and the central cluster to which it belongs is less than the threshold, that is, σ i <λ, then add the text representation to the corresponding j-th text representation set S j This process is expressed as:

[0051]

[0052] Among them, if σ i <λ, then Where S j Represents the j-th text topic representation set.

[0053] Finally, the text representation set Sj of each class is subjected to a separate Prefix-Tuning training operation to obtain the prefix prompt vector sp of the corresponding text topiccj :

[0054] sp cj =PrefixTuning(S j );

[0055] Among them, sp cj Represents the jth topic information prefix representation. It should be noted here that the preset T5 generative model encoder is an encoder obtained by training the second parameter in the initial T5 generative model encoder using the historical comment text. Specifically, first use the basic model T5 to train the parameter φ to learn the ability of the basic generation task and obtain the trained parameter φ'; then, freeze the parameter φ' of the trained T5 model to obtain the preset T5 generative model encoder. Use the preset T5 generative model encoder to convert the text representation set S of each class j Perform a separate Prefix-Tuning training operation to obtain the prefix prompt vector spc = {sp c1 ,sp c2 ,……,sp cn}.

[0056] Step S13: Determine the weight coefficient corresponding to the encoded text and the topic information prefix text, and perform weighted averaging on the topic information prefix text based on the weight coefficient to obtain a dynamic topic prefix prompt corresponding to the encoded text.

[0057] In this embodiment, the determination of the weight coefficient corresponding to the encoded text and the topic information prefix text includes: inputting the encoded text and the topic information prefix text into an attention score calculation model to obtain a target attention score, and normalizing the target attention score to obtain the weight coefficient corresponding to the encoded text and the topic information prefix text. Figure 2 As shown, the current comment sentence x∈X is input into the BERT model for encoding and the vector of the first index position is taken to obtain the context representation x cls , the process is as follows:

[0058] x cls =BERT(x) cls .

[0059] Then, the context representation x cls The topic prefix information vector is applied to the proposed multi-layer perceptron-based attention mechanism to obtain an attention score e j and weight coefficient a j , the formula is as follows:

[0060] e j =vT tanh(W sp sp cj +W x x cls );

[0061] a j =softmax(e j ).

[0062] Among them, v T is a randomly initialized trainable weight vector used to convert the intermediate calculation results into a suitable scale to facilitate subsequent weighted operations. As shown in the above formula, the context representation x cls and the subject prefix vector sp cj Input into the multi-layer perceptron W x and W sp In order to obtain an attention score e j Then, the attention score e j Perform Softmax normalization to obtain the weight coefficient a j Finally, the weight coefficient a j The weighted average of each topic prefix is ​​obtained to obtain the dynamic topic prefix prompt dp under the context information. c The specific formula is as follows:

[0063]

[0064] Specifically, based on the context-specific prefix dp c It is dynamically weighted because all topic prefix information is taken into account under the current input (context information). In this way, the present invention realizes the dynamic integration of each topic information into the prefix prompt, thereby prompting the model to pay more attention to the topic prefix information that is more useful for sentiment quadruple extraction in the generation stage.

[0065] Step S14: re-parameterize the dynamic topic prefix prompt using a preset re-parameterization layer to obtain a parameterized vector.

[0066] In this embodiment, the use of a preset reparameterization layer to reparameterize the dynamic topic prefix prompt to obtain a parameterized vector includes: constructing a prompt transformation layer based on a multi-layer perceptron, and constructing a preset reparameterization layer based on the prompt transformation layer and a preset word embedding matrix; inputting the dynamic topic prefix prompt into the preset reparameterization layer for reparameterization to obtain a parameterized vector. Specifically, the context-based dynamic prefix prompt dp is obtained. c Finally, this method uses a reparameterized layer, which models a word embedding matrix and by multilayer perceptron and The composed prompt transformation layer re-parameterizes the prefix to obtain a parameterized vector, and the specific operation is as follows:

[0067]

[0068] Among them, L is the dynamic prefix prompt length, D is the dimension of the dynamic prefix prompt vector, which is consistent with the hidden layer dimension of the generation model T5. It should be noted that D' is the re-parameterization dimension number, where D' < D, because directly updating the parameters of the embedding vector will lead to unstable optimization of the model and a slight decrease in performance. Therefore, the method of re-parameterization can reduce the overall capacity of the model to limit the degrees of freedom of the model and achieve its training stability. Embedding vector parameters will cause unstable optimization of the model and a slight decrease in performance. Therefore, the method of re-parameterization can reduce the overall capacity of the model to limit the degrees of freedom of the model and achieve its training stability.

[0069] Step S15: Train the preset T5 generation model encoder based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract the sentiment quadruple in the target review text based on the target sentiment quadruple extraction model.

[0070] In this embodiment, it should be noted that the training parameters of this application include, in addition to the trainable parameters φ of the generation model T5, the parameters θ composed of the dynamic prefix encoder and the dynamic prefix prf . In specific experiments, it is found that optimizing the above parameters by means of joint training has poor effects, because φ and θ prf require different scales of training hyperparameters to achieve the best optimization effect. Therefore, training the preset T5 generation model encoder based on the parameterized vector to obtain a target sentiment quadruple extraction model includes: inputting the parameterized vector into the preset T5 generation model encoder to train the first parameters composed of the dynamic prefix encoder and the dynamic prefix in the T5 generation model encoder to obtain a target sentiment quadruple extraction model. After obtaining the re-parameterized dynamic prefix prompt vector , this method performs prefix prompt splicing and sends it into the Transformer layer of the T5 generation model encoder. That is, by loading all the trained topic prefix representations sp c , while freezing the parameters φ', training the parameters θ composed of the dynamic prefix encoder and the dynamic prefix prf . The loss function of the target sentiment quadruple extraction model is as follows:

[0071]

[0072] Among them, m represents the length of the output sequence, p(y k |y1,…,y m ,X i) represents the overall probability of the T5 generation model generating an output sequence given the i-th input sequence. In this embodiment, the final output sequence is generated by the T5 model decoder, and the process is as follows:

[0073]

[0074] Y = Decoder (h);

[0075] Among them, [vector; vector] represents the vector concatenation operation, T represents the sequence length of the input text vector, Decoder represents the decoder of the T5 model, h is the output representation of the Transformer, and Y represents the final output sequence, which is a natural language form combined with sentiment elements, such as "[aspect] is [viewpoint], because [category] is [emotion]", for example: for the input text "In recent years, some local rural commercial banks have shown satisfactory profitability", the corresponding output sequence is "profitability is satisfactory, because bank operations are positive". After obtaining the output sequence, this method directly decodes the sentiment elements (aspect, viewpoint, category, emotion) according to the position index.

[0076] It can be seen that in this embodiment, the historical comment text is encoded based on the preset text encoding model to obtain the encoded text, and the encoded text is clustered to obtain a number of central clusters; the corresponding target text is determined according to the similarity between the encoded text and the central text of the corresponding target central cluster, and the target text is input into the preset T5 generation model encoder to obtain the topic information prefix text; the weight coefficient corresponding to the encoded text and the topic information prefix text is determined, and the topic information prefix text is weighted averaged based on the weight coefficient to obtain the dynamic topic prefix prompt corresponding to the encoded text; the dynamic topic prefix prompt is re-parameterized using the preset re-parameterization layer to obtain a parameterized vector; the preset T5 generation model encoder is trained based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract the sentiment quadruple in the target comment text based on the target sentiment quadruple extraction model. That is, Figure 3 As shown in the figure, the topic prefix information extraction method is used to model the prompt information of a specific topic; the dynamic prefix encoder is used to calculate the context-specific prompt prefix when the model generates a sequence to integrate the topic information and context information, so that the model can dynamically focus on and generate sentiment quadruple related to the current context topic, and realize the dynamic optimization of the sentiment quadruple extraction task. This solves the shortcomings of the existing technology that rely on artificial prompt words or static prompts, which are suboptimal and ignore the topic information in text comments.

[0077] refer to Figure 4The embodiment of the present application also discloses a device for extracting emotion quadruple, including:

[0078] A text clustering module 11 is used to perform an encoding operation on the historical comment text based on a preset text encoding model to obtain an encoded text, and to perform a clustering operation on the encoded text to obtain a plurality of central clusters;

[0079] A prefix text acquisition module 12 is used to determine the corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and input the target text into a preset T5 generation model encoder to obtain a topic information prefix text;

[0080] A prefix prompt acquisition module 13, used to determine the weight coefficient corresponding to the encoded text and the topic information prefix text, and perform weighted averaging on the topic information prefix text based on the weight coefficient to obtain a dynamic topic prefix prompt corresponding to the encoded text;

[0081] A topic parameterization module 14, configured to re-parameterize the dynamic topic prefix prompt using a preset re-parameterization layer to obtain a parameterized vector;

[0082] The sentiment quadruple extraction module 15 is used to train the preset T5 generation model encoder based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract the sentiment quadruple in the target comment text based on the target sentiment quadruple extraction model.

[0083] It can be seen that in this embodiment, the target sentiment quadruple extraction model is generated by the topic prefix information extraction method; the model is enabled to dynamically focus on and generate sentiment quadruple related to the current context topic, thereby realizing dynamic optimization of the sentiment quadruple extraction task.

[0084] In some specific embodiments, the text clustering module 11 can be specifically used to perform a CLS vector extraction operation on the historical comment text based on the Bert text encoding model to obtain an encoded text, and use a K-Means++ clustering algorithm to perform a clustering operation on the encoded text to obtain a number of central clusters.

[0085] In some specific embodiments, the prefix text acquisition module 12 may specifically include:

[0086] A target text determination unit, used to determine the cosine similarity value between each of the encoded texts in the target center cluster and the center text of the target center cluster, and determine the encoded text whose cosine similarity value is less than a preset threshold as the corresponding target text;

[0087] The text training unit is used to input the target text into a preset T5 generation model encoder for text fine-tuning training to obtain a topic information prefix text.

[0088] In some specific embodiments, the prefix prompt acquisition module 13 can be specifically used to input the encoded text and the topic information prefix text into an attention score calculation model to obtain a target attention score, and normalize the target attention score to obtain a weight coefficient corresponding to the encoded text and the topic information prefix text.

[0089] In some specific embodiments, the theme parameterization module 14 may specifically include:

[0090] A parameter layer construction unit, used to construct a prompt transformation layer based on a multi-layer perceptron, and to construct a preset re-parameterization layer based on the prompt transformation layer and a preset word embedding matrix;

[0091] The vector conversion unit is used to input the dynamic topic prefix prompt into the preset re-parameterization layer for re-parameterization to obtain a parameterized vector.

[0092] In some specific embodiments, the emotion quadruple extraction module 15 can be specifically used to input the parameterized vector into the preset T5 generation model encoder to train the first parameter composed of the dynamic prefix encoder and the dynamic prefix in the T5 generation model encoder to obtain a target emotion quadruple extraction model.

[0093] In some specific embodiments, the emotion quadruple extraction device may further include:

[0094] The encoder generation module is used to train the second parameter in the initial T5 generation model encoder using the historical comment text to obtain the preset T5 generation model encoder.

[0095] Furthermore, the present application also discloses an electronic device. Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.

[0096] Figure 5A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the emotion quadruple extraction method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.

[0097] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0098] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0099] The operating system 221 is used to manage and control the hardware devices and computer program 222 on the electronic device 20, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the emotion quadruple extraction method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.

[0100] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the aforementioned disclosed method for extracting emotion quadruplets is implemented. The specific steps of the method can be referred to the corresponding contents disclosed in the aforementioned embodiments, and will not be repeated here.

[0101] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0102] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0103] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0104] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0105] The technical solution provided by the present application is introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technicians in this field, according to the idea of ​​the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for extracting emotion quadruple, characterized in that: include: Performing encoding operation on the historical comment text based on a preset text encoding model to obtain encoded text, and performing clustering operation on the encoded text to obtain a number of central clusters; Determine the corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and input the target text into the preset T5 generation model encoder to obtain the topic information prefix text; Determine a weight coefficient corresponding to the encoded text and the topic information prefix text, and perform weighted averaging on the topic information prefix text based on the weight coefficient to obtain a dynamic topic prefix prompt corresponding to the encoded text; Re-parameterizing the dynamic topic prefix prompt using a preset re-parameterization layer to obtain a parameterized vector; The preset T5 generative model encoder is trained based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract sentiment quadruple in the target review text based on the target sentiment quadruple extraction model.

2. The emotion quadruple extraction method according to claim 1, characterized in that: The encoding operation is performed on the historical comment text based on the preset text encoding model to obtain the encoded text, and the encoded text is clustered to obtain a plurality of central clusters, including: Based on the Bert text encoding model, a CLS vector extraction operation is performed on the historical comment text to obtain an encoded text, and a K-Means++ clustering algorithm is used to perform a clustering operation on the encoded text to obtain several central clusters.

3. The emotion quadruple extraction method according to claim 1, characterized in that: The method of determining a corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and inputting the target text into a preset T5 generative model encoder to obtain a topic information prefix text, includes: Determine the cosine similarity value between each of the encoded texts in the target center cluster and the center text of the target center cluster, and determine the encoded text whose cosine similarity value is less than a preset threshold as the corresponding target text; The target text is input into a preset T5 generative model encoder for text fine-tuning training to obtain a topic information prefix text.

4. The emotion quadruple extraction method according to claim 1, characterized in that: The determining of the weight coefficient corresponding to the encoded text and the topic information prefix text includes: The encoded text and the topic information prefix text are input into an attention score calculation model to obtain a target attention score, and the target attention score is normalized to obtain a weight coefficient corresponding to the encoded text and the topic information prefix text.

5. The emotion quadruple extraction method according to claim 1, characterized in that: The re-parameterizing the dynamic topic prefix prompt by using a preset re-parameterization layer to obtain a parameterized vector includes: Constructing a prompt transformation layer based on a multi-layer perceptron, and constructing a preset re-parameterization layer based on the prompt transformation layer and a preset word embedding matrix; The dynamic topic prefix prompt is input into the preset reparameterization layer for reparameterization to obtain a parameterization vector.

6. The emotion quadruple extraction method according to claim 1, characterized in that: The step of training the preset T5 generative model encoder based on the parameterized vector to obtain a target emotion quadruple extraction model includes: The parameterized vector is input into the preset T5 generative model encoder to train the first parameter consisting of the dynamic prefix encoder and the dynamic prefix in the T5 generative model encoder to obtain a target emotion quadruple extraction model.

7. The emotion quadruple extraction method according to claim 1, characterized in that: Before inputting the target text into a preset T5 generation model encoder to obtain a topic information prefix text, the method further includes: The historical comment text is used to train the second parameter in the initial T5 generative model encoder to obtain the preset T5 generative model encoder.

8. An emotion quadruple extraction device, characterized in that: include: A text clustering module, used for encoding the historical comment text based on a preset text encoding model to obtain an encoded text, and performing a clustering operation on the encoded text to obtain a plurality of central clusters; A prefix text acquisition module is used to determine the corresponding target text according to the similarity between the encoded text and the central text of the corresponding target central cluster, and input the target text into a preset T5 generation model encoder to obtain a topic information prefix text; A prefix prompt acquisition module, used to determine the weight coefficient corresponding to the encoded text and the topic information prefix text, and perform weighted averaging on the topic information prefix text based on the weight coefficient to obtain a dynamic topic prefix prompt corresponding to the encoded text; A topic parameterization module, used for re-parameterizing the dynamic topic prefix prompt using a preset re-parameterization layer to obtain a parameterized vector; The sentiment quadruple extraction module is used to train the preset T5 generation model encoder based on the parameterized vector to obtain a target sentiment quadruple extraction model, so as to extract the sentiment quadruple in the target comment text based on the target sentiment quadruple extraction model.

9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the emotion quadruple extraction method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: Used to store a computer program, which, when executed by a processor, implements the emotion quadruple extraction method as described in any one of claims 1 to 7.

Citation Information

Cited By

  • Dialogue scene-oriented aspect emotion tetrad prediction method and system

    CN120653756A