Model training method and apparatus
The method addresses reduced inference accuracy in hybrid cloud AI models by evaluating and retraining models based on inference metrics, adapting to data changes to maintain accuracy and performance.
Patent Information
- Application Number
- JP2022543575
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-01-16
- Filing Date
- 2020-09-04
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-09-04
AI Technical Summary
Existing AI model training methods in hybrid clouds face inaccuracies due to changes in input data, leading to reduced inference accuracy and system performance, particularly in scenarios like video surveillance where camera aging or repositioning affects the training model's effectiveness.
A method and apparatus for evaluating AI models in a hybrid cloud environment using inference results and model evaluation metrics to determine when retraining is necessary, ensuring timely updates to maintain accuracy and performance by integrating model retraining based on input data and inference outcomes.
This approach enhances inference accuracy and maintains service system performance by timely retraining models, adapting to changes in input data and ensuring consistent model effectiveness.
Smart Images

Figure 0007566027000001 
Figure 0007566027000002 
Figure 0007566027000003
Abstract
Description
[Technical field]
[0001] This application claims priority to Chinese Patent Application No. 202010049320.1, entitled "Model Training Method and Apparatus," filed with the State Intellectual Property Office of the People's Republic of China on January 16, 2020, which is incorporated herein by reference in its entirety.
[0002] The present application relates to the field of communication technology, and in particular to a model training method and apparatus. [Background technology]
[0003] Data, algorithms, and computing power are the three elements to realize artificial intelligence (AI). As data collection methods become more and more diverse, AI chips can obtain more data at lower costs. In addition, continuous breakthroughs in AI algorithms make the calculation speed of AI chips faster and faster. Therefore, AI chips have more and more powerful computing power, and AI is becoming more and more prevalent in the real world. In conventional technologies, a hybrid cloud is usually used to perform AI model training and inference. Specifically, an "online training and offline inference" mode is used. Training data is first uploaded to an online training platform in a public cloud for model training to determine a training model that meets the requirements. The training model is then pushed down to an offline inference platform in a private cloud, and the offline inference platform exposes the training model as a service for inference. In this implementation, the computing power of the public cloud can be maximized to perform model training and inference while using a private cloud to ensure the security of user data.
[0004] In an actual production environment, a hybrid cloud is used to perform model training, and after the training model is determined, the input data of the training model is changed, so that the inference results obtained by using the training model to perform inference may be less accurate. In the existing AI model training mode of the hybrid cloud, the service system (e.g., face recognition system) may not be able to sense the deterioration of the inference accuracy of the training model in a timely manner, and may frequently report it erroneously, or may be unavailable. For example, in a video surveillance scenario for security protection, the aging, replacement, or installation position adjustment of a checkpoint camera (e.g., a camera at the entrance of a residential area) may cause changes in the clarity, angle, etc. of the video captured by the checkpoint camera, that is, changes in the input data of the training model. Using the changed input data and training model to perform inference may significantly reduce the accuracy of the inference results of the subsequent training model, affecting the normal functioning of the video surveillance system for security protection. Summary of the Invention [Means for solving the problem]
[0005] This application provides a model training method and apparatus. In a hybrid cloud scenario, a training model is evaluated based on the inference result of the training model, and the evaluation result of the model evaluation metric of the training model is determined to monitor the inference effect of the training model. Therefore, the training model is retrained in a timely manner based on the inference effect of the training model to determine a training model with better inference effect, thereby improving the accuracy of the inference result and ensuring the performance of the service system.
[0006] To achieve the aforementioned objectives, the present application uses the following technical solutions:
[0007] According to a first aspect, an embodiment of the present application provides a model training method applied to a system including a first server and a second server. The first server is located in a private cloud and is used for model inference. The second server is located in a public cloud and is used for model training. The method includes: acquiring a first training model from the second server by the first server; and inputting input data into the first training model for model inference by the first server to obtain an inference result. Then, the first server evaluates the first training model based on the inference result and the model evaluation metric to obtain an evaluation result of the model evaluation metric. Finally, if the evaluation result of at least one model evaluation metric does not exceed a predetermined threshold corresponding to the model evaluation metric, the first server sends a retraining command for the first training model to the second server. The retraining command instructs the second server to retrain the first training model.
[0008] In conclusion, the first server evaluates the model evaluation metrics of the first training model to determine the inference effect of the first training model, and monitors the inference effect of the first training model. Therefore, when the first training model has insufficient inference effect, a retraining command is sent to the second server to be used for model retraining, so that the second server can timely retrain the training model based on the inference effect of the training model to determine a training model with better inference effect, thereby improving the accuracy of the inference result and ensuring the performance of the service system.
[0009] In a possible implementation form, after the step of inputting input data into the first training model for model inference and obtaining an inference result by the first server, the method further includes the step of transmitting the input data and the inference result to the second server by the first server to implement a data closed loop in the model training and inference system in a hybrid cloud scenario. Thus, in the present application, the training model may be retrained using the input data input into the training model for inference and the inference result obtained through the model inference, thereby improving the inference effect of the training model, i.e., the accuracy of the inference result, and ensuring the service system performance. The input data and the inference result are used to retrain the first training model.
[0010] In a possible implementation, the model evaluation metrics include at least one of the accuracy of the inference result, the precision of the inference result, the recall of the inference result, the F1-score of the inference result, and the area under the receiver operating characteristic ROC curve AUC of the inference result.
[0011] In a possible implementation, the method includes the first server not sending a retraining instruction for the first training model to the second server if all evaluation results of the model evaluation metrics exceed a predetermined threshold corresponding to the evaluation results.
[0012] According to a second aspect, an embodiment of the present application provides a model training method applied to a system including a first server and a second server. The first server is located in a private cloud and is used for model inference. The second server is located in a public cloud and is used for model training. The method includes a step of obtaining, by the second server, a retraining instruction for a first training model from the first server, input data, and an inference result. The retraining instruction instructs the second server to retrain the first training model, the input data is data input by the first server to the first training model, and the inference result is a result obtained after the first server inputs the input data to the first training model for model inference. Then, the second server determines a retraining sample set based on the input data and the inference result, and retrains the first training model based on the retraining sample set to determine a second training model, and the second training model is used to replace the first training model. Finally, the second server sends the second training model to the first server.
[0013] In a possible implementation, obtaining, by the second server, retraining instructions, input data, and inference results for the first training model from the first server specifically includes obtaining, by the second server, the input data and the inference results in response to the retraining instructions received from the first server.
[0014] In a possible implementation, the step of determining, by the second server, a retraining sample set based on the input data and the inference result specifically includes the step of annotating, by the second server, the input data to obtain annotated input data, and then storing the annotated input data and the inference result in the retraining sample set.
[0015] In a possible implementation form, prior to the step of annotating the input data by the second server to obtain annotated input data, the method further includes a step of, if the inference result is an accurate inference result, retaining, by the second server, the inference result and the input data corresponding to the inference result, or, if the inference result is an inaccurate inference result, deleting, by the second server, the inference result and the input data corresponding to the inference result, or replacing, by the second server, the inference result with an accurate inference result corresponding to the input data.
[0016] According to a third aspect, the present application further provides a model training apparatus functioning as a first server, which is applied to a system of a first server and a second server. The first server is disposed in a private cloud and used for model inference, and the second server is disposed in a public cloud and used for model training. The apparatus functioning as the first server includes an acquisition unit, an inference unit, an evaluation unit, and a sending unit. The acquisition unit is configured to acquire the first training model from the second server. The inference unit is configured to input input data into the first training model for model inference to obtain an inference result. The evaluation unit is configured to evaluate the first training model based on the inference result and the model evaluation metric to obtain an evaluation result of the model evaluation metric. The sending unit is configured to send a retraining command for the first training model to the second server when the evaluation result of the at least one model evaluation metric does not exceed a predetermined threshold corresponding to the model evaluation metric. The retraining command instructs the second server to retrain the first training model.
[0017] In a possible implementation, the model evaluation metrics include at least one of the accuracy of the inference result, the precision of the inference result, the recall of the inference result, the F1-score of the inference result, and the area under the receiver operating characteristic ROC curve AUC of the inference result.
[0018] In a possible implementation, the sending unit is further configured to send the input data and the inference result to a second server. The input data and the inference result are used to retrain the first training model.
[0019] According to a fourth aspect, in a possible implementation, the sending unit is further configured to skip sending retraining instructions for the first training model to the second server if all evaluation results of the model evaluation metrics exceed a predetermined threshold corresponding to the evaluation results.
[0020] The present application further provides a model training device that functions as a second server, which is applied to a system of a first server and a second server. The first server is located in a private cloud and is used for model inference, and the second server is located in a public cloud and is used for model training. The device that functions as the second server includes an acquisition unit, a determination unit, a transmission unit, and a processing unit. The acquisition unit is configured to acquire retraining instructions, input data, and inference results for the first training model from the first server. The determination unit is configured to determine a retraining sample set based on the input data and the inference result. The determination unit is further configured to retrain the first training model based on the retraining sample set to determine a second training model. The second training model is used to replace the first training model. The transmission unit is configured to transmit the second training model to the first server. The retraining command instructs the second server to retrain the first training model, the input data is data input by the first server into the first training model for model inference, and the inference result is a result obtained after the first server inputs the input data into the first training model for model inference.
[0021] In a possible implementation form, the processing unit is configured to, if the inference result is an accurate inference result, retain the inference result and input data corresponding to the inference result, by the second server, or, if the inference result is an inaccurate inference result, delete the inference result and the input data corresponding to the inference result, by the second server, or replace the inference result with an accurate inference result corresponding to the input data, by the second server.
[0022] In a possible implementation form, the obtaining unit is specifically configured to obtain the input data and the inference result in response to a retraining instruction received from the first server.
[0023] In a possible implementation, the decision unit is configured to annotate the input data to obtain annotated input data, and store the annotated input data and the inference results in a re-training sample set.
[0024] According to a fifth aspect, the present application provides a model training apparatus. The apparatus includes a processor, a memory, and a communication interface. The communication interface is configured to communicate with another device or a communication network, and the memory is configured to store one or more programs, the one or more programs including computer-executable instructions, and when the apparatus is operated, the processor executes the computer-executable instructions stored in the memory to enable the apparatus to perform the model training method according to any one of the first aspect or the second aspect, and the optional implementation forms of the first aspect or the second aspect.
[0025] According to a sixth aspect, the present application provides a computer program product including instructions that, when executed by a processor, enable the computer to perform a model training method according to any one of the first aspect or the second aspect and optional implementations of the first aspect or the second aspect.
[0026] According to a seventh aspect, the present application provides a computer-readable storage medium storing one or more programs. The computer-readable storage medium stores instructions. The one or more programs include instructions that, when executed by a processor, enable the computer to perform a model training method according to any one of the first aspect or the second aspect, and optional implementation forms of the first aspect or the second aspect. [Brief description of the drawings]
[0027] [Figure 1] FIG. 1 is a schematic diagram of the system used for AI model training and inference in a hybrid cloud scenario of the current technology. [Diagram 2] FIG. 2 is a schematic diagram of the system used for AI model training and inference in a hybrid cloud scenario of the current technology. [Diagram 3] FIG. 1 is a schematic diagram of a system used for AI model training and inference in a hybrid cloud scenario according to an embodiment of the present application. [Figure 4] 1 is a schematic diagram of a hardware structure of a chip according to an embodiment of the present application; [Diagram 5] FIG. 1 is a schematic diagram of a model training device according to an embodiment of the present application. [Figure 6] 1 is a schematic flowchart of a model training method according to an embodiment of the present application. [Figure 7] FIG. 1 is a schematic diagram of the area under the receiver operating characteristic ROC curve AUC of the inference results according to one embodiment of the present application. [Figure 8] FIG. 2 is a schematic diagram of a model training device functioning as a first server according to an embodiment of the present application. [Figure 9] FIG. 2 is a schematic diagram of a model training device functioning as a second server according to an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0028] In the following, first, technical terms used in this application are explained.
[0029] Cloud: A cloud is a server or a server cluster. The services provided by the servers or server clusters forming the cloud may be described as cloud services (e.g., storage, computing, etc.) or cloud computing services, i.e. cloud services. Resources and services required by users are obtained from the cloud through a network.
[0030] Private cloud: A private cloud, also known as an internal cloud or corporate cloud, is a cloud that provides cloud computing services to specific users (rather than the general public) over the Internet or a private internal network. Private clouds are usually deployed behind a firewall or hosting location to effectively guarantee the security and quality of the services provided.
[0031] Public cloud: A public cloud is a cloud that provides cloud computing services to all users over the Internet or a private internal network. At the core of a public cloud are shared resource services that are available over an open public network.
[0032] Hybrid cloud: A hybrid cloud is a cloud that integrates public and private clouds to provide cloud computing services to users.
[0033] After a brief description of hybrid cloud, a system used for AI model training and inference in a hybrid cloud scenario is first described with reference to FIG. 1.
[0034] As shown in Figure 1, a system used for AI model training and inference in a hybrid cloud scenario may include a first server 10 and a second server 20. The first server 10 is located in a private cloud and is used for model inference. The second server 20 is located in a public cloud and is used for model training.
[0035] The first server 10 may be a server in a private cloud or a server cluster including multiple servers in a private cloud. The second server 20 may be a server in a public cloud or a server cluster including multiple servers in a public cloud.
[0036] As shown in FIG. 2, when the modules are divided by function, a system used for AI model training and inference in the hybrid cloud scenario shown in FIG. 1 may include a data collection module 101, a model training module 102, a first model storage module 103, a second model storage module 104, and a model inference management module 105.
[0037] The data collection module 101, the model training module 102, and the first model storage module 103 are located in the second server 20. Specifically, if the second server 20 is a server in a public cloud, the data collection module 101, the model training module 102, and the first model storage module 103 are all located on the second server 20. If the second server 20 is a server cluster including multiple servers in a public cloud, the data collection module 101, the model training module 102, and the first model storage module 103 are located on the same server in the server cluster or on different servers in the server cluster.
[0038] The data collection module 101 is configured to acquire data used for model training, add the acquired data as training samples to a training sample set, and then send the training sample set to the model training module 102. Typically, the data collection module 101 can use an object storage service (OBS) to store the data acquired by the data collection module 101.
[0039] The model training module 102 is configured to receive the training sample set sent by the data collection module 101, perform model training on a predetermined model based on the training sample set to obtain a training model that meets the requirements of the application, and store the training model in the first model storage module 103. The predetermined model may be a pre-stored model (e.g., a training model obtained through model training in advance), or may be a model set based on the application scenario of the training model. For example, in the field of neuro-linguistic programming (NPL), a user usually performs model training on some benchmark models using the training sample set obtained by the user to obtain a required training model. In this case, the predetermined model in this embodiment of the present application is a benchmark model.
[0040] Optionally, the model training module 102 is configured to obtain, from the first model storage module 103, a predefined model used for model training.
[0041] The first model storage module 103 is configured to obtain the trained training model from the model training module 102, and store the training model obtained by the first model storage module 103. The first model storage module 103 is further configured to store the description information of the training model. The description information of the training model includes the name, use, life cycle, etc. of the training model. In addition, the first model storage module 103 is configured to modify the description information of the training model. The first model storage module 103 is further configured to manage the life cycle of the training model based on the life cycle in the description information of the training model, the period for storing the training model by the first model storage module 103, etc. In other words, the first model storage module 103 is configured to store, update, or delete the training model, the description information of the training model, etc. within the life cycle of the training model, and delete or update the training model, the description information of the training model, etc. after the life cycle of the training model is completed.
[0042] For example, the time when the first model storage module 103 acquires the training model A is 11:30 am, and the life cycle of the training model A is 2 hours. In other words, the life cycle of the training model is from 11:30 am to 1:30 pm. If the current moment is any time between 11:30 am and 1:30 pm, the first model storage module 103 may update or delete the training model A stored in the first model storage module 103, or may modify the descriptive information of the training model A stored in the first model storage module 103. The first model storage module 103 can modify the descriptive information of the training model A to change the name and use of the training model A, or to extend / shorten the life cycle of the training model A. If the first model storage module 103 does not change the lifecycle of the training model A stored in the first model storage module 103 during the period from 11:30am to 1:30pm, the lifecycle of the training model A will end after 1:30pm, and the first model storage module 103 will delete the training model A and the descriptive information of the training model A stored in the first model storage module 103.
[0043] Optionally, the first model storage module 103 is further configured to store a pre-defined model used for model training.
[0044] The first model storage module 103 is further configured to transmit the training model received by the first model storage module 103 from the model training module 102 to the second model storage module 104. Optionally, the first model storage module 103 is further configured to transmit descriptive information of the training model, etc. to the second model storage module 104, so that the model inference management module 105 performs model inference using the training model.
[0045] The second model storage module 104 is configured to acquire and store the training model sent by the first model storage module 103. Optionally, the second model storage module 104 is further configured to acquire and store description information of the training model sent by the first model storage module 103. For the description information, please refer to the above. Details will not be described again in this specification. The second model storage module 104 is further configured to modify the description information of the training model stored in the second model storage module 104. In addition, the second model storage module 104 is configured to manage the life cycle of the training model based on the life cycle in the description information of the training model, the period of storing the training model by the second model storage module 104, etc. For a specific description of managing the life cycle of the training model, please refer to the above. Details will not be described again in this specification. The second model storage module 104 is further configured to send the training model acquired by the second model storage module 104 from the first model storage module 103 to the model inference management module 105.
[0046] The second model storage module 104 and the model inference management module 105 are disposed on the first server 10. Specifically, when the first server 10 is a server in a private cloud, both the second model storage module 104 and the model inference management module 105 are disposed on the first server 10. When the first server 10 is a server cluster including multiple servers in the private cloud, the second model storage module 104 and the model inference management module 105 are disposed on the same server or on different servers in the server cluster.
[0047] The model inference management module 105 is configured to call the training model from the second model storage module 104 and publish the training model as a service. The model inference management module 105 is further configured to update and delete the service corresponding to the training model and published by the model inference management module 105 for updating and deleting the training model in the second model storage module 104. The model inference management module 105 is further configured to call the training model corresponding to the service after receiving the instruction to provide the service, input the input data into the training model for model inference to obtain the inference result, and deliver the inference result to the user terminal. Optionally, the model inference management module 105 is further configured to clip the training model, for example, reduce the number of network layers, merge operators, etc. in the deep learning model, so as to accelerate the inference process and improve the model inference efficiency.
[0048] In the existing method of using hybrid clouds to perform AI model training and inference, when the input data input to the training model changes (for example, in a video surveillance scenario, the aging, replacement, or position adjustment of the surveillance camera in this scenario changes the input data input to the training model), the accuracy of the inference result obtained by performing model inference using the training model may be reduced. Specifically, the training model may have insufficient inference effect, and the performance of the service system may be affected.
[0049] In order to solve the above-mentioned problems, the present application provides a model training method applied to a hybrid cloud scenario. The training model may be evaluated based on the model evaluation metrics and the inference results obtained by performing model inference on the training model, so as to monitor the inference effect of the training model and timely retrain the training model with insufficient inference effect, thereby improving the accuracy of the inference results obtained through model inference and ensuring the performance of the service system (e.g., face recognition system). Therefore, as shown in Figure 3, when the system used for AI model training and inference in the hybrid cloud scenario is divided by function, a model retraining management module 201 and a model evaluation module 202 are further added to the modules shown in Figure 2 in this embodiment of the present application.
[0050] If the second server 20 is a server in a public cloud, the data collection module 101, the model training module 102, the first model storage module 103, and the model retraining management module 201 are located on the second server 20. If the second server 20 is a server cluster including multiple servers in a private cloud, the data collection module 101, the model training module 102, the first model storage module 103, and the model retraining management module 201 are located on the same server in the server cluster or on different servers in the server cluster.
[0051] The model retraining management module 201 is for training models and is configured to receive a retraining command sent by the model evaluation module 202. The model retraining management module 201 is for training models and is further configured to instruct the data collection module 101 to obtain data used for model retraining from the model evaluation module 202 in response to the retraining command received by the model retraining management module 201, and to add the obtained data used as retraining samples to the retraining sample set sent to the model training module 102. Optionally, the model retraining management module 201 is further configured to instruct the model training module 102 to obtain a training model used for model retraining from the first model storage module 103 in response to the received retraining command.
[0052] The data collection module 101 is further configured to obtain data used for model retraining, i.e., input data and inference results, from the model evaluation module 202 based on the instruction of the model retraining management module 201. The input data is data input to a training model for model inference, and the inference result is an inference result obtained by inputting the input data to a training model for model inference. The data collection module 101 is further configured to add the data obtained by the data collection module 101 and used as model retraining samples to a retraining sample set, and then send the retraining sample set to the model training module 102. Typically, the data collection module 101 is further configured to store the obtained data using an object storage service (OBS).
[0053] The model training module 102 is further configured to obtain a retraining sample set used for model retraining from the data collection module 101, and obtain a training model used for model retraining from the first model storage module 103 based on an instruction of the model retraining management module 201. The model training module 102 is further configured to retrain the training model based on the retraining sample set obtained by the model training module 102, and replace the training model stored in the first model storage module 103 with the retrained model, so as to obtain a retrained model that meets the requirements of the application.
[0054] When the first server 10 is a server in a private cloud, the second model storage module 104, the model inference management module 105, and the model evaluation module 202 are all located on the first server 10. When the first server 10 is a server cluster including multiple servers in a private cloud, the second model storage module 104, the model inference management module 105, and the model evaluation module 202 are located on the same server in the server cluster or on different servers in the server cluster. For the description of the model training module 102, the first model storage module 103, the second model storage module 104, and the model inference management module 105, please refer to the above description. Details will not be described again in this specification.
[0055] The model evaluation module 202 is configured to evaluate the training model based on the model evaluation metric and the inference result obtained by inputting the input data into the training model for model inference, and determine the evaluation result of the model evaluation metric for the training model. Then, the model evaluation module 202 is further configured to determine the inference effect of the training model based on the evaluation result of the model evaluation metric and a predetermined threshold value corresponding to the model evaluation metric. The model evaluation module 202 is further configured to send a retraining command for the training model to the model retraining management module 201 based on the inference effect of the training model. The model evaluation module 202 is further configured to send data used for model retraining to the data collection module 101.
[0056] For example, if the model evaluation module 202 determines that the training model has poor inference effect, the model evaluation module 202 sends a retraining command for the training model to the model retraining management module 201. If the model evaluation module 202 determines that the training model has good inference effect, the model evaluation module 202 does not send a retraining command for the training model to the model retraining management module 201.
[0057] Optionally, the model evaluation module 202 may be further specifically divided into an evaluation policy configuration module 2021 , a data collection module 2022 , and a model evaluation metric assessment module 2023 .
[0058] The evaluation policy configuration module 2021 is used to configure an evaluation policy for the training model, which includes configuring at least one model evaluation metric used to evaluate the training model, an evaluation rule for the model evaluation metric, a predetermined threshold corresponding to the model evaluation metric, a selection rule for input data and inference results used to evaluate the model evaluation metric, and a retraining trigger policy for the training model. The input data is data input to the training model for model inference, and the inference result is a prediction result obtained by inputting the input data to the training model for model inference. Thus, there is a correspondence between the input data and the inference result. The evaluation policy configuration module 2021 is further configured to send to the data collection module 2022 the selection rule for input data and inference results used to evaluate the model evaluation metric, the at least one model evaluation metric used to evaluate the training model, and the evaluation rule for the model evaluation metric, and send to the model evaluation metric assessment module 2023 the at least one model evaluation metric used to evaluate the training model, the evaluation rule for the model evaluation metric, a predetermined threshold corresponding to the model evaluation metric, and a retraining trigger policy for the training model.
[0059] The data collection module 2022 is configured to obtain input data and inference results, and send the input data and inference results obtained by the data collection module 2022 to the data collection module 101. The data collection module 2022 is further configured to obtain information, such as a selection rule for the input data and inference results used to evaluate the model evaluation metrics, at least one model evaluation metric used to evaluate the training model, and an evaluation rule for the model evaluation metric, from the evaluation policy configuration module 2021, and based on the information, determine the input data and inference results used for model evaluation, and send the input data and inference results used for model evaluation to the model evaluation metric assessment module 2023.
[0060] The model evaluation metric assessment module 2023 is configured to obtain from the data collection module 2022 the input data and the inference result used for model evaluation, and obtain from the evaluation policy configuration module 2021 at least one model evaluation metric used for evaluating the training model, an evaluation rule for the model evaluation metric, a predetermined threshold corresponding to the model evaluation metric, and a retraining trigger policy for the training model. The model evaluation metric assessment module 2023 is further configured to use the input data and the inference result used for model evaluation to determine an evaluation result of the at least one model evaluation metric used for evaluating the training model based on the at least one model evaluation metric used for evaluating the training model and the evaluation rule for the model evaluation metric. The model evaluation metric assessment module 2023 is further configured to determine an inference effect of the training model based on the evaluation result of the model evaluation metric and the predetermined threshold corresponding to the model evaluation metric. The model evaluation metric assessment module 2023 is further configured to determine whether to send a retraining command for the training model to the model retraining management module 201 based on the retraining trigger policy of the training model.
[0061] For example, the retraining trigger policy for a training model is as follows: If the evaluation result of at least one model evaluation metric used to evaluate the training model does not exceed a predetermined threshold corresponding to the model evaluation metric, the model evaluation metric assessment module 2023 determines that the training model has insufficient inference effect, and sends a retraining command for the training model to the model retraining management module 201. If the evaluation results of all the model evaluation metrics used to evaluate the training model exceed the predetermined threshold corresponding to the evaluation results, the model evaluation metric assessment module 2023 determines that the training model has good inference effect, and does not send a retraining command for the training model to the model retraining management module 201.
[0062] Optionally, the division is performed based on the functional module. The system shown in FIG. 2 and FIG. 3 for performing AI model training and inference using hybrid cloud further includes a data annotation module. The data annotation module is loosely coupled to another module. The data collection module 101 is further configured to send the acquired data used for model training / model retraining to the data annotation module after acquiring the data used for model training or the data used for model retraining. Then, the data annotation module is configured to annotate the received data used for model training / model retraining and send the annotated data to the data collection module 101. Finally, the data collection module 101 adds the annotated data acquired from the data annotation module and used as training samples / retraining samples to the training sample set / retraining sample set, so that the model training module 102 can perform model training on a given model using the data in the training sample set / retraining sample set to obtain a training model that meets the requirements, or perform model retraining on the training model to obtain a retrained model.
[0063] For example, in a scenario where an object in an image is classified, the data annotation process involves using an annotation tool to add a rectangular frame to the object in the image and then adding a label, e.g., "cat", "cell phone", etc., to the object in the rectangular frame.
[0064] For other functions of the data collection module 101 and the model training module 102, as well as the functions of the first model storage module 103, the second model storage module 104, and the model inference management module 105, please refer to the above description, and the details will not be described again in this specification.
[0065] In the above process, it should be noted that the present application may further implement a data closed loop of model training and inference system in a hybrid cloud scenario. Specifically, an end-to-end service closed loop for model inference, model evaluation, model retraining, retrained model distribution, and retrained model inference may be implemented. Therefore, in the present application, when the inference effect of the training model is reduced due to factors such as changes in input data caused by environmental changes, the training model may be timely retrained using the input data input to the training model for inference and the inference result obtained through model inference, and then model inference is performed using the retrained model, thereby improving the inference effect of the training model, i.e., the accuracy of the inference result, and ensuring the service system performance.
[0066] Figure 4 shows a hardware structure of a chip according to an embodiment of the present application. The chip includes a neural network processing unit 300. The chip may be provided in the first server 10 and / or the second server 20 shown in Figure 1, and may be configured to complete the tasks of the modules shown in Figure 2 or Figure 3, including obtaining a training model through model training, performing model inference using the training model, performing model evaluation on the training model, obtaining a retrained model through model retraining, etc.
[0067] The neural network processing unit NPU300 is implemented as a co-processor in a host central processing unit (CPU). The host CPU assigns tasks. The core of the NPU300 is an arithmetic circuit 303. A controller 304 controls the arithmetic circuit 303 to extract data from a memory (weight memory or input memory) and perform operations.
[0068] In some implementations, the arithmetic circuit 303 includes multiple processing engines (PEs) therein. In some implementations, the arithmetic circuit 303 is a two-dimensional systolic array. Alternatively, the arithmetic circuit 303 may be a one-dimensional systolic array or another electronic circuit capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 303 is a general-purpose matrix processor.
[0069] For example, assume there is an input matrix A, a weight matrix B, and an output matrix C. The operation circuit 303 fetches data corresponding to matrix B from the weight memory 302 and buffers the data in each PE in the operation circuit 303. To perform a matrix operation on matrix B, the operation circuit 303 fetches data of matrix A from the input memory 301 and stores the obtained partial result or the obtained final result of the matrix in an accumulator 308.
[0070] The vector computation unit 307 may perform further processing, such as vector multiplication, vector addition, exponential operations, logarithmic operations, or value comparisons, on the output of the computation circuitry 303. For example, the vector computation unit 307 may be configured to perform network computations, such as pooling, batch normalization, or local response normalization, at non-convolutional / non-FC layers of a neural network.
[0071] In some implementations, the vector computation unit 307 can store the processed output vector in the unified memory 306. For example, the vector computation unit 307 may apply a non-linear function to the output of the arithmetic circuitry 303, e.g., a vector of accumulated values, to generate the activation value.
[0072] In some implementations, the vector computation unit 307 generates a normalized value, a composite value, or both.
[0073] In some implementations, the processed output vector can be used as a starting input to the computation circuit 303. For example, the processed output vector can be used in a subsequent layer in a neural network.
[0074] The unified memory 306 is configured to store input data and output data. A direct memory access controller (DMAC) 305 stores input data from the external memory in the input memory 301 and / or the unified memory 306, stores weight data from the external memory in the weight memory 302, and stores data from the unified memory 306 in the external memory.
[0075] A bus interface unit (BIU) 310 is configured to facilitate interaction between the host CPU, the DMAC, and the instruction fetch buffer 309 over a bus.
[0076] An instruction fetch buffer 309 connected to the controller 304 is configured to store instructions used by the controller 304. The controller 304 is configured to retrieve instructions buffered in the instruction fetch buffer 309 to control the working process of the arithmetic accelerator.
[0077] Typically, unified memory 306, input memory 301, weight memory 302, and instruction fetch buffer 309 are each on-chip memories. External memory is memory external to the NPU. External memory may be double data rate synchronous dynamic random access memory (DDR SDRAM), high bandwidth memory (HBM), or another readable and writable memory.
[0078] In Figures 1 to 3, the host CPU and NPU may cooperate to implement corresponding algorithms of the functions required by the first server 10 and the second server 20 in Figure 1. The operations of each module in the system shown in Figure 2 or Figure 3 may be performed by the arithmetic circuit 303 or the vector calculation unit 307.
[0079] The first server 10 and the second server 20 in Fig. 1 above can perform steps of the model training method in the embodiment of the present application. The chip shown in Fig. 4 can also be configured to perform steps of the model training method in the embodiment of the present application.
[0080] See Figure 5. The present application further provides a model training device. The model training device 400 includes one or more processors, such as processor 401 and / or processor 407, at least one communication interface, such as communication interface 404, and a communication line 402. Optionally, the communication device 400 may further include a memory 403. Hereinafter, the processor 401 will be described as an example.
[0081] The processor 401 may be a general purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), a Field Programmable Gate Array (FPGA), or one or more integrated circuits integrating multiple processing circuit functions (e.g., a CPU and an ASIC).
[0082] The communication lines 402 may include one or more paths for connecting different components.
[0083] The communication interface 404 may be a transceiver circuit and configured to communicate with another device or communication network, such as a cloud computing network, Ethernet, a radio access network (RAN), a wireless local area network (WLAN), etc. For example, the transceiver circuit may be a device such as a transceiver or a transceiver machine. Optionally, the communication interface 404 may instead be an input / output (I / O) circuit of the processor 401 and configured to implement signal input and signal output of the processor 401.
[0084] The memory 403 may be a device having a storage function. For example, the memory 403 may be a read-only memory (ROM) or another type of static storage device capable of storing static information and instructions, a random access memory (RAM) or another type of dynamic storage device capable of storing information and instructions, an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or another type of compact disc storage, an optical disc storage (including compressed optical discs, laser discs, optical discs, digital versatile discs, Blu-ray optical discs, etc.), a magnetic disc storage medium or another type of magnetic storage device, or any other medium that may be configured to carry or store predetermined program code in the form of instructions or data structures and that may be accessed by a computer. However, the memory 403 is not limited thereto. The memory 403 may exist independently and be connected to the processor 401 through a communication line 402. Of course, the memory 403 may also be integrated with the processor 401.
[0085] The memory 403 is configured to store computer-executable instructions for implementing the solutions of the present application, and the processor 401 controls the execution. The processor 401 is configured to read and execute computer instructions (e.g., for use in a CPU) or configuration files (e.g., for use in an FPGA) stored in the memory 403 to implement the model training methods provided in the embodiments of the present application.
[0086] Alternatively, optionally, in this embodiment of the present application, the processor 401 may perform processing functions related to the model training method provided in the following embodiment of the present application. The communication interface 404 is responsible for communicating with another device or another communication network, which is not particularly limited in this embodiment of the present application.
[0087] Optionally, the computer-executable instructions in this embodiment of the present application may also be referred to as application program code, which is not particularly limited in this embodiment of the present application.
[0088] During specific implementation, in one embodiment, the processor 401 may include one or more CPUs, for example, CPU 0 and CPU 1 of FIG.
[0089] During specific implementation, in one embodiment, the model training apparatus 400 may also include multiple processors, such as the processor 401 and the processor 407 of FIG. 5. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor herein may be one or more devices, circuits, and / or processing cores configured to process data (e.g., computer program instructions).
[0090] During specific implementation, in one embodiment, the model training apparatus 400 may further include an output device 405 and an input device 406. The output device 405 may communicate with the processor 401 and output information in multiple ways. For example, the output device 405 may be a touch screen, a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, a projector, a printer, etc. The input device 406 may communicate with the processor 401 and receive input from a user in multiple ways. For example, the input device 406 may be a mouse, a keyboard, a touch screen device, or a sensor device.
[0091] The model training apparatus 400 may be referred to as a training device and may be a general-purpose device or a dedicated device. For example, the training device may be a client, a desktop computer, a portable computer, a network server, a personal digital assistant (PDA), a mobile phone, a tablet computer, a wireless terminal device, an embedded device, or a device having a similar structure. Of course, the model training apparatus 400 may instead be a software and / or hardware entity provided within a single device as described above, such as a chip or a chip system configured to perform the tasks provided in the embodiments of the present application. The type of the model training apparatus 400 is not limited to this embodiment of the present application.
[0092] It should be understood that Figure 5 is merely a simplified schematic diagram of an example for ease of understanding, and the model training device may further include other components, circuits, or devices not shown in Figure 5.
[0093] In this embodiment of the present application, the model training device 400 shown in FIG. 5 is capable of executing the model training method shown in FIG.
[0094] The present application further provides a model training method applied to the system described in Fig. 1. Hereinafter, the model training method of the present application will be described with reference to Fig. 6. The method mainly includes steps S601 to S608.
[0095] S601: A first server obtains a first training model from a second server.
[0096] The first training model is obtained by performing model training on a predetermined model by the second server. The predetermined model may be a model pre-stored in the system, or may be a model determined based on an application scenario of the required first training model.
[0097] For example, in the field of neuro-linguistic programming (NPL), a user usually performs model training on some benchmark models, such as machine translation models, sentiment analysis models, etc., using a training sample set acquired by the user to obtain a required training model. The predetermined model in this embodiment of the present application is a benchmark model. If the current application scenario is a text translation scenario, the predetermined model may be a machine translation model. If the current application scenario is a scenario of analyzing the sentiment expressed by text, the predetermined model is a sentiment analysis model.
[0098] After the second server performs model training on the given model using the acquired training data to obtain a first training model, the second server stores the first training model and description information of the first training model, and distributes the first training model and description information of the first training model to the first server. The description information of the first training model includes the name, purpose, life cycle, etc. of the first training model. After the first server obtains the first training model and description information of the first training model distributed by the second server, the first server stores the received first training model and the received description information, and publishes the first training model as a service, so that a user can call the associated first training model through the service to perform model inference.
[0099] For example, the description information of the first training model includes a name of the first training model, e.g., face recognition model, a use of the first training model, e.g., face recognition, and a life cycle of the first training model, e.g., 1 hour. Optionally, the description information of the first training model includes a storage time of the first training model, e.g., 11:30am, and a storage duration of the first training model, e.g., 0.5 hours. In this case, the storage duration of the first training model is 0.5 hours.
[0100] Optionally, the first server or the second server may modify descriptive information of the first training model stored in the first server or the second server, or may delete or update the first training model based on a life cycle of the first training model.
[0101] S602: The first server inputs input data into a first training model for model inference to obtain an inference result.
[0102] After the first server receives the input data sent by the user terminal and used for model inference, the first server determines a first training model corresponding to the service through the service published by the first server.Then, the first server inputs the input data used for model inference, such as the data input by the user or the data stored locally, into the first training model for model inference to obtain an inference result, and sends the inference result to the corresponding user terminal.
[0103] For example, the first training model is a face recognition model. After step S602, the first server obtains the face recognition model sent by the second server, stores the face recognition model, and publishes the face recognition model as a face recognition service. Then, when the user terminal needs to recognize a face in an image, the user terminal sends a service call request of the face recognition service and an image to the first server. The first server determines the face recognition model corresponding to the face recognition service that needs to be called, and inputs the image into the face recognition model for model inference to determine an inference result. For example, the inference result is that the person in the image is A. Finally, the first server sends the inference result, i.e., that the person in the image is A, to the user terminal.
[0104] Based on the input data, model inference can be classified into batch inference and real-time inference. The process of inputting data acquired in real time into a training model for model inference to obtain an inference result is a real-time inference process. The process of inputting multiple pre-stored data into a training model for model inference to obtain multiple inference results is a batch inference process. There is a correspondence between multiple inference results and multiple data.
[0105] In the real-time inference process, the first server receives input data, i.e., data sent by a user terminal in real time, and a service invocation request. Then, the first server calls an inference service corresponding to the service invocation request through an application programming interface (API) based on the received service invocation request, and then inputs the input data into a first training model corresponding to the inference service for model inference to obtain an inference result.
[0106] For example, a turnstile in a face recognition scenario is used as an example. After using a camera to capture a face image, the face image and a face recognition service call request are further sent to the first server through an API between the turnstile and the first server. Then, the first server calls a corresponding face recognition model based on the face recognition service call request (e.g., a call request in an http format), recognizes the face image using the face recognition model, and sends the recognition result to the turnstile, so that the turnstile can be opened or kept closed based on the recognition result.
[0107] In the batch inference process, the first server receives input data and a service invocation request. The input data is pre-stored input data or path information of the pre-stored input data (e.g., a network file system (NFS) address, a file transfer protocol (FTP) address, etc.). Then, the first server obtains the pre-stored input data according to the path information, invokes the corresponding first training model according to the service invocation request, and inputs the obtained pre-stored data into the first training model for model inference to obtain an inference result.
[0108] For example, a face recognition scenario is used as an example. A user terminal sends a face recognition service invocation request and path information (e.g., an NFS address) of input data to a first server. Based on the NFS address, the first server obtains images stored in a folder pointed to by the address and invokes a face recognition model corresponding to the face recognition service. For example, the folder stores 10 images. The first server separately inputs the 10 images into the face recognition model for model inference to obtain 10 inference results.
[0109] After the first server inputs the input data into the first training model for model inference and obtains the inference result, the first server stores the input data and the inference result. Optionally, the first server may further transmit the obtained input data and the obtained inference result to the second server, so that the second server can retrain the first predetermined model based on the received input data and the received inference result.
[0110] S603: The first server evaluates the first training model based on the inference result and the model evaluation metric to obtain an evaluation result of the model evaluation metric.
[0111] The model evaluation metric includes at least one of the accuracy of the inference result, the precision of the inference result, the recall of the inference result, the F1-score of the inference result, and the area under the receiver operating characteristic ROC curve AUC of the inference result. Optionally, the model evaluation metric may further include a mean absolute error (MAE), a mean square error (MSE), etc. Typically, the model evaluation metrics such as accuracy, precision, recall, F1-score, and AUC are mainly used to evaluate binary classification models, and the model evaluation metrics such as MAE and MSE are mainly used to evaluate regression models (e.g., face recognition models).
[0112] Optionally, the model evaluation metric used to evaluate the first training model is determined based on a current application scenario, in particular, based on the use of the first training model.
[0113] For example, in the current application scenario, if a better evaluation effect can be obtained by using the recall of the inference results to evaluate the inference effect of the first training model compared with evaluating the inference effect of the first training model using another model evaluation metric, the recall of the inference results can be set as the model evaluation metric used to evaluate the inference effect of the first training model.
[0114] For example, in an application scenario, a user may instead set the model evaluation metrics used to evaluate the first training model to the precision of the inference result, the recall of the inference result, and the F1-Score of the inference result based on the requirements of the application scenario.
[0115] For example, the first training model is a binary classification model. Among 100 cards, 60 cards have odd numbers, i.e., there are 60 positive samples, and 40 cards have even numbers, i.e., there are 40 negative samples. The numbers of the 100 cards are predicted using the first training model. In other words, 100 inferences are performed and 100 inference results are generated. In the positive samples, the inference results corresponding to 40 cards are correct and 20 inference results are incorrect. In the negative samples, the inference results corresponding to 30 cards are correct and 10 inference results are incorrect. The number of positive samples predicted as positive samples TP is 40, the number of positive samples predicted as negative samples FN is 20, the number of negative samples predicted as positive samples FP is 10, and the number of negative samples predicted as negative samples TN is 30. Then, based on the evaluation rules of the model evaluation metrics, it can be determined that the accuracy of the inference result is (TP+TN) / (TP+FN+FP+TN), i.e., 70%, the precision of the inference result is TP / (TP+FP), i.e., 80%, the recall of the inference result is TP / (TP+FN), i.e., 2 / 3, and the F1-Score of the inference result is the harmonic mean of the precision and recall, 2Presicion*Recall / (Presicion+Recall), i.e., 8 / 11. The ROC and AUC are determined using x=FP / (FP+TN) as the horizontal coordinate and y=TP / (TP+FN) as the vertical coordinate, with the values of x and y being [0,1]. For example, in the ROC and AUC shown in FIG. 7, the coordinates of point A on the ROC are (1 / 4,2 / 3).
[0116] Optionally, model evaluation may be periodically performed on the first training model. For example, model evaluation is performed at a predetermined time interval using inference results of real-time inference within a first predetermined time interval to obtain evaluation results of model evaluation metrics of the first training model. Then, model evaluation is performed again based on inference results of real-time inference within a second predetermined time interval to obtain evaluation results of model evaluation metrics of the first training model again.
[0117] For example, real-time inference is performed 20 times between 10:00am and 12:00am for the first training model. For example, the predetermined time interval is 40 minutes. Model evaluation is performed once using the inference result of real-time inference between 10:00am and 10:40am to obtain an evaluation result of the model evaluation metric of the first training model. Then, model evaluation is performed using the inference result of real-time inference between 10:40am and 11:20am to obtain again an evaluation result of the model evaluation metric of the first training model. Finally, model evaluation is performed using the inference result of real-time inference between 11:20am and 12:00am to obtain again an evaluation result of the model evaluation metric of the first training model.
[0118] Optionally, the evaluation is performed based on a predetermined frequency interval using input data and inference results corresponding to the input data of batch inference or real-time inference to obtain evaluation results of model evaluation metrics of the first training model.
[0119] For example, the predetermined frequency interval is 1. If the batch inferences are performed 5 times, A, B, C, D, and E, for the first training model, the model evaluation is performed using the inference results of the batch inferences A, C, and E separately to obtain three groups of evaluation results of the model evaluation metrics of the first training model.
[0120] Optionally, before step S603 is executed, an evaluation policy of the first training model needs to be configured, which includes configuring at least one model evaluation metric used to evaluate the training model, an evaluation rule for the model evaluation metric, a predetermined threshold corresponding to the model evaluation metric, a selection rule for input data and inference results used to evaluate the model evaluation metric, and a retraining trigger policy for the training model. For a detailed description of the evaluation policy, please refer to the above description. The details will not be described again in this specification. Optionally, the first server may further configure a storage path for the input data and the inference result.
[0121] S604: If the evaluation result of at least one model evaluation metric does not exceed a predetermined threshold corresponding to the model evaluation metric, the first server sends a retraining instruction for the first training model.
[0122] The retraining instructions for the first training model instruct the second server to perform model retraining on the first training model.
[0123] Optionally, if the evaluation result of at least one model evaluation metric does not exceed a predetermined threshold corresponding to the model evaluation metric, the first server determines that the first training model has insufficient inference effect, and sends a retraining command for the first training model to the second server. If all the evaluation results of the model evaluation metric exceed the predetermined threshold corresponding to the evaluation result, the first server determines that the first training model has good inference effect and does not need to be updated. In this case, the first server does not send a retraining command for the first training model to the second server. The predetermined threshold corresponding to the evaluation result of the model evaluation metric may be preset based on a current application scenario, or may be preset by a user.
[0124] The model evaluation metrics include at least one of the accuracy of the inference result, the precision of the inference result, the recall of the inference result, the F1-score of the inference result, and the area under the ROC curve AUC of the inference result. If the accuracy of the inference result does not exceed a predetermined accuracy threshold, and / or if the precision of the inference result does not exceed a predetermined accuracy threshold, and / or if the recall of the inference result does not exceed a predetermined accuracy threshold, and / or if the AUC of the inference result does not exceed a predetermined AUC threshold, and / or if the F1-score of the inference result does not exceed a predetermined F1-score threshold, the first server determines that the first training model has insufficient inference effectiveness and sends a retraining instruction for the first training model to the second server. If the accuracy of the inference result exceeds a predetermined accuracy threshold, the precision of the inference result exceeds a predetermined precision threshold, the recall of the inference result exceeds a predetermined precision threshold, the AUC of the inference result exceeds a predetermined AUC threshold, and the F1-Score of the inference result does not exceed a predetermined F1-Score threshold, the first server determines that the first training model has a good inference effect, and does not send a retraining command for the first training model to the second server.
[0125] Optionally, in another possible implementation form, if all the evaluation results of the model evaluation metrics do not exceed a predetermined threshold corresponding to the evaluation results, the first server determines that the first training model has insufficient inference effect, and sends a retraining command for the first training model to the second server. If the evaluation results of at least one model evaluation metric exceed a predetermined threshold corresponding to the model evaluation metric, the first server determines that the first training model has good inference effect and does not need to be updated. In this case, the first server does not send a retraining command for the first training model to the second server.
[0126] Optionally, in a possible implementation, after the model evaluation metric used to evaluate the first training model is determined based on the requirements of the application scenario, and step S604 is executed, the user may further configure a trigger condition for the first server to send a retraining command to the second server based on the requirements of the application scenario. When the evaluation result of the model evaluation metric used to evaluate the first training model satisfies the trigger condition, the first server sends a retraining command for the first training model to the second server. It can be understood that the first server sends a retraining command for the first training model, that is, retraining for the first training model is enabled.
[0127] For example, in a current service scenario, a user sets three model evaluation metrics used to evaluate a first training model based on the requirements of the service scenario. The three model evaluation metrics are the accuracy of inference result, the recall of inference result, and the F1-Score of inference result, respectively. Then, based on the requirements of the service scenario, the user can determine that the conditions for triggering the first server to send a retraining instruction to the second server are as follows: If the evaluation result of at least one of the accuracy of inference result and the F1-Score of inference result does not exceed a predetermined threshold corresponding to the model evaluation metric, and the evaluation result of the recall of inference result exceeds a predetermined threshold corresponding to the model evaluation metric, the first server sends a retraining instruction for the first training model to the second server. Assume that in the first training model, the evaluation result of the accuracy of inference result is a, the evaluation result of the F1-Score of inference result is b, the evaluation result of the recall of inference result is c, and the predetermined thresholds corresponding to a, b, and c are A, B, and C, respectively. In this case, if a≦A and c≦C, the first server sends a retraining command for the first training model to the second server, regardless of whether b is greater than B. If b≦B and c≦C, the first server sends a retraining command for the first training model to the second server, regardless of whether a is greater than A. If a>A and b>B, the first server does not send a retraining command for the first training model to the second server, regardless of whether c is greater than C. If c>C, the first server does not send a retraining command for the first training model to the second server, regardless of whether a is greater than A and b is greater than B.
[0128] It should be noted that through the above process, in any service scenario, the first server periodically or non-periodically obtains the inference results used for model evaluation, evaluates the inference effect of the training model based on the pre-configured evaluation policy of the training model and the pre-configured retraining trigger policy of the training model, and then determines whether to trigger retraining for the training model, monitors the inference effect of the training model, and decides to retrain the training model with insufficient inference effect in a timely manner, thereby ensuring the performance of the service system.
[0129] S605: The second server obtains the input data and the inference result from the first server.
[0130] The input data is data input by the first server into a first training model for model inference, and the inference result is an inference result obtained after the first server inputs the input data into the first training model for model inference.
[0131] In response to the retraining command received by the second server from the first server, the second server sends to the first server an acquisition request for input data and an inference result corresponding to the input data. The acquisition request is used to request the first server to send to the second server the input data to be input into the first training model for model inference and the inference result corresponding to the input data. Then, the first server sends data to the second server in response to the acquisition request. The data includes the input data to be input into the first training model by the first server and the inference result obtained by performing model inference after the input data is input into the first training model.
[0132] Optionally, in another possible implementation, when the first server sends the retraining command, the first server sends the input data and the inference result corresponding to the input data to the second server.
[0133] Optionally, in another possible implementation form, after step S602, the second server may first execute step S605, and then execute steps S603 and S604. In this case, step S605 may be executed periodically. The second server periodically obtains the input data used for model evaluation and the inference result corresponding to the input data from the first server based on a predetermined time interval or a predetermined frequency interval. In other words, the first server may periodically transmit the input data used for model evaluation and the inference result corresponding to the input data to the second server based on a predetermined time interval or a predetermined frequency interval.
[0134] It should be noted that, compared with periodically executing step S605, after step S604, the second server obtains the input data and the inference result used for model evaluation to retrain the first training model in response to the received retraining command, so that when the input data and the inference result of the first training model are transmitted to the first server, the resources used for data transmission can be saved.
[0135] Optionally, in another possible implementation form, the first server and the second server may directly execute step S605 after step S602 instead of executing steps S603 and S604, and periodically or aperiodically send a retraining instruction to the second server, so that the second server uses the input data and the inference result corresponding to the input data to retrain the first training model based on the retraining instruction to determine a second training model.
[0136] It should be noted that in this technical solution, in order to achieve a good inference effect, the model evaluation is not performed, and the second server is directly instructed to perform model retraining, so that the retrained model matches well with the input data of the current environment. However, the model may be retrained too frequently, or the model may be retrained when the inference effect of the existing training model is good. This will result in a heavy computation load and unnecessary consumption of software and hardware. In addition, if the training model used for model inference in the service system is changed too frequently, the service system may become unstable and the service system performance may be affected. After the model evaluation is performed, a retraining command is sent to the second server based on the inference effect of the model, so that the model can be retrained when necessary. This can sufficiently reduce the waste of software and hardware resources such as bandwidth, and ensure the stable operation of the service system.
[0137] S606: The second server determines a retraining sample set based on the input data and the inference result.
[0138] In response to the received retraining command for the first training model, the second server adds the input data of the first training model and the inference results corresponding to the input data acquired by the second server from the first server to a retraining sample set used for model retraining. The retraining sample set stores the training data used for model retraining.
[0139] Optionally, after the second server obtains the input data and the inference results corresponding to the input data, the second server first annotates the input data to obtain annotated input data, and then adds the annotated input data and the inference results to a retraining sample set to obtain a retraining sample set used for model retraining.
[0140] Optionally, after the second server obtains the input data and the inference result corresponding to the input data, the second server screens or modifies the input data and the inference result based on whether the inference result is correct. For an accurate inference result, the second server adds the inference result and the input data corresponding to the inference result to the retraining sample set. Alternatively, after the input data corresponding to the accurate inference result is annotated, the annotated input data and the inference result corresponding to the input data are stored in the retraining sample set. For an inaccurate inference result, the second server deletes the inference result and the input data corresponding to the inference result, or the second server modifies the inaccurate inference result to an accurate inference result and adds the modified inference result and the input data (or the annotated input data) to the retraining sample set to obtain a retraining sample set used for model retraining.
[0141] S607: The second server performs model retraining on the first training model based on the retraining sample set to determine a second training model.
[0142] In response to the retraining command received by the second server, the second server performs model retraining on the first training model using the retraining sample set determined by the second server in step S606 to obtain a second training model. Then, the second server replaces the first training model stored in the second server with the second training model. Optionally, the second server further stores description information of the second training model. For a specific description of the description information, please refer to the above content. Details will not be described again in this specification.
[0143] S608: The second server sends the second training model to the first server.
[0144] The second server delivers to the first server the retraining sample set determined by the second server in step S606, the second training model obtained by performing model retraining on the first training model, and description information of the second training model. The first server replaces the first training model stored in the first server with the second training model, and stores the description information of the second training model. Then, the first server further publishes the second training model as a service, so that a user can call the second training model through the service to perform model inference. Optionally, the first server deletes the service corresponding to the first training model, or replaces the service corresponding to the first training model with the service corresponding to the second training model.
[0145] In the above process, the second server re-trains the first training model using the accurate inference result and the input data corresponding to the accurate inference result to obtain a second training model, which successfully improves the inference effect of the second training model, thereby ensuring the performance of the service system in which the second training model is deployed.
[0146] Optionally, the retraining instruction sent by the first server to the second server may be specific to a predetermined model, so that the second server performs model retraining on the predetermined model based on the retraining sample set determined in step S606 to obtain a second training model. Then, the second server replaces the first training model stored in the second server with the second training model, and stores the description information of the second training model. For the description of the predetermined model, please refer to the above content. Details will not be described again in this specification.
[0147] It should be noted that, compared with the second training model obtained by retraining the first training model based on the retraining sample set determined in step S606, the second training model determined by performing model retraining for a given model based on the retraining sample set determined in step S606 is more applicable to the current scenario, but has poor generalization ability. In other words, the inference effect cannot be guaranteed when previous data is used as input data for the second training model.
[0148] According to the above embodiment, the present application provides a model training method applied to a hybrid cloud scenario, which can evaluate the model evaluation metric of the first training model and monitor the inference effect of the first training model to determine the inference effect of the first training model. Thus, when the first training model has insufficient inference effect, a retraining command used for model retraining is sent to the second server, so that the second server can timely retrain the training model based on the inference effect of the training model to determine a training model with better inference effect, thereby improving the accuracy of the inference result and ensuring the performance of the service system.
[0149] As shown in Figure 8, the present application further provides a model training apparatus applied to a system of a first server and a second server. The first server is located in a private cloud and is used for model inference, and the second server is located in a public cloud and is used for model training. The apparatus functioning as the first server may be configured to execute the steps performed by the first server in the embodiments of the aforementioned method. The apparatus includes an obtaining unit 801, an inference unit 802, an evaluation unit 803, and a sending unit 804.
[0150] The obtaining unit 801 is configured to obtain a first training model from a second server.
[0151] The inference unit 802 is configured to input input data into a first training model for model inference to obtain an inference result.
[0152] The evaluation unit 803 is configured to evaluate the first training model based on the inference result and the model evaluation metric to obtain an evaluation result of the model evaluation metric.
[0153] The model evaluation metrics include at least one of an accuracy of the inference result, a precision of the inference result, a recall of the inference result, an F1-score of the inference result, and an area under the receiver operating characteristic ROC curve AUC of the inference result.
[0154] The sending unit 804 is configured to send a retraining instruction for the first training model to the second server when the evaluation result of the at least one model evaluation metric does not exceed a predetermined threshold corresponding to the model evaluation metric. The retraining instruction instructs the second server to retrain the first training model.
[0155] Optionally, the sending unit 804 is further configured to send the input data and the inference result to a second server. The input data and the inference result are used to retrain the first training model.
[0156] Optionally, the sending unit 804 is further configured to skip sending a retraining instruction for the first training model to the second server if all evaluation results of the model evaluation metrics exceed a predetermined threshold corresponding to the model evaluation metric.
[0157] As shown in Figure 9, the present application further provides a model training apparatus applied to a system of a first server and a second server. The first server is located in a private cloud and is used for model inference, and the second server is located in a public cloud and is used for model training. The apparatus functioning as the second server may be configured to perform the steps performed by the second server in the embodiments of the aforementioned method. The apparatus includes an obtaining unit 901, a determining unit 902, a sending unit 903, and a processing unit 904.
[0158] The acquiring unit 901 is configured to acquire retraining instructions, input data, and inference results for the first training model from the first server. The retraining instructions instruct the second server to retrain the first training model, the input data is data input by the first server into the first training model for model inference, and the inference result is a result obtained after the first server inputs the input data into the first training model for model inference.
[0159] The acquiring unit 901 is specifically configured to acquire input data and inference results in response to a retraining command received from the first server.
[0160] The determining unit 902 is configured to determine a retraining sample set based on the input data and the inference result.
[0161] The processing unit 904 is configured to, if the inference result is an accurate inference result, retain the inference result and the input data corresponding to the inference result, by the second server, or, if the inference result is an inaccurate inference result, delete the inference result and the input data corresponding to the inference result, by the second server, or replace the inference result with the accurate inference result corresponding to the input data, by the second server.
[0162] The determining unit 902 is configured to annotate the input data to obtain annotated input data, and store the annotated input data and the inference results in a re-training sample set.
[0163] The determining unit 902 is further configured to retrain the first training model based on the retraining sample set to determine a second training model, which is used to replace the first training model.
[0164] The sending unit 903 is configured to send the second training model to the first server.
[0165] An embodiment of the present application further provides a computer-readable storage medium, which stores instructions, which when executed by a processor, perform the method in the aforementioned method embodiments.
[0166] An embodiment of the present application further provides a computer program product comprising instructions, which, when executed by a processor in a computer, enable the computer to perform the method in the method embodiments described above.
[0167] An embodiment of the present application further provides a chip. The chip includes a transceiver unit and a processing unit. The transceiver unit may be an input / output circuit or a communication interface. The processing unit is a processor, a microprocessor, or an integrated circuit integrated on the chip. The chip can execute the method in the above-mentioned method embodiments.
[0168] For convenience and simplicity of description, the detailed operation processes of the aforementioned systems, devices, and units shall refer to the corresponding processes of the aforementioned method embodiments, and it can be clearly understood by those skilled in the art that the details will not be described again here.
[0169] The above-mentioned embodiments may be implemented in whole or in part using software, hardware, firmware, or any combination thereof. When the embodiments are implemented using a software program, the embodiments may appear in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded into a computer and executed, the procedures or functions according to the embodiments of the present application are generated in whole or in part.
[0170] The computer may be a general-purpose computer, a special-purpose computer, a computer network, or any other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from a computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center in a wired (e.g., coaxial cable, optical fiber, or digital subscriber line (DSL)) manner or wireless (e.g., infrared, radio, or microwave) manner. The computer-readable storage medium may be any available medium accessible by a computer, or a data storage device, such as a server or data center, that incorporates one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a DVD), a semiconductor medium (e.g., a solid state disk (SSD)), or the like.
[0171] Based on the above description of the embodiments, those skilled in the art can clearly understand that for convenience and simple description, the above division into functional modules is only used as an example for explanation. In practical application, the above functions can be allocated to different functional modules for realization based on requirements, that is, the internal structure of the device is divided into different functional modules for realizing all or part of the above functions.
[0172] In some embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be realized in other ways. For example, the described apparatus embodiments are merely examples. For example, the division of modules or units is merely a division of logical functions, and there may be other divisions in actual implementation. For example, multiple units or components may be combined or integrated into another apparatus, and some features may be ignored or not implemented. In addition, the shown or described mutual couplings or direct couplings or communication connections may be implemented through some interfaces. Indirect couplings or communication connections between apparatuses or units may be realized in electrical, mechanical, or other forms.
[0173] The units described as individual components may or may not be physically separated, and the components shown as units may be located in one place or distributed in multiple different places. In the application process, some or all of the units may be selected according to the practical requirements for achieving the objectives of the solutions of the embodiments.
[0174] In addition, the functional units in the embodiments of the present application may be integrated into one processing unit, or each of the units may exist physically alone, or two or more units may be integrated into one unit. The integrated unit may be implemented in the form of hardware or may be realized in the form of a software functional unit.
[0175] When the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, the integrated unit may be stored in a computer-readable storage medium. Based on such understanding, the technical solutions of the embodiments of the present application may be essentially, or a part of the contribution to the current technology, or a part of the technical solutions may be realized in the form of a software product. The computer software product is stored in a storage medium and includes some instructions for instructing a computer device (which may be a personal computer, a server, a network device, a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the method described in the embodiments of the present application. The storage medium includes any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disk, etc.
[0176] The above description is only a specific implementation form of the present application, and is not intended to limit the protection scope of the present application. Any modification or replacement within the technical scope disclosed in this application shall be within the protection scope of the present application. [Explanation of symbols]
[0177] 10 First Server 20 Second Server 101 Data Collection Module 102 Model Training Module 103 First Model Storage Module 104 Second Model Storage Module 105 Model Inference Management Module 201 Model Retraining Management Module 202 Model Evaluation Module 2021 Evaluation Policy Configuration Module 2022 Data Collection Module 2023 Model Evaluation Metrics Assessment Module 300 Neural Network Processing Units 301 Input Memory 302 Weight Memory 303 Arithmetic circuit 304 Controller 305 Storage Unit Access Controller 306 Unified Memory 307 Vector Calculation Unit 307 308 Accumulator 309 Instruction Fetch Buffer 310 Bus Interface Unit 400 Model Training Device 401, 407 processors 402 Communication Line 403 Memory 404 Communication Interface 405 Output Device 406 Input Devices 801, 901 Acquired Units 802 Inference Unit 803 Evaluation Unit 804, 903 Transmitter Unit 902 Decision Unit 904 Processing Unit
Claims
1. 1. A model training method applied to a system including a first server and a second server, the first server being located in a private cloud and used for model inference, and the second server being located in a public cloud and used for model training, the method comprising: obtaining, by the first server, a first training model from the second server; inputting input data into the first training model for model inference by the first server to obtain an inference result; evaluating, by the first server, the first training model based on the inference result and model evaluation metrics to obtain evaluation results of the model evaluation metrics, where the model evaluation metrics include an accuracy of the inference result, a precision of the inference result, a recall of the inference result, an F1 score of the inference result, and an area under a receiver operating characteristic (ROC) curve (AUC) of the inference result; sending, by the first server, a retraining instruction for the first training model to the second server if an evaluation result of at least one model evaluation metric is equal to or less than a predetermined threshold corresponding to the model evaluation metric, the retraining instruction instructing the second server to retrain the first training model; receiving, after sending the retraining command to the second server, a fetch request from the second server to request transmission, by the first server, of the input data and the inference result corresponding to the input data; transmitting, by the first server in response to the acquisition request, the input data and the inference result corresponding to the input data to the second server, wherein the input data and the inference result corresponding to the input data are used to retrain the first training model; obtaining, by the second server, retraining instructions for a first training model from the first server, the retraining instructions instructing the second server to retrain the first training model; sending, by the second server, an acquisition request to request the first server to transmit input data and an inference result corresponding to the input data in response to the retraining command, wherein the input data is data input by the first server to the first training model, and the inference result corresponding to the input data is a result obtained after the first server inputs the input data into the first training model for model inference; after transmitting the acquisition request to the first server, acquiring, by the second server, the input data and the inference result corresponding to the input data from the first server; determining, by the second server, a retraining sample set based on the input data and the inference result; retraining, by the second server, the first training model based on the retraining sample set to determine a second training model, the second training model being used to replace the first training model; transmitting, by the second server, the second training model to the first server; Including, The step of determining, by the second server, a retraining sample set based on the input data and the inference result includes: if the inference result is an accurate inference result, storing, by the second server, the inference result and input data corresponding to the inference result; or If the inference result is an inaccurate inference result, deleting, by the second server, the inference result and input data corresponding to the inference result, or replacing, by the second server, the inference result with an accurate inference result corresponding to the input data. The model training method further comprises:
2. 2. The method of claim 1, further comprising: skipping, by the first server, sending retraining instructions for the first training model to the second server if all evaluation results of a model evaluation metric exceed a predetermined threshold corresponding to the model evaluation metric.
3. 1. A model training method applied to a system including a first server and a second server, the first server being located in a private cloud and used for model inference, and the second server being located in a public cloud and used for model training, the method comprising: obtaining, by the second server, retraining instructions for a first training model from the first server, the retraining instructions instructing the second server to retrain the first training model; sending, by the second server, an acquisition request to request the first server to transmit input data and an inference result corresponding to the input data in response to the retraining command, wherein the input data is data input by the first server to the first training model, and the inference result corresponding to the input data is a result obtained after the first server inputs the input data into the first training model for model inference; after transmitting the acquisition request to the first server, acquiring, by the second server, the input data and the inference result corresponding to the input data from the first server; determining, by the second server, a retraining sample set based on the input data and the inference result; retraining, by the second server, the first training model based on the retraining sample set to determine a second training model, the second training model being used to replace the first training model; transmitting, by the second server, the second training model to the first server; Including, The step of determining, by the second server, a retraining sample set based on the input data and the inference result includes: if the inference result is an accurate inference result, storing, by the second server, the inference result and input data corresponding to the inference result; or If the inference result is an inaccurate inference result, deleting, by the second server, the inference result and input data corresponding to the inference result, or replacing, by the second server, the inference result with an accurate inference result corresponding to the input data. The model training method further comprises:
4. Specifically, the step of determining a retraining sample set based on the input data and the inference result by the second server includes: annotating, by the second server, the input data to obtain annotated input data; storing, by the second server, the annotated input data and the inference results in the retraining sample set; The method of claim 3, further comprising:
5. A system including a first server and a second server, the first server being located in a private cloud and used for model inference, and the second server being located in a public cloud and used for model training; The first server comprises: an acquiring unit configured to acquire a first training model from the second server; an inference unit configured to input input data to the first training model for model inference to obtain an inference result; an evaluation unit configured to evaluate the first training model based on the inference result and a model evaluation metric to obtain an evaluation result of the model evaluation metric, the model evaluation metric including: an accuracy of the inference result, a precision of the inference result, a recall of the inference result, an F1 score of the inference result, and an area under a receiver operating characteristic (ROC) curve (AUC) of the inference result; a first sending unit configured to send a retraining command for the first training model to the second server when an evaluation result of at least one model evaluation metric is equal to or less than a predetermined threshold corresponding to the model evaluation metric, the retraining command instructing the second server to retrain the first training model; and a receiving unit configured to receive, after transmitting the retraining command to the second server, an acquisition request from the second server to request transmission of the input data and the inference result corresponding to the input data; a second sending unit configured to send the input data and the inference result corresponding to the input data to the second server in response to the acquisition request, wherein the input data and the inference result corresponding to the input data are used to retrain the first training model; and Including, The second server, a first obtaining unit configured to obtain a retraining instruction for a first training model from the first server, the retraining instruction instructing the second server to retrain the first training model; and a first sending unit configured to send an acquisition request to the first server in response to the retraining command to request the first server to send input data and an inference result corresponding to the input data, the input data being data input by the first server to the first training model, and the inference result corresponding to the input data being a result obtained after the first server inputs the input data into the first training model for model inference; and a second acquiring unit configured to acquire, after sending the acquiring request to the first server, the input data and the inference result corresponding to the input data from the first server; a determining unit configured to determine a retraining sample set based on the input data and the inference result, The determining unit is further configured to retrain the first training model based on the retraining sample set to determine a second training model, the second training model being used to replace the first training model; and a second sending unit configured to send the second training model to the first server; Including, The determination unit is configured to reserve, by the second server, the inference result and input data corresponding to the inference result when the inference result is an accurate inference result; The determination unit is further configured to, if the inference result is an inaccurate inference result, delete, by the second server, the inference result and input data corresponding to the inference result, or replace, by the second server, the inference result with an accurate inference result corresponding to the input data.
6. The sending unit is further configured to skip sending retraining instructions for the first training model to the second server if all evaluation results of model evaluation metrics exceed a predetermined threshold corresponding to the model evaluation metric. The system of claim 5.
7. A model training apparatus applied to a system including a first server and a second server, the first server being located in a private cloud and used for model inference, the second server being located in a public cloud and used for model training, the apparatus functioning as the second server comprising: a first obtaining unit configured to obtain a retraining instruction for a first training model from the first server, the retraining instruction instructing the second server to retrain the first training model; and a first sending unit configured to send an acquisition request to the first server in response to the retraining command to request the first server to send input data and an inference result corresponding to the input data, the input data being data input by the first server to the first training model, and the inference result corresponding to the input data being a result obtained after the first server inputs the input data into the first training model for model inference; and a second acquiring unit configured to acquire, after sending the acquiring request to the first server, the input data and the inference result corresponding to the input data from the first server; a determining unit configured to determine a retraining sample set based on the input data and the inference result, The determining unit is further configured to retrain the first training model based on the retraining sample set to determine a second training model, the second training model being used to replace the first training model; and a second sending unit configured to send the second training model to the first server; Including, The determination unit is configured to reserve, by the second server, the inference result and input data corresponding to the inference result when the inference result is an accurate inference result; The model training apparatus, wherein the determination unit is further configured to, if the inference result is an inaccurate inference result, delete, by the second server, the inference result and input data corresponding to the inference result, or replace, by the second server, the inference result with an accurate inference result corresponding to the input data.
8. The determining unit is specifically configured to annotate the input data to obtain annotated input data; The decision unit is specifically further configured to store the annotated input data and the inference results in the retraining sample set. A model training apparatus according to claim 7.
9. 5. A model training apparatus comprising a processor, a memory, and a communication interface, the communication interface configured to communicate with another device or a communication network, the memory configured to store one or more programs, the one or more programs comprising computer-executable instructions, and wherein, when the apparatus is operated, the processor executes the computer-executable instructions stored in the memory to enable the apparatus to perform the model training method of claim 3 or 4.
10. 5. A computer-readable storage medium having stored thereon program instructions which, when executed by a processor, perform the model training method of claim 3 or 4.
11. 5. A computer program comprising instructions, which when executed by a processor in a computer, enables the computer to carry out the model training method according to claim 3 or 4.
Citation Information
Patent Citations
Characteristic estimation device
JP2012208710A
Distributed machine learning system, apparatus, and method
JP2019526851A
On-Device Machine Learning Platform
US20190050746A1
Method, apparatus, and system for in-vehicle data selection for feature detection model creation and maintenance
US20190295003A1
Learning model creation assistance device, learning model creation assistance method, and computer-readable recording medium
WO2020003532A1
