Multi-target stance detection method and system based on contrastive learning and consistency detection

By combining contrastive learning and consistency detection with a BERT-BiLSTM encoder and joint training, the problems of dataset noise, target association, and domain information in multi-target position detection are solved, thereby improving the accuracy and generalization ability of detection.

CN116992873BActive Publication Date: 2026-11-24DALIAN MARITIME UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310959805.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2026-11-24
Estimated Expiration
2043-07-31

AI Technical Summary

Technical Problem

Existing multi-object position detection tasks suffer from noisy and metaphorical datasets, object associations, and domain information issues, leading to decreased detection performance.

Method used

We employ a method based on contrastive learning and consistency detection. We learn hidden contextual information through the BERT-BiLSTM encoder, and combine the consistency detection module and the contrastive learning module to share domain-specific information using a joint training strategy, thereby enhancing the semantic connections between targets.

Benefits of technology

It improves the accuracy and generalization ability of multi-target position detection, solves the problems of noisy datasets, target association and domain information, and enhances the model's feature learning and detection performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116992873B_ABST
    Figure CN116992873B_ABST
Patent Text Reader

Abstract

The application discloses a multi-target stance detection method and system based on contrast learning and consistency detection, and belongs to the technical field of natural language processing. The application applies a consistency detection method to contrast learning, which enables a model to learn more feature information of targets, and strengthens the connection of semantic information between the targets, so that the targets assist each other in detecting their own stances. In addition, in the application, a BERT is fine-tuned and embedded into a BiLSTM as an encoder, so as to more fully utilize semantic information between hidden contexts. The application also takes joint training as a multi-task learning method, and allows the model to share information of a specific field based on a data set. The application solves the problems of a noisy data set, isolated targets and insufficient information of a specific field in multi-target stance detection. Not only does the application improve the precision of performance on the task, but also has reference significance for other multi-target text classification tasks with similar problems.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of natural language processing and relates to a multi-objective position detection method and system based on contrastive learning and consistency detection. Background Technology

[0002] With the widespread use of social media and the internet, people's opinions and views are more easily expressed and shared publicly, providing broader opportunities for the application of stance detection technology. For example, the surge in online social media has facilitated the generation of online discourse and many rumors, which can be detected by stance detection technology to avoid the harmful effects of spreading misinformation.

[0003] In the business world, stance detection technology can also help companies understand customer opinions and feedback on their products or services, thereby improving products and increasing customer satisfaction. Furthermore, stance detection can be used to identify users' stances on topics expressed on social media.

[0004] Initially, people only detected the stance of a single target. However, this single stance detection method is not applicable in some scenarios, such as political elections, where there is more than one candidate. Therefore, the number of targets to be detected has gradually increased, leading to multi-target stance detection.

[0005] Traditionally, stance detection tasks involved manually classifying the stance expressed in text. However, with advancements in computer hardware and deep learning theory, deep neural network models have been widely applied to automated stance detection tasks. Multi-objective stance detection remains challenging, primarily in the following three aspects: (1) Noisy and metaphorical datasets: Stance detection datasets contain a lot of complex semantic information and noise, such as special symbols and spelling errors. In addition, in datasets used for stance detection, there are often some datasets that do not contain the relevant target. Therefore, it is difficult to capture the dependency relationship between the target and the text.

[0006] (2) Target association problem: There are various kinds of connections between the targets involved in the text. In existing models, researchers focus more on how to more accurately detect the position of each target, without considering the association between targets.

[0007] (3) Domain Information Problem: Stance detection often analyzes datasets of comments, which contain various scenarios, such as elections and product feedback. Different datasets have their own domain-specific information, and these specific words will appear in the comments from time to time. People can understand them, but models have difficulty understanding them. In this case, the predictive performance of stance detection will be greatly reduced. Summary of the Invention

[0008] To address the aforementioned problems, this invention proposes a multi-objective stance detection method and system based on contrastive learning and consistency detection. This invention applies contrastive learning to consistency detection, enabling the model to learn more information about the features of the target and strengthen the semantic connections between them, allowing them to mutually reinforce each other in stance detection. Furthermore, this invention fine-tunes BERT and embeds a BiLSTM as the encoder to more fully utilize the semantic information between hidden contexts. This invention also employs joint training as a multi-task learning method, allowing models to share domain-specific information based on datasets.

[0009] The technical solution adopted in this invention is as follows: This invention provides a multi-target position detection method based on contrastive learning and consistency detection, comprising: Obtain a multi-target position detection dataset and preprocess the multi-target position detection dataset; A multi-objective stance detection model is established and trained. This model includes an encoder module, a consistency detection module, a contrastive learning module, and a joint training module. The joint training module performs joint training on the preprocessed dataset. Joint training involves swapping target pairs in one dataset and concatenating them with the original dataset, and concatenating datasets of related target pairs together to form the final dataset. The encoder module uses a BERT-BiLSTM encoder to encode the dataset processed by the joint training module, obtaining hidden contextual information between words. The consistency detection module performs similarity detection on the encoded data, learning semantic information between targets. The contrastive learning module performs contrastive learning on the consistency-detected data. The joint training module is also used to train multiple target pair datasets on a single model, enabling the model to learn domain-specific information related to the datasets. The trained multi-target position detection model is used to perform multi-target position detection on the preprocessed data.

[0010] Furthermore, the multi-target position detection dataset is preprocessed, including: removing stop words, performing word segmentation, and classifying targets.

[0011] Furthermore, training a multi-target position detection model includes: employing a multi-task learning method to jointly train a model using multiple datasets.

[0012] Furthermore, the consistency detection module performs consistency detection on the encoded data, including: The input is represented as and Then, using the two sequences The consistency test is used to detect whether authors convey the same stance. When authors express the same attitude towards two objectives, the consistency test label is recorded as 1; otherwise, it is recorded as 0. Encoded sentence representation, Used to separate targets Harmony ; An empty matrix is ​​introduced to store consistency detection information between targets.

[0013] Furthermore, the consistency detection module calculates according to the following formula:

[0014]

[0015] in , , , , It is an activation function. training set small batches, Represents the true labels used for consistency testing. It is the index of the data sample.

[0016] Furthermore, the contrastive learning module performs contrastive learning on the data after consistency detection, including: Given a mini-batch of samples Hidden vectors in Those with the same stance labels ∈ The anchor is considered a positive example, while other samples are considered negative examples.

[0017] Furthermore, the contrastive learning module is calculated according to the following formula:

[0018]

[0019]

[0020]

[0021] in If and only if The time is 1 and They are and Stance tags This represents the temperature parameter.

[0022] Furthermore, during the training phase, the model is trained using cross loss, assigning different weights to each loss to minimize the joint loss.

[0023] This invention also provides a multi-target position detection system based on contrastive learning and consistency detection, comprising: The preprocessing module is used to acquire a multi-target position detection dataset and preprocess the multi-target position detection dataset. A model building module is used to build and train a multi-objective stance detection model. The multi-objective stance detection model includes an encoder module, a consistency detection module, a contrastive learning module, and a joint training module. The joint training module performs joint training on the preprocessed dataset. Joint training includes swapping target pairs in one dataset and concatenating them with the original dataset, and concatenating datasets of related target pairs together to form the final dataset. The encoder module uses a BERT-BiLSTM encoder to encode the dataset processed by the joint training module, obtaining hidden contextual information between words. The consistency detection module performs similarity detection on the encoded data and learns semantic information between targets. The contrastive learning module performs contrastive learning on the consistency-detected data. The joint training module is also used to train multiple target pair datasets on a single model, enabling the model to learn domain-specific information related to the datasets. The detection module is used to perform multi-target position detection on the preprocessed data using the trained multi-target position detection model.

[0024] Compared with existing technologies, this invention addresses three challenges in the code allocation process of most current multi-object position detection models: noisy and metaphorical datasets, object association, and domain information issues. The beneficial effects of this invention are: 1) In this invention, BERT is fine-tuned and a bidirectional long short-term memory network (BiLSTM) is embedded as an encoder so that it can learn more features and more useful information about the hidden context between words, in order to solve the problem of noisy and metaphorical datasets.

[0025] 2) In this invention, contrastive learning is applied to consistency detection. It enables the model to learn more information about the features of the target and strengthens the semantic information connection between targets. In the position detection process, one target can assist in the detection of another target to solve the target association problem.

[0026] 3) This invention introduces a multi-task learning method, which trains the same model for all target pairs in the dataset through joint training. Based on the sharing of information in a specific domain in the dataset, this reduces overfitting and helps the model obtain a more generalized text representation to solve the domain information problem. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 This is a flowchart illustrating a multi-target position detection method based on contrastive learning and consistency detection in an embodiment of the present invention. Figure 2 This is a schematic diagram of the multi-target position detection model in an embodiment of the present invention. Detailed Implementation

[0029] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0030] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0031] This invention proposes a multi-target stance detection method based on contrastive learning and consistency detection. The method inputs preprocessed stance detection text data into a BERT-BiLSTM encoder to fully learn contextual semantic information. Then, consistency detection is introduced to strengthen the semantic connections between targets, and contrastive learning is used to better learn the target's feature information. Joint training is used as a multi-task learning method, enabling the model to share domain-specific information based on the dataset.

[0032] like Figure 1As shown in the figure, a multi-target position detection method based on contrastive learning and consistency detection in an embodiment of the present invention includes the following steps: S1: Obtain the multi-target position detection dataset and preprocess the obtained multi-target position detection dataset; In practice, a preprocessing program file for the multi-target position detection dataset is written, and the dataset is preprocessed using the preprocessing program file.

[0033] Preprocessing includes: transforming the raw corpus into input that can be accepted by deep learning network models, removing stop words from the dataset, performing word segmentation, and dividing the target into segments.

[0034] S2: Establish and train a multi-target position detection model; the multi-target position detection model includes: an encoder module, a consistency detection module, a contrastive learning module, and a joint training module; (1) Encoder module: The preprocessed data is input into the BERT-BiLSTM encoder to fully learn the hidden contextual information between words; The BERT-BiLSTM encoder consists of a fine-tuned BERT (Bidirectional Encoder Representations from Transformers, a pre-trained language representation model) and a bidirectional BiLSTM (Bi-directional Long Short-Term Memory, typically used to model contextual information). In this embodiment, BERT is fine-tuned using joint training and consistency detection techniques. During fine-tuning, the parameters are set as follows: batch size of 32, maximum sequence length of 128, AdamW optimizer, and learning rate of 2e-5. This BERT-BiLSTM encoder transforms the preprocessed data into... ,in Encoded sentence representation, Used to separate targets Harmony .

[0035] In practice, this step includes: S2.1: Input the output of step S1 into the fine-tuned BERT to learn the feature information near the target. S2.2: Input the output of step S2.2 into a bidirectional long short-term memory network layer (Bi-LSTM) to learn the contextual information in the text.

[0036] Specifically, take the last layer of BERT training that contains The output C ∈ Add weight ∈ As input to the BiLSTM model, the calculation is as shown in the formula:

[0037] in , , , It is a dimension of The bias vector, It is an activation function.

[0038] The BiLSTM model feeds the input vector into the hidden layers. After computing two hidden layers in different directions, BiLSTM combines the results. The forward hidden layer vector and the backward hidden layer vector are respectively... and , It is the output vector of the hidden layer, calculated using the following formula:

[0039] in , where i represents the i-th moment.

[0040] Furthermore, this model uses the tanh function as the activation function. To calculate the hidden layer, where The calculation formula is as follows:

[0041] in yes The weight matrix, corresponding to the k-th index, G is the time... Hidden layer output The corresponding weight matrix, This represents two different directions in the hidden layer. It corresponds to the first Bias vectors for each index.

[0042] (2) Consistency Detection Module: The stance consistency detection task is to detect whether the author's stance on two objectives is consistent. When the author expresses an attitude of holding the same stance on both objectives, the label is 1; otherwise, it is 0.

[0043] Specifically, given input data x and two targets t1 and t2, the input is formulated as follows: and Then, the [CLS] marker representations of the two sequences are used to detect whether the text authors expressed the same stance on the two targets. Consistency class probability. The following can be calculated:

[0044] in , , , , It is the size of the hidden dimension. It is an activation function.

[0045] An empty matrix is ​​introduced to store consistency detection information between targets.

[0046] (3) Comparative learning module: The results of the multi-target position detection are compared and learned, enabling the model to learn more feature information of the target; Contrastive learning is applied to position detection and consistency detection tasks. Position contrastive loss is defined on the hidden vectors of instances with supervised position label information.

[0047] Given a small batch Hidden vectors in , , The anchor is considered a positive example, that is... = other samples ∈B(k) m) is considered a negative example, so position detection loss is calculated. Loss compared with consistency detection as follows:

[0048]

[0049]

[0050]

[0051] in If and only if The time is 1. and They are and Stance tags This represents the temperature parameter.

[0052] By dividing the model into positive and negative examples, the model learns the feature information of the target, thereby enhancing the position-based perception between targets and improving the generalization ability of the framework.

[0053] (4) Joint training module: When training the multi-object position detection model, a joint training strategy is introduced. This strategy trains the same model with all object pairs from the benchmark dataset. This leverages data from all object pairs, mitigates overfitting, enriches domain-specific knowledge, and helps the model learn more general representations.

[0054] During the training phase, the model is trained using cross-loss, with different weights assigned to each loss function to minimize the joint loss. The total loss is calculated as follows:

[0055]

[0056]

[0057] Among them, let It is a labeled training dataset, and It is a small batch of MTSD, and makes and represents the true labels for the position detection task and the consistency detection task, respectively, and i is the index of the data sample. , , These are all adjusted hyperparameters, here. These are the optimal hyperparameters in the preliminary study.

[0058] S3. Use the trained multi-target position detection model to perform multi-target position detection on the preprocessed data.

[0059] like Figure 2 As shown, the multi-target position detection model in this embodiment of the invention includes: an encoder module, a consistency detection module, a contrastive learning module, and a joint training module.

[0060] First, the preprocessed dataset is processed through a joint training module. Joint training, as a "fusion" strategy, swaps the target pairs in one dataset and concatenates them with the original dataset, and concatenates the datasets of related target pairs together to form the final dataset for subsequent consistency detection and model training. That is, the model is trained by using data from many target pairs, thereby sharing domain-specific information based on the dataset. This reduces overfitting and helps the model obtain a more generalized representation of the text.

[0061] Secondly, BERT and BiLSTM are used as the upstream and downstream components of the encoder structure, respectively, to better capture the hidden contextual information between words. The encoder module encodes the data processed by the joint training module. The encoded information is then passed to the consistency detection module and the classifier. The consistency detection module integrates the input encoded information before model training for its own purposes.

[0062] Finally, during the classifier training phase, the consistency detection module uses the softmax function to perform similarity detection on the encoded information about two targets, discovering the hidden connections between them and enabling them to assist each other in detecting positions. The contrastive learning module adds contrastive learning to the information from the consistency detection module and the encoded information passed to the classifier. It divides the input information into positive and negative examples, bringing examples of the same category closer together and separating examples of different categories, thereby learning the higher-level semantic representation space. This allows the model to learn the feature information of the targets, enhancing position-based perception between them and improving the model's generalization ability.

[0063] Corresponding to the above method, this embodiment of the invention provides a multi-target position detection system based on contrastive learning and consistency detection, comprising: The preprocessing module is used to acquire a multi-target position detection dataset and preprocess the multi-target position detection dataset. A model building module is used to build and train a multi-objective stance detection model. The multi-objective stance detection model includes an encoder module, a consistency detection module, a contrastive learning module, and a joint training module. The joint training module performs joint training on the preprocessed dataset. Joint training includes swapping target pairs in one dataset and concatenating them with the original dataset, and concatenating datasets of related target pairs together to form the final dataset. The encoder module uses a BERT-BiLSTM encoder to encode the dataset processed by the joint training module, obtaining hidden contextual information between words. The consistency detection module performs similarity detection on the encoded data and learns semantic information between targets. The contrastive learning module performs contrastive learning on the consistency-detected data. The joint training module is also used to train multiple target pair datasets on a single model, enabling the model to learn domain-specific information related to the datasets. The detection module is used to perform multi-target position detection on the preprocessed data using the trained multi-target position detection model.

[0064] The parts of this invention not described in detail are well-known in the field.

[0065] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A multi-target stance detection method based on contrastive learning and consistency detection, characterized in that, include: Obtain a multi-target position detection dataset and preprocess the multi-target position detection dataset; Establish and train a multi-target position detection model; The multi-target stance detection model includes an encoder module, a consistency detection module, a contrastive learning module, and a joint training module. The joint training module performs joint training on the preprocessed dataset. Joint training includes swapping target pairs in one dataset and concatenating them with the original dataset, and concatenating datasets of related target pairs together to form the final dataset. The encoder module uses a BERT-BiLSTM encoder to encode the dataset processed by the joint training module, obtaining hidden contextual information between words. The consistency detection module performs similarity detection on the encoded data, learning semantic information between targets. The contrastive learning module performs contrastive learning on the consistency-detected data. The joint training module is also used to train multiple target pair datasets on a single model, enabling the model to learn domain-specific information related to the datasets. The trained multi-target position detection model is used to perform multi-target position detection on the preprocessed data.

2. The method according to claim 1, characterized in that, The multi-target position detection dataset is preprocessed, including: removing stop words, performing word segmentation, and classifying targets.

3. The method according to claim 1, characterized in that, Training a multi-target position detection model includes: employing a multi-task learning method to jointly train a model using multiple datasets.

4. The method according to claim 1, characterized in that, The consistency detection module performs consistency checks on the encoded data, including: The input is represented as and Then, using the two sequences The consistency test is used to detect whether authors convey the same stance. When authors express the same attitude towards two objectives, the consistency test label is recorded as 1; otherwise, it is recorded as 0. Encoded sentence representation, Used to separate targets Harmony ; An empty matrix is ​​introduced to store consistency detection information between targets.

5. The method according to claim 4, characterized in that, The consistency detection module calculates according to the following formula: in , , , , It is an activation function. training set small batches, Represents the true labels used for consistency testing. It is an index of the data sample; This represents the probability of a consistent class.

6. The method according to claim 1, characterized in that, The comparative learning module performs comparative learning on the data after consistency detection, including: Given a mini-batch of samples Hidden vectors in Those with the same stance labels ∈ The anchor is considered a positive example, while other samples are considered negative examples.

7. The method according to claim 6, characterized in that, The comparison learning module is calculated according to the following formula: in If and only if The time is 1 and They are and Stance tags Indicates temperature parameter; , For the hidden vector, To detect losses at the position, For consistency detection, compare the loss.

8. The method according to claim 1, characterized in that, During the training phase, the model is trained using cross loss, assigning different weights to each loss to minimize the joint loss.

9. A multi-target position detection system based on contrastive learning and consistency detection, characterized in that, include: The preprocessing module is used to acquire a multi-target position detection dataset and preprocess the multi-target position detection dataset. The model building module is used to build and train a multi-target position detection model; The multi-target stance detection model includes an encoder module, a consistency detection module, a contrastive learning module, and a joint training module. The joint training module performs joint training on the preprocessed dataset. Joint training includes swapping target pairs in one dataset and concatenating them with the original dataset, and concatenating datasets of related target pairs together to form the final dataset. The encoder module uses a BERT-BiLSTM encoder to encode the dataset processed by the joint training module, obtaining hidden contextual information between words. The consistency detection module performs similarity detection on the encoded data, learning semantic information between targets. The contrastive learning module performs contrastive learning on the consistency-detected data. The joint training module is also used to train multiple target pair datasets on a single model, enabling the model to learn domain-specific information related to the datasets. The detection module is used to perform multi-target position detection on the preprocessed data using the trained multi-target position detection model.

Citation Information

Patent Citations

  • Standard detection method based on multi-task learning

    CN114638195A

  • Sample vertical field detection method and device based on hierarchical comparative learning

    CN116414979A