Model Training Method and Related Devices Based on Edge-Cloud Collaboration
Through the model training method of edge-end collaboration, the model is split into server and device-side, combined with knowledge distillation and federated learning, the problems of data privacy and efficiency in large language model training are solved, and efficient and secure model training is achieved.
Patent Information
- Application Number
- CN202411221451.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2044-09-02
AI Technical Summary
Large language models face user data privacy protection needs and data island problems when acquiring large-scale high-quality training data. Traditional training methods rely on cloud computing power and storage, resulting in inefficiency.
The model training method of edge-end collaboration is adopted, and the model is split into server-side and device-side models, and knowledge distillation and local training is used for mobile devices. Combined with federated learning and in-network aggregation technology of data processors, the model is trained locally and uploaded encryptedly to ensure data privacy and compliance.
This improves training speed, reduces the computational burden of individual participants, reduces network load, realizes the lightweight and efficient model, and adapts to resource-constrained edge environments.
Smart Images

Figure CN119358637B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of model training, and in particular, to a model training method and related devices based on edge-cloud collaboration. Background Art
[0002] With the continuous development and wide application of large language model technology, the number of model parameters corresponding to it has increased rapidly like an exponential function curve. While the technology iteration speed in the field of large language models is extremely fast and the model complexity is continuously increasing, in the face of the growing demand for user data privacy protection and the problem of data silos, large language models face huge challenges in obtaining large-scale high-quality training data. Traditional large language model training uploads data to the cloud, and the model and data are downloaded after being trained in the cloud, relying on the computing power and a large amount of storage space provided by the cloud. Summary of the Invention
[0003] In view of this, the purpose of this application is to propose a model training method and related devices based on edge-cloud collaboration.
[0004] Based on the above purpose, this application provides a model training method based on edge-cloud collaboration, including:
[0005] According to the obtained mobile device resource parameters, split the model to be trained to obtain a first model and a second model;
[0006] Based on the local data of the mobile device, use the mobile device to perform knowledge distillation on the second model to obtain a distilled model;
[0007] Use the mobile device to send the first parameters of the distilled model to the data processor to obtain second parameters, and use the data processor to upload the second parameters to the server;
[0008] Use the server to calculate fourth parameters based on the second parameters and the third parameters of the model to be trained;
[0009] Based on the fourth parameters, use the server to update the first model to obtain a third model and the fifth parameters of the third model;
[0010] Based on the fifth parameters, use the mobile device to train the distilled model to obtain the sixth parameters of the fourth model;
[0011] In response to reaching the condition for stopping training, use the third model and the fourth model as the trained models.
[0012] In a possible implementation, the mobile device resource parameters include hardware resource parameters, latency sensitivity, load balancing, and model structure;
[0013] According to the obtained mobile device resource parameters, splitting the model to be trained to obtain a first model and a second model, including:
[0014] Based on the hardware resource parameters, latency sensitivity, load balancing, and model structure, splitting the model to be trained to obtain the first model and the second model.
[0015] In a possible implementation, using the local data of the mobile device to perform knowledge distillation on the second model using the mobile device to obtain a distilled model, including:
[0016] Using a server to train the second model to obtain a fifth model;
[0017] Based on the learning loss of the local data and the soft label distribution of the fifth model, using the mobile device to perform knowledge distillation on the second model to obtain the distilled model.
[0018] In a possible implementation, using the mobile device to send the first parameter of the distilled model to a data processor to obtain a second parameter, and using the data processor to upload the second parameter to the server, including:
[0019] Using the mobile device to send the first parameter of the distilled model to the data processor;
[0020] Using the data processor to perform aggregation processing on the first parameter to obtain the second parameter;
[0021] Using the data processor to upload the second parameter to the server.
[0022] In a possible implementation, calculating a fourth parameter based on the second parameter and the third parameter of the model to be trained, including:
[0023]
[0024] where w new represents the fourth parameter, w global represents the third parameter, represents the second parameter, i represents the i-th switch, η represents the learning rate of the model to be trained, and N represents the number of mobile devices participating in this round of training.
[0025] In a possible implementation, based on the fourth parameter, using the server to update the first model to obtain a third model and the fifth parameter of the third model, including:
[0026] Use the fourth parameter as the parameter of the first model, and update the first model by the server to obtain a third model and a fifth parameter of the third model.
[0027] In a possible implementation, the sixth parameter is calculated by the following formula:
[0028]
[0029] where r″ represents the sixth parameter of the fourth model, a represents the update ratio, r represents the seventh parameter obtained by the server for training the model to be trained, and r′ represents the first parameter.
[0030] Based on the same inventive concept, an embodiment of the present application further provides a model training device based on edge-cloud collaboration, including:
[0031] A splitting module, configured to split the model to be trained according to the obtained mobile device resource parameters to obtain a first model and a second model;
[0032] A mobile device, configured to perform knowledge distillation on the second model based on the local data of the mobile device to obtain a distilled model;
[0033] A mobile device, configured to send the first parameter of the distilled model to a data processor to obtain a second parameter, and use the data processor to upload the second parameter to the server;
[0034] A server, configured to calculate a fourth parameter based on the second parameter and the third parameter of the model to be trained;
[0035] A server, configured to update the first model based on the fourth parameter to obtain a third model and a fifth parameter of the third model;
[0036] A mobile device, configured to train the distilled model based on the fifth parameter to obtain a sixth parameter of the fourth model;
[0037] A stop module, configured to use the third model and the fourth model as the trained models in response to reaching the condition for stopping training.
[0038] Based on the same inventive concept, an embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the program, the method for model training based on edge-cloud collaboration as described in any one of the above is implemented.
[0039] Based on the same inventive concept, an embodiment of the present application further provides a non-transitory computer-readable storage medium. The non-transitory computer-readable storage medium stores computer instructions for causing the computer to execute any one of the above-mentioned model training methods based on edge-end collaboration.
[0040] As can be seen from the above, for the model training method and related devices based on edge-end collaboration provided by the present application, according to the obtained mobile device resource parameters, the model to be trained is split to obtain a first model and a second model; based on the local data of the mobile device, the mobile device is used to perform knowledge distillation on the second model to obtain a distilled model; the mobile device is used to send the first parameters of the distilled model to a data processor to obtain second parameters, and the data processor is used to upload the second parameters; the server is used to calculate fourth parameters based on the second parameters and the third parameters of the model to be trained; based on the fourth parameters, the server is used to update the first model to obtain a third model and the fifth parameters of the third model; based on the fifth parameters, the mobile device is used to train the distilled model to obtain the sixth parameters of the fourth model; in response to reaching the condition for stopping training, the third model and the fourth model are used as the trained models. In the embodiment of the present application, the present invention first constructs a collaborative training framework for large language models based on federated learning and split learning. Under this framework, each participant does not need to exchange raw data. Through the federated learning mechanism, the model parameters can be trained locally, and the encrypted model updates can be uploaded to the central server, ensuring data privacy and compliance. Considering the large number of parameter exchange processes in federated learning, a method of in-network aggregation based on a data processing unit (DPU) is designed. The DPU is deployed in the switch to aggregate parameters while transmitting data, reducing network load and increasing overall throughput. At the same time, using the split learning strategy, the large language model is divided into smaller sub-models, which are trained in parallel by being deployed on different nodes, and then the model updates are integrated through an encryption protocol, not only significantly improving the training speed, but also reducing the computational burden of a single participant. Secondly, the present invention designs a fine-tuning method for large language models based on knowledge distillation. In the training of large language models, knowledge distillation can help transfer the knowledge of large models to small models in this application, thereby realizing the lightweight and high efficiency of the models and reducing the pressure on the network transmission environment brought by federated learning. Description of the Drawings
[0041] In order to more clearly illustrate the technical solutions in the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0042] Figure 1 Schematic diagram of the model training method based on edge - end collaboration according to an embodiment of the present application;
[0043] Figure 2 Overall architecture schematic diagram of the model training method based on edge - end collaboration according to an embodiment of the present application;
[0044] Figure 3 Schematic diagram of the split - model evaluation data according to an embodiment of the present application;
[0045] Figure 4 Schematic diagram of the model splitting according to an embodiment of the present application;
[0046] Figure 5 Schematic diagram of the knowledge distillation steps according to an embodiment of the present application;
[0047] Figure 6 Schematic diagram of visualizing the training results of the knowledge distillation of the split model according to an embodiment of the present application;
[0048] Figure 7 Schematic diagram of the structure of the model training device based on edge - end collaboration according to an embodiment of the present application;
[0049] Figure 8 Schematic diagram of the structure of the electronic device according to an embodiment of the present application. Detailed implementation manners
[0050] To make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to specific embodiments and the accompanying drawings.
[0051] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should have the ordinary meanings understood by those of ordinary skill in the technical field to which the present application belongs. The terms "first", "second" and similar words used in the embodiments of the present application do not denote any order, quantity or importance, but are only used to distinguish different components. Words such as "including" or "comprising" mean that the elements or objects appearing before this word cover the elements or objects listed after this word and their equivalents, without excluding other elements or objects. Words such as "connected" or "coupled" are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Terms such as "upper", "lower", "left" and "right" are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.
[0052] It is understandable that before using the technical solutions of the various embodiments of the present disclosure, the types, usage scopes, usage scenarios, etc. of the personal information involved will be informed to the user in an appropriate manner, and the user's authorization will be obtained.
[0053] For example, when responding to receiving an active request from the user, a prompt message is sent to the user to clearly prompt the user that the operation requested by them will require obtaining and using the user's personal information. Thus, the user can autonomously choose whether to provide personal information to software or hardware such as an electronic device, application program, server, or storage medium that performs the operations of the technical solutions of the present disclosure based on the prompt message.
[0054] As an optional but non-limiting implementation manner, the manner of sending a prompt message to the user in response to receiving an active request from the user can be, for example, in the form of a pop-up window. The prompt message can be presented in text in the pop-up window. In addition, the pop-up window can also carry selection controls for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0055] It is understandable that the above process of notifying and obtaining the user's authorization is only illustrative and does not limit the implementation manner of the present disclosure. Other manners that comply with relevant laws and regulations can also be applied to the implementation manner of the present disclosure.
[0056] As described in the background art section, with the continuous development and wide application of large language model technology, the number of model parameters corresponding to it has increased rapidly like an exponential function curve. While the technology iteration speed in the large language model field is extremely fast and the model complexity is continuously increasing, in the face of the growing demand for user data privacy protection and the problem of data silos, large language models face huge challenges in obtaining large-scale high-quality training data. Traditional large language model training is to upload data to the cloud, and after the model and data are trained in the cloud, they are downloaded. It relies on the computing power and a large amount of storage space provided by the cloud.
[0057] In view of the above considerations, an embodiment of the present application proposes a model training method based on edge-cloud collaboration. According to the obtained mobile device resource parameters, the model to be trained is split to obtain a first model and a second model; based on the local data of the mobile device, the mobile device is used to perform knowledge distillation on the second model to obtain a distilled model; the mobile device is used to send the first parameters of the distilled model to a data processor to obtain second parameters, and the data processor is used to upload the second parameters to a server; the server is used to calculate fourth parameters based on the second parameters and the third parameters of the model to be trained; based on the fourth parameters, the server is used to update the first model to obtain a third model and the fifth parameters of the third model; based on the fifth parameters, the mobile device is used to train the distilled model to obtain the sixth parameters of a fourth model; in response to reaching the condition for stopping training, the third model and the fourth model are used as the trained models. In the embodiment of the present application, the present invention first constructs a collaborative training framework for large language models based on federated learning and split learning. Under this framework, each participant does not need to exchange raw data. Through the federated learning mechanism, the model parameters can be trained locally, and the encrypted model updates can be uploaded to the central server, ensuring data privacy and compliance. Considering the large number of parameter exchange processes in federated learning, a method for in-network aggregation based on a data processor (DPU) is designed. The DPU is deployed in a switch to aggregate parameters while transmitting data, reducing network load and increasing overall throughput. At the same time, using the split learning strategy, the large language model is divided into smaller sub-models, which are trained in parallel by being deployed on different nodes, and then the model updates are integrated through an encryption protocol, not only significantly improving the training speed but also reducing the computational burden of a single participant. Secondly, the present invention designs a method for fine-tuning large language models based on knowledge distillation. In the training of large language models, knowledge distillation can help transfer the knowledge of large models to small models in this application, thereby achieving model lightweight and efficiency, and reducing the pressure on the network transmission environment brought by federated learning.
[0058] Hereinafter, the technical solutions of the embodiments of the present application will be described in detail through specific embodiments.
[0059] Referring to Figure 1 , the model training method based on edge-cloud collaboration according to the embodiment of the present application includes the following steps:
[0060] Step S101: According to the obtained mobile device resource parameters, split the model to be trained to obtain a first model and a second model;
[0061] Step S102: Based on the local data of the mobile device, use the mobile device to perform knowledge distillation on the second model to obtain a distilled model;
[0062] Step S103: Use the mobile device to send the first parameter of the distillation model to the data processor to obtain a second parameter, and use the data processor to upload the second parameter to the server.
[0063] Step S104: Use the server to calculate a fourth parameter based on the second parameter and the third parameter of the model to be trained.
[0064] Step S105: Based on the fourth parameter, use the server to update the first model to obtain a third model and the fifth parameter of the third model.
[0065] Step S106: Based on the fifth parameter, use the mobile device to train the distillation model to obtain the sixth parameter of the fourth model.
[0066] Step S107: In response to reaching the condition for stopping training, use the third model and the fourth model as the trained models.
[0067] This application considers combining the technical characteristics of federated learning and split learning in the training process of large language models. For large language models in edge environments with limited computing hardware resources and network transmission resources, a more flexible and secure large language model training system can be designed.
[0068] Reference Figure 2 , which is the overall architecture schematic diagram of the model training method based on edge collaboration in the embodiments of this application.
[0069] As Figure 2 shown, in the overall architecture schematic diagram, in the embodiments of this application, for a specific large language model, taking the Bert model as an example, the training steps are roughly divided into the following six steps.
[0070] Step 1: Considering the mobile device resources, computing latency, and model accuracy, determine the cutting layer of the large language model, split the large language model into two sub-models, respectively called the server-side model and the device-side model, and all participating devices download the latest device-side model from the server.
[0071] Step 2: Each participating device uses local data to perform knowledge distillation on the device-side model to obtain the device-side model parameters and related calculation gradients. First, use the knowledge distillation technology on the device side to optimize the small model to make it mimic the behavior of the teacher model as much as possible. Theoretically, if all device sides use knowledge distillation and the distillation effect is good, the model aggregation result should be able to reflect some knowledge of the teacher model. However, due to the inevitable information loss during the distillation process, the performance of the final aggregated model will be slightly lower than the effect of directly training the complete model on the device side.
[0072] Step 3: After each device independently completes the training and distillation of the device-side model, it sends its updated model parameters Δw i (the first parameter) to the server.
[0073] Step 4: Deploy the DPU in the switch, and aggregate the parameters of each device in the switch, that is:
[0074]
[0075] where is the second parameter, i represents the i-th switch, and w j is the model parameter of the j-th device passing through this switch.
[0076] Step 5: The server-side completes the aggregation of model parameters according to the gradient. The server receives all the device-side parameters from the switches and aggregates these updates using the method of simple average:
[0077]
[0078] where, w new represents the fourth parameter, w global represents the third parameter, represents the second parameter, i represents the i-th switch, η represents the learning rate of the model to be trained, and N represents the number of mobile devices participating in this round of training.
[0079] Step 6: The updated global model parameter w new , as the input for the server-side model training, completes the training of the server-side model at the server-side and transmits the new model parameters to the device-side model for update. The update strategy is as follows:
[0080]
[0081] where, r″ represents the sixth parameter of the fourth model, a represents the update ratio, r represents the seventh parameter obtained by the server training the model to be trained, and r′ represents the first parameter.
[0082] Repeat the above steps 2 - 6 until the model result converges.
[0083] Next, each step will be described in detail. For the above step S101, according to the obtained mobile device resource parameters, the model to be trained is split to obtain the first model and the second model.
[0084] In some embodiments, the mobile device resource parameters include hardware resource parameters, latency sensitivity, load balancing, and model structure; splitting the model to be trained according to the obtained mobile device resource parameters to obtain a first model and a second model includes: splitting the model to be trained based on the hardware resource parameters, latency sensitivity, load balancing, and model structure to obtain the first model and the second model.
[0085] In this embodiment, the first model is a server-side model and the second model is a device-side model. For the model splitting part, taking the large language model: Bidirectional Encoder Representations from Transformers (BERT) as an example, the splitting process of its large model based on the Transformer structure can perform vertical splitting of the model in combination with the split learning algorithm. Taking the BERT model as an example, for the BERT-Base model, under standard hardware configurations and optimization conditions, with a relatively small batch size (16) and medium-length sentences (128 tokens), a single forward pass takes approximately 2 seconds. A model unidirectional propagation experiment was conducted.
[0086] Reference Figure 3 , is a schematic diagram of the model splitting evaluation data for the embodiments of the present application.
[0087] Reference Figure 4 , is a schematic diagram of the model splitting for the embodiments of the present application.
[0088] From Figure 3 it can be seen that the expected training latency for each cut layer is basically not much different. Since there is no difference in each encoder module of Bert, an enumeration strategy is adopted to perform vertical splitting on the BERT model. As Figure 4 shown, enumerate the specific layers split in the BERT model.
[0089] In addition, when dividing the model into a device-side model and a server-side model, the following key factors usually need to be considered:
[0090] Hardware resource allocation: The computing power, memory size, and bandwidth limitations of the device side (such as mobile phones, embedded devices). The high-performance computing resources on the server side can handle more complex calculations and larger model capacities.
[0091] Latency sensitivity: The device-side model should minimize latency as much as possible to achieve real-time or low-latency responses, which requires a part of the model to be lightweight enough. Although the server-side model does not need to consider real-time performance too much, the overall communication and computing latency still needs to be within an acceptable range.
[0092] Computational load balancing: Considering the computational intensity, the parts with higher computational complexity are placed on the server side, and simple pre-processing or preliminary feature extraction are placed on the device side.
[0093] Model structure characteristics: The choice of cutting layer should minimize the impact on model performance. Usually, the cutting layer is chosen at an intermediate layer with a higher level of abstraction. This ensures that the front-end device can efficiently extract basic features while allowing the server to focus on understanding and making decisions on high-level features.
[0094] Communication cost: When designing model splits, the communication overhead between the device and the server needs to be considered. Smaller intermediate activation vectors can reduce data transmission time.
[0095] Security and privacy protection: When considering model splitting, user privacy must also be taken into account. It is necessary to ensure that sensitive information is processed on the device side and avoid uploading it to the server.
[0096] Model effectiveness: The selection of cutting layers should be based on the principle of minimizing the performance loss of the model. Experiments can be used to verify the impact of different cutting strategies on model accuracy.
[0097] Therefore, when determining a large language splitting strategy, it is necessary to balance multiple factors, such as large language model performance, hardware resources, communication efficiency, and privacy protection, to find the optimal model structure split point so that the entire system can operate effectively within a distributed architecture. The selection of each parameter is unique and not easily apparent to those skilled in the art.
[0098] With respect to step S102 , knowledge distillation is performed on the second model using the mobile device based on local data of the mobile device to obtain a distilled model.
[0099] In some embodiments, the method of performing knowledge distillation on the second model based on the local data of the mobile device to obtain the distilled model includes: training the second model using a server to obtain a fifth model; and performing knowledge distillation on the second model using the mobile device based on the learning loss of the soft label distribution of the local data and the fifth model to obtain the distilled model.
[0100] refer to Figure 5 , which is a schematic diagram of the knowledge distillation steps of an embodiment of the present application.
[0101] In this embodiment, if Figure 5The device-side model optimization strategy based on knowledge distillation shown is mainly a model compression and transfer learning technique that allows knowledge to be extracted from a large and complex teacher model (usually an over-parameterized model) and effectively transferred to a small student model, enabling the student model to reduce computational resource consumption and improve inference speed while maintaining high performance.
[0102] First, it is necessary to obtain the pre-trained device-side model (the fifth model) from the server side and use it as the teacher model.
[0103] After that, the teacher model is used to generate soft labels. In this embodiment, the teacher model can not only output hard class labels but also the probability distribution of each class (i.e., the aforementioned "soft labels").
[0104] In the embodiment, the distilled model is trained by calculating the loss function and using the gradient descent method. The expression of the knowledge distillation loss function is as follows. The first part of the loss function refers to the cross-loss between the output of the softmax of the student model under the same temperature T and the soft labels, that is:
[0105]
[0106] where z i represents the logical value output by the student model, T represents the hyperparameter - temperature in the knowledge distillation process, which can control the smoothness of the probability distribution of the soft labels and thus affect the learning process of the student model. K represents the total number of labels. Similarly, the second part of the loss function is the cross-loss between the output of the softmax at T = 1 and the cross-loss between the predicted value and the true value, that is:
[0107]
[0108] The student model (the second model) in knowledge distillation is trained on the same task, but its loss function not only includes the conventional cross-entropy loss but also adds the learning loss of the soft label distribution provided by the teacher model. The student model attempts to imitate the decision-making behavior of the teacher model in the entire sample space, thereby absorbing the knowledge of the teacher model. It should be noted that in the overall embodiment, the second model is the device-side model, but in the process of knowledge distillation, the second model is the student model, and there is no conflict between the two.
[0109] In addition to knowledge transfer at the output level, knowledge distillation can also be achieved through the similarity of feature maps between layers, that is, making the intermediate layer features of the student model as close as possible to the corresponding layer features of the teacher model.
[0110] According to the characteristics of the student model, the model structure can be further optimized, such as pruning, quantization, etc., to reduce the complexity of the model while ensuring the distillation effect.
[0111] Above, the device-side model optimization strategy based on knowledge distillation can not only be used for model miniaturization, but also to accelerate the training and inference processes, which is of great significance for natural language processing deployed in resource-constrained environments. At the same time, this strategy is also applicable to cross-domain transfer learning and incremental learning scenarios, helping to improve the generalization ability and adaptability of the model in new environments. Performing knowledge distillation only on the device-side model will not directly affect the model aggregation process, but will have a positive impact on the following aspects:
[0112] The performance of the distilled device-side model is expected to be close to or reach the level of the teacher model. In this way, even during the network aggregation process, the prediction quality of a single node can be improved, and the overall aggregation result accuracy will also benefit from this.
[0113] Generally speaking, a smaller model means lower memory occupancy and faster inference speed, which may reduce the communication cost of transmitting data or model parameters between devices. Especially in federated learning or collaborative training, the compactness of the device-side model helps to optimize the efficiency of the entire system.
[0114] For resource-constrained edge devices, the distilled small model is more suitable for deployment, reducing energy consumption and adapting to more hardware conditions, which enables the effective participation of more devices in a large-scale distributed environment.
[0115] For step S103, use the mobile device to send the first parameter of the distilled model to the data processor to obtain a second parameter, and use the data processor to upload the second parameter to the server.
[0116] In some embodiments, the use of the mobile device to send the first parameter of the distilled model to the data processor to obtain a second parameter, and the use of the data processor to upload the second parameter to the server includes: using the mobile device to send the first parameter of the distilled model to the data processor; using the data processor to perform aggregation processing on the first parameter to obtain the second parameter; using the data processor to upload the second parameter to the server.
[0117] In this embodiment, as described in the aforementioned steps 3 and 4:
[0118] After each device-side independently completes the training and distillation of the device-side model, the updated model parameter Δw i (the first parameter) is sent to the server.
[0119] Deploy a DPU in the switch to aggregate the parameters of each device in the switch, that is:
[0120]
[0121] where is the second parameter, i represents the i-th switch, and w j is the model parameter of the j-th device end passing through the switch.
[0122] Furthermore, for step S104, using the server, based on the second parameter and the third parameter of the model to be trained, a fourth parameter is calculated.
[0123] In some embodiments, calculating the fourth parameter based on the second parameter and the third parameter of the model to be trained includes:
[0124]
[0125] where w new represents the fourth parameter, w global represents the third parameter, represents the second parameter, i represents the i-th switch, η represents the learning rate of the model to be trained, and N represents the number of mobile devices participating in this round of training.
[0126] In this embodiment, the server side completes model parameter aggregation according to the gradient. The server receives all the device end parameters from the switches and uses the method of simple averaging to aggregate these updates.
[0127] For step S105, based on the fourth parameter, the server is used to update the first model to obtain the third model and the fifth parameter of the third model.
[0128] In some embodiments, updating the first model using the server based on the fourth parameter to obtain the third model and the fifth parameter of the third model includes: using the fourth parameter as the parameter of the first model, and using the server to update the first model to obtain the third model and the fifth parameter of the third model.
[0129] In this embodiment, the updated global model parameter w new , as the input for server model training, completes the training of the server side model at the server side and obtains new model parameters (the fifth parameter).
[0130] Furthermore, for step S106, based on the fifth parameter, the mobile device is used to train the distillation model to obtain the sixth parameter of the fourth model.
[0131] In some embodiments, the sixth parameter is calculated by the following formula:
[0132]
[0133] Among them, r″ represents the sixth parameter of the fourth model, a represents the update ratio, r represents the seventh parameter obtained by the server through training the model to be trained, and r′ represents the first parameter.
[0134] In this embodiment, after the server-side model completes centralized training, the model update parameters for the device side can be obtained, and the model parameters are updated on the device side. The update strategy is as follows: In the scenarios of federated learning or distributed learning, the update strategy of model parameters is one of the cores because it determines how to effectively utilize the collaboration between the central server and edge devices (or clients) to optimize the model. The following is a detailed elaboration of this strategy:
[0135] Parameter initialization: First, complete one or several rounds of centralized training on the server side to obtain the global model parameters r. These parameters usually represent the generalization ability on the entire dataset.
[0136] Device-side personalized training: Then, send the global model parameters r to each edge device. Each device uses its own private data to train the model and obtains the model parameters r′ that adapt to the characteristics of local data. This process can be regarded as fine-tuning on the device side, aiming to make the model more conform to the distribution of device-side data.
[0137] Parameter fusion: The key step of the update strategy lies in how to combine the global knowledge on the server side with the personalized knowledge on the device side. The sixth parameter r″ is obtained by linear interpolation from the global parameter r and the device-side parameter r′, specifically as follows:
[0138]
[0139] Among them, r″ represents the sixth parameter of the fourth model, a represents the update ratio, r represents the seventh parameter obtained by the server through training the model to be trained, and r′ represents the first parameter.
[0140] The a (update ratio) among them determines the degree of fusion between the server-side model parameter r and the device-side model parameter r′. When a = 0.5, it means giving equal importance to both, neither completely leaning towards the universality of the global model nor overemphasizing the particularity of device-side data, achieving a balanced integration of the two. By adjusting the value of a, the influence of the global model on the personalized model can be flexibly controlled to adapt to different scenario requirements.
[0141] Feedback loop: The updated parameter r or its gradient on the device side can be uploaded to the server. The server re-aggregates and calculates new global model parameters based on the update results of all participating devices, and so on in a loop until the model converges or meets the stop condition.
[0142] The update strategy enables the strategy to incorporate the personalized requirements of the device side while maintaining the generalization ability of the model. Especially in the case of large differences in data distribution, it can effectively improve the performance of the model on edge devices. The introduction of the update ratio a provides flexibility in adjusting the model update direction, which can be adjusted according to the requirements of the actual application scenario to achieve a continuous adjustment from completely relying on the server-side model to emphasizing device-side personalization. Using the computing resources of the device side for personalized training reduces the computing burden on the server, which is particularly suitable for environments with limited resources or sensitive data privacy.
[0143] In summary, this update strategy that combines server-side model parameters with device-side model parameters provides an efficient and flexible model optimization path for the distributed learning system by cleverly balancing global knowledge and personalized requirements, which helps to improve the application effect of the model in diverse and personalized scenarios.
[0144] Finally, for step S107, in response to reaching the condition for stopping training, the third model and the fourth model are used as the trained models.
[0145] After the model results converge, training can be stopped, and the third model and the fourth model obtained in the current round of training are used as the final models. Here, the final model can be a model formed by splicing the third model and the fourth model based on the initially segmented number of layers.
[0146] As can be seen from the above embodiments, in the model training method based on edge-cloud collaboration according to the embodiments of the present application, the model to be trained is split into a first model and a second model according to the obtained mobile device resource parameters; based on the local data of the mobile device, the mobile device is used to perform knowledge distillation on the second model to obtain a distilled model; the mobile device is used to send the first parameters of the distilled model to the data processor to obtain second parameters, and the data processor is used to upload the second parameters to the server; the server is used to calculate fourth parameters based on the second parameters and the third parameters of the model to be trained; based on the fourth parameters, the server is used to update the first model to obtain a third model and the fifth parameters of the third model; based on the fifth parameters, the mobile device is used to train the distilled model to obtain the sixth parameters of the fourth model; in response to reaching the condition for stopping training, the third model and the fourth model are used as the trained models. In the embodiments of the present application, the present invention first constructs a collaborative training framework for large language models based on federated learning and split learning. Under this framework, each participant does not need to exchange raw data. Through the federated learning mechanism, the model parameters can be trained locally and the encrypted model updates can be uploaded to the central server, ensuring data privacy and compliance. Considering the large number of parameter exchange processes in federated learning, a method for in-network aggregation based on a data processor (DPU) is designed. The DPU is deployed in the switch to aggregate parameters while transmitting data, reducing network load and increasing overall throughput. At the same time, using the split learning strategy, the large language model is divided into smaller sub-models, which are trained in parallel by being deployed on different nodes, and then the model updates are integrated through an encryption protocol, not only significantly improving the training speed but also reducing the computational burden of a single participant. Secondly, the present invention designs a method for fine-tuning large language models based on knowledge distillation. In the training of large language models, knowledge distillation can help transfer the knowledge of large models to small models in this application, thereby achieving model lightweight and high efficiency, and reducing the pressure on the network transmission environment brought by federated learning.
[0147] In some other embodiments, in order to verify the effectiveness of the present invention, the following experiments were conducted
[0148] First, the model experiment of the control group was completed: the BERT-base model was trained on the training task in the local hardware environment, and the model training time and the accuracy of the model in completing the task were recorded. Record the experimental results of independent BERT training on the local device:
[0149] Table 1 Model training results without splitting
[0150]
[0151] As can be seen from the above experiments, as the batch size increases, the training time for a single iteration generally shows a downward trend. This is because when the batch size increases, the model can process more samples in one forward and backward pass, making more efficient use of the hardware resources and thus shortening the training time. According to the experimental data, when training the BERT model for sentiment binary classification tasks, appropriately increasing the batch size can effectively reduce the training time and, to a certain extent, improve the accuracy and F1 score of the model. However, when the batch size is too large, the improvement in accuracy and F1 score is not significant, and there may even be a slight decrease. In actual training, a moderate batch size needs to be selected to achieve a better balance between performance and efficiency.
[0152] Based on the control group experiment, an experiment on knowledge distillation training of the split model was carried out. Knowledge distillation was performed on local devices, and the experimental data during the process of migrating the large model to the small model are shown in the following table:
[0153] Table 2 Results of Knowledge Distillation Training of Split Model
[0154]
[0155] Reference Figure 6 , which is a visualization schematic diagram of the results of knowledge distillation training of the split model in the embodiments of this application.
[0156] From Figure 6 it can be seen that: as the batch size increases from 1 to 10, the number of samples used in each training iteration gradually increases. As the batch size increases from 1 to around 7, the accuracy (ac) of the model shows an upward trend, rising from 0.50450 to 0.86887, indicating that increasing the batch size within a certain range helps the student model to learn and converge better. However, when the batch size continues to increase to 8, 9, and 10, the accuracy does not continue to improve, and even shows a slight decrease when the batch size is 10. This may be because the too large batch size leads to a change in the training dynamics of the model and is no longer conducive to model optimization. On the other hand, as the batch size increases, the time required for a single iteration also gradually increases. This is because a larger batch requires more memory resources and may lead to a decrease in hardware utilization, so the overall training time may increase.
[0157] In the federated aggregation simulation experiment, due to limited device computing resources, only three client devices were simulated, with 1000 pieces of configured data for each client device and one server device.
[0158] Table 3 Record of Average Time Used by Federated Learning Clients
[0159]
[0160] Regarding congestion control, although its dynamics increase the complexity of simulation, a behavior model is set based on the standard TCP congestion control algorithm. At the initial stage of simulation, it can be simplified by assuming a basic rule for the growth and reduction of the congestion window. Then, as the simulation progresses, the model can be gradually refined. The calculation of the actual transmission time is more complex than the basic formula because it needs to consider more network factors, such as latency, packet loss rate, and the impact of congestion control mechanisms (such as TCP's slow start and congestion avoidance algorithms). A more comprehensive but simplified model can consider the combined effects of these factors. Although accurate prediction remains challenging because network behavior can be highly dynamic and unpredictable. Considering bandwidth, the number of data packets, the packet loss retransmission factor, and the expected number of retransmitted packets, relevant settings are made for the expected network environment at the edge side:
[0161] RTT (Round - Trip Time): In the actual network, the RTT can vary from dozens of milliseconds to hundreds of milliseconds, or even higher. For local network simulation, set the RTT to 1 - 10 ms.
[0162] The number of data packets: The number of data packets depends on the amount of data you want to transmit and the maximum segment size (MSS) of TCP. If there is 1 MB of data to be transmitted and the MSS is 1460 bytes (excluding the IP and TCP headers), then approximately 700 data packets are required (considering TCP headers and possible fragmentation).
[0163] Packet loss retransmission factor: This factor is usually estimated based on historical data or network conditions. In a stable network, the packet loss rate may be very low. In the simulation, an initial packet loss rate of 0.5% can be set.
[0164] Expected number of retransmitted data packets: This number can be estimated by multiplying the packet loss rate by the total number of data packets. For example, if the total number of data packets is 700 and the packet loss rate is 0.5%, then the expected number of retransmitted data packets is approximately 3.5.
[0165] Transmission time = Model size × 8 / Bandwidth + (RTT × Number of data packets) + (Packet loss retransmission factor × Expected number of retransmitted data packets)
[0166] Based on the completion of the simulation experiments for each part, the data results obtained from the experiments are further analyzed from the following three aspects:
[0167] Table 4 Result Analysis Table
[0168]
[0169] (1) Classification accuracy analysis:
[0170] As can be seen from the tabular data, the prediction accuracy of the BERT-base model is 0.926926927, while that of the S-Bert model is 0.86887. This shows that BERT-base performs significantly better than the S-Bert model in terms of accuracy. This means that in scenarios where high-precision prediction is required, BERT-base is a better choice. However, if the application scenario is more sensitive to speed or resource consumption, a trade-off between accuracy and efficiency may be needed.
[0171] (2) Latency analysis (computation latency and communication latency):
[0172] Computation latency: From the perspective of the single-batch training time, the training time of the BERT-base model is 185.603456 seconds, while the S-Bert model only requires 59.75997615 seconds, indicating that the S-Bert model has a significant advantage in training speed, and the training efficiency is about 3 times more than that of BERT-base. This shows that S-Bert significantly reduces the computational complexity through certain optimization means (such as model pruning, quantization, etc.), thus accelerating the training process.
[0173] Communication latency: Although the table does not directly provide the communication latency data, the change in model size has a direct impact on communication latency. The transmission size of the S-Bert model is only 8,427KB, which is much smaller than 399,587KB of BERT-base. In the scenarios of distributed training or cloud deployment, a smaller model means faster model loading and updating time, thus reducing communication latency and improving the overall system response speed. In terms of network transmission time, the BERT-base model requires 3896.716 milliseconds, while the S-Bert model is 1374.18 milliseconds. This means that S-Bert can complete network transmission faster during model deployment or update, reducing the waiting time caused by model exchange, which is especially important for scenarios with frequent distributed training or model updates.
[0174] (3) Device load analysis: Model size change
[0175] A significant reduction in model size (from 399,587KB of BERT-base to 8,427KB of S-Bert) has an important impact on device load. A smaller model size means lower memory occupancy. The S-Bert model occupies 3442MiB of memory during training, which is approximately 1700MiB less than 5144MiB of BERT-base, reducing the demand for hardware resources. This is particularly important for devices with limited resources (such as mobile devices and edge computing nodes) as it allows complex models to be deployed on these platforms without causing resource overload or slow operation. Therefore, S-Bert shows obvious advantages in reducing the device memory burden and expanding the scope of applicable devices.
[0176] In summary, the S-Bert model significantly improves the training speed and reduces resource requirements at the expense of a certain degree of accuracy, making it an optimal solution for scenarios sensitive to efficiency and resources. BERT-base, on the other hand, is more suitable for environments with strict requirements for prediction accuracy and relatively abundant resources. The choice of which model should be based on the comprehensive consideration of the accuracy, speed, and resource requirements of the specific application scenario.
[0177] It should be noted that the method of the embodiment of the present application can be executed by a single device, such as a computer or a server, etc. The method of this embodiment can also be applied to a distributed scenario, and completed by multiple devices cooperating with each other. In this case of a distributed scenario, one of the multiple devices can only execute one or more steps of the method of the embodiment of the present application, and these multiple devices will interact with each other to complete the described method.
[0178] It should be noted that some embodiments of the present application have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the above embodiments and still achieve the desired results. Additionally, the processes depicted in the figures do not necessarily require the particular order or sequential order shown to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0179] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application also provides a model training device based on edge-side collaboration.
[0180] Refer to Figure 7 , the model training device based on edge-side collaboration includes:
[0181] A splitting module 71, configured to split the model to be trained according to the obtained mobile device resource parameters, to obtain a first model and a second model;
[0182] A mobile device 72, configured to perform knowledge distillation on the second model based on local data of the mobile device to obtain a distilled model;
[0183] A mobile device 72, configured to send first parameters of the distilled model to a data processor to obtain second parameters, and use the data processor to upload the second parameters to a server;
[0184] A server 73, configured to calculate fourth parameters based on the second parameters and third parameters of the model to be trained;
[0185] A server 73, configured to update the first model based on the fourth parameters to obtain a third model and fifth parameters of the third model;
[0186] A mobile device 72, configured to train the distilled model based on the fifth parameters to obtain sixth parameters of a fourth model;
[0187] A stop module 74, configured to use the third model and the fourth model as trained models in response to reaching a condition for stopping training.
[0188] For the convenience of description, when describing the above device, various modules are described separately according to their functions. Of course, when implementing the present application, the functions of each module can be implemented in one or more software and / or hardware.
[0189] The device in the above embodiment is used to implement the corresponding edge-side collaborative model training method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated herein.
[0190] Based on the same inventive concept, corresponding to the method in any of the above embodiments, the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where when the processor executes the program, it implements the edge-side collaborative model training method described in any of the above embodiments.
[0191] Figure 8 FIG. shows a more specific schematic hardware structure diagram of the electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. Among them, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other inside the device through the bus 1050.
[0192] The processor 1010 may be implemented in the form of a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0193] The memory 1020 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0194] The input / output interface 1030 is used to connect to the input / output module to implement information input and output. The input / output module may be configured as a component in the device (not shown in the figure) or may be externally connected to the device to provide corresponding functions. Among them, the input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0195] The communication interface 1040 is used to connect to a communication module (not shown in the figure) to implement communication interaction between this device and other devices. Among them, the communication module may implement communication through a wired method (such as USB, network cable, etc.) or may implement communication through a wireless method (such as a mobile network, WIFI, Bluetooth, etc.).
[0196] The bus 1050 includes a path for transmitting information between various components of the device (such as the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0197] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in the specific implementation process, this device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solution of the embodiments of this specification and does not necessarily include all the components shown in the figure.
[0198] The electronic device of the above embodiment is used to implement the corresponding edge-terminal collaborative model training method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated herein.
[0199] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the edge-terminal collaborative model training method as described in any of the foregoing embodiments.
[0200] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette tapes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible by a computing device.
[0201] The computer instructions stored in the storage medium of the above embodiment are used to cause the computer to execute the edge-terminal collaborative model training method as described in any of the foregoing embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be elaborated herein.
[0202] Those of ordinary skill in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the present application (including the claims) is limited to these examples; within the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of brevity.
[0203] In addition, for simplicity of explanation and discussion, and in order not to make the embodiments of the present application difficult to understand, well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Further, the devices may be shown in block diagram form in order to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that details regarding the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application are to be implemented (i.e., these details should be fully within the understanding of those skilled in the art). In cases where specific details (such as circuits) are set forth to describe exemplary embodiments of the present application, it will be apparent to those skilled in the art that the embodiments of the present application may be practiced without these specific details or with variations of these specific details. Accordingly, these descriptions should be considered illustrative rather than restrictive.
[0204] Although the present application has been described in connection with specific embodiments thereof, many alternatives, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art in light of the foregoing description. For example, other memory architectures (such as dynamic RAM (DRAM)) may be used with the embodiments discussed.
[0205] Embodiments of the present application are intended to cover all such alternatives, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the embodiments of the present application shall be included within the protection scope of the present application.
Claims
1. A model training method based on edge-cloud collaboration, characterized in that Including: According to the obtained mobile device resource parameters, splitting the model to be trained to obtain a first model and a second model; Based on the local data of the mobile device, using the mobile device to perform knowledge distillation on the second model to obtain a distilled model; Using the mobile device to send the first parameters of the distilled model to a data processor to obtain second parameters, and using the data processor to upload the second parameters to a server, including: using the mobile device to send the first parameters of the distilled model to the data processor; using the data processor to perform aggregation processing on the first parameters to obtain the second parameters; using the data processor to upload the second parameters to the server; Using the server to calculate fourth parameters based on the second parameters and the third parameters of the model to be trained; Based on the fourth parameters, using the server to update the first model to obtain a third model and the fifth parameters of the third model; Based on the first parameters, calculating the sixth parameters of a fourth model; In response to reaching the condition for stopping training, using the third model and the fourth model as the trained models; The calculating the fourth parameters based on the second parameters and the third parameters of the model to be trained includes: Among them, w new represents the fourth parameter, w global represents the third parameter, represents the second parameter, i represents the i-th switch, η represents the learning rate of the model to be trained, and N represents the number of mobile devices participating in this round of training.
2. The method according to claim 1, wherein The mobile device resource parameters include hardware resource parameters, latency sensitivity, load balancing, model structure, communication cost, security, and model effectiveness; The splitting the model to be trained according to the obtained mobile device resource parameters to obtain a first model and a second model includes: Based on the hardware resource parameters, latency sensitivity, load balancing, model structure, communication cost, security, and model effectiveness, splitting the model to be trained to obtain the first model and the second model.
3. The method according to claim 1, wherein The performing knowledge distillation on the second model using the mobile device based on the local data of the mobile device to obtain a distilled model includes: Using the server to train the second model to obtain a fifth model; Based on the learning loss of the soft label distribution of the local data and the fifth model, using the mobile device to perform knowledge distillation on the second model to obtain the distilled model.
4. The method according to claim 1, wherein The updating the first model using the server based on the fourth parameters to obtain a third model and the fifth parameters of the third model includes: Using the fourth parameters as the parameters of the first model, and using the server to update the first model to obtain a third model and the fifth parameters of the third model.
5. The method according to claim 1, wherein The sixth parameters are calculated by the following formula: where r″ represents the sixth parameters of the fourth model, a represents the update ratio, r represents the seventh parameters obtained by the server training the model to be trained, r′ represents the first parameters, and the update ratio determines the fusion degree of the seventh parameters and the first parameters.
6. A model training device based on edge-cloud collaboration, characterized in that, Including: A splitting module configured to split the model to be trained according to the obtained mobile device resource parameters to obtain a first model and a second model; A mobile device configured to perform knowledge distillation on the second model based on the local data of the mobile device to obtain a distilled model; A mobile device, configured to send a first parameter of the distillation model to a data processor to obtain a second parameter, and use the data processor to upload the second parameter to a server, including: using the mobile device to send the first parameter of the distillation model to the data processor; using the data processor to perform an aggregation process on the first parameter to obtain the second parameter; using the data processor to upload the second parameter to the server; A server, configured to calculate a fourth parameter based on the second parameter and a third parameter of the model to be trained; A server, configured to update the first model based on the fourth parameter to obtain a third model and a fifth parameter of the third model; A mobile device, configured to calculate a sixth parameter of a fourth model based on the first parameter; A stop module, configured to, in response to reaching a condition for stopping training, use the third model and the fourth model as trained models; The calculating the fourth parameter based on the second parameter and the third parameter of the model to be trained includes: Among them, w new represents the fourth parameter, w global represents the third parameter, represents the second parameter, i represents the i-th switch, η represents the learning rate of the model to be trained, and N represents the number of mobile devices participating in this round of training.
7. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, the method described in any one of claims 1 to 5 is implemented.
8. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause a computer to execute the method described in any one of claims 1 to 5.
Citation Information
Patent Citations
Big model training method based on federal knowledge distillation
CN117236421A