Aspect-level sentiment triple extraction method for cross-domain migration
By generating target domain data and pseudo-labels, and combining prompting learning and the text generation model BART, a cross-domain triple extraction model is trained using syntactic and semantic information. This solves the problems of data scarcity and high annotation costs in cross-domain sentiment analysis and achieves efficient aspect-level sentiment triple extraction.
Patent Information
- Application Number
- CN202410394962.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-02
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2044-04-02
AI Technical Summary
Existing cross-domain sentiment analysis methods suffer from problems such as data scarcity, high data annotation costs, and insufficient utilization of syntactic and semantic information in fine-grained aspect-level sentiment triple extraction tasks, resulting in poor extraction performance in emerging fields.
By generating target domain data and pseudo-labels, and utilizing the cue learning and text generation model BART, combined with syntactic and semantic information, a semi-supervised learning model for cross-domain triple extraction is trained to improve the extraction performance of target domain sentiment triples.
It achieves efficient prediction of aspect-level sentiment triples in target domains lacking labeled data, improves the effect of cross-domain sentiment triple extraction, solves the problems of data scarcity and high labeling costs, and makes full use of syntactic and semantic information.
Smart Images

Figure CN118296135B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of artificial intelligence and sentiment analysis technology, and relates to an aspect-level sentiment triple extraction method for cross-domain transfer. Background Technology
[0002] With the development of information technology, more and more users are posting comments and expressing opinions on various internet platforms. This textual data contains users' viewpoints and emotions. Sentiment analysis aims to extract and utilize sentiment information from this massive amount of data, which has significant application value in areas such as product recommendation, sales decision-making, and public opinion monitoring. Aspect-level sentiment triple extraction is a fine-grained sentiment analysis task. Its purpose is to identify (aspect term, opinion term, sentiment) triples to obtain more comprehensive analysis results. Existing methods usually train directly on neural network models, but this often relies on a large amount of labeled data. For aspect-level sentiment triple extraction tasks, the labeled data needs to accurately label aspect terms, opinion terms, and the sentiment expressed by the aspect terms. This requires high data quality and is difficult to label. For domains lacking labeled data, the model struggles to achieve good results. As application scenarios become more complex and diversified, people often need to analyze emerging domains. Emerging means that labeled data in that domain is insufficient. Therefore, it is particularly important to utilize existing domain labeled data to achieve cross-domain sentiment analysis tasks.
[0003] Existing cross-domain sentiment analysis research mainly focuses on coarse-grained sentiment analysis problems. Research on fine-grained cross-domain sentiment analysis tasks is complex and difficult, and suffers from the following problems: 1) Current cross-domain research primarily targets joint extraction tasks of binary terms, such as joint cross-domain extraction of aspect terms and opinion terms, and joint cross-domain extraction of aspect terms and sentiment. 2) Most cross-domain studies rely on learning shared representations or weighting labeled data from the source domain, lacking full utilization of unlabeled data from the target domain and failing to deeply explore the commonalities between domains. 3) Insufficient utilization of the syntactic and semantic information of the data results in a lack of interaction information between aspect terms, opinion terms, and sentiment, making it difficult for models to achieve better results. Summary of the Invention
[0004] The purpose of this invention is to provide an aspect-level sentiment triple extraction method for cross-domain migration, which solves the problems of data scarcity, high data annotation costs, and insufficient utilization of syntactic and semantic information in the prior art, so as to improve the extraction effect of cross-domain sentiment triples.
[0005] The technical solution adopted in this invention is an aspect-level sentiment triple extraction method for cross-domain transfer, which is implemented according to the following steps:
[0006] Step 1: Generation of target domain data and pseudo-tags;
[0007] Step 2, train the cross-domain triple extraction model;
[0008] Step 3: Extraction of target domain triples.
[0009] The invention is further characterized by:
[0010] In step 1, the generation of target domain data and pseudo-labels is based on source domain labeled data and target domain unlabeled data. It utilizes cue learning and text generation models to generate target domain data and pseudo-labels, specifically implemented as follows:
[0011] Step 1.1, label the source domain data D S And unlabeled data D in the target domain U Extracting domain-specific terms involves the following steps:
[0012] Step 1.1.1, for the source domain labeled data D S First, domain-specific terms are extracted using tags, that is, aspect terms and opinion terms in the tagging results are used as domain-specific terms;
[0013] Step 1.1.2, for the source domain labeled data D S And unlabeled data D in the target domain U At the same time, by using word frequency, words that appear frequently in this domain but have low frequency in other domains are extracted as domain-specific words.
[0014] Step 1.2: Obtain domain-independent statements through the masking mechanism, using " <mask>"The character masking statement contains domain-specific words, and multiple masking probabilities are applied to the domain-specific words from small to large to obtain multiple sets of domain-independent statements;
[0015] Step 1.3, train the text generation model BART by combining prompts: By constructing prompts through template learning, and combining domain-specific words to form diverse domain-specific prompts, the prompts are inserted as prefixes into the domain-independent statements obtained in Step 1.2, and used as input to train the text generation model BART;
[0016] Step 1.4: Based on the domain-independent sentences with all domain-specific words masked, the trained text generation model BART generates the target domain data and pseudo-labels.
[0017] The training of the BART model in step 1.3 is as follows:
[0018] Step 1.3.1: Using manually constructed prompt templates combined with domain-specific terms, domain-specific prompts are formed and inserted as prefixes into domain-independent statements as input to the model;
[0019] Step 1.3.2: Based on a sample set of domain-independent sentences from easy to difficult, train the text generation model BART in a progressive training manner. First train on the simple domain-independent sample set, then transition to the difficult domain-independent sample set to fully learn the reconstruction of text and the generation of tags.
[0020] Step 1.3.3: For the labeled data in the source domain, the model's learning objective is to reconstruct the original text and the original labels. A loss function is constructed for training. By text loss function Label loss function constitute;
[0021]
[0022] Step 1.3.4: For unlabeled data in the target domain, the model's learning objective is solely to reconstruct the original text, and its loss function... Text loss function only constitute:
[0023]
[0024] The text and label loss functions in steps 1.3.3 and 1.3.4 are as follows:
[0025] In text generation models, the model needs to predict both text and labels simultaneously. Therefore, for each sample, the negative log-likelihood loss function is used to calculate the text loss separately. Label loss
[0026]
[0027]
[0028] In the formula, This represents the predicted word and predicted label at step t. H represents the predicted text and labels up to step t. e This is the encoding vector for the BART model;
[0029] Step 1.4 is implemented in the following steps:
[0030] Step 1.4.1: Use domain-independent statements with domain-specific words fully masked to generate target domain data and pseudo-labels. Due to the characteristic of the generation model that generates text and labels sequentially from left to right, i.e. the next word is generated based on the previous word, it is impossible to directly generate sentiment triple pseudo-labels. Therefore, (aspect words, opinion words) bigrams and (aspect words, sentiment) bigrams are used as pseudo-labels.
[0031] Step 1.4.2, using the training from the two tuple generation tasks in Step 1.4.1, generates more target domain data and their pseudo-labels while simultaneously generating pseudo-labels for the original unlabeled data in the target domain, achieving data augmentation. Then, through deduplication and unlabeled data filtering, the data is merged into the final target domain data and pseudo-label set D. G ;
[0032] Step 2, training the cross-domain triplet extraction model, is implemented as follows:
[0033] Step 2.1: Use the BERT pre-trained model to convert the text X into a vector representation with rich linguistic and contextual information to obtain the encoded vector representation H;
[0034] Step 2.2 involves introducing syntactic information, including a syntactic dependency tree and a phrase composition tree, through a syntactic encoder to enhance the fusion of information from aspect words and viewpoint words, thereby obtaining syntactic vector representations.
[0035] Step 2.3 introduces semantic information through a semantic encoder, derived from the self-attention score matrix of the BERT pre-trained model, to strengthen the semantic association between aspect words and opinion words, thereby obtaining semantic vector representations.
[0036] Step 2.4: For the three types of vector representations mentioned above, grid search annotation is used for each word pair (w i w j Predict the relationship between () and obtain sentiment triples through decoding;
[0037] Step 2.5: Generate datasets from the target domain and labeled datasets from the source domain. Based on the sentiment triple extraction model in Step 2.4, adopt the self-training method in semi-supervised learning to improve the model's performance in extracting target domain triples.
[0038] Step 2.2 is implemented as follows:
[0039] Step 2.2.1: Use a multilayer perceptron to transform H, the syntactic encoder, into an initial syntactic representation H. synn ;
[0040] Step 2.2.2: Use the parsing tool Stanza to parse and obtain the syntactic dependency tree and phrase composition tree of the text sentences, and convert them into an adjacency matrix M. a and M c Then, each layer of the two is merged using matrix-positional multiplication to form a syntactic adjacency matrix M. syn ;
[0041] Step 2.2.3: Encode syntactic information using a multi-head self-attention layer, and convert the syntactic adjacency matrix M... syn The multi-head self-attention layer, fused into the syntactic encoder, participates in the calculation of the self-attention score matrix, yielding the representation H. syn-selfatt Furthermore, residual normalization is used to smooth the representation information and obtain syntactic information.
[0042] Step 2.2.4: Process syntactic information through a multi-head cross-attention layer. and semantic information The interaction and fusion are used to obtain the representation. After passing through the residual normalization layer again, the final syntactic representation is obtained.
[0043] Step 2.3 is implemented in the following steps:
[0044] Step 2.3.1: Use a multilayer perceptron to transform H, the semantic encoder, into the initial semantic representation H. sem ;
[0045] Step 2.3.2, the self-attention score matrix M of the BERT pre-trained model bert Carrying rich semantic information, it is divided into layers and subjected to max pooling and average pooling strategies to obtain the semantic matrix M. sem ;
[0046] Step 2.3.3, the semantic encoding process is consistent with steps 2.2.3 and 2.2.4 of the syntactic encoding. First, the semantic matrix M is encoded through a multi-head self-attention layer. sem The data is then integrated, and syntactic and semantic information is interacted and fused through a multi-head cross-attention layer to obtain the final semantic representation.
[0047] Step 2.4 is implemented in the following steps:
[0048] Step 2.4.1, to obtain the representation of each word, the text representation H and the syntactic representation are... and semantic representation The images are spliced and merged to obtain the final representation.
[0049] Step 2.4.2, to determine word pairs (w i w j The relationship between ) and its representation and To perform fusion interaction, while considering the correlation information between the current word pair and other word pairs, the final relation probability is obtained using a fully connected layer and a softmax activation function.
[0050] Step 2.4.3: Perform triple decoding, first determining the word pair (w i w i To determine whether a term belongs to A or O, we identify aspect terms and opinion terms. If a match is found, we continue to assess the relationship probability. Is it a sentiment tag? If so, then consider aspect words and opinion words (w i w j If they belong to the same triple, they must be in the same triple; otherwise, they do not match. For paired aspect viewpoint pairs (w i w j ), through relational probability Determine their emotional relationships and obtain the final aspect-level emotional triad;
[0051] Step 2.5 is implemented in the following steps:
[0052] Step 2.5.1, label the source domain dataset D S As a training set, a loss function is constructed for model training, enabling the model to learn information related to the triplet extraction task.
[0053] Step 2.5.2, based on the unlabeled dataset D of the target domain U and generate dataset D G On the trained model, derive D G and D U The triplet results;
[0054] Step 2.5.3: Compare the triplet results from Step 2.5.2 with the pseudo-labels generated by the text generation model. If they match, the sample is used as high-quality screening data and added to the training set to continue training the model until no new screening data is added.
[0055] The loss functions in steps 2.5.1 and 2.5.3 are as follows:
[0056] For the triplet extraction task, the cross-entropy loss function is used to calculate the training loss between the true label or high-quality pseudo-label and the predicted label:
[0057]
[0058] In the formula, For the indicator function, y ij Indicates word pairs (w i w j ) genuine labels or high-quality pseudo-labels, Let C be the set of predicted labels;
[0059] Step 3 specifically involves processing the target domain test dataset D. T The text to be extracted is input into the trained cross-domain sentiment triplet extraction model, which derives the final triplet result for the target domain, namely (aspect words, opinion words, sentiment) triplet.
[0060] The beneficial effects of this invention are:
[0061] This invention presents an aspect-level sentiment triple extraction method for cross-domain transfer, which transfers aspect-level sentiment triple knowledge from the source domain to the target domain with unlabeled data, and integrates the syntactic and semantic information of the data to achieve efficient prediction of sentiment triples in the target domain. It primarily addresses the problems of data scarcity, high data labeling costs, and insufficient utilization of syntactic and semantic information in existing technologies. First, it utilizes cue learning and text generation models to generate target domain data and pseudo-labels. Then, it integrates the syntactic and semantic information of the data and uses semi-supervised learning to train a cross-domain triple extraction model, thereby achieving aspect-level sentiment triple extraction from the target domain and improving the extraction effect of cross-domain sentiment triples. Attached Figure Description
[0062] Figure 1 This is a diagram illustrating the overall model framework of the aspect-level sentiment triple extraction method for cross-domain migration according to the present invention.
[0063] Figure 2 This is a BART structure diagram of the text and tag generation model of the aspect-level sentiment triple extraction method for cross-domain transfer according to the present invention.
[0064] Figure 3 This is a triplet extraction model framework diagram of the aspect-level sentiment triplet extraction method for cross-domain migration according to the present invention.
[0065] Figure 4 This is a semi-supervised self-training flowchart of the aspect-level sentiment triple extraction method for cross-domain transfer according to the present invention. Detailed Implementation
[0066] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.
[0067] This invention provides an aspect-level sentiment triple extraction method for cross-domain transfer, as shown in the following embodiments:
[0068] Example 1: The design concept of this invention is as follows: The aspect-level sentiment triplet knowledge from the source domain is transferred to the target domain of unlabeled data, and the syntactic and semantic information of the data is integrated to achieve efficient prediction of sentiment triplets in the target domain. The model mainly consists of two stages. First, in the target domain data and pseudo-label generation stage, based on the labeled data from the source domain and the unlabeled data from the target domain, cue learning and text generation models are used to generate target domain data and pseudo-labels. Second, in the target domain triplet extraction stage, based on all data including the generated data, an aspect-level sentiment triplet extraction model integrating syntactic and semantic information is adopted. This model is trained using a self-training method in semi-supervised learning to improve the model's triplet extraction performance in the target domain.
[0069] The specific process and effects are shown in the following examples:
[0070] Example 2, as Figure 1 As shown, the aspect-level sentiment triple extraction method for cross-domain transfer is implemented according to the following steps:
[0071] Step 1, Generation of Target Domain Data and Pseudo-labels: Based on the source domain labeled data and the target domain unlabeled data, target domain data and pseudo-labels are generated using cue learning and text generation models; the model framework is as follows: Figure 2 As shown, the specific steps include:
[0072] Step 1.1, label the source domain data D S And unlabeled data D in the target domain U Extracting domain-specific terms, which are terms that are unique to and common in this domain but uncommon in other domains; the specific process is as follows:
[0073] Step 1.1.1, for the source domain labeled data D S First, domain-specific terms are extracted using tags, that is, aspect terms and opinion terms in the tagging results are used as domain-specific terms;
[0074] Step 1.1.2, for the source domain labeled data D S And unlabeled data D in the target domain U Simultaneously, domain-specific words are extracted using a term frequency method, that is, based on the relative frequency of a word within a domain; following the n-gram concept, the text sentence is segmented into word segments of different lengths, and then the value of each word segment w in the domain D is calculated. i The relative frequency of a domain is calculated by comparing the frequency of a word that appears in a domain with the frequency of words that appear in other domains.
[0075]
[0076] In the formula, freq(w, D i ) indicates that the word segment w is in the domain D i The relative frequency of the domain, count(w, D) i ) indicates that the word segment w is in the domain D i The term frequency is denoted by θ, which represents the smoothness number. The higher the relative frequency in a domain, the more frequently the term w appears in that domain compared to other domains.
[0077] Step 1.2: Obtain domain-independent statements through the masking mechanism, using " <mask>"The character masking process identifies domain-specific words appearing in the statements, and applies multiple masking probabilities, from smallest to largest, to obtain multiple sets of domain-independent statements; the specific process is as follows:"
[0078] Step 1.2.1, use " <mask>The character replaces the domain-specific words that appear in the statement; when searching for domain-specific words in the statement, a greedy forward maximum matching algorithm is used to select the longest domain-specific word;
[0079] Step 1.2.2: Apply multiple masking probabilities, from smallest to largest, to domain-specific terms to obtain multiple sets of domain-independent statements. The masking probability of a domain-specific term represents whether each domain-specific term is masked with a certain probability, thereby controlling the difficulty of domain-independent statements. The masking probability uses mask = {0.0, 0.3, 0.5, 0.7, 1.0}, where mask = 0.0 means that no domain-specific terms are masked, and mask = 1.0 means that all domain-specific terms are masked.
[0080] Step 1.3, train the text generation model BART by combining prompts: Through prompt learning based on template construction, diverse domain-specific prompts are formed by combining domain-specific words. These prompts are then inserted as prefixes into the domain-independent statements obtained in Step 1.2, and used as input to train the text generation model BART; the specific process is as follows:
[0081] Step 1.3.1: Using manually constructed prompt templates combined with domain-specific terms, domain-specific prompts are formed and inserted as prefixes into domain-independent statements as input to the model; for example, for the restaurant review domain, the template "restaurantreview of '<domain-specific term>':" is used, and for the computer review domain, the template "laptop review of '<domain-specific term>':" is used.
[0082] Step 1.3.2: Based on a sample set of domain-independent sentences from easy to difficult, train the text generation model BART in a progressive training manner. First train on the simple domain-independent sample set, then transition to the difficult domain-independent sample set to fully learn the reconstruction of text and the generation of tags.
[0083] First, the input is represented using the pre-trained word vector matrix `embbedingMatrix` of the BART model. The model's input is a combination of cue templates and domain-independent statements. Its characterization H is obtained;
[0084]
[0085] Subsequently, in the encoding stage, the encoder of the BART model is used to encode the input with sufficient contextual information;
[0086] H e =BARTEncoder(H) (8)
[0087] During the decoding phase, the BART model needs to reconstruct the text and generate labels. Therefore, at each decoding step, the decoder needs to process the predicted text up to step t. and prediction labels With the encoding vector H e Combined as input;
[0088]
[0089]
[0090] In the formula, W represents the predicted word and predicted label at step t. x b x and W y b y For the trainable parameters of two linear layers, z represents two parsing heads. t This represents the output of the BART decoder at step t;
[0091] Step 1.3.3: For the labeled data in the source domain, the model's learning objective is to reconstruct the original text and the original labels. A loss function is constructed for training. By text loss function Label loss function constitute:
[0092]
[0093]
[0094]
[0095] Step 1.3.4: For unlabeled data in the target domain, the model's learning objective is solely to reconstruct the original text, and its loss function... Text loss function only constitute;
[0096]
[0097] Step 1.4: Based on domain-independent statements with all domain-specific terms masked, the text generation model generates target domain data and pseudo-tags; the specific process is as follows:
[0098] Step 1.4.1: Use domain-independent statements with domain-specific words fully masked (i.e., mask=1.0) to generate target domain data and pseudo-labels; due to the characteristic of the generation model that generates text and labels sequentially from left to right, i.e. the next word is generated based on the previous word, it is impossible to directly generate sentiment triple pseudo-labels. Therefore, (aspect word, opinion word) bigrams and (aspect word, sentiment) bigrams are used as pseudo-labels.
[0099] Step 1.4.2: Using the training from the two tuple generation tasks described above, the model generates pseudo-labels for the original unlabeled data in the target domain, while simultaneously generating more target domain data and their pseudo-labels, achieving data augmentation. Then, through deduplication and unlabeled data filtering, the data is merged into the final target domain data and pseudo-label set D. G ;
[0100] Step 2, Train the cross-domain triple extraction model: Based on all data, including generated data, train a sentiment triple extraction model that integrates syntax and semantics using the self-training method in semi-supervised learning; the model framework is as follows. Figure 3 As shown, the specific steps include:
[0101] Step 2.1: Use the BERT pre-trained model to convert the text X into a vector representation with rich linguistic and contextual information, obtaining the encoded vector representation H; the BERT pre-trained model converts the text sentence X = {w0, w1, w2, ..., w...} of length n into a vector representation of length n. n-1 Encode into a vector representation H = {h0, h1, h2, ..., h} n-1 };
[0102] Step 2.2 involves introducing syntactic information, including a syntactic dependency tree and a phrase composition tree, through a syntactic encoder to enhance the fusion of information from aspect words and viewpoint words, thereby obtaining syntactic vector representations. The specific process is as follows:
[0103] Step 2.2.1: Use a multilayer perceptron to transform H into an initial syntactic representation H. sym :
[0104] H syn =MLP syn (H) (11)
[0105] Step 2.2.2: Use the parsing tool Stanza to parse and obtain the syntactic dependency tree and phrase composition tree of the text sentences, and convert them into an adjacency matrix M. d and M c The two layers are then fused at each level using matrix-positional multiplication to form a syntactic adjacency matrix M. syn ;
[0106]
[0107]
[0108] In the formula, l represents the l-th level of the phrase composition tree;
[0109] Step 2.2.3: Encode syntactic information using a multi-head self-attention layer, and convert the syntactic adjacency matrix M... syn It is integrated into the multi-head self-attention layer of the syntactic encoder and participates in the calculation of the self-attention score matrix;
[0110]
[0111]
[0112]
[0113]
[0114] In the formula, and These are the initial syntactic representations of the i-th and j-th words, respectively. It is the representation of the i-th word after processing by the self-attention mechanism, d s W represents the vector dimension. Q W K and W V These represent three different attention parameter matrices, which are optimized through backpropagation. i,j This refers to the original attention score weights of the i-th and j-th words. The attention score is the result of fusing the syntactic adjacency matrix.
[0115] After fusing syntactic information through a multi-head self-attention layer, a representation is obtained. Furthermore, residual normalization is used to smooth the representation information and obtain syntactic information.
[0116]
[0117] Step 2.2.4: syntactic information is processed through a multi-head cross-attention layer. Semantic information obtained by processing in a similar manner as a semantic encoder To ensure the complementarity of information between the two and enhance their expressive capabilities;
[0118]
[0119]
[0120] In the formula, and WC represents the syntactic and semantic information of the i-th and j-th words, respectively. Q WC K and WC V These represent three different attention parameter matrices, which are optimized through backpropagation.
[0121] Through complementary fusion of multi-head cross-attention, a representation is obtained. After passing through the residual normalization layer again, the final syntactic representation is obtained.
[0122]
[0123] Step 2.3 introduces semantic information through a semantic encoder, mainly derived from the self-attention score matrix of the BERT pre-trained model, to strengthen the semantic association between aspect words and opinion words, and obtain semantic vector representations. The specific process is as follows:
[0124] Step 2.3.1: Use a multilayer perceptron to transform H into an initial semantic representation H. sem ;
[0125] H sem =MLP sem (H) (22)
[0126] Step 2.3.2, the self-attention score matrix M of the BERT pre-trained model bert Carrying rich semantic information, it is divided into layers and subjected to max pooling and average pooling strategies to obtain the semantic matrix M. sem ;
[0127]
[0128]
[0129]
[0130] In the formula, This represents the attention score matrix of the j-th attention head in the i-th layer of the BERT model, where p is the number of layers contained in an interval. The hierarchical structure of the BERT model is divided into m intervals by p. Max pooling is used between different layers within the same interval to focus on salient features; mean pooling is used between different attention heads within the same layer to fuse information from different attention heads. Each interval generates... This leads to the final semantic matrix M. sem ;
[0131] Step 2.3.3: The semantic encoding process is consistent with the syntactic encoding process. First, the semantic matrix M is encoded using a multi-head self-attention layer. sem The data is then integrated, and syntactic and semantic information is interacted and fused through a multi-head cross-attention layer to obtain the final semantic representation.
[0132] Step 2.4: For the three types of vector representations mentioned above, grid search annotation is used for each word pair (w i w j The relationship between the two factors is predicted, and the sentiment triples are obtained through decoding; the specific process is as follows:
[0133] Step 2.4.1, to obtain the representation of each word, the text representation H and the syntactic representation are... and semantic representation The images are spliced and merged to obtain the final representation.
[0134]
[0135] Step 2.4.2, to determine word pairs (w i w j The relationship between ) and its representation and To perform fusion interaction, while considering the correlation information between the current word pair and other word pairs, the final relation probability is obtained using a fully connected layer and a softmax activation function.
[0136] z i =maxpooling(z i,: ), z j =maxpooling(z j,: (27)
[0137]
[0138]
[0139] In the formula, z i,: and z j,: These represent the relationships between the i-th and j-th words and all other words, respectively. [·; ·] denotes vector concatenation operations. i and z j Max pooling in the process is used to see the most significant relationship between the current word and other words, which helps to simplify the expression of information. W and b are the learnable weights and biases of the fully connected layer, respectively.
[0140] Step 2.4.3: Perform triple decoding, first determining the word pair (w i w i To determine whether a term belongs to A or O, we identify aspect terms and opinion terms. If a match is found, we continue to assess the relationship probability. Is it a sentiment tag? If so, then consider aspect words and opinion words (w i w j If they belong to the same triple, they must be in the same triple; otherwise, they do not match. For paired aspect viewpoint pairs (w i w j ), through relational probability Determine their emotional relationships and obtain the final aspect-level emotional triad;
[0141] Step 2.5: Using the target domain-generated dataset and the source domain-labeled dataset, based on the sentiment triple extraction model in Step 2.4, a self-training method from semi-supervised learning is adopted to improve the model's performance in extracting target domain triples; the self-training process is as follows: Figure 4 As shown, the specific process is as follows:
[0142] Step 2.5.1, label the source domain dataset D S As a training set, a loss function is constructed for model training, enabling the model to learn information related to the triplet extraction task. For the triplet extraction task, the cross-entropy loss function is used to calculate the training loss between the true label or high-quality pseudo label and the predicted label.
[0143]
[0144] In the formula, For the indicator function, y ij Indicates word pairs (w i w j ) genuine labels or high-quality pseudo-labels, Let C be the set of predicted labels;
[0145] Step 2.5.2, based on the unlabeled dataset D of the target domain U and generate dataset D G On the trained model, derive D G and D U The triplet results;
[0146] Step 2.5.3: Compare the above triplet results with the pseudo-labels generated by the text generation model. If they match, the sample is used as high-quality screening data and added to the training set to continue training the model until no new screening data is added.
[0147] Step 3, Target Domain Triple Extraction: Input the test set of the target domain into the trained cross-domain triple extraction model to generate (aspect words, opinion words, sentiment) triples for the target domain.
[0148] Example 3 verifies the aspect-level sentiment triple extraction method for cross-domain transfer learning of the present invention: The trained detection model is loaded, and cross-domain sentiment triple extraction is verified using a public dataset:
[0149] This invention uses the publicly available dataset SemEval for experimental verification, which contains four sub-datasets: 14res, 15res, and 16res are restaurant review datasets, and 14lap is a computer review dataset. Model training primarily focuses on two cross-domain scenarios: predicting computer review data as the target domain based on restaurant reviews as the source domain; and predicting restaurant review data as the target domain based on computer reviews as the source domain.
[0150] The following tables illustrate the cross-domain triple extraction performance of this invention on the SemEval public dataset, evaluated using the F1 score. Table 1 is a cross-domain study based on restaurant review data 16res and computer review data 14lap, where 16res-14lap indicates 16res as the source domain and 14lap as the target domain, and 14lap-16res as the target domain, and vice versa. Table 2 is also a cross-domain study based on restaurant review data 14res and computer review data 14lap. Some comparison methods are only applicable to specific sub-tasks. Specifically, A and O represent individual extraction sub-tasks for opinion words and aspect words, respectively; AO and AS represent joint extraction sub-tasks for (aspect words, opinion words) and (aspect words, sentiment) doublets, respectively; AOS represents joint extraction task for (aspect words, opinion words, sentiment) triplets; and "-" indicates that the method is not applicable to that sub-task.
[0151] Table 1. Comparative experimental results based on 16res and 14lap
[0152]
[0153] Table 2 shows the comparative experimental results based on 14res and 14lap.
[0154]
[0155]
[0156] The comparison methods in Tables 1 and 2 are specifically the following existing methods: Zheng Li et al. Transferable end-to-end aspect-based sentiment analysis with selective adversarial learning. Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing. 2019, pp. 4590-4600;
[0157] Chenggong Gong et al. Unified feature and instance based domain adaptation for aspect-based sentiment analysis. *Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing*. 2020, pp. 7035-7045;
[0158] Jianfei Yu et al. Cross-domain review generation for aspect-based sentiment analysis. *Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021*. 2021, pp. 4767-4777;
[0159] Junjie Li et al. Generative cross-domain data augmentation for aspect and opinion co-extraction. *Proceedings of the 2022 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies*. 2022, pp. 4219-4229;
[0160] Zhen Wu et al. Grid Tagging Scheme for Aspect-oriented Fine-grained Opinion Extraction. *Findings of the Association for Computational Linguistics: EMNLP 2020*. 2020, pp. 2576-2585;
[0161] As shown in Tables 1 and 2, the cross-domain triplet extraction model proposed in this invention performs best, achieving an improvement of over 4% compared to the baseline cross-domain triplet extraction methods GTS-BERT and DualEncoder. DualEncoder is the triplet extraction model of this invention that integrates syntactic and semantic information. Like the GTS-BERT model, it is directly trained in a fully supervised manner based on the source domain labeled data and then predicts the target domain test set. DualEncoder performs better than GTS-BERT because it integrates the syntactic and semantic information of the data, improving the extraction efficiency of the target domain. The performance of this invention on certain subtasks is better than the comparative methods of binary cross-domain extraction. The binary extraction method is only responsible for the individual extraction and joint extraction of two elements, and the model has to process less information, making the problem relatively easier to solve. However, the triplet extraction method needs to consider the joint extraction of three elements at the same time, which places higher demands on the model. Moreover, the triplet joint extraction problem cannot be regarded as a simple sequence labeling problem, so it is more difficult.< / mask> < / mask> < / mask>
Claims
1. A method for aspect-level sentiment triple extraction for cross-domain transfer, characterized in that, The specific steps are as follows: Step 1: Generation of target domain data and pseudo-tags; Step 2, train the cross-domain triple extraction model; Step 3, target domain triple extraction; Step 2, training the cross-domain triplet extraction model, is implemented according to the following steps: Step 2.1: Use the BERT pre-trained model to process the text. Transform it into a vector representation with rich linguistic and contextual information to obtain the encoded vector representation. ; Step 2.2 involves introducing syntactic information, including a syntactic dependency tree and a phrase composition tree, through a syntactic encoder to enhance the fusion of information from aspect words and viewpoint words, thereby obtaining syntactic vector representations. ; Step 2.3 introduces semantic information through a semantic encoder, derived from the self-attention score matrix of the BERT pre-trained model, to strengthen the semantic association between aspect words and opinion words, thereby obtaining semantic vector representations. ; Step 2.4: For the three types of vector representations mentioned above, grid search annotation is used for each word pair. The relationships between them are predicted, and sentiment triples are obtained through decoding; Step 2.5: Generate datasets from the target domain and labeled datasets from the source domain. Based on the sentiment triple extraction model in Step 2.4, adopt the self-training method in semi-supervised learning to improve the model's performance in extracting target domain triples. Step 2.2 is implemented in the following steps: Step 2.2.1, using a multilayer perceptron to... Transforming the syntactic encoder into an initial syntactic representation ; Step 2.2.2: Use the parsing tool Stanza to parse and obtain the syntactic dependency tree and phrase composition tree of the text sentences, and convert them into an adjacency matrix. and The two layers are then fused together using matrix-positional multiplication to form a syntactic adjacency matrix. ; Step 2.2.3: Encode syntactic information using a multi-head self-attention layer, and convert the syntactic adjacency matrix... The multi-head self-attention layer, fused into the syntactic encoder, participates in the calculation of the self-attention score matrix, yielding the representation. Furthermore, residual normalization is used to smooth the representation information and obtain syntactic information. ; Step 2.2.4: Process syntactic information through a multi-head cross-attention layer. and semantic information The interaction and fusion are used to obtain the representation. After passing through a residual normalization layer again, the final syntactic representation is obtained. ; Step 2.3 is implemented in the following steps: Step 2.3.1, using a multilayer perceptron to... Transforming the semantic encoder into an initial semantic representation ; Step 2.3.2, Self-attention score matrix of BERT pre-trained model Carrying rich semantic information, the semantic matrix is obtained by dividing it into layers and applying max pooling and average pooling strategies. ; Step 2.3.3, the semantic encoding process is consistent with steps 2.2.3 and 2.2.4 of the syntactic encoding. First, the semantic matrix is encoded using a multi-head self-attention layer. The data is then integrated, and syntactic and semantic information is interacted and fused through a multi-head cross-attention layer to obtain the final semantic representation. .
2. The aspect-level sentiment triple extraction method for cross-domain migration as described in claim 1, characterized in that, In step 1, the generation of target domain data and pseudo-labels is based on source domain labeled data and target domain unlabeled data. It utilizes cue learning and text generation models to generate target domain data and pseudo-labels, specifically implemented as follows: Step 1.1, label the source domain data. and unlabeled data in the target domain Extracting domain-specific terms involves the following steps: Step 1.1.1, for source domain labeled data First, domain-specific terms are extracted using tags, that is, aspect terms and opinion terms in the tagging results are used as domain-specific terms; Step 1.1.2, for source domain labeled data and unlabeled data in the target domain At the same time, by using word frequency, words that appear frequently in this domain but have low frequency in other domains are extracted as domain-specific words. Step 1.2: Obtain domain-independent statements through the masking mechanism, using " <mask> "The character masking statement contains domain-specific words, and multiple masking probabilities are applied to the domain-specific words from small to large to obtain multiple sets of domain-independent statements;< / mask> Step 1.3, train the text generation model BART by combining prompts: By constructing prompts through template learning, and combining domain-specific words to form diverse domain-specific prompts, the prompts are inserted as prefixes into the domain-independent statements obtained in Step 1.2, and used as input to train the text generation model BART; Step 1.4: Based on the domain-independent statements with all domain-specific terms masked, the trained text generation model BART generates the target domain data and pseudo-labels.
3. The aspect-level sentiment triple extraction method for cross-domain transfer as described in claim 2, characterized in that, The training of the BART model in step 1.3 is as follows: Step 1.3.1: Using manually constructed prompt templates combined with domain-specific terms, domain-specific prompts are formed and inserted as prefixes into domain-independent statements as input to the model; Step 1.3.2: Based on a sample set of domain-independent sentences from easy to difficult, train the text generation model BART in a progressive training manner. First train on the simple domain-independent sample set, then transition to the difficult domain-independent sample set to fully learn the reconstruction of text and the generation of tags. Step 1.3.3: For the labeled data in the source domain, the model's learning objective is to reconstruct the original text and the original labels. A loss function is constructed for training. By text loss function Label loss function constitute; (1) Step 1.3.4: For unlabeled data in the target domain, the model's learning objective is solely to reconstruct the original text, and its loss function... Text loss function only constitute: (2) The text and label loss functions in steps 1.3.3 and 1.3.4 are as follows: In text generation models, the model needs to predict both text and labels simultaneously. Therefore, for each sample, the negative log-likelihood loss function is used to calculate the text loss separately. Label loss : (3) (4) In the formula, , Indicates the first Predicting words and tags step by step. , Representative at the The predicted text and labels from the previous step, This is the encoding vector for the BART model.
4. The aspect-level sentiment triple extraction method for cross-domain transfer as described in claim 2, characterized in that, Step 1.4 is implemented in the following steps: Step 1.4.1: Using domain-independent statements with all domain-specific words masked, target domain data and pseudo-labels are generated. Due to the characteristic of the generation model that generates text and labels sequentially from left to right, i.e. the next word is generated based on the previous word, it is impossible to directly generate sentiment triple pseudo-labels. Therefore, (aspect words, opinion words) bigrams and (aspect words, sentiment) bigrams are generated as pseudo-labels. Step 1.4.2, using the training from the two tuple generation tasks in Step 1.4.1, generates more target domain data and their pseudo-labels while simultaneously generating pseudo-labels for the original unlabeled data in the target domain, thus achieving data augmentation. Then, through deduplication and unlabeled data filtering operations, the data is merged into the final target domain data and pseudo-label set. .
5. The aspect-level sentiment triple extraction method for cross-domain transfer as described in claim 1, characterized in that, Step 2.4 is implemented in the following steps: Step 2.4.1, to obtain the representation of each word, the text representation is... Syntactic representation and semantic representation The images are spliced and merged to obtain the final representation. ; Step 2.4.2 is for judging word pairs. The relationship between them, and their representation and To achieve fusion and interaction, while considering the correlation information between the current word pair and other word pairs, fully connected layers and Activation function to obtain the final relationship probability ; Step 2.4.3: Perform triple decoding, first determining word pairs. Does it belong to or To identify aspect terms and opinion terms, if a pair is found, the relationship probability is further determined. Is it an emotional tag? If so, then consider the aspect words and opinion words. They must belong to the same triplet; otherwise, they do not match. (This refers to pairings of opinion words.) Through relational probability Determine their emotional relationship and obtain the final aspect-level emotional triad.
6. The aspect-level sentiment triple extraction method for cross-domain migration according to claim 1, characterized in that, Step 2.5 is implemented in the following steps: Step 2.5.1, label the source domain dataset. As a training set, a loss function is constructed for model training, enabling the model to learn relevant information about the triplet extraction task. Step 2.5.2, based on the unlabeled dataset of the target domain and generating datasets On the trained model, derive and The triplet results; Step 2.5.3: Compare the triplet results from Step 2.5.2 with the pseudo-labels generated by the text generation model. If they match, the samples are used as high-quality screening data and added to the training set to continue training the model until no new screening data is added. The loss functions in steps 2.5.1 and 2.5.3 are as follows: For the triplet extraction task, the cross-entropy loss function is used to calculate the training loss between the true label or high-quality pseudo-label and the predicted label: (5) In the formula, For indicator functions, Indicator pairs Real labels or high-quality pseudo labels, For predicting labels, It is a set of relations.
7. The aspect-level sentiment triple extraction method for cross-domain transfer as described in claim 1, characterized in that, Step 3 specifically involves processing the target domain test dataset. The text to be extracted is input into the trained cross-domain sentiment triplet extraction model, which derives the final triplet result for the target domain, namely (aspect words, opinion words, sentiment) triplet.
