A federated learning optimization method based on mutual knowledge transfer
By deploying large models in the federated learning system and utilizing knowledge distillation and mutual knowledge transfer technologies, the training process of the model on the local client is optimized, solving the problems of high computing resource requirements and data privacy protection for large models, and achieving model performance and security. sexual enhancement.
Patent Information
- Application Number
- CN202410783397.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2044-06-18
AI Technical Summary
Large models require a large amount of computing resources during training and inference, resulting in high costs. The large number of parameters of the model makes it difficult to explain the decision-making process and data security needs to be considered when processing personal privacy data. It is difficult to effectively improve model performance with existing technology. Generalization ability and safety.
Adopting a federated learning optimization method based on mutual knowledge transfer, by deploying a large model on the central server, using knowledge distillation to migrate its knowledge to the student model, and training on the local client, combined with mutual knowledge transfer technology, iterative optimization round by round model until the model converges.
It reduces the computing and storage requirements of the local client, improves model performance and generalization capabilities, alleviates the problem of catastrophic forgetting, and provides a new method for the field of data privacy protection, significantly improving the performance and security of federated models.
Smart Images

Figure CN118364898B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computing technology, and in particular to a federated learning optimization method based on mutual knowledge transfer. Background Art
[0002] At present, with the continuous innovation of computer hardware technology, computing power continues to improve. From single-core to multi-core, from CPU to GPU, and then to TPU, hardware devices provide strong support for the training and reasoning of large models. This provides the necessary conditions for the rise of large models. Large models require huge computing resources for parameter optimization and model training, and the high performance of modern hardware devices makes this process more efficient and feasible. However, the development of large models also faces some challenges and problems. The first is the increase in demand and cost of computing resources. Large models require a lot of computing resources for training and reasoning, and the acquisition and maintenance costs of these resources are high. The second is the problem of model interpretability and comprehensibility. The number of parameters of large models is huge, and it is often difficult to explain the decision-making process and reasoning logic, which brings difficulties to the application and evaluation of the model. In addition, data privacy and security issues also need to be paid attention to. Large models need to take effective privacy protection measures when processing personal privacy data.
[0003] It can be seen that there is an urgent need for a federated learning optimization method based on mutual knowledge transfer that can improve model performance, generalization ability and security. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a federated learning optimization method based on mutual knowledge transfer, which at least partially solves the problems of poor model performance, generalization ability and security in the prior art.
[0005] The embodiment of the present invention provides a federated learning optimization method based on mutual knowledge transfer, including:
[0006] Step 1: Select the corresponding large model according to the requirements of the task party received and deploy it on the central server of the federated learning system, and store the data set corresponding to the large model;
[0007] Step 2: Use the large model as the teacher model and transfer the knowledge of the large model to the distilled student model through knowledge distillation on the central server;
[0008] Step 3: Use the student model as the initial model of the federated learning system and send it to the local client of the federated system;
[0009] Step 4: The local client copies the issued initial model as a student model and saves it locally. Then, each local client uses its own local data set as the input of the model to train the initial model and update the initial model parameters to obtain a generation of local models after this round of training.
[0010] Step 5: The first-generation local model trained with the local data set continues to learn the knowledge of the student model through the mutual knowledge transfer technology to obtain the second-generation local model of the local client trained in this round;
[0011] Step 6: In one round of training, each local client uploads its own second-generation local model to the server, and the server aggregates the second-generation local models uploaded by the local clients to obtain the global model of this round of training;
[0012] In step 7, the global model after the previous round of training is sent again to each local client of the federated system. The local client uses the local data set to train the local model of this round again, and then repeats steps 5 and 6 for iterative training until the global model converges after the last round of training, and the training process ends.
[0013] According to a specific implementation of the embodiment of the present invention, step 5 specifically includes:
[0014] Step 5.1: Install the local client Dataset Divide into L small batches of size , denoted as ;
[0015] Step 5.2: Use the local model trained with the local dataset to imitate the output of the student model by minimizing the given loss function, and traverse the local client Local dataset Minimize the loss function and update the local model , get the The second-generation local model obtained by the local client in the tth round of training .
[0016] According to a specific implementation of an embodiment of the present invention, the expression for minimizing a given loss function is:
[0017] ;
[0018] in, for The true label set of the data samples in yes The true label of the zth sample in is the first generation local model trained by the k-th local client using local private data in the t-th round of training. is the soft prediction produced by the global model, are the soft predictions produced by the student model:
[0019]
[0020]
[0021] in and are two vectors of length C, representing the number of The soft prediction of the zth data sample in , It is the student network after knowledge distillation of the large model;
[0022] Represents the cross entropy error between the true label and the soft prediction
[0023]
[0024] in yes One-hot vector, All elements in are zero except the The elements are 1, and the second term in the loss function is to quantify the KL divergence of the soft prediction matching of the two networks, expressed as:
[0025] ;
[0026] The expression of the second-generation local model is:
[0027]
[0028] in, is the learning rate for mutual knowledge transfer.
[0029] According to a specific implementation of the embodiment of the present invention, step 6 specifically includes:
[0030] Each local client sends the second-generation local model Aggregate to the server to obtain the global model of the tth round of training , then t is incremented by 1 to proceed to the next round of iterative training.
[0031] According to a specific implementation of the embodiment of the present invention, the aggregation method adopted in step 6 is a federated averaging algorithm.
[0032] The federated learning optimization scheme based on mutual knowledge transfer in the embodiment of the present invention includes: step 1, selecting the corresponding large model according to the needs of the received task party and deploying it on the central server of the federated learning system, and storing the data set corresponding to the large model; step 2, using the large model as the teacher model, and migrating the knowledge of the large model to the distilled student model through knowledge distillation on the central server; step 3, using the student model as the initial model of the federated learning system, and sending it to the local client of the federated system; step 4, the local client copies the sent initial model as the student model and saves it locally, and then each local client uses its own local data set as the input of the model to train the initial model and update the initial model parameters to obtain the local model. The first-generation local model after round training; Step 5, the first-generation local model trained with the local data set continues to learn the knowledge of the student model through the mutual knowledge transfer technology to obtain the second-generation local model of the local client in this round of training; Step 6, in a round of training, each local client uploads its own second-generation local model to the server, and the server aggregates the second-generation local models uploaded by the local clients to obtain the global model of this round of training; Step 7, the global model after the previous round of training is sent again to each local client of the federal system, and the local client uses the local data set again to train the local model of this round, and then repeats steps 5 and 6 for iterative training until the global model converges after the last round of training is completed, and the training process ends.
[0033] The beneficial effects of the embodiments of the present invention are as follows: through the scheme of the present invention, the addition of the large model enables the local client to not only not have to bear the huge computing and storage requirements of the large model, but also run the model with the knowledge of the large model, thereby realizing model optimization in federated learning and improving model performance, so that the model run by the client in this method can achieve performance and generalization capabilities that cannot be achieved by federated training of ordinary models, and realize the catch-up of ordinary federated models to large models. For the catastrophic forgetting problem that occurs during the local training of the student model after the distillation of the large model, the knowledge of the large model can be continued to be learned after local training through the mutual knowledge transfer technology, thereby alleviating the catastrophic forgetting problem, thereby realizing the large model assisting the federated model optimization process to the greatest extent, and providing new ideas and methods for the application of large models in the field of data privacy, especially in the field of federated learning that protects data privacy, thereby significantly improving the performance of the federated model, realizing the optimization of the federated model, and through the mutual knowledge transfer technology, alleviating the catastrophic forgetting problem of the large model knowledge during local training. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0035] Figure 1 A schematic diagram of a flow chart of a federated learning optimization method based on mutual knowledge transfer provided by an embodiment of the present invention;
[0036] Figure 2 A schematic diagram of a specific implementation process of a federated learning optimization method based on mutual knowledge transfer provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0037] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0038] The following describes the embodiments of the present invention through specific examples, and those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be noted that the following embodiments and features in the embodiments can be combined with each other without conflict. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work belong to the scope of protection of the present invention.
[0039] It should be noted that various aspects of the embodiments within the scope of the appended claims are described below. It should be apparent that the aspects described herein can be embodied in a wide variety of forms, and any specific structure and / or function described herein is merely illustrative. Based on the present invention, it should be understood by those skilled in the art that an aspect described herein can be implemented independently of any other aspect, and two or more of these aspects can be combined in various ways. For example, any number of aspects described herein can be used to implement the device and / or practice the method. In addition, other structures and / or functionalities other than one or more of the aspects described herein can be used to implement this device and / or practice this method.
[0040] It should also be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention. The drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0041] Additionally, in the following description, specific details are provided to facilitate a thorough understanding of the examples. However, it will be understood by those skilled in the art that the aspects described may be practiced without these specific details.
[0042] An embodiment of the present invention provides a federated learning optimization method based on mutual knowledge transfer, which can be applied to the local client model training process in scenarios such as communities and hospitals.
[0043] See also Figure 1 , is a flow chart of a federated learning optimization method based on mutual knowledge transfer provided by an embodiment of the present invention. Figure 1 and Figure 2 As shown, the method mainly comprises the following steps:
[0044] Step 1: Select the corresponding large model according to the requirements of the task party received and deploy it on the central server of the federated learning system, and store the data set corresponding to the large model;
[0045] Federated learning is a distributed training method for machine learning that allows centralized model training while protecting data privacy. Traditional machine learning methods usually require all data to be centralized to a centralized server for training, while federated learning can perform local training on local devices and send updates to model parameters to a central server for aggregation, thereby achieving global training of the model. The core idea of federated learning is to separate the model training process from the storage of data to protect user privacy. In federated learning, the central server only receives and aggregates updates to model parameters and cannot directly access the user's original data. In this way, the user's data can always be kept locally and does not need to be transmitted to the central server, thereby reducing the risk of privacy leakage. Federated learning is suitable for scenarios where data is widely distributed and large in scale, such as smartphones, IoT devices, etc. It can use data on these distributed devices to train models, thereby improving the effectiveness and universality of the models while protecting the privacy of user data. Federated learning has broad application prospects in the fields of medicine, finance, intelligent transportation, etc., and has made remarkable research progress in recent years.
[0046] Studies have shown that today's large models are still limited by huge computing and storage requirements and cannot be applied in the context of data privacy protection, and there is no research result in this area in academia. Federated learning, as an important technology in the field of data privacy protection, can realize the application of large models in the field of data privacy protection by combining large models with federated learning. However, the combination of the two also still has a series of problems. For example, how to run the large model normally without violating the principle of non-sharing of privacy data in federated learning, how the network of the federated learning system can undertake the interactive communication between the large model and the server, and whether the local client of the federation has enough computing power and storage space to support the training of the large model. Based on these situations, the present invention proposes a federated learning optimization method based on mutual knowledge transfer in the context of data privacy protection. The proposed method can not only expand the application of large models in the field of data privacy protection, but also improve the model performance and generalization ability of federated learning, expand the application of federated learning, and enhance the status of federated learning in the field of data privacy.
[0047] In specific implementation, in a federated learning system, the central server has sufficient computing power and storage resources to support the normal operation of the large model. A large model is deployed on the central server and its corresponding data set is stored.
[0048] Step 2: Use the large model as the teacher model and transfer the knowledge of the large model to the distilled student model through knowledge distillation on the central server;
[0049] In the specific implementation, considering that the local client of the federated system may not be able to run the large model normally, the knowledge distillation, a large model knowledge transfer technology, is used to enable the model that has learned the knowledge of the large model to be trained normally on the local client. The stored large model data set can be used as input, and the knowledge distillation technology can be used to extract the knowledge of the large model as a guiding condition to guide the training of the student model, thus obtaining a student model that has learned the knowledge of the large model.
[0050] Knowledge distillation is an important machine learning technique, also known as the teacher-student neural network learning algorithm, which aims to improve the performance and generalization ability of the model by transferring the knowledge of a large model (teacher model) to a small model (student model). The core idea is to transform the comprehensive knowledge of the teacher model into a more concise and effective representation. In large model knowledge distillation, there are usually two main categories: standard knowledge distillation and knowledge distillation based on EA (emergent ability).
[0051] The main goal of standard knowledge distillation is to enable the student model to learn the common knowledge possessed by the large language model (LLM), such as output distribution and feature information. EA-based knowledge distillation not only transfers the common sense knowledge of LLM, but also focuses on distilling the emergent ability of LLM. This emergent ability refers to the surprising ability of LLM in handling complex tasks, including contextual learning (ICL), chain of thoughts (CoT) and instruction following (IF).
[0052] In practical applications, the process of large model knowledge distillation can select appropriate knowledge distillation methods to learn the knowledge of large models according to specific task requirements. In this way, the student model can not only maintain high performance, but also reduce the occupation of computing resources and storage space, and achieve model compression and acceleration.
[0053] For example, the specific process of large model knowledge distillation can be as follows:
[0054] The process of large model knowledge distillation can select appropriate knowledge distillation methods to learn the knowledge of large models according to task requirements. The following introduces a common large model knowledge distillation method, the specific process is as follows:
[0055] Assume that the number of sample training samples is N and the number of categories is C. is the loss function that the teacher model teaches the student model to learn:
[0056]
[0057] in
[0058]
[0059]
[0060] Where N represents the number of model training samples, p represents the output of the teacher model, q represents the output of the student model, T represents the temperature, represents the probability prediction value for the i-th category output by the teacher model, is the probability prediction value for the i-th category output by the student model, represents the output of the i-th sample in the teacher network at temperature T, represents the output of the i-th sample in the student network at temperature T, represents the i-th sample, represents the jth sample, represents the kth sample.
[0061] is the loss function that the student model learns by itself following the true label:
[0062]
[0063] in
[0064]
[0065] In fact, it is the same as the conventional model, that is, learning based on the labels of the training set. In the above formula, g is the true label, which is to calculate the cross entropy between the output result q of the student model and the label g.
[0066] The total loss is:
[0067]
[0068] in and is a parameter that balances the distillation loss and the student loss, and .
[0069] Step 3: Use the student model as the initial model of the federated learning system and send it to the local client of the federated system;
[0070] In specific implementation, after the student model is trained, the student model can be used as the initial model of the federated learning system and sent to the local client of the federated system.
[0071] Step 4: The local client copies the issued initial model as a student model and saves it locally. Then, each local client uses its own local data set as the input of the model to train the initial model and update the initial model parameters to obtain a generation of local models after this round of training.
[0072] In the specific implementation, for the initial model sent by the server, that is, the student model after the large model is distilled, first a copy of the student model is saved locally, and then each local client trains the model sent by the server according to its own local private data set. After the training is completed, the client obtains the first generation of local model trained in this round.
[0073] Step 5: The first-generation local model trained with the local data set continues to learn the knowledge of the student model through the mutual knowledge transfer technology to obtain the second-generation local model of the local client trained in this round;
[0074] Based on the above embodiment, step 5 specifically includes:
[0075] Step 5.1: Install the local client Dataset Divide into L small batches of size , denoted as ;
[0076] Step 5.2: Use the local model trained with the local dataset to imitate the output of the student model by minimizing the given loss function, and traverse the local client Local dataset Minimize the loss function and update the local model , get the The second-generation local model obtained by the local client in the tth round of training .
[0077] Furthermore, the expression for minimizing the given loss function is:
[0078]
[0079] in, for The true label set of the data samples in yes The true label of the zth sample in is the first generation local model trained by the k-th local client using local private data in the t-th round of training. is the soft prediction produced by the global model, are the soft predictions produced by the student model:
[0080]
[0081]
[0082] in and are two vectors of length C, representing the number of The soft prediction of the zth data sample in , It is the student network after knowledge distillation of the large model;
[0083] Represents the cross entropy error between the true label and the soft prediction
[0084]
[0085] in yes One-hot vector, All elements in are zero except the The elements are 1, and the second term in the loss function is to quantify the KL divergence of the soft prediction matching of the two networks, expressed as:
[0086] ;
[0087] The expression of the second-generation local model is:
[0088]
[0089] in, is the learning rate for mutual knowledge transfer.
[0090] In specific implementation, mutual knowledge transfer is a process where a local model learns the knowledge of another model by imitating the output of the student model. The specific process is as follows:
[0091] Local Client Dataset Divide into L small batches of size , denoted as , the different “expertise” of the two models leads to different outputs of their softmax layers, that is, soft predictions for the same mini-batch data samples.
[0092] On this basis, in order to transfer knowledge to each other, the output of the student network is imitated by minimizing the given loss function
[0093]
[0094] in for The true label set of the data samples in yes The true label of the zth sample in It is a generation of local model trained by the k-th client using local private data in the t-th round of training. is the soft prediction produced by the global model, are the soft predictions produced by the student model:
[0095]
[0096] in and are two vectors of length C, representing the number of The soft prediction of the zth data sample in , It is the student network after knowledge distillation of the large model.
[0097] The loss function Represents the cross entropy error between the true label and the soft prediction
[0098] ;
[0099] in yes One-hot vector, All elements in are zero except the The second term in the loss function quantifies the KL divergence of the two network soft prediction matches, given as follows:
[0100] ;
[0101] Then the first generation local model is updated to
[0102]
[0103] in, is the learning rate of mutual knowledge transfer. Local dataset and minimize the loss function, update , get the The second-generation local model obtained by the client in the tth round of training .
[0104] Step 6: In one round of training, each local client uploads its own second-generation local model to the server, and the server aggregates the second-generation local models uploaded by the local clients to obtain the global model of this round of training;
[0105] Based on the above embodiment, step 6 specifically includes:
[0106] Each local client sends the second-generation local model Aggregate to the server to obtain the global model of the tth round of training , then t is incremented by 1 to proceed to the next round of iterative training.
[0107] Furthermore, the aggregation method used in step 6 is a federated average algorithm.
[0108] In specific implementation, the specific training process of the federated model is mainly divided into the following three steps:
[0109] ① Task initialization: Before training begins, the server must first determine the training tasks and goals, select the devices participating in federated learning, and then send the student model obtained by distilling the above large model knowledge to the selected devices.
[0110] ② Local training and sharing: Each device uses private data to train a local model. The goal of training is to find the best local model. After the device is trained, the model parameters are uploaded to the server for the next step.
[0111] ③ Global aggregation and update: After the server collects the local models from all participating devices, it aggregates the model parameters. The typical aggregation operation is the average algorithm FedAvg. The federated learning server obtains the aggregated global model of this round by averaging the local model parameters, and then learns the knowledge of the large model through mutual knowledge transfer technology to obtain the final global model of this round. The goal is to find the best global model.
[0112] The above steps will be iterated sequentially, and the training will end when the global model converges or reaches a certain accuracy.
[0113] For the aggregation process of federated learning, the federated average algorithm can be used here. Of course, other model aggregation algorithms can also be used. In practical applications, the appropriate aggregation algorithm can be selected for federated learning based on task requirements in order to train a better model and obtain better model effects.
[0114] In step 7, the global model after the previous round of training is sent again to each local client of the federated system. The local client uses the local data set to train the local model of this round again, and then repeats steps 5 and 6 for iterative training until the global model converges after the last round of training, and the training process ends.
[0115] In specific implementation, the final global model obtained from the previous round of training can be sent to each participant, and each participant trains the local model again based on the local data set, and then repeats steps 5 and 6 for iterative training until the final global model after the last round of training converges, then all training processes are terminated.
[0116] The federated learning optimization method based on mutual knowledge transfer provided in this embodiment can expand the application of large models in the field of data privacy by using knowledge distillation and mutual knowledge transfer technology to learn the knowledge of large models, making the application of large models more extensive. At the same time, it allows the federated learning model to learn the knowledge of the large model, improve the performance and generalization ability of the model, and further expand the application of federated learning in the field of data privacy protection.
[0117] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof.
[0118] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A federated learning optimization method based on mutual knowledge transfer, It is characterized in that include: Step 1: Select the corresponding large model according to the requirements of the task party received and deploy it on the central server of the federated learning system, and store the data set corresponding to the large model; Step 2: Use the large model as the teacher model and transfer the knowledge of the large model to the distilled student model through knowledge distillation on the central server; Step 3: Use the student model as the initial model of the federated learning system and send it to the local client of the federated system; Step 4: The local client copies the issued initial model as a student model and saves it locally. Then, each local client uses its own local data set as the input of the initial model, trains the initial model and updates the initial model parameters to obtain a generation of local models after this round of training. Step 5: The first-generation local model trained with the local data set continues to learn the knowledge of the student model through the mutual knowledge transfer technology to obtain the second-generation local model of the local client trained in this round; The step 5 specifically includes: Step 5.1: Local client Dataset Divide into L small batches of size , denoted as ; Step 5.2: Use the local model trained with the local dataset to imitate the output of the student model by minimizing the given loss function, and traverse the local client Local dataset Minimize the loss function and update the local model , get the The second-generation local model obtained by the local client in the tth round of training ; The expression for minimizing the given loss function is in, for The true label set of the data samples in yes The true label of the zth sample in is the first generation local model trained by the k-th local client using local private data in the t-th round of training. is the soft prediction produced by the global model, are the soft predictions produced by the student model: in and are two vectors of length C, representing the number of The soft prediction of the zth data sample in , It is the student network after knowledge distillation of the large model; Represents the cross entropy error between the true label and the soft prediction in yes One-hot vector, All elements in are zero except the The elements are 1, and the second term in the loss function is to quantify the KL divergence of the soft prediction matching of the two networks, expressed as: ; The expression of the second-generation local model is: in, is the learning rate for mutual knowledge transfer; Step 6: In one round of training, each local client uploads its own second-generation local model to the server, and the server aggregates the second-generation local models uploaded by the local clients to obtain the global model of this round of training; In step 7, the global model after the previous round of training is sent again to each local client of the federated system. The local client uses the local data set to train the local model of this round again, and then repeats steps 5 and 6 for iterative training until the global model converges after the last round of training, and the training process ends.
2. The method according to claim 1, Features , the step 6 specifically includes: Each local client sends the second-generation local model Aggregate to the server to obtain the global model of the tth round of training , then t is incremented by 1 to proceed to the next round of iterative training.
3. The method according to claim 2, Features ,The aggregation method adopted in step 6 is the federated average algorithm.
