Anomaly detection method and system based on federated learning and knowledge distillation

By employing federated learning, knowledge distillation, and blockchain technology, the problems of sample imbalance and high communication loss in multi-institutional joint detection have been solved, enabling efficient and secure anomaly detection while protecting data privacy.

CN118551863BActive Publication Date: 2026-11-06THE ACAD OF TIANJIN UNIV HEFEI
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410641067.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-22
Publication Date
2026-11-06
Estimated Expiration
2044-05-22

AI Technical Summary

Technical Problem

Existing technologies suffer from problems such as imbalanced original samples, high communication losses, and insufficient data security and privacy protection.

Method used

An anomaly detection method based on federated learning and knowledge distillation is adopted. A global model is generated through at least two rounds of federated learning training. The IDW-SMOTE algorithm is used for data preprocessing to establish a machine learning model based on knowledge distillation. Blockchain and differential privacy algorithms are introduced for encryption to reduce communication loss and protect data security.

Benefits of technology

It enables efficient, safe, and low-loss cross-institutional anomaly data detection, solves the sample imbalance problem, reduces communication loss, and improves data security and privacy protection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118551863B_ABST
    Figure CN118551863B_ABST
Patent Text Reader

Abstract

The application provides an anomaly detection method and system based on federated learning and knowledge distillation. The method comprises the following steps: a server aggregates and distributes a global model; an IDW-SMOTE algorithm is used to complete data preprocessing; a machine learning model based on knowledge distillation is established to realize anomaly detection; a differential privacy algorithm is used to encrypt a local model; and the encrypted local model is uploaded. The application solves the technical problems of unbalanced original samples, high communication loss, and low data security and privacy protection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine learning anomaly detection, specifically to anomaly detection methods and systems based on federated learning and knowledge distillation. Background Technology

[0002] Due to the large amounts of transaction data and user information involved, financial institutions are easily targeted by financial crimes. Therefore, training a machine learning model capable of detecting abnormal data and behavior in financial institutions is crucial. However, with economic and technological development, the massive amounts of user-generated data are widely distributed across various financial institutions, making joint anomaly detection by multiple institutions a new challenge. To address data security and privacy issues when multiple institutions conduct machine learning collaboratively, federated learning has emerged. For example, the existing invention patent application document CN115907003A, "Method and System for Detecting Malicious Model Updates Based on Metric Learning in Federated Learning," describes a method that includes: collecting locally updated data and preprocessing it to obtain feature vectors; inputting the feature vectors into a metric learning module for training and testing to obtain a trained metric learning network and using it to obtain a low-dimensional representation of the feature vectors; inputting the low-dimensional representation into an anomaly detection module to filter eligible low-dimensional representations and find corresponding model updates; inputting the model updates into a security aggregation module for security aggregation to obtain the client average accuracy, which is then input into an early termination module to calculate the difference. If the difference is greater than a threshold, federated learning continues; otherwise, it terminates. Utilizing the existing invention patent application document CN117828343A, entitled "Method for Generating Abnormal Samples, Method for Graph Anomaly Detection, and Electronic Device," this existing method includes: encoding first normal graph data based on a local encoder to obtain first encoded data; then applying the first encoded data to generate abnormal encoded data; and finally decoding the abnormal encoded data based on a local decoder to obtain abnormal graph data. The local encoder and decoder are obtained through federated learning with a peer encoder and decoder based on second normal graph data, with the peer encoder and decoder set at the peer end. This method can achieve single-classification learning tasks and generate abnormal samples in a federated learning scenario through a federated autoencoder model constructed by the local encoder, local decoder, and peer encoder and decoder. Federated learning is currently widely used in various fields, but reducing communication loss remains a significant challenge. Furthermore, few researchers consider the imbalanced data problem in anomaly detection while using federated learning architectures. Therefore, further in-depth and extensive research on federated learning is still needed.

[0003] Existing technologies suffer from technical problems such as imbalanced original samples, high communication losses, and insufficient data security and privacy protection. Summary of the Invention

[0004] The technical problem to be solved by this invention is: how to solve the technical problems of imbalanced original samples, high communication loss and low level of data security and privacy protection in the prior art.

[0005] This invention solves the above-mentioned technical problems by employing the following technical solution: An anomaly detection method based on federated learning and knowledge distillation includes:

[0006] S1. Conduct at least two rounds of federated learning training to generate a global model. On the server side, use a model aggregator to aggregate the global model and use a model deployer to distribute the global model to the client.

[0007] S2. Obtain the raw data, use the IDW-SMOTE algorithm to perform data preprocessing operations to obtain balanced sample data, add noise to the local model on the client side to obtain an encrypted local model.

[0008] S3. Establish a machine learning model based on knowledge distillation to achieve anomaly detection. Use balanced sample data as input to the machine learning neural network, use the machine learning model based on knowledge distillation to perform anomaly detection, and compress to generate a local model. The local model includes: a local teacher network, a local student network, and a local distillation network.

[0009] S4. Add zero-mean Laplace noise to the local model and execute the local differential privacy algorithm to obtain an encrypted local model;

[0010] S5. Upload the encrypted local model to the server.

[0011] The anomaly detection machine learning method of this invention is characterized by high efficiency, security, and low overhead, and can be applied to joint anomaly detection by multiple institutions. Based on a federated learning framework, this invention proposes the IDW-SMOTE data preprocessing algorithm to address the imbalance problem of original sample data, uses a knowledge distillation algorithm to compress the model and reduce communication overhead, and introduces blockchain and differential privacy algorithms to protect data security and privacy.

[0012] In a more specific technical solution, S1 includes:

[0013] S11. In the first round of federated learning training, the server-side model deployer is used to generate an initial global model, which is then stored in the global database. During the federated learning training process, the model aggregator is used to aggregate local models to generate the global model.

[0014] S12. Use the model deployer to distribute the global model to all clients;

[0015] S13. The client uploads the hash value of the global model to the server and stores the hash value in the pre-built blockchain;

[0016] When S14 receives all the local model parameters uploaded by the clients on the server side, it will perform an aggregation operation using the model aggregator.

[0017] S15. The model aggregator stores the updated global model in the global database and passes the global model to the model deployer for the next round of federated learning training.

[0018] In a more specific technical solution, S2 includes:

[0019] S21. Collect user-generated raw data using the client, and perform data preprocessing operations on the raw data using the IDW-SMOTE algorithm in the preprocessing module to obtain balanced sample data. The preprocessing module includes: inverse distance weighting module, distillation module and noise addition module.

[0020] S22. The balanced data is transmitted to the distillation module for knowledge distillation. Using the global model on the server, anomaly detection and model compression are performed to detect abnormal data and obtain the applicable student model to obtain the applicable local model. The distillation module includes: neural network, softmax layer, soft label, hard label and real label; the neural network includes: teacher network and student network.

[0021] S23. The applicable local model is passed to the noise-adding module, which adds noise to the applicable local model to complete the encryption operation and obtain the encrypted local model. Specifically, in the blockchain-based federated learning architecture, a local differential privacy algorithm is used to add applicable zero-mean Laplacian noise to the gradient for gradient tuning, thus completing the encryption operation. The gradient tuning is performed using the following logic:

[0022] g new =clip(g,δ)+Laplace(0,λ)

[0023] In the formula, clip(g,δ) is used to determine the noise threshold, and the gradient g with δ needs to be noise-added. g represents the gradient without noise, δ represents the threshold, Laplace(0,λ) represents zero-mean Laplace noise, and λ is the noise scale. The noise-added gradient will be uploaded to the server for aggregation;

[0024] S24. The client will encrypt the local model, upload it to the server, and store it in the global database.

[0025] This invention employs a knowledge distillation algorithm to preserve the knowledge learned from the original model through distillation, and then transfers the knowledge to a compressed model. Although the compressed model is much smaller than the original model, it can learn the same knowledge. Therefore, knowledge distillation can be applied to the local model of a federated learning compressed client to overcome the communication loss problem caused by the excessive size of the transmitted model.

[0026] In a more specific technical solution, S21 includes:

[0027] S211. Using the IDW-SMOTE algorithm, randomly select an initial sample from the pre-set minority class, and select no less than 2 neighbor samples from the neighboring points of the pre-set minority class and the initial sample.

[0028] S212. Based on the Euclidean distance from the neighbor sample to the initial sample, calculate the neighbor weight of each neighbor sample through an inverse distance weighting operation.

[0029] S213. Based on the initial samples, neighbor samples, and neighbor weights, generate and add new sample points to the pre-defined minority class. The neighbor weights are calculated using the inverse distance weighting (IDW) operation.

[0030]

[0031] In the formula, wj represents the weight of neighbor j;

[0032] S214. Repeat the above operation until the number of samples in the preset minority class is the same as the number of samples in the preset majority class.

[0033] This invention first ensures client-side data security and privacy through federated learning, blockchain, and differential privacy algorithms. Next, it utilizes the IDW-SMOTE data preprocessing algorithm to address the imbalance problem in raw sample data for anomaly detection. Finally, it combines knowledge distillation algorithms to compress the local model, thereby reducing communication overhead during model exchange between the server and client. The federated learning-based anomaly detection framework proposed in this invention achieves efficient, secure, and low-loss detection of cross-institutional anomaly data using the above algorithms.

[0034] In a more specific technical solution, in S213, the following logic is used to generate a new sample point x new, and the new sample point is added to the preset minority class A:

[0035]

[0036] In the formula, randam(100) represents randomly selecting an integer in the range (1,100).

[0037] In a more specific technical solution, in S22, the teacher network is pre-trained and distilled to obtain output knowledge data, and the student network learns the output knowledge data to obtain classification results; a Softmax layer is used to map the classification results to a preset interval to obtain the corresponding probability; soft labels are used to process the probability distribution according to the corresponding probability, hard labels are used to process the corresponding probability to obtain Boolean data, and the actual classification result is obtained by processing with real labels.

[0038] In a more specific technical solution, in S22, the knowledge distillation operation includes:

[0039] S221. Input the balanced data into the teacher network for pre-training. Obtain the soft labels of the teacher network through the Softmax layer. In the Softmax layer, when the difference between the probabilities logits of two entities that did not enter the Softmax layer is greater than a preset threshold, use temperature T to maintain the difference between outputs in order to save the output knowledge data. The teacher network is transformed and processed by the Softmax layer using the following logic:

[0040]

[0041] In the formula, q represents the probability output of the teacher network, T represents temperature, zi is the original value of each category participating in the classification, and zj is the original value of item j.

[0042] S222. Input the balanced sample data into the student network for training. When the temperature T meets the preset conditions, combine the processing of hard labels, soft labels and real labels to obtain the student network loss.

[0043] S223. Based on the knowledge output data of the teacher network, control the student network to perform teacher network fitting output operations to obtain a suitable student model.

[0044] In a more specific technical solution, in step S223, the following logic is used to determine the cross-entropy between the soft labels output by the Softmax layer of the teacher network and the soft labels output by the Softmax layer of the student network at the same temperature T:

[0045] L=αL soft +(1-α)L hard

[0046] In the formula, α is the weight, L soft is the distillation loss, and L hard is the loss of the student network at T=1.

[0047] Determine the distillation loss L soft using the following logic:

[0048] L soft =CE(q, p)·T 2

[0049] In the formula, CE is the cross-entropy, p is the predicted value of the student network, and q is the probability output value of the teacher network.

[0050] Using the following logic, at temperature T=1, determine the cross-entropy Lhard between the hard labels output by the Softmax layer of the student network and the true labels:

[0051] L hard =CE(y, p)

[0052] In the formula, CE is the cross-entropy, y is the true label, and p is the predicted value of the student network.

[0053] In a more specific technical solution, S5 includes:

[0054] S51. Upload the encrypted local model to the server. When the server completes the aggregation, it starts the next round of federated learning training.

[0055] S52. Upload and store the hash value of the encrypted local model to the blockchain.

[0056] In more specific technical solutions, anomaly detection systems based on federated learning and knowledge distillation include:

[0057] The aggregation and deployment module is used to perform no less than two rounds of federated learning training to generate a global model. On the server side, the global model is aggregated using a model aggregator, and the global model is distributed to the client using a model deployer.

[0058] The preprocessing module is used to obtain raw data, perform data preprocessing operations using the IDW-SMOTE algorithm to obtain balanced sample data, add noise to the local model on the client to obtain an encrypted local model, and connect the preprocessing module to the aggregation deployment module.

[0059] The knowledge distillation and anomaly detection module is used to build a machine learning model based on knowledge distillation to achieve anomaly detection. It takes balanced sample data as input to the machine learning neural network, uses the machine learning model based on knowledge distillation to perform anomaly detection, and compresses and generates a local model. The local model includes a local teacher network, a local student network, and a local distillation network. The knowledge distillation module is connected to the preprocessing module.

[0060] The local model encryption module is used to add zero-mean Laplace noise to the local model and execute the local differential privacy algorithm to obtain an encrypted local model. The local model encryption module is connected to the knowledge distillation module.

[0061] The local model upload module is used to upload encrypted local models to the server. The local model upload module is connected to the local model encryption module.

[0062] The present invention has the following advantages over the prior art:

[0063] The anomaly detection machine learning method of this invention is characterized by high efficiency, security, and low overhead, and can be applied to joint anomaly detection by multiple institutions. Based on a federated learning framework, this invention proposes the IDW-SMOTE data preprocessing algorithm to address the imbalance problem of original sample data, uses a knowledge distillation algorithm to compress the model and reduce communication overhead, and introduces blockchain and differential privacy algorithms to protect data security and privacy.

[0064] This invention employs a knowledge distillation algorithm to preserve the knowledge learned from the original model through distillation, and then transfers the knowledge to a compressed model. Although the compressed model is much smaller than the original model, it can learn the same knowledge. Therefore, knowledge distillation can be applied to the local model of a federated learning compressed client to overcome the communication loss problem caused by the excessive size of the transmitted model.

[0065] This invention first ensures client-side data security and privacy through federated learning, blockchain, and differential privacy algorithms. Next, it utilizes the IDW-SMOTE data preprocessing algorithm to address the imbalance problem in raw sample data for anomaly detection. Finally, it combines knowledge distillation algorithms to compress the local model, thereby reducing communication overhead during model exchange between the server and client. The federated learning-based anomaly detection framework proposed in this invention achieves efficient, secure, and low-loss detection of cross-institutional anomaly data using the above algorithms.

[0066] This invention solves the technical problems of imbalanced original samples, high communication loss, and low level of data security and privacy protection in the prior art. Attached Figure Description

[0067] Figure 1 This is a schematic diagram of the basic steps of the anomaly detection method based on federated learning and knowledge distillation in Embodiment 1 of the present invention;

[0068] Figure 2 This is a schematic diagram of the basic architecture and data flow processing of the anomaly detection system based on federated learning and knowledge distillation according to Embodiment 1 of the present invention.

[0069] Figure 3 This is a schematic diagram illustrating the specific steps of aggregating and distributing the global model in Embodiment 1 of the present invention;

[0070] Figure 4 This is a schematic diagram illustrating the specific steps of data preprocessing in Embodiment 1 of the present invention;

[0071] Figure 5 This is a schematic diagram illustrating the working principle of the knowledge distillation module in Embodiment 1 of the present invention;

[0072] Figure 6 This is a schematic diagram illustrating the specific steps of knowledge distillation in Embodiment 1 of the present invention;

[0073] Figure 7 This is a schematic diagram illustrating the specific steps of uploading a local model in Embodiment 1 of the present invention. Detailed Implementation

[0074] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, 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.

[0075] Example 1

[0076] like Figure 1 and Figure 2 As shown, the anomaly detection method based on federated learning and knowledge distillation provided by this invention includes the following basic steps:

[0077] Step S1: Aggregate and distribute the global model on the server side;

[0078] like Figure 3 As shown, in this embodiment, step S1, which aggregates and distributes the global model, further includes the following specific steps:

[0079] Step S11: If it is the first round of federated learning training, the server-side model deployer will generate the initial global model; if federated learning training has already started, the server-side model aggregator will aggregate all local models and generate the global model.

[0080] In this embodiment, the model deployer generates an initial global model and stores it in a global database. In this embodiment, the server broadcasts the global model to every client and uses it for anomaly detection.

[0081] Step S12: The server-side model deployer distributes the global model to all clients;

[0082] Step S13: Upload and store the hash value of the global model in the blockchain.

[0083] In this embodiment, the server waits for the client to upload local model parameters. After receiving all the local models, the model aggregator will perform an aggregation operation. After the aggregation is completed, the model aggregator will store the updated global model in the global database and pass the global model to the model deployer. This global model will be used for the next round of training.

[0084] Step S2: Use the IDW-SMOTE algorithm to complete data preprocessing;

[0085] In this embodiment, the original data is preprocessed before machine learning training on the client side to address the data imbalance problem of the original samples.

[0086] like Figure 4 As shown, in this embodiment, the data preprocessing step S2 further includes the following specific steps:

[0087] Step S21: The client first collects the raw data generated by the user and processes the raw data in the preprocessing module using the IDW-SMOTE algorithm to solve the data imbalance problem.

[0088] In this embodiment, the IDW-SMOTE algorithm randomly selects an initial sample from the minority class and then selects several samples from the neighboring points of that class and the initial sample as neighbors. Based on the Euclidean distance from the neighbors to the initial sample, the weight of each neighbor is calculated using inverse distance weighting. New sample points are generated based on the initial sample point, its neighbors, and their weights, and then added to the minority class. This process is repeated until the number of samples in the minority class is the same as the number of samples in the majority class.

[0089] In this embodiment, the data preprocessing module includes, but is not limited to: a preprocessing module, a distillation module, and a noise-adding module;

[0090] In the preprocessing module used in this embodiment, the inverse distance weighted SMOTE (IDW-SMOTE) algorithm is employed. During the execution of the IDW-SMOTE algorithm, for any random sample x in the minority class A, N samples are selected from the neighboring points of sample x in class A, thereby obtaining the K nearest neighbors of sample x. The number of samples N is determined manually based on the sampling imbalance ratio.

[0091] For sample x, calculate the Euclidean distance dj (j = 1, 2, ..., N) from each nearest neighbor. The weight of each neighbor is calculated based on inverse distance weighting (IDW). The calculation formula is as follows:

[0092]

[0093] Where wj represents the weight of neighbor j.

[0094] Generate a new sample point x new according to the following formula, and add the new sample point to class A:

[0095]

[0096] Where, randam(100) represents randomly selecting an integer in the range (1, 100);

[0097] Repeat the aforementioned DW-SMOTE algorithm execution process until the number of samples in the minority class is the same as the number of samples in the majority class;

[0098] In this embodiment, data preprocessing solves the problem of sample imbalance, and the processed data can be used as input to the distillation module for subsequent anomaly detection.

[0099] Step S22: Transmit the preprocessed data to the distillation module and use the global model issued by the server to complete anomaly detection and model compression;

[0100] like Figure 5 As shown, in this embodiment, the distillation module used in knowledge distillation includes: neural network, Softmax layer, soft labels, hard labels, and real labels.

[0101] In this embodiment, the neural network includes a teacher network and a student network; in this embodiment, the structure of the teacher network is more complex, see [link to documentation]. Figure 2 The network has five layers, while the student network has a relatively simple structure. (See [link to relevant documentation]). Figure 2 It has three floors.

[0102] In this embodiment, the teacher network needs to be pre-trained and distilled to extract knowledge so that the student network can learn; in this embodiment, the Softmax layer is used to map the output classification result to between 0 and 1, thereby converting the classification result of the neural network into the corresponding probability.

[0103] In this embodiment, different probabilities represent the likelihood that the sample belongs to the corresponding category; the higher the probability, the greater the likelihood that the sample belongs to that category, and the sum of the probabilities is 1. The result of a soft label is a probability distribution with values ​​between 0 and 1, while the result of a hard label is either 0 or 1. The true label is the actual classification result of the sample.

[0104] like Figure 6 As shown, in this embodiment, step S22 of performing knowledge distillation further includes the following specific steps:

[0105] Step S221: Input the preprocessed data into the teacher network for pre-training, and obtain the soft labels of the teacher network through the Softmax layer;

[0106] In this embodiment, Softmax is crucial for anomaly detection because the teacher network's output should ideally be a 0-1 classification result. However, such an output is indistinguishable from the hard labels output by the student network, resulting in a very small contribution of the teacher network to the loss function. Therefore, a Softmax layer is introduced to increase the contribution of the teacher network's loss to the distillation loss. Furthermore, the trained model itself can become overconfident because the probability distribution entropy of the Softmax output is very small, leading the model to place great confidence in its predictions, which may cause errors in anomaly detection. Therefore, a temperature T is introduced into the Softmax layer. When the difference between the two logits is large, temperature T can maintain the difference between the two outputs, preserving the model's knowledge. In this embodiment, logits represent the probability of not entering the Softmax layer.

[0107] In this embodiment, Softmax uses a gentler approach to highlight the probability of the correct class, and the temperature T is used to make the "softness" of Softmax an adjustable hyperparameter.

[0108] Based on the aforementioned logic, the Softmax of the teacher network can be converted using the following formula:

[0109]

[0110] Where q represents the probability output of the teacher network, T represents temperature, zi is the original value of each category involved in the classification, and zj is the original value of item j.

[0111] Step S222: Input the preprocessed data into the student network for training;

[0112] In this embodiment, when T=1, the hard labels are output, and the hard labels are combined with the real labels to obtain the loss of the student network;

[0113] Step S223: Based on the knowledge output of the teacher network, the student network should match the output of the teacher network as closely as possible;

[0114] In this embodiment, the new loss will be derived using the following formula:

[0115] L=αL soft +(1-α)L hard

[0116] Where α is the weight, Lsoft is the distillation loss, which is the cross-entropy between the soft labels output by the teacher network's Softmax and the soft labels output by the student network's Softmax at the same temperature T. Lhard is the loss of the student network at T=1. The formula for calculating Lsoft is as follows:

[0117] Lsoft =CE(q, p)·T 2

[0118] Where CE is the cross-entropy, p is the predicted value of the student network, and q is the probability output value of the teacher network;

[0119] In this embodiment, L hard is the cross-entropy between the hard label output by the student network Softmax and the real label when T=1. The formula for calculating L hard is as follows:

[0120] L hard =CE(y, p) where CE is the cross-entropy, y is the true label, and p is the predicted value of the student network. L hard is necessary because the teacher network also has a certain error rate, and using the true label can effectively reduce the possibility of errors being transmitted to the student network.

[0121] In summary, the aforementioned distillation process not only detects outlier data but also yields a small and accurate student model. In federated learning, transmitting this student model helps reduce communication costs.

[0122] Step S23: Transfer the trained local model to the noise-adding module, where noise is added to the local model to complete the encryption.

[0123] In the federated learning process of this embodiment, there is a risk of information leakage when the client uploads its local model to the server. Attackers may steal the local model during transmission and thus infer information from the original data. To protect data security during model transmission, a local differential privacy algorithm is introduced into the blockchain-based federated learning architecture. This algorithm is executed before uploading the local model, adding appropriate zero-mean Laplace noise to the gradient. The optimized gradient formula is as follows:

[0124] g new =clip(g,δ)+Laplace(0,λ)

[0125] Here, clip(g,δ) is used to determine the noise threshold, and the gradient g with δ needs to be noise-added. g represents the gradient without noise, δ represents the threshold, Laplace(0,λ) represents zero-mean Laplace noise, and λ is the noise scale. The noisy gradient will be uploaded to the server for aggregation.

[0126] Step S24: The client uploads the encrypted local model to the server and stores it in the database.

[0127] Step S3: Establish a machine learning model based on knowledge distillation to achieve anomaly detection;

[0128] In this embodiment, the data preprocessed in step S2 is used as the input to a machine learning neural network. A knowledge distillation-based machine learning model is used to detect anomalies and compress the generated local model. In this embodiment, the local model includes, but is not limited to, a teacher network, a student network, and a distillation network.

[0129] The teacher network used in this embodiment is a neural network with a relatively complex structure and superior performance. In this embodiment, the aforementioned teacher network needs to be pre-trained to extract the trained knowledge and obtain a teacher model for the student network to learn from.

[0130] The student network used in this embodiment is a relatively simple neural network.

[0131] The distillation network used in this embodiment has the same structure as the aforementioned student network. By using the distillation network to mimic the teacher network, the aforementioned teacher model is transformed into the student model, enabling the student model to achieve performance that is similar to or even better than that of the teacher model.

[0132] In the federated learning architecture adopted in this embodiment, the server and each client generate at least one blockchain node, which records relevant data from the server or client. To protect data privacy, an off-chain data storage design pattern is employed. The model data is structured, and the overall hash value is calculated. The hash value and related attributes of the data are uploaded to the blockchain, while the data itself is stored in the database of the server or client. This storage pattern improves storage efficiency, ensures data privacy by not directly storing the data model, and allows for the tracking of the data and model's origin through the data attributes stored in the blockchain, effectively ensuring data security.

[0133] In this embodiment, the aforementioned hash value and related data attributes include, but are not limited to: hash algorithm, timestamp, data owner signature, and data path.

[0134] Step S4: Encrypt the local model using a differential privacy algorithm;

[0135] In this embodiment, zero-mean Laplace noise is added to the local model obtained in step three, and the local differential privacy algorithm is executed. In this embodiment, the differential privacy algorithm is used to encrypt the local model, which effectively protects the data security during the communication process between the server and the client.

[0136] Step S5: Upload the encrypted local model.

[0137] like Figure 7 As shown, in this embodiment, step S5 of uploading the local model includes:

[0138] Step S51: Upload the encrypted local model to the server. After the server completes the aggregation, it will start the next round of federated learning training.

[0139] Step S52: Upload and store the hash value of the local model into the blockchain.

[0140] Example 2

[0141] This invention verifies the efficiency of the preprocessing algorithm and the anomaly detection of the distillation network, as shown in Tables 1, 2, and 3 below:

[0142] Table 1 Comparison of data preprocessing algorithms in the three datasets

[0143]

[0144]

[0145] Table 2 Comparison of different anomaly detection algorithms in the three datasets

[0146]

[0147] Table 3 Comparison of distillation network algorithms in the three datasets

[0148]

[0149]

[0150] The above results demonstrate that the IDW-SMOTE algorithm and distillation network of this invention are more efficient than traditional techniques.

[0151]

[0152] In summary, the anomaly detection machine learning method of this invention is characterized by high efficiency, security, and low overhead, and can be applied to joint anomaly detection by multiple institutions. Based on a federated learning framework, this invention proposes the IDW-SMOTE data preprocessing algorithm to address the imbalance problem of original sample data, uses a knowledge distillation algorithm to compress the model and reduce communication overhead, and introduces blockchain and differential privacy algorithms to protect data security and privacy.

[0153] This invention employs a knowledge distillation algorithm to preserve the knowledge learned from the original model through distillation, and then transfers the knowledge to a compressed model. Although the compressed model is much smaller than the original model, it can learn the same knowledge. Therefore, knowledge distillation can be applied to the local model of a federated learning compressed client to overcome the communication loss problem caused by the excessive size of the transmitted model.

[0154] This invention first ensures client-side data security and privacy through federated learning, blockchain, and differential privacy algorithms. Next, it utilizes the IDW-SMOTE data preprocessing algorithm to address the imbalance problem in raw sample data for anomaly detection. Finally, it combines knowledge distillation algorithms to compress the local model, thereby reducing communication overhead during model exchange between the server and client. The federated learning-based anomaly detection framework proposed in this invention achieves efficient, secure, and low-loss detection of cross-institutional anomaly data using the above algorithms.

[0155] This invention solves the technical problems of imbalanced original samples, high communication loss, and low level of data security and privacy protection in the prior art.

[0156] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications 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.

Claims

1. An anomaly detection method based on federated learning and knowledge distillation, characterized in that, The method includes: S1. Perform at least two rounds of federated learning training to generate a global model. On the server side, use a model aggregator to aggregate the global model and use a model deployer to distribute the global model to the client. S2. Obtain the raw data, use the IDW-SMOTE algorithm to perform data preprocessing operations to obtain balanced sample data, add noise to the local model on the client side to obtain an encrypted local model. S2 includes: S21. The client collects the raw data generated by the user, and the IDW-SMOTE algorithm is used in the preprocessing module to perform the data preprocessing operation on the raw data to obtain the balanced sample data. The preprocessing module includes: an inverse distance weighting module, a distillation module and a noise addition module. S21 includes: S211. Using the IDW-SMOTE algorithm, an initial sample is randomly selected from the preset minority class. Among the adjacent points of the preset minority class and the initial sample, no less than two neighbor samples are selected. S212. Based on the Euclidean distance from the neighbor sample to the initial sample, calculate the neighbor weight value of each neighbor sample through an inverse distance weighting operation; S213. Based on the initial sample, the neighbor sample, and the neighbor weight, generate and add new sample points to the preset minority class, wherein the neighbor weight is calculated through the inverse distance weighting operation (IDW). In the formula, wj Indicates neighbors j The weight, DJ Represents each nearest neighbor and sample x The Euclidean distance; S214. Repeat the above operation until the number of samples in the preset minority class is the same as the number of samples in the preset majority class; S22. The balanced data is transmitted to the distillation module for knowledge distillation. Using the global model on the server, anomaly detection and model compression are performed to detect abnormal data and obtain a suitable student model to obtain a suitable local model. The distillation module includes: a neural network, a Softmax layer, soft labels, hard labels, and real labels. The neural network includes: a teacher network and a student network. S23. The applicable local model is passed to the noise-adding module to add noise to the applicable local model, completing the encryption operation and obtaining an encrypted local model; wherein, in the blockchain-based federated learning architecture, a local differential privacy algorithm is used to add applicable zero-mean Laplace noise to the gradient for gradient tuning to complete the encryption operation, wherein the gradient tuning is performed using the following logic: In the formula, clip (g, δ This is used to determine the threshold for noise. δ The gradient g needs to have noise added, while g represents the gradient without noise. δ Indicates the threshold. Laplace (0, λ ) represents zero-mean Laplace noise. λ As a noise scale, the noisy gradient will be uploaded to the server for aggregation; S24. The client uploads the encrypted local model to the server and stores it in the global database; S3. Establish a machine learning model based on knowledge distillation to achieve anomaly detection. Use the balanced sample data as input to the machine learning neural network, use the machine learning model based on knowledge distillation to perform anomaly detection, and compress to generate the local model. The local model includes: a local teacher network, a local student network, and a local distillation network. S4. Add zero-mean Laplace noise to the local model and execute the local differential privacy algorithm to obtain an encrypted local model; S5. Upload the encrypted local model to the server.

2. The anomaly detection method based on federated learning and knowledge distillation according to claim 1, characterized in that, S1 includes: S11. In the first round of federated learning training, the model deployer on the server is used to generate an initial global model, and the initial global model is stored in the global database; during the federated learning training process, the model aggregator is used to aggregate local models to generate a global model. S12. Using the model deployer, distribute the global model to all clients; S13. The client uploads the hash value of the global model to the server and stores the hash value in a pre-set blockchain; S14 When the server receives all the local model parameters uploaded by the client, it will perform an aggregation operation using the model aggregator; S15. The model aggregator stores the updated global model in the global database and passes the global model to the model deployer for the next round of federated learning training.

3. The anomaly detection method based on federated learning and knowledge distillation according to claim 1, characterized in that, In step S213, the new sample points are generated using the following logic. x new The new sample points are added to the preset minority class A: In the formula, randam(100) represents randomly selecting an integer in the range (1,100).

4. The anomaly detection method based on federated learning and knowledge distillation according to claim 1, characterized in that, In step S22, the output knowledge data is obtained by pre-training and distilling the teacher network, and the student network learns the output knowledge data to obtain classification results. The Softmax layer is used to map the classification results to a preset interval to obtain corresponding probabilities. The probability distribution is obtained by processing the corresponding probabilities using soft labels, and the corresponding probabilities are processed using hard labels to obtain Boolean data, which is then processed using real labels to obtain the actual classification results.

5. The anomaly detection method based on federated learning and knowledge distillation according to claim 1, characterized in that, In step S22, the knowledge distillation operation includes: S221. The balanced data is input into the teacher network for pre-training. The soft labels of the teacher network are obtained through the Softmax layer. In the Softmax layer, when the difference between the probabilities logits of two entities that did not enter the Softmax layer is greater than a preset threshold, the temperature T is used to maintain the difference between the outputs in order to save the output knowledge data. The teacher network is transformed and processed in the Softmax layer using the following logic: In the formula, q This represents the probability output of the teacher network, where T represents temperature. zi These are the original values ​​for each category involved in the classification. zj It is a project j The original values ​​for the classification; S222. Input the balanced sample data into the student network for training. When the temperature T meets the preset conditions, combine the hard label, the soft label and the real label to obtain the student network loss. S223. Based on the knowledge output data of the teacher network, control the student network to perform teacher network fitting output operation to obtain the applicable student model.

6. The anomaly detection method based on federated learning and knowledge distillation according to claim 5, characterized in that, In step S223, the cross-entropy of the soft labels output by the Softmax layer of the teacher network and the soft labels output by the Softmax layer of the student network is determined using the following logic, under the same temperature T: In the formula, α As weight, L Softness represents distillation loss. L hard is the loss of the student network at T = 1. The distillation loss is determined using the following logic. L soft: In the formula, CE is the cross-entropy, p is the predicted value of the student network, and q is the probability output value of the teacher network. Using the following logic, at temperature T = 1, determine the cross-entropy between the hard label output by the Softmax layer of the student network and the real label. L hard: In the formula, CE is the cross-entropy, y is the true label, and p is the predicted value of the student network.

7. The anomaly detection method based on federated learning and knowledge distillation according to claim 1, characterized in that, S5 includes: S51. Upload the encrypted local model to the server. When the server completes the aggregation, it starts the next round of federated learning training. S52. Upload and store the hash value of the encrypted local model to the blockchain.

8. An anomaly detection system based on federated learning and knowledge distillation, used to execute the anomaly detection method based on federated learning and knowledge distillation as described in any one of claims 1 to 7, characterized in that, The system includes: The aggregation and deployment module is used to perform no less than two rounds of federated learning training to generate a global model. On the server side, the global model is aggregated using a model aggregator, and the global model is distributed to the client using a model deployer. The preprocessing module is used to obtain raw data, perform data preprocessing operations using the IDW-SMOTE algorithm to obtain balanced sample data, and add noise to the local model on the client to obtain an encrypted local model. The preprocessing module is connected to the aggregation deployment module. The knowledge distillation and anomaly detection module is used to establish a machine learning model based on knowledge distillation to achieve anomaly detection. The balanced sample data is used as the input of the machine learning neural network, and the machine learning model based on knowledge distillation is used to perform anomaly detection and compress to generate the local model. The local model includes a local teacher network, a local student network, and a local distillation network. The knowledge distillation and anomaly detection module is connected to the preprocessing module. A local model encryption module is used to add zero-mean Laplace noise to the local model and execute a local differential privacy algorithm to obtain an encrypted local model. The local model encryption module is connected to the knowledge distillation and anomaly detection module. A local model upload module is used to upload the encrypted local model to the server. The local model upload module is connected to the local model encryption module.

Citation Information

Patent Citations

  • Measurement learning-based federal learning malicious model updating detection method and system

    CN115907003A

  • Abnormal sample generation method, graph anomaly detection method and electronic equipment

    CN117828343A

  • Federal learning network flow classification model training method based on unbalanced data distribution, model and classification method

    CN115002031A

  • Federal learning aggregation method and system based on data-free distillation

    CN116629376A