Social bot detection method and system based on causal intervention and hybrid experts
By enhancing the graph Transformer encoder with causal intervention and hybrid expert mechanism, cross-environment invariant causal features are extracted, which solves the problem of declining generalization performance of social robot detection methods under changing data distribution. Stable cross-platform and cross-time period detection is achieved, and a unified cross-distribution verification standard is established.
Patent Information
- Application Number
- CN202511516143.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-23
- Publication Date
- 2025-12-23
- Estimated Expiration
- 2045-10-23
AI Technical Summary
Existing social bot detection methods suffer from reduced generalization performance when faced with changes in data distribution, making it difficult to effectively identify social bots across platforms and time periods, and lacking a unified cross-distribution verification standard.
A social robot detection method based on causal intervention and hybrid experts is adopted. It combines a pseudo-environment estimator and a graph Transformer encoder enhanced by hybrid expert mechanism. By extracting cross-environment invariant causal features, generating environment-aware weights using Gumbel-Softmax relaxation technique, and training the model with a joint optimization objective function, cross-environment stable detection is achieved.
It breaks through the bottleneck of out-of-distribution generalization, improves the stability and accuracy of the model in cross-environment detection, significantly enhances the cross-domain generalization ability of social robot detection, and establishes a complete OOD evaluation system.
Smart Images

Figure CN120996084B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of social robot detection technology, and in particular to a social robot detection method and system based on causal intervention and hybrid experts. Background Technology
[0002] Social bots pose a serious threat to social networking platforms. They manipulate public opinion, disrupt information dissemination, and engage in malicious advertising through automated interactions and the generation of deceptive content, thereby undermining the integrity of the online ecosystem. As social networks become increasingly complex, effectively identifying social bots has become a pressing research challenge. Meanwhile, social bots often act as "information amplifiers" in the dissemination of public opinion; their abnormally active interactions can mislead public perception, exacerbate information polarization, and even interfere with social governance and public policy formulation. Therefore, conducting research on social bot detection is not only helpful in maintaining the credibility and healthy development of social networks, but also of great significance for strengthening online public opinion supervision and ensuring social information security.
[0003] Most existing social bot detection methods assume that training and testing data come from the same environmental distribution. However, in real-world applications, the features of social platform data constantly evolve due to platform mechanism updates, changes in user behavior, and the emergence of new social trends. When a model cannot effectively adapt to these changes in environmental distribution, its generalization performance will significantly decline. For example, some features may have strong discriminative power on a specific platform or during a specific time period, but may become irrelevant or even misleading in different contexts. Cresci et al. pointed out that before 2015, features such as the number of likes and shares had strong discriminative power in social bot detection, but after 2015, the role of these features gradually weakened, and they even became potential interfering factors. To address this challenge, some researchers have attempted to improve the robustness and generalization ability of models through richer feature engineering and contrastive learning techniques.
[0004] However, methods based on feature extraction or contrastive learning typically still assume that the training and test data have a consistent distribution, making it difficult to capture key features that remain stable across different environments and are unaffected by external disturbances. This limitation reduces the model's cross-domain generalization ability. Summary of the Invention
[0005] To address the limitation that existing detection methods primarily focus on performance on a single dataset and neglect the critical challenge of out-of-distribution (OOD) generalization, this invention proposes a social robot detection method based on causal intervention and hybrid experts. It combines a pseudo-environment estimator with a graph Transformer (MoE-GT) encoder enhanced by a hybrid expert mechanism to extract robust causal features, thereby eliminating the interference of environmental confounding factors. By ensuring that the extracted features remain unchanged under distributional transfer, this causal inference framework significantly improves the model's generalization ability.
[0006] To achieve the above objectives, the technical solution adopted is:
[0007] This invention provides a social robot detection method based on causal intervention and hybrid experts, comprising the following steps:
[0008] Step 1: Obtain graph structure data of social networks, determine the real labels of accounts through expert annotation, and construct a graph with accounts as nodes based on interaction relationships;
[0009] Step 2: Construct the CausBot model, which includes a pseudo-environment estimator and a graph Transformer encoder enhanced by a hybrid expert mechanism;
[0010] Step 3: Estimate the potential environment distribution of each node using the pseudo-environment estimator, and generate environment-aware weights based on the Gumbel-Softmax relaxation technique;
[0011] Step 4: Using the graph Transformer encoder enhanced by the hybrid expert mechanism, under the control of the environment-aware weights, multi-level encoding of node features is performed to extract cross-environment invariant causal features.
[0012] Step 5: Train the CausBot model using a joint optimization objective function, while simultaneously optimizing the parameters of the pseudo-environment estimator and the graph Transformer encoder enhanced by the hybrid expert mechanism. The objective function includes a supervised loss term and a KL divergence regularization term.
[0013] Step 6: Extract causal features based on the trained CausBot model, estimate the bot probability of the input social network account node, and output the label of whether it is a bot by Softmax.
[0014] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, the specific implementation process of the pseudo-environment estimator in step 3 is as follows:
[0015] In the l In a layered graph Transformer, for nodes vHidden representation By performing linear mapping and normalization, the pseudo-environment probability distribution is obtained. :
[0016] ;in, A learnable environment-aware projection matrix. Represents a node v In the l Feature vectors after layer aggregation Represents a node v In the l The pseudo-environment probability distribution of the layer;
[0017] Nodes are generated using the Gumbel-Softmax relaxation technique. v In the l Layer k Environmental perception weight of each environmental factor :
[0018] ;in, It is random noise. , For temperature coefficient, when The output approaches discrete sampling when The time distribution degenerates into a uniform distribution; For the first l Layer nodes v Belongs to the k The probability distribution of each pseudo-environment.
[0019] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, the specific implementation process of the graph Transformer encoder enhanced by the hybrid expert mechanism in step 4 is as follows:
[0020] The first in each expert module l In the layer, for nodes v Features with neighboring nodes u Features Perform linear transformations respectively to generate query vectors. Key vector Sum value vector The calculation formula is:
[0021] ;in, Indicates a linear layer. They are the first l Learnable weight matrices for layered queries, keys, and values;
[0022] compute nodes vWith nodes u Attention coefficient between After activation using the LeakyReLU function, it is normalized using Softmax.
[0023] Based on attention coefficient The features of neighboring nodes are weighted and aggregated, and the outputs of multiple attention heads are computed in parallel and concatenated to obtain the node. v In the l Intermediate feature representation of the layer ;
[0024] Based on the environmental perception weights output by the pseudo-environment estimator ,right K The outputs of each expert module are weighted and fused to obtain the node. v In the l Feature representation of +1 layer .
[0025] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, further, the node v In the l Feature representation of +1 layer The calculation formula is:
[0026] ;in, For the first k The nodes output by each expert module v In the l Characteristics of the layer.
[0027] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, further, the joint optimization objective function in step 5 is... The expression is:
[0028] ; in, E Indicates a pseudo-environment. G Representing the graph structure, Indicates the predicted label, For pseudo-environment estimators, For predictors, As a priori distribution of the environment, For distribution in pseudo-environment The expected loss of supervision, For pseudo-environment distribution Prior distribution of the environment KL divergence, This is the balance coefficient.
[0029] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, the joint optimization objective function is further... The specific calculation method is as follows:
[0030] ;in, To determine the number of nodes in the training set, It is a node v The one-hot vector of the true label, It is the predicted probability distribution output by the model. L This represents the total number of layers in the Transformer graph. K For the number of pseudo-environment categories, For nodes v In the l Layer k Environmental perception weights of each environmental factor For the first l Layer nodes v Belongs to the k The probability distribution of each pseudo-environment.
[0031] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, the environmental prior distribution is further... Assuming a uniform distribution, the prior probability of each pseudo-environment is... .
[0032] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, the method further includes an out-of-distribution generalization testing strategy, including the following two modes:
[0033] CausBot-SD generates multiple pseudo-environments on a single dataset, with some pseudo-environment datasets used for training and in-distribution testing, and the rest used for out-of-distribution testing.
[0034] CausBot-MD: Uses multiple real-world datasets, one of which serves as the source domain for training and in-distribution testing, and the remaining datasets serve as the target domain for out-of-distribution generalization evaluation.
[0035] According to the social robot detection method based on causal intervention and hybrid experts of the present invention, the pseudo-environment is further generated in the CausBot-SD mode as follows:
[0036] By applying environment-specific perturbations to the original graph structure using a graph structure generator, multiple pseudo-environment graph data are generated:
[0037] ;in, For the generated first PGraph data in a pseudo-environment, This represents a graph structure generator based on the original graph data. This represents a noise generator based on an environment indicator vector. It is the first P The indicator vector of the pseudo-environment, when the node belongs to the first... P When there is a pseudo-environment, the corresponding position is 1, and the other positions are 0.
[0038] Furthermore, the present invention also provides a social robot detection system based on causal intervention and hybrid experts, comprising:
[0039] The data acquisition module is used to acquire graph structure data of social networks, determine the real labels of accounts through expert annotation, and construct a graph with accounts as nodes based on interaction relationships;
[0040] The model building module is used to build the CausBot model, which includes a pseudo-environment estimator and a graph Transformer encoder enhanced by a hybrid expert mechanism.
[0041] The environment estimation module is used to estimate the potential environment distribution of each node through the pseudo environment estimator and generate environment-aware weights based on the Gumbel-Softmax relaxation technique.
[0042] The feature encoding module is used to encode node features at multiple levels using the graph Transformer encoder enhanced by the hybrid expert mechanism, under the control of the environment-aware weights, in order to extract cross-environment invariant causal features.
[0043] The model training module is used to train the CausBot model using a joint optimization objective function, while optimizing the parameters of the pseudo-environment estimator and the graph Transformer encoder enhanced by the hybrid expert mechanism. The objective function includes a supervised loss term and a KL divergence regularization term.
[0044] The detection and prediction module is used to extract causal features based on the trained CausBot model, estimate the bot probability of the input social network account node, and output the label of whether it is a bot by Softmax.
[0045] The beneficial effects achieved by adopting the above technical solution are:
[0046] 1. Overcome the bottleneck of out-of-distribution generalization and improve the stability of cross-environment detection.
[0047] This invention is the first to explicitly focus on the out-of-distribution generalization problem in the field of social robot detection. By using a causal inference framework and a "backdoor adjustment" strategy, it effectively decouples environmental pseudo-correlation factors (such as platform-specific features and time-specific data bias) from cross-environment invariant causal features (such as abnormal robot interaction patterns and fixed network structures). This allows the model to maintain stable detection performance in data distribution migration scenarios (such as cross-platform and cross-time period detection), solving the problem of generalization performance degradation caused by environmental changes in traditional methods.
[0048] 2. Innovate model architecture to enhance feature extraction and global interaction capture capabilities.
[0049] We designed a graph Transformer (GT) encoder that integrates causal modeling and hybrid expert mechanism (MoE). Compared with the traditional GNN model, it can dynamically adjust the feature extraction strategy of multiple expert modules through MoE to adapt to feature differences in different environments. It can also accurately capture the complex global interactions and high-order dependencies between accounts by leveraging the multi-head self-attention mechanism of GT. This significantly improves the extraction accuracy of key features of social robots and its detection performance is superior to the comparison methods that do not introduce causal modeling.
[0050] 3. Establish a complete OOD assessment system and improve the verification standards for testing methods.
[0051] This paper constructs the first out-of-distribution (OOD) generalization evaluation protocol for social robot detection tasks, comprising two modes: "Generative Pseudo-Environment Validation (CausBot-SD)" and "Cross-Real-World Dataset Validation (CausBot-MD)". The former enhances environmental diversity by generating pseudo-environment datasets that simulate distribution shifts; the latter integrates multi-source real-world datasets to achieve systematic validation of cross-domain generalization capabilities. This system provides a standardized paradigm for OOD performance evaluation in the field of social robot detection, filling the gap in existing research that lacks a unified cross-distribution validation standard. Attached Figure Description
[0052] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings of the embodiments of the present invention will be briefly described below. The drawings are merely illustrative of some embodiments of the present invention and are not intended to limit the scope of the present invention to all embodiments.
[0053] Figure 1 This is a flowchart illustrating the social robot detection method based on causal intervention and hybrid experts according to an embodiment of the present invention.
[0054] Figure 2 This is a model framework diagram of CausBot according to an embodiment of the present invention;
[0055] Figure 3This is a comparison of the CausBot implementation of the present invention with existing social robot detection methods. Detailed Implementation
[0056] The exemplary solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Unless otherwise defined, the technical or scientific terms used in this invention should have the ordinary meaning understood by one of ordinary skill in the art.
[0057] Existing social robot detection methods typically optimize the likelihood function. This approach learns the representation of each account, but this optimization strategy is easily affected by environmental confounding factors. Inspired by causal inference theory, this invention aims to intervene through a strategy that... This helps to eliminate the influence of these environmental confounding factors, thereby improving the model's cross-distribution generalization ability.
[0058] This invention discloses a social robot detection method based on causal intervention and hybrid experts, such as... Figure 1 As shown, it includes the following:
[0059] Step S101: Obtain the graph structure data of the social network (including account attributes and text information, interaction edges such as following / forwarding between accounts), determine the true label Y of the account through expert annotation (label Y is used to identify whether the account is a social bot), and construct a graph with accounts as nodes based on the interaction relationship. ,in, Let E be the set of account nodes, and E be the set of interaction edges between accounts. Initial node characteristics... It consists of vectorized text and attribute information.
[0060] Step S102: Construct the CausBot model, which mainly consists of two modules: a pseudo-environment estimator and a hybrid expert mechanism-enhanced graph Transformer encoder (MoE-GT) (structure as follows). Figure 2 (As shown). Unlike traditional graph Transformer models, CausBot effectively decouples the interference of environmental confounding factors on detection performance through causal inference and a hybrid expert mechanism. This allows the model to rely more on causal relationships rather than just empirical correlations for judgment, thereby enhancing its generalization ability across different platforms or data distributions.
[0061] Step S103: Estimate the potential environment distribution of each node using the pseudo-environment estimator, and generate environment-aware weights based on the Gumbel-Softmax relaxation technique.
[0062] The CausBot framework introduces a learnable pseudo-environment estimator. This is used to estimate the latent environmental distribution of the training data to mitigate the influence of environment-specific confounding factors. Specifically, in the Graph Transformer (GT) process... In the layer, each node v Implicit context representation It is modeled as a latent variable and from the distribution Mid-sampling, of which K This represents the number of potential environmental factors in a social network. The parameters of this distribution are... The result is obtained by normalizing the node representation after nonlinear mapping in the current layer:
[0063]
[0064] in, A learnable environment-aware projection matrix. d The dimension of the feature vector; Represents a node v In the l Feature vectors after layer aggregation Represents a node v In the l The pseudo-environment probability distribution of the layer.
[0065] However, if sampling is directly taken from discrete environmental variables Due to its non-differentiability, the gradient backpropagation will be hindered. To overcome this limitation, this invention introduces the Gumbel-Softmax relaxation technique, which approximates the discrete sampling process with a differentiable continuous distribution, thereby ensuring the integrity of gradient propagation.
[0066] The core idea of Gumbel-Softmax is to inject data from the Gumbel distribution into the sampling process. random noise Subsequently, this noise is used to construct a continuous relaxation form of the discrete distribution, and the temperature coefficient is then used to... This allows for control, enabling efficient gradient-based optimization. Nodes are generated using the Gumbel-Softmax relaxation technique. v In the l Layer k Environmental perception weight of each environmental factor :
[0067]
[0068] Among them, temperature coefficient Dynamically control the degree of relaxation: when When the output approaches one-hot discrete sampling, and when... When this happens, the distribution will degenerate into a uniform distribution; For the first l Layer nodes v Belongs to the k The probability distribution of each pseudo-environment.
[0069] Step S104: The graph Transformer encoder enhanced by the hybrid expert mechanism performs multi-level encoding on node features under the control of the environment-aware weights to extract cross-environment invariant causal features.
[0070] First, we introduce causal modeling logic for the graph Transformer:
[0071] like Figure 3 As shown in the upper part, existing graph-based social robot detection methods typically optimize the likelihood function. To train the model to predict social graphs Is a certain account a bot (corresponding tag)? The optimization process can be represented as:
[0072]
[0073] in, This indicates sampling an environment from the training distribution. , Indicates the environment Below, diagram structure With tags The joint distribution of .
[0074] However, these methods may be affected by environmental variables (such as platform characteristics, like Twitter) on graph structures. With predictive labels The confounding effect can lead to spurious correlations.
[0075] To address this problem, this invention proposes an intervention-based training method, the optimization objective of which is the likelihood function under intervention. (like Figure 3 (lower half), in which This represents a causal intervention used to eliminate environmental variables. right The intervention can guide the model to focus on causal features that are stable across environments (such as anomalous behavior and network structure), while ignoring features that are sensitive to the environment (such as account registration time).
[0076] While the ideal intervention could be achieved by randomizing the graph structure, this is difficult to implement directly in large-scale experiments due to platform rules and ethical constraints. Therefore, this approach employs a causal framework based on backdoor adjustment and do-calculus to simulate the effects of the intervention.
[0077] By implementing interventions on social graphs Cut off the path The predicted distribution under intervention was derived:
[0078]
[0079] Formula (4) directly uses the law of total probability to decompose the predicted distribution under intervention into the distribution in each specific environment. The weighted average of intervention predictions, where the weights are the post-intervention environment. E Distribution .
[0080] Based on the action / observation exchange property of do-calculus, in the post-intervention graph From (i.e., from) All directed edges originating from this point are cut off, when the condition is met. Independent of the diagram When it is established (i.e. The conditional probability under intervention can be simplified to the observation conditional probability. Its form can be expressed as:
[0081]
[0082] Furthermore, based on the insertion / deletion properties of do-calculus, in the graph after intervention... (i.e., cut off all pointers) (the incoming edges), when the environment variable E is independent of the graph G, i.e. Environmental distribution will no longer depend on intervention operations.
[0083]
[0084] in, This represents the prior distribution of the environmental variable E (e.g., the sampling ratio of different environments in multi-platform data).
[0085] Substituting the above formulas (5) and (6) into the total probability formula (4), we can obtain the final expression for the intervention distribution:
[0086]
[0087] Introducing the variational distribution in step S103 Then, the objective function is updated to:
[0088]
[0089] Equation (8) is a transformation to prepare for the next step of applying Jensen's inequality, thereby simplifying the difficult-to-handle equation. The form is transformed into something that is easy to optimize. form.
[0090] Using Jensen's inequality, it can be decomposed into two parts: one part is used to optimize the model's predictive ability in variational environments, and the other part is used to regularize the environment distribution to make it consistent with the prior distribution.
[0091]
[0092] Jensen's inequality states that for a convex function (here, log) and a set of weights (here, ...), ... The weighted average of the function values is greater than or equal to the weighted average of the function values. Formula (9) applies this inequality, moving log to the summation symbol. in.
[0093] The right side of formula (9) can be further divided into two terms. The first term is the weighted reconstruction term, which requires the model to be reconstructed from the given terms. Accurate predictions can be made under different environmental weights. The second term is the KL regularization term, which is a variational distribution. With prior distribution The KL divergence between them.
[0094] Finally, through the above causal analysis, the joint optimization objective can be obtained:
[0095]
[0096] Formula (10) is the final expression of formula (9). This is a balancing coefficient used to adjust the weights between the two terms in the objective function. The first term on the right is the expected prediction loss, which encourages accurate predictions and forces the encoder to... and pseudo-environment estimator Collaborative work enables each input The assigned environment e This helps the model make the most accurate judgment. The second term on the right is the KL regularization term. Without this term, to minimize the loss of the first term, There is a possibility of taking shortcuts, such as assigning all samples to one environment, thus degenerating back to the traditional model. The KL term prevents this behavior.
[0097] The specific implementation process of the graph Transformer encoder enhanced by hybrid expert mechanisms is as follows:
[0098] In pseudo-environment estimator Based on this, this scheme proposes a MoE-enhanced graph Transformer encoder. This is to achieve environment-adaptive coding. The core idea is as follows: in the pseudo-environment estimator... Provided environmental representation Under the control of [the system], a self-centered graph for each node. Multi-level encoding is performed. The encoding process consists of... K The system is completed collaboratively by several expert modules, enabling dynamic adjustment of feature extraction strategies at different layers. In each layer, the input features are first encoded using a Graph Transformer (GT), and then output by a pseudo-environment estimator. The contributions of each expert are dynamically adjusted to achieve an effective integration of expert learning characteristics.
[0099] Specifically, guided by the pseudo-environment estimator, the MoE-enhanced GT encoding process is as follows:
[0100] Step a): In each expert module, the first... l In the layer, for nodes v Features with neighboring nodes u Features Perform linear transformations respectively to generate query vectors. Key vector Sum value vector The calculation formula is:
[0101]
[0102] in, Indicates a linear layer. They are the first l Learnable weight matrices for layered queries, keys, and values;
[0103] Step b): Compute nodes v With nodes u Attention coefficient between After activation using the LeakyReLU function, it is normalized using Softmax:
[0104]
[0105] Based on the above calculations, the node vThe features of its neighboring nodes are weighted and aggregated based on the attention coefficient. In the multi-head attention mechanism, multiple attention heads are computed in parallel, and the outputs of each attention head are concatenated. This process can be described as follows:
[0106]
[0107] in, Indicates the first The first in the layer i The output of each attention head; in This represents the initial characteristics of the account, which are formed by concatenating the account's tweet feature vector and attribute feature vector.
[0108] The MoE-enhanced GT encoding process involves each input being processed through... K Each expert module performs coding, and each expert module has an independent path to process the same input data. The output is determined based on the environment weights provided by the pseudo-environment estimator. Perform weighted fusion:
[0109]
[0110] in, Indicates the first l The node representation in layer +1 It consists of semantic and attribute information of the account, and its encoding method is the same as that used in BotRGCN.
[0111] Step S105: Train the CausBot model using a joint optimization objective function, while simultaneously optimizing the parameters of the pseudo-environment estimator and the graph Transformer encoder enhanced by the hybrid expert mechanism. The objective function includes a supervised loss term and a KL divergence regularization term.
[0112] During model training, a gradient-based optimization method is used to simultaneously optimize the pseudo-environment estimator. With GT predictor To define the prior distribution of the pseudo-environment. Assuming it follows a uniform distribution, that is, all K Each of the possible pseudo-environment categories has the same probability.
[0113] Based on the objective function derived from causal analysis (Formula 10), the loss function can be expressed as:
[0114]
[0115] in, To determine the number of nodes in the training set, LThis represents the total number of layers in the Transformer graph. K The first term represents the number of pseudo-environment categories (i.e., the total number of possible environments). Indicates monitoring losses, It is a node v The one-hot vector of the true label, It is a GT model enhanced by MoE. Output nodes v The predicted probability distribution. This term is essentially the cross-entropy loss. The second term is a regularization term based on KL divergence, which aims to constrain the estimated pseudo-environment distribution. With prior distribution The differences between them improve the stability and generalization ability of the model. Specifically, the formula... middle, For nodes v In the l Layer k The environmental perception weights of each environmental factor are obtained by Gumbel-Softmax sampling. For the first l Layer nodes v Belongs to the k The probability distribution of each pseudo-environment. It is a hyperparameter that controls the strength of the KL divergence regularization term.
[0116] Due to the assumption Following a uniform distribution, the prior probability of each pseudo-environment category is: ,then This regularization term characterizes the learned pseudo-environment distribution. With uniform prior distribution The differences between them guide the model to learn features that are relevant to the environment but more general, while avoiding overfitting to environment-specific noise.
[0117] In this scheme, the number of potential environmental factors of social networks K This is equal to the number of expert models in the hybrid expert mechanism. This design aims to achieve precise matching between "environment and expert", ensuring that each expert can specifically handle the features of the corresponding environment, and enabling the model to achieve distributed out-generalization, which is a key linkage design.
[0118] Step S106: Employ an out-of-distribution generalization testing strategy, including a generative pseudo-environment verification mechanism and a cross-domain verification mechanism, to evaluate the effectiveness of the model under out-of-distribution testing.
[0119] To evaluate the effectiveness of the proposed method under out-of-distribution (OOD) testing, this scheme introduces a "two-dimensional validation framework," including: (1) a generative pseudo-environment validation mechanism based on a single dataset (CausBot-SD); and (2) a cross-domain validation mechanism based on multiple real-world datasets (CausBot-MD). This setup follows common practices in graph OOD generalization research, namely, assuming that the environment label (such as dataset / domain identifier) of each training sample is known during the training phase, thereby performing environment-aware modeling; while during the OOD testing phase, no environment information needs to be used or provided. All baseline methods are trained and evaluated under exactly the same data partitioning and conditions to ensure fair comparison.
[0120] CausBot-SD: In social robot detection tasks, a single dataset is typically used only for InD (In-Distribution) testing. To enhance environment diversity and achieve OOD (Out-of-Depth) evaluation, this approach employs a generative strategy to construct multiple pseudo-environment datasets. Specifically, for each node, an environment indicator vector is generated to represent the specific environment to which the node belongs. For each environment i, the corresponding environment vector is constructed by setting the i-th position of the vector to 1 and the remaining positions to 0.
[0121]
[0122] Next, we will introduce a generator based on GCN. This generator is used to generate graph structures under given environmental conditions. It takes the original graph G as input and outputs a set of features to simulate the environment-specific effects:
[0123]
[0124] in, Represented as the generated first P Graph data in a pseudo-environment. Component Implemented by linear layers, this introduces environment-related random noise into the generated features. During training, each node is assigned a unique environment ID to indicate its environment, a standard assumption in OOD methods. Finally, P pseudo-environment datasets are synthesized. In the CausBot-SD setting, the original dataset and the first m pseudo-environment datasets are used for training, validation, and InD testing, while the remaining P - m pseudo-environment datasets are reserved for OOD testing.
[0125] CausBot-MD: When using multiple real-world datasets, each dataset is treated as an independent environment. The first dataset is used for training, validation, and InD testing, with its environment label set to 1; the remaining datasets are assigned different environment labels and used only for OOD testing. This setup enables a comprehensive evaluation of cross-domain generalization capabilities.
[0126] The overall algorithm pseudocode is as follows:
[0127]
[0128]
[0129]
[0130] Step S107: Extract causal features based on the trained CausBot model, estimate the robot probability of the input social network account node, and output the label of whether it is a robot by Softmax.
[0131] Corresponding to the above method, embodiments of the present invention also disclose a social robot detection system based on causal intervention and hybrid experts, comprising:
[0132] The data acquisition module is used to acquire graph structure data of social networks, determine the real labels of accounts through expert annotation, and construct a graph with accounts as nodes based on interaction relationships;
[0133] The model building module is used to build the CausBot model, which includes a pseudo-environment estimator and a graph Transformer encoder enhanced by a hybrid expert mechanism.
[0134] The environment estimation module is used to estimate the potential environment distribution of each node through the pseudo environment estimator and generate environment-aware weights based on the Gumbel-Softmax relaxation technique.
[0135] The feature encoding module is used to encode node features at multiple levels using the graph Transformer encoder enhanced by the hybrid expert mechanism, under the control of the environment-aware weights, in order to extract cross-environment invariant causal features.
[0136] The model training module is used to train the CausBot model using a joint optimization objective function, while optimizing the parameters of the pseudo-environment estimator and the graph Transformer encoder enhanced by the hybrid expert mechanism. The objective function includes a supervised loss term and a KL divergence regularization term.
[0137] The detection and prediction module is used to extract causal features based on the trained CausBot model, estimate the bot probability of the input social network account node, and output the label of whether it is a bot by Softmax.
[0138] Unless otherwise specifically stated, the relative steps, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention.
[0139] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple; relevant parts can be referred to the method section.
[0140] The units and method steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of each example have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations are not considered to be beyond the scope of this invention.
[0141] Those skilled in the art will understand that all or part of the steps in the above methods can be implemented by a program instructing related hardware, and the program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk. Optionally, all or part of the steps in the above embodiments can also be implemented using one or more integrated circuits. Accordingly, each module / unit in the above embodiments can be implemented in hardware or as a software functional module. This invention is not limited to any particular combination of hardware and software.
[0142] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A social bot detection method based on causal intervention and mixed experts, characterized in that, The method comprises the following steps: Step 1, obtaining graph structure data of a social network, determining real labels of accounts through expert annotation, and constructing a graph with accounts as nodes according to interaction relationships; Step 2, constructing a CausBot model, which comprises a pseudo-environment estimator and a graph Transformer encoder enhanced by a mixed expert mechanism; Step 3, estimating a potential environment distribution to which each node belongs through the pseudo-environment estimator, and generating environment-aware weights based on a Gumbel-Softmax relaxation technique; Step 4, using the graph Transformer encoder enhanced by the mixed expert mechanism to encode node features at multiple levels under the regulation of the environment-aware weights, so as to extract cross-environment invariant causal features; Step 5, training the CausBot model by using a joint optimization objective function to optimize parameters of the pseudo-environment estimator and the graph Transformer encoder enhanced by the mixed expert mechanism, wherein the objective function comprises a supervised loss term and a KL divergence regularization term; Step 6, extracting causal features based on the trained CausBot model, performing robot probability estimation on an input social network account node, and outputting a label of whether the node is a robot by Softmax. 2.The social bot detection method based on causal intervention and hybrid experts according to claim 1, wherein, The specific implementation process of the pseudo-environment estimator in Step 3 is as follows: In the l In a layered graph Transformer, for nodes v Hidden representation By performing linear mapping and normalization, the pseudo-environment probability distribution is obtained. : ; wherein, is a learnable environment perception projection matrix, represents a node v at the first l layer aggregated feature vector, represents a node v at the first l layer pseudo-environment probability distribution; Generating nodes by Gumbel-Softmax relaxation technique v In the first l Layer the k Environmental perception weight of the : ; where, is a random noise, , is a temperature coefficient, when the output tends to a discrete sampling, when the distribution degenerates to a uniform distribution; is the l node in the v th layer belongs to the k th pseudo-environment. 3.The social bot detection method based on causal intervention and hybrid experts according to claim 2, characterized in that, The specific implementation process of the graph Transformer encoder enhanced by the mixed expert mechanism in Step 4 is as follows: The first in each expert module l In the layer, for nodes v Features with neighboring nodes u Features Perform linear transformations respectively to generate query vectors. Key vector Sum value vector The calculation formula is: ; wherein, represents a linear layer, are the learnable weight matrices for the l layer queries, keys, and values, respectively. Computing node v Attention coefficients between nodes u Attention coefficients between nodes , activated by a LeakyReLU function and normalized by Softmax Based on attention coefficient The features of the neighbor nodes are weighted aggregated, and the outputs of multiple attention heads are calculated in parallel and spliced to obtain the node v In the first l Intermediate feature representation of the layer ; Environment perception weights outputted according to the pseudo environment estimator , the outputs of the K expert modules are weighted and fused to obtain a node v feature representation at the l +1 layer .
4. The social bot detection method based on causal intervention and hybrid experts according to claim 3, characterized in that, The node v In the first l Characteristics of the +1 layer The calculation formula is: ; wherein, is the output of the k expert module at the v feature at the l layer. 5.The social bot detection method based on causal intervention and hybrid experts according to claim 1, wherein, The combined optimization objective function described in step 5 The expression for the combined optimization objective function is: ; in, E Indicates a pseudo-environment. G Representing the graph structure, Indicates the predicted label, For pseudo-environment estimators, For predictors, As a priori distribution of the environment, For distribution in pseudo-environment The expected loss of supervision, For pseudo-environment distribution Prior distribution of the environment KL divergence, This is the balance coefficient.
6. The social bot detection method based on causal intervention and hybrid experts of claim 5, wherein, The joint optimization objective function The specific calculation form is: ; wherein, is the number of nodes in the training set, is the true label of a node v in one-hot vector, is the predicted probability distribution output by the model, L is the total number of layers of the graph Transformer, K is the number of pseudo-environment classes, is the environmental perception weight of the node v in the l layer for the k environmental factor, is the probability distribution of the node l belonging to the v pseudo-environment in the k layer. 7.The social bot detection method based on causal intervention and hybrid experts according to claim 5, wherein, The environmental prior distribution Set to uniform distribution, i.e. prior probability of each pseudo-environment is . 8.The social bot detection method based on causal intervention and hybrid experts according to claim 1, wherein, The method further comprises a distribution-out generalization test strategy, including the following two modes: CausBot-SD: generating multiple pseudo-environments on a single dataset, wherein part of the pseudo-environment datasets are used for training and distribution-in test, and the remaining pseudo-environment datasets are used for distribution-out test; CausBot-MD: using multiple real-world datasets, wherein one dataset is used as a source domain for training and distribution-in test, and the remaining datasets are used as target domains for distribution-out generalization evaluation. 9.The social bot detection method based on causal intervention and hybrid experts according to claim 8, characterized in that, In the CausBot-SD mode, the pseudo-environment is generated in the following manner: An original graph structure is disturbed by a graph structure generator to generate multiple pseudo-environment graph data: ;in, For the generated first P Graph data in a pseudo-environment, This represents a graph structure generator based on the original graph data. This represents a noise generator based on an environment indicator vector. It is the first P The indicator vector of the pseudo-environment, when the node belongs to the first... P When there is a pseudo-environment, the corresponding position is 1, and the other positions are 0.
10. A social bot detection system based on causal intervention and hybrid experts, characterized in that, including: A data acquisition module is configured to obtain graph structure data of a social network, determine real labels of accounts through expert annotation, and construct a graph with accounts as nodes according to interaction relationships; A model construction module is configured to construct a CausBot model, which comprises a pseudo-environment estimator and a graph Transformer encoder enhanced by a mixed expert mechanism; An environment estimation module is configured to estimate a potential environment distribution to which each node belongs through the pseudo-environment estimator, and generate environment-aware weights based on a Gumbel-Softmax relaxation technique; A feature encoding module is configured to use the graph Transformer encoder enhanced by the mixed expert mechanism to encode node features at multiple levels under the regulation of the environment-aware weights, so as to extract cross-environment invariant causal features; The model training module is configured to train the CausBot model by using a joint optimization objective function, so as to optimize parameters of the pseudo-environment estimator and the mixed expert mechanism enhanced graph Transformer encoder, and the objective function comprises a supervised loss term and a KL divergence regularization term. The detection prediction module is configured to extract causal features based on the trained CausBot model, perform robot probability estimation on an input social network account node, and output a label of whether the input social network account node is a robot by using Softmax.
Citation Information
Patent Citations
Account tag prediction method and device, storage medium and electronic equipment
CN116307078A
Online public opinion research, judgment, analysis, classification and grading early warning method and system
CN119577144A