Emotion extraction method and device, electronic equipment and storage medium

By obtaining the word features and context representation of the text to be extracted in the emotion extraction method and generating the target feature representation, the problem of low accuracy of emotion extraction in the existing technology is solved and the performance of emotion analysis is improved.

CN118569255APending Publication Date: 2024-08-30HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410399107.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-01
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing sentiment extraction methods have low accuracy when modeling the relationship between aspect items and opinion items, resulting in poor sentiment analysis performance.

Method used

By obtaining the text to be extracted, the emotion extraction model is used to extract word features to obtain word representation and context representation, and combined with the target feature representation to generate emotion extraction results, including emotional triples or quadruple sequences, to enhance the use of relationship information.

Benefits of technology

The accuracy of emotion extraction results is improved, and more relationship information is combined to enhance the performance of emotion analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118569255A
    Figure CN118569255A
Patent Text Reader

Abstract

The invention discloses an emotion extraction method and device, electronic equipment and a storage medium. The emotion extraction method comprises the steps of obtaining a to-be-extracted text; performing word feature extraction on the to-be-extracted text by using the emotion extraction model to obtain context representations among word representations in the to-be-extracted text; based on each word representation and the context representation, determining a target feature representation of the to-be-extracted text, the target feature representation representing relation information capable of indicating an emotion extraction model to generate an extraction result of the to-be-extracted text; and performing emotion extraction on the target feature representation and each word representation to obtain a target extraction result corresponding to the to-be-extracted text, the target extraction result comprising an emotion triple sequence or an emotion tetrad sequence. According to the scheme, the accuracy of the target extraction result corresponding to the to-be-extracted text can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of emotion extraction, and in particular to an emotion extraction method, device, electronic device and storage medium. Background Art

[0002] In recent years, sentiment extraction is an important aspect-level sentiment analysis task in natural language processing, which performs sentiment analysis on text. The main challenge of aspect-level sentiment analysis task is how to effectively model the relationship between aspect items and opinion items. Existing methods design a variety of discriminator models based on modeling aspect items and opinion items. Existing methods include table filling methods, fragment-based methods, and reading comprehension-based methods. Among them, the table filling method decomposes the relationship between aspect items and opinion items into word-level relationships through a customized annotation scheme, and then uses the interaction between words to model these word-level relationships; the fragment-based method directly learns the fragment representation, and then uses the interaction between fragments to model the relationship between aspect items and opinion items; the reading comprehension-based scheme converts the aspect-level sentiment analysis task into a multi-round understanding problem, and then models the relationship between aspect items and opinion items through a customized question template.

[0003] Although the existing generative model solves the problem that discriminative models are difficult to model uniformly, it only uses the word vectors of the text to be extracted for sentiment analysis, resulting in low accuracy of the sentiment extraction results of the extracted sentences and poor sentiment analysis performance of the extracted sentences. Summary of the invention

[0004] The present application at least provides a method, device, electronic device and storage medium for emotion extraction.

[0005] The present application provides a sentiment extraction method, comprising: obtaining a text to be extracted;

[0006] The sentiment extraction model is used to extract word features of the text to be extracted, and the context representation between each word representation in the text to be extracted is obtained; based on each word representation and the context representation, the target feature representation of the text to be extracted is determined, and the target feature representation represents the relational information that can instruct the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted, and the target extraction result includes a sentiment triple sequence or a sentiment quadruple sequence.

[0007] The present application provides a sentiment extraction device, including: an acquisition module, an extraction module, a determination module and an extraction module; the acquisition module is used to acquire a text to be extracted; the extraction module is used to use a sentiment extraction model to perform word feature extraction on the text to be extracted, and obtain a context representation between each word representation in the text to be extracted; the determination module is used to determine a target feature representation of the text to be extracted based on each word representation and the context representation, the target feature representation characterizing the relationship information that can indicate that the sentiment extraction model generates an extraction result for the text to be extracted; the extraction module is used to perform sentiment extraction on the target feature representation and each word representation, and obtain a target extraction result corresponding to the text to be extracted, the target extraction result including a sentiment triple sequence or a sentiment quadruple sequence.

[0008] The present application provides an electronic device, including a memory and a processor, wherein the processor is used to execute program instructions stored in the memory to implement the above-mentioned emotion extraction method.

[0009] The present application provides a computer-readable storage medium on which program instructions are stored. When the program instructions are executed by a processor, the above-mentioned emotion extraction method is implemented.

[0010] The above scheme, after obtaining the text to be extracted, determines the target feature representation of the text to be extracted based on the word representations and context representations obtained by extracting word features of the text to be extracted using the sentiment extraction model, wherein the target feature representation represents the relationship information that can indicate the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted. Compared with directly performing sentiment extraction on the text to be extracted, the present application can combine more relationship information about the text to be extracted, thereby improving the accuracy of the sentiment extraction results.

[0011] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present application and are used together with the specification to illustrate the technical solution of the present application.

[0013] Figure 1 This is a flow chart of an embodiment of the emotion extraction method of the present application;

[0014] Figure 2 This is another flowchart of an embodiment of the emotion extraction method of the present application;

[0015] Figure 3 is a structural schematic diagram showing an emotion extraction model in an embodiment of the emotion extraction method of the present application;

[0016] Figure 4 It is a structural schematic diagram of an embodiment of the emotion extraction device of the present application;

[0017] Figure 5 It is a structural schematic diagram of an embodiment of the electronic device of the present application;

[0018] Figure 6 It is a structural diagram of an embodiment of a computer-readable storage medium of the present application. DETAILED DESCRIPTION

[0019] The scheme of the embodiment of the present application is described in detail below in conjunction with the drawings of the specification.

[0020] In the following description, for the purpose of explanation rather than limitation, specific details such as specific system structures, interfaces, and technologies are provided to facilitate a thorough understanding of the present application.

[0021] The term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the objects associated before and after are in an "or" relationship. In addition, "many" in this article means two or more than two. In addition, the term "at least one" in this article means any combination of at least two of any one or more of a plurality of, for example, including at least one of A, B, and C, can mean including any one or more elements selected from the set consisting of A, B, and C.

[0022] The present application provides some emotion extraction methods and emotion extraction devices. The execution subject of the emotion extraction method can be an emotion extraction device, for example, the emotion extraction device can be a terminal device or a server or other processing device, wherein the terminal device can be a device for text emotion analysis, a user equipment (User Equipment, UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (Personal Digital Assistant, PDA), a handheld device, a computing device, a vehicle-mounted device, etc. In some possible implementations, the emotion extraction method can be implemented by a processor calling a computer-readable instruction stored in a memory.

[0023] See also Figure 1 , Figure 1 1 is a flow chart of an embodiment of the emotion extraction method of the present application. Specifically, the emotion extraction method may include the following steps:

[0024] Step S11: Obtain the text to be extracted.

[0025] The text to be extracted is composed of at least one word. For example, the text to be extracted can be an article, a paragraph, or a sentence, etc. The specific form of the text to be extracted is not specifically limited here. The number of texts to be extracted can be one or more. A word can be a single Chinese character, a word composed of Chinese characters, a word composed of English letters or multiple English letters, etc. The specific form of the word is not specifically limited here. The text to be extracted can be a given sentence text.

[0026] Among them, in some application scenarios, obtaining the text to be extracted can be through a database query. For a database that has been created and contains text data of the text to be extracted, the text to be extracted can be obtained through a query statement. In some application scenarios, obtaining the text to be extracted can be through an API call, and the API provided by the online service can be used to obtain the text to be extracted in a specific topic or field. In some application scenarios, obtaining the text to be extracted can be manual input or voice input. For text to be extracted with a small amount of data, the text to be extracted can be obtained by manual input or voice input. In some application scenarios, obtaining the text to be extracted can be by crawling web page data, using crawler technology to crawl the text content of relevant web pages from the Internet. In some application scenarios, obtaining the text to be extracted can be through a search engine or a data set platform to find and download the data set. The text to be extracted may exist in the form of a data set, and the text to be extracted may be an existing data set. This is only an example, and does not limit the method of obtaining the text to be extracted.

[0027] Step S12: Use the sentiment extraction model to extract word features from the text to be extracted, and obtain the context representation between the word representations in the text to be extracted.

[0028] The sentiment extraction model can be a model that can extract features from the input text to be extracted to obtain feature representations. The process of extracting word features from the text to be extracted can be to extract features from the input text to be extracted, obtain representations of each word in the text to be extracted, and extract word features from each word representation to obtain context representations between each word representation in the text to be extracted. The representations of each word in the text to be extracted can refer to vector representations corresponding to each word in a given sentence text. For example, for any two words in a sentence, the first word a and the second word b, or the first word i and the second word j. The first word representation corresponding to any two words in the text to be extracted is h i , the second word is represented by h j. The context representation may refer to the association between any two words in the text to be extracted. Specifically, the context representation may refer to the association between the semantic information between any two words in the text to be extracted. The context representation may utilize the semantic information of the sentence text between the first word i and the second word j. For example, the context representation corresponding to any two words may be expressed as c ij .

[0029] In some application scenarios, the process of extracting features from the input text to be extracted and obtaining the representations of each word in the text to be extracted may be to perform word segmentation embedding processing on the text to be extracted to obtain the representations of each word in the text to be extracted. Among them, the sentiment extraction model may include multiple modules or networks. The sentiment extraction model may include a decoder and a relationship supervision module. In some application scenarios, the decoder in the sentiment extraction model may perform feature extraction on the input text to be extracted to obtain the representations of each word in the text to be extracted. Specifically, the decoder performs word segmentation embedding processing on the text to be extracted. In other application scenarios, the text embedding model in the sentiment extraction model may be used to perform word segmentation embedding processing on the text to be extracted to obtain the representations of each word. Among them, the representations of each word may be word embedding representations. The text embedding model may be a pre-trained language representation model such as BERT, Word2vec, Glove, FastText, Elmo, etc. The vector representation of each word in the text to be extracted may be obtained through the text embedding model. The vector representation corresponding to each word in the text to be extracted may be obtained, and the vector representation may be a word embedding representation. For example, after the word segmentation and embedding processing is performed on the text to be extracted, the word embedding representation obtained can be [CLS], Tok1, Tok2, etc. In some application scenarios, the relationship supervision module in the sentiment extraction model can extract word features from each word representation to obtain the context representation between each word representation in the text to be extracted.

[0030] Specifically, the above step S12 may include the following steps: using the encoder in the sentiment extraction model to perform feature extraction on the input text to be extracted, and obtaining the representation of each word in the text to be extracted. Using the relationship supervision module in the sentiment extraction model, extract word features from each word representation, and obtain the context representation between each word representation in the text to be extracted.

[0031] In some application scenarios, the relationship supervision module may include a pooling layer. The pooling layer in the relationship supervision module may be a pooling layer. The pooling layer in the relationship supervision module is used to perform a pooling operation on each word representation to obtain a contextual representation between each word representation in the text to be extracted. Specifically, the process of obtaining the contextual representation corresponding to any two words in the text to be extracted can refer to formula (1):

[0032] c ij=pooling(h i ,h i+1 ,…,h j ) formula (1);

[0033] Among them, any two words in the text to be extracted can be the first word i and the second word j. i ,h i+1 ,…,h j ) can represent the word representation corresponding to the sentence text between the first word i and the second word j. i+1 It can represent the word representation corresponding to the second word in the sentence text between the first word i and the second word j. The first word in the sentence text between the first word i and the second word j is the first word i, and the last word is the second word j. ij It is used to represent the context representation of any two words in the text to be extracted. pooling can represent the pooling layer.

[0034] Step S13: Based on the representation of each word and the context representation, determine the target feature representation of the text to be extracted.

[0035] The target feature representation characterizes the relational information that can instruct the sentiment extraction model to generate extraction results for the text to be extracted. Among them, the target feature representation is a feature representation that can instruct the sentiment extraction model to generate extraction results for the text to be extracted. The target feature representation contains one or more relational information in the text to be extracted. Specifically, the target feature representation can be a soft prompt. The soft prompt contains the relational information in the text to be extracted that is valuable for the extraction result. It can be considered that the sentiment extraction model uses the relational information corresponding to the soft prompt to generate the target extraction result.

[0036] In some application scenarios, the process of determining the target feature representation of the text to be extracted based on each word representation and the context representation may be a process of extracting features from each word representation and the context representation. Specifically, feature extraction is performed based on the word representation corresponding to any two words in the text to be extracted and the context representation corresponding to the any two words to determine the target feature representation corresponding to the any two words.

[0037] Step S14: Extract sentiment from the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted.

[0038] The target extraction result includes a sequence of sentiment triples or a sequence of sentiment quadruplets. In some application scenarios, when the target extraction result is a sequence of sentiment triples, the text to be extracted is a given sentence text X, and the length of the text to be extracted is n. The sentiment extraction of the target features and each word representation of the text to be extracted can be aspect sentiment triple extraction. Among them, the goal of aspect sentiment triple extraction is to extract a set of aspect sentiment triples. The sentiment triple sequence can include one or more triples. Among them, a triple is defined as consisting of three elements. Each element of the triple can be an aspect item (aspect), an opinion item (opinion), and a sentiment polarity (sentiment). Sentiment polarity can be divided into three categories, which can be positive, neutral, and negative. In some application scenarios, when the target extraction result is a sequence of sentiment quadruplets, the text to be extracted is a given sentence text X, and the length of the text to be extracted is n. The sentiment extraction of the target features and each word representation of the text to be extracted can be aspect sentiment quadruplet extraction. Among them, the goal of aspect sentiment quadruple extraction is to extract a set of aspect sentiment quadruple. That is, the goal of aspect sentiment quadruple extraction is to extract quadruple information from the text to be extracted. Quadruple information may include one or more quadruple. Among them, the definition of a quadruple is composed of four elements. Each element of the quadruple can be an aspect term (Aspect Term), an opinion term (Opinion Term), a sentiment polarity (SentimentPolarity), and an aspect category (Aspect Category). It can be understood that one or more words may exist in each element corresponding to the sentiment triple sequence or the sentiment quadruple sequence in the target extraction result. The target extraction result can be applied to a variety of scenarios, such as knowledge graph construction, public opinion analysis, user portrait construction, text sentiment analysis, etc.

[0039] The above scheme, after obtaining the text to be extracted, determines the target feature representation of the text to be extracted based on the word representations and context representations obtained by extracting word features of the text to be extracted using the sentiment extraction model, wherein the target feature representation represents the relationship information that can indicate the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted. Compared with directly performing sentiment extraction on the text to be extracted, the present application can combine more relationship information about the text to be extracted, thereby improving the accuracy of the sentiment extraction results.

[0040] In some embodiments, the above step S13 may include the following steps: first, linearly transform each context representation and each word representation to obtain an intermediate relationship level representation of the text to be extracted. Then, convolution processing is performed on the intermediate relationship level representation to obtain a relationship level representation, which represents the feature representation between each word in the text to be extracted and the text to be extracted.

[0041] Subsequently, the relationship level representation is subjected to a preset processing to obtain a target feature representation, wherein the preset processing includes a pooling processing.

[0042] The sentiment extraction model may include a relationship prompt module, which is used to extract features based on the relationship level representation to obtain the target feature representation. In some application scenarios, the above step S13 may include the following steps: using the relationship supervision module in the sentiment extraction model to linearly transform each context representation and each word representation to obtain the intermediate relationship level representation of the text to be extracted. Using the relationship supervision module in the sentiment extraction model, convolution processing is performed on the intermediate relationship level representation to obtain the relationship level representation. Using the relationship prompt module in the sentiment extraction model, the relationship level representation is preset to obtain the target feature representation.

[0043] Among them, the intermediate relationship level representation can be a transformed feature representation obtained by linearly transforming the word representation of any two words and the context representation of the any two words. The intermediate relationship level representation is one or more. In some application scenarios, the above-mentioned step of linearly transforming each context representation and each word representation to obtain the intermediate relationship level representation of the text to be extracted may include fusing the word representation of any two words and the context representation of the any two words to obtain the fused feature representation of the any two words. Linear transformation processing is performed on the fused feature representation of any two words to obtain the intermediate relationship level representation of any two words. Among them, the fusion processing can be splicing the word representation of any two words and the context representation of the any two words.

[0044] In some application scenarios, the relationship supervision module may include a linear layer. The linear layer in the relationship supervision module may be a linear layer Linear. The linear layer in the relationship supervision module is used to perform linear transformation on each context representation and each word representation to obtain an intermediate relationship level representation of the text to be extracted. Specifically, the process of obtaining the intermediate relationship level representation corresponding to any two words in the text to be extracted can refer to formula (2):

[0045] r′ ij =GELU(Linear([h i ;h j ;c ij ])) Formula (2);

[0046] Any two words in the text to be extracted can be the first word i and the second word j. ij It is used to represent the context representation of any two words in the text to be extracted. Linear can represent a linear layer. i ;h j;c ij ] can represent the fusion feature representation of any two words. GELU can represent a nonlinear activation function. For example, the activation function can be a sigmoid function, a tanh function, a relu function, etc. r′ ij It can represent the intermediate relationship level representation corresponding to any two words.

[0047] The relationship level representation is used to represent the feature representation of the relationship information between each word in the text to be extracted and the text to be extracted. The relationship level representation is one or more. Specifically, the relationship level representation is used to represent the association relationship between the semantic information of the sentence text between any two words in the text to be extracted and the semantic information of any two words.

[0048] In some application scenarios, the relationship supervision module may include a convolution layer. The convolution layer in the relationship supervision module may be a convolution layer ConvNet. The convolution layer in the relationship supervision module is used to perform convolution processing on the intermediate relationship level representation to obtain the relationship level representation. Specifically, the process of obtaining the relationship level representation corresponding to any two words in the text to be extracted can refer to formula (3):

[0049] r=ConvNet(r′) formula (3);

[0050] Among them, r′ can represent the intermediate relationship level representation corresponding to any two words. ConvNet can represent a convolutional neural network, that is, a convolutional layer ConvNet. r can represent the relationship level representation corresponding to any two words. In other application scenarios, the intermediate relationship level representation can be input into the attention mechanism network to obtain the relationship level representation. At this time, it is necessary to ensure that the intermediate relationship level representation and the relationship level representation belong to the same dimension.

[0051] It can be considered that the present application can encourage the relationship supervision module to learn the relationship representation in the sentence text between any two words in the text to be extracted, so as to obtain the relationship level representation corresponding to any two words. Furthermore, the target feature representation determined based on the relationship level representation can be combined with more relationship information about the text to be extracted.

[0052] The target feature representation characterizes the relationship information that can indicate the sentiment extraction model to generate the extraction result for the text to be extracted. Specifically, the relationship information corresponding to the target feature representation can be the relationship information between any word in the text to be extracted or the word corresponding to any position in the text to be extracted and other words in at least part of the text to be extracted. Exemplarily, the relationship information corresponding to the target feature representation can be the relationship information between the word corresponding to any position in the text to be extracted and the row-related words and / or column-related words of the word in the text to be extracted.

[0053] The preset processing performed on the relationship level representation may be a process of extracting features from the relationship level representation to obtain a target feature representation. Different feature extraction methods may be set according to the requirements of the target feature representation. The preset processing may be a pooling process.

[0054] In some application scenarios, the relationship prompt module may include a pooling layer. The pooling layer in the relationship prompt module may be a pooling layer. The pooling layer in the relationship prompt module is used to perform pooling processing on the relationship level representation to obtain the target feature representation. The relationship prompt module may output the target feature representation. Specifically, the process of obtaining the target feature representation in the text to be extracted may refer to formula (4):

[0055] p i =pooling(r i1 ,r i2 ,…,r im ,r 1i ,r 2i ,…,r mi ) formula (4);

[0056] Among them, the i-th position x of the text to be extracted i It can correspond to a word. That is, it is the word corresponding to any position in the text to be extracted. The text to be extracted can contain m words, i is any value from 1 to m, and m is the maximum length of the text to be extracted. pooling can represent the pooling layer. (r i1 ,r i2 ,…,r im ,r 1i ,r 2i ,…,r mi ) can represent the relationship level between the word corresponding to any position and other words in at least part of the text to be extracted. In some application scenarios, (r i1 ,r i2 ,…,r im ,r 1i ,r 2i ,…,r mi ) can represent the relationship level between the word corresponding to any position and the row-related words and / or column-related words of the word in the text to be extracted. i It can represent the i-th position x of the text to be extracted i Corresponding soft hints. The soft hints at all positions in the text to be extracted can constitute the target feature representation.

[0057] For example, the relationship hint module may be to obtain the i-th position x of the text to be extracted by using the row-column cross-maximum pooling operationi The corresponding word relationship-aware soft hint p i Then, the soft prompts corresponding to the words at all positions in the extracted text are fused or concatenated to obtain a target feature representation composed of the soft prompts corresponding to the words at all positions.

[0058] It can be considered that the target feature representation combines the relationship information corresponding to the soft prompts corresponding to the words at all positions, so that the target extraction result obtained by instructing the sentiment extraction model based on the target feature representation is more accurate.

[0059] In some embodiments, the emotion extraction model includes a decoder, and the decoder includes a plurality of cascaded decoding layers. The above step S14 may include the following steps: first, for the first decoding layer in the decoder, a plurality of word representations and target feature representations are used as input to obtain the first target word in the target extraction result. The first target word belongs to one of the elements of the target extraction result; then, for other decoding layers in the decoder, the output of at least one reference decoding layer, the fusion result of the plurality of word representations and the target feature representation are used as the input of other decoding layers, and the reference decoding layer is a decoding layer before other decoding layers; wherein the target extraction result is obtained by combining the output results of each decoding layer.

[0060] The sentiment extraction module may include a decoder. The decoder includes several decoding layers arranged in cascade. Each decoding layer is used to generate a target word in a target sequence corresponding to the target extraction result. The target sequence in the target extraction result may be a sentiment triple sequence or a sentiment quadruple sequence. Among them, the target sequence may include multiple elements. For example, a sentiment triple sequence may include three elements: aspect term, opinion term, and sentiment polarity. For example, a sentiment quadruple sequence may include four elements: aspect term, opinion term, sentiment polarity, and aspect category. It can be understood that the target word in the target sequence corresponding to the target extraction result generated by each decoding layer belongs to one of the elements in the above target sequence.

[0061] The above step S14 may be a process of inputting each word representation output by the encoder and the target feature representation output by the relationship prompt module into the decoder to obtain the target extraction result output by the decoder. For the first decoding layer in the decoder, the input of the first decoding layer may be a number of word representations and a target feature representation, and the output of the first decoding layer may be the first target word in the target extraction result. Among them, the first target word belongs to one of the elements in the target sequence in the target extraction result. Other decoding layers in the decoder may be non-first decoding layers in the decoder. Several word representations may be one word representation or multiple word representations. Several word representations may be at least one word representation in the text to be extracted. In some application scenarios, several word representations may be each word representation output by the encoder. For the non-first decoding layer in the decoder, the input of the non-first decoding layer may be the fusion result of the output of at least one reference decoding layer, several word representations and the target feature representation. The output of the non-first decoding layer may be the target word corresponding to the non-first decoding layer. Among them, the reference decoding layer is a decoding layer before other decoding layers. The output of the reference decoding layer may be the target word output by the decoding layer. In some application scenarios, the input of the non-first decoding layer may be the output of all reference decoding layers, the fusion result of several word representations and the target feature representation. Specifically, the output of all reference decoding layers may be the target word output by all decoding layers before the non-first decoding layer. The fusion result of the output of all reference decoding layers, several word representations and the target feature representation may be the target word output by all decoding layers before the non-first decoding layer, and the several word representations and the target feature representation are spliced ​​together to obtain the corresponding fusion result of the non-first decoding layer. Exemplarily, for the last encoding layer, the target word output by all encoding layers before the last encoding layer, the word representations output by the encoder, and the target feature representation output by the relationship prompt module are spliced ​​together to obtain the fusion result corresponding to the last decoding layer. The fusion result corresponding to the last decoding layer is input to the last decoding layer to obtain the target word output by the last decoding layer.

[0062] The target extraction result is obtained by combining the output results of each decoding layer. In some application scenarios, the target words output by all decoding layers in the decoder are combined to obtain a target sequence. This target sequence is used as the target extraction result.

[0063] It can be considered that using the word representations output by the encoder and the target feature representations with more relationship information output by the relationship prompt module to determine the target words of each decoding layer as the target extraction result can improve the accuracy of the target extraction result.

[0064] See also Figure 2 , Figure 21 is another flow chart of an embodiment of the emotion extraction method of the present application. Specifically, the emotion extraction method further includes a training step for the emotion extraction model, and the training step may include the following steps:

[0065] Step S21: Obtain sample text.

[0066] The sample text may be one or more. Each sample text is obtained. Each sample text may include multiple words. In some application scenarios, the sample text may be a text to be extracted. The relationship between the sample text and the text to be extracted may be the same text object or the same type of text object.

[0067] For sample text and how to obtain sample text, please refer to the above contents of text to be extracted and how to obtain text to be extracted, which will not be described in detail here.

[0068] Step S22: Using the encoder in the sentiment extraction model, obtain sample word representations of the sample text.

[0069] For a sample text, the sample text is input into the encoder in the sentiment extraction model, and the encoder of the sentiment extraction model can output the representation of each sample word of the sample text.

[0070] The decoder performs word segmentation and embedding processing on the sample text. A vector representation corresponding to each word in the sample text is obtained. The vector representation can be a word embedding representation, that is, a sample word representation. The sample word representation can be one or more.

[0071] It can be understood that the process of obtaining the sample word representation of the sample text using the encoder in the sentiment extraction model can refer to the above-mentioned process of obtaining the representation of each word of the text to be extracted using the encoder in the sentiment extraction model, and will not be repeated here.

[0072] Step S23: using the relationship supervision module in the sentiment extraction model, determine the sample relationship level representation based on each sample word representation.

[0073] The sample relationship level representation characterizes the feature representation between each word in the sample text and the sample text.

[0074] The above step S23 may include the following steps: using the relational supervision module in the sentiment extraction model to extract word features from each word representation to obtain a sample context representation between each word representation in the sample text. Using the relational supervision module in the sentiment extraction model to perform linear transformation on each sample context representation and each sample word representation to obtain a sample intermediate relational level representation of the sample text. Using the relational supervision module in the sentiment extraction model to perform convolution processing on the sample intermediate relational level representation to obtain a sample relational level representation.

[0075] Among them, the sample context representation may refer to the association relationship between any two words in the sample text. Specifically, the sample context representation may refer to the association relationship corresponding to the semantic information between any two words in the sample text. Among them, the relationship supervision module in the sentiment extraction model is used to perform linear transformation on each sample context representation and each sample word representation to obtain a sample intermediate relationship level representation of the sample text. The sample intermediate relationship level representation is convolved using the relationship supervision module in the sentiment extraction model to obtain a sample relationship level representation. The sample relationship level representation is used to represent the feature representation of the relationship information between each word in the sample text and the sample text. The sample relationship level representation is one or more. Specifically, the sample relationship level representation is used to represent the association relationship between the semantic information of the sentence text between any two words in the sample text and the semantic information of any two words.

[0076] It can be understood that the process of determining the sample relationship level representation based on the representation of each sample word using the relationship supervision module in the sentiment extraction model can refer to the above-mentioned process of obtaining the relationship level representation using the relationship supervision module in the sentiment extraction model, which will not be repeated here.

[0077] Step S24: Use the relationship prompt module in the sentiment extraction model to perform pooling processing on the sample relationship level representation to obtain the sample target feature representation.

[0078] The sample target feature representation is used to instruct the sentiment extraction model to generate extraction results for the sample text.

[0079] The sample relationship level representation is pooled using the relationship prompt module in the sentiment extraction model to obtain the sample target feature representation. The sample target feature representation represents the relationship information that can instruct the sentiment extraction model to generate the sample extraction result for the sample text. Specifically, the relationship information corresponding to the sample target feature representation can be the relationship information between any word in the sample text or the word corresponding to any position in the sample text and other words in at least part of the sample text. Exemplarily, the relationship information corresponding to the sample target feature representation can be the relationship information between the word corresponding to any position in the sample text and the row-related words and / or column-related words of the word in the sample text.

[0080] It can be understood that the process of pooling the sample relationship level representation using the relationship prompt module in the sentiment extraction model to obtain the sample target feature representation can refer to the above-mentioned process of obtaining the target feature representation using the relationship prompt module in the sentiment extraction model, and will not be repeated here.

[0081] Step S25: Use the decoder in the sentiment extraction model to perform sentiment extraction on the sample target feature representation and each sample word representation to obtain a sample extraction result corresponding to the sample text.

[0082] The sample extraction results include sentiment triplet sequences or sentiment quadruple sequences.

[0083] It can be understood that the process of using the decoder in the sentiment extraction model to perform sentiment extraction on the sample target feature representation and each sample word representation to obtain the sample extraction result corresponding to the sample text can refer to the above-mentioned process of using the decoder in the sentiment extraction model to obtain the target extraction result, which will not be repeated here.

[0084] Step S26: Based on the difference between the sample extraction result and the extraction label of the sample text, adjust the parameters of at least some modules in the sentiment extraction model.

[0085] The extracted label represents the extraction result of the sample text that has been pre-labeled.

[0086] The sentiment extraction model may include a training module. The training module is used to adjust the parameters of at least some modules in the sentiment extraction model based on the difference between the sample extraction result and the extraction label of the sample text. Adjusting the parameters of at least some modules in the sentiment extraction model may be adjusting the parameters of at least one module in the sentiment extraction model. Among them, each module in the sentiment extraction model may be an encoder, a relationship supervision module, a relationship prompt module, a decoder and a training module.

[0087] In some application scenarios, the extraction label of the sample text may be to use at least part of the generated extraction results as pre-labeled extraction results. In some application scenarios, the sample extraction result of the sample text may be a sequence of emotion triples or a sequence of emotion quadruplets of the sample text output by the emotion extraction model. Among them, the number of sample texts may be one or more. The sample extraction result of the sample text may be a prediction result output by the emotion extraction model. The extraction label of the sample text may be a real result corresponding to the prediction result output by the emotion extraction model. Exemplarily, the sample extraction result of the sample text may be a prediction result of the emotion triple sequence of the sample text. The extraction label of the sample text is used to represent the real emotion triple sequence pre-labeled by the sample text. In some application scenarios, the training module of the emotion extraction model may sequentially perform the definition of the loss function, the initialization of the emotion extraction model parameters, the forward propagation of the emotion extraction model, the calculation of the loss, the back propagation and the parameter update to adjust the parameters of at least part of the modules in the emotion extraction model. Specifically, the process of adjusting the parameters in the emotion extraction model may be to define the loss function or to select an appropriate loss function to measure the difference between the prediction result of the emotion extraction model and the real result. Initializing the parameters of the emotion extraction model may be initializing the parameters of at least some modules in the emotion extraction model, such as weights and biases. Forward propagation may be calculating the prediction result of the emotion extraction model through forward propagation. Calculating the loss may be comparing the prediction result with the true result and calculating the value of the loss function. Backward propagation may be calculating the gradient of the parameter to the loss function through the back propagation algorithm, that is, the rate of change of the emotion extraction model parameter relative to the loss function. Parameter updating may be updating the parameters of the emotion extraction model using the negative gradient direction of the parameter according to the gradient descent algorithm. There may be multiple options for updating the parameters, such as batch gradient descent, stochastic gradient descent, or mini-batch gradient descent. The training module of the emotion extraction model may be a process of iteratively executing forward propagation, loss calculation, back propagation, and parameter updating until a predetermined stop condition is reached, such as reaching a certain number of iterations or the loss function is reduced to a certain threshold. The training module of the sentiment extraction model Through this process of adjusting the parameters in the sentiment extraction model, the sentiment extraction model parameters will gradually adjust to minimize the loss function and make the predicted results consistent with the actual results. The key point is to calculate the loss and gradient before each parameter update, and use this information to adjust the parameters during the update process. In this way, the sentiment extraction model will more accurately predict the sample extraction results after sentiment extraction of each sample text and improve the performance of the sentiment extraction model.

[0088] The above scheme, after obtaining the text to be extracted, determines the target feature representation of the text to be extracted based on the word representations and context representations obtained by extracting word features of the text to be extracted using the sentiment extraction model, wherein the target feature representation represents the relationship information that can indicate the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted. Compared with directly performing sentiment extraction on the text to be extracted, the present application can combine more relationship information about the text to be extracted, thereby improving the accuracy of the sentiment extraction results.

[0089] In some embodiments, the number of sample texts is multiple, and the above step S26 may include the following steps: First, for each sample text, based on the sample extraction result and the extraction label of the sample text, determine the first loss of the sample text. Then, combine the first losses to obtain the first target loss. Subsequently, based on the first target loss, adjust the parameters of the encoder, the relationship supervision module, and the decoder in the sentiment extraction model.

[0090] For each sample text, the probability value of the sample extraction result can be determined based on the sample extraction result and the extraction label of the sample text. In some application scenarios, the extraction label of the sample text can be an input sequence of the sample text input to the sentiment extraction model. In some application scenarios, the extraction label of the sample text can be an input sequence of pre-labeled sample text input to the sentiment extraction model. In other application scenarios, the extraction label of the sample text can be a sample extraction result that has been at least partially generated. Exemplarily, for the final sample extraction result, the final sample extraction result includes all sample target words. The extraction label of the sample text can be at least part of the sample target words.

[0091] Specifically, the process of determining the first loss of the sample text by the training module can refer to formula (5):

[0092]

[0093] Wherein, x may represent the input sequence of the sentiment extraction model. The input sequence may be the sequence corresponding to the sample text. y may represent the output sequence of the sentiment extraction model. The output sequence may be at least part of the sequence in the sample extraction result. T may represent the total length of the sequence corresponding to the sample extraction result. t may represent the sequence corresponding to the sample extraction result. y t It can be said that when the sequence corresponding to the sample extraction result is at position t, the sentiment extraction model is calculated based on the input value and the sequence that has been output, and the prediction result of the sentiment extraction model is generated. Among them, if the total length of the sequence corresponding to the sample extraction result represented by T can be T, then the value of t can be any value m between 1 and T. P θIt can represent the probability that the computing sentiment extraction model generates the prediction result of the sentiment extraction model based on the input value and the already output sequence. L1 can represent the first target loss. The first target loss is obtained by summing multiple first losses.

[0094] It can be understood that y<t can represent the case when the sequence of the sample extraction result output by the encoder is not the final target sequence but an intermediate sequence. Among them, the intermediate sequence is at least part of the sequence in the sample extraction result. Different positions t in the sequence of the sample extraction result correspond to a sample target word. Specifically, the intermediate sequence can be the sequence when the sequence corresponding to the sample extraction result is at position t = m. The intermediate sequence can be the sequence composed of all sample target words before any non-tail position in the target sequence corresponding to the sample extraction result. P θ It can represent that at any position t = m in the target sequence corresponding to the sample extraction result, the computing sentiment extraction model generates the prediction result y of the sentiment extraction model based on the sequence of the input sample text and the intermediate sequence of the already output sentiment extraction result. t of the probability. For the prediction result y of the sentiment extraction model corresponding to any position t = m in the target sequence corresponding to the sample extraction result. t of the probability P θ Take the logarithm to obtain the first loss corresponding to any position t = m in the target sequence corresponding to the sample extraction result. Sum the first losses corresponding to each position t = m in the target sequence corresponding to the sample extraction result to obtain the first target loss.

[0095] Based on the first target loss, adjust the parameters of the encoder, relationship supervision module, and decoder in the sentiment extraction model until the first loss output by the trained sentiment extraction model meets the requirements. Train the encoder, relationship supervision module, and decoder in the above sentiment extraction model with the goal of minimizing the first target loss until the first loss output by the trained sentiment extraction model meets the requirements.

[0096] In some embodiments, the sentiment extraction method further includes the following steps: First, for each sample text, determine the second loss of the sample text based on the sample extraction result and the sample target feature representation. Then, combine each second loss to obtain the second target loss. Subsequently, based on the second target loss, adjust the parameters of the encoder, relationship supervision module, and decoder in the sentiment extraction model.

[0097] For each sample text, based on the sample extraction result, the extraction label of the sample text, and the sample target feature representation, the probability value of the sample extraction result can be determined. In some application scenarios, the extraction label of the sample text can be the input sequence of the sentiment extraction model for the input sample text. In some application scenarios, the extraction label of the sample text can be the pre-annotated input sequence for the sample text input to the sentiment extraction model. In some other application scenarios, the extraction label of the sample text can be at least part of the already generated sample extraction results. Exemplarily, for the final sample extraction result, the final sample extraction result includes all sample target words. The extraction label of the sample text can be at least part of the sample target words.

[0098] Specifically, the process by which the training module determines the second loss of the sample text can refer to formula (6):

[0099]

[0100] Wherein, x can represent the input sequence of the sentiment extraction model. The input sequence can be the sequence corresponding to the sample text. y can represent the output sequence of the sentiment extraction model. The output sequence can be at least part of the sequence in the sample extraction result. T can represent the total length of the sequence corresponding to the sample extraction result. t can represent the sequence corresponding to the sample extraction result. y t can represent that when the sequence of the sample extraction result output by the encoder is not the final target sequence but the intermediate sequence y. Among them, the intermediate sequence is at least part of the sequence in the sample extraction result. Different positions t of the sequence of the sample extraction result correspond to a sample target word. Specifically, the intermediate sequence can be the sequence when the sequence corresponding to the sample extraction result is at the position t = m. p can represent the sample target feature representation output by the relationship prompt module. The intermediate sequence can be the sequence composed of all sample target words before any non-tail position in the target sequence corresponding to the sample extraction result. P θ can represent the probability of calculating the prediction result of the sentiment extraction model based on the input value and the already output sequence. L MLE can represent the second target loss. The second target loss is obtained by summing multiple second losses.

[0101] It can be understood that y<t can represent when the sequence of the sample extraction result output by the encoder is not the final target sequence but the intermediate sequence y. Among them, the intermediate sequence is at least part of the sequence in the sample extraction result. Different positions t of the sequence of the sample extraction result correspond to a sample target word. Specifically, the intermediate sequence can be the sequence when the sequence corresponding to the sample extraction result is at the position t = m. p can represent the sample target feature representation output by the relationship prompt module. The intermediate sequence can be the sequence composed of all sample target words before any non-tail position in the target sequence corresponding to the sample extraction result. P θIt can be said that at any position t=m in the target sequence corresponding to the sample extraction result, the sentiment extraction model is calculated based on the sequence of the input sample text and the intermediate sequence of the output sentiment extraction result to generate the prediction result y of the sentiment extraction model t The prediction result y of the sentiment extraction model corresponding to any position t=m in the target sequence corresponding to the sample extraction result t The probability P θ Take the logarithm to obtain the second loss corresponding to any position t=m in the target sequence corresponding to the sample extraction result. Sum the second losses corresponding to each position t=m in the target sequence corresponding to the sample extraction result to obtain the second target loss.

[0102] Based on the second target loss, the parameters of the encoder, relationship supervision module, and decoder in the emotion extraction model are adjusted until the second loss output by the trained emotion extraction model meets the requirements. The encoder, relationship supervision module, and decoder in the above emotion extraction model are trained with the second target loss reduced until the second loss output by the trained emotion extraction model meets the requirements.

[0103] In some embodiments, the extracted labels include preset classifications of the sample texts, and the above-mentioned step of combining the second losses to obtain the second target loss may include the following steps: First, label the sample extraction results to obtain a target label set. Then, based on the sample relationship level representation and each label in the target label set, determine the probability of each label. The label probability characterizes the possibility that the sample relationship level representation has each label in the target label set. Subsequently, for each sample text, based on each label probability and the preset classification of each sample text, determine the third loss of the sample text. Next, combine each second loss and each third loss to obtain the second target loss.

[0104] The extracted labels include preset categories of sample texts. The preset categories can be obtained through labeling. For example, taking the aspect category as an example, the complete one is S_aspect category, S_emotion polarity is put into Lac and Lca, and E_aspect category and E_emotion polarity are put into Lbd and Ldb. S and E represent start and end, that is, this pair of relationships is the beginning and end of a certain aspect category or emotion polarity.

[0105] The training module creates an initial label set. The initial label set includes a label subset corresponding to each sample relationship level. The initial label set can be expressed as L ij .

[0106] The step of labeling the sample extraction results to obtain the target label set may include: initializing the initial label set to obtain the initialized label set, where the initialized label set is an empty set. Adding labels to each label subset in the initialized label set to obtain the target label set. In some application scenarios, the process of adding labels to each label subset in the initialized label set to obtain the target label set may be to place the sample target words corresponding to each element in the sample extraction result in each label subset. For example, a sentiment quadruple sequence (at o ,ac o ,ot o ,sp o ), the aspect terms in the aspect items can be at i =(x a ,x a+1 ,…,x b ), the opinion word in the opinion item can be ot i =(x c ,x c+1 ,…,x d ). The tag subsets in the target tag set can be set Lac and set Lca, and set Lbd and set Ldb. Suppose the segment of aspect words is from word a to word b, and the segment of opinion words is from word c to word d. In some application scenarios, each tag in the target tag set can have a corresponding relationship with the sample relationship level representation. Set Lac can correspond to the sample relationship level representation r ac The set Lca can correspond to the sample relationship level representation r ca. The sample target words corresponding to each element in the sample extraction result are placed in each label subset according to the preset rules. Among them, the preset rules can be for the aspect category and sentiment polarity in the sample extraction result of the sample text, put the S_aspect category into Lac and Lca, put the E_aspect category into Lbd and Ldb, put the S_aspect category and S_sentiment polarity into Lac and Lca, and put the E_aspect category and E_sentiment polarity into Lbd and Ldb. S_aspect category can indicate the start (start) of identifying these groups of sample relationship levels as a group of aspect sentiment quadruple with this aspect category. E_aspect category can indicate the end (end) of identifying these groups of sample relationship levels as a group of aspect sentiment quadruple with this aspect category. S_sentiment polarity can indicate the start (start) of identifying these groups of sample relationship levels as a group of aspect sentiment quadruple with this sentiment polarity. E_sentiment polarity can indicate the end (end) of identifying these groups of sample relationship levels as a group of aspect sentiment quadruple with this sentiment polarity. It can be understood that the process of adding labels to each label subset in the initialization label set to obtain the target label set can be to traverse all quadruple sequences in the sample extraction results according to preset rules to update the label set corresponding to the sample relationship level representation to obtain the target label set.

[0107] It can be considered that after obtaining the target label set, the present application treats the classification task of the relationship representation as a multi-label classification problem, and sets a binary classifier for each label of each label subset in the target label set to determine whether the relationship representation has this label. In other application scenarios, a multi-classifier can be set for each label of each label subset in the target label set. The label probability can be an indication of whether a given sample relationship level representation has a certain label in the target label set. For example, for a given label S positive The sample relationship level between words i and j is represented by r ij , determine the sample relationship level representation r between words i and j ij Whether it has S positive Label. The preset classification of the sample text can be a given fact classification. Specifically, the fact classification can be the actual probability that the sample relationship level between word i and word j has the label S_positve.

[0108] Specifically, the process of determining the label probability of the sample text and the third loss can refer to formula (7), formula (8), formula (9) and formula (10):

[0109]

[0110]

[0111]

[0112]

[0113] Among them, FFNN represents a forward propagation deep neural network with a nonlinear activation function. ij It can be a sample-level relationship representation between words i and j. is the intermediate value used for calculation after representing the sample relationship level between word i and word j through the deep neural network. The calculated sample relationship level between word i and word j has the label probability of label S_positve. The sigmoid function is a mathematical function whose goal is to map a value with a range of R to a number between 0 and 1 to obtain the label probability. Linear can represent a linear layer. It can represent fact classification. Given a fact classification Among them, given the fact classification It can be said that when the label set represented by the sample relationship level representation of word i and word j has S_positive, then is 1, otherwise is 0. This application uses the cross entropy function to calculate the loss function. It can represent S positive The loss corresponding to the label. It can represent the sum of the losses corresponding to all labels in the target label set. Specifically, for example, for labels S_positive, S_negative, S_neutral, the losses corresponding to all labels are added together to calculate the sum of losses. The sum of losses can represent the third loss corresponding to the sample text. L RS It can represent the third loss corresponding to any sample text.

[0114] The process of obtaining the second target loss by combining the second losses and the third losses can be to sum the second losses of all sample texts and the third losses of all sample texts to obtain the second target loss. Adjust the parameters of the encoder, relationship supervision module, and decoder in the sentiment extraction model based on the second target loss until the second loss output by the trained sentiment extraction model meets the requirements. Train the encoder, relationship supervision module, and decoder in the above sentiment extraction model with the goal of reducing the second target loss until the second loss output by the trained sentiment extraction model meets the requirements.

[0115] It is understandable that weights can be added when adding the loss functions in the calculation process of the first target loss and the second target loss of the present application. Exemplarily, in combination with each second loss and each third loss, the process of obtaining the second target loss can multiply the second loss of all sample texts by the weight corresponding to the second loss to obtain the second product. Multiply the third loss of all sample texts by the weight corresponding to the third loss to obtain the third product. Sum the second product and the third product to obtain the second target loss. Among them, the weight corresponding to the second loss and the weight corresponding to the third loss are determined according to the training requirements of the sentiment extraction model.

[0116] See also Figure 3 , Figure 3 This is a structural diagram of the emotion extraction model shown in an embodiment of the emotion extraction method of the present application.

[0117] The sentiment extraction model may include a decoder, a relation supervision module, a relation hint module, and an encoder.

[0118] Among them, the encoder input can be the text to be extracted. The output of the encoder is the word representation corresponding to each word of the text to be extracted. The input of the relationship supervision module can be the word representation output by the encoder. The output of the relationship supervision module can be the relationship level representation between any two words in the text to be extracted. The input of the relationship prompt module can be the relationship level representation output by the relationship supervision module, and the output of the relationship prompt module can be the target feature representation. Among them, the target feature representation is a feature representation that characterizes the relationship information that can indicate the sentiment extraction model to generate extraction results for the extracted text. Specifically, the target feature representation can be a soft prompt. The input of the decoder is the word representation output by the encoder and the target feature representation output by the relationship prompt module. The output of the decoder can be the target extraction result.

[0119] The above scheme, after obtaining the text to be extracted, determines the target feature representation of the text to be extracted based on the word representations and context representations obtained by extracting word features of the text to be extracted using the sentiment extraction model, wherein the target feature representation represents the relationship information that can indicate the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted. Compared with directly performing sentiment extraction on the text to be extracted, the present application can combine more relationship information about the text to be extracted, thereby improving the accuracy of the sentiment extraction results.

[0120] See also Figure 4 , Figure 4It is a structural diagram of an embodiment of the emotion extraction device of the present application. The emotion extraction device 40 includes an acquisition module 41, an extraction module 42, a determination module 43 and an extraction module 44. The acquisition module 41 is used to acquire the text to be extracted; the extraction module 42 is used to perform word feature extraction on the text to be extracted using the emotion extraction model, and obtain the context representation between each word representation in the text to be extracted; the determination module 43 is used to determine the target feature representation of the text to be extracted based on each word representation and the context representation, and the target feature representation represents the relationship information that can indicate that the emotion extraction model generates an extraction result for the text to be extracted; the extraction module 44 is used to perform emotion extraction on the target feature representation and each word representation, and obtain the target extraction result corresponding to the text to be extracted, and the target extraction result includes an emotion triple sequence or an emotion quadruple sequence.

[0121] The above scheme, after obtaining the text to be extracted, determines the target feature representation of the text to be extracted based on the word representations and context representations obtained by extracting word features of the text to be extracted using the sentiment extraction model, wherein the target feature representation represents the relationship information that can indicate the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted. Compared with directly performing sentiment extraction on the text to be extracted, the present application can combine more relationship information about the text to be extracted, thereby improving the accuracy of the sentiment extraction results.

[0122] Please refer to the emotion extraction method for the functions performed by each module, which will not be repeated here.

[0123] See also Figure 5 , Figure 5 : is a schematic diagram of the structure of an embodiment of an electronic device of the present application. The electronic device 50 includes a memory 51 and a processor 52, and the processor 52 is used to execute program instructions stored in the memory 51 to implement the steps in the above-mentioned emotion extraction method embodiment. In a specific implementation scenario, the electronic device 50 may include but is not limited to: a microcomputer, a server, and in addition, the electronic device 50 may also include mobile devices such as laptops and tablet computers, which are not limited here.

[0124] Specifically, the processor 52 is used to control itself and the memory 51 to implement the steps in the above-mentioned emotion extraction method embodiment. The processor 52 can also be called a CPU (Central Processing Unit). The processor 52 may be an integrated circuit chip with signal processing capabilities. The processor 52 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field-programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. In addition, the processor 52 can be implemented by an integrated circuit chip.

[0125] The above scheme, after obtaining the text to be extracted, determines the target feature representation of the text to be extracted based on the word representations and context representations obtained by extracting word features of the text to be extracted using the sentiment extraction model, wherein the target feature representation represents the relationship information that can indicate the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted. Compared with directly performing sentiment extraction on the text to be extracted, the present application can combine more relationship information about the text to be extracted, thereby improving the accuracy of the sentiment extraction results.

[0126] See also Figure 6 , Figure 6 The computer-readable storage medium 60 stores program instructions 601, which implement the steps in any of the above emotion extraction method embodiments when executed by a processor.

[0127] The above scheme, after obtaining the text to be extracted, determines the target feature representation of the text to be extracted based on the word representations and context representations obtained by extracting word features of the text to be extracted using the sentiment extraction model, wherein the target feature representation represents the relationship information that can indicate the sentiment extraction model to generate extraction results for the text to be extracted; sentiment extraction is performed on the target feature representation and each word representation to obtain the target extraction result corresponding to the text to be extracted. Compared with directly performing sentiment extraction on the text to be extracted, the present application can combine more relationship information about the text to be extracted, thereby improving the accuracy of the sentiment extraction results.

[0128] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.

[0129] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0130] In the several embodiments provided in the present application, it should be understood that the disclosed methods and devices can be implemented in other ways. For example, the device implementation described above is only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.

[0131] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0132] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) or a processor (processor) to perform all or part of the steps of each implementation method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0133] If the technical solution of this application involves personal information, the product using the technical solution of this application has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using the technical solution of this application has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the "explicit consent" requirement. For example, on personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to the collection of his or her personal information; or on the device that processes personal information, the personal information processing rules are notified by obvious signs / information, and the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; among them, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

Claims

1. A sentiment extraction method, characterized in that: include: Get the text to be extracted; Using the sentiment extraction model to extract word features from the text to be extracted, and obtaining context representations between word representations in the text to be extracted; Based on each of the word representations and the context representation, determining a target feature representation of the text to be extracted, wherein the target feature representation represents relationship information that can instruct the sentiment extraction model to generate an extraction result for the text to be extracted; Sentiment extraction is performed on the target feature representation and each of the word representations to obtain a target extraction result corresponding to the text to be extracted, wherein the target extraction result includes a sequence of sentiment triples or a sequence of sentiment quadruples.

2. The method according to claim 1, characterized in that The step of determining the target feature representation of the text to be extracted based on each of the word representations and the context representation includes: Performing linear transformation on each of the context representations and each of the word representations to obtain an intermediate relation level representation of the text to be extracted; Performing convolution processing on the intermediate relationship level representation to obtain a relationship level representation, wherein the relationship level representation represents a feature representation between each word in the text to be extracted and the text to be extracted; The relationship level representation is subjected to a preset processing to obtain the target feature representation, wherein the preset processing includes a pooling processing.

3. The method according to claim 1 or 2, characterized in that: The sentiment extraction model includes a decoder, and the decoder includes a plurality of cascaded decoding layers. The sentiment extraction is performed on the target feature representation and each word representation to obtain a target extraction result corresponding to the text to be extracted, including: For a first decoding layer in the decoder, taking the plurality of word representations and the target feature representation as input, obtaining a first target word in the target extraction result, wherein the first target word belongs to one of the elements of the target extraction result; For other decoding layers in the decoder, using the output of at least one reference decoding layer, the fusion result of the plurality of word representations and the target feature representation as the input of the other decoding layers, the reference decoding layer being the decoding layer before the other decoding layers; The target extraction result is obtained by combining the output results of each decoding layer.

4. The method according to claim 2, characterized in that: The method further comprises a step of training the emotion extraction model, wherein the training step comprises: Get sample text; Using the encoder in the sentiment extraction model, a sample word representation of the sample text is obtained; Using the relationship supervision module in the sentiment extraction model, a sample relationship level representation is determined based on each of the sample word representations, wherein the sample relationship level representation represents a feature representation between each word in the sample text and the sample text; Using the relationship prompt module in the sentiment extraction model to perform pooling processing on the sample relationship level representation to obtain the sample target feature representation, wherein the sample target feature representation is used to instruct the sentiment extraction model to generate an extraction result for the sample text; Using the decoder in the sentiment extraction model to perform sentiment extraction on the sample target feature representation and each of the sample word representations, to obtain a sample extraction result corresponding to the sample text, wherein the sample extraction result includes a sentiment triple sequence or a sentiment quadruple sequence; Based on the difference between the sample extraction result and the extraction label of the sample text, the parameters of at least some modules in the sentiment extraction model are adjusted, and the extraction label represents the extraction result of the sample text that has been pre-labeled.

5. The method according to claim 4, characterized in that The number of the sample texts is multiple, and adjusting the parameters of at least some modules in the sentiment extraction model based on the difference between the sample extraction result and the extraction label of the sample text includes: For each of the sample texts, determining a first loss of the sample text based on the sample extraction result and the extraction label of the sample text; Combining the first losses, obtaining a first target loss; Based on the first target loss, the parameters of the encoder, the relationship supervision module and the decoder in the sentiment extraction model are adjusted.

6. The method according to claim 4, characterized in that The method further comprises: For each of the sample texts, determining a second loss of the sample text based on the sample extraction result and the sample target feature representation; Combining the second losses, a second target loss is obtained; Based on the second target loss, the parameters of the encoder, the relationship supervision module and the decoder in the sentiment extraction model are adjusted.

7. The method according to claim 6, characterized in that The extracted label includes a preset classification of the sample text, and the combining of the second losses to obtain a second target loss includes: Performing labeling processing on the sample extraction results to obtain a target label set; Determine the probability of each tag based on the sample relationship level representation and each tag in the target tag set, wherein the tag probability represents the possibility that the sample relationship level representation has each tag in the target tag set; For each of the sample texts, based on the label probabilities and the preset classification of each of the sample texts, determining a third loss of the sample text; The second loss and the third loss are combined to obtain a second target loss.

8. An emotion extraction device, characterized in that: include: An acquisition module is used to obtain the text to be extracted; An extraction module, used to extract word features from the text to be extracted using a sentiment extraction model, and obtain context representations between word representations in the text to be extracted; A determination module, used to determine a target feature representation of the text to be extracted based on each of the word representations and the context representation, wherein the target feature representation represents relationship information that can instruct the sentiment extraction model to generate an extraction result for the text to be extracted; The extraction module is used to perform sentiment extraction on the target feature representation and each word representation to obtain a target extraction result corresponding to the text to be extracted, wherein the target extraction result includes a sentiment triple sequence or a sentiment quadruple sequence.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores program instructions, and the processor retrieves the program instructions from the memory to execute the emotion extraction method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that: include: Program instructions are stored, and when the program instructions are executed by a processor, they are used to implement the emotion extraction method as described in any one of claims 1-7.