Method, device and computer equipment for extracting sentiment triples from text data
Through text expansion and feature perception models, the training data is expanded and optimized for the emotional triple extraction model, which solves the scarcity and indecision problems of training data in the existing technology, and achieves a more efficient and accurate emotional triple extraction effect.
Patent Information
- Application Number
- CN202410615227.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2044-05-17
AI Technical Summary
In the prior art, the number of training data used to train the emotional triple extraction model is scarce, and due to the fine-grained nature, manual annotation data is expensive and the data is not targeted, making it difficult to select targeted training data.
The sample text data is expanded and synthesized through the text extension model, synthesized text data is constructed, and the text data is encoded through the feature perception model to obtain text coded feature data. Then, the sample text data and text encoding feature data are input into the initial emotional triple extraction model, and the enhanced text data is constructed according to the preset iteration strategy, the interaction between the model and the training data is optimized, and the quantity and quality of the training data are improved.
By increasing the quantity and quality of training data, more targeted training data are built, and the emotional triple extraction model is adapted to different frameworks, improving the accuracy and efficiency of model training, thereby achieving accurate extraction of emotional triple of text data.
Smart Images

Figure CN118569247B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of natural language processing technology and sentiment analysis technology, and in particular to a method, device, computer equipment and storage medium for extracting sentiment triples from text data. Background Art
[0002] Aspect Sentiment Triplet Extraction (ASTE) is a relatively complex subtask in aspect-based sentiment analysis (ABSA). It requires the model to not only identify the aspect words (aspect) and opinion words (opinion) involved in the sentence, but also to accurately determine which target aspect word the opinion word corresponds to and their corresponding sentiment polarity (sentiment), so as to combine these three elements to generate a complete sentiment triplet [aspect, opinion, sentiment].
[0003] However, the training data currently used to train the ASTE model has the following problems: the amount of training data is scarce, and due to the fine-grained nature of ASTE, it costs a lot of money to manually label the data; the training data is not targeted. The current ASTE adopts model frameworks such as Span-Based, Table-Filling, MRC-Based and Generation-Based. Faced with the diversity of ASTE problem modeling, it is difficult to select targeted training data to train the model. Summary of the invention
[0004] Based on this, the purpose of the present invention is to provide a method, device, computer equipment and storage medium for extracting emotion triples from text data, expand and synthesize sample text data through a text extension model to construct synthetic text data, encode the sample text data and sentences in the synthetic text data through a feature perception model to obtain text encoding feature data, input the sample text data and the text encoding feature data into an initial emotion triple extraction model, and construct enhanced text data with several iterations according to a preset iteration strategy to train the initial emotion triple extraction model, optimize the interaction between the model and the training data by designing an iteration strategy, continuously improve the quantity and quality of the training data, construct more targeted training data, and be able to adapt to emotion triple extraction models of different frameworks, improve the accuracy and efficiency of model training, thereby realizing accurate extraction of emotion triples from text data.
[0005] In a first aspect, an embodiment of the present application provides a method for extracting sentiment triples from text data, comprising the following steps:
[0006] Obtaining sample text data, wherein the sample text data includes a plurality of sample sentences;
[0007] According to the sample text data and a preset text expansion model, several types of extended text data of the sample text data are obtained, and the several types of extended text data are combined to obtain synthetic text data;
[0008] Inputting the sample text data and the synthetic text data into a preset feature perception model for encoding processing to obtain text encoding feature data;
[0009] Inputting the sample text data and the text encoding feature data into the initial sentiment triple extraction model, constructing enhanced text data of several iterations according to the sample text data, the text encoding feature data and a preset iteration strategy, training the initial sentiment triple extraction model according to the enhanced text data of several iterations and the corresponding iteration numbers, and obtaining a target sentiment triple extraction model;
[0010] The text data to be extracted is obtained, and the text data to be extracted is input into a target sentiment triple extraction model to obtain a sentiment triple extraction result of the text data to be extracted.
[0011] In a second aspect, an embodiment of the present application provides a device for extracting sentiment triples from text data, comprising:
[0012] A data acquisition module, used to acquire sample text data, wherein the sample text data includes a plurality of sample sentences;
[0013] A text expansion module, used for obtaining several types of extended text data of the sample text data according to the sample text data and a preset text expansion model, and combining the several types of extended text data to obtain synthetic text data, wherein the synthetic text data includes several extended sentences;
[0014] A text encoding module, used for inputting the sample text data and the synthetic text data into a preset feature perception model for encoding processing to obtain text encoding feature data, wherein the text encoding feature data includes encoding feature representations of a plurality of the sample sentences and the extended sentences;
[0015] A model training module, for inputting the sample text data and the text encoding feature data into the initial sentiment triple extraction model, constructing enhanced text data of several iterations according to the sample text data, the text encoding feature data and a preset iteration strategy, training the initial sentiment triple extraction model according to the enhanced text data of several iterations and the corresponding iteration numbers, and obtaining a target sentiment triple extraction model;
[0016] The sentiment triplet extraction module is used to obtain text data to be extracted, input the text data to be extracted into a target sentiment triplet extraction model, and obtain sentiment triplet extraction results of the text data to be extracted.
[0017] In a third aspect, an embodiment of the present application provides a computer device comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor; when the computer program is executed by the processor, the steps of the method for extracting sentiment triples from text data as described in the first aspect are implemented.
[0018] In a fourth aspect, an embodiment of the present application provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for extracting sentiment triples from text data as described in the first aspect.
[0019] In an embodiment of the present application, a method, apparatus, computer equipment and storage medium for extracting sentiment triples from text data are provided. Sample text data are expanded and synthesized through a text extension model to construct synthetic text data. The sample text data and sentences in the synthetic text data are encoded through a feature perception model to obtain text encoding feature data. The sample text data and the text encoding feature data are input into an initial sentiment triple extraction model. According to a preset iteration strategy, enhanced text data of several iterations are constructed to train the initial sentiment triple extraction model. By designing an iteration strategy, the interaction between the model and the training data is optimized, the quantity and quality of the training data are continuously improved, and more targeted training data are constructed. The sentiment triple extraction models that can adapt to different frameworks are able to improve the accuracy and efficiency of model training, thereby realizing accurate extraction of sentiment triples from text data.
[0020] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Figure 1 A schematic diagram of a flow chart of a method for extracting sentiment triples from text data provided in one embodiment of the present application;
[0022] Figure 2A schematic diagram of the process of S2 in the method for extracting sentiment triples from text data provided by one embodiment of the present application;
[0023] Figure 3 A schematic diagram of the process of S6 in the method for extracting sentiment triples from text data provided by another embodiment of the present application;
[0024] Figure 4 A schematic diagram of the process of S4 in the method for extracting sentiment triples from text data provided by another embodiment of the present application;
[0025] Figure 5 A schematic diagram of the process of S41 in a method for extracting sentiment triples from text data provided by one embodiment of the present application;
[0026] Figure 6 A schematic diagram of the flow of S42 in a method for extracting sentiment triples from text data provided by another embodiment of the present application;
[0027] Figure 7 A schematic diagram of the structure of a device for extracting sentiment triples from text data provided by one embodiment of the present application;
[0028] Figure 8 A schematic diagram of the structure of a computer device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0029] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0030] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0031] It should be understood that, although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" / "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determination".
[0032] See also Figure 1 , Figure 1 A flowchart of a method for extracting sentiment triples from text data provided by an embodiment of the present application, the method comprising the following steps:
[0033] S1: Obtain sample text data.
[0034] The subject of the method for extracting sentiment triples from text data of the present application is an extraction device for the method for extracting sentiment triples from text data (hereinafter referred to as extraction device). In an optional embodiment, the extraction device can be a computer device, a server, or a server cluster formed by a combination of multiple computer devices.
[0035] In this embodiment, the extraction device may obtain sample text data input by a user or from a preset database, wherein the sample text data includes a number of sample sentences, and the sample sentences include a number of aspect words and opinion words.
[0036] S2: According to the sample text data and a preset text expansion model, several types of extended text data of the sample text data are obtained, and the several types of extended text data are combined to obtain synthetic text data.
[0037] The text expansion model adopts a large language model (LLM) and can synthesize new data based on seed samples.
[0038] In this embodiment, the extraction device obtains several types of extended text data of the sample text data according to the sample text data and a preset text extension model, wherein the types of the extended text data include a breadth type and a depth type, the breadth type of extended text data is brand new text data generated by inspiring a large language model based on the sample text data, and the depth type of extended text data is more complex text data generated by inspiring a large language model to reshape and expand the sample text data.
[0039] The extraction device combines several types of extended text data to obtain synthetic text data, wherein the synthetic text data includes several extended sentences.
[0040] See also Figure 2 , Figure 2 The flowchart of S2 in the method for extracting sentiment triples from text data provided by one embodiment of the present application includes steps S21 to S23, which are specifically as follows:
[0041] S21: Obtaining annotation data of several types of extended text data output by the text extension model.
[0042] In this embodiment, the extraction device obtains the annotation data of several types of extended text data output by the text extension model, wherein the annotation data is used to indicate aspect words and opinion words with incorrect markings in the extended text data.
[0043] S22: according to the several types of extended text data and the corresponding annotation data, the extended sentences containing aspect words or viewpoint words with the corresponding annotation data in the several types of extended text data are deleted to obtain several types of first deleted text data.
[0044] In this embodiment, the extraction device deletes the extended sentences of aspect words or opinion words having corresponding annotation data in the several types of extended text data according to the several types of extended text data and corresponding annotation data, and obtains several types of first abridged text data.
[0045] S23: According to several types of the first abridged text data, traverse the sample text data, delete the extended sentences in the first abridged text data that contain the same aspect words as those in the sample sentences in the sample text data, obtain several types of the second abridged text data, combine the several types of the second abridged text data, and obtain synthetic text data.
[0046] In this embodiment, the extraction device traverses the sample text data according to several types of the first abridged text data, deletes the extended sentences in the first abridged text data that contain the same aspect words as in the sample sentences in the sample text data, obtains several types of the second abridged text data, combines the several types of the second abridged text data, obtains synthetic text data, achieves the expansion of training data and the improvement of quality, for training the sentiment triplet extraction model, and improves the accuracy of the sentiment triplet extraction model.
[0047] S3: Input the sample text data and the synthetic text data into a preset feature perception model for encoding processing to obtain text encoding feature data.
[0048] The feature perception model adopts the T5 (Text-to-Text Transfer Transformer) model, which can capture the syntactic structure information and emotional feature information of text data.
[0049] In this embodiment, the extraction device inputs the sample text data and the synthetic text data into a preset feature perception model for encoding processing to obtain text encoding feature data, wherein the text encoding feature data includes encoding feature representations of several of the sample sentences and extended sentences.
[0050] In an optional embodiment, step S6 is further included: training the feature perception model, see Figure 3 , Figure 3 The flowchart of S6 in the method for extracting sentiment triples from text data provided by another embodiment of the present application includes steps S61 to S63, which are specifically as follows:
[0051] S61: Input the training sentence set into the feature perception model to be trained for encoding processing to obtain encoding feature representations of several training sentences; perform feature extraction on the encoding feature representations of several training sentences to obtain emotional feature representations of several training sentences; perform random inactivation processing on the emotional feature representations of several training sentences to obtain randomly inactivated feature representations of several training sentences.
[0052] In this embodiment, the extraction device inputs the training sentence set of the current batch into the feature perception model to be trained for encoding processing to obtain the encoded feature representation of several training sentences in the training sentence set of the current batch.
[0053] The extraction device performs feature extraction on the encoded feature representations of several training sentences in the training sentence set of the current batch to obtain the emotional feature representations of several training sentences in the training sentence set of the current batch. Specifically, the extraction device performs pooling processing and full connection processing on the encoded feature representations of several training sentences in sequence to obtain the feature representation after the full connection processing as the emotional feature representation.
[0054] The extraction device performs random inactivation processing on the sentiment feature representations of several of the training sentences to obtain random inactivation feature representations of several of the training sentences, wherein the sentiment feature representations include sentiment polarity sentiment feature representations, aspect word sentiment feature representations, and opinion word sentiment feature representations, and the random inactivation feature representations include sentiment polarity random inactivation feature representations, aspect word random inactivation feature representations, and opinion word random inactivation feature representations.
[0055] S62: obtaining sentiment polarity label data of a plurality of the training sentences, and constructing extended training sentence sentiment feature representation sets and positive training sentence sentiment feature representation sets corresponding to a plurality of the training sentences respectively according to the sentiment polarity label data of the plurality of the training sentences and the random inactivation feature representations of the plurality of the training sentences;
[0056] In this embodiment, the extraction device obtains the sentiment polarity label data of a number of the training sentences, wherein the sentiment polarity label data is used to indicate the sentiment polarity of the sample sentences.
[0057] The extraction device takes several of the training sentences as target sentences respectively, and constructs extended training sentence emotion feature representation sets and positive training sentence emotion feature representation sets corresponding to several target sentences according to the emotion polarity label data and the random inactivation feature representations of the several training sentences respectively, wherein the extended training sentence emotion feature representation set includes the random inactivation feature representation of the target sentence, the emotion feature representation and the random inactivation feature representation of other training sentences except the target sentence, and the positive training sentence emotion feature representation set includes the emotion feature representation and the random inactivation feature representation of other training sentences in the extended training sentence emotion feature representation set that have the same emotion polarity as the target sentence.
[0058] S63: According to the emotion feature representation set of positive training sentences corresponding to several training sentences, the emotion feature representation set of extended training sentences and a preset contrastive learning loss function, several categories of contrastive learning loss values are obtained; according to the contrastive learning loss values of several categories, the feature perception model to be trained is trained to obtain a preset feature perception model.
[0059] In this embodiment, the extraction device uses the random inactivation feature representation and the emotion feature representation in the positive training sentence emotion feature representation set and the extended training sentence emotion feature representation set as the training emotion feature representation, and encourages the model to maximize the representation similarity between training sentences with the same emotion polarity and minimize the representation similarity between training sentences with different emotion polarities through contrastive learning according to the positive training sentence emotion feature representation set, the extended training sentence emotion feature representation set and the preset contrastive learning loss function corresponding to several target sentences, and obtains several categories of contrastive learning loss values, wherein the contrastive learning loss value includes the contrastive learning loss value of emotion polarity, the contrastive learning loss value of aspect words and the contrastive learning loss value of opinion words, and the contrastive learning loss function is:
[0060]
[0061] In the formula, For the i The first training sentence l The contrastive learning loss value for each class, , Sentiment Represents emotional polarity, Aspect Represents aspect words, Opinion Words representing opinions, For the i The positive training sentence sentiment feature representation set of training sentences, For the i The extended training sentence sentiment feature representation set of training sentences, , i ,as well as b are the indexes of the training sentences, , , For the i , , b The first training sentence l The training sentiment feature representation of categories is is the similarity calculation function, is the temperature coefficient.
[0062] The extraction device trains the feature perception model to be trained according to the contrastive learning loss values of several categories to obtain a preset feature perception model. In an optional embodiment, the extraction device also obtains a cross entropy loss value. The extraction device obtains a total loss value according to the cross entropy loss value, the contrastive learning loss values of several categories and a preset total loss value calculation algorithm. According to the total loss value, the feature perception model to be trained is trained to obtain a preset feature perception model, wherein the total loss value calculation algorithm is:
[0063]
[0064] In the formula, is the total loss value, is the cross entropy loss value, is the contrastive learning loss value of sentiment polarity, is the contrastive learning loss value of aspect words, is the contrastive learning loss value of opinion words, is a hyperparameter.
[0065] By adopting contrastive learning method and cross entropy loss value calculation method, cross entropy loss value and contrastive learning loss values of several categories are obtained to train the feature perception model to be trained, so that the feature perception model can better understand the syntactic structure information and three key emotional feature information in the sentence at the feature level, so that the feature perception model can output more accurate encoding feature data for subsequent construction of enhanced text data, thereby improving the accuracy of the emotional triple extraction model.
[0066] S4: Input the sample text data and text encoding feature data into the initial emotion triple extraction model, construct enhanced text data of several iterations according to the sample text data, text encoding feature data and a preset iteration strategy, train the initial emotion triple extraction model according to the enhanced text data of several iterations and the corresponding iteration numbers, and obtain the target emotion triple extraction model.
[0067] In this embodiment, the extraction device inputs the sample text data and text encoding feature data into the initial sentiment triple extraction model, and constructs enhanced text data of several iterations according to the sample text data, text encoding feature data and a preset iteration strategy.
[0068] The extraction device trains the initial emotion triple extraction model according to the enhanced text data of several iterations and the corresponding iteration numbers to obtain the target emotion triple extraction model. Specifically, the extraction device obtains the real emotion triple probability data of several sample sentences in the enhanced text data of the current iteration number and the predicted emotion triple probability data of several sample sentences in the enhanced text data output by the initial emotion triple extraction model of the current iteration number, wherein the emotion triple probability data includes emotion polarity probability data, aspect word probability data and opinion word probability data.
[0069] The extraction device trains the initial emotion triplet extraction model of the current iteration using a supervised learning method based on the real emotion triplet probability data of several sample sentences in the enhanced text data of the current iteration and the predicted emotion triplet probability data, and obtains the emotion triplet extraction model trained for the current iteration as the initial emotion triplet extraction model for the next iteration.
[0070] See also Figure 4 , Figure 4 The flowchart of S4 in the method for extracting sentiment triples from text data provided by one embodiment of the present application includes steps S41 to S42, which are specifically as follows:
[0071] S41: Using the sample text data as the emotion triplet processing data of the initial emotion triplet extraction model of the first iteration to perform emotion triplet extraction, and obtaining predicted emotion triplet extraction results of several sample sentences of the current iteration number; and determining several target sample sentences from the several sample sentences according to the predicted emotion triplet extraction results.
[0072] In this embodiment, the extraction device uses the sample text data as the emotion triple processing data of the initial emotion triple extraction model of the first iteration to perform emotion triple extraction, and obtains the predicted emotion triple extraction results of several of the sample sentences of the current iteration number, wherein the emotion triple extraction results include emotion polarity extraction results, aspect word extraction results and opinion word extraction results.
[0073] The extraction device determines a plurality of target sample sentences from the plurality of sample sentences according to the predicted emotion triple extraction result.
[0074] See also Figure 5 , Figure 5 The flowchart of S41 in the method for extracting sentiment triples from text data provided by one embodiment of the present application includes steps S411 to S412, which are specifically as follows:
[0075] S411: obtaining the real emotion triple extraction results of several sample sentences, and comparing the real emotion triple extraction results and the predicted emotion triple extraction results of the same sample sentence to obtain the emotion triple comparison results of several sample sentences.
[0076] In this embodiment, the extraction device obtains the real emotion triple extraction results of several of the sample sentences, and compares the real emotion triple extraction results and the predicted emotion triple extraction results of the same sample sentence to obtain the emotion triple comparison results of several of the sample sentences, wherein the emotion triple comparison results include emotion polarity comparison results, aspect word comparison results and opinion word comparison results, and the comparison results include identical results and different results.
[0077] S412: If the sample sentences have sentiment triple comparison results with different results, the sample sentences are used as target sample sentences, and a plurality of target sample sentences are determined from the plurality of sample sentences.
[0078] In this embodiment, if the sample sentences have sentiment triple comparison results with different results, the extraction device uses the sample sentences as target sample sentences and determines a plurality of target sample sentences from the plurality of sample sentences.
[0079] S42: Based on the encoding feature representations of several target sample sentences and the encoding feature representations of several extended sentences, a clustering analysis method is used to extract several target extended sentences from the synthetic text data, and add them to the sample text data as sample sentences to construct enhanced text data of the current iteration number.
[0080] In this embodiment, the extraction device uses a clustering analysis method to extract several target extended sentences from the synthetic text data based on the encoding feature representations of several target sample sentences in the text encoding feature data and the encoding feature representations of several extended sentences in the synthetic text data, and adds them to the sample text data as sample sentences to construct enhanced text data for the current iteration number.
[0081] See also Figure 6 , Figure 6 The flowchart of S42 in the method for extracting sentiment triples from text data provided by one embodiment of the present application includes steps S421 to S422, which are specifically as follows:
[0082] S421: According to the encoding feature representations of the target sample sentences, a K-means clustering algorithm is used to obtain clustering feature data.
[0083] In this embodiment, the extraction device uses a K-means clustering algorithm to obtain cluster feature data based on the encoding feature representations of several target sample sentences, wherein the cluster feature data includes cluster feature representations of several preset cluster center points.
[0084] S422: Based on the cluster feature data and the encoded feature representations of the several extended sentences, a Euclidean distance algorithm is used to obtain the Euclidean distance between the encoded feature representations of the several extended sentences and the cluster feature representations of the several cluster center points; based on the Euclidean distance and a preset number of sentences, a number of extended sentences corresponding to the several cluster center points are obtained; the several extended sentences corresponding to the several cluster center points are taken as target extended sentences, and the several target extended sentences are extracted from the synthetic text data.
[0085] In this embodiment, the extraction device uses the Euclidean distance algorithm based on the cluster feature data and the coding feature representations of the several extended sentences to obtain the Euclidean distance between the coding feature representations of the several extended sentences and the cluster feature representations of the several cluster centers.
[0086] The extraction device obtains several extended sentences whose Euclidean distances are closest to the cluster feature representations of several cluster center points according to the Euclidean distance and a preset number of sentences, and obtains several extended sentences corresponding to several cluster center points. In an optional embodiment, the extraction device masks the indexes of the selected extended sentences to avoid repeated selection of the same extended sentences, thereby improving the quality of construction of enhanced text data.
[0087] S5: Obtain text data to be extracted, input the text data to be extracted into a target sentiment triplet extraction model, and obtain sentiment triplet extraction results of the text data to be extracted.
[0088] In this embodiment, the extraction device obtains text data to be extracted, inputs the text data to be extracted into a target emotion triple extraction model, obtains emotion triple extraction results of the text data to be extracted, expands and synthesizes the sample text data through a text extension model, constructs synthetic text data, encodes the sample text data and sentences in the synthetic text data through a feature perception model, obtains text encoding feature data, inputs the sample text data and the text encoding feature data into an initial emotion triple extraction model, and constructs enhanced text data of several iterations according to a preset iteration strategy to train the initial emotion triple extraction model. By designing an iteration strategy, the interaction between the model and the training data is optimized, the quantity and quality of the training data are continuously improved, and more targeted training data are constructed, which can adapt to emotion triple extraction models of different frameworks, improve the accuracy and efficiency of model training, and thus realize accurate extraction of emotion triples of text data.
[0089] Please refer to Figure 7 , Figure 7A schematic diagram of the structure of a device for extracting emotion triples from text data provided by an embodiment of the present application. The device can implement all or part of the device for extracting emotion triples from text data through software, hardware, or a combination of both. The device 7 includes:
[0090] A data acquisition module 71, used to obtain sample text data, wherein the sample text data includes a number of sample sentences;
[0091] A text expansion module 72, configured to obtain, according to the sample text data and a preset text expansion model, several types of extended text data of the sample text data, and combine the several types of extended text data to obtain synthetic text data, wherein the synthetic text data includes several extended sentences;
[0092] A text encoding module 73 is used to input the sample text data and the synthetic text data into a preset feature perception model for encoding processing to obtain text encoding feature data, wherein the text encoding feature data includes encoding feature representations of a plurality of the sample sentences and the extended sentences;
[0093] The model training module 74 is used to input the sample text data and the text encoding feature data into the initial emotion triple extraction model, construct enhanced text data of several iterations according to the sample text data, the text encoding feature data and a preset iteration strategy, train the initial emotion triple extraction model according to the enhanced text data of several iterations and the corresponding iteration numbers, and obtain the target emotion triple extraction model;
[0094] The sentiment triplet extraction module 75 is used to obtain text data to be extracted, input the text data to be extracted into a target sentiment triplet extraction model, and obtain sentiment triplet extraction results of the text data to be extracted.
[0095] In this embodiment, sample text data is obtained through a data acquisition module, wherein the sample text data includes a plurality of sample sentences; a text expansion module is used to obtain a plurality of types of extended text data of the sample text data according to the sample text data and a preset text expansion model, and the plurality of types of extended text data are combined to obtain synthetic text data, wherein the synthetic text data includes a plurality of extended sentences; a text encoding module is used to input the sample text data and the synthetic text data into a preset feature perception model for encoding processing, and obtain text encoding feature data, wherein the text encoding feature data includes a plurality of the sample sentences with and the coding feature representation of the extended sentence; through the model training module, the sample text data and the text coding feature data are input into the initial sentiment triple extraction model, and according to the sample text data, the text coding feature data and the preset iteration strategy, several times of enhanced text data of iteration are constructed, and according to the several times of enhanced text data of iteration and the corresponding number of iterations, the initial sentiment triple extraction model is trained to obtain the target sentiment triple extraction model; through the sentiment triple extraction module, the text data to be extracted is obtained, and the text data to be extracted is input into the target sentiment triple extraction model to obtain the sentiment triple extraction result of the text data to be extracted. Through the text extension model, the sample text data is expanded and synthesized to construct synthetic text data. Through the feature perception model, the sample text data and the sentences in the synthetic text data are encoded to obtain text encoding feature data. The sample text data and the text encoding feature data are input into the initial sentiment triple extraction model. According to the preset iteration strategy, enhanced text data with several iterations is constructed to train the initial sentiment triple extraction model. By designing an iteration strategy, the interaction between the model and the training data is optimized, the quantity and quality of the training data are continuously improved, and more targeted training data is constructed. It can adapt to the sentiment triple extraction models of different frameworks, improve the accuracy and efficiency of model training, and thus realize the accurate extraction of sentiment triples of text data.
[0096] Please refer to Figure 8 , Figure 8 The computer device 8 is a schematic diagram of a structure of a computer device provided in an embodiment of the present application. The computer device 8 includes: a processor 81, a memory 82, and a computer program 83 stored in the memory 82 and executable on the processor 81; the computer device may store multiple instructions, which are suitable for being loaded and executed by the processor 81. Figures 1 to 6 For the specific implementation process, please refer to Figures 1 to 6 The specific description is not repeated here.
[0097] Among them, the processor 81 may include one or more processing cores. The processor 81 uses various interfaces and lines to connect various parts in the server, and executes various functions and processes data of the emotion triple extraction device 7 of text data by running or executing instructions, programs, code sets or instruction sets stored in the memory 82, and calling the data in the memory 82. Optionally, the processor 81 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programble Logic Array, PLA). The processor 81 can integrate one or a combination of a central processing unit 81 (Central Processing Unit, CPU), an image processor 81 (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the touch display screen; the modem is used to process wireless communication. It can be understood that the above-mentioned modem may not be integrated into the processor 81, and can be implemented separately through a chip.
[0098] The memory 82 may include a random access memory 82 (RAM) or a read-only memory 82 (Read-Only Memory). Optionally, the memory 82 includes a non-transitory computer-readable storage medium. The memory 82 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 82 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch instructions, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 82 may also be optionally at least one storage device located away from the aforementioned processor 81.
[0099] The present application also provides a storage medium that can store multiple instructions, which are suitable for the processor to load and execute the above-mentioned Figures 1 to 6 For the specific implementation process, please refer to Figures 1 to 6 The specific description is not repeated here.
[0100] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0101] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0102] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraint algorithm of the technical solution. Professional and technical personnel can 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 the present invention.
[0103] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple 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, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0104] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0105] In addition, each functional unit in each embodiment of the present invention 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.
[0106] If the integrated module / 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 present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc.
[0107] The present invention is not limited to the above-mentioned embodiments. If various changes or modifications to the present invention do not depart from the spirit and scope of the present invention, and if these changes and modifications fall within the scope of the claims and equivalent technologies of the present invention, the present invention is also intended to include these changes and modifications.
Claims
1. A method for extracting sentiment triples from text data, characterized in that: The following steps are involved: Obtaining sample text data, wherein the sample text data includes a plurality of sample sentences; According to the sample text data and a preset text expansion model, several types of extended text data of the sample text data are obtained, and the several types of extended text data are combined to obtain synthetic text data; Inputting the sample text data and the synthetic text data into a preset feature perception model for encoding processing to obtain text encoding feature data; The sample text data and the text encoding feature data are input into the initial sentiment triple extraction model; based on the sample text data, the text encoding feature data and the preset iteration strategy, the sample text data is used as the sentiment triple processing data of the initial sentiment triple extraction model of the first iteration to perform sentiment triple extraction, and the predicted sentiment triple extraction results of the sample sentences of the current iteration number are obtained; based on the predicted sentiment triple extraction results, a plurality of target sample sentences are determined from the plurality of sample sentences; According to the encoding feature representations of several target sample sentences and the encoding feature representations of several extended sentences, a cluster analysis method is used to extract several target extended sentences from the synthetic text data, and the sentences are added to the sample text data as sample sentences to construct enhanced text data of the current iteration number and enhanced text data of several iteration numbers; according to the enhanced text data of several iteration numbers and the corresponding iteration numbers, the initial sentiment triple extraction model is trained to obtain the target sentiment triple extraction model; The text data to be extracted is obtained, and the text data to be extracted is input into a target sentiment triple extraction model to obtain a sentiment triple extraction result of the text data to be extracted.
2. The method for extracting sentiment triples from text data according to claim 1, characterized in that: The method of obtaining several types of extended text data of the sample text data according to the sample text data and a preset text extension model, and combining the several types of extended text data to obtain synthetic text data comprises the following steps: Obtaining annotation data of several types of extended text data output by the text extension model, wherein the annotation data is used to indicate aspect words and opinion words with incorrect markings in the extended text data; According to the several types of the extended text data and the corresponding annotation data, the extended sentences having the aspect words or viewpoint words with the corresponding annotation data in the several types of the extended text data are deleted to obtain several types of first deleted text data; According to several types of the first abridged text data, the sample text data is traversed, and the extended sentences in the first abridged text data that contain the same aspect words as those in the sample sentences in the sample text data are deleted to obtain several types of second abridged text data, and the several types of the second abridged text data are combined to obtain synthetic text data.
3. The method for extracting sentiment triples from text data according to claim 1, characterized in that: The step of inputting the sample text data and the synthesized text data into a preset feature perception model for encoding and obtaining text encoding feature data further includes the following steps: Inputting the training sentence set into the feature perception model to be trained for encoding processing to obtain encoding feature representations of several training sentences; performing feature extraction on the encoding feature representations of several training sentences to obtain emotional feature representations of several training sentences; performing random inactivation processing on the emotional feature representations of several training sentences to obtain random inactivation feature representations of several training sentences; Obtaining sentiment polarity label data of a plurality of the training sentences, and constructing extended training sentence sentiment feature representation sets and positive training sentence sentiment feature representation sets corresponding to a plurality of the training sentences respectively according to the sentiment polarity label data of the plurality of the training sentences and the random inactivation feature representations of the plurality of the training sentences; According to the positive example training sentence sentiment feature representation set corresponding to several training sentences, the extended training sentence sentiment feature representation set and the preset contrastive learning loss function, several categories of contrastive learning loss values are obtained; according to the contrastive learning loss values of several categories, the feature perception model to be trained is trained to obtain the preset feature perception model.
4. The method for extracting sentiment triples from text data according to claim 1, characterized in that: The sample sentence includes a number of aspect words and opinion words; the sentiment triple extraction result includes a sentiment polarity extraction result, an aspect word extraction result and an opinion word extraction result; The step of determining a plurality of target sample sentences from a plurality of sample sentences according to the predicted emotion triple extraction result comprises the steps of: Obtaining the true emotion triple extraction results of several sample sentences, and comparing the true emotion triple extraction results and the predicted emotion triple extraction results of the same sample sentence to obtain the emotion triple comparison results of several sample sentences; If the sample sentences have sentiment triple comparison results with different results, the sample sentences are used as target sample sentences, and a plurality of target sample sentences are determined from the plurality of sample sentences.
5. The method for extracting sentiment triples from text data according to claim 1, characterized in that: The method of extracting a plurality of target extended sentences from the synthetic text data using a cluster analysis method based on the encoding feature representations of the plurality of target sample sentences and the encoding feature representations of the plurality of extended sentences comprises the following steps: According to the encoding feature representations of the target sample sentences, a K-means clustering algorithm is used to obtain cluster feature data, wherein the cluster feature data includes cluster feature representations of a plurality of preset cluster center points; According to the cluster feature data and the coding feature representations of the several extended sentences, a Euclidean distance algorithm is used to obtain the Euclidean distance between the coding feature representations of the several extended sentences and the cluster feature representations of the several cluster center points; according to the Euclidean distance and a preset number of sentences, several extended sentences corresponding to the several cluster center points are obtained; the several extended sentences corresponding to the several cluster center points are taken as target extended sentences, and several target extended sentences are extracted from the synthetic text data.
6. A device for extracting sentiment triples from text data, characterized in that: include: A data acquisition module, used to acquire sample text data, wherein the sample text data includes a plurality of sample sentences; A text expansion module, used for obtaining several types of extended text data of the sample text data according to the sample text data and a preset text expansion model, and combining the several types of extended text data to obtain synthetic text data; A text encoding module, used for inputting the sample text data and the synthetic text data into a preset feature perception model for encoding processing to obtain text encoding feature data; A model training module is used to input the sample text data and text encoding feature data into the initial emotion triple extraction model, and according to the sample text data, the text encoding feature data and the preset iteration strategy, use the sample text data as the emotion triple processing data of the initial emotion triple extraction model of the first iteration to perform emotion triple extraction, and obtain the predicted emotion triple extraction results of several sample sentences of the current iteration number; according to the predicted emotion triple extraction results, determine several target sample sentences from several sample sentences; According to the encoding feature representations of several target sample sentences and the encoding feature representations of several extended sentences, a cluster analysis method is used to extract several target extended sentences from the synthetic text data, and the sentences are added to the sample text data as sample sentences to construct enhanced text data of the current iteration number and enhanced text data of several iteration numbers; according to the enhanced text data of several iteration numbers and the corresponding iteration numbers, the initial sentiment triple extraction model is trained to obtain the target sentiment triple extraction model; The sentiment triplet extraction module is used to obtain text data to be extracted, input the text data to be extracted into a target sentiment triplet extraction model, and obtain sentiment triplet extraction results of the text data to be extracted.
7. A computer device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for extracting sentiment triples from text data as described in any one of claims 1 to 5 are implemented.
8. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method for extracting sentiment triples from text data as described in any one of claims 1 to 5 are implemented.