A multi-model federated learning method, system and storage medium
The multi-model federated learning method optimizes model allocation across multiple clients, addressing inefficiencies in single-model training by maximizing resource utilization and enhancing training efficiency.
Patent Information
- Application Number
- CN202210581613.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2042-05-26
AI Technical Summary
Existing federated learning systems are inefficient in utilizing client resources as they focus on single-model training, leading to waste of powerful client capabilities and suboptimal utilization.
A multi-model federated learning method that optimizes the allocation of multiple models to different clients based on client resources, using an optimization allocation matrix to ensure timely completion and aggregation of model parameters, thereby maximizing training efficiency.
The method enhances overall training efficiency by fully utilizing client resources and improving performance in multi-model training scenarios.
Smart Images

Figure CN114841016B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to a multi-model federated learning method, system and storage medium. Background Art
[0002] In recent years, federated learning has attracted great attention as a distributed machine learning paradigm. Under the management of a central server (referred to as the server), it allows distributed client devices (referred to as clients) to join AI (Artificial Intelligence) model training without requiring them to share their respective private data, thereby protecting user privacy while breaking data silos and improving the training efficiency of AI models.
[0003] According to the basic framework of the federated learning system, the server communicates with different clients participating in the federated learning training through the network, distributes the model to be trained to each client for training in an iterative manner, and each iteration the client completes a model training and uploads the trained model parameters to the server. The server aggregates the received model parameters and (if necessary) starts the next round of iterative training of a model until the model reaches a certain inference accuracy or the number of iterations reaches a certain threshold.
[0004] Based on the above framework, the existing scheme sets a fixed upper limit time T for each round of training, and designs a client selection method. In each round of training, the existing scheme first randomly selects a certain proportion of clients from all available clients, and then selects as many clients as possible from the randomly selected clients that can make the actual federated training time per round less than or equal to the upper limit time T. This scheme is designed for single model training and cannot fully utilize client resources.
[0005] Based on the above framework, existing federated learning systems focus on single-model training, that is, the system is only responsible for training one model at a time. In such a system, the server is responsible for managing the federated training of a single model, and the training process is carried out in an iterative manner; in each round of iteration, the server selects a certain number of clients to participate in the training of a single model, and each client trains the single model once; in each round of iteration, in order to complete a round of iterative training, the server needs to wait for the client with the slowest training process to complete the training. Therefore, the existing single-model federated learning system will waste a lot of powerful client resources, and the capabilities of these clients are not fully utilized because only one model can be trained in each round. Summary of the invention
[0006] The purpose of the embodiments of this specification is to provide a multi-model federated learning method, system and storage medium.
[0007] To solve the above technical problems, the embodiments of the present application are implemented in the following ways:
[0008] In a first aspect, the present application provides a multi-model federated learning method, the method comprising:
[0009] The server obtains a set of models to be trained; the set of models to be trained includes several models to be trained;
[0010] The server adopts a multi-model optimization allocation method to generate an optimization allocation matrix to allocate the models to be trained to different clients according to the optimization allocation matrix; so that each client downloads its corresponding model to be trained according to the instructions of the optimization allocation matrix generated by the server, completes the current round of model training, and uploads the trained model parameters to the server; wherein, according to the optimization allocation matrix, each client needs to complete its own model training task within a preset time;
[0011] The server receives the model parameters uploaded by the client within a preset time and aggregates the model parameters;
[0012] The server determines the accuracy of each model to be trained and the total number of model training rounds based on the aggregated model parameters. For models to be trained that meet the accuracy requirements or whose number of training rounds exceeds the round number threshold, the training is terminated and the other models to be trained enter the next round of training.
[0013] In one embodiment, a multi-model optimization allocation method is used to generate an optimization allocation matrix, including:
[0014] Randomly assign the model to be trained to each client to obtain the initial assignment matrix;
[0015] According to the initial allocation matrix and the model accuracy function table, the corresponding initial objective function value is calculated;
[0016] Based on the initial objective function value, construct the indexes of all possible allocation attempts of the model to be trained to obtain an index set;
[0017] According to the index set, an optimized allocation matrix is determined.
[0018] In one embodiment, the structure of the model accuracy function table includes: model type, initial model accuracy, number of clients used for model training, and end model accuracy; creation of the model accuracy function table includes:
[0019] Obtaining mathematical models;
[0020] Based on the mathematical model, the final model accuracy of different types of models after one round of training is calculated when different initial model accuracies and different numbers of clients are used;
[0021] The correspondence between all model types, initial model accuracy, number of clients used, and final model accuracy forms an initial model accuracy function table.
[0022] In one embodiment, updating the model accuracy function table includes:
[0023] After each round of model training, obtain the model training type during this round of training, the initial training model accuracy at the beginning of this round, the number of clients used in this round of training, and the final training model accuracy at the end of this round;
[0024] Update the corresponding model accuracy function table according to the training type, start training model accuracy, client training quantity, and end training model accuracy.
[0025] In one embodiment, according to the training category, the start training model accuracy, the training quantity of the client, and the end training model accuracy, the corresponding model accuracy function table is updated, including:
[0026] From the records of the corresponding training category in the model accuracy function table, find the data record that is closest to the start training model accuracy and the number of trainings on the client, and update the end model accuracy in the data record to the end training model accuracy.
[0027] In one embodiment, according to the initial allocation matrix and the model accuracy function table, the corresponding initial objective function value is calculated, including:
[0028] Get the initial training accuracy of any model at the beginning of this round of training;
[0029] Under the condition of the initial allocation matrix, the expected inference accuracy is determined according to the model accuracy function table and the initial training accuracy;
[0030] Determine the initial objective function value based on the initial training accuracy and expected inference accuracy.
[0031] In one embodiment, determining an optimized allocation matrix according to an index set includes:
[0032] Determine whether the index collection is empty;
[0033] If the index set is empty, the current allocation matrix is output as the optimized allocation matrix;
[0034] If the index set is not empty, for each possible allocation attempt recorded in the index set, under the current allocation matrix, try to allocate clients to each model according to the allocation attempt, and at the same time, remove one or more allocated models on the client so that the client can complete model training within the preset time, record the attempted model allocation matrix, and calculate the attempted objective function value corresponding to the attempted model allocation matrix;
[0035] According to all possible allocation attempts recorded in the index set and the corresponding allocation matrix of the attempt model and the attempt objective function value, the allocation attempt corresponding to the maximum attempt objective function value is selected as the best allocation attempt, and the attempt objective function value corresponding to the best allocation attempt is the maximum attempt objective function value;
[0036] If the maximum attempted objective function value is less than or equal to the current objective function value, the current allocation matrix is output as the optimized allocation matrix;
[0037] If the maximum attempt objective function value is greater than the current objective function value, update the current allocation matrix to the best allocation matrix corresponding to the best allocation attempt, update the variable corresponding to the current objective function value to the variable corresponding to the maximum attempt objective function value, delete the best allocation attempt from the index set, and return to determine whether the index set is empty to continue execution.
[0038] In one embodiment, the set of models to be trained includes newly injected models to be trained and / or models remaining to be trained after the previous round of training.
[0039] In a second aspect, the present application provides a multi-model federated learning system, the system comprising:
[0040] The server is used to obtain a set of models to be trained; the set of models to be trained includes a plurality of models to be trained; and a multi-model optimization allocation method is used to generate an optimization allocation matrix, and the models to be trained are allocated to different clients according to the optimization allocation matrix;
[0041] Several clients are used to download their corresponding models to be trained according to the instructions of the optimization allocation matrix, complete the current round of model training, and upload the trained model parameters to the server; wherein, according to the optimization allocation matrix, each client needs to complete its own model training task within a preset time;
[0042] The server is also used to receive the model parameters uploaded by the client within a preset time and aggregate the model parameters; and determine the accuracy of each model to be trained and the total number of model training rounds based on the aggregated model parameters, and end the training for the model to be trained that meets the accuracy requirements or the number of training rounds exceeds the round number threshold, and the other models to be trained enter the next round of training.
[0043] In a third aspect, the present application provides a readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the multi-model federated learning method as in the first aspect.
[0044] It can be seen from the technical solution provided in the above embodiments of this specification that this solution: based on the differences in client resources, optimizes the allocation of training tasks from multiple models to multiple clients, and is expected to maximize the overall training efficiency of multiple models, and can make full use of client resources, thereby significantly improving training efficiency during multi-model training. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0046] Figure 1 A schematic diagram of the structure of the multi-model federated learning system provided for this application;
[0047] Figure 2 A flowchart of the multi-model federated learning method provided for this application;
[0048] Figure 3 Another flowchart of the multi-model federated learning method provided for this application;
[0049] Figure 4 A schematic diagram of the process flow of the multi-model optimization allocation method provided in this application. DETAILED DESCRIPTION
[0050] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.
[0051] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0052] It will be apparent to those skilled in the art that various modifications and variations may be made to the specific embodiments of the present application description without departing from the scope or spirit of the present application. Other embodiments derived from the present application description will be apparent to those skilled in the art. The present application description and examples are exemplary only.
[0053] The words “include,” “including,” “have,” “contain,” etc. used in this document are open-ended terms, meaning including but not limited to.
[0054] Unless otherwise specified, "parts" in this application are all calculated by mass.
[0055] In the related art, the existing federated learning systems are all focused on single-model training, that is, the system is only responsible for training one model at a time. In such a system, the server is responsible for managing the federated training of a single model, and the training process is carried out in an iterative manner; in each round of iteration, the server selects a certain number of clients to participate in the training of a single model, and each client trains the single model once; in each round of iteration, the server needs to wait for the slowest client to complete a round of training. Therefore, the existing single-model federated learning system will waste a lot of powerful client resources, and the capabilities of these clients are not fully utilized because only one model can be trained in each round.
[0056] Based on this, this application proposes a multi-model federated learning method, which is based on an efficient multi-model federated learning system to train multiple models in parallel. The system takes into account the differences in client resources, optimizes the allocation of training tasks from multiple models to multiple clients, and maximizes the overall training efficiency of multiple models. It can make full use of client resources and achieve significant performance improvements in multi-model training.
[0057] The present invention is further described in detail below with reference to the accompanying drawings and embodiments.
[0058] The method provided in the embodiment of the present application is applied to a multi-model federated learning system, and the multi-model federated learning system refers to a system used to implement the multi-model federated learning method. Figure 1 A schematic diagram of a multi-model federated learning system provided in an embodiment of the present application is shown. Figure 1 As shown, the system includes a server 11 and several clients 12 that can participate in model training. Each client 12, as a participant in federated learning, has its own user data (i.e., private data). The server 11 and the client 12 communicate through the Internet (including backbone networks and various types of access networks) to implement federated learning.
[0059] Among them, the client 12 can be a PC client, a mobile client, a smart vehicle client, etc.
[0060] Among them, the server 11 manages the training of multiple AI models and is responsible for managing the parallel federated learning of multiple models in a cyclic iterative manner until each model reaches its preset inference accuracy or the total number of iterative training of the model reaches the preset maximum threshold. In each round of iteration, the server executes a multi-model optimization allocation method, assigns multiple models to multiple randomly selected clients for parallel training, and aggregates the model parameters after client training to improve the model inference accuracy and achieve high-performance multi-model federated learning.
[0061] In order to achieve the optimal allocation of multiple models to multiple clients, the server communicates with each client at a certain period to obtain dynamic and different information about the client, including the bandwidth capacity for uploading and downloading model data, the models that private data can support training, the computing power of model training, etc., so as to dynamically estimate the total time required for a client i to train a model j (denoted as δ ij ), including the time required for the client to download and upload model parameters and the time required to train the model once with its private data, so that the server can perform optimal distribution of calculations from multiple models to multiple clients based on this information.
[0062] Reference Figure 2 , which shows a flow chart of the multi-model federated learning method applicable to the embodiment of the present application.
[0063] like Figure 2 As shown, the multi-model federated learning method can include:
[0064] S210, obtaining a set of models to be trained; the set of models to be trained includes a plurality of models to be trained, wherein the set of models to be trained may include a newly injected model to be trained and / or a model remaining to be trained after the last round of training.
[0065] S220, the server adopts a multi-model optimization allocation method to generate an optimization allocation matrix to allocate the models to be trained to different clients according to the optimization allocation matrix; so that each client downloads its corresponding model to be trained according to the instructions of the optimization allocation matrix generated by the server, completes this round of model training, and uploads the trained model parameters to the server; wherein, according to the optimization allocation matrix, each client needs to complete its own model training task within a preset time;
[0066] S230, the server receives the model parameters uploaded by the client within a preset time, and aggregates the model parameters;
[0067] S240. The server determines the accuracy of each model to be trained and the total number of model training rounds based on the aggregated model parameters. For the models to be trained that meet the accuracy requirements or the number of training rounds exceeds the round number threshold, the training is terminated, and the other models to be trained enter the next round of training.
[0068] It can be understood that the model training in the multi-model federated learning method provided in the embodiment of the present application is implemented by round-by-round training, and each round of training process is as follows: Figure 3 As shown in the figure, it mainly includes the steps of preparing the model to be trained and the client, preparing the model accuracy function table, calculating the multi-model optimization allocation, training the model in parallel, and collecting and aggregating model parameters. The specific process is as follows:
[0069] First, the server needs to prepare the models to be trained in this round in advance, and the set of all models to be trained is recorded as M. The server also needs to randomly select a certain number of clients, record the client set as N, and start this round of training. Among them, M includes the models that need to be further trained after the previous round of training, as well as the newly injected models to be trained.
[0070] Afterwards, the server prepares the model accuracy function table for use in this round of multi-model allocation. The preparation process involves two operations, one is to initialize the model accuracy function table according to the mathematical model (i.e., create the model accuracy function table), and the other is to update the model accuracy function table according to the actual training results of the previous round (i.e., update the model accuracy function table). The specific steps of creating and updating the model accuracy function table are described in the following embodiments.
[0071] Next, the server uses a multi-model optimization allocation method to generate an optimization allocation matrix π to allocate the |M| models to be trained in this round (i.e., the models to be trained) to the clients in the set N. According to the optimization allocation matrix π, each client should be able to complete the model training task it undertakes within the preset time T (which can be set according to actual needs). In this allocation calculation process, the server will estimate the time δ required for any client i∈N to complete the training of any model j∈M ij , and the model accuracy function table, perform the calculation of the allocation of multiple models to multiple clients, and generate an optimized allocation matrix π={π ij |i∈N,j∈M} to assign the |M| models to be trained in this round to the clients in the set N, where element π ij =1 / 0 indicates whether model j is assigned to client i.
[0072] Then, each client downloads the model to be trained that it is responsible for according to the instructions of the optimization allocation matrix π generated by the server, and uploads the trained model parameters to the server.
[0073] Afterwards, the server receives the model parameters uploaded by the client within the time T required for this round of training (the time required for this round of training is the preset time) and aggregates the model parameters.
[0074] Finally, the server determines the accuracy of each model to be trained and the total number of model training rounds based on the aggregated model parameters. For models that meet the accuracy requirements or have trained more than a certain number of rounds (i.e., the round threshold, which can be set according to actual needs), the training process is terminated, and other models are retained for the next round of training.
[0075] The structure of the model accuracy function table includes: model type (or model category), initial model accuracy, the number of clients used for model training, and final model accuracy.
[0076] In one embodiment, the creation of the model accuracy function table may include:
[0077] Obtaining mathematical models;
[0078] Based on the mathematical model, the final model accuracy of different categories of models is calculated after one round of training when different initial model accuracies and different numbers of clients are given;
[0079] The correspondence between all model categories, initial model accuracy, the number of clients used, and the final model accuracy forms an initial model accuracy function table.
[0080] In one embodiment, updating the model accuracy function table includes:
[0081] After each round of model training, obtain the model training category of this round of training, the initial training model accuracy at the beginning of this round, the number of training clients used in this round, and the final training model accuracy at the end of this round;
[0082] Update the corresponding model accuracy function table according to the training category, start training model accuracy, client training quantity, and end training model accuracy.
[0083] Specifically, the multi-model allocation method of this application assumes that in one round of federated learning, the inference accuracy of a model j after training is Overall, it is the inference accuracy of model j at the beginning of this round And the number of clients n that will be used in this round of training j The function of is called the model accuracy function and can be expressed as
[0084]
[0085] In order to facilitate the use of multi-model allocation calculation, the model accuracy function will be stored in the server's memory in the form of a function table (understandably, it can also be stored in other places such as storage media or other servers, as long as the server can obtain it when using it), so that the expected model accuracy can be obtained by looking up the table according to the given parameters. In the following expression form, the table lookup process is still expressed in the form of formula (1). The structure, creation and update of the model accuracy function table are described below.
[0086] The model accuracy function table structure includes the following basic fields: model type, current accuracy of the model (corresponding to ), the number of clients that will be used for model training (corresponding to n j ), the model accuracy after training (corresponding to ).
[0087] When using the model accuracy function table, the program will calculate the model accuracy based on the given model type and the current model accuracy. The number of clients participating in the training n j , fuzzy retrieval model accuracy function table, from which to find the corresponding model type and the required and n j The closest record, read the trained model accuracy of the record (corresponding to ) as the expected accuracy. As above, this application still uses the symbol To represent the fuzzy retrieval of the above model accuracy function table.
[0088] The creation and update of the model accuracy function table will be based on the mathematical model and the actual model training results respectively. The creation of the table is based on the following mathematical model derived from actual observations.
[0089]
[0090] Among them, j represents the model, α j , β j is the model parameter, which can be measured in advance through experimental data, n j The number of clients used for model training, is the model inference accuracy obtained by using these clients to train the most original model j. Given the mathematical model (2), the accuracy of different types of models j under different given initial models can be calculated. and different numbers of clients n j The model accuracy expected to be achieved after one round of training under the condition Right now:
[0091]
[0092] Furthermore, the model accuracy of model j obtained by a round of training under different given initial model accuracy and different client numbers can be calculated based on formula (3), and these data are saved in the memory table to form an initial model accuracy function table. Among them, the value of the current model accuracy field in the table can correspond to several quantization intervals between 0 and 1, such as 0.1, 0.2, ..., 0.9, and the value of the client number field can correspond to a value from 1 to |N|, with a certain integer interval, such as 1, 2, ..., |N|.
[0093] The model accuracy function table will be continuously updated with the actual execution results of multi-model training to more accurately reflect the actual correlation between parameters and improve the accuracy of the multi-model allocation method. After each round of actual training, the server will record the category of model j trained in this round, the model accuracy at the beginning of this round, and the model accuracy at the beginning of this round. The number of clients used in this round n j , and the model accuracy at the end of this round And use these data to update the value of the corresponding record in the model accuracy function table. Specifically, find the closest record to the model j category in the table. and n j The data record is updated with the model accuracy value after training. This completes the record update of the model accuracy function table.
[0094] In one embodiment, a multi-model optimization allocation method is used to generate an optimization allocation matrix, including:
[0095] Randomly assign the model to be trained to each client to obtain the initial assignment matrix;
[0096] According to the initial allocation matrix and the model accuracy function table, the corresponding initial objective function value is calculated;
[0097] Based on the initial objective function value, construct the indexes of all possible allocation attempts of the model to be trained to obtain an index set;
[0098] According to the index set, an optimized allocation matrix is determined.
[0099] Among them, according to the initial allocation matrix and the model accuracy function table, calculating the corresponding initial objective function value may include:
[0100] Get the initial training accuracy of any model at the beginning of this round of training;
[0101] Under the condition of the initial allocation matrix, the expected inference accuracy is determined according to the model accuracy function table and the initial training accuracy;
[0102] Determine the initial objective function value based on the initial training accuracy and expected inference accuracy.
[0103] Wherein, determining the optimized allocation matrix according to the index set includes:
[0104] Determine whether the index collection is empty;
[0105] If the index set is empty, the current allocation matrix is output as the optimized allocation matrix;
[0106] If the index set is not empty, for each possible allocation attempt recorded in the index set, under the current allocation matrix, try to allocate clients to each model according to the allocation attempt, and at the same time, remove one or more allocated models on the client so that the client can complete model training within the preset time, record the attempted model allocation matrix, and calculate the attempted objective function value corresponding to the attempted model allocation matrix;
[0107] According to all possible allocation attempts recorded in the index set and the corresponding allocation matrix of the attempt model and the attempt objective function value, the allocation attempt corresponding to the maximum attempt objective function value is selected as the best allocation attempt, and the attempt objective function value corresponding to the best allocation attempt is the maximum attempt objective function value;
[0108] If the maximum attempted objective function value is less than or equal to the current objective function value, the current allocation matrix is output as the optimized allocation matrix;
[0109] If the maximum attempt objective function value is greater than the current objective function value, update the current allocation matrix to the best allocation matrix corresponding to the best allocation attempt, update the variable corresponding to the current objective function value to the variable corresponding to the maximum attempt objective function value, delete the best allocation attempt from the index set, and return to determine whether the index set is empty to continue execution.
[0110] Specifically, the training efficiency of a model (hereinafter referred to as the model to be trained) is defined as the improvement of its inference accuracy, that is, Furthermore, this application proposes a multi-model optimization allocation method to obtain the optimal allocation matrix π from multiple models to multiple clients, so as to maximize the objective function of the overall weighted training efficiency of all models in each round of training, that is, formula (4), thereby optimizing the overall training efficiency of the multi-model federated learning system.
[0111]
[0112] Among them, w j is the importance coefficient of model j, which can be set manually. In particular, if the w of all models j ≡1, it means that all models have the same priority. is the accuracy of model j at the beginning of this round (i.e., initial training accuracy), is the expected inference accuracy under the given allocation matrix π, which can be obtained by querying the model accuracy function table, that is, where n j =∑ i∈N π ij , M and N are the set of models and the set of clients corresponding to this round of training respectively.
[0113] In general, the multi-model optimization allocation method proposed in this application finds the optimal allocation matrix of multiple models to multiple clients by performing the following calculation process. First, the models to be trained are randomly assigned to each client to form an initial allocation matrix, and the corresponding objective function value F(π) is calculated. Note that this process must be carried out under the condition that each client can complete the model training it undertakes within the specified time T. Subsequently, the best model allocation is iteratively sought in a greedy manner, and each iteration is based on the current π, and an attempt that can maximize the objective function value in this round of training is selected from all possible model allocation attempts until no attempt can further increase the objective function value. Among them, a model allocation attempt refers to assigning a model to a client, and at the same time (if necessary) eliminating one or more assigned models on the client so that the client can complete the model training it undertakes within time T; wherein, eliminating the model is also an iterative process: each time a model that minimizes the objective function loss is eliminated until the remaining models can be trained within T.
[0114] Figure 4 The specific process of the multi-model optimization allocation method is given. The input parameters required by this method include: the time limit T of each round (i.e. the preset duration), the set N of clients participating in this round of training, the set M of models to be trained, and the total time δ required for any client i∈N to train any model j∈M ij , the weight parameter w of each model j , and an initial allocation matrix π whose elements are all 0. The method generates the final optimized allocation matrix by performing the following steps.
[0115] Step 1: Initialize model allocation and record the allocation results in the initial allocation matrix π. Randomly allocate models to each client so that each client does not have extra time to train more models, that is, for any client i∈N, the relationship is satisfied
[0116] Step 2: Based on the initial allocation matrix π, calculate the value of F(π) according to formula (4) and store it in variable u; construct the index (i, j) of all possible model allocation attempts and store them in the set Γ to facilitate subsequent iterative operations. Each element (i, j) of Γ indicates a model j that can be allocated but has not yet been allocated to client i.
[0117] Step 3: Determine whether the index set Γ is empty. If it is empty, the allocation matrix π is output as the final allocation result, that is, the optimized allocation matrix, and the method ends; otherwise, execute the next step and enter the loop iteration process.
[0118] Step 4: For each possible allocation attempt (i, j) recorded in the index set Γ, try to allocate model j to client i under the current allocation matrix π, and (if necessary) remove one or more allocated models on client j so that client j can complete the training of all models it undertakes within time T. The removal is also an iterative process: each time, an allocated model that minimizes the loss of the objective function value is removed from the client until the remaining models can be trained within T. The model allocation matrix obtained by the above operations is recorded. Calculate the objective function value And store it in variable ü (i,j) .
[0119] Step 5: For all possible allocation attempts (i, j) recorded in the index set Γ and the corresponding allocation matrix obtained in step 4 and the objective function value u (i,j) , select the allocation attempt with the largest objective function value as the best allocation attempt (i * ,j * ), that is (i * ,j * ) = argmax (i,j)∈Γ {ü (i,j)}.
[0120] Step 6: Determine the best allocation attempt (i * ,j * ) corresponds to the objective function value Is it greater than the objective function value u corresponding to the current allocation matrix π? If Then the loop process is terminated, the current allocation matrix π is output as the final result, and the method ends; otherwise, execute the next step.
[0121] Step 7: Update π to the best allocation attempt (i * ,j * ) corresponds to the distribution matrix At the same time, update the objective function value variable u as And delete the selected (i * ,j * ). Then, return to step 3 to continue.
[0122] The multi-model federated learning method provided in the embodiment of the present application can train multiple models in parallel. The method optimizes the allocation of training tasks from multiple models to multiple clients based on the differences in client resources, and is expected to maximize the overall training efficiency of the multiple models. It can also make full use of the client's resources, and significantly improve the training efficiency during multi-model training.
[0123] Continue to refer to Figure 1 , which shows a structural diagram of a multi-model federated learning system described according to an embodiment of the present application.
[0124] like Figure 1 As shown, the multi-model federated learning system can include:
[0125] The server 11 is used to obtain a set of models to be trained; the set of models to be trained includes a plurality of models to be trained; and a multi-model optimization allocation method is used to generate an optimization allocation matrix, and the models to be trained are allocated to different clients according to the optimization allocation matrix;
[0126] Several clients 12 are used to receive the optimization allocation matrix sent by the server, and download the corresponding models to be trained according to the instructions of the optimization allocation matrix, complete the current round of model training, and upload the trained model parameters to the server; wherein, according to the optimization allocation matrix, each client needs to complete its own model training task within a preset time;
[0127] The server 11 is also used to receive the model parameters uploaded by the client within a preset time and aggregate the model parameters; and determine the accuracy of each model to be trained and the total number of model training rounds based on the aggregated model parameters, and end the training for the model to be trained that meets the accuracy requirements or the number of training rounds exceeds the round number threshold, and the other models to be trained enter the next round of training.
[0128] Optionally, the server 11 is further used for:
[0129] Randomly assign the model to be trained to each client to obtain the initial assignment matrix;
[0130] According to the initial allocation matrix and the model accuracy function table, the corresponding initial objective function value is calculated;
[0131] Based on the initial objective function value, construct the indexes of all possible allocation attempts of the model to be trained to obtain an index set;
[0132] According to the index set, an optimized allocation matrix is determined.
[0133] Optionally, the structure of the model accuracy function table includes: model type, initial model accuracy, number of clients used for model training, and end model accuracy; the server 11 is also used to: create a model accuracy function table, including:
[0134] Obtaining mathematical models;
[0135] Based on the mathematical model, the final model accuracy of different types of models after one round of training is calculated when different initial model accuracies and different numbers of clients are used;
[0136] The correspondence between all model types, initial model accuracy, number of clients used, and final model accuracy forms an initial model accuracy function table.
[0137] Optionally, the server 11 is further used to: update the model accuracy function table, including:
[0138] After each round of model training, obtain the model training type during this round of training, the initial training model accuracy at the beginning of this round, the number of clients used in this round of training, and the final training model accuracy at the end of this round;
[0139] Update the corresponding model accuracy function table according to the training type, start training model accuracy, client training quantity, and end training model accuracy.
[0140] Optionally, the server 11 is further used for:
[0141] From the records of the corresponding training category in the model accuracy function table, find the data record that is closest to the start training model accuracy and the number of trainings on the client, and update the end model accuracy in the data record to the end training model accuracy.
[0142] Optionally, the server 11 is further used for:
[0143] Get the initial training accuracy of any model at the beginning of this round of training;
[0144] Under the condition of the initial allocation matrix, the expected inference accuracy is determined according to the model accuracy function table and the initial training accuracy;
[0145] Determine the initial objective function value based on the initial training accuracy and expected inference accuracy.
[0146] Optionally, the server 11 is further used for:
[0147] Determine whether the index collection is empty;
[0148] If the index set is empty, the current allocation matrix is output as the optimized allocation matrix;
[0149] If the index set is not empty, for each possible allocation attempt recorded in the index set, under the current allocation matrix, try to allocate clients to each model according to the allocation attempt, and at the same time, remove one or more allocated models on the client so that the client can complete model training within the preset time, record the attempted model allocation matrix, and calculate the attempted objective function value corresponding to the attempted model allocation matrix;
[0150] According to all possible allocation attempts recorded in the index set and the corresponding allocation matrix of the attempt model and the attempt objective function value, the allocation attempt corresponding to the maximum attempt objective function value is selected as the best allocation attempt, and the attempt objective function value corresponding to the best allocation attempt is the maximum attempt objective function value;
[0151] If the maximum attempted objective function value is less than or equal to the current objective function value, the current allocation matrix is output as the optimized allocation matrix;
[0152] If the maximum attempt objective function value is greater than the current objective function value, update the current allocation matrix to the best allocation matrix corresponding to the best allocation attempt, update the variable corresponding to the current objective function value to the variable corresponding to the maximum attempt objective function value, delete the best allocation attempt from the index set, and return to determine whether the index set is empty to continue execution.
[0153] Optionally, the set of models to be trained includes newly injected models to be trained and / or models remaining to be trained after the previous round of training.
[0154] This embodiment provides a multi-model federated learning system that can execute the embodiments of the above method. Its implementation principles and technical effects are similar and will not be repeated here.
[0155] As another aspect, the present application further provides a storage medium, which may be the storage medium included in the aforementioned device in the above embodiment; or a storage medium that exists independently and is not assembled into the device. The storage medium stores one or more programs, and the aforementioned programs are used by one or more processors to execute the multi-model federated learning method described in the present application.
[0156] Storage media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.
[0157] It should be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of further restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0158] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
Claims
1. A multi-model federated learning method, characterized in that: The method comprises: The server obtains a set of models to be trained; the set of models to be trained includes a plurality of models to be trained; The server adopts a multi-model optimization allocation method to generate an optimization allocation matrix to allocate the models to be trained to different clients according to the optimization allocation matrix; so that each of the clients downloads the corresponding models to be trained according to the instructions of the optimization allocation matrix generated by the server, completes the current round of model training, and uploads the trained model parameters to the server; wherein, according to the optimization allocation matrix, each of the clients needs to complete its own model training task within a preset time; The server receives the model parameters uploaded by the client within the preset time and aggregates the model parameters; The server determines the accuracy of each of the models to be trained and the total number of rounds of model training according to the aggregated model parameters, and terminates the training of the models to be trained that meet the accuracy requirements or the number of training rounds exceeds the round number threshold, and the other models to be trained enter the next round of training; The method of using a multi-model optimization allocation method to generate an optimization allocation matrix includes: Randomly assign the model to be trained to each client to obtain an initial assignment matrix; Calculate the corresponding initial objective function value according to the initial allocation matrix and the model accuracy function table; Based on the initial objective function value, construct indexes of all possible allocation attempts of the model to be trained to obtain an index set; The optimized allocation matrix is determined according to the index set.
2. The method according to claim 1, characterized in that: The structure of the model accuracy function table includes: model type, initial model accuracy, number of clients used in model training, and end model accuracy; the creation of the model accuracy function table includes: Obtaining mathematical models; Based on the mathematical model, calculating the final model accuracy of different types of models after one round of training when different initial model accuracies and different numbers of clients are used; The correspondence between all the model types, initial model accuracy, number of clients used, and final model accuracy forms the initial model accuracy function table.
3. The method according to claim 2, characterized in that The updating of the model accuracy function table includes: After each round of model training, obtain the model training type during this round of training, the initial training model accuracy at the beginning of this round, the number of training clients used in this round, and the final training model accuracy at the end of this round; According to the training type, the initial training model accuracy, the training quantity of the client, and the end training model accuracy, the corresponding model accuracy function table is updated.
4. The method according to claim 3, characterized in that The updating of the corresponding model accuracy function table according to the training category, the initial training model accuracy, the training quantity of the client, and the end training model accuracy includes: From the records corresponding to the training category in the model accuracy function table, find the data record closest to the initial training model accuracy and the training quantity of the client, and update the end model accuracy in the data record to the end training model accuracy.
5. The method according to claim 4, characterized in that The calculating the corresponding initial objective function value according to the initial allocation matrix and the model accuracy function table includes: Get the initial training accuracy of any model at the beginning of this round of training; Under the condition of the initial allocation matrix, determining the expected inference accuracy according to the model accuracy function table and the initial training accuracy; The initial objective function value is determined according to the initial training accuracy and the expected inference accuracy.
6. The method according to claim 1, characterized in that The step of determining the optimized allocation matrix according to the index set includes: Determine whether the index set is empty; If the index set is empty, outputting the current allocation matrix as an optimized allocation matrix; If the index set is not empty, for each possible allocation attempt recorded in the index set, under the current allocation matrix, try to allocate clients to each model according to the allocation attempt, and at the same time, remove one or more allocated models on the client so that the client can complete model training within the preset time, record the attempted model allocation matrix, and calculate the attempted objective function value corresponding to the attempted model allocation matrix; According to all possible allocation attempts recorded in the index set and the corresponding allocation matrix of the attempt model and the attempt objective function value, the allocation attempt corresponding to the maximum attempt objective function value is selected as the best allocation attempt, and the attempt objective function value corresponding to the best allocation attempt is the maximum attempt objective function value; If the maximum attempted objective function value is less than or equal to the current objective function value, outputting the current allocation matrix as the optimized allocation matrix; If the maximum attempt objective function value is greater than the current objective function value, update the current allocation matrix to the optimal allocation matrix corresponding to the optimal allocation attempt, update the variables corresponding to the current objective function value to the variables corresponding to the maximum attempt objective function value, delete the optimal allocation attempt from the index set, and return to the step of determining whether the index set is empty to continue execution.
7. The method according to any one of claims 1 to 6, characterized in that: The set of models to be trained includes newly injected models to be trained and / or models remaining to be trained after the previous round of training.
8. A multi-model federated learning system, characterized in that: The system comprises: The server is used to obtain a set of models to be trained; the set of models to be trained includes a plurality of models to be trained; and a multi-model optimization allocation method is used to generate an optimization allocation matrix, and the models to be trained are allocated to different clients according to the optimization allocation matrix; The method of using a multi-model optimization allocation method to generate an optimization allocation matrix includes: The model to be trained is randomly assigned to each client to obtain an initial assignment matrix; the corresponding initial objective function value is calculated according to the initial assignment matrix and the model accuracy function table; based on the initial objective function value, the indexes of all possible assignment attempts of the model to be trained are constructed to obtain an index set; according to the index set, the optimized assignment matrix is determined; Several clients are used to download the corresponding models to be trained according to the instructions of the optimization allocation matrix, complete the current round of model training, and upload the trained model parameters to the server; wherein, according to the optimization allocation matrix, each of the clients needs to complete its own model training task within a preset time; The server is also used to receive the model parameters uploaded by the client within the preset time and aggregate the model parameters; and determine the accuracy of each model to be trained and the total number of model training rounds based on the aggregated model parameters, and end the training for the model to be trained that meets the accuracy requirement or the number of training rounds exceeds the round number threshold, and the other models to be trained enter the next round of training.
9. A readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the multi-model federated learning method as described in any one of claims 1-7 is implemented.
