A cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy
By integrating contrastive learning and domain alignment strategies, the text feature space and label feature matching of the T5 model are optimized, which solves the problem of low pseudo-label quality in cross-domain sentiment analysis and achieves more efficient cross-domain sentiment analysis results.
Patent Information
- Application Number
- CN202411660227.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-09-30
- Estimated Expiration
- 2044-11-20
AI Technical Summary
In existing cross-domain sentiment analysis methods, due to the discreteness and complexity of text, domain adversarial learning methods are difficult to converge stably, and the quality of the generated target domain pseudo labels is not high, which affects the effect of cross-domain sentiment analysis.
By integrating contrastive learning and domain alignment strategies, the text feature space of the T5 model is optimized by constructing a contrastive loss function, a domain discriminator, and a regularization term. The label features are matched in combination with the graph optimal transfer theory to generate high-quality pseudo labels and enhanced text.
The feature alignment and pseudo-label quality improvement of cross-domain sentiment analysis models are achieved, which improves the adaptability of the model in the target domain and the accuracy of sentiment analysis.
Smart Images

Figure CN119597919B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing technology, 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 emotional tendencies of different aspects in a text. Unlike traditional sentiment analysis, ABSA not only analyzes the overall sentiment of a text, but also delves into specific aspects, opinions, and sentiment polarity.
[0003] With the development of deep learning, many ABSA-related training schemes have demonstrated excellent performance in specific fields. However, these methods often rely on large-scale fine-grained annotation, which is costly and performs poorly in low-resource scenarios. In particular, 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 domains, making it difficult to effectively perform sentiment analysis in new domains.
[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 enable 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 dataset; 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 processing cross-domain ABSA tasks, making the model more sensitive 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's ability to effectively capture and align 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 being of low quality, thereby affecting the generation effect of the enhanced text in the target domain, and further leading to poor cross-domain sentiment analysis.
[0005] In addition, due to the large differences between domains and poor model adaptability, the enhanced text of the target domain generated by pseudo-label prediction in the target domain has certain limitations and singleness, 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 generated pseudo-labels of the target domain being of low quality, thereby 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, thereby 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 that integrates contrastive learning and domain alignment strategy, including:
[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 target domain, construct a contrast loss function, and obtain the optimized text feature space by minimizing the contrast loss function; and 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] Each text feature representation in the optimized text feature space is input into the decoder of the T5 model, and the generated label of the text corresponding to each text feature representation is output; based on the generated label and the true label corresponding to each text in the source domain, a label loss function is constructed;
[0011] The domain adversarial network loss function, regularization term loss function and 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 used 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 based on the target domain text dataset, including:
[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 a 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] Based on 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 a 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 a 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 true label of each label feature representation; construct a text loss function based on the enhanced text corresponding to each true label in the source domain and the true text;
[0016] The node matching loss function, structure matching loss function and 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 used 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 based on the target domain pseudo-label dataset, including:
[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 used as the sentiment analysis model to perform 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 area;
[0031] The expression of the feature extraction loss function is:
[0032]
[0033] Where f(·) represents the feature extractor; o s 、o t Represent the text of the source domain and the target domain respectively; represents the 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 loss function is:
[0038]
[0039] Among them, P s 、P t Represent the probability distribution of source domain and 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 P 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 ) represents Q sand Q t The set of joint distributions γ of WD(Q s ,Q t ) represents Q s , Q t Wasserstein distance between d(q 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 source domain label feature representation q s and 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 structure matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s ,Q t ) represents Q s and Q t The set of joint distributions γ of GWD(Q s ,Q t ) represents Q s , Q t The Gromov-Wasserstein distance between them; 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 ξth label feature representation 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 present invention discloses a cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy, which uses the hidden state of the encoder of the T5 model as the text feature representation; utilizes the contrastive learning strategy, and optimizes the contrast loss function to shorten the distance of the text feature representation from the source domain, while pushing the distance of the text feature representation from the target domain away, 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 a clearer domain division in the high-dimensional regenerated Hilbert space, which brings more heterogeneity and complexity, and enables the model to provide 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 acts as a generator, and optimizes the feature extractor and domain classifier 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 accuracy of pseudo-label prediction in the target domain, and providing high-quality pseudo-labels for the subsequent generation of enhanced text in the target domain;
[0068] The cross-domain sentiment analysis method described in the present invention integrates contrastive learning and domain alignment strategies, adopting an enhanced text generation strategy from labels to text to enrich the text data in the target domain. In this process, the graph optimal transmission theory is used to transform the complex cross-domain alignment problem into a graph matching problem. The Wasserstein distance and Gromov-Wasserstein distance are used to match the node and edge structures, ensuring more precise alignment of cross-domain data in the high-dimensional label feature space, thereby generating higher-quality text and providing rich data samples to improve the accuracy of the model's sentiment analysis results.
[0069] The present invention provides a cross-domain sentiment analysis method that integrates contrastive learning and domain alignment strategies, and proposes an end-to-end unified framework that combines contrastive learning and domain alignment strategies. In the target domain pseudo-label prediction stage, the text feature representations of the source and target domains are effectively aligned by optimizing the text feature space, introducing a domain adversarial network, and adopting KL divergence as an adjustment mechanism, thereby improving the quality of pseudo-label generation. In the target domain data enhancement stage, the graph optimal transfer theory is adopted, and the Wasserstein distance and Gromov-Wasserstein distance are utilized 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 generating 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 based on specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0071] Figure 1 This is a schematic diagram of the pseudo-label prediction T5 model training process;
[0072] Figure 2 This is a schematic diagram of the training process of the T5 model for enhanced text generation;
[0073] Figure 3 This is a diagram showing 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 the contrastive learning module added;
[0075] Figure 5 This 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 will be further described below with reference to the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it. However, 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) all require models to deeply identify specific aspects in text and analyze the specific emotional connotations 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, we focus 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 Indicates the amount of text data in the target domain; e indicates the text index in the target domain.
[0087] In this paper, 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 This is a schematic diagram of the T5 model training process for pseudo-label prediction; specifically, it includes:
[0089] Suppose that a text consisting of multiple tokens is input to 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 increase the distance between negative sample pairs by optimizing a contrastive loss function, where positive sample pairs refer to samples from the same domain and negative sample pairs refer to samples from different domains, we construct a contrastive loss function 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. Its expression is:
[0092]
[0093] Among them, L con represents the contrast loss function; Respectively represent the i-th text feature representation and the j-th text feature representation of the source domain; 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, the 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 orthogonal (no correlation), and -1 represents the completely opposite direction;
[0096] By minimizing the contrast loss function, an optimized text feature space is obtained. During the optimization process, the feature representation is updated to minimize the contrast loss function. This process is achieved by the gradient descent method. 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 contrastive loss with respect to the model parameters. In this way, the text feature representation can be gradually made more discriminative, with samples from the source domain clustered in the feature space, while samples from the target domain are effectively distinguished. This not only enhances the model's internal cohesion for source domain data, but also improves its discrimination for 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 text of the source domain and the target domain respectively; represents the 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 local features. 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] Among them, 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 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 Represent the probability distribution of the source domain and the target domain respectively, that is, the probability distribution of the source domain is obtained by statistical analysis of the feature representations of each text in the source domain, and the probability distribution of the target domain is obtained by statistical analysis of 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 area;
[0120] In order to confuse the domain discriminator, the parameters of the feature extractor are optimized, making it difficult for the discriminator to distinguish the domain source of the features; 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 implement 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 a 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, which is expressed as:
[0128]
[0129] Among them, P s 、P t Represent the probability distribution of source domain and 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 P 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 probabilistic models, this paper uses KL divergence as a regularization term. The regularization term provides an information-theoretic perspective on the feature alignment problem, which measures the information loss when using the distribution of one domain to approximate the distribution of another domain.
[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 The T5 model is trained so that the T5 model can generate ABSA structured labels in a defined specific format based on the input text. Therefore, the present invention defines the label loss function as a mathematical expression shown in L1;
[0135] S14: Perform 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 used as the pseudo-label prediction T5 model 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 using the pseudo-label prediction T5 model to infer the text in the target domain and obtain pseudo-labels with higher quality, since the extracted objects in the labels are from the text and include a structured annotation scheme, the present invention limits the candidate set of predicted labels to work. The expression of the candidate set of predicted labels is:
[0141]
[0142] in, represents the i-th * Predicted labels; X t The input text representing the target domain; Indicates that in the prediction of 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, given the distribution differences between domains, the pseudo-labels generated using the knowledge learned by the model in the source domain may not be completely accurate, which will result in 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 a dynamic graph; edges are calculated and constructed based on 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; and 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 simple terms, 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, while considering 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 diagram of the T5 model training process for augmented text generation, specifically 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; based on the similarity between the nodes in each domain graph, construct each edge in each domain graph;
[0146] S22: Match the nodes and graph structures according to the graph matching principle, 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. 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 ) represents Q s and Q t The set of joint distributions γ of WD(Q s ,Q t ) represents Q s , Q t Wasserstein distance between d(q 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 source domain label feature representation q sand 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 considers the global structural alignment between the graphs, not just the 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 structure matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s ,Q t ) represents Q s and Q t The set of joint distributions γ of GWD(Q s ,Q t ) represents 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 ξth label feature representation 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 between two node pairs in the graph, which is calculated based on the edge weight. 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 true 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 prediction 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 the 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 used as the enhanced text generation T5 model to generate an enhanced text dataset corresponding to the target domain pseudo-label dataset based on the target domain pseudo-label dataset;
[0170] In summary, by minimizing the second loss function, effective feature alignment between the source and target domains can be achieved, enabling the current model to generate higher-quality text and thus achieve 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 is inferred using the previously trained model for generating ABSA labels from text, filtering out samples whose labels are consistent with the pseudo-labels. This method obtains enhanced data for the target domain. The enhanced data for the target domain is merged with the labeled data for the source domain to form a target training set. The target training set is used to train the enhanced text generation T5 model, resulting in the trained enhanced text generation T5 model serving as the 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, construct a training set corresponding to each sentiment analysis subtask according to the input identifier and output structured label of 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 for performing different sentiment analysis subtasks;
[0177] Among them, the loss function expression 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 dataset mainly covers 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 contains 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 constructed ten cross-domain data pairs based on four datasets; since the two domains L and D are very similar, the two data pairs L→D and D→L were not used in the experiment; for the cross-domain ASTE and AOPE tasks, six cross-domain data pairs were 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] During the target domain labeled data generation phase, a decay factor σ = 0.1 is used when calculating edge weights. This provides a suitable decay rate, helping the model capture more information details. Weighing the cross-entropy loss, the coefficient of the WD loss is β1 = 0.15, and the coefficient of the 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 size of 2.
[0193] The experimental results are the average of 5 trials using different random seeds; the model was trained on a single NVIDIA4090 GPU.
[0194] 3. Experimental Baseline
[0195] To comprehensively evaluate the effectiveness of CLAFR, the following state-of-the-art methods are considered for comparison on the cross-domain ATE and UABSA tasks:
[0196] (1) GAS, by formalizing the ABSA task as a text generation problem, takes advantage of 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 dependence on fine-labeled data in ABSA tasks;
[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 augmented 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 a 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 on 10 cross-domain pairs, the proposed method outperforms the other 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% in average Micro-F1 compared to BGCA, respectively.
[0211] The method provided by the present invention is effective 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, by maximizing the similarity of positive sample pairs and minimizing the similarity of negative sample pairs, actually performs an orthogonal decomposition in RKHS, which can ensure that the features learned in RKHS have good regeneration properties and improve the discriminability of 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 makes the domain boundary in the feature space blurred, 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 the topological structure of the entire graph, ensuring the consistency and smoothness of the feature space; the result of this alignment operation is that 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 Studies
[0222] The present invention conducts ablation studies to explore the effective role of each component in CLAFR. 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 without contra 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. In the subsequent feature alignment training process, the gradient direction may be relatively vague, resulting in a slow optimization process or even falling into a local optimum.
[0226] Secondly, after removing 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, removing the KL divergence from the model resulted in a 2.78% decrease in the average F1 score, indicating that the model requires 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 proposed model without the graph optimal transfer module dropped by 2.51%. 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] Overall, 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 intention when 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 results of the feature representation of the T5 model without special processing, the visualization results of the feature representation of the model with contrastive learning, and the visualization results of the feature representation of the model with dynamic combination of contrastive learning and domain alignment. Figures 3 to 5 Each point in the image 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 As can be seen from the figure, 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 As can be seen from the figure, after the contrastive learning module is processed, the discrimination of the feature representation is significantly improved; this process effectively separates the 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 from the figure, the further feature alignment step aims to effectively confine 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] This paper specifically discusses the comparison of using the optimal graph transmission strategy with and without the application of pseudo-labels when generating labeled data in the target domain. Table 6 shows a specific example of this comparison, which shows that the text generated by the model after fine-tuning the feature alignment using cross-domain graph matching 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 concrete and logical. In the conversion of negative sentiment, the generated text more intuitively reflects the poor service quality and is more straightforward. In contrast, the text directly generated by the original model is semantically confusing and difficult to understand. In the conversion from Rest to Laptop, the text generated by the model after applying graph-optimal transfer exhibits greater descriptive detail. For example, "The battery was very large, the speed was fast, and the display was bright" is clearer and more specific than the simple description generated by the original model. Similarly, the description of "keyboard" and "software" is enriched with more qualitative descriptions, making the text richer and more comprehensive.
[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, demonstrating greater 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, this paper addresses the significant challenge of performance degradation in cross-domain aspect-based sentiment analysis by introducing a novel feature refinement approach within an end-to-end framework. By dynamically combining a contrastive learning module and a domain adversarial network, our approach enhances feature discriminability and intra-domain cohesion, thereby more smoothly achieving domain alignment. KL divergence is further utilized as a regularization mechanism to further optimize the model's alignment with probability distributions across different domains. An innovative data generation strategy is implemented, leveraging optimal transport theory to transform cross-domain alignment into a graph matching problem, thereby improving the feature topology and enhancing the model's adaptability to target domain labels. The generated augmented text exhibits significant improvements in coherence and sentiment nuance. Extensive experiments on multiple public ABSA datasets demonstrate the effectiveness of the proposed approach, demonstrating significant performance improvements on four cross-domain ABSA subtasks. These experimental results highlight the potential of the proposed unified framework to effectively leverage source domain knowledge to improve target domain sentiment analysis, thereby enhancing the adaptability and generalization of ABSA models in diverse domain settings.
[0240] Obviously, the above embodiments are merely examples for clarity of explanation and are not intended to limit the implementation methods. Those skilled in the art will appreciate that other variations or modifications can be made based on the above description. It is not necessary and impossible to enumerate all implementation methods here. Obvious variations or modifications arising therefrom remain 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 by: 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; and 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; Each text feature representation in the optimized text feature space is input into the decoder of the T5 model, and the generated label of the text corresponding to each text feature representation is output; based on the generated label and the true label corresponding to each text in the source domain, a label loss function is constructed; The domain adversarial network loss function, regularization term loss function and 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 used 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. A cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 1, characterized in that: The T5 model is trained by minimizing the first loss function, and the trained T5 model is used 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, 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 a 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; Based on 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 a 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 a 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 true label of each label feature representation; construct a text loss function based on the enhanced text corresponding to each true label in the source domain and the true text; The node matching loss function, structure matching loss function and 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 used 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 used as the enhanced text generation T5 model, which is used to generate the enhanced text dataset corresponding to the target domain pseudo-label dataset based on the target domain pseudo-label dataset. 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 used as the sentiment analysis model to perform different sentiment analysis subtasks.
4. The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 1 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 is 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 source domain and 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 area; The expression of the feature extraction loss function is: Where f(·) represents the feature extractor; o s 、o t Represent the text of the source domain and the target domain respectively; represents the 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 is 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 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 P 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. The cross-domain sentiment analysis method integrating contrastive learning and domain alignment strategy according to claim 2 is 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 ) represents Q s and Q t The set of joint distributions γ of WD(Q s , Q t ) represents Q s , Q t Wasserstein distance between d(q 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 source domain label feature representation q s and 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 is characterized in that: The expression of the structure matching loss function is: Among them, L GWD represents the structure matching loss function; Q s , Q t Represents the node distribution of the source domain and the target domain respectively; Γ(Q s , Q t ) represents Q s and Q t The set of joint distributions γ of GWD(Q s , Q t ) represents 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 ξth label feature representation 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: 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 is 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 is characterized in that: The loss function of the sentiment analysis model is expressed as: 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