Multi-element initialization soft fusion advanced persistent threat traffic detection method based on federal element learning
By employing a multi-initialization soft fusion strategy, and utilizing verification risk-driven continuous weight allocation and weight-aware aggregation, the problem that a single initialization parameter in federated meta-learning cannot adapt to heterogeneous tasks is solved, thus achieving more stable advanced persistent threat traffic detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEILONGJIANG UNIV
- Filing Date
- 2026-03-13
- Publication Date
- 2026-05-01
AI Technical Summary
In existing federated meta-learning methods, the single global meta-initialization parameter cannot adapt to the heterogeneous tasks of edge nodes in new power systems, which can easily lead to negative migration and unstable detection performance, affecting the reliability and practicality of the distributed new power system security protection system.
A multi-initialization soft fusion strategy is adopted. The server maintains a multi-initialization parameter set, the client calculates the verification risk through the local verification set and performs normalization processing, assigns continuous weights, performs weighted fusion to generate personalized initialization parameters, and performs weight-aware aggregation and update on the server to build a model adapted to local tasks.
It improves the adaptability and detection performance in heterogeneous scenarios, solves the problems of negative transfer and detection instability caused by single initialization parameters, and enhances the stability and detection performance of the model in heterogeneous scenarios.
Smart Images

Figure CN121967080A_ABST
Abstract
Description
A Multivariate Initialization Soft Fusion Advanced Persistent Threat Traffic Detection Method Based on Federated Meta-Learning Technical Field
[0001] This invention relates to the field of network security, and specifically to a traffic detection method based on federated meta-learning. Background Technology
[0002] Advanced Persistent Threats (APTs) are cyberattacks launched by attackers with strong adversarial capabilities, characterized by long-term latency and high stealth, seriously threatening the security of critical information infrastructure and important business systems in emerging power systems. These systems exhibit a complex structure characterized by cloud-edge collaboration, multi-domain interconnection, and heterogeneous equipment. The attack sample size obtainable by a single node of edge devices such as substation automation terminals and distribution monitoring devices is limited, and they are constrained by privacy protection and compliance requirements. Furthermore, cross-domain centralized sharing of raw traffic data is difficult to achieve in practical deployments.
[0003] Existing federated meta-learning methods typically rely on a single global meta-initialization parameter shared across clients. However, when the tasks of each client differ significantly, a single initialization parameter often fails to meet the needs of different clients simultaneously. It may promote some client tasks while inhibiting others, leading to problems such as negative transfer. This results in unstable model convergence or a decline in local detection performance, seriously affecting the reliability and practicality of the distributed new power system security protection system. Summary of the Invention
[0004] To overcome the technical problems of existing federated meta-learning methods, such as the inability of a single global meta-initialization parameter to adapt to heterogeneous tasks at edge nodes of new power systems, the tendency to induce negative migration, and unstable detection performance, this invention provides a multi-element initialization soft fusion advanced persistent threat traffic detection method based on federated meta-learning.
[0005] This invention is achieved through the following technical solution:
[0006] A multi-initialization soft fusion advanced persistent threat traffic detection method based on federated meta-learning includes the following steps:
[0007] Step 1: The server maintains a multi-element initialization parameter set. including Individual initialization parameters; set of multi-element initialization parameters Distribute to each edge client;
[0008] Step 2: Each edge client uses its local validation set to calculate a multivariate initialization parameter set. The verification risk corresponding to each element's initialization parameter;
[0009] Step 3: Each edge client normalizes the verification risk of each meta-initialization parameter, and assigns continuous weights to each meta-initialization parameter based on the normalized verification risk, resulting in a weight vector. ; Indicates the number of the edge client;
[0010] Step 4: Each edge client initializes the multivariate parameter set based on continuous weights. In The individual initialization parameters are weighted and fused to obtain personalized initialization parameters adapted to the local task. ;
[0011] Step 5: Each edge client initializes its parameters with personalized settings. Starting with the local training set, the first stage of adaptation update is performed on the local training set, and then the second stage of correction update is performed on the local validation set to obtain the updated local model parameters. ;
[0012] Step Six: Each edge client updates its local model parameters. and weight vector Uploaded to the server, the server uses the weight vector uploaded by each client. and updated local model parameters For each multi-dimensional initialization parameter set Each meta-initialization parameter in the dataset undergoes a weight-aware aggregation update to obtain the updated meta-initialization parameter set. .
[0013] Furthermore, each edge client uses a detection model with the same structure, including a linear embedding layer, a single-layer Transformer coding layer, and a fully connected layer; the single-layer Transformer coding layer includes a multi-head self-attention mechanism, a feedforward neural network, residual connections, and layer normalization.
[0014] Furthermore, the local datasets of each edge client include training sets and validation sets. The traffic samples in the training sets and validation sets include normal traffic samples and attack traffic samples, and the local data distribution of different edge clients is heterogeneous.
[0015] Furthermore, the expression for verifying the risk in step two is:
[0016] ,
[0017] in, Represents a multi-dimensional initialization parameter set The Middle One initialization parameter; Indicates the first Each client initializes a multivariate set of parameters on a local validation set. The k-th meta-initialization parameter The calculated verification risk; This represents the local verification set of the nth client; express Traffic feature samples; Representation of flow characteristic samples The corresponding real category label; Indicates that the initialization parameters are The detection model for input samples The calculated prediction results; This represents the classification loss function.
[0018] Furthermore, the normalization described in step three is Softmax normalization.
[0019] Furthermore, for the nth client, the multi-element initialization parameter set is received. The Middle The individual element initialization parameters are assigned weights, and the expression is:
[0020] ,
[0021] In the formula, This represents the set of multi-element initialization parameters received by the nth client. The Middle The weights of the initialization parameters of each element; Indicates the index of the meta-initialization parameter; .
[0022] Furthermore, the expression for the personalized initialization parameter is:
[0023] ,
[0024] In the formula, Indicates the first Personalized initialization parameters for each client.
[0025] Furthermore, the calculation formula for weight-aware aggregation described in step six is as follows:
[0026] ,
[0027] in, Represents the updated set of multivariate initialization parameters The Middle Individual initialization parameters; Represents a set of edge clients; It is a numerically stable term.
[0028] The beneficial effects of this invention are:
[0029] This invention maintains a set of meta-initialization parameters on the server side. The client uses a local validation set to calculate the validation risk corresponding to each meta-initialization parameter and generates a continuous weight vector through normalization mapping. Multiple meta-initialization parameters are then weighted and fused within the parameter space to obtain personalized initialization parameters. Subsequently, the client performs a local model update based on these personalized initialization parameters and uploads the updated local model parameters and corresponding weight vectors to the server. The server, for each meta-initialization parameter in the multi-dimensional initialization parameter set, performs weighted aggregation on the updated local model parameters according to the weights corresponding to each client, thereby obtaining an updated multi-dimensional initialization parameter set. This solves the technical problems of existing federated meta-learning methods where a single global meta-initialization parameter cannot adapt to heterogeneous tasks at edge nodes of new power systems, easily leading to negative migration and unstable detection performance, thus improving adaptability and detection performance in heterogeneous scenarios. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0031] Figure 1 is a schematic diagram of the method execution flow provided in an embodiment of the present invention;
[0032] Figure 2 is a schematic diagram comparing the Macro-F1 curves of four methods provided in one embodiment of the present invention;
[0033] Figure 3 is a schematic diagram comparing the Acc curves of four methods provided in one embodiment of the present invention;
[0034] Figure 4 is a schematic diagram comparing the loss curves of four methods provided in one embodiment of the present invention;
[0035] Figure 5 is a schematic diagram comparing the loss curves of the model used in the method of the present invention and the MLP model provided in one embodiment of the present invention;
[0036] Figure 6 is a schematic diagram comparing the Macro-F1 score curves of the model used in the method of the present invention and the MLP model provided in one embodiment of the present invention;
[0037] Figure 7 is a schematic diagram comparing the Acc curves of the model used in the method of the present invention and the MLP model provided in one embodiment of the present invention;
[0038] Figure 8 is a schematic diagram of the Macro-F1 score curves when different numbers of initialization parameters are set according to the method of the present invention in one embodiment of the present invention.
[0039] Figure 9 is a schematic diagram of the Acc score curve when different numbers of initialization parameters are set according to an embodiment of the present invention.
[0040] Figure 10 is a schematic diagram of the Loss score curves when different numbers of initialization parameters are set according to an embodiment of the present invention.
[0041] Figure 11 is a schematic diagram of the Macro-F1 curve of the ablation experiment provided in one embodiment of the present invention. Detailed Implementation
[0042] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0043] Specific Implementation Method 1
[0044] The novel power system applied in this invention adopts a collaborative operation architecture consisting of cloud, edge layer, and terminal devices. Each edge node, such as a substation automation terminal or distribution monitoring device, exhibits significant differences in operating environment, service functions, and communication modes, demonstrating non-independent and identically distributed characteristics. This invention treats each edge node as a client and the cloud as a central server, constructing a federated learning environment. During federated training, the client utilizes only a limited number of local traffic attack samples to perform model updates and achieves cross-node knowledge sharing through parameter interaction with the server. Each client task is formalized as a few-sample learning problem, and its local data can be divided into a support set and a query set (i.e., a training set and a validation set), used for rapid adaptation and performance evaluation, respectively.
[0045] To address the shortcomings of using a single global initialization parameter as the sole starting point for all heterogeneous clients, this invention provides a multi-element initialization soft fusion advanced persistent threat traffic detection method based on federated meta-learning. Please refer to Figure 1, which is a schematic diagram of the execution flow of the method of this invention. The method of this invention includes:
[0046] Step S1: Data acquisition and preprocessing.
[0047] The public network traffic dataset CICIDS2017 was used as the original data source. After decompression, the traffic CSV files corresponding to multiple working days were read and merged into a unified dataset.
[0048] Preprocessing operations include: field filtering, label numericalization, sample cleaning, and dataset partitioning.
[0049] Field filtering: Remove duplicate or meaningless fields, including flow identifier, source / destination IP address, port, timestamp field, constant or low contribution characteristics.
[0050] Numericalization of tags: Traffic tags are uniformly encoded, and normal traffic and various attack types are mapped to integer category numbers to form multi-class tags.
[0051] Sample cleaning: Remove records containing missing values, overflow values, or infinite values to obtain a valid traffic sample set.
[0052] Dataset partitioning: Based on the visibility of attack categories, the effective traffic sample set is divided into a training set and a test set. The training set contains normal traffic and traffic samples of some known attack categories, while the test set additionally contains traffic samples of unknown attack categories that did not appear during the training phase, simulating the distribution offset scenario in actual advanced persistent threat detection.
[0053] Multiple clients are constructed, and each client randomly selects several visible categories (including normal traffic and known attack categories) from the training set, and extracts a preset number of small-scale traffic data from each category to form a local dataset. During the testing phase, multiple test clients can be constructed, and samples of unknown attack categories with different proportions can be gradually introduced to simulate the distribution shift in actual advanced persistent threat detection scenarios, thereby verifying the detection capability and generalization performance of the method in unknown attack environments.
[0054] This construction method introduces heterogeneity at both the category composition and sample size levels: on the one hand, the category sets of different clients are significantly different, reflecting the non-independent and identically distributed characteristics at the category composition level; on the other hand, the number of samples for each client is extremely small, constituting a small sample condition.
[0055] Step S2: System construction and local dataset partitioning.
[0056] The federated system consists of one central server and N edge clients, denoted as: All edge clients divide their local datasets into training sets in the same proportion. and verification set The training set is used to locally detect model parameter updates, while the validation set is used to evaluate the validation risk of multivariate initialization parameters, satisfying the needs of initialization selection and parameter updates in the federated meta-learning framework. All data partitioning and training processes are completed locally on the client side. The server only receives model parameter updates and does not access any raw traffic data or feature information, thus strictly adhering to the basic requirements of federated learning for data privacy protection.
[0057] Step S3: The server maintains a multi-element initialization parameter set. including Individual initialization parameters; set of multi-element initialization parameters Distribute to each edge client;
[0058] The set of multi-dimensional initialization parameters ,in, Indicates the number of candidate initialization parameters; Indicates the first Individual initialization parameters.
[0059] Meta-initialization parameters can be generated using the same or different randomization methods. Each meta-initialization parameter can be regarded as an implicit characterization of the potential task distribution or attack feature pattern, and its specific semantics do not depend on any explicit task labels or prior partitions.
[0060] Compared to a single initialization strategy, the multi-initialization mechanism provides multiple optional model starting points for different edge client tasks, so as to meet the needs of specific client tasks and more effectively adapt to heterogeneous APT traffic detection tasks.
[0061] Step S4: Each edge client uses its local validation set to calculate the multivariate initialization parameter set. The verification risk corresponding to each element initialization parameter.
[0062] Each edge client uses the same detection model, which includes a linear embedding layer, a single-layer Transformer encoding layer, and a fully connected layer; the single-layer Transformer encoding layer includes a multi-head self-attention mechanism, a feedforward neural network, residual connections, and layer normalization.
[0063] Specifically, let the traffic feature vector input locally by the client be... , This represents the feature dimension of the preprocessed traffic sample data.
[0064] (1) The feature vector is embedded through a linear embedding layer. Mapping to a high-dimensional representation space yields the embedding vector. :
[0065] ,
[0066] In the formula, Represents the weight matrix of the linear embedding layer; , Indicates the embedding dimension; This represents the bias vector.
[0067] (2) embedding vector The input is fed into a single-layer Transformer Encoder for feature modeling to obtain a high-dimensional feature vector. :
[0068]
[0069] Using multi-head self-attention mechanisms to model the correlations between different feature dimensions helps capture potential cross-dimensional feature dependencies in complex attack behaviors. Since network traffic features themselves do not have a strict time-series order, positional encoding here is used to distinguish the structural positions of different feature dimensions in the embedding space, thereby enhancing the detection model's ability to express feature combination relationships.
[0070] (3) Transform high-dimensional feature vectors Input a fully connected classifier, activate it with Softmax, and output the predicted probability distribution of each attack category. :
[0071]
[0072] In the formula, Represents the classification layer weight matrix; This represents the bias vector.
[0073] The detection model is a systematic simplification and optimization for federated meta-learning and edge computing scenarios. By retaining the single-layer encoder structure, compressing the embedding representation dimension and reducing the number of attention heads, and adopting a linear embedding method oriented towards structured traffic features to replace the traditional sequence-to-label mapping mechanism, the overall model parameter size is maintained at only a few hundred KB under standard configuration, which is significantly smaller than common ResNet series networks or multi-layer Transformer architectures. This significantly reduces the model size and computational burden while ensuring modeling capabilities.
[0074] The verification risk can be calculated using the following formula:
[0075] ,
[0076] in, Indicates the first Each client initializes a multivariate set of parameters on a local validation set. The k-th meta-initialization parameter The calculated verification risk; Indicates the first A local client validation dataset used by one client to evaluate the fit of candidate initialization parameters; express Traffic feature samples; Representation and Feature Samples The corresponding real category label; Indicates that the initialization parameters are The detection model for input samples The calculated prediction results; This represents the classification loss function.
[0077] Step S5: Each edge client normalizes the verification risk of each meta-initialization parameter, and assigns continuous weights to each meta-initialization parameter based on the normalized verification risk, thus obtaining a weight vector. .
[0078] To measure the degree of matching between different initialization parameters and the task distribution of edge clients, this invention uses verification risk as a quantitative indicator of matching degree. The lower the verification risk, the higher the degree of matching between the set of initialization parameters and the client data distribution. Based on this, the current client, upon receiving the multi-dimensional initialization parameter set... The validation risk corresponding to each parameter is normalized to ensure that all validation risk values are in a unified metric space. Then, based on the normalized validation risks, a multivariate initialization parameter set is calculated. By continuously initializing the meta-initialization parameters, continuous weight modeling of the meta-initialization parameters is achieved, resulting in an initial weight vector. .
[0079] For example, the set of multi-element initialization parameters received by the nth client. The Middle The individual element initialization parameters are assigned weights, and the expression is:
[0080] ,
[0081] In the formula, This represents the set of multi-element initialization parameters received by the nth client. The Middle The weights of the initialization parameters of each element; Indicates the index of the meta-initialization parameter; Weight This indicates the degree of compatibility between the initialization parameters and the client task, with weights. The higher the value, the better the fit.
[0082] By using the softmax operation for normalization, the absolute risk values of the initialization parameters of different groups on the validation set are mapped to a set of comparable relative weights, thereby enabling continuous characterization of the adaptation relationship of multivariate initialization parameters without the need for additional learnable modules.
[0083] Step S6: Each edge client initializes the multivariate parameter set based on continuous weights. In The individual initialization parameters are weighted and fused to obtain personalized initialization parameters adapted to the local task. .
[0084] The following formula can be used for calculation:
[0085] ,
[0086] In the formula, Indicates the first Personalized initialization parameters for each client.
[0087] This invention employs a weighted fusion approach within the parameter space to construct personalized initialization parameter combinations. This transforms the initialization parameter selection strategy from a discrete "hard selection" to a continuous "soft fusion" approach. This strategy effectively avoids the problems of discrete jumps and training instability caused by frequent switching of the initialization starting point during multiple rounds of communication, which are susceptible to small fluctuations in validation loss when the validation set size is limited or the performance differences between different initialization parameters are small. This mechanism does not require the introduction of an additional learnable gating module; it achieves a "continuous gating" effect solely through local validation risk, improving robustness and personalized expressive capabilities. Furthermore, when multiple initialization parameters have a certain degree of adaptability to the current client task, this fusion strategy can comprehensively utilize their prior information rather than relying on a single candidate solution. This allows for a more thorough exploration of the complementarity of multiple initialization parameters in heterogeneous client tasks, providing a more robust starting point for subsequent local updates.
[0088] Step S7: Each edge client initializes its parameters with personalized settings. Starting with the local training set, the first stage of adaptation update is performed on the local training set, and then the second stage of correction update is performed on the local validation set to obtain the updated local model parameters. .
[0089] The first stage update is a training set adaptation update, using personalized parameter initialization. Starting with the local client training set, gradient updates are performed using gradient descent to obtain intermediate model parameters. :
[0090] ,
[0091] In the formula, Represents edge client Based on personalized initialization parameters The intermediate model parameters obtained after completing the first stage of rapid adaptation and update on the local training set; This indicates the learning rate update in the first stage; This indicates the personalized initialization parameters. Gradient operator for finding gradients; from the edge client Validation risks on local training sets As an empirical loss function.
[0092] The second stage update is a validation set correction update. It uses the intermediate model parameters obtained from the first stage update. Starting with the local validation dataset, perform a correction update to obtain the updated model parameters:
[0093] ,
[0094] In the formula, Represents edge client The model parameters after the second-stage validation set calibration and update; This represents the learning rate updated in the second phase; in the context of edge clients. Validation risks on local validation sets As an empirical loss function.
[0095] After the local update is complete, all clients upload their updated model parameters to the server. and initial weight vector .
[0096] Step S8: Each edge client updates its local model parameters. and weight vector Uploaded to the server, the server uses the weight vector uploaded by each client. and updated local model parameters Each of the following is a multi-dimensional initialization parameter set. Each meta-initialization parameter in the dataset undergoes a weight-aware aggregation update to obtain the updated meta-initialization parameter set. ,in, Indicates the updated number Group global candidate multivariate initialization parameters.
[0097] Updated multi-element initialization parameter set It can be used for the next round of federated training or for the deployment of APT traffic detection models.
[0098] The calculation formula for the weight-aware aggregation is as follows:
[0099] ,
[0100] in, Represents the updated set of multivariate initialization parameters The Middle Individual initialization parameters; Represents a set of edge clients; It is a numerically stable term.
[0101] After each federated training cycle, the client not only uploads the updated model parameters locally but also reports its sparse preference weights for each initialization parameter—that is, the weights used for each initialization parameter. When updating the k-th meta-initialization parameter, the server only aggregates the client updates with higher weights on that initialization, ensuring that the optimization direction of that initialization parameter is primarily determined by the peripheral client group it "mainly serves." This design effectively suppresses the homogenization trend of multiple initialization parameters during repeated aggregation and promotes the gradual formation of targeted parameter representations around different client subgroups, thereby improving the stability and effectiveness of the multi-initialization federated meta-learning method in highly heterogeneous scenarios.
[0102] (1) Compared with federated learning methods such as FedAvg that do not have personalized meta-initialization capabilities and federated meta-learning methods such as Per-FedAvg that rely on a single global meta-initialization parameter, this invention maintains multiple meta-initialization parameters on the server side and combines them with a verification risk-driven soft fusion mechanism to construct personalized initialization parameters that are more adapted to the local task distribution of different clients, thereby improving the adaptability and detection performance in heterogeneous scenarios.
[0103] (2) In view of the discrete decision-making defect that the client can only select the single best one from multiple candidate initialization parameters, this invention further introduces a continuous weight allocation mechanism based on verification risk, which improves the initialization parameter selection process from hard selection to soft fusion, thereby effectively reducing the interference of verification noise on initialization decision under small sample conditions and avoiding frequent discrete jumps of the initialization starting point in multiple rounds of federated communication.
[0104] (3) By weighted fusion of multiple meta-initialization parameters on the client side and weight-aware aggregation update of each meta-initialization parameter on the server side, this invention can more fully explore the complementary relationship between different meta-initialization parameters, suppress the homogenization trend of multiple initialization parameters in the training process, and improve the stability of the federated training process, the client's personalized adaptation capability, and the overall performance and generalization capability of advanced persistent threat traffic detection.
[0105] To verify the beneficial effects of the present invention, the following comparative experiments were conducted:
[0106] The comparison methods include:
[0107] • FedAvg: The classic federated average algorithm, serving as a baseline method that does not introduce personalized mechanisms;
[0108] • Per-FedAvg: A personalized federated meta-learning algorithm based on a single initialization parameter;
[0109] • Multi-Init-hard ( ): A multivariate initialization federated meta-learning method that employs a hard selection strategy based on validation loss;
[0110] • SoftInit-FML ( The method is based on the verification risk perception soft initialization fusion method (the method of this invention). It introduces continuous weights driven by verification risk on the basis of multiple initialization parameters for soft fusion.
[0111] To systematically evaluate the detection performance of the proposed method in a federated learning scenario, comparative experiments were conducted at two levels: algorithm design and model structure. Firstly, the proposed multivariate initialization federated meta-learning method was compared with typical federated learning baseline algorithms to verify its effectiveness at the algorithm level. Secondly, under the same federated learning framework, the proposed lightweight Transformer detection model was compared with traditional basic models to analyze the impact of the detection model structure on overall performance.
[0112] The differences between the methods lie in the number of global communication rounds T, data partitioning method, number of local update rounds E, and learning rate parameter. and Keep hyperparameter settings consistent, and uniformly set the number of initializations in multiple initialization methods. The relevant hyperparameters were kept constant during the experiment to ensure the fairness and reproducibility of the comparison results.
[0113] Regarding evaluation metrics, considering the common problem of class imbalance in APT traffic detection tasks, this invention introduces the Macro-F1 score as the primary evaluation metric. Accuracy and loss are also used to comprehensively analyze the model training process.
[0114] Please refer to Figures 2 to 4, which show the curves of Macro-F1, Accuracy, and Loss on the validation set for different methods as a function of the global communication rounds.
[0115] As can be seen from the Macro-F1 curves, the FedAvg and Per-FedAvg methods converge relatively quickly in the early stages of training, but they are significantly lacking in their ability to identify minority class attack samples. The Multi-Init method, after introducing a multi-initialization mechanism, shows improved performance in the later stages of training. The improved SoftInit-FML method maintains a superior Macro-F1 score throughout the entire training process and also maintains a stable advantage during convergence. This demonstrates that the initialization fusion method based on continuous weights in this invention can effectively utilize multi-branch prior information, thereby constructing a more robust personalized initialization model.
[0116] In terms of accuracy, the overall differences among the methods are relatively small, but the proposed method, SoftInit-FML, still slightly outperforms the others. Because the class distribution in APT traffic detection is highly uneven, accuracy is affected by the majority class. Therefore, the Macro-F1 score more accurately reflects the model's ability to detect minority class attack samples, and the advantage of the proposed method in this metric has greater practical significance.
[0117] The loss curves show that the validation loss of all methods generally decreases with increasing communication rounds, indicating good overall stability during training. Compared to Per-FedAvg, Multi-Init has significantly improved optimization efficiency, while SoftInit-FML achieves the lowest or near-lowest validation loss in most rounds, further validating the stability advantage brought by introducing continuous weight modeling in the initialization phase.
[0118] For the lightweight Transformer model proposed in this invention, a comparative experiment was conducted using a traditional Multilayer Perceptron (MLP) model to verify the effectiveness of the proposed model in federated learning scenarios. Both models were trained under the same data partitioning, number of communication rounds, and local training parameters, with differences only in the detection model structure to ensure the fairness of the comparison results. In the case of the two models, the images of loss (Loss), macro-F1 score, and accuracy (Acc) are shown in Figures 5 to 7, respectively.
[0119] Figure 5 illustrates the changes in the loss function of the two models on the validation set. The lightweight Transformer model described in this invention converges faster in the initial training phase, with its validation loss rapidly decreasing within a few communication rounds and eventually stabilizing at a low level. In contrast, the loss of the MLP model decreases more slowly and remains at a higher value throughout the training process. This demonstrates that the lightweight Transformer model described in this invention performs better in high-dimensional network traffic feature modeling and parameter optimization.
[0120] Figure 6 shows the Macro-F1 score variation curves of different models on the validation set. The lightweight Transformer significantly outperforms the MLP model throughout the training process, especially in the mid-to-late stages, where its Macro-F1 score stabilizes at a high value, while the MLP model's Macro-F1 score remains consistently low. Since the Macro-F1 metric treats all classes equally, it more accurately reflects the ability to identify few-shot attacks such as advanced persistent threats. This experimental result also demonstrates that the proposed model has superior detection performance under conditions of minority-class attack samples and imbalanced data.
[0121] Figure 7 shows the changes in classification accuracy for the two models on the validation set. The lightweight Transformer model also outperforms the MLP model in accuracy and exhibits a more stable convergence trend.
[0122] Overall, the lightweight Transformer model exhibits a more stable convergence trend than the MLP model during training and achieves superior detection performance on key metrics such as Macro-F1. This is mainly attributed to the Transformer model's ability to explicitly model the global dependencies between traffic features, thereby demonstrating stronger feature representation capabilities and better identifying complex attack behaviors. These results confirm the rationality and effectiveness of the proposed resource-efficient Transformer model as a federated meta-learning detector.
[0123] To systematically analyze the impact of multivariate initialization mechanisms on model performance and training behavior, different initialization parameters were tested on the CICIDS2017 dataset. Ablation experiments were conducted:
[0124] Set separately , and And compare its detection performance and convergence characteristics on the validation set, among which, The baseline Per-FedAvg method is shown in Figures 8, 9, and 10, respectively, for its Macro-F1 score, loss, and accuracy (Acc).
[0125] Figure 8 shows the different The changes in Macro-F1 configuration with different global communication rounds can be observed. It can be seen that the multi-initialization strategy ( Throughout the entire training process, it significantly outperformed a single initialization configuration, where and It shows significant advantages in both convergence speed and final performance, indicating that diversified initialization helps improve the model's adaptability to non-independent and identically distributed client data.
[0126] Figure 9 shows the corresponding accuracy curves. The results indicate that multivariate initialization not only improves detection capability under class balance conditions but also significantly enhances the overall classification accuracy. In contrast, It is inferior in both convergence speed and final accuracy, while A better compromise was achieved between stability and final performance.
[0127] As shown in Figure 10, the loss curves reveal that the multivariate initialization strategy exhibits a faster decline in loss during the early stages of training and maintains a lower and more stable loss level in the mid-to-late stages. This indicates that the mechanism not only improves detection performance but also enhances the model's optimization stability in federated, non-independent, identically distributed scenarios.
[0128] Based on these three indicators, we can conclude that an appropriate number of multivariate initializations can effectively improve the model's detection performance and training stability. It exhibits the best overall performance under the current experimental setup.
[0129] To further verify the role of risk perception weight modeling in the initialization fusion stage as described in this invention, an ablation experiment was designed to target the initialization fusion strategy. While maintaining the model structure and initialization quantity... Under the premise that the number of communication rounds and other training parameters are completely consistent, the Multi-Init method based on the hard selection strategy and the method of this invention were compared. The curve of Macro-F1 change with the number of global communication rounds on the validation set is shown in Figure 11. As can be seen from the figure, in the initial training stage, the Macro-F1 improvement speed of SoftInit-FML (this invention) is significantly faster than that of the Multi-Init method, indicating that the continuous weight modeling driven by validation risk can more stably integrate the initialization prior under small sample conditions, thereby helping the model to form a more suitable personalized initialization direction faster. As the number of communication rounds increases, SoftInit-FML maintains a higher Macro-F1 level throughout the process, and the performance advantage remains stable in the convergence stage. In terms of final performance, the Macro-F1 of SoftInit-FML reaches 0.7959, which is about 3.1% higher than that of Multi-Init. Furthermore, by statistically analyzing the number of communication rounds required to reach 95% of the final performance, the soft fusion mechanism was introduced to shorten the convergence rounds from 177 rounds to 143 rounds, which significantly improved the training efficiency. Specific values are shown in Table 1. As can be seen from the table, the validation risk-driven continuous weight allocation mechanism can effectively alleviate the instability in the initialization selection process, enabling the model to obtain a better initialization starting point under small sample and non-independent identically distributed conditions, thereby improving the overall detection performance.
[0130] To further evaluate the model's generalization ability in real-world deployment scenarios, it was evaluated on the CICIDS2017 test client set. The test set includes attack types not observed during training, presenting the challenge of both "cross-client distribution shift" and "unknown attack types." A local partitioning strategy consistent with the training phase was adopted, with a rapid adaptation performed during the testing phase to simulate the rapid update process when edge nodes arrive at new tasks. Approximately 38% of the samples in the test set correspond to attack categories not observed during training, effectively simulating common distribution shift scenarios in real-world deployment environments. The experimental results are shown in Table 2. The table shows that the Multi-Init method based on hard selection of validation loss significantly degrades in performance on the test set, with the Macro-F1 score significantly lower than... The Per-FedAvg method demonstrates that, under small-sample validation conditions, the discrete initialization choice becomes susceptible to noise interference as the initialization parameters increase, thus affecting the model's generalization ability in unknown attack scenarios. In contrast, the improved SoftInit-FML method proposed in this invention achieves a Macro-F1 score of 0.2696 on the test set, which is significantly better than Multi-Init (…). It achieves an improvement of over 60%, while also demonstrating better or more stable results in terms of accuracy and loss metrics. More importantly, SoftInit-FML... Under the various initialization settings, its overall performance is comparable to Per-FedAvg ( The results are on par with or even slightly higher than those of the model, indicating that by validating risk-driven continuous weight modeling, the selection instability problem faced by multiple initializations under strong distribution bias can be effectively alleviated. Experiments have verified that such methods help improve the robustness and generalization stability of the model in scenarios with a high proportion of unknown attacks.
[0131] Table 1 Ablation Experiment Results
[0132]
[0133] Table 2. Performance comparison of different methods on the CICIDS2017 test set (mean ± std)
[0134]
[0135] Finally, it should be noted that in this invention, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0136] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A multi-initialization soft fusion advanced persistent threat traffic detection method based on federated meta-learning, characterized in that, Includes the following steps: Step 1. The server maintains a multi-element initialization parameter set. including Individual initialization parameters; set of multi-element initialization parameters Step 2: Each edge client uses its local validation set to calculate the multivariate initialization parameter set. Step 3: Each edge client normalizes the verification risk of each meta-initialization parameter, and assigns continuous weights to each meta-initialization parameter based on the normalized verification risk, thus obtaining a weight vector. ; Indicates the edge client's ID; Step 4: Each edge client initializes the multivariate parameter set based on continuous weights. In The individual initialization parameters are weighted and fused to obtain personalized initialization parameters adapted to the local task. Step 5: Each edge client initializes its parameters with personalized settings. Starting with the local training set, the first stage of adaptation update is performed on the local training set, and then the second stage of correction update is performed on the local validation set to obtain the updated local model parameters. Step Six: Each edge client updates its local model parameters. and weight vector Uploaded to the server, the server uses the weight vector uploaded by each client. and updated local model parameters For each multi-dimensional initialization parameter set Each meta-initialization parameter in the dataset undergoes a weight-aware aggregation update to obtain the updated meta-initialization parameter set. 。 2. The method for detecting advanced persistent threat traffic based on federated meta-learning and multi-element initialization soft fusion according to claim 1, characterized in that, Each edge client uses the same detection model, which includes a linear embedding layer, a single-layer Transformer encoding layer, and a fully connected layer; the single-layer Transformer encoding layer includes a multi-head self-attention mechanism, a feedforward neural network, residual connections, and layer normalization.
3. The method for detecting advanced persistent threat traffic based on federated meta-learning and multi-element initialization soft fusion according to claim 2, characterized in that, Each edge client's local dataset includes a training set and a validation set. The traffic samples in the training set and validation set include normal traffic samples and attack traffic samples, and the local data distribution of different edge clients is heterogeneous.
4. The method for detecting advanced persistent threat traffic based on federated meta-learning and multi-element initialization soft fusion according to claim 3, characterized in that, The expression for verifying the risk in step two is: ,in, Represents a multi-dimensional initialization parameter set The Middle One initialization parameter; Indicates the first Each client initializes a multivariate set of parameters on a local validation set. The k-th meta-initialization parameter The calculated verification risk; This represents the local verification set of the nth client; express Traffic feature samples; Representation of flow characteristic samples The corresponding real category label; Indicates that the initialization parameters are The detection model for input samples The calculated prediction results; This represents the classification loss function.
5. The method for detecting advanced persistent threat traffic based on federated meta-learning and multi-element initialization soft fusion according to claim 4, characterized in that, The normalization described in step three is Softmax normalization.
6. The method for detecting advanced persistent threat traffic based on federated meta-learning and multi-element initialization soft fusion according to claim 5, characterized in that, For the set of multi-element initialization parameters received by the nth client The Middle The individual element initialization parameters are assigned weights, and the expression is: In the formula, This represents the set of multi-element initialization parameters received by the nth client. The Middle The weights of the initialization parameters of each element; Indicates the index of the meta-initialization parameter; 。 7. The method for detecting advanced persistent threat traffic based on federated meta-learning and multi-element initialization soft fusion according to claim 6, characterized in that, The expression for the personalized initialization parameter is: In the formula, Indicates the first Personalized initialization parameters for each client.
8. The method for detecting advanced persistent threat traffic based on federated meta-learning and multi-element initialization soft fusion according to claim 7, characterized in that, The calculation formula for weight-aware aggregation described in step six is as follows: ,in, Represents the updated set of multivariate initialization parameters The Middle Individual initialization parameters; Represents a set of edge clients; It is a numerically stable term.