Cross-domain sentiment analysis method fusing comparative learning and domain alignment strategy
By integrating contrast learning and domain alignment strategies in cross-domain sentiment analysis, the T5 model is used to optimize the text feature space and introduce domain adversarial network and KL divergence regularization term, the problem of field adversarial learning in the existing technology is solved, and the pseudo-label quality and the accuracy of cross-domain sentiment analysis are improved.
Patent Information
- Application Number
- CN202411660227.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2044-11-20
AI Technical Summary
In the prior art, due to the discreteness and complexity of the text and lack of good initial distribution, the domain adversarial learning method is difficult to converge stably, resulting in the quality of the pseudo-labels in the generated target field, which affects the generation effect of the target field and the cross-domain sentiment analysis effect of the target field.
A cross-domain sentiment analysis method that integrates contrast learning and domain alignment strategies is adopted, text feature representation is generated through the encoder of the T5 model, and a contrast loss function is constructed to optimize the text feature space, and a domain adversarial network and KL divergence regularization term is introduced to achieve the alignment of the source domain and target domain features.
By comparing learning and domain alignment strategies, the model can more effectively distinguish the characteristics of the source and target areas, improve the quality of pseudo-labels and the accuracy of cross-domain sentiment analysis, and enhance the model's adaptability and generalization ability in the target areas.
Smart Images

Figure CN119597919A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy. Background Art
[0002] Aspect-Based Sentiment Analysis (ABSA) is a fine-grained sentiment analysis task that aims to identify and analyze the sentiment tendencies of different aspects in a text. Different from traditional sentiment analysis, ABSA not only analyzes the overall sentiment of the text, but also goes deep into specific aspects, opinions, and sentiment polarity.
[0003] With the development of deep learning, many ABSA-related training schemes have shown excellent performance in specific fields. However, these methods often rely on large-scale fine-grained annotations, have high costs, and perform poorly in low-resource scenarios. Especially in cross-domain applications, they often face insufficient training data and large domain differences, resulting in degraded model performance and insufficient generalization capabilities in new fields, making it difficult to effectively perform sentiment analysis in new fields.
[0004] To alleviate the above problems, researchers have tried various methods to transfer knowledge from the source domain to the target domain, including: using transfer learning to allow the model to learn domain-independent representations; using data augmentation techniques to transfer important information from the target domain to the source domain to expand the labeled data set; using knowledge distillation to provide more reliable pseudo-labels for the target domain; however, these methods usually rely on complex domain mapping mechanisms and are designed for specific tasks, which limits the model's ability to be applied to new tasks. Therefore, the use of an end-to-end framework can effectively solve this problem and has achieved significant performance improvements on multiple cross-domain ABSA subtasks; however, such methods often ignore the importance of structural alignment between domains, resulting in the inability to fully capture and utilize common information between domains when dealing with cross-domain ABSA tasks, making the model more susceptible to noise and abnormal data in the target domain. It is sensitive and difficult to capture complex emotional relationships, which reduces the accuracy and depth of model analysis, resulting in a decrease in the quality of pseudo labels predicted by the model for the target domain, affecting the overall performance of the model; therefore, many methods have introduced domain adversarial learning methods to solve the above problems by capturing the correlation between the source domain and the target domain to reduce domain differences. However, since natural language text itself has discrete distribution characteristics and complex similarity relationships, that is, the text is discrete and complex and lacks a good initial distribution, it is difficult for the domain adversarial learning method to converge stably, which limits the model from effectively capturing and aligning the similarities between the source domain and the target domain in the feature space, making it more difficult to unify the features between domains, resulting in the generated pseudo labels of the target domain of low quality, which affects the generation effect of the target domain enhanced text, and further leads to poor cross-domain sentiment analysis.
[0005] In addition, due to the large differences between domains and poor model adaptability, the enhanced text in the target domain generated by pseudo-label prediction in the target domain has certain limitations and uniformity, that is, the text is insufficient in content length, fluency, accuracy and practicality, which affects the effect of cross-domain sentiment analysis. Summary of the invention
[0006] To this end, the technical problem to be solved by the present invention is to overcome the problem in the prior art that due to the discreteness and complexity of text and the lack of a good initial distribution, the domain adversarial learning method is difficult to converge stably, resulting in the low quality of the generated pseudo-labels in the target domain, thus affecting the generation effect of the enhanced text in the target domain; due to the large differences between domains and poor model adaptability, the enhanced text in the target domain generated by predicting the pseudo-labels in the target domain has certain limitations and singleness, thus affecting the effect of cross-domain sentiment analysis.
[0007] To solve the above technical problems, the present invention provides a cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy, comprising:
[0008] Input the source domain text dataset and the target domain text dataset into the encoder of the T5 model to obtain the source domain text feature representation set and the target domain text feature representation set, and construct a text feature space; with the optimization goal of reducing the distance between text features in the source domain and increasing the distance between text features in the source domain and the target domain, construct a contrast loss function, and obtain the optimized text feature space by minimizing the contrast loss function; construct a feature extraction loss function;
[0009] Input each text feature representation in the optimized text feature space into the domain discriminator, and output the domain generation probability distribution of each text feature representation; construct the domain discriminator loss function based on the domain generation probability distribution of each text feature representation and the domain true probability distribution; construct the domain adversarial network loss function based on the feature extraction loss function and the domain discriminator loss function; construct the regularization term loss function based on the KL divergence between the source domain probability distribution and the target domain probability distribution;
[0010] Input each text feature representation in the optimized text feature space into the decoder of the T5 model, and output the generated label of the text corresponding to each text feature representation; construct a label loss function based on the generated label and the true label corresponding to each text in the source domain;
[0011] The domain adversarial network loss function, the regularization term loss function and the label loss function are weightedly summed to obtain the first loss function; the T5 model is trained by minimizing the first loss function, and the trained T5 model is obtained as the pseudo-label prediction T5 model, which is used to generate a pseudo-label dataset corresponding to the target domain text dataset based on the target domain text dataset.
[0012] Preferably, the T5 model is trained by minimizing the first loss function to obtain the trained T5 model as a pseudo-label prediction T5 model, which is used to generate a pseudo-label dataset corresponding to the target domain text dataset according to the target domain text dataset, and then comprises:
[0013] The source domain real label dataset and the target domain pseudo label dataset are input into the encoder of the pseudo label prediction T5 model to obtain the source domain label feature representation set and the target domain label feature representation set, and construct the label feature space; each label feature representation in each domain label feature representation set is used as each node in each domain graph; based on the similarity between the nodes in each domain graph, each edge in each domain graph is constructed;
[0014] According to the graph matching principle, the Wasserstein distance is used to reduce the similarity cost between the nodes in the source domain graph and the nodes in the target domain graph, and the node matching loss function is constructed; the Gromov-Wasserstein distance is used to reduce the similarity cost between the source domain graph structure and the target domain graph structure, and the structure matching loss function is constructed;
[0015] Input each label feature representation in the label feature space into the decoder of the pseudo label prediction T5 model, and output the enhanced text corresponding to the real label of each label feature representation; construct a text loss function based on the enhanced text and real text corresponding to each real label in the source field;
[0016] The node matching loss function, the structure matching loss function and the text loss function are weightedly summed to obtain the second loss function; the pseudo-label prediction T5 model is trained by minimizing the second loss function, and the trained pseudo-label prediction T5 model is obtained as the enhanced text generation T5 model, which is used to generate an enhanced text dataset corresponding to the target domain pseudo-label dataset based on the target domain pseudo-label dataset.
[0017] Preferably, the pseudo-label prediction T5 model is trained by minimizing the second loss function, and the trained pseudo-label prediction T5 model is obtained as the enhanced text generation T5 model, which is used to generate an enhanced text dataset corresponding to the target domain pseudo-label dataset according to the target domain pseudo-label dataset, and then comprises:
[0018] Based on the pseudo-labeled dataset of the target domain and its corresponding enhanced text dataset, a labeled dataset of the target domain is constructed; based on the labeled dataset of the target domain and the labeled dataset of the source domain, a target training set is constructed;
[0019] Based on the target training set, the training sets corresponding to each sentiment analysis subtask are constructed according to the input identifiers and output structured labels of each sentiment analysis subtask; the enhanced text generation T5 model is trained using the training sets corresponding to each sentiment analysis subtask, and the trained enhanced text generation T5 model is obtained as a sentiment analysis model for performing different sentiment analysis subtasks.
[0020] Preferably, it is characterized in that the expression of the contrast loss function is:
[0021]
[0022] Among them, L con represents the contrast loss function; They represent the i-th text feature representation and the j-th text feature representation of the source domain respectively; represents the kth text feature representation in the target domain; τ represents the temperature coefficient; sim(·,·) represents the similarity function between feature representations, then The expression is:
[0023]
[0024] in, express and The dot product of Respectively The norm of The norm of .
[0025] Preferably, the expression of the domain adversarial network loss function is:
[0026] L DAL =L D +λL f
[0027] Among them, L DAL represents the domain adversarial network loss function; L D represents the discriminator loss function; L f represents the feature extraction loss function; λ represents the trade-off coefficient;
[0028] The expression of the discriminator loss function is:
[0029]
[0030] Among them, P s , P t Represent the probability distribution of the source domain and the target domain respectively; Z s 、z t denote the text feature representation of the source domain and the target domain respectively; D(·) denotes the discriminator; represents the probabilistic loss of the source domain; represents the probability loss of the target domain;
[0031] The expression of the feature extraction loss function is:
[0032]
[0033] Where f(·) represents the feature extractor; o s , o t Represent the texts in the source domain and the target domain respectively; Indicates reverse loss in the source domain; represents the inverse loss in the target domain.
[0034] Preferably, the expression of the first loss function is:
[0035]
[0036] in, represents the first loss function; L1 represents the label loss function; L DAL represents the domain adversarial network loss function; L KL represents the regularization term loss function; α1 represents the domain adversarial network loss coefficient; α2 represents the regularization term loss coefficient;
[0037] The expression of the regularization term loss function is:
[0038]
[0039] Among them, P s , P t Represent the probability distribution of the source domain and the target domain respectively; z r represents the rth text feature representation in the optimized text feature space; P s (z r ) represents the text feature representation z in the source domain r The probability distribution of t (z r ) represents the text feature representation z in the target domain r The probability distribution of KL(P s ||P t ) represents the KL divergence between the probability distribution of the source domain and the probability distribution of the target domain;
[0040] The expression of the label loss function is:
[0041]
[0042] Among them, l represents the length of the sentence corresponding to the text; X s Represents source domain text; represents the vth true label in the source domain; Indicates that based on all predicted labels The conditional probability of the vth label under the condition of .
[0043] Preferably, the expression of the node matching loss function is:
[0044]
[0045] Among them, L WD represents the node matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s ,Q t ) indicates Q sand Q t The set of joint distributions γ of WD(Q s ,Q t ) indicates Q s , Q t The Wasserstein distance between s ,q t ) represents the cost function of the similarity between the source domain node and the target domain, then d(q sa ,q tb ) is:
[0046]
[0047] Among them, q sa represents the ath label feature representation in the source domain; q tb represents the bth label feature representation in the target domain; C represents the cost matrix, representing the label feature representation q in the source domain s and the target domain label feature representation q t The distance between ab Represents the elements in the cost matrix, representing q sa and q tb The complement of the cosine distance between .
[0048] Preferably, the expression of the structure matching loss function is:
[0049]
[0050] Among them, L GWD represents the structural matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s ,Q t ) indicates Q s and Q t The set of joint distributions γ of GWD(Q s ,Q t ) indicates Q s , Q t The Gromov-Wasserstein distance between Represent the node pairs extracted from the source domain graph and the target domain graph respectively; q sδ represents the δth label feature representation in the source domain; q sξ represents the feature representation of the ξth label in the source domain; q tη represents the nth label feature representation of the target domain; Indicates the target area label feature representation; M(·,·) represents the cost function of the similarity of the graph structure between two node pairs, then The expression is:
[0051]
[0052] Among them, ω sδ,sξ represents the weight of the edge between the δth label feature representation and the ξth label feature representation in the source domain, and its expression is:
[0053]
[0054] Indicates the nth label feature representation of the target domain and the The weight of the edge between the label features is expressed as:
[0055]
[0056] Here, σ represents the attenuation factor.
[0057] Preferably, the expression of the second loss function is:
[0058]
[0059] in, represents the second loss function; L2 represents the text loss function; L GWD represents the structure matching loss function;
[0060] The expression of the text loss function is:
[0061]
[0062] Where l′ represents the length of the tag sequence; Y s represents the true label of the source domain; Represents the mth token of the source domain text; Indicates that based on all predictive text The conditional probability of the mth text under the condition of .
[0063] Preferably, the loss function of the sentiment analysis model is expressed as:
[0064]
[0065] Among them, l represents the length of the sentence corresponding to the text; X u represents the target training text; represents the wth true label in the target training set; Indicates that based on all predicted labels The conditional probability of the wth label under the condition of .
[0066] The above technical solution of the present invention has the following beneficial effects compared with the prior art:
[0067] The cross-domain sentiment analysis method of the present invention integrates contrastive learning and domain alignment strategies, which uses the hidden state of the encoder of the T5 model as text feature representation; utilizes the contrastive learning strategy, by optimizing the contrast loss function, shortens the distance of the text feature representation from the source domain, and pushes away the distance of the text feature representation from the target domain, so that the model can distinguish the text feature representation of the source domain from the text feature representation of the target domain, and achieves clearer domain division in the high-dimensional regenerated Hilbert space, which brings more heterogeneity and complexity, so that the model provides a clearer decision boundary for downstream tasks; introduces a domain adversarial network, and combines the feature extraction of the encoder of the T5 model and the feature optimization of contrastive learning to form a feature extractor; uses the text feature representation in the optimized text feature space as the input of the domain discriminator, so that the domain discriminator can effectively distinguish whether the feature comes from the source domain or the target domain; The encoder of the T5 model is used as a generator. The feature extractor and domain classifier are optimized through adversarial training, so that the encoder of the T5 model can generate text feature representations that confuse the domain discriminator, that is, the domain discriminator cannot distinguish the features of the source domain and the target domain. This adversarial training method makes the features generated by the encoder of the T5 model as similar as possible to the source domain features in the eyes of the domain discriminator, that is, the text feature representation learned by the model is insensitive to domain information, thereby achieving cross-domain feature alignment, providing more robust input for subsequent cross-domain tasks, and improving the adaptability of the model in the target domain. Using KL divergence as a regularization term, by measuring the relative entropy of the probability distribution of the two domains, the difference between the domains is further narrowed, and the feature alignment of the source domain and the target domain is further achieved, thereby improving the prediction accuracy of the target domain pseudo-label and providing high-quality pseudo-labels for the subsequent generation of enhanced text in the target domain.
[0068] The cross-domain sentiment analysis method of the present invention, which integrates contrastive learning and domain alignment strategies, adopts an enhanced text generation strategy from label to text to enrich the text data of the target domain. In this process, the graph optimal transmission theory is adopted to transform the complex cross-domain alignment problem into a graph matching problem, and the node and edge structure are matched by the Wasserstein distance and the Gromov-Wasserstein distance to ensure a more refined alignment of cross-domain data in the high-dimensional label feature space, thereby generating higher quality text, and providing rich data samples for improving the accuracy of the model sentiment analysis results.
[0069] The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy described in the present invention proposes an end-to-end unified framework, which combines contrastive learning and domain alignment strategy; in the target domain pseudo-label prediction stage, by optimizing the text feature space and introducing a domain adversarial network, and using KL divergence as an adjustment mechanism, the text feature representations of the source domain and the target domain are effectively aligned, thereby improving the quality of pseudo-label generation; in the target domain data enhancement stage, the graph optimal transmission theory is adopted, and the Wasserstein distance and the Gromov-Wasserstein distance are used to more accurately match nodes and edges in graphs of different domains, thereby improving the topological structure of the features, enabling the model to better adapt to labels from the target domain and generate higher quality text, thereby improving the accuracy of the effect of cross-domain sentiment analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0070] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0071] Figure 1 This is a schematic diagram of the training process of the T5 model for pseudo-label prediction;
[0072] Figure 2 It is a schematic diagram of the training process of the T5 model for enhanced text generation;
[0073] Figure 3 This is a diagram of the visualization results of the feature representation of the T5 model without special processing;
[0074] Figure 4 This is a diagram showing the visualization of the feature representation of the model with contrastive learning module added;
[0075] Figure 5 Figure 2 is a diagram showing the visualization of the feature representation of a model that dynamically combines contrastive learning and domain alignment. DETAILED DESCRIPTION
[0076] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention.
[0077] In the field of natural language processing (NLP), aspect-based sentiment analysis (ABSA) is an important fine-grained sentiment analysis method. Aspect Term Extraction (ATE), unified sentiment analysis (UABSA), aspect opinion pair extraction (AOPE) and aspect sentiment triplet extraction (ASTE); these tasks require the model to deeply identify specific aspects in the text and analyze the specific emotional colors of these aspects.
[0078] Taking the sentence “The waitstaff here are exceptionally friendly.” as an example, based on the structured labels corresponding to the four ABSA subtasks, the sentiment analysis results of the current sentence corresponding to the four ABSA subtasks are obtained, as shown in Table 1.
[0079] Table 1 Sentiment analysis results based on the four ABSA subtasks
[0080] Subtasks Structured Tags example ATE <aspect> A < / aspect> <aspect>waitstaff < / aspect> UABSA <sentiment> A < / sentiment> <pos>waitstaff < / pos> AOPE <aspect> A <opinion> O < / opinion> < / aspect> <aspect>waitstaff <opinion>friendly < / opinion> < / aspect> ASTE <sentiment> A <opinion> O < / opinion> < / sentiment> <pos>waitstaff <opinion>friendly < / opinion> < / pos>
[0081] In this paper, the focus is on the four ABSA subtasks of ATE, UABSA, AOPE, and ASTE; A, O, and S are used to represent aspect items, opinion items, and sentiment items, respectively. The Kth target sentiment tuple B corresponding to the four subtasks is K The representation is as follows:
[0082] ATE: B K =[A];
[0083] UABSA: B K =[A,S];
[0084] AOPE: B K =[A,O];
[0085] ASTE: B K =[A,O,S];
[0086] In cross-domain tasks, the initial training set includes labeled data from the source domain. and unlabeled data from the target domain The purpose is to train a model to predict the set of tuples corresponding to the target domain; Represents source domain text; Indicates the label corresponding to the source domain text; N s Indicates the number of source domain text / label data; c indicates the source domain text / label index; Indicates the target domain text; N t represents the amount of text data in the target domain; e represents the text index in the target domain.
[0087] In the present invention, a pre-trained Text-to-Text Transfer Transformer (T5) model is used to extract deep feature representations from text data. It is a much more powerful language text-to-text framework and can unify all text-related tasks into a text-to-text format, achieving cross-task versatility and effectiveness.
[0088] Reference Figure 1 As shown, Figure 1 Schematic diagram of the T5 model training process for pseudo-label prediction; specifically including:
[0089] Assume that given an input text consisting of multiple tokens, it is input into the encoder of the T5 model and the hidden state sequence of the last layer of the encoder is selected as the feature representation of the current input text, where each hidden state in the sequence corresponds to the high-order feature vector of a vocabulary unit in the input text;
[0090] S11: Input the source domain text dataset and the target domain text dataset into the encoder of the T5 model to obtain the source domain text feature representation set and the target domain text feature representation set, and construct a text feature space;
[0091] Since the goal of contrastive learning is to shorten the distance between positive sample pairs and push away the distance between negative sample pairs by optimizing a contrastive loss function, where positive sample pairs refer to samples from the same field and negative sample pairs refer to samples from different fields, the contrastive loss function is constructed with the optimization goal of reducing the distance between text features in the source field and increasing the distance between text features in the source field and the target field. Its expression is:
[0092]
[0093] Among them, L con represents the contrast loss function; They represent the i-th text feature representation and the j-th text feature representation of the source domain respectively; represents the kth text feature representation in the target domain; τ represents the temperature coefficient, which is used to control the scaling of the similarity weight; sim(·,·) represents the similarity function between feature representations, then The expression is:
[0094]
[0095] in, express and The dot product of Respectively The norm of norm; in a specific embodiment of the present invention, a cosine similarity function is selected as the similarity function between feature representations, and its value range is between -1 and 1, that is, 1 represents the exact same direction, 0 represents orthogonality (no correlation), and -1 represents the exact opposite direction;
[0096] By minimizing the contrast loss function, an optimized text feature space is obtained; wherein, during the optimization process, the feature representation is updated to minimize the contrast loss function, and this process is implemented by the gradient descent method, and the expression of the gradient descent is:
[0097]
[0098] Among them, θ T+1 represents the model parameters at time step T+1; θ T represents the model parameters at time step T; μ T represents the learning rate at time step T; Represents the gradient of the contrast loss with respect to the model parameters. In this way, the text feature representation can gradually become more distinguishable. The samples in the source domain are clustered in the feature space, while the samples in the target domain are effectively distinguished. This not only enhances the internal cohesion of the model for the source domain data, but also improves the distinguishability of the target domain data.
[0099] Construct the feature extraction loss function, which is expressed as:
[0100]
[0101] Where f(·) represents the feature extractor; o s , o t Represent the texts in the source domain and the target domain respectively; Indicates reverse loss in the source domain; represents the reverse loss in the target domain;
[0102] S12: Input each text feature representation in the optimized text feature space into the domain discriminator, and output the domain generation probability distribution of each text feature representation;
[0103] The domain discriminator is a binary classifier, whose purpose is to distinguish whether the feature representation comes from the source domain or the target domain. The text feature representation z is input into the convolutional layer of the domain discriminator to capture the local features, and its expression is:
[0104]
[0105] Among them, h conv represents the output of the convolutional layer; W conv Represents the convolutional layer weight matrix; Represents the convolution layer bias; * represents the convolution operation; R(·) represents the ReLU activation function;
[0106] The pooling layer of the domain discriminator is used to reduce the feature dimension while retaining important information, and the Dropout layer is applied to prevent overfitting. The mathematical expression of this process is:
[0107] h pool =Pool(h conv )
[0108] h drop = Dropout(h pool )
[0109] Among them, h pool represents the output of the pooling layer; Pool(·) represents the pooling operation; h drop represents the output of the Dropout layer; Dropout(·) represents the Dropout operation;
[0110] After that, the features are fed into the fully connected layer of the domain discriminator for further extraction and batch normalization is applied to improve the stability of the discriminator. The mathematical expression of this process is:
[0111]
[0112] h bn =BatchNorm(h fc )
[0113] Among them, h fc represents the output of the fully connected layer; W fc represents the weight matrix of the fully connected layer; represents the bias of the fully connected layer; h bn Represents the result of the batch normalization operation; BatchNorm(·) represents the batch normalization operation;
[0114] Furthermore, the extracted features are input into the output layer of the domain discriminator to obtain the domain generation probability distribution represented by the text features. The expression of the output layer is:
[0115]
[0116] Where D(z) represents the domain generation probability distribution of the text feature representation z, including the probability that the text feature representation z belongs to the source domain and the probability that the text feature representation z belongs to the target domain, and the sum of the probability that the text feature representation z belongs to the source domain and the probability that the text feature representation z belongs to the target domain is 1; for example, if the domain generation probability distribution output by the domain discriminator is [0.7, 0.3], this means that the input text feature representation has a 70% probability of belonging to the source domain and a 30% probability of belonging to the target domain; however, in fact, the input text feature representation belongs to the source domain, that is, its true domain probability distribution is [1, 0]; such a probability distribution can help the model perform domain adversarial learning during training so as to better adapt to the characteristics and distributions of different domains; W output represents the weight matrix of the output layer; represents the output layer bias; ig(·) represents the Sigmoid activation function, which is used to convert the output into a probability value between 0 and 1;
[0117] Based on the domain generation probability distribution and the domain true probability distribution represented by each text feature, the domain discriminator loss function is constructed, and its expression is:
[0118]
[0119] Among them, P s , P t Respectively represent the probability distribution of the source domain and the target domain, that is, the probability distribution of the source domain is obtained by statistically analyzing the feature representations of each text in the source domain, and the probability distribution of the target domain is obtained by statistically analyzing the feature representations of each text in the target domain; z s 、z t denote the text feature representation of the source domain and the target domain respectively; D(·) denotes the discriminator; represents the probabilistic loss of the source domain; represents the probability loss of the target domain;
[0120] In order to confuse the domain discriminator, the parameters of the feature extractor are optimized at the same time, making it difficult for the discriminator to distinguish the domain source of the feature; the feature extractor is composed of the feature extraction of the T5 model and the feature optimization of contrastive learning; the feature extraction loss is; a gradient reversal layer is used between the feature extractor and the domain discriminator to achieve adversarial training. The mathematical expression of the gradient reversal layer is:
[0121]
[0122] in, represents the gradient of the feature extraction loss with respect to the feature extractor parameters; represents the gradient of the domain discriminator loss with respect to the feature extractor parameters;
[0123] According to the feature extraction loss function and the domain discriminator loss function, the domain adversarial network loss function is constructed, and its expression is:
[0124] L DAL =L D +λL f
[0125] Among them, L DAL represents the domain adversarial network loss function; L D represents the discriminator loss function; L f represents the feature extraction loss function; λ represents the trade-off coefficient;
[0126] Through domain adversarial training, the feature representation learned by the model is forced to be insensitive to domain information, thereby achieving cross-domain feature alignment and providing more robust input for subsequent cross-domain tasks;
[0127] In order to further achieve the alignment of source domain and target domain features in the optimized text feature space, Kullback-Leibler (KL) divergence is used as the regularization term, that is, based on the KL divergence between the source domain probability distribution and the target domain probability distribution, a regularization term loss function is constructed, and its expression is:
[0128]
[0129] Among them, P s , P t Represent the probability distribution of the source domain and the target domain respectively; z r represents the rth text feature representation in the optimized text feature space; P s (z r ) represents the text feature representation z in the source domain r The probability distribution of t (z r ) represents the text feature representation z in the target domain r The probability distribution of KL(P s ||P t ) represents the KL divergence between the probability distribution of the source domain and the probability distribution of the target domain;
[0130] Since KL divergence is a statistic that measures the difference between two probability scores and is widely used in machine learning to optimize probability models, the present invention uses KL divergence as a regularization term; the regularization term provides an information theory perspective to view the feature alignment problem, which measures the information loss when using the distribution of one field to approximate the distribution of another field;
[0131] S13: Input each text feature representation in the optimized text feature space into the decoder of the T5 model, and output the generated label of the text corresponding to each text feature representation; construct a label loss function based on the generated label and the true label corresponding to each text in the source domain, and its expression is:
[0132]
[0133] Among them, l represents the length of the sentence corresponding to the text; X s Represents the source domain text, that is, the text input by the current model; represents the vth true label in the source domain; Indicates that based on all predicted labels The conditional probability of the vth label under the condition of;
[0134] For the main ABSA subtask, we need to minimize the standard maximum likelihood loss using the text label pairs {X s ,Y s}Train the T5 model so that the T5 model can generate a defined specific format of ABSA structured label according to the input text. Therefore, the present invention defines the label loss function as a mathematical expression as shown in L1;
[0135] S14: Perform a weighted summation of the domain adversarial network loss function, the regularization term loss function, and the label loss function to obtain the first loss function, which is expressed as:
[0136]
[0137] in, represents the first loss function; L1 represents the label loss function; L DAL represents the domain adversarial network loss function; L KL represents the regularization term loss function; α1 represents the domain adversarial network loss coefficient; α2 represents the regularization term loss coefficient;
[0138] The T5 model is trained by minimizing the first loss function, and the trained T5 model is obtained as a pseudo-label prediction T5 model, which is used to generate a pseudo-label dataset corresponding to the target domain text dataset based on the target domain text dataset;
[0139] In summary, by minimizing the first loss function, the T5 model can not only learn the ability to generate specific and appropriate ABSA labels, but also achieve feature alignment between the source and target domains;
[0140] In addition, when the pseudo-label prediction T5 model is used to infer the text in the target field to obtain a pseudo-label with higher quality, since the extracted object in the label is from the text and includes a structured annotation scheme, the present invention limits the candidate set of the predicted label to work, and the expression of the candidate set of the predicted label is:
[0141]
[0142] in, represents the i-th * Predicted labels; X t The input text representing the target domain; Indicates that in predicting the i * All predicted label sequences before labels; U represents the set of vocabulary and predefined label tokens in the input text; in actual operation, beam search is used to implement this process to ensure that the generated label sequence is optimal, and the generated optimal label sequence is used as the pseudo-label corresponding to the target domain text.
[0143] After steps S11-S14, in view of the distribution differences between domains, the pseudo-labels generated by using the knowledge learned by the model in the source domain may not be completely accurate, which will cause noise interference between the generated text and the actual semantics. This noise interference may mislead the learning process of the model; in order to reduce the impact of noise interference, the present invention adopts a text generation method based on pseudo-labels, that is, given a structured label sequence with multiple tokens, it is input into the encoder of the T5 model, and the hidden state sequence of the last layer of the encoder is selected as the label feature representation; at the same time, in order to achieve feature alignment in this part, the present invention constructs weighted graphs for the two domains respectively, that is, the label feature representation of the source domain and the label feature representation of the target domain are regarded as nodes in the dynamic graph; calculate and construct edges according to the similarity between the nodes; the higher the similarity between the nodes, the greater the weight of the edge, that is, the stronger the connection between the nodes; then according to the graph optimal transmission theory, consider matching the nodes, and consider matching the nodes and edges at the same time.
[0144] In short, it is necessary to use the source domain real label dataset and the target domain pseudo label dataset to train the pseudo label prediction T5 model, and at the same time consider solving the problem of aligning the label features of the source domain and the target domain, so as to obtain the trained pseudo label prediction T5 model as the enhanced text generation T5 model, which is used to generate the enhanced text dataset corresponding to the target domain pseudo label dataset according to the target domain pseudo label dataset; its training process refers to Figure 2 As shown, Figure 2 A schematic diagram of the T5 model training process for augmented text generation, including:
[0145] S21: Input the source domain real label dataset and the target domain pseudo label dataset into the encoder of the pseudo label prediction T5 model to obtain the source domain label feature representation set and the target domain label feature representation set, and construct a label feature space; use each label feature representation in each domain label feature representation set as each node in each domain graph; construct each edge in each domain graph based on the similarity between nodes in each domain graph;
[0146] S22: According to the graph matching principle, the nodes and graph structures are matched respectively, including:
[0147] (1) The Wasserstein distance is used to measure the difference between two probability distributions by considering the "cost" required to "deform" one distribution into another distribution. That is, the minimum value of the difference between the two probability distributions can be calculated by minimizing the expected cost of all possible transfer schemes. Therefore, the present invention uses the Wasserstein distance to reduce the similarity cost between the nodes in the source domain graph and the nodes in the target domain graph, and constructs a node matching loss function, which is expressed as follows:
[0148]
[0149] Among them, L WD represents the node matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s ,Q t ) indicates Q s and Q t The set of joint distributions γ of WD(Q s ,Q t ) indicates Q s , Q t The Wasserstein distance between s ,q t ) represents the cost function of the similarity between the source domain node and the target domain, then d(q sa ,q tb ) is:
[0150]
[0151] Among them, q sa represents the ath label feature representation in the source domain; q tb represents the bth label feature representation of the target domain; C represents the cost matrix. In the optimal transmission theory, the cost matrix is a key component, which defines the cost of transferring one distribution to another. Based on this, the present invention constructs the cost matrix C to represent the label feature representation q of the source domain. sand the target domain label feature representation q t The distance between ab Represents the elements in the cost matrix, representing q sa and q tb The complement of the cosine distance between them; thus, C captures the dissimilarity between nodes in the label feature space;
[0152] (2) The Gromov-Wasserstein distance is used to measure the structural similarity between two graphs. It takes into account the global structural alignment between graphs, rather than just node-to-node matching. Therefore, the Gromov-Wasserstein distance is used to reduce the similarity cost between the source domain graph structure and the target domain graph structure, and a structural matching loss function is constructed. Its expression is:
[0153]
[0154] Among them, L GWD represents the structural matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s ,Q t ) indicates Q s and Q t The set of joint distributions γ of GWD(Q s ,Q t ) indicates Q s , Q t The Gromov-Wasserstein distance between Represent the node pairs extracted from the source domain graph and the target domain graph respectively; q sδ represents the δth label feature representation in the source domain; q sξ represents the feature representation of the ξth label in the source domain; q tη represents the nth label feature representation of the target domain; Indicates the target area label feature representation; M(·,·) represents the cost function of the structural similarity in the graph between two node pairs, which is calculated based on the edge weights. The expression is:
[0155]
[0156] Among them, ω sδ,sξ represents the weight of the edge between the δth label feature representation and the ξth label feature representation in the source domain, and its expression is:
[0157]
[0158] Indicates the nth label feature representation of the target domain and the The weight of the edge between the label features is expressed as:
[0159]
[0160] Among them, σ represents the decay factor, which is used to control the decay speed of the weight;
[0161] S23: Input each label feature representation in the label feature space into the decoder of the pseudo label prediction T5 model, and output the enhanced text corresponding to the real label of each label feature representation;
[0162] Based on the enhanced text and real text corresponding to each real label in the source field, a text loss function is constructed, which is expressed as:
[0163]
[0164] Where l′ represents the length of the tag sequence; Y s Represents the true label of the source domain, that is, the structured label of the current model input; Represents the mth token of the source domain text; Indicates that based on all predictive text The conditional probability of the mth text under the condition of ;
[0165] While performing graph-based optimization on feature distribution, the present invention uses cross entropy loss to measure the difference between the model predicted text domain and the actual text, using the source domain label text pair {Y s ,X s The training model can generate corresponding text according to the input label. Therefore, the present invention defines the text loss function as a mathematical expression shown in L2;
[0166] S24: Perform weighted summation on the node matching loss function, the structure matching loss function and the text loss function to obtain a second loss function, which is expressed as:
[0167]
[0168] in, represents the second loss function; L2 represents the text loss function; L GWD represents the structure matching loss function;
[0169] The pseudo-label prediction T5 model is trained by minimizing the second loss function, and the trained pseudo-label prediction T5 model is obtained as the enhanced text generation T5 model, which is used to generate an enhanced text dataset corresponding to the target domain pseudo-label dataset according to the target domain pseudo-label dataset;
[0170] In summary, by minimizing the second loss function, effective feature alignment between the source domain and the target domain can be achieved, so that the current model can generate higher quality text, thereby achieving better performance in downstream tasks;
[0171] In addition, after feature alignment and current model training are completed, the current model is used to infer the pseudo-labels of the target domain to generate the corresponding enhanced text. The enhanced text generation process is based on iterative decoding, and its expression is:
[0172]
[0173] in, represents the i-th * Generated text; Y t Input labels representing the target domain; Indicates that when generating the i * All generated text sequences before the text; V represents the vocabulary of the current model, which helps to generate richer and more diverse texts; in actual operation, beam search is used to implement this process to ensure that the generated text is optimal, and the generated optimal text is used as the enhanced text corresponding to the pseudo-label of the target domain.
[0174] After steps S21-S24, the generated text will be inferred by the previously trained model for generating ABSA labels from text, and samples with the same regenerated labels and pseudo labels will be filtered out. In this way, enhanced data of the target domain is obtained; the enhanced data of the target domain is merged with the labeled data of the source domain to form a target training set; the target training set is used to train the enhanced text generation T5 model, and the trained enhanced text generation T5 model is obtained as a sentiment analysis model. The specific process includes:
[0175] S31: Based on the pseudo-labeled dataset of the target domain and its corresponding enhanced text dataset, a labeled dataset of the target domain is constructed; based on the labeled dataset of the target domain and the labeled dataset of the source domain, a target training set is constructed;
[0176] S32: Based on the target training set, according to the input identifier and output structured label of each sentiment analysis subtask, construct the training set corresponding to each sentiment analysis subtask; use the training set corresponding to each sentiment analysis subtask to train the enhanced text generation T5 model, and obtain the trained enhanced text generation T5 model as the sentiment analysis model, which is used to perform different sentiment analysis subtasks;
[0177] Among them, the expression of the loss function of the sentiment analysis model is:
[0178]
[0179] Among them, l represents the length of the sentence corresponding to the text; X u Represents the target training text, that is, the text input to the current model; represents the wth true label in the target training set; Indicates that based on all predicted labels The conditional probability of the wth label under the condition of .
[0180] In order to verify the effectiveness of the Contrastive Learning and Advanced Feature Refinement (CLAFR) framework proposed in this paper, this paper focuses on evaluating the performance of CLAFR on four cross-domain sentiment analysis tasks: ATE, UABSA, AOPE, and ASTE.
[0181] 1. Experimental Dataset
[0182] The benchmark datasets mainly cover four different areas, including: Laptop (L), Restaurant (R), Device (D) and Service (S), and their statistical information is shown in Table 2; among them, L is also called L14, which contains laptop reviews from the 2014 SemEval sentiment analysis challenge; R contains the restaurant review collections of the 2014, 2015 and 2016 SemEval sentiment analysis challenges, denoted by R14, R15 and R16 respectively; D contains reviews on 5 different digital devices provided by Hu and Liu; S includes Web service reviews collected by Toprak et al.
[0183] Table 2 Number of samples in the dataset
[0184]
[0185] For the cross-domain UABSA and ATE tasks, the present invention constructs ten cross-domain data pairs based on four data sets; since the two domains L and D are very similar, the two data pairs L→D and D→L are not used in the experiment; for the cross-domain ASTE and AOPE tasks, six cross-domain data pairs are constructed based on L14, R14, R15 and R16; under the premise of unsupervised pre-adaptation, the training set used by the model includes labeled data in the source domain and unlabeled data in the target domain; Micro-F1 score is used as the evaluation indicator in the experiment, and the extracted results are considered correct if and only if all predicted elements are completely matched with the gold labels.
[0186] 2. Experimental parameter settings
[0187] In the feature extraction stage, the T5-base version is used as the text encoder, its hidden state dimension is set to 768, and AdamW is used as the optimizer to optimize the parameters, and its learning rate is 3e-4.
[0188] In the contrastive learning module, the negative sample attention is adjusted to balance the clustering and uniformity of features, and 0.07 is selected as the temperature coefficient.
[0189] In the domain adversarial network, the dropout rate is set to 0.5, and the trade-off coefficient λ between the feature generator loss and the domain discriminator loss is set to 0.6.
[0190] In the target domain pseudo-label generation stage, the coefficients of the three loss terms are weighed as α1=0.1 and α2=0.05.
[0191] In the target domain labeled data generation stage, the decay factor σ=0.1 is used when calculating the edge weight, which can provide a suitable decay rate and help the model capture more information details. Weighing the cross entropy loss, the coefficient of WD loss is β1=0.15, and the coefficient of GWD loss is β2=0.2.
[0192] In all training stages, the models are trained for 25 epochs with a fixed batch size of 16 and a fixed gradient accumulation step of 2.
[0193] The results of the experiments are the average of 5 trials using different random seeds; the model was trained on a single NVIDIA4090 GPU.
[0194] 3. Experimental Baseline
[0195] In order to comprehensively evaluate the effectiveness of CLAFR, the following advanced methods are considered for comparison on cross-domain ATE and UABSA tasks:
[0196] (1) GAS, which formalizes the ABSA task into a text generation problem and uses the powerful capabilities of pre-trained language models in natural language generation to uniformly handle various ABSA tasks;
[0197] (2) UDA, a domain adaptation method that combines features and instances, aims to alleviate the reliance on finely labeled data in the ABSA task;
[0198] (3) FMIM, which improves the performance of the model on the target domain by maximizing the mutual information between two random variables;
[0199] (4) CDRG, a method to obtain enhanced data by transferring target domain-specific attributes to domain-independent reviews;
[0200] (5) MMT, which adopts the mean teacher strategy and uses the pseudo labels generated by the teacher model to guide the learning of the student model, thereby effectively improving the performance of the model in the target domain;
[0201] (6) BGCA, a unified bidirectional generation framework trained in both Text-to-Label and Label-to-Text directions.
[0202] For the cross-domain AOPE and ASTE tasks, the following baselines are considered for comparison:
[0203] (1) RoBMRC, a bidirectional machine reading comprehension method with enhanced optimization;
[0204] (2) SpanASTE, a method that combines span-level interactions and dual-channel pruning strategy;
[0205] (3) GAS, which formalizes the ABSA task into a text generation problem and uses the powerful capabilities of pre-trained language models in natural language generation to uniformly handle various ABSA tasks;
[0206] (4) BGCA, a unified bidirectional generation framework trained in both Text-to-Label and Label-to-Text directions.
[0207] IV. Main Results of the Experiment
[0208] The comparison results of all methods on the cross-domain ABSA and ATE tasks are reported in Table 3, where the results are the average F1 of 5 runs of experiments; it can be observed from Table 3 that in the experiments conducted on 10 cross-domain pairs, the proposed method outperforms the remaining strong baselines on most domain pairs.
[0209] Specifically, CLAFR achieves the best performance in terms of average Micro-F1, surpassing the state-of-the-art method BGCA by 2.45% and 0.98% on the ABSA and ATE tasks.
[0210] For the cross-domain AOPE and ASTE tasks, the results of experiments on six cross-domain data pairs are shown in Table 4. The method provided by the present invention achieves an improvement of 1.45% and 0.59% respectively on average Micro-F1 compared with BGCA.
[0211] The method provided by the present invention has a significant effect because:
[0212] (1) Reproducing kernel Hilbert space is a special Hilbert space in which the kernel function can evaluate the similarity between two vectors. In this space, the feature map is implicit, and the kernel function directly defines the inner product of the space. Contrastive learning maximizes the similarity of positive sample pairs and minimizes the similarity of negative sample pairs. In fact, an orthogonal decomposition is performed in RKHS, which can ensure that the features learned in RKHS have good regeneration properties and improve the discriminability of the features. This operation reduces the intra-class gap and increases the inter-class gap in the feature space, providing a better starting point for the training of subsequent domain adversarial networks.
[0213] (2) Domain adversarial learning uses the gradient reversal layer (GRL) to adjust the gradient flow to train the feature extractor, making it impossible for the domain discriminator to distinguish which domain the feature vector comes from. This blurs the domain boundary in the feature space, thereby achieving domain consistency of the features of the source domain and the target domain.
[0214] (3) The KL divergence is introduced as a regularization term, which provides an effective means for the present invention to further reduce the distribution differences in statistical characteristics of features from different fields, which also helps to alleviate the noise interference caused by field differences; through the combined optimization of contrastive learning and field alignment, the model can generate higher quality pseudo labels;
[0215] (4) In the target domain labeled data generation stage, by applying the graph optimal transfer framework, an optimal mapping scheme is actually found, which not only considers the similarity between nodes, but also takes into account the topological structure of the entire graph, ensuring the consistency and smoothness of the feature space; as a result of this alignment operation, the generated text is not only more semantically consistent with the data in the target domain, but also more natural in style and expression.
[0216] Table 3 Main results of cross-domain UABSA and ATE based on Micro-F1
[0217]
[0218]
[0219] Table 4 Main results of cross-domain AOPE and ASTE based on Micro-F1
[0220]
[0221] 5. Ablation Study
[0222] The present invention conducts ablation research to explore the effective role of each component in CLAFR, and the experimental results of the model with the specified components deleted are shown in Table 5.
[0223] Table 5: Ablation study results for each part of CLAFR.
[0224] UABSA ATE AOPE ASTE Avg. CLAFR 48.52 54.67 63.82 56.39 55.85 w / ocontra 44.43 50.03 60.72 55.27 52.61 w / odann 45.37 50.17 62.50 55.64 53.42 w / okl 44.83 50.18 61.32 55.94 53.07 w / ogot 45.25 50.52 61.55 56.05 53.34
[0225] First, after removing the contrastive learning module, the average F1 score of the four tasks decreased by 3.24%; this result shows that the design of contrastive learning makes samples of the same type more compact in the feature space, while the distance between samples of different types is larger; if it is ignored, the features will not be highly distinguishable at the beginning, and in the subsequent feature alignment training process, the gradient direction may be fuzzy, resulting in a slow optimization process or even falling into a local optimum.
[0226] Secondly, after deleting the domain adversarial network, the average F1 score of the four tasks dropped by 2.43 absolute percentage points; this shows that domain adversarial learning achieves better feature alignment by confusing the domain discriminator, making the model more adaptable and generalizable to data from the target domain, and generating higher quality pseudo-labels for unlabeled data in the target domain.
[0227] In addition, after removing the application of KL divergence in the model, the average F1 score dropped by 2.78%, indicating that the model needs a constraint to smooth the training process, reduce instability when processing high-dimensional data, and improve the convergence speed and robustness of the model; the addition of KL divergence achieves this goal well.
[0228] Finally, the average F1 score of the model proposed in this paper dropped by 2.51% without the graph optimal transfer module; this result further proves that graph matching can help the t5 model better understand and utilize the structured information of the target domain, improve the quality and consistency of text generation, and thus improve the overall performance of the model.
[0229] In general, the ablation results of this paper clearly demonstrate the importance of each component in the framework to the final performance of the model; these results not only support the original intentions in designing and implementing these components, but also prove their key role in improving model performance.
[0230] 6. Visualization
[0231] Figures 3 to 5 The figure shows the distribution of feature samples of source and target domain texts in the feature space on the domain pair R→L in cross-domain UABSA, the visualization result of the feature representation of the T5 model without special processing, the visualization result of the feature representation of the model with contrastive learning, and the visualization result of the feature representation of the model with dynamic combination of contrastive learning and domain alignment. Figures 3 to 5 Each point in the graph represents a sample, dark points represent samples from the source domain, and light points represent samples from the target domain.
[0232] The present invention adopts the t-SNE method to intuitively show the distribution of text features in high-dimensional space through scatter plots; Figure 3 It can be seen from the figure that the features generated by the T5 model without special processing are mixed between the two domains, which indicates that directly inputting these features into the domain discriminator will lead to poor discrimination effect because the features lack obvious discrimination; Figure 4 It can be seen from the figure that after being processed by the contrastive learning module, the discrimination of feature representation has been significantly improved; this process effectively separates features of different categories by maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs, providing a clearer and more discriminative feature representation for subsequent tasks; Figure 5 As can be seen in the figure, the further feature alignment step aims to effectively limit the distribution of target domain features to a region close to the source domain features, thereby enhancing the model's ability to recognize target domain features and simulating the model's training effect on the source domain; the effect of this feature alignment is intuitively demonstrated in the figure, where the target domain features are clearly confined to the range of the source domain feature distribution after alignment; through this feature alignment, the model can more accurately identify and utilize shared features across domains, thereby improving performance in new domains.
[0233] 7. Text Enhancement Case Study
[0234] The present invention specifically discusses the comparison of the optimal transmission strategy with and without the application graph in the stage of using pseudo-labels to generate labeled data in the target domain; the specific case of the comparison is shown in Table 6, and it can be seen that the text generated by the model after combining the cross-domain graph matching for fine feature alignment has higher naturalness and consistency.
[0235] Specifically, in the conversion from Laptop to Rest, the text generated by the model after feature graph matching not only retains the positive sentiment of the original sentence, but also further enhances the specific description of the service and staff, making it more specific and logical; in the conversion of negative sentiment, the text generated can more intuitively reflect the poor service quality, and the wording is more straightforward; while the text directly generated by the original model is semantically confusing and incomprehensible; in the conversion from Rest to Laptop, the text generated by the model after the optimal transfer of the application graph shows higher description details, for example: "The battery was very large, the speed was fast, and the display was bright." Compared with the simple description of the text generated by the original model, it is clearer and more specific. Similarly, for the description of "keyboard" and "software", it adds more qualitative descriptions, making the text richer and more comprehensive in details.
[0236] In summary, the text generated by combining the T5 model and graph optimal transmission technology is not only more delicate in emotional expression, but also significantly improves the fluency and coherence of the text, providing a more effective solution for cross-domain sentiment analysis; in this way, the model can more accurately capture and convey emotional information when processing heterogeneous data, showing stronger adaptability and robustness.
[0237] Table 6 Case analysis results of domain pairs L→R and R→L in cross-domain UABSA
[0238]
[0239] In summary, the present invention addresses the significant challenge of performance degradation in cross-domain aspect-based sentiment analysis by introducing a novel feature refinement method in an end-to-end framework. By dynamically combining contrastive learning modules and domain adversarial networks, the proposed method enhances feature discriminability and intra-domain cohesion, and thereby achieves domain alignment more smoothly. The KL divergence is further used as a regularization mechanism to further optimize the alignment of the model with probability distributions of different domains. An innovative data generation strategy is implemented, which uses optimal transfer theory to convert cross-domain alignment into a graph matching problem, thereby improving the topological structure of features and enhancing the adaptability of the model to target domain labels. The generated enhanced text has significant improvements in coherence and emotional sophistication. Extensive experiments on multiple public ABSA datasets demonstrate the effectiveness of the proposed method, showing significant performance improvements on four cross-domain ABSA subtasks. These experimental results highlight the potential of the proposed unified framework, which can effectively utilize source domain knowledge to improve sentiment analysis in the target domain to enhance the adaptability and generalization ability of ABSA models in different domain environments.
[0240] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. A cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy, characterized in that: include: Input the source domain text dataset and the target domain text dataset into the encoder of the T5 model to obtain the source domain text feature representation set and the target domain text feature representation set, and construct a text feature space; With the optimization goal of reducing the distance between text features in the source domain and increasing the distance between text features in the source domain and the target domain, a contrast loss function is constructed. By minimizing the contrast loss function, the optimized text feature space is obtained; a feature extraction loss function is constructed; Input each text feature representation in the optimized text feature space into the domain discriminator, and output the domain generation probability distribution of each text feature representation; construct the domain discriminator loss function based on the domain generation probability distribution of each text feature representation and the domain true probability distribution; construct the domain adversarial network loss function based on the feature extraction loss function and the domain discriminator loss function; construct the regularization term loss function based on the KL divergence between the source domain probability distribution and the target domain probability distribution; Input each text feature representation in the optimized text feature space into the decoder of the T5 model, and output the generated label of the text corresponding to each text feature representation; construct a label loss function based on the generated label and the true label corresponding to each text in the source domain; The domain adversarial network loss function, the regularization term loss function and the label loss function are weightedly summed to obtain the first loss function; the T5 model is trained by minimizing the first loss function, and the trained T5 model is obtained as the pseudo-label prediction T5 model, which is used to generate a pseudo-label dataset corresponding to the target domain text dataset based on the target domain text dataset.
2. According to claim 1, a cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy is characterized in that: The T5 model is trained by minimizing the first loss function, and the trained T5 model is obtained as the pseudo-label prediction T5 model, which is used to generate a pseudo-label dataset corresponding to the target domain text dataset according to the target domain text dataset, including: The source domain real label dataset and the target domain pseudo label dataset are input into the encoder of the pseudo label prediction T5 model to obtain the source domain label feature representation set and the target domain label feature representation set, and construct the label feature space; each label feature representation in each domain label feature representation set is used as each node in each domain graph; based on the similarity between the nodes in each domain graph, each edge in each domain graph is constructed; According to the graph matching principle, the Wasserstein distance is used to reduce the similarity cost between the nodes in the source domain graph and the nodes in the target domain graph, and the node matching loss function is constructed; the Gromov-Wasserstein distance is used to reduce the similarity cost between the source domain graph structure and the target domain graph structure, and the structure matching loss function is constructed; Input each label feature representation in the label feature space into the decoder of the pseudo label prediction T5 model, and output the enhanced text corresponding to the real label of each label feature representation; construct a text loss function based on the enhanced text and real text corresponding to each real label in the source field; The node matching loss function, the structure matching loss function and the text loss function are weightedly summed to obtain the second loss function; the pseudo-label prediction T5 model is trained by minimizing the second loss function, and the trained pseudo-label prediction T5 model is obtained as the enhanced text generation T5 model, which is used to generate an enhanced text dataset corresponding to the target domain pseudo-label dataset based on the target domain pseudo-label dataset.
3. A cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 2, characterized in that: The pseudo-label prediction T5 model is trained by minimizing the second loss function, and the trained pseudo-label prediction T5 model is obtained as the enhanced text generation T5 model, which is used to generate an enhanced text dataset corresponding to the target domain pseudo-label dataset according to the target domain pseudo-label dataset, including: Based on the pseudo-labeled dataset of the target domain and its corresponding enhanced text dataset, a labeled dataset of the target domain is constructed; based on the labeled dataset of the target domain and the labeled dataset of the source domain, a target training set is constructed; Based on the target training set, the training sets corresponding to each sentiment analysis subtask are constructed according to the input identifiers and output structured labels of each sentiment analysis subtask; the enhanced text generation T5 model is trained using the training sets corresponding to each sentiment analysis subtask, and the trained enhanced text generation T5 model is obtained as a sentiment analysis model for performing different sentiment analysis subtasks.
4. According to claim 1, a cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy is characterized in that: The expression of the contrast loss function is: Among them, L con represents the contrast loss function; They represent the i-th text feature representation and the j-th text feature representation of the source domain respectively; represents the kth text feature representation in the target domain; τ represents the temperature coefficient; sim(·,·) represents the similarity function between feature representations, then The expression is: in, express and The dot product of Respectively The norm of The norm of .
5. The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 1, characterized in that: The expression of the domain adversarial network loss function is: THE DAL =L D +λL f Among them, L DAL represents the domain adversarial network loss function; L D represents the discriminator loss function; L f represents the feature extraction loss function; λ represents the trade-off coefficient; The expression of the discriminator loss function is: Among them, P s , P t Represent the probability distribution of the source domain and the target domain respectively; z s 、z t denote the text feature representation of the source domain and the target domain respectively; D(·) denotes the discriminator; represents the probabilistic loss of the source domain; represents the probability loss of the target domain; The expression of the feature extraction loss function is: Where f(·) represents the feature extractor; o s , o t Represent the texts in the source domain and the target domain respectively; Indicates reverse loss in the source domain; represents the inverse loss in the target domain.
6. The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 1, characterized in that: The expression of the first loss function is: in, represents the first loss function; L1 represents the label loss function; L DAL represents the domain adversarial network loss function; L KL represents the regularization term loss function; α1 represents the domain adversarial network loss coefficient; α2 represents the regularization term loss coefficient; The expression of the regularization term loss function is: Among them, P s , P t Represent the probability distribution of the source domain and the target domain respectively; Z r represents the rth text feature representation in the optimized text feature space; P s (Z r ) represents the text feature representation Z in the source domain r The probability distribution of t (z r ) represents the text feature representation z in the target domain r The probability distribution of KL(P s ||P t ) represents the KL divergence between the probability distribution of the source domain and the probability distribution of the target domain; The expression of the label loss function is: Among them, l represents the sentence length corresponding to the text; s represents the source domain text; represents the vth true label in the source domain; Indicates that based on all predicted labels The conditional probability of the vth label under the condition of .
7. A cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 2, characterized in that: The expression of the node matching loss function is: Among them, L WD represents the node matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s , Q t ) indicates Q s and Q t The set of joint distributions γ of WD(Q s , Q t ) indicates Q s , Q t The Wasserstein distance between s ,q t ) represents the cost function of the similarity between the source domain node and the target domain, then d(q sa ,q tb ) is: Among them, q sa represents the ath label feature representation in the source domain; q tb represents the bth label feature representation in the target domain; C represents the cost matrix, representing the label feature representation q in the source domain s and the target domain label feature representation q t The distance between ab Represents the elements in the cost matrix, representing q sa and q tb The complement of the cosine distance between .
8. The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 2, characterized in that: The expression of the structure matching loss function is: Among them, L GWD represents the structural matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s , Q t ) indicates Q s and Q t The set of joint distributions γ of GWD(Q s , Q t ) indicates Q s , Q t The Gromov-Wasserstein distance between sδ ,q sξ ), Represent the node pairs extracted from the source domain graph and the target domain graph respectively; q sδ represents the δth label feature representation in the source domain; q sξ represents the feature representation of the ξth label in the source domain; q tη represents the nth label feature representation of the target domain; Indicates the target area label feature representation; M(·,·) represents the cost function of the in-graph structural similarity between two node pairs, then The expression is: Among them, ω sδ,sξ represents the weight of the edge between the δth label feature representation and the ξth label feature representation in the source domain, and its expression is: Indicates the nth label feature representation of the target domain and the The weight of the edge between the label features is expressed as: Where v represents the attenuation factor.
9. The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 2, characterized in that: The expression of the second loss function is: in, represents the second loss function; L2 represents the text loss function; L GWD represents the structure matching loss function; The expression of the text loss function is: Where l′ represents the length of the tag sequence; Y s represents the true label of the source domain; Represents the mth token of the source domain text; Indicates that based on all predictive text The conditional probability of the mth text under the condition of .
10. The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 3, characterized in that: The expression of the loss function of the sentiment analysis model is: Among them, l represents the length of the sentence corresponding to the text; X u represents the target training text; represents the wth true label in the target training set; Indicates that based on all predicted labels The conditional probability of the wth label under the condition of .
Citation Information
Patent Citations
Model training method and device, prediction method and device and electronic equipment
CN115700555A
Cross-domain sentiment classification method based on comparative learning
CN116049406A
Cited By
Description text generation-based missing multi-label image identification method and device
CN120708227A