A method, apparatus, and equipment for processing a model.
By receiving server models for training and pruning on terminal devices and sending model update data to adaptively adjust training duration and pruning degree, the inefficiency caused by devices with poor computing power in federated learning is solved, and an efficient federated learning framework is realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TSINGHUA UNIVERSITY
- Filing Date
- 2022-08-15
- Publication Date
- 2026-07-17
AI Technical Summary
In federated learning, terminal devices with poor computing and communication capabilities become "burdens," leading to reduced training efficiency. Existing technologies, which use a fully synchronous approach, also result in low efficiency.
By receiving server models on terminal devices, performing training and structure pruning, sending model update data to trigger server updates, and adaptively adjusting training duration and pruning degree according to terminal device performance, an efficient federated learning framework is formed.
It improves the training efficiency of federated learning, maximizes the computing power of terminal devices with different performance levels, ensures model performance, and makes the single-round update time consistent for all terminal devices, thus solving the "drag problem".
Smart Images

Figure CN115345233B_ABST
Abstract
Description
Technical Field
[0001] This document relates to the field of computer technology, and in particular to a method, apparatus and device for processing a model. Background Technology
[0002] Artificial intelligence (AI) learns specific knowledge from massive amounts of data and then uses that knowledge to perform corresponding business processes, bringing great convenience to society. However, with the rapid growth of data on the internet and increasing public concern about data privacy, data often needs to be stored locally. Learning specific knowledge solely from data from a subset of nodes (terminal devices in federated learning) results in insufficient and biased knowledge. To address this issue, collaborative learning mechanisms between multiple nodes have emerged, assuming localized data. In practical applications, the capabilities of different nodes (including communication and computing capabilities) often vary.
[0003] Currently, federated learning typically employs a fully synchronous processing method. In this method, the server must wait for all pre-selected terminal devices to submit updated model data before it can update the current model on its server. In this case, terminal devices with poor computing and communication capabilities become "bottlenecks" in model training, thus reducing the efficiency of federated learning. Therefore, a technical solution is needed to improve the efficiency of federated learning. Summary of the Invention
[0004] The purpose of the embodiments in this specification is to provide a technical solution that can make federated learning more efficient.
[0005] To achieve the above technical solution, the embodiments in this specification are implemented as follows:
[0006] This specification provides a model processing method applied to a terminal device. The method includes: receiving a first model sent by a server; obtaining first training sample data for training the first model; training the first model using the first training sample data and adjusting the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The method also includes sending model update data corresponding to the target model to the server, which triggers the server to determine the time required to obtain the target model, and updating the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model; determining whether the model structure of the second model needs further pruning; and when it is determined that the model structure of the second model needs pruning, determining the degree of pruning of the model structure of the second model by different terminal devices and the time required to train the second model. Finally, the method receives the degree of pruning of the model structure of the second model and the time required to train the second model, as well as the second model, sent by the server. Obtain second training sample data for training the second model, train the second model based on the second training sample data and the training time of the second model, and adjust the model structure of the second model by the degree of pruning of the model structure to obtain the trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
[0007] This specification provides a model processing method applied to a server. The method includes: distributing a first model to pre-selected different terminal devices, the first model triggering the terminal devices to acquire first training sample data for training the first model; training the first model using the first training sample data and adjusting the model structure of the first model to obtain a trained target model, the target model having the same model structure as the first model, or the target model being a model obtained by trimming the model structure of the first model; receiving model update data corresponding to the trained target model sent by different terminal devices; determining the duration used to obtain the target model; and updating the current model in the server based on the model update data corresponding to the target model provided by the different terminal devices to obtain a second model. If it is determined that the model structure of the second model needs to be pruned, then the degree of pruning of the model structure of the second model for different terminal devices and the training time of the second model are determined, and the pruning degree, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal devices to obtain second training sample data, and the second model is trained based on the second training sample data and the training time of the second model. The pruning degree and the second model are used to trigger the server to adjust the model structure of the second model according to the pruning degree to obtain the trained third model, and the model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
[0008] This specification provides a model processing apparatus, comprising: a first model processing module, which receives a first model sent by a server, acquires first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model, wherein the target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model; an update data sending module, which sends model update data corresponding to the target model to the server, wherein the model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model, and determines whether the model structure of the second model needs to be pruned again, and when it is determined that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model; and a data receiving module, which receives the degree of pruning of the model structure of the second model and the time used to train the second model sent by the server, as well as the second model. The second model processing module acquires second training sample data for training the second model, trains the second model based on the second training sample data and the training time of the second model, adjusts the model structure of the second model by pruning the model structure of the second model, obtains the trained third model, and sends the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
[0009] This specification provides a model processing apparatus, comprising: a model distribution module, which distributes a first model to pre-selected different terminal devices. The first model triggers the terminal devices to acquire first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by trimming the model structure of the first model. A model update module receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by the different terminal devices to obtain a second model. The data sending module, if it determines that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model for different terminal devices and the training time of the second model, and sends the pruning degree, the training time of the second model, and the second model to the different terminal devices. The training time of the second model and the second model are used to trigger the terminal devices to obtain second training sample data, and train the second model based on the second training sample data and the training time of the second model. The pruning degree and the second model are used to trigger the server to adjust the model structure of the second model according to the pruning degree to obtain a trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the device.
[0010] This specification provides an embodiment of a model processing device, comprising: a processor; and a memory arranged to store computer-executable instructions, wherein the executable instructions, when executed, cause the processor to: receive a first model sent by a server; acquire first training sample data for training the first model; train the first model using the first training sample data; and adjust the model structure of the first model to obtain a trained target model, wherein the target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model; send model update data corresponding to the target model to the server, wherein the model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model, and update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model; and determine whether the model structure of the second model needs to be pruned again, and when it is determined that the model structure of the second model needs to be pruned, determine the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model. The system receives information from the server regarding the degree of pruning of the model structure of the second model, the training time for the second model, and the second model itself. It then acquires second training sample data for training the second model, trains the second model based on the second training sample data and the training time, adjusts the model structure of the second model by pruning its structure, and obtains a trained third model. Finally, it sends the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
[0011] This specification provides a model processing device comprising: a processor; and a memory arranged to store computer-executable instructions. When executed, the executable instructions cause the processor to: send a first model to pre-selected different terminal devices, the first model triggering the terminal devices to acquire first training sample data for training the first model; train the first model using the first training sample data and adjust the model structure of the first model to obtain a trained target model, the target model having the same model structure as the first model, or the target model being a model obtained by trimming the model structure of the first model; receive model update data corresponding to the trained target model sent by different terminal devices; determine the duration used to obtain the target model; and update the current model in the server based on the model update data corresponding to the target model provided by the different terminal devices to obtain a second model. If it is determined that the model structure of the second model needs to be pruned, then the degree of pruning of the model structure of the second model for different terminal devices and the training time of the second model are determined, and the degree of pruning, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal device to obtain the second training sample data, and the second model is trained based on the second training sample data and the training time of the second model. The degree of pruning and the second model are used to trigger the server to adjust the model structure of the second model according to the degree of pruning to obtain the trained third model, and the model update data corresponding to the third model is sent to the device as the model update data corresponding to the target model.
[0012] This specification also provides a storage medium for storing computer-executable instructions. When executed by a processor, these instructions implement the following process: receiving a first model sent by a server; acquiring first training sample data for training the first model; training the first model using the first training sample data; adjusting the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The target model's corresponding model update data is sent to the server. This model update data triggers the server to determine the time required to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model. The server also determines whether the model structure of the second model needs further pruning, and when it is determined that the model structure of the second model needs pruning, determines the degree of pruning of the model structure of the second model by different terminal devices and the time required to train the second model. Finally, the server receives the degree of pruning of the model structure of the second model, the time required to train the second model, and the second model itself. Obtain second training sample data for training the second model, train the second model based on the second training sample data and the training time of the second model, and adjust the model structure of the second model by the degree of pruning of the model structure to obtain the trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
[0013] This specification also provides a storage medium for storing computer-executable instructions. When executed by a processor, these instructions implement the following process: a first model is sent to pre-selected different terminal devices. This first model triggers the terminal devices to acquire first training sample data for training the first model. The first model is then trained using the first training sample data, and its structure is adjusted to obtain a trained target model. The target model has the same structure as the first model, or it is a model obtained by trimming the structure of the first model. The system also receives model update data corresponding to the trained target model from different terminal devices, determines the duration used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by the different terminal devices to obtain a second model. If it is determined that the model structure of the second model needs to be pruned, then the degree of pruning of the model structure of the second model for different terminal devices and the training time of the second model are determined, and the pruning degree, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal devices to obtain second training sample data, and the second model is trained based on the second training sample data and the training time of the second model. The pruning degree and the second model are used to trigger the server to adjust the model structure of the second model according to the pruning degree to obtain the trained third model, and the model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1A This is an embodiment of a model processing method described in this specification;
[0016] Figure 1B This is a schematic diagram illustrating the processing procedure of one model in this specification;
[0017] Figure 2 This is a schematic diagram of the processing system for one model in this specification;
[0018] Figure 3 This is a schematic diagram illustrating the processing procedure of another model in this specification;
[0019] Figure 4A This is an embodiment of another model processing method described in this specification;
[0020] Figure 4B This is a schematic diagram illustrating the processing procedure of another model in this specification;
[0021] Figure 5 This is a schematic diagram illustrating the processing procedure of another model in this specification;
[0022] Figure 6 This is a schematic diagram of a model aggregation process described in this specification;
[0023] Figure 7 This is an embodiment of a processing device for a model described in this specification;
[0024] Figure 8 This is another embodiment of the processing device for a different model in this specification;
[0025] Figure 9 This is an embodiment of a processing device for one model in this specification. Detailed Implementation
[0026] This specification provides a method, apparatus, and device for processing a model.
[0027] 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 with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.
[0028] Example 1
[0029] like Figure 1A and Figure 1B As shown in the embodiments of this specification, a method for processing a model is provided. The execution subject of this method can be a terminal device, which can be a mobile phone, tablet computer, or other terminal device; a computer device such as a laptop or desktop computer; an IoT device (specifically, a smartwatch, in-vehicle device, etc.); or a pre-set machine with a certain function. The method may specifically include the following steps:
[0030] In step S102, the first model sent by the server is received, the first training sample data for training the first model is obtained, the first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain the trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0031] The server can be a server for federated learning (or collaborative learning), a server for risk control, or a backend server for an application or business, etc., depending on the actual situation. This specification does not limit this. The first model can be any model. It can be a model trained by the server or a model that has not been trained. The first model can be a model for any user or function, such as a model for risk control or a model for biometrics. The first model can be constructed using various algorithms, such as a convolutional neural network algorithm or a classification algorithm, etc., depending on the actual situation. This specification does not limit this. The first training sample data can include image data, text data, etc. The data type of the first training sample data can be determined according to the function or role of the first model. For example, if the first model is a biometric model, the first training sample data can be fingerprint data, facial data, or iris data of different users, etc. If the first model is a risk control model, the first training sample data can be business data of a certain business, such as business data of a certain financial business, etc., depending on the actual situation. This specification does not limit this.
[0032] In practice, artificial intelligence (AI) learns specific knowledge from massive amounts of data and then uses this knowledge to perform corresponding business processes, bringing great convenience to social development. However, with the rapid growth of data on the internet and increasing public concern for data privacy, data often needs to be stored locally. Learning specific knowledge solely from data from a subset of nodes (terminal devices in federated learning) results in insufficient and biased knowledge. To address this issue, collaborative learning mechanisms between multiple nodes have emerged, enabling data to be stored locally. In practical applications, the capabilities of different nodes (including communication and computing capabilities) often differ. Even if two nodes have identical hardware, the resources allocated to a task (including memory and bandwidth) during task execution are limited.
[0033] For example, in a terminal-cloud risk control scenario, user terminal devices can be used for model training. User data can be stored locally on the terminal device without being uploaded to a server, thus protecting data privacy. However, the performance of user terminal devices varies significantly; for the same computational task, the computation time on a high-performance terminal device can differ by hundreds of times compared to a low-performance terminal device.
[0034] Currently, federated learning typically employs a fully synchronous processing method. In this method, the server must wait for all pre-selected terminal devices to submit updated model data before it can update the current model on its server. In this case, terminal devices with poor computing and communication capabilities become "bottlenecks" in model training, thus reducing the efficiency of federated learning. Therefore, there is a need to provide a technical solution that can improve the efficiency of federated learning. This specification provides an achievable technical solution, which specifically includes the following:
[0035] For federated learning, such as Figure 2 As shown, its system architecture may include user terminal devices and servers. The server may include a model to be trained (i.e., a first model, such as a model for risk control of a certain business). The server can distribute the first model for a certain business (such as financial business, biometric business, etc.) to each user's terminal device. The user's terminal device can use the first model distributed by the server as the initial model and can obtain relevant data of the above-mentioned business. This data may be relevant data collected and stored by the terminal device during the execution of the business. The content of the relevant data can be selected according to the needs of the first model. The relevant data obtained can be used as the first training sample data for training the first model. The first model can be trained using the first training sample data. During the training process, units with lower importance can be selected from the model structure based on their importance. These units can be removed from the model structure. For example, if the first model has 11 neurons and 3 of them are of lower importance, these 3 neurons can be removed from the 11 neurons. The remaining 8 neurons form the final model structure, which is also the final trained model (i.e., the target model).
[0036] It should be noted that during the training of the first model using the first training sample data, the first model can be trained multiple times using the first training sample data. For example, the first model can be trained using the first training sample data to obtain a trained first model. Then, the trained first model can be trained again using the first training sample data to obtain a trained model, and so on, until the specified number of training iterations is reached, ultimately yielding the trained model. Furthermore, different terminal devices can use the same number of training iterations or different numbers of training iterations, depending on the actual situation. This specification does not limit this in the embodiments.
[0037] In addition, during the training of the first model using the first training sample data, the degree of pruning of the first model can be determined based on the performance of the terminal device used to train the first model. For example, if the performance of the terminal device is comparable to that of the server, then no pruning of the first model is required. If the performance of the terminal device is weaker than that of the server, then the first model can be pruned according to the actual situation. The specific pruning can be set according to the actual situation, and this specification does not limit this aspect in the embodiments.
[0038] In step S104, the model update data corresponding to the target model is sent to the server. The model update data corresponding to the target model is used to trigger the server to determine the time required to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the current model in the server is updated to obtain the second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time required to train the second model are determined.
[0039] The model update data can be data related to the target model, specifically including data such as the model structure and parameters of the target model, or data such as gradients. The degree of pruning can be presented in various ways. For example, the degree of pruning can refer to the ratio of the size of the pruned model to the size of the original model. Specifically, it can be the ratio of the remaining model structure after pruning to the original model structure, such as 100% (i.e., no pruning) or 72% (e.g., if the original model structure included 11 neurons, and after pruning, 8 neurons remain, then 8 / 11 = 72%).
[0040] In implementation, after the server sends the first model to the terminal device, it can start a timer. Once the target model is obtained through this method, the corresponding model update data can be determined based on the target model. This update data can be sent to the server, at which point the server can stop the timer. This allows us to obtain the time taken from training the first model to obtaining the target model, thus determining the total time taken to obtain the target model. The current model on the server can be updated using the model update data corresponding to the target models provided by different terminal devices to obtain a second model. Multiple models can be updated based on the model update data corresponding to the target models provided by different terminal devices. These multiple models can be superimposed and averaged to obtain the final second model.
[0041] The server can determine whether the second model's structure needs further pruning in the next round of model training. Specifically, it can pre-set judgment conditions and match the obtained data (which may include the time taken to obtain the target model, the degree of pruning from the first model to the target model, and pre-set thresholds) with these conditions. If the data does not match the conditions, it can be determined that the second model's structure does not need pruning; if the data matches the conditions, it can be determined that the second model's structure needs pruning. If it is determined that the second model's structure does not need pruning, then subsequent pruning of the model is unnecessary. However, at this point, it can be determined whether the second model needs to be retrained based on the actual situation, but pruning is not required during the training process. If it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the second model's structure and the training time of the second model can be calculated for different terminal devices based on data such as the time taken to obtain the target model, the degree of pruning from the first model to the target model, and a pre-set threshold. For example, based on the time taken to obtain the target model, a corresponding average value can be calculated, and this average value can be used as the training time of the second model. The degree of pruning of the second model's structure for different terminal devices can be set according to actual conditions. The server can then send the degree of pruning of the second model's structure, the training time of the second model, and the second model itself to different terminal devices.
[0042] In step S106, the receiver receives the degree of pruning of the model structure of the second model and the training time of the second model, as well as the second model itself, sent by the server.
[0043] In step S108, second training sample data for training the second model is obtained. The second model is trained based on the second training sample data and the training time of the second model. The model structure of the second model is adjusted by the degree of pruning of the model structure of the second model to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
[0044] In implementation, the user's terminal device can use the second model issued by the server as the initial model and obtain relevant data for the aforementioned business. This data can be data collected and stored by the terminal device during the execution of the business. The content of this relevant data can be selected according to the needs of the second model. The obtained relevant data can be used as the second training sample data for training the second model. The second model can be trained using the second training sample data and the training time. During the training of the first model, based on the importance of each unit in the model structure of the first model, the less important units can be selected from the model structure of the second model by pruning the model structure. The selected less important units can be pruned from the model structure to obtain the pruned model structure, and the final trained model (i.e., the third model) can also be obtained.
[0045] The obtained third model can be used as the target model. Then, the model update data corresponding to the target model can be sent to the server. The server can execute the relevant processing in step S104, that is, the server can stop the timer, thereby determining the time taken to obtain the target model. The model update data corresponding to the target model provided by different terminal devices can be used to update the current model in the server to obtain the second model. The server can determine whether the model structure of the second model needs to be pruned again in the next round of model training. If it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time taken to train the second model are calculated. The server can send the degree of pruning of the model structure of the second model, the time taken to train the second model, and the second model to different terminal devices. Afterwards, the terminal devices can continue to execute the subsequent processing of steps S106 and S108. The processing of steps S104, S106, and S108 can continue to be executed repeatedly to finally obtain the trained model, which can be used by different terminal devices for business processing.
[0046] This specification provides a model processing method. It involves receiving a first model from a server, obtaining first training sample data for training the first model, training the first model using the first training sample data, adjusting the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time required to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the server updates the current model to obtain a second model. It also determines whether the model structure of the second model needs further pruning. If it is determined that the model structure of the second model needs pruning, the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model are determined. Finally, the target model can be obtained... The second training sample data used to train the second model is taken. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure, resulting in a trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that adapt to the capabilities of the terminal devices themselves, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0047] Example 2
[0048] like Figure 3 As shown in the embodiments of this specification, a method for processing a model is provided. The execution subject of this method can be a terminal device, which can be a mobile phone, tablet computer, or other terminal device; a computer device such as a laptop or desktop computer; an IoT device (specifically, a smartwatch, in-vehicle device, etc.); or a pre-set machine with a certain function. The method may specifically include the following steps:
[0049] In step S302, the first model sent by the server is received, the first training sample data for training the first model is obtained, and the first training sample data is used to train the first model to obtain the first pre-selected model after training.
[0050] In step S304, the model structure of the first pre-selected model is adjusted to obtain the target model. The target model has the same model structure as the first model, or the target model is a model obtained by trimming the model structure of the first model.
[0051] In implementation, the process of pruning the model structure can be done after model training, or before model training, or during model training. Based on this, through the processing of step S302, the first model can be trained using the first training sample data to obtain the trained first pre-selected model. Then, the model structure of the first pre-selected model can be adjusted to obtain the trained target model. If pruning the model structure of the first pre-selected model is not required, the first pre-selected model can be directly used as the target model. In this case, the target model and the first model have the same model structure (i.e., the first pre-selected model and the first model have the same model structure). If pruning the model structure of the first pre-selected model is required, the model structure of the first pre-selected model can be adjusted to obtain the adjusted model, which can be used as the target model. In addition, the model structure of the first model can be adjusted during the training process using the first training sample data to obtain the trained target model. For the specific processing, please refer to the relevant content in the above embodiment one, which will not be repeated here.
[0052] The above-mentioned process of adjusting the model structure of the first model can be varied. The following is an optional processing method, which may include the following: trimming the model structure of the first model based on the preset unit importance rules in the model to obtain the target model.
[0053] In implementation, the pre-defined unit importance rules in the model can be used to determine the importance of each unit in the model. For example, the importance of a neuron can be determined based on its position and relationship with other neurons in the model. The importance of each neuron in the model can be obtained in the above way. The neurons in the model can be sorted by importance, and neurons with an importance value less than a certain threshold can be selected as neurons that need to be pruned, thus obtaining the remaining neurons.
[0054] Based on the above, in addition to trimming the model structure after training the model, the model structure can also be trimmed before training the model. Specifically, this can include the following steps A2 and A4.
[0055] In step A2, the model structure of the first model is adjusted to obtain the second pre-selected model.
[0056] In practical applications, the processing of step A2 above can be varied. The following is an optional processing method, which may include the following: trimming the model structure of the first model based on the preset unit importance rules in the model to obtain the second pre-selected model.
[0057] In step A4, the second pre-selected model is trained using the first training sample data to obtain the trained target model.
[0058] In step S306, the model update data corresponding to the target model is sent to the server. The model update data corresponding to the target model is used to trigger the server to determine the time required to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the current model in the server is updated to obtain the second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time required to train the second model are determined.
[0059] The specific processing of step S306 can be found in the relevant content of Embodiment 1 above, and will not be repeated here. In practical applications, the processing of step S306 can be varied. The following provides an optional processing method, which may include the following: sending the index information of the target model and the index information of the first model to the server.
[0060] In step S308, the receiver receives the degree of pruning of the model structure of the second model and the training time of the second model, as well as the second model itself, sent by the server.
[0061] In step S310, second training sample data for training the second model is obtained. The second model is trained based on the second training sample data and the training time of the second model. The model structure of the second model is adjusted by the degree of pruning of the model structure to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
[0062] In step S312, the server receives the second model and performs business processing based on the second model. The second model is the model sent by the server when it determines that the model structure of the second model does not need to be trimmed.
[0063] This specification provides a model processing method. It involves receiving a first model from a server, obtaining first training sample data for training the first model, training the first model using the first training sample data, adjusting the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time required to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the server updates the current model to obtain a second model. It also determines whether the model structure of the second model needs further pruning. If it is determined that the model structure of the second model needs pruning, the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model are determined. Finally, the target model can be obtained... The second training sample data used to train the second model is taken. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure, resulting in a trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that adapt to the capabilities of the terminal devices themselves, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0064] Example 3
[0065] like Figure 4A and Figure 4B As shown in the embodiments of this specification, a method for processing a model is provided. The execution subject of this method can be a server, which can be a single independent server or a server cluster composed of multiple servers. The server can be a backend server for financial or online shopping services, or a backend server for an application. Specifically, the method may include the following steps:
[0066] In step S402, a first model is sent to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain the first training sample data for training the first model. The first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain the trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0067] In step S404, the model update data corresponding to the trained target model sent by different terminal devices is received, the time used to obtain the target model is determined, and the current model in the server is updated based on the model update data corresponding to the target model provided by different terminal devices to obtain the second model.
[0068] In step S406, if it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model are determined. The degree of pruning, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal devices to obtain the second training sample data. The second model is trained based on the second training sample data and the training time of the second model. The degree of pruning and the second model are used to trigger the server to adjust the model structure of the second model according to the degree of pruning to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
[0069] The specific processing procedures for steps S402 to S406 can be found in the relevant content of Embodiment 1 and Embodiment 2 above, and will not be repeated here.
[0070] This specification provides a model processing method. It involves receiving a first model from a server, obtaining first training sample data for training the first model, training the first model using the first training sample data, adjusting the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time required to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the server updates the current model to obtain a second model. It also determines whether the model structure of the second model needs further pruning. If it is determined that the model structure of the second model needs pruning, the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model are determined. Finally, the target model can be obtained... The second training sample data used to train the second model is taken. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure, resulting in a trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that adapt to the capabilities of the terminal devices themselves, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0071] Example 4
[0072] like Figure 5 As shown in the figure, an embodiment of the present invention provides a model processing method. The execution subject of this method can be a server, which can be a single independent server or a server cluster composed of multiple servers. The server can be a backend server for financial or online shopping services, or a backend server for an application. Its system architecture can be as follows: Figure 2 As shown, the method may specifically include the following steps:
[0073] In step S502, a first model is sent to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain the first training sample data for training the first model. The first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain the trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0074] In step S504, the model update data corresponding to the trained target model sent by different terminal devices is received, and the time used to obtain the target model is determined.
[0075] In practice, the server starts timing after distributing the first model to different terminal devices. When it receives the model update data corresponding to the trained target model sent by different terminal devices, it stops timing. Thus, the time between stopping timing and starting timing can be determined as the time used to obtain the target model (i.e., the single update time of model training).
[0076] In step S506, the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the total number of different terminal devices are obtained.
[0077] In implementation, the received models can be aggregated. Due to differences in the performance of different terminal devices, the degree of pruning corresponding to the model structure of the target model obtained from different terminal devices also varies. Therefore, some units may only appear in the target model of certain terminal devices. For example, ... Figure 6 As shown, Figure 6 The three rectangles in the middle represent the weight matrices of a certain network layer in the target model of the three terminal devices. Figure 6 In the target models of the two lower terminal devices, the network layer was not pruned, therefore the weight matrices of the target models for the two lower terminal devices are complete. However, in the target model of the top terminal device, one neuron was pruned, resulting in a missing column of weights corresponding to that neuron in its weight matrix. Based on this, two different model aggregation methods can be used, which are applicable to different situations. One model aggregation method is By-worker, which divides the sum of the weights corresponding to the terminal devices with a pre-defined model structure in the target model by the total number of terminal devices (e.g., ...). Figure 6 The total number of terminal devices is 3. Based on this, the weight calculation rules can be obtained. The weights of terminal devices with different model structures in the target model can be calculated using the weight calculation rules, and the total number of different terminal devices can be obtained.
[0078] In step S508, based on the weights of the terminal devices corresponding to the target models provided by different terminal devices that contain the preset model structure and the total number of different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server and obtain the second model.
[0079] In implementation, such as Figure 6 As shown on the right, the weight matrix of a network layer (or unit) can be obtained by dividing the sum of the weights corresponding to the terminal devices that provide the target model containing the preset model structure by the total number of different terminal devices. The weight matrix of each network layer (or unit) can be obtained in the above way. The target models provided by different terminal devices can be aggregated to update the current model in the server, thereby obtaining a new weight matrix of the network layer. The weight matrix of the new network layer can be transformed to obtain the updated model (i.e., the second model).
[0080] It should be noted that the By-worker model aggregation method described above is suitable for the initial stage of model pruning, when the importance of the pruned neurons is very low, meaning that the weight values associated with the pruned neurons are close to 0. The By-worker model aggregation method can directly treat the weight values of the pruned neurons as 0 for aggregation, which is closer to the real-world situation.
[0081] In addition to the above-mentioned methods for model aggregation, model aggregation can also be performed using the By-unit model aggregation method. For details, please refer to steps S510 and S512 below.
[0082] In step S510, the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices are obtained.
[0083] In implementation, for the By-unit model aggregation method, the sum of the weights corresponding to terminal devices with a preset model structure in the target model can be divided by the number of terminal devices whose target models contain the preset model structure (e.g., ...). Figure 6 The number of terminal devices that contain the preset model structure in the target model provided by different terminal devices is 2). Based on this, the weight calculation rule can be obtained. The weight corresponding to the terminal devices with different model structures in the target model can be calculated by the weight calculation rule, and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices can be obtained.
[0084] In step S512, based on the weights of the terminal devices that contain the preset model structure in the target models provided by different terminal devices and the number of terminal devices that contain the preset model structure in the target models provided by different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server and obtain the second model.
[0085] In implementation, such as Figure 6 As shown on the left, the weight matrix of a network layer (or unit) can be obtained by dividing the sum of the weights corresponding to the terminal devices that provide the target model containing the preset model structure by the number of terminal devices that provide the target model containing the preset model structure. The weight matrix of each network layer (or unit) can be obtained in the above way. The target models provided by different terminal devices can be aggregated to update the current model in the server, thereby obtaining a new weight matrix of the network layer. The weight matrix of the new network layer can be transformed to obtain the updated model (i.e., the second model).
[0086] It should be noted that the By-unit model aggregation method described above is suitable for the later stages of model pruning. At this point, the importance of the pruned neurons (or units) is only relatively lower than that of other neurons (or units), but the weight values associated with the pruned neurons (or units) will not approach 0. The By-worker model aggregation method can directly treat the weight values of the pruned neurons (or units) as the average of the weights corresponding to the other two terminal devices for aggregation, which is closer to the real-world situation.
[0087] In step S514, if the time taken by each terminal device to obtain the target model is not within the preset range, and the degree of pruning of the model structure of the first model does not reach the preset minimum pruning threshold, then it is determined that the model structure of the second model needs to be pruned.
[0088] The preset range can be a pre-defined duration range, which can be set according to the actual situation, such as 1 hour to 1.5 hours or 1 hour to 1.2 hours. The minimum trimming threshold can be set according to the actual situation, such as 50% or 45%.
[0089] In implementation, it can be determined whether the time taken by each terminal device to obtain the target model is basically consistent. Specifically, the time taken by each terminal device to obtain the target model can be compared with a preset range to determine whether the time taken by each terminal device to obtain the target model is within the preset range. Furthermore, it can be determined whether the degree of pruning of the first model's structure reaches the minimum pruning threshold. The degree of pruning of the first model's structure can be obtained by dividing the size of the target model by the size of the first model. Specifically, the degree of pruning of the first model's structure can be compared with the minimum pruning threshold. Based on this, if the time taken by each terminal device to obtain the target model is not within the preset range, and the degree of pruning of the first model's structure does not reach the preset minimum pruning threshold, then it is determined that the second model's structure needs to be pruned.
[0090] It should be noted that if it is determined that the model structure of the second model still needs to be pruned, it is also necessary to determine whether to prune the model in the next round of model training. This is because if the model is pruned in every round of model training, it will affect the performance of the model. Therefore, after each round of model pruning, it is often necessary to retain one or more rounds of model training to allow the model to recover. The condition for determining whether to recover can be a pre-set number of model training rounds, or it can be determined by the accuracy curve to determine whether the accuracy growth has recovered, etc. The specific condition can be set according to the actual situation, and the embodiments in this specification do not limit this.
[0091] In step S516, if it is determined that the model structure of the second model needs to be pruned, the baseline update time corresponding to different terminal devices is determined based on the time used by the target model obtained by different terminal devices.
[0092] In implementation, the average time taken by different terminal devices to obtain the target model can be calculated. The minimum average among the calculated averages can be selected as the baseline update time for different terminal devices. By calculating the above averages, the influence of certain random factors (such as random bandwidth fluctuations, the influence of other tasks, etc.) can be eliminated, thereby making the modeling of terminal device capabilities more robust.
[0093] In step S518, based on preset data processing rules, the baseline update time of different terminal devices is processed to obtain the pre-selected pruning degree of the model structure of the second model for different terminal devices.
[0094] The data processing rules may include one or more of the following: data difference processing rules and data fitting processing rules.
[0095] In implementation, the (baseline update time, pre-selected pruning degree) corresponding to different terminal devices can be used as data points. The above data points can be interpolated using data interpolation rules. The baseline update time of different terminal devices obtained above can be substituted into the above interpolation process to obtain the pre-selected pruning degree of the model structure of the second model for the corresponding different terminal devices. Alternatively, the above data points can be fitted using data fitting rules. The baseline update time of different terminal devices obtained above can be substituted into the above data fitting process to obtain the pre-selected pruning degree of the model structure of the second model for the corresponding different terminal devices.
[0096] It should be noted that the data processing rules adopt data interpolation or data fitting rules. On the one hand, this is to avoid introducing unnecessary computational burden. On the other hand, as mentioned above, due to the influence of certain random factors, it is only necessary to obtain a rough value of the pre-selected clipping degree. Precise modeling is not required. Simple interpolation or data fitting can meet the above requirements.
[0097] In step S520, based on the pre-selected pruning degree and preset selection conditions, the pruning degree of the model structure of the second model by different terminal devices is determined, and the baseline update time of different terminal devices is used as the time used to train the second model.
[0098] The selection criteria can be set according to the actual situation. For example, when the pre-selected cropping degree is less than the preset threshold, the preset threshold is used as the cropping degree of the model structure of the second model by the terminal device. When the pre-selected cropping degree is greater than the preset threshold, the pre-selected cropping degree is used as the cropping degree of the model structure of the second model by the terminal device.
[0099] In implementation, the pre-selected pruning degree can be matched with the preset selection conditions. Based on the matching results, the pruning degree of the model structure of the second model for different terminal devices can be determined. In addition, the baseline update time of different terminal devices can be used as the training time for the second model.
[0100] In practical applications, the processing of determining the degree of trimming of the model structure of the second model by different terminal devices in step S520 above, based on the pre-selected trimming degree and preset selection conditions, can be varied. The following provides an optional processing method, which may specifically include the processing of steps B2 and B4.
[0101] In step B2, if the pre-selected cropping degree is less than the preset minimum cropping degree threshold, then the preset minimum cropping degree threshold is used as the cropping degree of the model structure of the second model for different terminal devices.
[0102] The minimum trimming threshold can be set according to the actual situation, such as 50% or 60%.
[0103] In practice, due to significant performance differences among terminal devices in some cases, the model structure calculated for lower-performing devices may be pruned to a very low degree. This results in a model with limited learning capabilities, potentially lacking key knowledge, which is detrimental to the overall federated learning. Therefore, it is necessary to constrain the pruning extent based on a pre-set minimum pruning threshold, ensuring that each terminal device retains a model with basic learning capabilities. Based on this, if the pre-selected pruning degree is less than the preset minimum pruning threshold, the preset minimum pruning threshold can be used as the pruning degree for the second model's structure for different terminal devices.
[0104] In step B4, if the difference between the pre-selected clipping degree and the clipping degree of the model structure corresponding to the second model is greater than the preset maximum clipping ratio, then the difference between the pre-selected clipping degree and the preset maximum clipping ratio is taken as the clipping degree of the model structure of the second model for different terminal devices.
[0105] The maximum cutting ratio can be set according to the actual situation, such as 20% or 40%.
[0106] In practice, during the model pruning process, some studies have shown that pruning too many model units at once can significantly reduce the model's performance. This is because the model pruning process lacks a fine-tuning process. Therefore, a maximum single pruning ratio is preset. The fine-tuning process can be the process of freezing some network layers of the pre-trained model (such as convolutional layers, usually multiple convolutional layers near the input layer, etc.) and training the remaining network layers (such as some convolutional layers near the output layer, etc.) and fully connected layers.
[0107] In step S522, the degree of pruning, the training time for the second model, and the second model are sent to different terminal devices. The training time for the second model and the second model are used to trigger the terminal devices to obtain the second training sample data. The second model is trained based on the second training sample data and the training time for the second model. The degree of pruning and the second model are used to trigger the server to adjust the model structure of the second model according to the degree of pruning to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
[0108] In addition, as mentioned above, after each model pruning, it is often necessary to retain one or more rounds of model training to allow the model to recover. The criteria for determining whether it has recovered can be a pre-set number of model training rounds or by judging through the accuracy curve to determine whether the accuracy growth has recovered, etc. Specifically, this can be achieved through the processing of steps S524 and S526 below.
[0109] In step S524, if it is determined that the model structure of the second model does not need to be pruned, the second model is sent to different terminal devices. The second model is used to trigger the terminal devices to obtain the third training sample data. The second model is trained based on the third training sample data to obtain the trained fourth model.
[0110] In step S526, model update data corresponding to the fourth model sent by different terminal devices is received. The current model in the server is updated based on the model update data corresponding to the fourth model provided by different terminal devices to obtain the fifth model. The fifth model is sent to different terminal devices for training. The current model in the server is updated based on the model update data corresponding to the trained model until the number of times the current model in the server is updated reaches a preset threshold. The updated model in the server is obtained and sent to different terminal devices for business processing.
[0111] Based on the processing in steps S502 to S526 above, compared to commonly used federated learning, the server adds calculations related to pruning the model structure, and the terminal device adds calculations related to the importance of model units. The computational overhead of both of these parts is negligible. Regarding the transmitted content, in one or more rounds of model training (one or more rounds of model training that require model pruning), two additional components are added: the degree of model structure pruning and the index of the base model corresponding to the local model. These additional components are also negligible compared to the overall transmitted content. Therefore, the additional overhead introduced in the above processing method is negligible.
[0112] This specification provides a model processing method. It involves receiving a first model from a server, obtaining first training sample data for training the first model, training the first model using the first training sample data, adjusting the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time required to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the server updates the current model to obtain a second model. It also determines whether the model structure of the second model needs further pruning. If it is determined that the model structure of the second model needs pruning, the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model are determined. Finally, the target model can be obtained... The second training sample data used to train the second model is taken. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure, resulting in a trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that adapt to the capabilities of the terminal devices themselves, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0113] Example 5
[0114] Based on the same idea, embodiments of this specification also provide a model processing device, such as... Figure 7 As shown.
[0115] The processing device for this model includes: a first model processing module 701, an update data sending module 702, a data receiving module 703, and a second model processing module 704, wherein:
[0116] The first model processing module 701 receives a first model sent by the server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by trimming the model structure of the first model.
[0117] The update data sending module 702 sends the model update data corresponding to the target model to the server. The model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model, and update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain the second model. It also determines whether the model structure of the second model needs to be pruned again, and when it is determined that the model structure of the second model needs to be pruned, it determines the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model.
[0118] The data receiving module 703 receives the degree of pruning of the model structure of the second model and the training time of the second model sent by the server, as well as the second model;
[0119] The second model processing module 704 acquires second training sample data for training the second model, trains the second model based on the second training sample data and the training time of the second model, adjusts the model structure of the second model by the degree of pruning of the model structure of the second model, obtains the trained third model, and sends the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
[0120] In this embodiment of the specification, the first model processing module 701 includes:
[0121] The first training unit uses the first training sample data to train the first model to obtain the first pre-selected model after training.
[0122] The first adjustment unit adjusts the model structure of the first pre-selected model to obtain the target model.
[0123] In this embodiment of the specification, the first model processing module 701 includes:
[0124] The second adjustment unit adjusts the model structure of the first model to obtain the second pre-selected model;
[0125] The second training unit uses the first training sample data to train the second pre-selected model to obtain the trained target model.
[0126] In the embodiments described in this specification, the device further includes:
[0127] The business processing module receives the second model sent by the server and performs business processing based on the second model. The second model is the model sent by the server when it determines that the model structure of the second model does not need to be trimmed.
[0128] In this embodiment of the specification, the first model processing module 701 trims the model structure of the first model based on a preset rule of unit importance in the model.
[0129] In this embodiment of the specification, the update data sending module 702 sends the index information of the target model and the index information of the first model to the server.
[0130] The specific processing procedures for each of the above modules or units can be found in the relevant content of Embodiments 1 to 4 above, and will not be repeated here.
[0131] This specification provides a model processing apparatus that receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time used to obtain the target model, and update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model. The apparatus also determines whether the model structure of the second model needs to be pruned again, and when it is determined that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model. Finally, it can obtain... The second training sample data used to train the second model is taken. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure, resulting in a trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that adapt to the capabilities of the terminal devices themselves, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0132] Example 6
[0133] Based on the same idea, embodiments of this specification also provide a model processing device, such as... Figure 8 As shown.
[0134] The processing unit for this model includes: a model distribution module 801, a model update module 802, and a data transmission module 803, wherein:
[0135] The model delivery module 801 delivers a first model to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain first training sample data for training the first model, use the first training sample data to train the first model, and adjust the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0136] The model update module 802 receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used by the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model.
[0137] The data sending module 803, if it is determined that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model, and sends the pruning degree, the training time of the second model, and the second model to different terminal devices. The training time of the second model and the second model are used to trigger the terminal devices to obtain second training sample data, and to train the second model based on the second training sample data and the training time of the second model. The pruning degree and the second model are used to trigger the server to adjust the model structure of the second model according to the pruning degree to obtain a trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the device.
[0138] In the embodiments of this specification, the model update module 802 includes:
[0139] The first data acquisition unit acquires the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the total number of different terminal devices.
[0140] The first model aggregation unit aggregates the target models provided by different terminal devices based on the weights corresponding to the terminal devices and the weights corresponding to different terminal devices that contain a preset model structure in the target model provided by different terminal devices, so as to update the current model in the server and obtain the second model.
[0141] In the embodiments of this specification, the model update module 802 includes:
[0142] The second data acquisition unit acquires the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices.
[0143] The second model aggregation unit aggregates the target models provided by different terminal devices based on the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices, so as to update the current model in the server and obtain the second model.
[0144] In the embodiments described in this specification, the device further includes:
[0145] If the time taken by each terminal device to obtain the target model is not within a preset range, and the degree of pruning of the model structure of the first model has not reached the preset minimum pruning threshold, then the pruning determination module determines that the model structure of the second model needs to be pruned.
[0146] In the embodiments described in this specification, the device further includes:
[0147] If the second model sending module determines that the model structure of the second model does not need to be pruned, it sends the second model to different terminal devices. The second model is used to trigger the terminal devices to obtain the third training sample data, and the second model is trained based on the third training sample data to obtain the trained fourth model.
[0148] The update data receiving module receives model update data corresponding to the fourth model sent by different terminal devices. Based on the model update data corresponding to the fourth model provided by different terminal devices, the current model in the server is updated to obtain the fifth model. The fifth model is sent to different terminal devices for training, and the current model in the server is updated based on the model update data corresponding to the trained model. This process continues until the number of times the current model in the server is updated reaches a preset threshold, resulting in the updated model in the server. The updated model is then sent to different terminal devices for business processing.
[0149] In this embodiment of the specification, the data transmission module 803 includes:
[0150] The baseline duration determination unit determines the baseline update duration corresponding to different terminal devices based on the duration used by the target model obtained from different terminal devices if it is determined that the model structure of the second model needs to be pruned.
[0151] The pre-selected clipping degree determination unit processes the baseline update time of different terminal devices based on preset data processing rules to obtain the pre-selected clipping degree of the model structure of the second model for different terminal devices. The data processing rules include one or more of data difference processing rules and data fitting processing rules.
[0152] The data determination unit determines the degree of pruning of the model structure of the second model by different terminal devices based on the pre-selected pruning degree and the preset selection conditions, and uses the baseline update time of different terminal devices as the time used to train the second model.
[0153] In this embodiment of the specification, if the pre-selected cropping degree is less than a preset minimum cropping degree threshold, the data determining unit uses the preset minimum cropping degree threshold as the cropping degree of the model structure of the second model for different terminal devices; if the difference between the pre-selected cropping degree and the cropping degree of the model structure corresponding to the second model is greater than a preset maximum cropping ratio, the difference between the pre-selected cropping degree and the preset maximum cropping ratio is used as the cropping degree of the model structure of the second model for different terminal devices.
[0154] The specific processing procedures for each of the above modules or units can be found in the relevant content of Embodiments 1 to 4 above, and will not be repeated here.
[0155] This specification provides a model processing apparatus that receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time used to obtain the target model, and update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model. The apparatus also determines whether the model structure of the second model needs to be pruned again, and when it is determined that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model. Finally, it can obtain... The second training sample data used to train the second model is taken. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure, resulting in a trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that adapt to the capabilities of the terminal devices themselves, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0156] Example 7
[0157] The above describes the model processing apparatus provided in the embodiments of this specification. Based on the same idea, the embodiments of this specification also provide a model processing device, such as... Figure 9 As shown.
[0158] The processing device for the model can be a terminal device or a server, as described in the above embodiments.
[0159] The processing device of the model can vary considerably due to differences in configuration or performance, and may include one or more processors 901 and memory 902. Memory 902 may store one or more application programs or data. Memory 902 may be temporary or persistent storage. The application programs stored in memory 902 may include one or more modules (not shown in the figures), each module including a series of computer-executable instructions for the model's processing device. Furthermore, processor 901 may be configured to communicate with memory 902 and execute the series of computer-executable instructions in memory 902 on the model's processing device. The model's processing device may also include one or more power supplies 903, one or more wired or wireless network interfaces 904, one or more input / output interfaces 905, and one or more keyboards 906.
[0160] Specifically, in this embodiment, the processing device for the model includes a memory and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the processing device of the model, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:
[0161] The system receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0162] The model update data corresponding to the target model is sent to the server. The model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model, and to update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain the second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model are determined.
[0163] The server sends the degree of pruning of the model structure of the second model and the training time of the second model, as well as the second model itself.
[0164] Obtain second training sample data for training the second model, train the second model based on the second training sample data and the training time of the second model, and adjust the model structure of the second model by the degree of pruning of the model structure to obtain the trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
[0165] In the embodiments of this specification, training the first model using the first training sample data and adjusting the model structure of the first model to obtain the trained target model includes:
[0166] The first model is trained using the first training sample data to obtain the first pre-selected model after training.
[0167] The model structure of the first pre-selected model is adjusted to obtain the target model.
[0168] In the embodiments of this specification, training the first model using the first training sample data and adjusting the model structure of the first model to obtain the trained target model includes:
[0169] The model structure of the first model is adjusted to obtain the second pre-selected model;
[0170] The second pre-selected model is trained using the first training sample data to obtain the trained target model.
[0171] The embodiments in this specification also include:
[0172] The server receives the second model sent by the server and performs business processing based on the second model. The second model is the model sent by the server when it determines that the model structure of the second model does not need to be pruned.
[0173] In the embodiments of this specification, adjusting the model structure of the first model includes:
[0174] The model structure of the first model is trimmed based on the preset unit importance rules in the model.
[0175] In this embodiment of the specification, sending the model update data corresponding to the target model to the server includes:
[0176] The index information of the target model and the index information of the first model are sent to the server.
[0177] The specific processing procedure of the processing device for the above model can be found in the relevant content of Embodiment 1 and Embodiment 2 above, and will not be repeated here.
[0178] Specifically, in this embodiment, the processing device for the model includes a memory and one or more programs, wherein one or more programs are stored in the memory, and one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the processing device of the model, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:
[0179] A first model is sent to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain first training sample data for training the first model. The first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0180] The system receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model.
[0181] If it is determined that the model structure of the second model needs to be pruned, then the degree of pruning of the model structure of the second model for different terminal devices and the training time of the second model are determined, and the pruning degree, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal devices to obtain second training sample data, and the second model is trained based on the second training sample data and the training time of the second model. The pruning degree and the second model are used to trigger the server to adjust the model structure of the second model according to the pruning degree to obtain the trained third model, and the model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
[0182] In this embodiment of the specification, updating the current model in the server based on model update data corresponding to the target model provided by different terminal devices to obtain a second model includes:
[0183] Obtain the weights corresponding to the terminal devices that contain the preset model structure in the target model provided by different terminal devices, and the weights corresponding to different terminal devices;
[0184] Based on the target models provided by different terminal devices, which include the weights corresponding to the terminal devices with a preset model structure and the weights corresponding to different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server, thereby obtaining a second model.
[0185] In this embodiment of the specification, updating the current model in the server based on model update data corresponding to the target model provided by different terminal devices to obtain a second model includes:
[0186] Obtain the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices, and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices;
[0187] Based on the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server and obtain the second model.
[0188] In the embodiments of this specification, before determining the degree of pruning of the model structure of the second model for different terminal devices and the training time for the second model if it is determined that the model structure of the second model needs to be pruned, the method further includes:
[0189] If the time taken by each terminal device to obtain the target model is not within the preset range, and the degree of pruning of the model structure of the first model does not reach the preset minimum pruning threshold, then it is determined that the model structure of the second model needs to be pruned.
[0190] The embodiments in this specification also include:
[0191] If it is determined that the model structure of the second model does not need to be pruned, the second model is sent to different terminal devices. The second model is used to trigger the terminal devices to obtain the third training sample data. The second model is trained based on the third training sample data to obtain the trained fourth model.
[0192] The system receives model update data corresponding to the fourth model sent by different terminal devices, updates the current model in the server based on the model update data corresponding to the fourth model provided by different terminal devices to obtain a fifth model, sends the fifth model to different terminal devices for training, and updates the current model in the server based on the model update data corresponding to the trained model, until the number of times the current model in the server is updated reaches a preset threshold, to obtain the updated model of the current model in the server, and sends the updated model to different terminal devices for business processing.
[0193] In the embodiments of this specification, if it is determined that the model structure of the second model needs to be pruned, then determining the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model includes:
[0194] If it is determined that the model structure of the second model needs to be pruned, then the baseline update time corresponding to different terminal devices is determined based on the time taken by the target model to obtain the target model on different terminal devices.
[0195] Based on preset data processing rules, the baseline update time of different terminal devices is processed to obtain the pre-selected pruning degree of the model structure of the second model for different terminal devices. The data processing rules include one or more of data difference processing rules and data fitting processing rules.
[0196] Based on the pre-selected pruning degree and preset selection conditions, the pruning degree of the model structure of the second model for different terminal devices is determined, and the baseline update time of different terminal devices is used as the training time for the second model.
[0197] In this embodiment of the specification, determining the degree of trimming of the model structure of the second model for different terminal devices based on the pre-selected trimming degree and preset selection conditions includes:
[0198] If the preselected cropping degree is less than the preset minimum cropping degree threshold, then the preset minimum cropping degree threshold is used as the cropping degree of the model structure of the second model for different terminal devices;
[0199] If the difference between the preselected cropping degree and the cropping degree of the model structure corresponding to the second model is greater than the preset maximum cropping ratio, then the difference between the preselected cropping degree and the preset maximum cropping ratio is taken as the cropping degree of the model structure of the second model for different terminal devices.
[0200] The specific processing procedure of the processing device for the above model can be found in the relevant content of Embodiments 3 and 4 above, and will not be repeated here.
[0201] This specification provides a model processing device that receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time used to obtain the target model, and update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model. The device also determines whether the model structure of the second model needs to be pruned again, and when it is determined that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model. Finally, it can obtain... The second training sample data used to train the second model is taken. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure, resulting in a trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that adapt to the capabilities of the terminal devices themselves, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0202] Example 8
[0203] Furthermore, based on the above Figures 1A to 6 The method shown in this specification, along with one or more embodiments, also provides a storage medium for storing computer-executable instruction information. In one specific embodiment, the storage medium can be a USB flash drive, optical disc, hard disk, etc. When the computer-executable instruction information stored in the storage medium is executed by a processor, it can achieve the following process:
[0204] The system receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0205] The model update data corresponding to the target model is sent to the server. The model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model, and to update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain the second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model are determined.
[0206] The server sends the degree of pruning of the model structure of the second model and the training time of the second model, as well as the second model itself.
[0207] Obtain second training sample data for training the second model, train the second model based on the second training sample data and the training time of the second model, and adjust the model structure of the second model by the degree of pruning of the model structure to obtain the trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
[0208] In the embodiments of this specification, training the first model using the first training sample data and adjusting the model structure of the first model to obtain the trained target model includes:
[0209] The first model is trained using the first training sample data to obtain the first pre-selected model after training.
[0210] The model structure of the first pre-selected model is adjusted to obtain the target model.
[0211] In the embodiments of this specification, training the first model using the first training sample data and adjusting the model structure of the first model to obtain the trained target model includes:
[0212] The model structure of the first model is adjusted to obtain the second pre-selected model;
[0213] The second pre-selected model is trained using the first training sample data to obtain the trained target model.
[0214] The embodiments in this specification also include:
[0215] The server receives the second model sent by the server and performs business processing based on the second model. The second model is the model sent by the server when it determines that the model structure of the second model does not need to be pruned.
[0216] In the embodiments of this specification, adjusting the model structure of the first model includes:
[0217] The model structure of the first model is trimmed based on the preset unit importance rules in the model.
[0218] In this embodiment of the specification, sending the model update data corresponding to the target model to the server includes:
[0219] The index information of the target model and the index information of the first model are sent to the server.
[0220] The specific processing steps described above can be found in the relevant content of Embodiment 1 and Embodiment 2 above, and will not be repeated here.
[0221] Furthermore, one or more embodiments of this specification also provide a storage medium for storing computer-executable instruction information. In another specific embodiment, the storage medium can be a USB flash drive, optical disc, hard disk, etc. When the computer-executable instruction information stored in the storage medium is executed by a processor, it can realize the following process:
[0222] A first model is sent to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain first training sample data for training the first model. The first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model.
[0223] The system receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model.
[0224] If it is determined that the model structure of the second model needs to be pruned, then the degree of pruning of the model structure of the second model for different terminal devices and the training time of the second model are determined, and the pruning degree, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal devices to obtain second training sample data, and the second model is trained based on the second training sample data and the training time of the second model. The pruning degree and the second model are used to trigger the server to adjust the model structure of the second model according to the pruning degree to obtain the trained third model, and the model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
[0225] In this embodiment of the specification, updating the current model in the server based on model update data corresponding to the target model provided by different terminal devices to obtain a second model includes:
[0226] Obtain the weights corresponding to the terminal devices that contain the preset model structure in the target model provided by different terminal devices, and the weights corresponding to different terminal devices;
[0227] Based on the target models provided by different terminal devices, which include the weights corresponding to the terminal devices with a preset model structure and the weights corresponding to different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server, thereby obtaining a second model.
[0228] In this embodiment of the specification, updating the current model in the server based on model update data corresponding to the target model provided by different terminal devices to obtain a second model includes:
[0229] Obtain the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices, and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices;
[0230] Based on the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server and obtain the second model.
[0231] In the embodiments of this specification, before determining the degree of pruning of the model structure of the second model for different terminal devices and the training time for the second model if it is determined that the model structure of the second model needs to be pruned, the method further includes:
[0232] If the time taken by each terminal device to obtain the target model is not within the preset range, and the degree of pruning of the model structure of the first model does not reach the preset minimum pruning threshold, then it is determined that the model structure of the second model needs to be pruned.
[0233] The embodiments in this specification also include:
[0234] If it is determined that the model structure of the second model does not need to be pruned, the second model is sent to different terminal devices. The second model is used to trigger the terminal devices to obtain the third training sample data. The second model is trained based on the third training sample data to obtain the trained fourth model.
[0235] The system receives model update data corresponding to the fourth model sent by different terminal devices, updates the current model in the server based on the model update data corresponding to the fourth model provided by different terminal devices to obtain a fifth model, sends the fifth model to different terminal devices for training, and updates the current model in the server based on the model update data corresponding to the trained model, until the number of times the current model in the server is updated reaches a preset threshold, to obtain the updated model of the current model in the server, and sends the updated model to different terminal devices for business processing.
[0236] In the embodiments of this specification, if it is determined that the model structure of the second model needs to be pruned, then determining the degree of pruning of the model structure of the second model by different terminal devices and the training time of the second model includes:
[0237] If it is determined that the model structure of the second model needs to be pruned, then the baseline update time corresponding to different terminal devices is determined based on the time taken by the target model to obtain the target model on different terminal devices.
[0238] Based on preset data processing rules, the baseline update time of different terminal devices is processed to obtain the pre-selected pruning degree of the model structure of the second model for different terminal devices. The data processing rules include one or more of data difference processing rules and data fitting processing rules.
[0239] Based on the pre-selected pruning degree and preset selection conditions, the pruning degree of the model structure of the second model for different terminal devices is determined, and the baseline update time of different terminal devices is used as the training time for the second model.
[0240] In this embodiment of the specification, determining the degree of trimming of the model structure of the second model for different terminal devices based on the pre-selected trimming degree and preset selection conditions includes:
[0241] If the preselected cropping degree is less than the preset minimum cropping degree threshold, then the preset minimum cropping degree threshold is used as the cropping degree of the model structure of the second model for different terminal devices;
[0242] If the difference between the preselected cropping degree and the cropping degree of the model structure corresponding to the second model is greater than the preset maximum cropping ratio, then the difference between the preselected cropping degree and the preset maximum cropping ratio is taken as the cropping degree of the model structure of the second model for different terminal devices.
[0243] The specific processing steps described above can be found in the relevant content of Embodiments 3 and 4 above, and will not be repeated here.
[0244] This specification provides a storage medium that receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. Then, the model update data corresponding to the target model can be sent to the server to trigger the server to determine the time used to obtain the target model, and update the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain a second model. The specification also determines whether the model structure of the second model needs to be pruned again, and when it is determined that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model. Finally, the storage medium can obtain the target model. The second training sample data is used to train the second model. Based on the second training sample data and the received training time for the second model, the second model is trained. The model structure of the second model is adjusted according to the received pruning degree of the model structure to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model. Then, the model is trained again for multiple rounds of pruning and training. In this way, the efficient federated learning framework based on the performance of adaptive terminal devices can be used to provide different training tasks (i.e., models of different sizes) for terminal devices with different performance. On the one hand, it can maximize the computing power of terminal devices with different performance and ensure model performance. On the other hand, by equipping models that are adapted to the capabilities of the terminal devices, the single-round update time of all terminal devices tends to be consistent, solving the "burden" problem that is common in federated learning and improving training efficiency.
[0245] The foregoing has described specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0246] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using a hardware physical module. For example, a Programmable Logic Device (PLD) (e.g., a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program a digital system themselves to "integrate" it onto a PLD, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.
[0247] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, ASICs, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0248] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.
[0249] For ease of description, the above apparatus is described by dividing it into various functional units. Of course, when implementing one or more embodiments of this specification, the functions of each unit can be implemented in one or more software and / or hardware.
[0250] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0251] The embodiments described herein are illustrated with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable parallel device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable parallel device, create means for implementing the functions specified in one or more flowchart illustrations and / or one or more block diagrams.
[0252] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable fraud device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means that implement the functions specified in one or more flowcharts and / or one or more block diagrams.
[0253] These computer program instructions may also be loaded onto a computer or other programmable device in parallel or in series, causing a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process, such that the instructions, which execute on the computer or other programmable device, provide steps for implementing the functions specified in one or more flowcharts and / or one or more block diagrams.
[0254] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0255] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0256] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, 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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0257] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0258] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, one or more embodiments of this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, one or more embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0259] One or more embodiments of this specification can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a particular task or implement a particular abstract data type. One or more embodiments of this specification can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.
[0260] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to interchangeably. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0261] The above description is merely an embodiment of this specification and is not intended to limit this application. Various modifications and variations can be made to this specification by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this specification should be included within the scope of the claims of this specification.
Claims
1. A method for processing a model, applied to any terminal device in a federated learning framework, wherein the federated learning framework includes a server and multiple collaborative learning terminal devices, the method comprising: The system receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The model update data corresponding to the target model is sent to the server. The model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the current model in the server is updated to obtain multiple models. The multiple models are averaged to obtain a second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model are determined to provide different training tasks for different terminal devices. The server sends the degree of pruning of the model structure of the second model and the training time of the second model, as well as the second model itself. Obtain second training sample data for training the second model, train the second model based on the second training sample data and the training time of the second model, and adjust the model structure of the second model by the degree of pruning of the model structure to obtain the trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
2. The method according to claim 1, wherein training the first model using the first training sample data and adjusting the model structure of the first model to obtain the trained target model includes: The first model is trained using the first training sample data to obtain the first pre-selected model after training. The model structure of the first pre-selected model is adjusted to obtain the target model.
3. The method according to claim 1, wherein training the first model using the first training sample data and adjusting the model structure of the first model to obtain the trained target model includes: The model structure of the first model is adjusted to obtain the second pre-selected model; The second pre-selected model is trained using the first training sample data to obtain the trained target model.
4. The method according to claim 1, further comprising: The server receives the second model sent by the server and performs business processing based on the second model. The second model is the model sent by the server when it determines that the model structure of the second model does not need to be pruned.
5. The method according to any one of claims 1-4, wherein adjusting the model structure of the first model includes: The model structure of the first model is trimmed based on the preset unit importance rules in the model.
6. The method according to claim 1, wherein sending the model update data corresponding to the target model to the server comprises: The index information of the target model and the index information of the first model are sent to the server.
7. A method for processing a model, applied to a server in a federated learning framework, the federated learning framework including a server and multiple collaborative learning terminal devices, the method comprising: A first model is sent to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain first training sample data for training the first model. The first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The system receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain multiple models. The system then averages the multiple models to obtain a second model. If it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model and the training time of the second model for different terminal devices are determined to provide different training tasks for different terminal devices. The degree of pruning, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal device to obtain the second training sample data. The second model is trained based on the second training sample data and the training time of the second model. The degree of pruning and the second model are used to trigger the server to adjust the model structure of the second model according to the degree of pruning to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
8. The method according to claim 7, wherein updating the current model in the server based on model update data corresponding to the target model provided by different terminal devices to obtain a second model includes: Obtain the weights corresponding to the terminal devices that contain the preset model structure in the target model provided by different terminal devices, and the weights corresponding to different terminal devices; Based on the target models provided by different terminal devices, which include the weights corresponding to the terminal devices with a preset model structure and the weights corresponding to different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server, thereby obtaining a second model.
9. The method according to claim 7, wherein updating the current model in the server based on model update data corresponding to the target model provided by different terminal devices to obtain a second model includes: Obtain the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices, and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices; Based on the weights of the terminal devices that contain the preset model structure in the target model provided by different terminal devices and the number of terminal devices that contain the preset model structure in the target model provided by different terminal devices, the target models provided by different terminal devices are aggregated to update the current model in the server and obtain the second model.
10. The method according to claim 7, wherein if it is determined that the model structure of the second model needs to be pruned, before determining the degree of pruning of the model structure of the second model by different terminal devices and the training time for the second model, the method further comprises: If the time taken by each terminal device to obtain the target model is not within the preset range, and the degree of pruning of the model structure of the first model does not reach the preset minimum pruning threshold, then it is determined that the model structure of the second model needs to be pruned.
11. The method according to claim 7, further comprising: If it is determined that the model structure of the second model does not need to be pruned, the second model is sent to different terminal devices. The second model is used to trigger the terminal devices to obtain the third training sample data. The second model is trained based on the third training sample data to obtain the trained fourth model. The system receives model update data corresponding to the fourth model sent by different terminal devices, updates the current model in the server based on the model update data corresponding to the fourth model provided by different terminal devices to obtain a fifth model, sends the fifth model to different terminal devices for training, and updates the current model in the server based on the model update data corresponding to the trained model, until the number of times the current model in the server is updated reaches a preset threshold, to obtain the updated model of the current model in the server, and sends the updated model to different terminal devices for business processing.
12. The method according to claim 7, wherein if it is determined that the model structure of the second model needs to be pruned, determining the degree of pruning of the model structure of the second model by different terminal devices and the training time for the second model includes: If it is determined that the model structure of the second model needs to be pruned, then the baseline update time corresponding to different terminal devices is determined based on the time taken by the target model to obtain the target model on different terminal devices. Based on preset data processing rules, the baseline update time of different terminal devices is processed to obtain the pre-selected pruning degree of the model structure of the second model for different terminal devices. The data processing rules include one or more of data difference processing rules and data fitting processing rules. Based on the pre-selected pruning degree and preset selection conditions, the pruning degree of the model structure of the second model for different terminal devices is determined, and the baseline update time of different terminal devices is used as the training time for the second model.
13. The method according to claim 12, wherein determining the degree of trimming of the model structure of the second model for different terminal devices based on the pre-selected trimming degree and preset selection conditions includes: If the preselected cropping degree is less than the preset minimum cropping degree threshold, then the preset minimum cropping degree threshold is used as the cropping degree of the model structure of the second model for different terminal devices; If the difference between the preselected cropping degree and the cropping degree of the model structure corresponding to the second model is greater than the preset maximum cropping ratio, then the difference between the preselected cropping degree and the preset maximum cropping ratio is taken as the cropping degree of the model structure of the second model for different terminal devices.
14. A model processing apparatus, applied to any terminal device in a federated learning framework, the federated learning framework including a server and multiple collaborative learning terminal devices, the apparatus comprising: The first model processing module receives a first model sent by the server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by trimming the model structure of the first model. The update data sending module sends the model update data corresponding to the target model to the server. The model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the current model in the server is updated to obtain multiple models. The multiple models are averaged to obtain a second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model are determined to provide different training tasks for different terminal devices. The data receiving module receives the degree of pruning of the model structure of the second model and the training time of the second model sent by the server, as well as the second model itself. The second model processing module acquires second training sample data for training the second model, trains the second model based on the second training sample data and the training time of the second model, adjusts the model structure of the second model by pruning the model structure of the second model, obtains the trained third model, and sends the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
15. A model processing apparatus applied to a server in a federated learning framework, the federated learning framework including a server and multiple collaborative learning terminal devices, the apparatus comprising: The model delivery module delivers a first model to different pre-selected terminal devices. The first model is used to trigger the terminal device to obtain first training sample data for training the first model, use the first training sample data to train the first model, and adjust the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The model update module receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used by the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain multiple models. The average of the multiple models is then calculated to obtain a second model. The data sending module, if it determines that the model structure of the second model needs to be pruned, determines the degree of pruning of the model structure of the second model for different terminal devices and the training time of the second model, so as to provide different training tasks for different terminal devices. The pruning degree, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal device to obtain second training sample data. Based on the second training sample data and the training time of the second model, the second model is trained. The pruning degree and the second model are used to trigger the server to adjust the model structure of the second model according to the pruning degree, to obtain a trained third model. The model update data corresponding to the third model is sent to the device as the model update data corresponding to the target model.
16. A model processing device, applied to any terminal device in a federated learning framework, the federated learning framework including a server and multiple collaborative learning terminal devices, the model processing device comprising: processor; as well as A memory configured to store computer-executable instructions, which, when executed, cause the processor to: The system receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The model update data corresponding to the target model is sent to the server. The model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the current model in the server is updated to obtain multiple models. The multiple models are averaged to obtain a second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model are determined to provide different training tasks for different terminal devices. The server sends the degree of pruning of the model structure of the second model and the training time of the second model, as well as the second model itself. Obtain second training sample data for training the second model, train the second model based on the second training sample data and the training time of the second model, and adjust the model structure of the second model by the degree of pruning of the model structure to obtain the trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
17. A model processing device applied to a server in a federated learning framework, the federated learning framework including a server and multiple collaborative learning terminal devices, the model processing device comprising: processor; as well as A memory configured to store computer-executable instructions, which, when executed, cause the processor to: A first model is sent to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain first training sample data for training the first model. The first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The system receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain multiple models. The system then averages the multiple models to obtain a second model. If it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model and the training time of the second model for different terminal devices are determined to provide different training tasks for different terminal devices. The degree of pruning, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal device to obtain the second training sample data. The second model is trained based on the second training sample data and the training time of the second model. The degree of pruning and the second model are used to trigger the server to adjust the model structure of the second model according to the degree of pruning to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.
18. A storage medium applied to any terminal device in a federated learning framework, the federated learning framework including a server and multiple collaborative learning terminal devices, the storage medium being used to store computer-executable instructions, the executable instructions implementing the following process when executed by a processor: The system receives a first model sent by a server, obtains first training sample data for training the first model, trains the first model using the first training sample data, and adjusts the model structure of the first model to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The model update data corresponding to the target model is sent to the server. The model update data corresponding to the target model is used to trigger the server to determine the time used to obtain the target model. Based on the model update data corresponding to the target model provided by different terminal devices, the current model in the server is updated to obtain multiple models. The multiple models are averaged to obtain a second model. It is also determined whether the model structure of the second model needs to be pruned again. When it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model by different terminal devices and the time used to train the second model are determined to provide different training tasks for different terminal devices. The server sends the degree of pruning of the model structure of the second model and the training time of the second model, as well as the second model itself. Obtain second training sample data for training the second model, train the second model based on the second training sample data and the training time of the second model, and adjust the model structure of the second model by the degree of pruning of the model structure to obtain the trained third model, and send the model update data corresponding to the third model as the model update data corresponding to the target model to the server.
19. A storage medium for use in a server within a federated learning framework, the federated learning framework including a server and multiple collaborative learning terminal devices, the storage medium for storing computer-executable instructions that, when executed by a processor, implement the following process: A first model is sent to different pre-selected terminal devices. The first model is used to trigger the terminal devices to obtain first training sample data for training the first model. The first model is trained using the first training sample data, and the model structure of the first model is adjusted to obtain a trained target model. The target model has the same model structure as the first model, or the target model is a model obtained by pruning the model structure of the first model. The system receives model update data corresponding to the trained target model sent by different terminal devices, determines the duration used to obtain the target model, and updates the current model in the server based on the model update data corresponding to the target model provided by different terminal devices to obtain multiple models. The system then averages the multiple models to obtain a second model. If it is determined that the model structure of the second model needs to be pruned, the degree of pruning of the model structure of the second model and the training time of the second model for different terminal devices are determined to provide different training tasks for different terminal devices. The degree of pruning, the training time of the second model, and the second model are sent to different terminal devices. The training time of the second model and the second model are used to trigger the terminal device to obtain the second training sample data. The second model is trained based on the second training sample data and the training time of the second model. The degree of pruning and the second model are used to trigger the server to adjust the model structure of the second model according to the degree of pruning to obtain the trained third model. The model update data corresponding to the third model is sent to the server as the model update data corresponding to the target model.