Interactive continuous learning lightweight model training and reasoning method
By conducting model training and updates on the edge equipment, and the lightweight model reasoning on the terminal equipment, the problem of high bandwidth consumption, high transmission delay, and lagging model update in existing technologies have been solved. Model reasoning and update.
Patent Information
- Application Number
- CN202411949375.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-27
- Publication Date
- 2025-01-28
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In the prior art, there are problems such as high bandwidth consumption, high transmission delay, data privacy leakage, as well as model update lag and low update frequency.
By completing model training and updates on the edge equipment, the lightweight model is transmitted to the terminal device to reason, reducing dependence on the cloud, adopting interactive continuous learning strategies and lightweight strategies (such as knowledge distillation and model branches) to optimize the model Essence
It reduces network bandwidth consumption and transmission delay, enhances data privacy protection, realizes the timely update and adapting to the dynamic environment of the model, and enhances the real -time and self -learning ability of the system.
Smart Images

Figure CN119378648A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to an interactive continuous learning lightweight model training and reasoning method. Background Art
[0002] With the rapid development of artificial intelligence technology, the application scenarios of models are becoming increasingly extensive, and research on model training and reasoning methods is crucial.
[0003] Currently, existing model training and inference methods include:
[0004] The first is the cloud-based training and cloud-based reasoning model. In this model, both model training and reasoning are performed in the cloud, and the edge device is only responsible for data collection and transmitting the collected data to the cloud. The cloud uses powerful computing resources to train the model and perform real-time reasoning. This method can make full use of the computing power of the cloud and is suitable for large-scale, high-complexity model processing tasks. However, the edge device needs to upload the collected data to the cloud for processing. The larger the amount of data, the higher the network bandwidth requirement. Especially in applications with large amounts of real-time data such as video surveillance and autonomous driving, the bandwidth pressure increases significantly, so that the network operating costs increase accordingly, and data transmission may be blocked or slow due to insufficient bandwidth. The round-trip process of data transmission and cloud processing produces significant network delay problems. For applications that require real-time response, such as autonomous driving and smart medical care, delays may directly affect the security and practicality of the system. In addition, in the process of uploading data to the cloud, user data is at risk of leakage, especially in fields involving sensitive information such as medical care and finance. Data leakage may lead to user privacy exposure, trigger a crisis of trust, and even cause economic losses and legal disputes.
[0005] The second is the cloud training and edge reasoning mode. In this mode, model training is performed in the cloud, and the trained model is downloaded to the edge device for reasoning. Cloud training uses powerful computing resources to complete the training of complex models, while the edge device performs local reasoning. This method reduces the demand for data transmission from the edge to the remote end, improves the response speed, and can alleviate the problems of bandwidth pressure and transmission delay to a certain extent. However, model training and updating can only be completed in the cloud, and the edge device cannot update the model in time when the environment changes or the data distribution changes, resulting in the model's lack of adaptability to dynamic environments, which in turn causes the model to gradually fail or performance degradation, thereby affecting the overall performance of the system, reducing work efficiency, and failing to meet the needs of actual application tasks. Model training is performed in the cloud, and model updates are limited by cloud resources and processes, resulting in the inability to frequently update the model in some real-time scenarios to adapt to changes in real-time data, so that the model has poor flexibility and cannot accurately reflect the latest situation of the real-time scenario, thereby affecting the accuracy and timeliness of decision-making. In addition, this method still has the problem of data privacy leakage. Summary of the invention
[0006] To this end, the technical problem to be solved by the present invention is to overcome the problems of high bandwidth consumption, high transmission delay, data privacy leakage, and delayed model update and low update frequency in the prior art.
[0007] In order to solve the above technical problems, the present invention provides an interactive continuous learning lightweight model training and reasoning method, comprising:
[0008] Obtain the initial data set through the terminal device, and upload the initial data set to the edge device through the network protocol;
[0009] Receive and store an initial data set through an edge device; based on the initial data set, train an initial model by minimizing a cross entropy loss function, obtain the trained initial model as a first model, and store the first model in the edge device; based on the initial data set, use a lightweight strategy to perform a lightweight operation on the first model to obtain a lightweight initial model; deploy the lightweight initial model to a terminal device through a network protocol;
[0010] Through the terminal device, the lightweight initial model is received and loaded. After executing and completing the lightweight initial model inference task, the acquired new data is organized into an incremental data set, and the incremental data set is uploaded to the edge device through the network protocol;
[0011] Receive and store the incremental data set through the edge device, and load the first model; construct a continuous learning loss function based on the continuous learning strategy; train the first model based on the incremental data set by minimizing the continuous learning loss function, update the high-level parameters of the first model, obtain the trained first model as the incremental model, and store the incremental model in the edge device; based on the incremental data set, adopt a lightweight strategy to perform lightweight operations on the incremental model to obtain a lightweight incremental model, and deploy the lightweight incremental model to the terminal device through the network protocol;
[0012] Through the terminal device, the lightweight incremental model is received and loaded, and the lightweight initial model is replaced with the lightweight incremental model. After completing the model update task, the lightweight incremental model reasoning task is executed and completed;
[0013] Continue to feed back new data collected by the terminal device to the edge device, perform model training tasks on the edge device, and perform model updates and reasoning tasks on the terminal device, thereby achieving interactive and continuous learning of lightweight model training and reasoning.
[0014] Preferably, the training of the initial model based on the initial data set by minimizing the cross entropy loss function to obtain the trained initial model as the first model includes:
[0015] Initialize the initial model, set the number of network layers, activation function and optimizer parameters of the initial model;
[0016] The cross entropy loss function The expression is:
[0017] ;
[0018] in, Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates the number of categories; Indicates the index of the category; The output of the initial model is Initial sample The predicted probability of each category; Indicates Initial sample The true labels of the categories;
[0019] Back propagation and gradient descent methods are used to update and adjust the initial model parameters; the expression for updating the initial model parameters is:
[0020] ;
[0021] in, Indicates that the initial model is Parameters at the iteration; represents the learning rate, represents the gradient of the cross entropy loss function; Represents the sum of the gradients of the loss function of all initial samples to the initial model parameters; Indicates Initial samples; Indicates The true labels corresponding to the initial samples;
[0022] The initial model is trained for multiple rounds using the initial data set until the initial model reaches a preset convergence standard or the number of training rounds, and the training is stopped to obtain the trained initial model as the first model.
[0023] Preferably, the step of performing a lightweight operation on the first model based on the initial data set and adopting a lightweight strategy to obtain a lightweight initial model includes:
[0024] The lightweight strategy is a knowledge distillation and model pruning method;
[0025] The first model is used as the first teacher model; the first student model is constructed; the first knowledge distillation loss function is constructed with the goal of minimizing the difference between the soft labels generated by the first teacher model and the predicted probability distribution output by the first student model, and its expression is:
[0026] ;
[0027] in, represents the knowledge distillation loss function; Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates the number of categories; The index representing the category; represents the first teacher model generated Initial sample Soft labels for categories; Represents the output of the first student model Initial sample The predicted probability of each category;
[0028] The first student model is trained by minimizing the first knowledge distillation loss function to obtain a trained first student model;
[0029] Perform forward propagation on the initial data set and calculate the average activation value of each neuron in the first student model after training. The expression is:
[0030] ;
[0031] in, Indicates The average activation value of neurons; Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates Initial samples; Indicates The neuron in The activation value on the initial sample;
[0032] The neurons whose average activation value is less than the threshold are marked as redundant neurons; each redundant neuron and its connection are removed from the network structure of the trained first student model, and the network weights and biases of the trained first student model are updated to obtain the pruned first student model;
[0033] Using the initial dataset, fine-tune the pruned first student model to obtain a lightweight initial model.
[0034] Preferably, the predicted probability distribution output by the first teacher model is used as the soft label generated by the first teacher model, and the expression of the predicted probability distribution output by the first teacher model is:
[0035] ;
[0036] in, represents the predicted probability distribution of the output of the first teacher model; represents the predicted logical value of the first teacher model; Represents the temperature parameter.
[0037] Preferably, the expression of the predicted probability distribution output by the first student model is:
[0038] ;
[0039] in, represents the predicted probability distribution of the first student model output; represents the predicted logistic value of the first student model; Represents the temperature parameter.
[0040] Preferably, the method of constructing a continuous learning loss function based on a continuous learning strategy; training the first model based on an incremental data set by minimizing the continuous learning loss function, updating high-level parameters of the first model, and obtaining the trained first model as an incremental model includes:
[0041] Adopt a continuous learning strategy based on L2 regularization and construct a regularized cross entropy loss function as a continuous learning loss function , whose expression is:
[0042] ;
[0043] in, Indicates the number of incremental samples in the incremental data set; Indicates the index of the incremental sample; Indicates the new number of categories; The index representing the new category; The output of the first model is Incremental samples The predicted probability of the new category; Indicates Incremental samples The true labels of new categories; represents the weight of the L2 regularization term; Indicates the first model parameters; represents the total number of parameters of the first model;
[0044] The high-level parameters of the first model are updated and adjusted through back propagation and gradient descent methods; wherein the expression for updating the high-level parameters of the first model is:
[0045] ;
[0046] in, Indicates that the first model is Parameters at the iteration; represents the learning rate, represents the gradient of the regularized cross entropy loss function; Represents the sum of the gradients of the loss function of all incremental samples to the first model parameters; Indicates Incremental samples; Indicates The true labels corresponding to the incremental samples;
[0047] The first model is iteratively trained for multiple rounds using the incremental data set until the first model reaches a preset convergence standard or the number of training rounds, and the training is stopped to obtain the trained first model as the incremental model.
[0048] Preferably, the step of performing lightweight operations on the incremental model based on the incremental data set and adopting a lightweight strategy to obtain the lightweight incremental model includes:
[0049] The lightweight strategy is a knowledge distillation and model pruning method;
[0050] The incremental model is used as the second teacher model; a second student model is constructed; a second knowledge distillation loss function is constructed with the goal of minimizing the difference between the soft labels generated by the second teacher model and the predicted probability distribution output by the second student model; the second student model is trained by minimizing the second knowledge distillation loss function to obtain a trained second student model;
[0051] Perform forward propagation on the incremental data set to calculate the average activation value of each neuron in the trained second student model; mark the neurons whose average activation value is less than the threshold as redundant neurons; remove each redundant neuron and its connection from the network structure of the trained second student model, and update the network weights and bias of the trained second student model to obtain the pruned second student model;
[0052] Using the incremental dataset, the pruned second student model is fine-tuned to obtain a lightweight incremental model.
[0053] Preferably, the network protocol includes: HTTP or MQTT protocol.
[0054] Preferably, before deploying the lightweight model to the terminal device through the network protocol, the parameters and structure of the lightweight model need to be packaged and a deployment format adapted to the terminal device is generated; wherein the deployment format adapted to the terminal device is the ONNX format.
[0055] Preferably, before using the incremental data set to train the first model, the incremental data set needs to be cleaned, standardized and format-converted to obtain a preprocessed incremental data set; wherein each incremental data in the preprocessed incremental data set is adapted to the input format of the first model.
[0056] The above technical solution of the present invention has the following beneficial effects compared with the prior art:
[0057] The interactive continuous learning lightweight model training and reasoning method described in the present invention completes model training and updating on the edge device, and transmits the updated lightweight model to the terminal device for reasoning, thereby reducing the reliance on frequent data transmission on the cloud and reducing network bandwidth consumption, which is particularly effective in scenarios with large data volumes or requiring real-time reasoning. The edge device is responsible for model updating, and the terminal device performs instant reasoning to form a closed-loop learning system, which reduces network latency issues during model reasoning, ensures real-time response capabilities, and meets the needs of high-real-time application scenarios. The edge device only exchanges data and models with the terminal device, and the terminal device only performs reasoning, so data does not need to be frequently uploaded to the cloud, ensuring local processing and storage of data and reducing It reduces the risk of data leakage during transmission and enhances the privacy protection and data security of the system; introduces a continuous learning mechanism on the edge device, so that the model can be incrementally updated according to the latest data feedback from the terminal device, so that the model can adapt to the dynamic changes of the environment, and the terminal device can always use the latest model for efficient reasoning, thereby improving the adaptability and self-learning ability of the system in a dynamic environment; the edge device uses knowledge distillation and model pruning methods to lightweight the trained model, and the terminal device performs reasoning tasks on the lightweight model, so that the terminal device can still maintain efficient reasoning operations under limited computing resources, while reducing the computing power and storage requirements of the terminal device, extending the service life of the device and saving energy. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] In order to make the content of the present invention more clearly understood, the present invention is further described in detail below according to specific embodiments of the present invention in conjunction with the accompanying drawings, wherein:
[0059] Figure 1 It is a flowchart of an interactive continuous learning lightweight model training and reasoning method provided by the present invention;
[0060] Figure 2 This is a schematic diagram of the interaction process between edge devices and terminal devices of an interactive continuous learning lightweight model training and reasoning method provided by the present invention. DETAILED DESCRIPTION
[0061] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand the present invention and implement it, but the embodiments are not intended to limit the present invention. Embodiment 1
[0062] Reference Figure 1 and Figure 2 As shown, the interactive continuous learning lightweight model training and reasoning method provided by the present invention includes:
[0063] S1: Obtain the initial data set through the terminal device , and upload the initial data set to the edge device through the network protocol;
[0064] S2: Receive and store the initial data set through edge devices;
[0065] Based on the initial data set, the initial model is trained by minimizing the cross entropy loss function, and the trained initial model is obtained as the first model, including:
[0066] Initialize the initial model, set the number of network layers, activation function and optimizer parameters of the initial model;
[0067] The cross entropy loss function The expression is:
[0068] ;
[0069] in, Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates the number of categories; Indicates the index of the category; The output of the initial model is Initial sample The predicted probability of each category; Indicates Initial sample The loss function is used to evaluate the difference between the predicted output of the initial model and the actual label, and continuously adjust the initial model parameters during the training process to reduce this error;
[0070] Back propagation and gradient descent methods are used to update and adjust the initial model parameters so that the initial model gradually converges and learns the distribution characteristics of the data; the expression for updating the initial model parameters is:
[0071] ;
[0072] in, Indicates that the initial model is The parameters at the iteration; represents the learning rate, represents the gradient of the cross entropy loss function; Represents the sum of the gradients of the loss function of all initial samples to the initial model parameters; Indicates Initial samples; Indicates The true labels corresponding to the initial samples;
[0073] The initial model is trained for multiple rounds using the initial data set until the initial model reaches a preset convergence standard or the number of training rounds, and the training is stopped to obtain the trained initial model as the first model;
[0074] storing the first model in an edge device;
[0075] Based on the initial data set, a lightweight strategy is adopted to perform lightweight operations on the first model to obtain a lightweight initial model, including:
[0076] In a specific embodiment of the present invention, the lightweight strategy is a knowledge distillation and model pruning method;
[0077] The first model is used as the first teacher model to guide the learning of the lightweight model, wherein the predicted probability distribution output by the first teacher model is used as the soft label generated by the first teacher model, and the expression of the predicted probability distribution output by the first teacher model is:
[0078] ;
[0079] in, represents the predicted probability distribution of the output of the first teacher model; represents the predicted logical value of the first teacher model; represents the temperature parameter;
[0080] Construct a first student model, which is a smaller student model with lower computational complexity so as to run efficiently on the terminal device; wherein the expression of the predicted probability distribution output by the first student model is:
[0081] ;
[0082] in, represents the predicted probability distribution of the first student model output; represents the predicted logistic value of the first student model; represents the temperature parameter;
[0083] With the goal of minimizing the difference between the soft labels generated by the first teacher model and the predicted probability distribution output by the first student model, the first knowledge distillation loss function is constructed, and its expression is:
[0084] ;
[0085] in, represents the knowledge distillation loss function; Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates the number of categories; Indicates the index of the category; represents the first teacher model generated Initial sample Soft labels for categories; Represents the output of the first student model Initial sample The predicted probability of each category;
[0086] The first student model is trained by minimizing the first knowledge distillation loss function to obtain a trained first student model;
[0087] Perform forward propagation on the initial data set and calculate the average activation value of each neuron in the first student model after training. The expression is:
[0088] ;
[0089] in, Indicates The average activation value of neurons; Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates Initial samples; Indicates The neuron in The activation value on the initial sample;
[0090] The neurons whose average activation value is less than the threshold are marked as redundant neurons; each redundant neuron and its connection are removed from the network structure of the trained first student model to reduce the number of model parameters and computational complexity, and the network weights and biases of the trained first student model are updated to obtain the pruned first student model;
[0091] Using the initial data set, fine-tune the pruned first student model to ensure that the pruning operation does not affect the overall performance of the model, thereby obtaining a lightweight initial model;
[0092] Packing the parameters and structure of the lightweight initial model and generating a deployment format adapted to the terminal device; wherein the deployment format adapted to the terminal device is an ONNX format;
[0093] Deploy the lightweight initial model to the terminal device through the network protocol; wherein the network protocol is HTTP or MQTT network protocol, that is, the lightweight model is transmitted to the terminal device through HTTP or MQTT network protocol by using the edge device; HTTP or MQTT network protocol can ensure data integrity and stability during the transmission process to prevent damage or loss of the model file;
[0094] S3: Receive and load the lightweight initial model through the terminal device, execute and complete the lightweight initial model reasoning task, organize the acquired new data into incremental data sets, and upload the incremental data sets to the edge device through the network protocol;
[0095] S4: receiving and storing the incremental data set through the edge device, and loading the first model; wherein, before using the incremental data set to train the first model, the incremental data set needs to be preprocessed by cleaning, standardizing and format conversion to obtain a preprocessed incremental data set, so that each incremental data in the preprocessed incremental data set can adapt to the input format of the first model; in subsequent steps, the incremental data sets used are all preprocessed incremental data sets;
[0096] Based on the continuous learning strategy, a continuous learning loss function is constructed; based on the incremental data set, the first model is trained by minimizing the continuous learning loss function, and the high-level parameters of the first model are updated to obtain the trained first model as the incremental model, including:
[0097] Adopt a continuous learning strategy based on L2 regularization and construct a regularized cross entropy loss function as a continuous learning loss function , whose expression is:
[0098] ;
[0099] in, Indicates the number of incremental samples in the incremental data set; Indicates the index of the incremental sample; Indicates the new number of categories; The index representing the new category; The output of the first model is Incremental samples The predicted probability of the new category; Indicates Incremental samples The true labels of new categories; represents the weight of the L2 regularization term; Indicates the first model parameters; represents the total number of parameters of the first model;
[0100] Through the back propagation and gradient descent methods, the high-level parameters of the first model are updated and adjusted, the basic feature extraction part of the first model is kept unchanged, and the adaptability of the incremental model to new data is ensured; wherein, the expression for updating the high-level parameters of the first model is:
[0101] ;
[0102] in, Indicates that the first model is The parameters at the iteration; represents the learning rate, represents the gradient of the regularized cross entropy loss function; Represents the sum of the gradients of the loss function of all incremental samples to the first model parameters; Indicates Incremental samples; Indicates The true labels corresponding to the incremental samples;
[0103] Perform multiple rounds of iterative training on the first model using the incremental data set until the first model reaches a preset convergence standard or the number of training rounds, stop training, and obtain the trained first model as the incremental model;
[0104] Storing incremental models in edge devices;
[0105] Based on the incremental data set, a lightweight strategy is adopted to perform lightweight operations on the incremental model to obtain a lightweight incremental model, including:
[0106] In a specific embodiment of the present invention, the lightweight strategy is a knowledge distillation and model pruning method;
[0107] The incremental model is used as the second teacher model, and its knowledge is transferred to a lightweight student model so that the terminal device can load it efficiently; the second student model is constructed; the second knowledge distillation loss function is constructed with the goal of minimizing the difference between the soft label generated by the second teacher model and the predicted probability distribution output by the second student model; the second student model is trained by minimizing the second knowledge distillation loss function to obtain a trained second student model;
[0108] Among them, whether it is the first knowledge distillation loss function or the second knowledge distillation loss function, each knowledge distillation loss function uses the soft label (prediction probability distribution) generated by its corresponding teacher model as the learning target of its corresponding student model, so that its corresponding student model learns key features by imitating the output of its corresponding teacher model, and gradually approaches the performance of its corresponding teacher model. That is, the soft label generated by the teacher model is used to guide the student model, so that the lightweight model is close to the original incremental model in inference performance;
[0109] Perform forward propagation on the incremental data set to calculate the average activation value of each neuron in the trained second student model; mark the neurons whose average activation value is less than the threshold as redundant neurons; remove each redundant neuron and its connection from the network structure of the trained second student model, and update the network weights and bias of the trained second student model to obtain the pruned second student model;
[0110] Using the incremental data set, fine-tune the pruned second student model to ensure that the model achieves a balance between accuracy and efficiency, thereby obtaining a lightweight incremental model.
[0111] Packing the parameters and structure of the lightweight model and generating a deployment format adapted to the terminal device; wherein the deployment format adapted to the terminal device is the ONNX format;
[0112] Deploy lightweight incremental models to terminal devices through network protocols to ensure that no data is lost or damaged during transmission;
[0113] In S4, based on the actual application task requirements, a suitable continuous learning strategy can be selected. The selectable continuous learning strategies include continuous learning based on weight regularization or continuous learning based on experience replay to ensure that the incremental model can adapt to new data without forgetting old data.
[0114] S5: Receive and load the lightweight incremental model through the terminal device, use the lightweight incremental model to replace the lightweight initial model, and after completing the model update task, execute and complete the lightweight incremental model reasoning task;
[0115] S6: Continue to feed back new data collected by the terminal device to the edge device, perform model training tasks on the edge device, and perform model updates and reasoning tasks on the terminal device, thereby achieving interactive and continuous learning of lightweight model training and reasoning. Embodiment 2
[0116] In order to demonstrate the specific application of an interactive continuous learning lightweight model training and reasoning method provided by the present invention in actual scenarios, in a specific embodiment of the present invention, the method provided by the present invention is applied to an elderly monitoring and abnormal motion recognition system based on health care radar, which is suitable for intelligent monitoring of elderly people living alone or in elderly care facilities.
[0117] Health care radars are deployed as terminal devices in the homes of elderly people living alone, and installed on the ceiling above areas where the elderly are prone to abnormal movements (such as falls) (such as bedrooms, bathrooms, or corridors). Small embedded devices are installed as edge devices in locations in the home that do not take up space (such as corners of the living room).
[0118] The health radar collects data through wireless signals (such as millimeter wave radar), including various actions (such as standing, sitting, walking and falling), as the initial data set, and uploads and stores it in the edge device; when the small embedded device leaves the factory, the model is trained through the initial data set. At the same time, due to the limited storage space of the health radar, the trained model needs to be lightweight processed to obtain a lightweight first action recognition model; after receiving the lightweight first action recognition model, the health radar loads it and performs the reasoning task in real time at the deployment location, that is, detecting whether the elderly person falls.
[0119] As edge devices, small embedded devices have smaller computing power. Placing model training on the edge side can protect privacy from being transmitted to the cloud and speed up the transmission rate. As a terminal device, the health care radar is used to perform the reasoning task of judging whether the elderly has fallen down based on various real-time motion data through the lightweight first motion recognition model. At the same time, the acquired new motion data is transmitted to the small embedded device, which is convenient for the small embedded device to perform the model training task, and then obtain the lightweight second motion recognition model. The lightweight second motion recognition model is transmitted to the health care radar. After completing the model update task, it continues to perform the reasoning task of judging whether the elderly has fallen down based on various real-time motion data through the lightweight second motion recognition model, thereby realizing interactive and continuous learning of lightweight model training and reasoning.
[0120] Since different users' actions are heterogeneous, including differences in speed and angle, the new data collected by the health radar during the inference process is transmitted as incremental data to small embedded devices for continuous learning, allowing the system to dynamically adjust the model according to the user's activity characteristics, improve accuracy and reduce false alarm rates. In addition to abnormal movements such as falling, the system can also add new abnormal movement recognition functions according to user needs; for example, increase the recognition of health risks such as long-term bed rest to further enhance monitoring capabilities.
[0121] In the prior art, the cloud refers to a server cluster that provides various computing services through the Internet. These services include data storage (such as cloud storage), computing processing (such as cloud computing), etc. The cloud has powerful computing and storage resources and can handle a large amount of complex data and tasks. The edge device is at the edge of the network, close to the terminal device, such as a network access device such as a router or gateway, or an edge server with certain computing and storage capabilities. Its main function is to perform preliminary processing and screening of the data of the terminal device, reduce the burden on the cloud, and also reduce data transmission delay. The terminal device is the interface for the user to interact with the computer system or network, and is the final endpoint of information transmission; the terminal device is the source and recipient of data in the network, and can send requests to the server or other network devices; at the same time, the terminal device can also serve as a storage endpoint for data. Therefore, in the method provided by the present invention, the edge device is responsible for the training and updating of the model, the terminal device is responsible for real-time reasoning and data collection, and feeds back new data to the edge device to achieve continuous updating of the model, which can reduce data transmission and reduce the frequent data interaction between the terminal device and the cloud.
[0122] In summary, the present invention forms a closed-loop structure through the training and updating of edge devices, and the reasoning and data feedback of terminal devices. This structure realizes real-time adaptation to dynamic environments and has effective applications in resource-constrained environments; a continuous learning algorithm is applied on edge devices to gradually optimize the model based on new data, thereby improving the dynamic adaptability of the model and reducing the delay problem caused by traditional cloud updates; the model is lightweighted through knowledge distillation and model pruning methods to ensure that the terminal device can load the lightweight model and reason efficiently, which is suitable for edge computing environments with low power consumption and low computing power devices, so that the model can be efficiently reasoned on the terminal device, thereby realizing real-time reasoning on terminal devices with limited computing resources.
[0123] The present invention reduces bandwidth dependence and reduces data transmission, which is reflected in: by performing model training and optimization on edge devices, the frequent data interaction between terminal devices and the cloud is reduced; after model training and updating are completed on the edge device, the lightweight model is transmitted to the terminal device for reasoning, thereby significantly reducing network bandwidth consumption and dependence on the cloud.
[0124] The present invention realizes the continuous updating of the model, which is reflected in: by introducing a continuous learning mechanism on the edge device, the model can be incrementally updated according to the latest data fed back by the terminal device; through this dynamic adjustment, the model can adapt to the ever-changing environment, solving the problem of lagging model updates in the prior art, so that the terminal device can always use the latest model for efficient reasoning.
[0125] The present invention improves the reasoning efficiency of terminal devices, which is reflected in the following aspects: the present invention uses technologies such as knowledge distillation and model pruning to perform lightweight processing on the trained model, ensuring that the terminal device (such as ESP32) can still perform reasoning operations efficiently under limited computing resources, solving the problem of limited reasoning ability of terminal devices in the prior art; at the same time, the lightweight model reduces energy consumption while ensuring reasoning efficiency, and is suitable for operation of devices with limited resources.
[0126] The present invention improves the real-time performance of the system, which is reflected in: by performing local reasoning on the terminal device, the present invention greatly reduces the network delay problem during model reasoning; the edge device is responsible for model updating, and the terminal device performs instant reasoning to form a closed-loop learning system, ensuring that the real-time response capability meets the application scenarios with high real-time requirements, and solves the problem of slow system response speed in the prior art.
[0127] The present invention enhances data privacy and security, which is reflected in: by reducing the frequency of data upload to the cloud, ensuring local processing and storage of data, reducing the risk of data leakage during transmission, and enhancing the privacy protection and data security of the system; this architecture is particularly suitable for fields with high requirements for data security, such as smart homes, medical health and industrial automation.
[0128] Obviously, the above embodiments are merely examples for the purpose of clear explanation and are not intended to limit the implementation methods. For those skilled in the art, other different forms of changes or modifications can be made based on the above description. It is not necessary and impossible to list all the implementation methods here. The obvious changes or modifications derived therefrom are still within the scope of protection of the present invention.
Claims
1. An interactive continuous learning lightweight model training and reasoning method, characterized in that: include: Obtain the initial data set through the terminal device, and upload the initial data set to the edge device through the network protocol; Receive and store the initial data set through edge devices; Based on the initial data set, the initial model is trained by minimizing the cross entropy loss function, the trained initial model is obtained as the first model, and the first model is stored in the edge device; Based on the initial data set, a lightweight strategy is adopted to perform a lightweight operation on the first model to obtain a lightweight initial model; Deploy the lightweight initial model to the terminal device through the network protocol; Through the terminal device, the lightweight initial model is received and loaded. After executing and completing the lightweight initial model inference task, the acquired new data is organized into an incremental data set, and the incremental data set is uploaded to the edge device through the network protocol; Receiving and storing the incremental data set and loading the first model through the edge device; Based on the continuous learning strategy, a continuous learning loss function is constructed; based on the incremental data set, the first model is trained by minimizing the continuous learning loss function, the high-level parameters of the first model are updated, the trained first model is obtained as the incremental model, and the incremental model is stored in the edge device; Based on the incremental data set, a lightweight strategy is adopted to perform lightweight operations on the incremental model to obtain a lightweight incremental model, and the lightweight incremental model is deployed to the terminal device through the network protocol; Through the terminal device, the lightweight incremental model is received and loaded, and the lightweight initial model is replaced with the lightweight incremental model. After completing the model update task, the lightweight incremental model reasoning task is executed and completed; Continue to feed back new data collected by the terminal device to the edge device, perform model training tasks on the edge device, and perform model updates and reasoning tasks on the terminal device, thereby achieving interactive and continuous learning of lightweight model training and reasoning.
2. The interactive continuous learning lightweight model training and reasoning method according to claim 1 is characterized in that: The initial model is trained based on the initial data set by minimizing the cross entropy loss function to obtain the trained initial model as the first model, including: Initialize the initial model, set the number of network layers, activation function and optimizer parameters of the initial model; The cross entropy loss function The expression is: ; in, Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates the number of categories; Indicates the index of the category; The output of the initial model is Initial sample The predicted probability of each category; Indicates Initial sample The true labels of the categories; Back propagation and gradient descent methods are used to update and adjust the initial model parameters; the expression for updating the initial model parameters is: ; in, Indicates that the initial model is Parameters at the iteration; represents the learning rate, represents the gradient of the cross entropy loss function; Represents the sum of the gradients of the loss function of all initial samples to the initial model parameters; Indicates Initial samples; Indicates The true labels corresponding to the initial samples; The initial model is trained for multiple rounds of iterations using the initial data set until the initial model reaches a preset convergence standard or the number of training rounds, and the training is stopped to obtain the trained initial model as the first model.
3. The interactive continuous learning lightweight model training and reasoning method according to claim 1, characterized in that: The lightweight operation is performed on the first model based on the initial data set by adopting a lightweight strategy to obtain a lightweight initial model, including: The lightweight strategy is a knowledge distillation and model pruning method; The first model is used as the first teacher model; the first student model is constructed; the first knowledge distillation loss function is constructed with the goal of minimizing the difference between the soft labels generated by the first teacher model and the predicted probability distribution output by the first student model, and its expression is: ; in, represents the knowledge distillation loss function; Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates the number of categories; Indicates the index of the category; represents the first teacher model generated Initial sample Soft labels for categories; Represents the output of the first student model Initial sample The predicted probability of each category; The first student model is trained by minimizing the first knowledge distillation loss function to obtain a trained first student model; Perform forward propagation on the initial data set and calculate the average activation value of each neuron in the first student model after training. The expression is: ; in, Indicates The average activation value of neurons; Represents the number of initial samples in the initial data set; Represents the index of the initial sample; Indicates Initial samples; Indicates The neuron in The activation value on the initial sample; The neurons whose average activation value is less than the threshold are marked as redundant neurons; each redundant neuron and its connection are removed from the network structure of the trained first student model, and the network weights and biases of the trained first student model are updated to obtain the pruned first student model; Using the initial dataset, fine-tune the pruned first student model to obtain a lightweight initial model.
4. The interactive continuous learning lightweight model training and reasoning method according to claim 3 is characterized in that: The predicted probability distribution output by the first teacher model is used as the soft label generated by the first teacher model. The expression of the predicted probability distribution output by the first teacher model is: ; in, represents the predicted probability distribution of the output of the first teacher model; represents the predicted logical value of the first teacher model; Represents the temperature parameter.
5. The interactive continuous learning lightweight model training and reasoning method according to claim 3 is characterized in that: The expression of the predicted probability distribution output by the first student model is: ; in, represents the predicted probability distribution of the first student model output; represents the predicted logistic value of the first student model; Represents the temperature parameter.
6. The interactive continuous learning lightweight model training and reasoning method according to claim 1, characterized in that: The method of constructing a continuous learning loss function based on a continuous learning strategy; training a first model based on an incremental data set by minimizing the continuous learning loss function, updating high-level parameters of the first model, and obtaining the trained first model as an incremental model includes: Adopt a continuous learning strategy based on L2 regularization and construct a regularized cross entropy loss function as a continuous learning loss function , whose expression is: ; in, Indicates the number of incremental samples in the incremental data set; Indicates the index of the incremental sample; Indicates the new number of categories; The index representing the new category; The output of the first model is Incremental samples The predicted probability of the new category; Indicates Incremental samples The true labels of new categories; represents the weight of the L2 regularization term; Indicates the first model parameters; represents the total number of parameters of the first model; The high-level parameters of the first model are updated and adjusted through back propagation and gradient descent methods; wherein the expression for updating the high-level parameters of the first model is: ; in, Indicates that the first model is Parameters at the iteration; represents the learning rate, represents the gradient of the regularized cross entropy loss function; Represents the sum of the gradients of the loss function of all incremental samples to the first model parameters; Indicates Incremental samples; Indicates The true labels corresponding to the incremental samples; The first model is iteratively trained for multiple rounds using the incremental data set until the first model reaches a preset convergence standard or the number of training rounds, and the training is stopped to obtain the trained first model as the incremental model.
7. The interactive continuous learning lightweight model training and reasoning method according to claim 1 is characterized in that: The lightweight incremental model is obtained by performing lightweight operations on the incremental model based on the incremental data set using a lightweight strategy, and includes: The lightweight strategy is a knowledge distillation and model pruning method; The incremental model is used as the second teacher model; a second student model is constructed; a second knowledge distillation loss function is constructed with the goal of minimizing the difference between the soft labels generated by the second teacher model and the predicted probability distribution output by the second student model; the second student model is trained by minimizing the second knowledge distillation loss function to obtain a trained second student model; Perform forward propagation on the incremental data set to calculate the average activation value of each neuron in the trained second student model; mark the neurons whose average activation value is less than the threshold as redundant neurons; remove each redundant neuron and its connection from the network structure of the trained second student model, and update the network weights and bias of the trained second student model to obtain the pruned second student model; Using the incremental dataset, the pruned second student model is fine-tuned to obtain a lightweight incremental model.
8. The interactive continuous learning lightweight model training and reasoning method according to claim 1, characterized in that: The network protocol includes: HTTP or MQTT protocol.
9. The interactive continuous learning lightweight model training and reasoning method according to claim 1, characterized in that: Before deploying the lightweight model to the terminal device through the network protocol, the parameters and structure of the lightweight model need to be packaged and a deployment format compatible with the terminal device is generated; wherein the deployment format compatible with the terminal device is the ONNX format.
10. The interactive continuous learning lightweight model training and reasoning method according to claim 1, characterized in that: Before using the incremental data set to train the first model, the incremental data set needs to be cleaned, standardized and format-converted to obtain a preprocessed incremental data set; wherein each incremental data in the preprocessed incremental data set is adapted to the input format of the first model.
Citation Information
Patent Citations
Knowledge distillation-based edge device scene identification method and device
CN114241282A
Millimeter wave radar home health monitoring system and method
CN117471451A
Cited By
Large model lightweight deployment method based on knowledge distillation
CN121683934A