Multi-target group classification method for social media content

By employing a multi-target group classification method for social media content and utilizing pre-trained language models and target-aware contrastive learning, this approach addresses the issue of unsatisfactory multi-target stance detection performance in specialized domains, achieving efficient group tendency analysis and accurate target detection.

CN117094835BActive Publication Date: 2026-11-27PEOPLE CN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311035552.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2023-05-24
Filing Date
2023-08-16
Publication Date
2026-11-27
Estimated Expiration
2043-08-16

AI Technical Summary

Technical Problem

Existing technologies are not ideal for multi-target position detection in specialized fields, making it difficult to analyze network users' tendencies and positions from a more macro perspective.

Method used

We employ a multi-target group classification method for social media content, including target indicator detection, target relevance detection, and target sentiment analysis. We utilize pre-trained language models and contrastive learning of target perception, and improve the accuracy of target semantic delivery and sentiment analysis through inter-layer dynamic routing and attention mechanisms.

Benefits of technology

It improves the accuracy of group classification, effectively detects the tendency of abstract targets, and enhances detection efficiency and accuracy. It is suitable for multi-target group classification of social media content.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117094835B_ABST
    Figure CN117094835B_ABST
Patent Text Reader

Abstract

The application discloses a multi-target group classification method for social media content. The application first detects the determiner of each target from the training corpus to form the text description of each target; then target relevance detection and target tendency analysis are carried out in turn, the former is used to detect the relevance of the text to each target, and the latter is used to predict the tendency of the text to each relevant target. In target relevance detection, target embedding attention is used to establish semantic interaction between the text and each level target, and through inter-layer target dynamic routing and one-level relevance attention, various forms of inter-level information transmission are modeled. In target tendency analysis, the text is mapped into prompts combined with templates, and the linguistic knowledge in the pre-trained language model is fully utilized; target-aware contrastive learning is used to promote model training. Experimental results prove that the application can effectively identify the group categories of social media content on multiple targets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, specifically relating to a multi-target group classification method for social media content, which is used in the fields of stance detection and public opinion analysis. Background Technology

[0002] With the rapid development and popularization of information technology, online social media has become an important arena for public opinion, generating massive amounts of personalized content daily. Analyzing the stance of text content on social media towards specific targets is therefore crucial. It helps public opinion managers quickly grasp current trends, make corresponding decisions, and conduct targeted interventions and guidance. Current techniques for stance detection can be broadly categorized into single-target stance detection, multi-target stance detection, and cross-target stance detection.

[0003] Single-objective stance detection aims to identify an author's attitude towards a single objective (e.g., "support," "oppose," "neutrality," etc.). Its core steps typically include text representation learning, objective representation learning, and stance classification. Many studies also integrate objective semantics into the text representation learning process to obtain objective-specific text representations. In a single text, an author may express opinions on multiple objectives. Multi-objective stance detection determines the author's stance on multiple given objectives. Existing methods can be broadly categorized into independent objective detection and joint objective detection. The former trains a separate model for each objective for classification and prediction, essentially dividing multi-objective stance detection into multiple single-objective stance detections. The latter trains the same model for all objectives, resulting in lower training costs and wider application scenarios. Cross-objective stance detection aims to predict stances on objectives not present during training (called "final objectives"). Therefore, it requires establishing a connection between the source objective (i.e., the objective in the training samples) and the final objective. Cross-objective stance detection based on transfer learning leverages the common themes contained in the source and final objectives to perform knowledge transfer and enhance representation learning.

[0004] The targets in the aforementioned stance detection methods are mostly specific entities or events. These methods or tasks are designed for specific objects in general domains and can effectively detect the stance and attitude of online text towards specific entities or events. However, their performance may not be ideal when applied to specialized domains. Summary of the Invention

[0005] In response to the limitations of existing technologies and the need for improvement, this invention provides a multi-target group classification method for social media content. The purpose is to achieve a multi-target group classification method that is independent of specific entities or events, thereby enabling the analysis of online users' tendencies and stances from a more macro perspective.

[0006] To achieve the above objectives, this invention provides a multi-target group classification method for social media content, including a target indicator detection step, a target relevance detection step, and a target bias analysis step. The target relevance detection step includes text and target encoding, first-level target embedding attention, first-level target relevance classification, inter-layer target dynamic routing, second-level target embedding attention, first-level relevance attention, second-level target relevance classification, and training and testing networks. The target bias analysis step includes input template mapping, text encoding, contrastive learning of target perception, target bias classification, and training and testing networks.

[0007] (1) Target indicator word detection step: Using a probabilistic statistical method, the most relevant words to each target are automatically detected from the training corpus, thereby converting the abstract target concept into a concrete lexical description; including the following sub-steps:

[0008] (1-1) Perform word segmentation on all texts in the training corpus;

[0009] (1-2) Let the set of two-level objectives be denoted as . T1 and T2 are the sets of first-level and second-level targets, respectively, and n1 and n2 are the numbers of first-level and second-level targets, respectively. For level l (l = 1, 2) targets... Select from the training corpus The relevant texts form a corpus c r The rest are the same as Unrelated texts form a corpus c u ;

[0010] (1-3) for c r and c u Sort all the words in c, and a word is in c. r The higher the importance of c u The lower the importance of a word, the higher its ranking; the top k words are selected as the target words. Indicative words.

[0011] (2) Target Relevance Detection Step: Since a text typically only involves some of the targets in T, this step detects the relevance of the text to each target, obtaining the relevance of the text to the targets at each level. and irrelevant targets For each text, target relevance detection includes the following steps:

[0012] (2-1) Text and target encoding: Encode the text and target using a pre-trained language model to obtain vectorized representations of the text and target, including the following sub-steps:

[0013] (2-1-1) Convert the text and target into the input form of the pre-trained language model. For the text, add special words before and after the text:

[0014] [CLS]Text[SEP]

[0015] For the target, use a combination of indicator words as the text description of the target, and add special words between each indicator word:

[0016] [CLS] Demonstrate 1 [SEP] Demonstrate 2 [SEP]... [SEP] Demonstrate k [SEP]

[0017] (2-1-2) The converted text and the target are respectively input into two pre-trained language models BERTweet to capture deep contextual semantic features;

[0018] (2-1-3) Extract the representation of each word in the text from the last layer of the pre-trained language model. (where m is the number of words in the text and d represents the vector dimension), the vector corresponding to [CLS] is taken as the target representation. In addition, the representation of each indicator word of the primary target is extracted.

[0019] (2-2) First-level target embedding attention: Establish semantic interaction between the text and the first-level target to obtain the text representation perceived by the first-level target. For each text, the first-level target embedding attention includes the following sub-steps:

[0020] (2-2-1) Calculate the cosine similarity matrix between words in the text and the primary target. Each element in G

[0021]

[0022] (2-2-2) Perform convolution on G to measure the relevance between a text window of length 2r+1 and the target. For a text window G centered at position l with length 2r+1... l-r:l+r ,calculate

[0023] u l =ReLU(w f G l-r:l+r +b f )

[0024] in, For learnable parameters of a neural network, Extract u l The maximum value in:

[0025] v l =MaxPooling(ul )

[0026] Move the text window by a step size of 1 to get

[0027] (2-2-3) Normalize v to obtain the attention weight of each word in the text, and perform a weighted summation of the word representation vectors according to the weights to obtain the text representation of the first-level target perception:

[0028] α = softmax(v)

[0029]

[0030] (2-3) First-level target relevance classification: The text representation perceived by the first-level target is input into a two-layer feedforward network, and the probability of the text being related to each first-level target is obtained through the sigmoid function:

[0031]

[0032] in, All parameters are learnable, and f is the activation function. Let represent the probability that the text is related to the i-th primary objective.

[0033] (2-4) Inter-layer dynamic routing of targets: Secondary targets are different aspects of their respective primary targets, and the indicators of primary targets can also be seen as descriptions of the corresponding targets from different perspectives. Therefore, there is a correlation between the indicators of primary targets and their corresponding secondary targets. The information transfer between the two is established through inter-layer dynamic routing, including the following sub-steps:

[0034] (2-4-1) Initialize the secondary target embedding obtained from dynamic routing The coupling coefficient b between the i-th indicator of a primary objective and the j-th secondary objective under that primary objective. ij =0;

[0035] (2-4-2) Embed p with first-level target indicator words i Embedded with corresponding secondary targets Vector dot product update b ij :

[0036]

[0037] (2-4-3) Use the softmax function to adjust b ij Normalize,

[0038]

[0039] (2-4-4) with βij We perform a weighted sum on the embeddings of the first-level target indicators to obtain the intermediate representation of the second-level target embeddings:

[0040]

[0041] (2-4-5) e j The secondary target embedding is obtained after applying a nonlinear squash function:

[0042]

[0043] (2-4-6) Repeat steps (2-4-2) to (2-4-5) z times, until the final result is obtained. This refers to the second-level target embedding obtained from dynamic routing.

[0044] (2-5) Second-level target embedding attention: There are now two types of second-level target embeddings. One is the one obtained by encoding the indicator words in step (2-1). One type is obtained from the dynamic routing of inter-layer targets in steps (2-4). For these two types of secondary target embeddings, perform operations similar to step (2-2) to establish semantic interaction between the text and the secondary targets, thereby obtaining text representations perceived by the two types of secondary targets. and

[0045] (2-6) First-level relevance attention: Because the number of first-level targets is relatively small, relevance prediction is easier and more accurate. Therefore, the results of first-level relevance prediction can be introduced into the second-level relevance prediction process to help improve the accuracy of second-level relevance prediction. Using first-level relevance attention to achieve the above motivation includes the following sub-steps:

[0046] (2-6-1) Using the first-level target-related probabilities obtained in step (2-3) As the weights, perform a weighted sum on the embeddings of the first-level targets:

[0047]

[0048] (2-6-2) Calculate the cosine similarity between d and the word embedding in the text, and normalize it using the softmax function to obtain the attention weight α for each word. i :

[0049]

[0050] (2-6-3) Perform a weighted summation operation on the text word embeddings based on the attention weight of each word to obtain the text representation perceived by the first-level relevance prediction results:

[0051]

[0052] (2-7) Secondary target relevance classification: Text representation that integrates two types of secondary target perception and the text representation of the first-order correlation prediction results Using a feedforward neural network, the prediction of secondary target relevance includes the following sub-steps:

[0053] (2-7-1) Use a gating mechanism to calculate the contribution of the three text representations to the final prediction:

[0054]

[0055]

[0056]

[0057] in, These are learnable parameters;

[0058] (2-7-2) Calculate the final text representation based on the gating coefficients of the three text representations:

[0059]

[0060] Where ⊙ represents element-wise multiplication of the vector elements;

[0061] (2-7-3) Using text representations as input, a feedforward neural network is used to predict the probability that the text is associated with each secondary objective:

[0062]

[0063] in, All parameters are learnable, and σ is the activation function. Let represent the probability that the text is related to the i-th secondary target.

[0064] (2-8) Training and testing the network: based on the predicted target relevance probability The probability y related to the true target 1 y 2 A loss function is constructed, and then the backpropagation (BP) algorithm is used to train the network to minimize the loss function. After training, text from the test set is input to obtain the relevant targets for each test sample.

[0065] (3) Target propensity analysis steps: Using a prompt template-based text encoding method, predict text pairs. The target preference is determined for each secondary relevant objective. For each text, objective preference analysis includes the following sub-steps:

[0066] (3-1) Input template mapping: Given a template And a related objective, the input text x inp and related target indicator x ind Mapped to prompt text x prompt :

[0067]

[0068] (3-2) Text Encoding: Encode the prompt text x prompt Input the pre-trained language model RoBERTa to capture deep contextual semantic features, and extract the hidden vector corresponding to [MASK] from the last layer of the pre-trained language model as the text representation:

[0069] s=h [MASK]

[0070] (3-3) Target-Aware Contrastive Learning: To make the vector representations of texts with the same tendency category as close as possible, and the vector representations of texts with different tendency categories as far apart as possible, while encouraging the model to pay more attention to target information, comparative learning of target perception is performed. For each text x in a training batch... i Contrastive learning for target perception includes the following sub-steps:

[0071] (3-3-1) Given a training batch, with x i Texts with the same tendency category and the same goal are used as x i Positive examples, and x i Texts with different biases or different goals are used as x i Negative examples;

[0072] (3-3-2) Let x be... i The target is t i The vector is represented as s i Calculate the contrastive learning loss for target perception:

[0073]

[0074]

[0075] Where B is the training batch size, P(i) = {j | i ≠ j, t} i =t j y i =y j}, B(i)={1,2,...,B}\{i}, τ is the temperature coefficient;

[0076] (3-4) Target Preference Classification: Based on the text representation obtained in step (3-2), a feedforward network is used to predict the text's preference category for a given target. To take advantage of the ordinal nature of preference categories, a steep-breaking method is used in the prediction process. For each text, target preference classification includes the following sub-steps:

[0077] (3-4-1) Input the text representation into the feedforward network and pass it through the sigmoid function:

[0078] a=σ(W2f(W1s+b1)+b2)

[0079] Where W1, W2, b1, b2 are learnable parameters, and f is the activation function. Each dimension of a i It is a decision boundary, representing the proportion of the probability of class i in the probabilities of all subsequent classes ({j|j≥i});

[0080] (3-4-2) Use the steep-breaking method to convert the output of the feedforward network into a probability distribution.

[0081]

[0082]

[0083]

[0084] This represents the probability that the text's tendency toward a given target belongs to the i-th class;

[0085] (3-5) Training and testing the network: based on the predicted probabilities of the biased class. A loss function is constructed using the true bias label, and combined with the target-aware contrastive learning loss. The backpropagation (BP) algorithm is used to train the network to minimize the loss function. After training, text from the test set is input to obtain the tendency category of each test sample for each relevant target.

[0086] Preferably, in steps (1-3), the weighted log-odds-ratio method with Dirichlet prior is used to analyze the corpus c. r and c u The specific steps to sort the words in the text are as follows:

[0087] The difference in frequency of word w between the two corpora was calculated using a weighted log ratio with Dirichlet prior:

[0088]

[0089]

[0090] Where, n r For corpus c r The number of words in n u Corpus c u The number of Chinese words The word w in the corpus c r c u The number of times it appears in the text; n0 is the number of words in the background corpus. The number of times word w appears in the background corpus.

[0091] Calculate the variance of the logarithmic ratio, and finally calculate the Z-score for word w:

[0092]

[0093]

[0094] Z w The higher the level of the descriptive word w in the corpus c r China and Vietnam are important, and in the corpus c u China and Vietnam are not important. According to Z w For corpus c r c u Sort all words and take the top k words as indicator words.

[0095] Preferably, in step (2-1), the pre-trained language model uses BERTweet; in step (3-2), the pre-trained model uses RoBERTa. BERTweet and RoBERTa use different corpora during pre-training, but employ the same training process and have the same model structure. Both are based on multi-layer stacking of transformer encoders, with each encoding layer containing two sub-layers: multi-head self-attention and a feedforward network. Each sub-layer includes residual connections and layer normalization. The formula for multi-head self-attention is as follows:

[0096] O = [head1, ..., head] h W o

[0097]

[0098] Q i =XW i,Q K i =XW i,K V i =XW i,V

[0099] Where h is the number of attention heads, They are input and output, respectively. These are trainable parameters.

[0100] Preferably, step (2-4) uses inter-layer target dynamic routing to establish the interaction between first-level target indicators and second-level targets, summarizes the semantics of first-level target indicators from different perspectives, and realizes the transmission of target semantic information from first-level to second-level.

[0101] Preferably, in steps (2-8), to address the problem of imbalanced relevance categories—that is, the number of irrelevant texts under each target far exceeds the number of relevant texts—the training set of texts irrelevant to all targets is downsampled during training, with a downsampling rate of r. The prediction loss function uses a weighted binary cross-entropy loss function. To improve the representation of secondary targets... To better represent the semantic information of the target, regularization is applied. The input classifier is expected to distinguish between different target representations, and the cross-entropy loss predicted by the classifier is used as the target regularization loss. Therefore, the loss of the target relevance detection network can be expressed as follows:

[0102]

[0103]

[0104]

[0105] Where λ1 and λ2 are the balance parameters among the three types of losses. The loss is the relevance classification loss for the i-th level target. Let N be the target regularization loss, and N be the number of training samples. The positive example loss weight for the k-th target at level i is calculated as follows:

[0106]

[0107] in, These represent the number of relevant and irrelevant texts for the k-th target at level i, respectively.

[0108] Optionally, step (2) can simultaneously predict the relevance of the text to both levels of objectives. If there is only one level of objective, steps (2-4) to (2-7) can be omitted, that is, only the relevance of the text to each level of objective can be detected.

[0109] Preferably, step (3-1) uses a template to map the input to a natural language prompt containing the special word [MASK], which reduces the difference between the fine-tuning and pre-training stages and helps to stimulate the linguistic knowledge in the pre-trained language model.

[0110] Preferably, in step (3-3), target information is introduced into the contrastive learning. Only texts with the same tendency category and the same target can be used as positive examples, guiding the model to pay more attention to target information, thereby better capturing the tendency features for different targets.

[0111] Preferably, in steps (3-4), a steep-breaking method is used to take advantage of the sequential nature of the preference categories. The network's output vector is not a direct probability distribution; each dimension is a decision boundary, representing the proportion of that category's probability among all subsequent categories. Based on this, the network output is transformed into a probability distribution.

[0112] Preferably, in steps (3-5), the loss function is the cross-entropy loss function. The loss of the target propensity analysis network can be expressed as follows:

[0113]

[0114]

[0115] Where γ is the balance parameter between the two losses, N is the number of training samples, and y j,k , Let be the true probability and the predicted probability, respectively, that the j-th text belongs to the k-th sentiment category.

[0116] In summary, compared with the prior art, the above-described technical solutions conceived by this invention can achieve the following beneficial effects:

[0117] (1) High accuracy of group classification: The model first eliminates targets not mentioned in the text through target relevance detection, avoiding biased detection of irrelevant targets, which can improve detection efficiency and accuracy; the inter-layer dynamic routing and first-level relevance attention in target relevance detection realize the transfer of target semantics and relevance prediction results from the first level to the second level, which helps to improve the accuracy of second-level relevance detection; in target bias analysis, the use of prompt templates and target perception contrast learning is conducive to mining the linguistic knowledge in the pre-trained language model, prompting the model to pay attention to target information, thereby improving the performance of target bias analysis.

[0118] (2) Capable of detecting tendencies in abstract target concepts: This invention proposes a target indicator word detection method, which automatically extracts some words most relevant to the target from the training corpus based on word frequency comparison as indicator words. This is particularly effective for abstract target scenarios, as it can transform abstract target concepts into concrete text descriptions. At the same time, compared with manually defined target interpretations, the indicator words detected by this method are more consistent with the way social media content describes target concepts, which is more conducive to semantic matching and semantic understanding by the model. Attached Figure Description

[0119] Figure 1 This is a flowchart illustrating a multi-target group classification method for social media content in an embodiment of the present invention. Detailed Implementation

[0120] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. Furthermore, the technical features involved in the various embodiments of this invention described below can be combined with each other as long as they do not conflict with each other.

[0121] like Figure 1 As shown, this invention provides a multi-target group classification method for social media content, including a target indicator word detection step, a target relevance detection step, and a target preference analysis step. The target relevance detection step includes text and target encoding, first-level target embedding attention, first-level target relevance classification, inter-layer target dynamic routing, second-level target embedding attention, first-level relevance attention, second-level target relevance classification, and training and testing networks. The target preference analysis step includes input template mapping, text encoding, target-aware contrastive learning, target preference classification, and training and testing networks. The overall idea of ​​this invention's multi-target group classification method for social media content is that it first detects indicator words for each target from a training corpus, converting abstract target concepts into concrete text descriptions; then, based on the semantic interaction between text and targets, it detects the relevance between text and each target, obtaining the relevant targets involved in the text; finally, based on cue templates and contrastive learning, it analyzes the text's preference for each relevant target.

[0122] like Figure 1 As shown, the present invention provides a multi-target group classification method for social media content, comprising the following steps:

[0123] (1) Target indicator word detection step: Using a probabilistic statistical method, the most relevant words to each target are automatically detected from the training corpus, thereby transforming the abstract target concept into a concrete lexical description. This step includes the following sub-steps:

[0124] (1-1) Perform word segmentation on all texts in the training corpus;

[0125] (1-2) Let the set of two-level objectives be denoted as . T1 and T2 are the sets of first-level and second-level targets, respectively, and n1 and n2 are the numbers of first-level and second-level targets, respectively. For level l (l = 1, 2) targets... Select from the training corpus The relevant texts constitute the corpus c r The rest are the same as Unrelated texts constitute a corpus c u ;

[0126] (1-3) for c r and c u Sort all the words in c, and a word is in c. r The higher the importance of c u The lower the importance of a word, the higher its ranking; the top k words are selected as the target. Indicative words.

[0127] (2) Figure 1 As shown, the target relevance detection step is as follows: Since a text typically only involves a portion of the targets in T, this step detects the relevance of the text to each target, obtaining the relevance of the text to the targets at each level. and irrelevant targets For each text, target relevance detection includes the following steps:

[0128] (2-1) Text and target encoding: Encode the text and target using a pre-trained language model to obtain vectorized representations of the text and target, including the following sub-steps:

[0129] (2-1-1) Convert the text and target into the input form of the pre-trained language model. For the text, add special words before and after the text:

[0130] [CLS]Text[SEP]

[0131] For the target, use a combination of indicator words as the text description of the target, and add special words between each indicator word:

[0132] [CLS] Demonstrate 1 [SEP] Demonstrate 2 [SEP]... [SEP] Demonstrate k [SEP]

[0133] (2-1-2) The converted text and the target are respectively input into two pre-trained language models BERTweet to capture deep contextual semantic features;

[0134] (2-1-3) Extract the representation of each word in the text from the last layer of the pre-trained language model. (where m is the number of words in the text and d represents the vector dimension), the vector corresponding to [CLS] is taken as the target representation. In addition, the representation of each indicator word of the primary target is extracted.

[0135] (2-2) First-level target embedding attention: Establish semantic interaction between the text and the first-level target to obtain the text representation perceived by the first-level target. For each text, the first-level target embedding attention includes the following sub-steps:

[0136] (2-2-1) Calculate the cosine similarity matrix between words in the text and the primary target. Each element in G

[0137]

[0138] (2-2-2) Perform convolution on G to measure the relevance between a text window of length 2r+1 and the target. For a text window G centered at position l with length 2r+1... l-r:l+r ,calculate

[0139] u l =ReLU(w f G l-r:l+r +b f )

[0140] in, For learnable parameters of a neural network, Extract u l The maximum value in:

[0141] v l =MaxPooling(u l )

[0142] Move the text window by a step size of 1 to get

[0143] (2-2-3) Normalize v to obtain the attention weight of each word in the text, and perform a weighted summation of the word representation vectors according to the weights to obtain the text representation of the first-level target perception:

[0144] α = softmax(v)

[0145]

[0146] (2-3) First-level target relevance classification: The text representation perceived by the first-level target is input into a two-layer feedforward network, and the probability of the text being related to each first-level target is obtained through the sigmoid function:

[0147]

[0148] in, All parameters are learnable, and f is the activation function. Let represent the probability that the text is related to the i-th primary objective.

[0149] (2-4) Inter-layer dynamic routing of targets: Secondary targets are different aspects of their respective primary targets, and the indicators of primary targets can also be seen as descriptions of the corresponding targets from different perspectives. Therefore, there is a correlation between the indicators of primary targets and their corresponding secondary targets. The information transfer between the two is established through inter-layer dynamic routing, including the following sub-steps:

[0150] (2-4-1) Initialize the secondary target embedding obtained from dynamic routing The coupling coefficient b between the i-th indicator of a primary objective and the j-th secondary objective under that primary objective. ij =0;

[0151] (2-4-2) Embed p with first-level target indicator words i Embedded with corresponding secondary targets Vector dot product update b ij :

[0152]

[0153] (2-4-3) Use the softmax function to adjust b ij Normalize,

[0154]

[0155] (2-4-4) with β ij We perform a weighted sum on the embeddings of the first-level target indicators to obtain the intermediate representation of the second-level target embeddings:

[0156]

[0157] (2-4-5) e j The secondary target embedding is obtained after applying a nonlinear squash function:

[0158]

[0159] (2-4-6) Repeat steps (2-4-2) to (2-4-5) z times, until the final result is obtained. This refers to the second-level target embedding obtained from dynamic routing.

[0160] (2-5) Second-level target embedding attention: There are now two types of second-level target embeddings. One is the one obtained by encoding the indicator words in step (2-1). One type is obtained from the dynamic routing of inter-layer targets in steps (2-4). For these two types of secondary target embeddings, perform operations similar to step (2-2) to establish semantic interaction between the text and the secondary targets, thereby obtaining text representations perceived by the two types of secondary targets. and

[0161] (2-6) First-level relevance attention: Because the number of first-level targets is relatively small, relevance prediction is easier and more accurate. Therefore, the results of first-level relevance prediction can be introduced into the second-level relevance prediction process to help improve the accuracy of second-level relevance prediction. Using first-level relevance attention to achieve the above motivation includes the following sub-steps:

[0162] (2-6-1) Using the first-level target-related probabilities obtained in step (2-3) As the weights, perform a weighted sum on the embeddings of the first-level targets:

[0163]

[0164] (2-6-2) Calculate the cosine similarity between d and the word embedding in the text, and normalize it using the softmax function to obtain the attention weight α for each word. i :

[0165]

[0166] (2-6-3) Perform a weighted summation operation on the text word embeddings based on the attention weight of each word to obtain the text representation perceived by the first-level relevance prediction results:

[0167]

[0168] (2-7) Secondary target relevance classification: Text representation that integrates two types of secondary target perception and the text representation of the first-order correlation prediction results Using a feedforward neural network, the prediction of secondary target relevance includes the following sub-steps:

[0169] (2-7-1) Use a gating mechanism to calculate the contribution of the three text representations to the final prediction:

[0170]

[0171]

[0172]

[0173] in, These are learnable parameters;

[0174] (2-7-2) Calculate the final text representation based on the gating coefficients of the three text representations:

[0175]

[0176] Where ⊙ represents element-wise multiplication of the vector elements;

[0177] (2-7-3) Using text representations as input, a feedforward neural network is used to predict the probability that the text is associated with each secondary objective:

[0178]

[0179] in, All parameters are learnable, and σ is the activation function. Let represent the probability that the text is related to the i-th secondary target.

[0180] (2-8) Training and testing the network: based on the predicted target relevance probability The probability y related to the true target 1 y 2 A loss function is constructed, and then the backpropagation (BP) algorithm is used to train the network to minimize the loss function. After training, text from the test set is input to obtain the relevant targets for each test sample.

[0181] (3) Figure 1 As shown, the steps of target preference analysis are as follows:

[0182] Predict text pairs using a prompt-based text encoding method. The target preference is determined for each secondary relevant objective. For each text, objective preference analysis includes the following sub-steps:

[0183] (3-1) Input template mapping: Given a template And a related objective, the input text x inp and related target indicator x ind Mapped to prompt text x prompt :

[0184]

[0185] (3-2) Text Encoding: Encode the prompt text x prompt Input the pre-trained language model RoBERTa to capture deep contextual semantic features, and extract the hidden vector corresponding to [MASK] from the last layer of the pre-trained language model as the text representation:

[0186] s = h [MASK]

[0187] (3-3) Contrastive learning of goal perception:

[0188] To ensure that the vector representations of texts with the same tendency category are as close as possible, and the vector representations of texts with different tendency categories are as far apart as possible, while simultaneously encouraging the model to focus more on target information, comparative learning for target perception is employed. For each text x within a training batch... i Contrastive learning for target perception includes the following sub-steps:

[0189] (3-3-1) Given a training batch, with x i Texts with the same tendency category and the same goal are used as x i Positive examples, and x i Texts with different biases or different goals are used as x i Negative examples;

[0190] (3-3-2) Let x be... i The target is t i The vector is represented as s i Calculate the contrastive learning loss for target perception:

[0191]

[0192]

[0193] Where B is the training batch size, P(i) = {j | i ≠ j, t} i =t j y i =y j}, B(i)={1,2,...,B}\{i}, τ is the temperature coefficient;

[0194] (3-4) Target Preference Classification: Based on the text representation obtained in step (3-2), a feedforward network is used to predict the preference category of the text for a given target. To take advantage of the orderliness of preference categories, a steep-breaking method is used in the prediction process.

[0195] For each piece of text, target preference classification includes the following sub-steps:

[0196] (3-4-1) Input the text representation into the feedforward network and pass it through the sigmoid function:

[0197] a=σ(W2f(W1s+b1)+b2)

[0198] Where W1, W2, b1, b2 are learnable parameters, and f is the activation function. Each dimension of a i It is a decision boundary, representing the proportion of the probability of class i in the probabilities of all subsequent classes ({j|j≥i});

[0199] (3-4-2) Use the steep-breaking method to convert the output of the feedforward network into a probability distribution.

[0200]

[0201]

[0202]

[0203] This represents the probability that the text's tendency toward a given target belongs to the i-th class;

[0204] (3-5) Training and testing the network: based on the predicted probabilities of the biased class. A loss function is constructed using the true bias label, and combined with the target-aware contrastive learning loss. The backpropagation (BP) algorithm is used to train the network to minimize the loss function. After training, text from the test set is input to obtain the tendency category of each test sample for each relevant target.

[0205] Those skilled in the art will readily understand that the above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A multi-target group classification method for social media content, characterized in that, It includes target indicator detection steps, target relevance detection steps, and target tendency analysis steps. The target relevance detection steps include text and target encoding, first-level target embedding attention, first-level target relevance classification, inter-layer target dynamic routing, second-level target embedding attention, first-level relevance attention, second-level target relevance classification, training and testing the network. The target bias analysis steps include input template mapping, text encoding, target-aware contrastive learning, target bias classification, training and testing the network, wherein: (1) Target indicator word detection step: Using a probabilistic statistical method, the most relevant words to each target are automatically detected from the training corpus, thereby converting the abstract target concept into a concrete lexical description. This includes the following sub-steps: (1-1) Perform word segmentation on all texts in the training corpus; (1-2) Let the set of two-level objectives be denoted as . T1 and T2 are the sets of primary and secondary targets, respectively, and n1 and n2 are the number of primary and secondary targets, respectively; for level l (l = 1, 2) targets Select from the training corpus The relevant texts constitute the corpus c r The rest are the same as Unrelated texts constitute a corpus c u ; (1-3) for c r and c u Sort all the words in c, and a word is in c. r The higher the importance of c u The lower the importance of a word, the higher its ranking; the top k words are selected as the target words. Indicative words; (2) Target Relevance Detection Step: Since a text typically only involves some of the targets in T, this step detects the relevance of the text to each target, obtaining the relevance of the text to the targets at each level. and irrelevant targets For each text, target relevance detection includes the following sub-steps: (2-1) Text and target encoding: Use a pre-trained language model to encode the text and target, obtaining the representation of each word in the text. m is the number of words in the text, and d represents the vector dimension; target representation And the representation of each indicator word of the primary target. Vectorized representations of text and targets; (2-2) First-level target embedding attention: x represented by text i First-level objectives are represented Using cosine similarity calculation and convolution operations as input, a semantic interaction between the text and the primary target is established, resulting in a text representation s of the primary target. 1 ; (2-3) First-level target relevance classification: The text representation perceived by the first-level target is input into a two-layer feedforward network, and the probability of the text being related to each first-level target is obtained through the sigmoid function: in, All parameters are learnable, and f is the activation function. Let represent the probability that the text is related to the i-th primary objective. (2-4) Inter-layer target dynamic routing: Secondary targets are different aspects of their respective primary targets. The indicator words of primary targets are seen as descriptions of the corresponding targets from different perspectives. Therefore, there is a correlation between the indicator words of primary targets and their corresponding secondary targets; p is represented by the indicator words of primary targets. i and secondary objectives Using this as input, information exchange between the two is established through dynamic routing between layers to obtain a new secondary target representation. (2-5) Second-level target embedding attention: There are now two types of second-level target embeddings. One is the one obtained by encoding the indicator words in step (2-1). One type is obtained from the dynamic routing of inter-layer targets in steps (2-4). For these two types of secondary target embeddings, target embedding attention is used to establish semantic interaction with the text, resulting in two types of text representations for secondary target awareness. and (2-6) First-level relevance attention: Since the number of first-level targets is relatively small, relevance prediction is easier and more accurate. Therefore, the results of first-level relevance prediction are introduced into the second-level relevance prediction process to help improve the accuracy of second-level relevance prediction. First-level relevance attention is used to achieve the above motivation, based on the relevance probability of the first-level targets obtained in step (2-3). The first-level target representation obtained in step (2-1) and text word representation x i For input, The weighted sum as a query, x i As keys and values, after attention operations, a textual representation of the first-level relevance prediction results is obtained. (2-7) Secondary target relevance classification: Applying a gating mechanism to fuse text representations of two secondary target perceptions and the text representation of the first-order correlation prediction results Then, a feedforward neural network is used to predict the probability of relevance to secondary targets. (2-8) Training and testing the network: based on the predicted target relevance probability The probability y related to the true target 1 ,y 2 Construct a loss function, then train the network using the backpropagation algorithm to minimize the loss function; after training, input the text in the test set to obtain the relevant targets for each test sample; (3) Target bias analysis steps: Using a prompt template-based text encoding method, predict text pairs The bias towards each secondary relevant objective in the text; for each text, objective bias analysis includes the following sub-steps: (3-1) Input template mapping: Given a template And a related objective, the input text x inp and related target indicator x ind Mapped to prompt text x prompt : (3-2) Text Encoding: Encode the prompt text x prompt Input the pre-trained language model RoBERTa to capture deep contextual semantic features, and extract the hidden vector corresponding to [MASK] from the last layer of the pre-trained language model as the text representation: s=h [MASK] (3-3) Target-aware contrastive learning: To make the vector representations of texts with the same tendency category as close as possible, and the vector representations of texts with different tendency categories as far apart as possible, while prompting the model to pay more attention to target information, contrastive learning of target perception is performed; for each text x in a training batch i Let its target be t. i , with x i Texts with the same tendency category and the same goal are used as x i Positive examples, and x i Texts with different biases or different goals are used as x i For negative examples, calculate the contrastive learning loss function. Where B is the training batch size, s i For text x i The vector representation of P(i) = {j | i ≠ j, t} i =t j ,y i =y j }, B(i)={1,2,…,B}\{i}, τ is the temperature coefficient; (3-4) Target Preference Classification: Based on the text representation s obtained in step (3-2), a feedforward network is used to predict the text's preference category for a given target, and the network output is converted into a probability distribution. (3-5) Training and testing the network: based on the predicted probabilities of the biased class. A loss function is constructed using the true bias label, and combined with the target-aware contrastive learning loss. The network is trained using the backpropagation (BP) algorithm to minimize the loss function. After training, text from the test set is input to obtain the tendency category of each test sample for each relevant target.

2. The multi-target group classification method for social media content as described in claim 1, characterized in that, In steps (1-3), a weighted logarithmic ratio method with Dirichlet prior is used to analyze the corpus c. r and c u The specific steps to sort the words in the text are as follows: The difference in frequency of word w between the two corpora was calculated using a weighted log ratio with Dirichlet prior: Where, n r For corpus c r The number of words in n u Corpus c u The number of Chinese words The word w in the corpus c r ,c u The number of times it appears in the text; n0 is the number of words in the background corpus. The number of times word w appears in the background corpus; Calculate the variance of the logarithmic ratio, and finally calculate the Z-score for word w: Z w The higher the level of the descriptive word w in the corpus c r China and Vietnam are important, and in the corpus c u China and Vietnam are not important; according to Z w For corpus c r ,c u Sort all words and take the top k words as indicator words.

3. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, Step (2-1) includes the following sub-steps: (2-1-1) Convert the text and target into the input form of the pre-trained language model; for the text, add special words before and after the text: [CLS]Text[SEP] For the target, use a combination of indicator words as the text description of the target, and add special words between each indicator word: [CLS] Demonstrate 1 [SEP] Demonstrate 2 [SEP]... [SEP] Demonstrate k [SEP] (2-1-2) The converted text and the target are respectively input into two pre-trained language models BERTweet to capture deep contextual semantic features; (2-1-3) Extract the representation of each word in the text from the last layer of the pre-trained language model. m is the number of words in the text, and d represents the vector dimension; the vector corresponding to [CLS] is taken as the target representation. In addition, the representation of each indicator word of the primary target is extracted.

4. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, The target embedding attention in steps (2-2) and (2-5) includes the following sub-steps: (2-2-1) Calculate the cosine similarity matrix between word representations and target representations in the text. Each element in G (2-2-2) Perform convolution on G to measure the correlation between a text window of length 2r+1 and the target; for a text window G centered at position l with length 2r+1... l-r:l+r ,calculate her l !!ReLU(w f G l-r:l+r +b f ) in, For learnable parameters of a neural network, Extract u l The maximum value in: v l =MaxPooling(u l ) Move the text window by a step size of 1 to get (2-2-3) Normalize v to obtain the attention weight of each word in the text, and perform a weighted sum of the word representation vectors according to the weights to obtain the target-aware text representation: α=softmax(v), 5. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, Step (2-4) includes the following sub-steps: (2-4-1) Initialize the secondary target embedding obtained from dynamic routing The coupling coefficient b between the i-th indicator of a primary objective and the j-th secondary objective under that primary objective. ij =0; (2-4-2) Embed p with first-level target indicator words i Embedded with corresponding secondary targets Vector dot product update b ij : (2-4-3) Use the softmax function to adjust b ij Normalize, (2-4-4) with β ij We perform a weighted sum on the embeddings of the first-level target indicators to obtain the intermediate representation of the second-level target embeddings: (2-4-5) e j The secondary target embedding is obtained after applying a nonlinear squash function: (2-4-6) Repeat steps (2-4-2) to (2-4-5) z times, until the final result is obtained. This refers to the second-level target embedding obtained from dynamic routing.

6. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, Step (2-6) includes the following sub-steps: (2-6-1) Using the first-level target-related probabilities obtained in step (2-3) As the weights, perform a weighted sum on the embeddings of the first-level targets: (2-6-2) Calculate the cosine similarity between d and the word embedding in the text, and normalize it using the softmax function to obtain the attention weight α for each word. i : (2-6-3) Perform a weighted summation operation on the text word embeddings based on the attention weight of each word to obtain the text representation perceived by the first-level relevance prediction results:

7. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, Step (2-7) includes the following sub-steps: (2-7-1) Use a gating mechanism to calculate the contribution of the three text representations to the final prediction: in, These are learnable parameters; (2-7-2) Calculate the final text representation based on the gating coefficients of the three text representations: Where ⊙ represents element-wise multiplication of the vector elements; (2-7-3) Using text representations as input, a feedforward neural network is used to predict the probability that the text is associated with each secondary objective: in, All parameters are learnable, and σ is the activation function. Let represent the probability that the text is related to the i-th secondary target.

8. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, In steps (2-8), to address the problem of imbalanced relevance categories, i.e., the number of irrelevant texts far exceeds the number of relevant texts, during training, texts in the training set that are irrelevant to all targets are downsampled at a rate of r; the prediction loss function uses a weighted binary cross-entropy loss function; to improve the representation of secondary targets... It can better represent the semantic information of the target, so it is regularized; The input classifier is expected to distinguish between different target representations, and the cross-entropy loss predicted by the classifier is used as the target regularization loss; the loss of the target relevance detection network is expressed as follows: Where λ1 and λ2 are the balance parameters among the three types of losses. The loss is the relevance classification loss for the i-th level target. Let N be the target regularization loss, and N be the number of training samples. The positive example loss weight for the k-th target at level i is calculated as follows: in, These represent the number of relevant and irrelevant texts for the k-th target at level i, respectively.

9. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, Step (3-4) includes the following sub-steps: (3-4-1) Input the text representation s into the feedforward network and pass it through the sigmoid function: a=σ(W2f(W1s+b1)+b2) Where W1, W2, b1, b2 are learnable parameters, and f is the activation function. Each dimension of a i It is a decision boundary, representing the proportion of the probability of class i in the probabilities of all subsequent classes ({j|j≥i}); (3-4-2) Use the steep-breaking method to convert the output of the feedforward network into a probability distribution. in, This represents the probability that the text's tendency toward a given target belongs to the i-th class.

10. The multi-target group classification method for social media content as described in claim 1 or 2, characterized in that, In steps (3-5), the cross-entropy loss function is used; the loss representation of the target bias analysis network is as follows: Where γ is the balance parameter between the two losses, and N is the number of training samples. Let be the true probability and the predicted probability, respectively, that the j-th text belongs to the k-th sentiment category.