A method, device and storage medium for joint training of a model
By segmenting and distributing the initial global model, ensuring that the client only knows some model parameters, it solves the problem that the client learns global model parameters in traditional federated learning, resulting in lower security, and achieves higher model security.
Patent Information
- Application Number
- CN202010947310.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-10
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2040-09-10
AI Technical Summary
In federated learning, traditional practices allow each client to know the parameters of the global model, causing the server to lose control of the model, and the security of the global model is reduced, which easily leads to leakage.
By segmenting the initial global model, a set of sub-models is obtained. The parameters of each sub-model are less than those of the initial global model and are distributed to different clients for training, so that the client only knows the parameters of some models and cannot know all parameters of the global model.
On the premise of ensuring that the training effect of the federated learning model is not affected, the security of the federated learning model is improved and information leakage is prevented.
Smart Images

Figure CN112163675B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of artificial intelligence technology, and relates to, but is not limited to, a method, device, and storage medium for jointly training a model. Background Art
[0002] Federated learning technology is a newly emerging privacy protection technology that can effectively combine data from all parties for model training without the data leaving the local area.
[0003] When using federated learning to jointly train multiple clients, the traditional approach is to initialize a global model and send the parameters of the initialized global model to each client for local training. After the training is completed, a local model is obtained, and then the server aggregates multiple local models to update the initialized global model. Repeating the above steps yields the final trained global model. This traditional approach makes the local model of each client consistent with the global model, allowing the client to know the parameters of the global model and use the model for other tasks on its own, resulting in the server losing control of the model. And in many scenarios, the server only wants to use the local data of the client for joint training to improve the performance of the global model, and does not want the client to know all the parameters of the global model, leading to a reduction in the security of the global model and easy leakage of secrets. Summary of the Invention
[0004] Embodiments of this application provide a method, device, equipment, and storage medium for jointly training a model, which can improve the security of the federated learning model.
[0005] The technical solution of the embodiments of this application is implemented as follows:
[0006] Embodiments of this application provide a method for jointly training a model. The method is applied to a server device and includes:
[0007] Split an initial global model to obtain a set of sub-models, where the parameters in each sub-model in the set of sub-models are fewer than the parameters in the initial global model;
[0008] Send at least two sub-models in the set of sub-models to at least two clients, where different sub-models are sent to different clients;
[0009] Receive the trained sub-models sent by at least one client, where the trained sub-models are obtained by the client training the received sub-models based on training data;
[0010] Synthesize a current global model based on the trained sub-models and the initial global model.
[0011] An embodiment of the present application provides a method for joint training of a model. The method is applied to a client and includes:
[0012] Receiving a sub-model sent by a server device, where the parameters in the sub-model are fewer than those in the initial global model;
[0013] Obtaining training data for training the sub-model from its own storage space;
[0014] Training the sub-model based on the training data to obtain a trained sub-model;
[0015] Sending the trained sub-model to the server device.
[0016] An embodiment of the present application provides a device for joint training of a model. The device is applied to a server device and includes:
[0017] A splitting module, configured to split an initial global model to obtain a set of sub-models, where the parameters in each sub-model in the set of sub-models are fewer than those in the initial global model;
[0018] A first sending module, configured to send at least two sub-models in the set of sub-models to at least two clients, where different sub-models are sent to different clients;
[0019] A first receiving module, configured to receive trained sub-models sent by at least one client, where the trained sub-models are obtained by the client training the received sub-model based on training data;
[0020] A synthesizing module, configured to synthesize a current global model based on the trained sub-models and the initial global model.
[0021] An embodiment of the present application provides a device for joint training of a model. The device is applied to a client and includes:
[0022] A second receiving module, configured to receive a sub-model sent by a server device, where the parameters in the sub-model are fewer than those in the initial global model;
[0023] A fifth obtaining module, configured to obtain training data for training the sub-model from its own storage space;
[0024] A training module, configured to train the sub-model based on the training data to obtain a trained sub-model;
[0025] A second sending module, configured to send the trained sub-model to the server device.
[0026] An embodiment of the present application provides a device for jointly training a model, including:
[0027] A memory for storing executable instructions;
[0028] A processor for implementing the method provided by the embodiment of the present application when executing the executable instructions stored in the memory.
[0029] An embodiment of the present application provides a storage medium storing executable instructions for causing a processor to implement the method provided by the embodiment of the present application when executed.
[0030] The embodiment of the present application has the following beneficial effects:
[0031] In the method for jointly training a model provided by the embodiment of the present application, the server device splits the initial global model, and sends at least two sub-models obtained by the splitting to at least two clients, so that different clients receive different sub-models. After the server device receives the trained sub-models obtained by the clients training the sub-models based on the training data, it synthesizes the current global model based on the trained sub-models and the initial global model. In this way, by splitting the global model and distributing it to different clients for sub-model training, each client only knows the parameters of part of the model and cannot know all the parameters of the global model. Then the server device synthesizes the trained sub-models to obtain an updated global model, which can improve the security of the federated learning model on the premise of ensuring that the training effect of the federated learning model is not affected. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 It is a schematic diagram of the implementation process of the method for jointly training a model in the related art;
[0033] Figure 2 It is a schematic diagram of the network architecture of the method for jointly training a model provided by the embodiment of the present application;
[0034] Figure 3 It is a schematic diagram of the composition structure of the device for jointly training a model provided by the embodiment of the present application;
[0035] Figure 4 It is a schematic diagram of an implementation process of the method for jointly training a model provided by the embodiment of the present application;
[0036] Figure 5A It is a schematic diagram of the server device splitting the initial global model;
[0037] Figure 5B It is a schematic diagram of the server device synthesizing the current global model;
[0038] Figure 6Another schematic diagram of the implementation process of the joint training method of the model provided by the embodiment of the present application;
[0039] Figure 7 Another schematic diagram of the implementation process of the joint training method of the model provided by the embodiment of the present application;
[0040] Figure 8 Another schematic diagram of the implementation process of the joint training method of the model provided by the embodiment of the present application;
[0041] Figure 9 Another schematic diagram of the server-side splitting of the global model provided by the embodiment of the present application. Detailed implementation manners
[0042] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be construed as limiting the present application. All other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0043] In the following description, "some embodiments" are involved, which describe a subset of all possible embodiments. However, it can be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments, and can be combined with each other without conflict.
[0044] In the following description, the terms "first / second / third" involved are only used to distinguish similar objects, and do not represent a specific order for the objects. It can be understood that "first / second / third" can be interchanged with a specific order or sequence when allowed, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0045] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the technical field to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0046] Before further elaborating on the embodiments of the present application, the nouns and terms involved in the embodiments of the present application are described. The nouns and terms involved in the embodiments of the present application are applicable to the following explanations.
[0047] 1) Federated Learning, an emerging basic technology of artificial intelligence, whose design goal is to carry out efficient machine learning among multiple participants or multiple computing nodes while ensuring information security during big data exchange, protecting terminal data and personal data privacy, and ensuring legality and compliance.
[0048] 2) Horizontal Federated Learning. When the users of two datasets are different and have little overlap, but the user features overlap more, the datasets are split horizontally (i.e., along the user dimension), and a part of the data with the same user features but different users is selected for training in machine learning.
[0049] To better understand the embodiments of the present application, first, the joint training method of the model in the related art and its existing drawbacks will be described.
[0050] Figure 1 It is a schematic diagram of the implementation process of the joint training method of the model in the related art. As Figure 1 shown, the server uses horizontal federated learning to conduct joint training on multiple hospitals (clients). The server first initializes the global model, and then sends the parameters of the initialized global model to each client for local training. Subsequently, each client returns the trained global model to the server, and the server aggregates the received trained global models of each client to obtain an updated global model. Although federated learning is completed by the client using the data stored on its own during training without sending the data to the server, it can greatly reduce the problem of data privacy leakage to a large extent; however, it is necessary for the server to send the global model parameters to each client. When the server only wants to use the data of the client participants for joint training to improve the effect of the global model and does not want the client to know all the parameters of the global model, the horizontal federated learning in the related art enables each client to know the structure of the global model, and the client can use the model by itself for other work, resulting in the server losing control of the global model and causing information leakage of the global model.
[0051] Based on the above problems, in the embodiments of the present application, a joint training method of the model is provided. The partial models obtained by splitting the global model are sent to different clients for training, so that each client only knows the parameters of the partial model and cannot know all the parameters of the global model, ensuring the security of the global model when using the data of each client for joint training.
[0052] Next, the exemplary application of the device implementing the embodiments of the present application will be described. The device provided in the embodiments of the present application can be implemented as a terminal device. Next, the exemplary application covering the terminal device when the device is implemented as a terminal device will be described.
[0053] Figure 2 It is a schematic diagram of the network architecture of the joint training method of the model provided in the embodiments of the present application. As Figure 2 shown, in this network architecture, at least a server device (including server 100) and clients (at least including two clients 200) are included.Figure 2 Exemplarily shown in the figure are 3 clients 200, denoted as client 200-1, client 200-2, and client 200-3 respectively for distinction. In actual implementation, there may be more clients), and a network 300. To support an exemplary application, the server 100 can be a federated learning service terminal, such as a server, etc. The server 100 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server based on cloud technology, and is used to assist each bank or hospital client terminal to perform federated learning to obtain a federated learning model. The client 200 (including client 200-1, client 200-2, and client 200-3) can be a client terminal of a federated learning participant, such as a participating device of each bank or hospital that stores user feature data. The client 200 can be a notebook computer, a tablet computer, a desktop computer, a dedicated training device, or other devices with model training functions. The server 100 is connected to at least two clients 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two, and uses wireless or wired links to achieve data transmission.
[0054] Based on the model joint training method provided in the embodiments of the present application, the server 100 can split the initial global model into multiple sub-models, so that the number of parameters in each sub-model is less than that in the initial global model, and then distribute the multiple sub-models to different clients 200, so that each client 200 only knows part of the parameters of the global model; the client 200 uses the training data (such as banking business data, hospital pathological feature data, etc.) in its own storage space to train the received sub-model to obtain a trained sub-model, and returns the trained sub-model to the server 100; the server 100 receives the trained sub-models returned by at least one client, and synthesizes the current global model based on the trained sub-models and the initial global model. By splitting the global model and distributing it to different clients for sub-model training, each client only knows part of the model parameters and cannot know all the parameters of the global model. The server then synthesizes the trained sub-models to obtain an updated global model, which can improve the security of the federated learning model on the premise of ensuring that the training effect of the federated learning model is not affected.
[0055] The device provided in the embodiments of the present application can be implemented in a hardware or a combination of hardware and software manner. The following describes various exemplary implementations of the device provided in the embodiments of the present application.
[0056] According to Figure 3The exemplary structure of the server 100 shown can foresee other exemplary structures of the server 100. Therefore, the structures described here should not be regarded as restrictive. For example, some components described below can be omitted, or components not described below can be added to meet the special requirements of certain applications.
[0057] Figure 3 The server 100 shown includes: at least one processor 110, a memory 140, at least one network interface 120, and a user interface 130. Each component in the server 100 is coupled together through a bus system 150. It can be understood that the bus system 150 is used to realize the connection and communication between these components. In addition to the data bus, the bus system 150 also includes a power bus, a control bus, and a status signal bus. However, for the sake of clear illustration, in Figure 3 all kinds of buses are labeled as the bus system 150.
[0058] The user interface 130 may include a display, a keyboard, a mouse, a touchpad, and a touch screen, etc.
[0059] The memory 140 can be a volatile memory or a non-volatile memory, or can include both volatile and non-volatile memories. Among them, the non-volatile memory can be a read-only memory (ROM, Read Only Memory). The volatile memory can be a random access memory (RAM, Random Access Memory). The memory 140 described in the embodiments of the present application is intended to include any suitable type of memory.
[0060] The memory 140 in the embodiments of the present application can store data to support the operation of the server 100. Examples of these data include: any computer programs for operating on the server 100, such as an operating system and application programs. Among them, the operating system contains various system programs, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks. The application programs can contain various application programs.
[0061] As an example of the method provided in the embodiments of the present application being implemented in software, the method provided in the embodiments of the present application can be directly embodied as a combination of software modules executed by the processor 110. The software modules can be located in a storage medium. The storage medium is located in the memory 140. The processor 110 reads the executable instructions included in the software modules in the memory 140 and combines the necessary hardware (for example, including the processor 110 and other components connected to the bus 150) to complete the method provided in the embodiments of the present application.
[0062] As an example, the processor 110 may be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or any conventional processor, etc.
[0063] The exemplary application and implementation of the terminal provided in the embodiments of the present application will be combined to illustrate the joint training method of the model provided in the embodiments of the present application.
[0064] Figure 4 It is a schematic flowchart of an implementation process of the joint training method of the model provided in the embodiments of the present application, which is applied to Figure 2 the server device of the network architecture shown, and will be described in combination with Figure 4 the steps shown.
[0065] Step S401: Split the initial global model to obtain a set of sub-models.
[0066] Here, the parameters in each sub-model in the set of sub-models are fewer than the parameters in the initial global model.
[0067] In order to prevent each client from learning the global model structure of the server device and causing the leakage of global model information, in the embodiments of the present application, the initial global model is split, and all the sub-models obtained by the split are determined as the set of sub-models. Among them, the set of sub-models includes at least two sub-models, and each sub-model only has a part of the structure of the initial global model.
[0068] Refer to Figure 5A , Figure 5A which is a schematic diagram of splitting the initial global model for the server device. Figure 5A In, the initial global model 51 includes 10 parameters, and two sub-models are obtained after splitting twice: sub-model 52 and sub-model 53. Among them, the black nodes in sub-model 52 and sub-model 53 represent the split parameters and are included in the sub-model, and the gray nodes represent the deleted parameters and are not included in the sub-model. It can be seen from Figure 5A that sub-model 52 includes 5 parameters and sub-model 53 includes 6 parameters. Obviously, the parameters included in sub-model 52 and sub-model 53 are both fewer than the parameters included in the initial global model.
[0069] Step S402: Send at least two sub-models in the set of sub-models to at least two clients.
[0070] The server device sends at least two sub-models obtained by splitting to different clients respectively, and different sub-models are sent to different clients, so that each client can only know a part of the structure of the global model and cannot know the entire structure of the global model, ensuring the security of the global model.
[0071] For example, the sub-model 52 is sent to the first client, and the first client cannot know Figure 5A other nodes in the sub-model 52 except the black nodes, and the second client also cannot know Figure 5A other nodes in the sub-model 53 except the black nodes.
[0072] When the client receives the sub-model, it first determines the training data from the local data in its own storage space. This training data is the data related to the parameters in the sub-model. Using the obtained training data, the sub-model is trained. Since it cannot know other parameters in the initial global model except the parameters in the sub-model, other parameters will not be trained, and the trained sub-model corresponding to the sub-model is obtained. Then, the client sends the trained sub-model back to the server device.
[0073] Step S403: Receive the trained sub-models sent by at least one client.
[0074] Wherein, the trained sub-model is obtained by the client training the received sub-model based on the training data.
[0075] After the server device sends the sub-model to the client, if the client disconnects from the server device at this time, the server device cannot receive the trained sub-model sent by this client. Therefore, the number of trained sub-models received by the server device is not greater than the number of sent sub-models. For example, after the server device sends the sub-model 53 to the second client and the second client disconnects from the server device, the server device can only receive the trained sub-model sent by the first client.
[0076] Step S404: Synthesize the current global model based on the trained sub-model and the initial global model.
[0077] The parameters in the trained sub-model are synthesized with the other parameters in the initial global model except the parameters in the trained sub-model to obtain the current global model.
[0078] See Figure 5B , Figure 5BSchematic diagram for the server device to synthesize the current global model. The first client trains the sub-model 52 to obtain the trained sub-model 52'. Based on the trained sub-model 52' and the initial global model 51, the current global model 51' is synthesized. Among them, the synthesized current global model includes all parameters, and the performance of this current global model is better than the training performance of the initial global model.
[0079] The method for jointly training the model provided by the embodiments of the present application includes: splitting the initial global model to obtain a set of sub-models, where the parameters in each sub-model in the set of sub-models are less than the parameters in the initial global model; sending at least two sub-models in the set of sub-models to at least two clients, where different sub-models are sent to different clients; receiving the trained sub-models sent by at least one client, and the trained sub-models are obtained by the client training the received sub-model based on the training data; synthesizing the current global model based on the trained sub-models and the initial global model. By splitting the global model and distributing it to different clients for training the sub-models, each client only knows the parameters of part of the model and cannot know all the parameters of the global model. Then the server device synthesizes the trained sub-models to obtain the updated global model, which can improve the security of the federated learning model on the premise of ensuring that the training effect of the federated learning model is not affected.
[0080] In some embodiments, before the server device splits the initial global model, the method may further include the following steps:
[0081] Step S31, obtaining the number of clients connected to itself and the number of parameters in the initial global model.
[0082] When the number of clients is 1, federated learning cannot be formed. Only when the number of clients is greater than 1, at least 2, can federated learning be realized; at the same time, the number of sub-models split by the server device is also related to the number of parameters in the initial global model. Therefore, in the embodiments of the present application, before the server device splits the initial global model, it is necessary to first obtain the number of clients accessing the server device and the number of parameters in the initial global model.
[0083] In one implementation, the server device can monitor in real time the number of clients connected to itself, and determine the number of clients according to the real-time monitored data.
[0084] Step S32, when the number of clients is greater than 1, determining the splitting number based on the number of clients and the number of parameters.
[0085] Here, the number of splits is the number of sub-models included in the sub-model set, and the number of splits is an integer greater than or equal to 2. To ensure that each split sub-model is distributed to different clients, in some embodiments, the number of splits is less than or equal to the number of clients.
[0086] In the embodiments of the present application, the server device can more accurately determine the number of splits according to the obtained number of clients and the number of parameters in the initial global model.
[0087] In some embodiments, Figure 4 In the shown embodiment, step S401 "Split the initial global model to obtain a sub-model set" can be implemented through the following steps:
[0088] Step S4011, randomly select at least two parameters from multiple parameters of the initial global model.
[0089] In the embodiments of the present application, the number of parameters in the initial global model is denoted as M, and each time of splitting, i parameters are randomly selected from M parameters. Here, i is an integer greater than 1 and less than M.
[0090] Step S4012, obtain the initial weight values of the at least two parameters.
[0091] Step S4013, determine a split sub-model based on the at least two parameters and the initial weight values of the at least two parameters.
[0092] For example, the initial global model is as Figure 5A The shown initial global model 51, the number of splits is 6. In the 5th split, i parameters are randomly selected from 10 parameters of the initial global model 51, such as Figure 5A The 6 parameters within the dotted line 54 shown, and then obtain the initial weight values of the 6 parameters, and determine the sub-model 53 composed of the 6 parameters and the initial weight values of the 6 parameters as the 5th sub-model.
[0093] Split the initial global model multiple times, that is, repeat steps S4011 to S4013 multiple times to obtain multiple sub-models split from the initial global model.
[0094] Step S4014, determine the multiple sub-models obtained from multiple splits as the sub-model set.
[0095] In the embodiments of the present application, since i parameters are randomly selected each time of splitting, the parameters in each sub-model obtained from multiple splits may be different or the same. When the parameters in each sub-model obtained from multiple splits are the same, such as Figure 5AThe initial global model 51 shown, the first sub-model obtained by the first segmentation and the fifth sub-model obtained by the fifth segmentation. However, when distributing, the first sub-model and the fifth sub-model are distributed to different clients, and different clients use different training data for training, and the trained sub-models obtained are different. Therefore, different trained sub-models can be used to update the initial global model.
[0096] In the embodiments of the present application, the union of the parameters in each sub-model obtained by multiple segmentations may be equal to the set of all parameters in the initial global model, or may be a subset of the set of all parameters in the initial global model. When the union of the parameters in each sub-model obtained by multiple segmentations is a subset of the set of all parameters in the initial global model, as Figure 5A shown in the initial global model 51, after two segmentations, the sub-model 52 and the sub-model 53 are obtained. The union of the parameters in the sub-model 52 and the parameters in the sub-model 53 is a subset of the parameters in the initial global model 51, excluding the parameter 511 and the parameter 512. At this time, the sub-model 52 and the sub-model 53 are distributed to different clients for training to obtain two trained sub-models, and the initial weight values of the parameters 511 and 512 in the initial global model will not be updated by the two trained sub-models.
[0097] In the embodiments of the present application, each segmentation randomly selects some parameters from the initial global model, which can ensure that after multiple trainings, the obtained current global model can be consistent with the global model obtained by sending the global model to the client for training in the related art.
[0098] In some embodiments, Figure 4 In the embodiment shown, the step S404 "synthesize the current global model based on the trained sub-model and the initial global model" can be implemented by the following steps:
[0099] Step S4041, determine the training parameter set according to the trained sub-model.
[0100] Here, when implementing step S4041, first obtain the parameter sets in each trained sub-model, and then determine the union of each parameter set as the training parameter set.
[0101] For example, the training parameters included in the first parameter set obtained according to the trained sub-model 52' are {a, b, c, d, e}, and the training parameters included in the second parameter set obtained according to the trained sub-model 53' are {c, d, e, f, g, h}. Then the determined training parameter set is the union of the first parameter set and the second parameter set, that is, {a, b, c, d, e, f, g, h}.
[0102] Step S4042: Determine the current weight values of the respective training parameters in the training parameter set based on the trained sub-models.
[0103] In the embodiments of the present application, if a training parameter only exists in one trained sub-model, the training weight value of the training parameter in the trained sub-model is determined as the current weight value of the training parameter. For example, if training parameters a and b only exist in the trained sub-model 52', the training weight of a in the trained sub-model 52' is determined as the current weight value of a, and the training weight of b is determined as the current weight of b. Similarly, the current weight values of f, g, and h are obtained.
[0104] If a training parameter exists in at least two trained sub-models, based on at least two training weight values of the same training parameter in the at least two trained sub-models, determine the current weight value of the training parameter. For example, if training parameters c, d, and e exist in both the trained sub-model 52' and the trained sub-model 53', then the current weight values of c, d, and e are determined according to the two trained sub-models. In some embodiments, the weighted average of the training weights of the same training parameter in each trained sub-model can be calculated, and the weighted average is determined as the current weight value of the training parameter.
[0105] In some embodiments, the determination of the current weight values of the respective training parameters in the training parameter set based on the trained sub-models can be implemented as follows: Based on the trained sub-models, obtain the respective training weight values of the respective training parameters in the training parameter set, calculate the average value of the training weight values of the respective training parameters, and obtain the current weight values of the respective training parameters.
[0106] For example, based on the trained sub-models, obtain the respective training weight values of the k-th training parameter in the training parameter set, where k = 1, 2,..., K, and K is the number of training parameters in the training parameter set; calculate the average value of the respective training weight values of the k-th training parameter to obtain the current weight value of the k-th training parameter, and calculate for each training parameter in the training parameter set respectively to obtain the current weight values of the respective training parameters.
[0107] Step S4043: Replace the initial weight values of the respective training parameters in the initial global model with the current weight values to obtain the current global model.
[0108] After obtaining the current weight values of the respective training parameters, replace the initial weight values of the corresponding parameters in the initial global model to obtain the current global model.
[0109] The method provided by the embodiments of the present application determines which parameters in the initial global model have been trained according to the parameters in each trained sub-model and the weight values of each parameter, obtains the current weight values of these trained parameters, and then determines the current global model according to the trained parameters, the current weight values of the trained parameters, and the other parameters in the initial global model except the trained parameters and the initial weight values of the other parameters. The training effect of the current global model is better than that of the initial global model.
[0110] In some embodiments, as Figure 6 shown, after step S404 of the embodiment shown in Figure 4 the method may further include the following steps:
[0111] Step S405, determining whether the current global model converges.
[0112] When it is determined that the current global model converges, it indicates that the current global model has been trained, and at this time, step S406 is entered; when it is determined that the current global model does not converge, it indicates that the current global model has not been trained, and at this time, step S408 is entered to continue the joint training.
[0113] Step S406, determining that the training is completed.
[0114] Step S407, determining the current global model as the target federated learning model.
[0115] Step S408, updating the current updated global model to the initial global model, and continuing the joint training until a convergent current global model is obtained.
[0116] After multiple trainings, when the current global model converges, it is determined that the convergent current global model is the target federated learning model. The other parameters in the target federated learning model except the trained parameters and the initial weight values of the other parameters are used to determine the current global model, and the training effect of the current global model is better than that of the initial global model.
[0117] In some embodiments, when determining whether the current global model converges in step S405 above, the following several methods can be used to implement it:
[0118] The first method is to determine convergence through the number of syntheses. At this time, it can be implemented through the following steps:
[0119] Step S405a1, obtaining the number of syntheses.
[0120] Step S405a2, determining whether the number of syntheses reaches a preset number threshold.
[0121] When the number of syntheses is greater than or equal to the preset number threshold, proceed to step S405a3; when the number of syntheses is less than the preset number threshold, proceed to step S405a4.
[0122] Step S405a3, determine that the current global model converges.
[0123] Step S405a4, determine that the current global model does not converge.
[0124] In some embodiments, the preset number threshold can be determined according to empirical values or default values. For example, when the number of syntheses reaches 100 times, it is considered that the current global model converges.
[0125] The second method is to determine convergence through the convergence error, which can be achieved through the following steps:
[0126] Step S405b1, obtain multiple current global models obtained from adjacent syntheses.
[0127] Step S405b2, calculate the differences between the multiple current global models.
[0128] In some embodiments, obtain P current global models obtained from adjacent P syntheses, calculate the differences between the P current global models, and the variance of the current weight values of the current global model and the current weight values of the previous P - 1 times can be used as the differences between the P current global models.
[0129] Step S405b3, determine whether the differences are less than the preset difference threshold.
[0130] When the differences are less than the preset difference threshold, proceed to step S405b4; when the differences are greater than or equal to the preset difference threshold, proceed to step S405b5.
[0131] Step S405b4, determine that the current global model converges.
[0132] Step S405b5, determine that the current global model does not converge.
[0133] In some embodiments, it can be determined whether the differences between the current global model and the current global models determined in the previous 9 adjacent times are less than the preset difference threshold. The difference threshold can be preset by the user, such as set to 0.1. When the difference is less than 0.1, it is determined that the current global model converges. Of course, the difference threshold can also use the default value, which is not limited in the embodiments of the present application.
[0134] The third method is to determine convergence through the joint training duration, which can be achieved through the following steps:
[0135] Step S405c1, obtain the joint training duration.
[0136] Step S405c2: Determine whether the joint training duration is greater than a preset duration threshold.
[0137] When the joint training duration is greater than the preset duration threshold, go to step S405c3; when the joint training duration is less than or equal to the preset duration threshold, go to step S405c4.
[0138] Step S405c3: Determine that the current global model converges.
[0139] Step S405c4: Determine that the current global model does not converge.
[0140] In some embodiments, the preset duration threshold can be determined according to empirical values or default values. For example, when the joint training duration reaches 10 minutes, it is considered that the current global model converges.
[0141] Based on the foregoing embodiments, an embodiment of the present application further provides a method for jointly training a model, which is applied to Figure 2 a client in the network architecture shown, and the method includes:
[0142] Step S501: Receive a sub-model sent by a server device.
[0143] Here, the number of parameters in the sub-model is less than the number of parameters in the initial global model.
[0144] The client receives a sub-model sent by the server device. The number of parameters in the sub-model is less than the number of parameters in the initial global model, so that the client can only know some parameters and cannot obtain all the parameters of the global model, that is, cannot know the entire structure of the global model, thereby ensuring the security of the global model of the server device.
[0145] Step S502: Obtain training data for training the sub-model from its own storage space.
[0146] Step S503: Train the sub-model based on the training data to obtain a trained sub-model.
[0147] In some embodiments, step S503 can be implemented as:
[0148] Step S5031: Parse the sub-model to obtain each parameter included in the sub-model and the initial weight value of each parameter;
[0149] Step S5032: Train the initial weight values of the respective parameters based on the training data to obtain trained respective training weight values;
[0150] Step S5033: Determine the trained sub-model based on the various parameters and the training weight values of the various parameters.
[0151] When the client receives the sub-model, it first determines the training data from the local data in its own storage space. This training data is data related to the parameters in the sub-model. Using the obtained training data, the sub-model is trained. Since it is impossible to know the other parameters in the initial global model except for the parameters in the sub-model, no other parameters will be trained, and the trained sub-model corresponding to the sub-model is obtained. Then, the client sends the trained sub-model back to the server device.
[0152] Step S504: Send the trained sub-model to the server device.
[0153] The model collaborative training method provided by the embodiments of the present application includes: receiving a sub-model sent by a server device, where the parameters in the sub-model are fewer than those in the initial global model, obtaining training data for training the sub-model from its own storage space, training the sub-model based on the training data to obtain a trained sub-model, and sending the trained sub-model to the server device. By locally training the sub-model obtained by splitting the initial global model, each client only knows the parameters of part of the model and cannot know all the parameters of the global model. Then, the server device sends the trained sub-model to the server device for synthesis to obtain an updated global model, which can improve the security of the federated learning model on the premise of ensuring that the training effect of the federated learning model is not affected.
[0154] Based on the foregoing embodiments, the embodiments of the present application further provide a model collaborative training method, which is applied to Figure 2 the network architecture shown in Figure 7 which is another schematic flowchart of the implementation of the model collaborative training method provided by the embodiments of the present application, as shown in Figure 7 shown, the method includes:
[0155] Step S701: The server device obtains the number of clients connected to itself and the number of parameters M in the initial global model.
[0156] Step S702: When the number of clients is greater than 1, the server device determines the splitting number N based on the number of clients and the number of parameters M.
[0157] Where N is an integer greater than or equal to 2.
[0158] Step S703: The server device initializes j to 1.
[0159] Step S704, the server device randomly selects i parameters from the M parameters of the initial global model.
[0160] Where i is an integer greater than 1 and less than M, such that the number of parameters in each sub-model in the sub-model set is less than the number of parameters in the initial global model.
[0161] Step S705, the server device obtains the initial weight values of the i parameters.
[0162] Step S706, the server device determines the j-th sub-model based on the i parameters and the initial weight values of the i parameters.
[0163] Step S707, the server device increments j by 1.
[0164] Step S708, the server device determines whether j is greater than N.
[0165] When j is greater than N, it indicates that the splitting has been performed N times and N sub-models have been obtained. At this time, step S709 is entered; when j is less than or equal to N, it indicates that the splitting is not completed, and the process returns to step S704 to continue splitting.
[0166] Step S709, the server device determines the N sub-models obtained by splitting as the sub-model set.
[0167] Step S710, the server device sends at least two sub-models in the sub-model set to at least two clients.
[0168] Among them, different sub-models are sent to different clients. In the embodiments of the present application, they are respectively sent to the first client and the second client.
[0169] Step S711, the client obtains the training data for training the sub-model from its own storage space.
[0170] Step S712, the client parses the sub-model to obtain the Q parameters included in the sub-model and the initial weight values of the Q parameters.
[0171] Where Q is the number of parameters in the sub-model.
[0172] Step S713, the client trains the initial weight values of the Q parameters based on the training data to obtain the trained Q training weight values.
[0173] Step S714, the client determines the trained sub-model based on the Q parameters and the trained Q training weight values.
[0174] Step S715, the client sends the trained sub-model to the server device.
[0175] Step S716, the server device determines a set of training parameters according to the trained sub-model.
[0176] Step S717, the server device obtains the respective training weight values of the k-th training parameter in the set of training parameters based on the trained sub-model.
[0177] Where k = 1, 2, …, K, and K is the number of training parameters in the set of training parameters.
[0178] Step S718, the server device calculates the average value of the respective training weight values of the k-th training parameter to obtain the current weight value of the k-th training parameter.
[0179] Step S719, the server device replaces the initial weight values of the respective training parameters in the initial global model with the current weight values to obtain the current global model.
[0180] Step S720, the server device determines whether the current global model converges.
[0181] When it is determined that the current global model converges, go to Step S721; when it is determined that the current global model does not converge, return to Step S701 to continue the collaborative training.
[0182] In some embodiments, Step S720 can be implemented as: obtaining the number of synthesis times; when the number of synthesis times reaches a preset number threshold, determining that the current global model converges; when the number of synthesis times does not reach the preset number threshold, determining that the current global model does not converge.
[0183] In some embodiments, Step S720 can also be implemented as: obtaining P current global models obtained by adjacent P syntheses; calculating the difference between the P current global models; when the difference is less than a preset difference threshold, determining that the current global model converges; when the difference is greater than or equal to the preset difference threshold, determining that the current global model does not converge.
[0184] In some embodiments, Step S720 can further be implemented as: obtaining the collaborative training duration; when the collaborative training duration is greater than a preset duration threshold, determining that the current global model converges; when the collaborative training duration is less than or equal to the preset duration threshold, determining that the current global model does not converge.
[0185] Step S721, the server device determines that the training is completed and determines the current global model as the target federated learning model.
[0186] The joint training method of the model provided by the embodiment of the present application divides the global model and distributes it to different clients for sub-model training, so that each client only knows part of the model parameters and cannot know all the parameters of the global model. Then the server device synthesizes the trained sub-models to obtain the current global model, and ends the training until the current global model converges, obtaining the target federated learning model. Without affecting the training effect of the federated learning model, the security of the federated learning model can be improved.
[0187] Next, an exemplary application of the embodiment of the present application in an actual application scenario will be described.
[0188] As can be seen from Figure 1 the joint training method of the model shown, although federated learning in the related art greatly alleviates the problem of data privacy leakage, each participating party knows the structure of the global model, which causes information leakage of the global model structure.
[0189] For example, when we use federated learning to jointly train multiple hospitals, at the beginning, we need to initialize the global model and send the parameters of the initialized global model to each client for local training. Therefore, the local model of each client is the same as the global model, and in fact, it knows the structure of the global model. However, in many scenarios, this approach has the following problems:
[0190] 1) The server only wants to use the data of the client participating parties for joint training of the model to improve the effect of the global model, and does not want the client participating parties to know all the parameters of the global model.
[0191] 2) If the client participating parties know the structure parameters of the global model, the server loses control of the model, and the client can use the model for other work by itself.
[0192] To solve this problem, the embodiment of the present application further provides a joint training method of the model. Figure 8 This is another schematic diagram of the implementation process of the joint training method of the model provided by the embodiment of the present application. In the solution of dividing the global model on the server side, after dividing the model, it is distributed to each client participating party. Each client participating party only has a part of the model structure. Therefore, each client does not know the structure of the global model.
[0193] In the embodiment of the present application, S represents the global model to be jointly trained;
[0194] N represents the number of clients;
[0195] C i represents the i-th client;
[0196] S i : represents the local model obtained by the i-th client;
[0197] Without loss of generality, assume that currently N = 3, that is, the number of clients connected to the server is 3.
[0198] As Figure 8 shown, the embodiments of the present application include the following steps:
[0199] Step S801, the server initializes the global model S and randomly divides the model into N parts.
[0200] Where N represents the number of clients. Figure 9 This is another schematic diagram of the server dividing the global model provided by the embodiments of the present application. As Figure 9 shown, the global model S is divided into three sub-models, namely S 1 , S 2 , S 3 , and they are sent to three clients respectively. Here, S i , in fact, does not really cut it all off, but sets the node weights of other parameters except the randomly selected parameters in the global model (corresponding to the initial weight values in the above text) to 0. In this way, even if the client C i receives S i , it only knows the partial parameters included in the sub-model and the parameter weight values corresponding to this part of the parameters, and does not know the remaining parameters and the parameter weight values corresponding to other parameters, thus ensuring the security of the global model.
[0201] Step S802, each i-th client C i after receiving S i , uses local data for training, and the global model changes from S i to S (i,k) .
[0202] During the process of the client training the sub-model, it cannot know the parameters with a weight value of 0, so there is no need to train other parameters.
[0203] Step S803, the client returns S (i,k) to the server, and the server performs aggregation to obtain the updated global model S.
[0204] Step S804, determine whether the global model converges.
[0205] When the global model converges, it indicates that the training is over, and at this time, enter step S805; when the global model does not converge, return to step S801 and repeat the above four steps until the global model converges.
[0206] Step S805: Determine that the training is completed and determine the current global model as the target federated learning model.
[0207] A solution for splitting a global model on the server side proposed in the embodiments of the present application distributes the split global model to each client participant. Each client participant only has a part of the structure of the global model. Therefore, each client does not know the structure of the global model, realizing the protection of the global model.
[0208] Next, continue to describe the exemplary structure of the software module implementation of the model joint training device provided in the embodiments of the present application. In some embodiments, as Figure 3 shown, the software module in the model joint training device 90 stored in the memory 140 may include:
[0209] A splitting module 91, configured to split an initial global model to obtain a set of sub-models, where the parameters in each sub-model in the set of sub-models are less than the parameters in the initial global model;
[0210] A first sending module 92, configured to send at least two sub-models in the set of sub-models to at least two clients, where different sub-models are sent to different clients;
[0211] A first receiving module 93, configured to receive the trained sub-models sent by at least one client, where the trained sub-models are obtained by the client training the received sub-models based on training data;
[0212] A synthesizing module 94, configured to synthesize a current global model based on the trained sub-models and the initial global model.
[0213] In some embodiments, the splitting module 91 may further be configured to:
[0214] Randomly select at least two parameters from multiple parameters of the initial global model;
[0215] Obtain the initial weight values of the at least two parameters;
[0216] Determine a sub-model obtained by splitting based on the at least two parameters and the initial weight values of the at least two parameters;
[0217] Determine multiple sub-models obtained by multiple splittings as the set of sub-models.
[0218] In some embodiments, the model joint training device 90 may further include:
[0219] A first obtaining module, configured to obtain the number of clients connected to itself and the number of parameters in the initial global model;
[0220] A first determination module, configured to determine the number of splits based on the number of clients and the number of parameters when the number of clients is greater than 1.
[0221] In some embodiments, the synthesis module 94 may further be configured to:
[0222] Determine a training parameter set according to the trained sub-model;
[0223] Based on the trained sub-model, determine the current weight value of each training parameter in the training parameter set;
[0224] Replace the initial weight value of each training parameter in the initial global model with the current weight value to obtain the current global model.
[0225] In some embodiments, the synthesis module 94 may further be configured to:
[0226] Based on the trained sub-model, obtain the respective training weight values of each training parameter in the training parameter set;
[0227] Calculate the average value of the training weight values of each training parameter to obtain the current weight value of each training parameter.
[0228] In some embodiments, the joint training device 90 of the model may further include:
[0229] A second determination module, configured to determine that the training is completed when it is determined that the current global model converges;
[0230] A third determination module, configured to determine the current global model as the target federated learning model.
[0231] In some embodiments, the joint training device 90 of the model may further include:
[0232] A second acquisition module, configured to acquire the number of synthesis times;
[0233] A fourth determination module, configured to determine that the current global model converges when the number of synthesis times reaches a preset number threshold;
[0234] A fifth determination module, configured to determine that the current global model does not converge when the number of synthesis times does not reach the preset number threshold.
[0235] In some embodiments, the joint training device 90 of the model may further include:
[0236] A third acquisition module, configured to acquire multiple current global models obtained by adjacent multiple syntheses;
[0237] A calculation module, configured to calculate the difference between the multiple current global models;
[0238] A sixth determination module, configured to determine that the current global model converges when the difference is less than a preset difference threshold;
[0239] A seventh determination module, configured to determine that the current global model does not converge when the difference is greater than or equal to the preset difference threshold.
[0240] In some embodiments, the joint training device 90 of the model may further include:
[0241] A fourth acquisition module, configured to acquire the joint training duration;
[0242] An eighth determination module, configured to determine that the current global model converges when the joint training duration is greater than a preset duration threshold;
[0243] A ninth determination module, configured to determine that the current global model does not converge when the joint training duration is less than or equal to the preset duration threshold.
[0244] In some embodiments, the joint training device 90 of the model may further include:
[0245] An update module, configured to update the current updated global model to the initial global model when it is determined that the current global model does not converge, and continue joint training until a converged current global model is obtained.
[0246] Based on the foregoing embodiments, an embodiment of the present application further provides a joint training device for a model, and the device at least includes:
[0247] A second receiving module, configured to receive a sub-model sent by a server device, where the parameters in the sub-model are fewer than the parameters in the initial global model;
[0248] A fifth acquisition module, configured to acquire training data for training the sub-model from its own storage space;
[0249] A training module, configured to train the sub-model based on the training data to obtain a trained sub-model;
[0250] A second sending module, configured to send the trained sub-model to the server device.
[0251] In some embodiments, the training module may further be configured to:
[0252] Parse the sub-model to obtain each parameter included in the sub-model and the initial weight value of each parameter;
[0253] Train the initial weight values of the respective parameters based on the training data to obtain the trained weight values of the respective parameters;
[0254] Determine the trained sub-model based on the respective parameters and the trained weight values of the respective parameters.
[0255] It should be noted here that: the description of the above embodiments of the joint training device of the model is similar to the above method description and has the same beneficial effects as the method embodiments. For the technical details not disclosed in the embodiments of the joint training device of the model of the present application, those skilled in the art may refer to the description of the method embodiments of the present application for understanding.
[0256] The embodiments of the present application provide a storage medium storing executable instructions, where the executable instructions, when executed by a processor, will cause the processor to execute the method provided by the embodiments of the present application. For example, as Figure 4 、 Figure 6 、 Figure 7 and Figure 8 the methods shown.
[0257] In some embodiments, the storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disc, or CD-ROM; or it may be various devices including one or any combination of the above memories.
[0258] In some embodiments, the executable instructions may be in the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including being deployed as an independent program or being deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0259] As an example, the executable instructions may or may not correspond to files in the file system, may be stored as part of a file storing other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, stored in a single file dedicated to the program being discussed, or stored in multiple cooperating files (for example, files storing one or more modules, subroutines, or code portions).
[0260] As an example, the executable instructions may be deployed to be executed on one computing device, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network.
[0261] As described above, the above are only embodiments of the present application and are not intended to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and scope of the present application are all included in the protection scope of the present application.
Claims
1. A method for joint training of a model, characterized in that, the method is applied to a server device, and the method includes: Randomly select at least two parameters from multiple parameters of an initial global model, and determine a sub-model obtained by segmentation based on the at least two parameters and the initial weights of the at least two parameters. Determine multiple sub-models obtained by multiple segmentations as a sub-model set, and the parameters in each sub-model in the sub-model set are fewer than those in the initial global model; Send at least two sub-models in the sub-model set to at least two clients, where different sub-models are sent to different clients; Receive the trained sub-models sent by at least one client, and the trained sub-models are obtained by the client training the received sub-models based on training data; Determine a training parameter set. If the training parameter in the training parameter set is in one of the trained sub-models, determine the training weight value of the training parameter in the trained sub-model as the current weight value of the training parameter; If the training parameter is in multiple trained sub-models, determine the average value of the training weight values of the training parameter in each of the trained sub-models where it is located as the current weight value of the training parameter; Replace the initial weight values of each training parameter in the initial global model with the current weight values to obtain the current global model.
2. The method according to claim 1, characterized in that, the method further includes: Obtain the number of clients connected to itself and the number of parameters in the initial global model; When the number of clients is greater than 1, determine the number of segmentations based on the number of clients and the number of parameters.
3. The method according to claim 1, characterized in that, the method further includes: Determine a training parameter set according to the trained sub-model; Determine the current weight value of each training parameter in the training parameter set based on the trained sub-model.
4. The method according to claim 1, characterized in that, the step of determining the average value of the training weight values of the training parameter in each of the trained sub-models where it is located as the current weight value of the training parameter includes: Based on the trained sub-model, obtain the training weight values of each training parameter in the training parameter set; Calculate the average value of the training weight values of each training parameter to obtain the current weight value of each training parameter.
5. The method according to claim 1, characterized in that, the method further includes: When it is determined that the current global model converges, determine that the training is completed; Determine the current global model as the target federated learning model.
6. The method according to claim 5, characterized in that, the method further includes: Obtain the number of synthesis times; when the number of synthesis times reaches a preset number threshold, determine that the current global model converges; and / or, Obtain multiple current global models obtained by adjacent multiple syntheses; calculate the difference between the multiple current global models; when the difference is less than a preset difference threshold, determine that the current global model converges; Obtain the collaborative training duration; when the collaborative training duration is greater than a preset duration threshold, determine that the current global model converges.
7. The method according to claim 1, wherein, the method further includes: when it is determined that the current global model does not converge, update the current updated global model to the initial global model, and continue with collaborative training until a converged current global model is obtained.
8. A method for collaborative training of a model, wherein, the method is applied to a client, and the method includes: Receive a sub-model sent by a server device, where the parameters in the sub-model are fewer than the parameters in the initial global model. Among them, the server device randomly selects at least two parameters from multiple parameters of the initial global model, and determines a sub-model obtained by splitting based on the at least two parameters and the initial weights of the at least two parameters. The multiple sub-models obtained by multiple splits are determined as a sub-model set; Obtain training data for training the sub-model from its own storage space; Train the sub-model based on the training data to obtain a trained sub-model; Send the trained sub-model to the server device. Among them, determine a training parameter set. If the training parameter in the training parameter set is in one of the trained sub-models, determine the training weight value of the training parameter in the trained sub-model where it is located as the current weight value of the training parameter. If the training parameter is in multiple trained sub-models, determine the average value of the training weight values of the training parameter in each of the trained sub-models where it is located as the current weight value of the training parameter. Replace the initial weight values of each training parameter in the initial global model with the current weight values to obtain the current global model.
9. The method according to claim 8, wherein, the training the sub-model based on the training data to obtain a trained sub-model includes: Parse the sub-model to obtain each parameter included in the sub-model and the initial weight values of each parameter; Train the initial weight values of each parameter based on the training data to obtain trained weight values for each parameter; Determine a trained sub-model based on each parameter and the trained weight values of each parameter.
10. A device for collaborative training of a model, wherein, the device includes: A memory for storing executable instructions; A processor, when executing the executable instructions stored in the memory, implements the method according to any one of claims 1 to 7 or claims 8 to 9.
11. A storage medium, wherein, stores executable instructions for causing a processor to implement the method according to any one of claims 1 to 7 or claims 8 to 9 when executed.
Citation Information
Patent Citations
Model joint training method and device for protecting privacyPrivacy protection model joint training method and device
CN111340242A