Data reasoning method, model training method and device
By dynamically obtaining and using candidate inference models trained based on the latest data in heterogeneous computing power systems, the problem of model inference accuracy lag in training data in heterogeneous computing power systems is solved, and the accuracy and real-time nature of inference are improved.
Patent Information
- Application Number
- PCT/CN2024/090184
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-06-30
- Filing Date
- 2024-04-26
- Publication Date
- 2025-01-02
AI Technical Summary
In model inference and training of existing heterogeneous computing power systems, the model used by general-purpose chip online inference is a model trained offline by AI chips, which affects the accuracy of inference and the model training data lags behind real-time data.
By dynamically obtaining newer data in computing devices for model training, and using models trained based on newer sampled data for inference to ensure the effectiveness of the target inference model, thereby improving the inference accuracy. The specific method includes in a heterogeneous computing power system, the computing device acquires real-time data at each inference moment, and trains the candidate inference model based on the current moment and the sample data in the previous period, and selects the target with a time difference less than the preset threshold. The inference model performs inference.
It realizes the accuracy and effectiveness of model inference in heterogeneous computing power systems, ensures the real-time and accuracy of the inference model, and avoids the reduction in accuracy caused by lag in training data.
Smart Images

Figure CN2024090184_02012025_PF_FP_ABST
Abstract
Description
A data inference method, model training method and device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of the People's Republic of China on June 30, 2023, with application number 202310809417.1 and invention name “A data inference method, model training method and device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0003] The present application relates to the field of computer technology, and in particular to a data inference method, a model training method and a device. Background Art
[0004] With the continuous development of high-performance computing (HPC) and related applications, the demand for computing power has continued to rise. Relying solely on processors of a single computing type and architecture cannot meet existing computing power requirements. Heterogeneous computing refers to parallel computing performed on heterogeneous computing systems. Heterogeneous computing systems can include computing units with different instruction sets and architectures. Heterogeneous computing is widely used in cloud data centers, edge computing scenarios, and other scenarios. For example, heterogeneous computing can coordinate the computing power of multiple hardware such as CPUs, GPUs, FPGAs, and ASICs to meet application requirements in different scenarios, improve system computing power, reduce costs, and maximize computing efficiency. For example, with the development of artificial intelligence (AI) technology, heterogeneous computing power solutions and application scenarios that integrate HPC and AI have been further expanded.
[0005] A common heterogeneous computing system includes general-purpose chips and AI chips. General-purpose chips, such as CPUs, are generally used in HPC computing scenarios. AI chips, such as graphics processing units (GPUs), field programmable gate arrays (FPGAs), and application-specific integrated circuits (ASICs), are acceleration chips that are typically used in AI computing scenarios. When heterogeneous computing power is applied to model reasoning and training scenarios, because model training requires a large amount of AI computing resources and the reasoning process needs to be fast and stable, a common processing mode is to use AI chips for offline model training and general-purpose chips for online reasoning based on the trained model.
[0006] When performing model inference and training based on the above, the model used for online inference on general-purpose chips is the model trained offline by the AI chip. Reasoning based on this model will affect the inference accuracy.
[0007] Summary of the Invention
[0008] This application provides a data inference method, a model training method and a device, which are used to provide an accurate model training method and inference method, thereby improving the inference accuracy.
[0009] In the first aspect, the present application provides a data inference method, which can be executed by a computing device or a processing chip in a computing device, or by a computing device cluster. In this method, the computing device obtains first data, which is data obtained at the first moment; obtains a target inference model from at least one candidate inference model, and the at least one candidate inference model corresponds to different sampling moments, and the first sampling moment corresponding to the target inference model is before the first moment, and the time difference between the first moment and the target inference model is less than a first preset threshold; the target training model is obtained by training a pre-trained model based on a first training data set, and the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time period before the first sampling moment; the first data is input into the target inference model to obtain a first inference result.
[0010] In the above method, the target inference model used by the computing device during inference is a model trained based on newer sampling data, thereby ensuring the validity of the target inference model and improving the inference accuracy.
[0011] In one possible design, obtaining a target inference model from at least one candidate inference model includes: determining at least two target candidate inference models from at least one candidate inference model, wherein the sampling moments corresponding to each of the target candidate inference models are both before the first moment, and the time difference between each of the sampling moments and the first moment is less than the first preset threshold; obtaining the target inference model from the at least two target candidate inference models.
[0012] Acquiring a target reasoning model from the at least two target candidate reasoning models includes but is not limited to the following three methods.
[0013] The first way: the model number corresponding to the target inference model and the time sequence number corresponding to the first time can meet the following conditions: j=i-1
[0014] The j is the model serial number corresponding to the target inference model after the at least one candidate inference model is sequentially assigned a model serial number from 0 to p in accordance with the order of the sampling moments corresponding to the at least one candidate inference model from front to back. For example, the candidate inference models trained at each sampling moment are respectively assigned model serial numbers 1, 2, 3...p, etc. in accordance with the order of the sampling moments from front to back, and p is a positive integer; the i is the moment serial number corresponding to the first moment after the multiple inference moments are sequentially assigned a moment serial number from 0 to q in accordance with the order of the multiple inference moments from front to back. For example, the moment serial numbers 1, 2, 3...q, etc. are respectively assigned to each inference moment in accordance with the order of the inference moments from front to back, and q is a positive integer; and after the multiple sampling moments are sequentially assigned a moment serial number from 0 to w in accordance with the order of the sampling moments corresponding to the at least one candidate inference model from front to back, the time difference between the inference moment and the sampling moment with the same serial number is less than the second preset threshold, and w is a positive integer. For example, according to the order of sampling moments from front to back, each sampling moment is assigned a time sequence number 1, 2, 3...w, etc., then the sampling moment and the inference moment with the same sequence number 5 can be the same time, or a similar time, that is, the sampling moment and the inference moment with the same sequence number 5 are theoretically relatively close time points.
[0015] Through this design, when the training duration is less than or equal to a sampling interval, when an inference moment arrives, the computing device has completed the model training based on the previous moment of the inference moment or a moment relatively close to the previous moment, then the computing device can directly obtain the candidate inference model trained based on the previous moment, or the candidate inference model trained based on a moment relatively close to the previous moment as the target inference model.
[0016] In a second manner, the model number corresponding to the target inference model and the time sequence number corresponding to the first time may also meet the following conditions: j=max(0, in);
[0017]
[0018] The definitions and explanations of j and i refer to the description of the first method above, which will not be repeated here. trainis the maximum allowable training time for training any of the candidate inference models; the Δt is the sampling interval, and the sampling interval is the time difference between any two adjacent sampling moments. For example, if sampling moments t3 and t4 are two adjacent sampling moments and t4 is after t3, the sampling interval can be the value of t4-t3; and after assigning moment numbers from 0 to w to multiple sampling moments in order from front to back corresponding to the sampling moments of at least one candidate inference model, the time difference between the inference moment and the sampling moment with the same number is less than a second preset threshold, and w is a positive integer. For the relationship between the sampling moment and the inference moment with the same number, please refer to the description of the first method above, which will not be repeated here.
[0019] With this design, when the maximum allowable duration for a computing device to execute a training task is greater than a sampling interval, and when an inference moment arrives, the computing device may not have completed model training based on the previous moment or a moment closer to the previous moment, the computing device can determine that the maximum allowable duration for executing a training task occupies a number n of sampling intervals. For example, when the maximum allowable duration for executing a training task is 2.4 times the sampling interval, the value of n is 3. If the computing device has not completed training a candidate inference model during the first n inference moments, the most initial candidate inference model, i.e., the candidate inference model with sequence number 0, can be selected. After the n+1th inference moment and the n+1th inference moment, the time difference between the sampling moment corresponding to the most recently completed candidate inference model and the inference moment is n sampling intervals. The computing device can select the candidate inference model corresponding to the model sequence number that differs by n from the sequence number of the inference moment as the target inference model, thereby ensuring that the target inference model obtained by the computing device is a complete inference model or an inference model trained based on the most recent sampling data.
[0020] In a third embodiment, the model serial number corresponding to the target inference model and the moment serial number corresponding to the first moment may also meet the following conditions:
[0021]
[0022] j is the model number corresponding to the target inference model; the model number of the at least one candidate inference model is the model number from 0 to p assigned to the at least one candidate inference model in order from the front to the back of the sampling moments corresponding to the at least one candidate inference model; p is a positive integer; i is the moment number corresponding to the first moment after the multiple inference moments are assigned moment numbers from 0 to q in order from the front to the back of the multiple inference moments; q is a positive integer. Please refer to the description of the first method above for the definitions and explanations of j and i, and will not be repeated here.
[0023] The T train For the definition and explanation of Δt, please refer to the description of the second method above, which will not be repeated here.
[0024] It is important to note that N here is the number of candidate inference models that can be trained simultaneously by the computing device; s is a preset value;
[0025] And after assigning moment numbers from 0 to w to multiple sampling moments in sequence according to the order from front to back of the sampling moments corresponding to the at least one candidate inference model, the time difference between the inference moment and the sampling moment with the same sequence number is less than a second preset threshold, and w is a positive integer. For the relationship between the sampling moment and the inference moment with the same sequence number, please refer to the description of the first method above, and no further details will be given here.
[0026] Through this design, when the maximum allowable time for the computing device to execute a training task is greater than a sampling interval, and the computing device executes multiple training tasks in order from front to back according to the sampling moments corresponding to the multiple training tasks, the computing device can allocate different computing resources to different training tasks. Taking the same computing resource as a training channel as an example, the number of candidate inference models that the computing device can train simultaneously is N, and the computing device has N training channels. Based on the above-mentioned third method, k takes a positive integer from 1 to N, and the candidate inference model that has completed training most recently that can be obtained on each training channel can be determined respectively. For example, when N is 2, k takes the value of 1, which is the model number of the candidate inference model with the smallest time difference between the sampling moment and the inference moment that can be obtained on the first training channel. K takes the value of 2, which is the model number of the candidate inference model with the smallest time difference between the sampling moment and the inference moment that can be obtained on the second training channel. The computing device selects the maximum value from the multiple determined model numbers. The candidate inference model corresponding to the maximum value is the model with the smallest time difference between the sampling moment and the inference moment among at least one candidate inference model. When the maximum value is 0, it means that the computing device has not yet completed the training of a candidate inference model. In this case, the most initial candidate inference model, i.e., the candidate inference model with sequence number 0, can be selected. This ensures that the target inference model obtained by the computing device is a complete inference model or an inference model trained based on the latest sampled data.
[0027] In one possible design, the method also includes: determining that the first moment is a second sampling moment; the second sampling moment is a sampling moment after the first sampling moment; based on a second training data set, training the pre-trained model to obtain a candidate inference model corresponding to the second sampling moment; the second training data set includes the first data and sample data collected within a first preset time length before the first moment; the candidate inference model corresponding to the second sampling moment is used for the inference task at and after the second moment, the second moment is after the first moment, and the time difference between the second moment and the first moment is greater than or equal to the preset training time length.
[0028] Through this design, when the computing device determines that an inference moment has arrived, if the inference moment is also a sampling moment set in the inference model training process, a training task can be started based on the data obtained at the inference moment and the data obtained within a period of time before the inference moment, so as to add the data obtained at the inference moment and the data obtained within a period of time before the inference moment to the training data set, perform model training on the pre-trained model, and obtain the latest candidate inference model, so as to realize dynamic updating of the candidate inference model during the inference process to ensure the effectiveness and accuracy of the inference.
[0029] In the second aspect, the present application provides a model training method, which can be executed by a computing device or a processing chip in a computing device, or by a computing device cluster. In this method, the computing device determines that a first sampling moment has arrived, and the first sampling moment is any sampling moment among Z sampling moments; the Z is a positive integer; based on the first training data set, the pre-trained model is trained to obtain a candidate inference model corresponding to the first sampling moment; the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time length before the first sampling moment, and the candidate inference model corresponding to the first sampling moment is used for the inference task at and after the first moment, the first moment is located after the first sampling moment, and the time difference between the first moment and the first sampling moment is greater than or equal to the preset training time length.
[0030] In the above method, the computing device can initiate a training task upon determining that a sampling time has arrived. Sample data acquired at the current sampling time and within a preset time period before the current sampling time are added to the training data set, and the pre-trained model is trained to obtain a candidate inference model relative to the current sampling time. This allows for dynamic updating of the inference model, ensuring its effectiveness and accuracy.
[0031] In a third aspect, the present application provides a model training method, which can be executed by a computing device or a processing chip within the computing device, or by a computing device cluster. In this method, the computing device determines that there are at least two training tasks, each of which is used to train a corresponding candidate inference model, and the at least two training tasks correspond to different sampling moments; the at least two training tasks are executed in sequence according to the sampling moments corresponding to the at least two training tasks from front to back, and any of the training tasks is trained based on the model training method described in the second aspect.
[0032] In the above method, when the computing device determines that there are at least two training tasks, the training tasks are executed in order from front to back according to the sampling moments corresponding to each training task, thereby ensuring that the model training is carried out in an orderly manner.
[0033] In a possible design, the sampling moment corresponding to the first training task is the rth sampling moment after multiple sampling moments are arranged in order from front to back, where r is a positive integer.
[0034] Through this design, the computing device performs model training based on the sample data obtained at the rth sampling moment after the initial moment, so that the computing device can reasonably allocate training computing power and update the inference model more effectively and reasonably. The negative optimization of the first few inference moments brings about positive optimization in the subsequent multiple inference moments, further improving the inference accuracy.
[0035] In a fourth aspect, the present application provides a computing device comprising an acquisition module and an inference module. The acquisition module is used to acquire first data, wherein the first data is data acquired at a first moment. The inference module is used to acquire a target inference model from at least one candidate inference model, wherein the at least one candidate inference model corresponds to different sampling moments respectively, and the first sampling moment corresponding to the target inference model is located before the first moment, and the time difference between the first moment and the target inference model is less than a first preset threshold; the target training model is obtained by training a pre-trained model based on a first training data set, wherein the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time length before the first sampling moment; the first data is input into the target inference model to obtain a first inference result.
[0036] In one possible design, the inference module is specifically used to: determine at least two target candidate inference models from at least one candidate inference model, the sampling moments corresponding to each of the target candidate inference models are all before the first moment, and the time difference between each and the first moment is less than the first preset threshold; obtain the target inference model from the at least two target candidate inference models.
[0037] In one possible design, the computing device also includes a training module, which is used to determine that the first moment is a second sampling moment; the second sampling moment is a sampling moment after the first sampling moment; based on a second training data set, the pre-trained model is trained to obtain a candidate inference model corresponding to the second sampling moment; the second training data set includes the first data and sample data collected within a first preset time length before the first moment; the candidate inference model corresponding to the second sampling moment is used for inference tasks at and after the second moment, the second moment is located after the first moment, and the time difference between the second moment and the first moment is greater than or equal to the preset training time length.
[0038] In a fifth aspect, the present application provides a computing device, which includes a sampling module and a training module. The sampling module is used to obtain sample data at each sampling moment of Z sampling moments; Z is a positive integer; the training module is used to determine the arrival of the first sampling moment, and the first sampling moment is any sampling moment of the Z sampling moments; based on the first training data set, the pre-trained model is trained to obtain a candidate inference model corresponding to the first sampling moment; the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time length before the first sampling moment, and the candidate inference model corresponding to the first sampling moment is used for the inference task at and after the first moment, the first moment is located after the first sampling moment, and the time difference between the first moment and the first sampling moment is greater than or equal to the preset training time length.
[0039] In one possible design, the training module is also used to: determine the existence of at least two training tasks, each of the training tasks is used to train a corresponding candidate inference model, and the at least two training tasks correspond to different sampling moments respectively; execute the at least two training tasks in sequence according to the order from front to back of the sampling moments corresponding to the at least two training tasks, and train any one of the training tasks based on the model training method described in the second aspect.
[0040] In a sixth aspect, the present application provides a computing device comprising a processor and a memory; the memory stores computer program instructions and at least one candidate reasoning model; the processor is used to execute the instructions stored in the memory to execute the method described in the first aspect and any possible design of the first aspect, or to execute the method described in the second aspect and any possible design of the second aspect, or to execute the method described in the third aspect and any possible design of the third aspect.
[0041] In the seventh aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed by a computing device cluster, enables the computing device cluster to execute the method described in the first aspect and any possible design of the first aspect, or execute the method described in the second aspect and any possible design of the second aspect, or execute the method described in the third aspect and any possible design of the third aspect.
[0042] In an eighth aspect, an embodiment of the present application provides a computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method described in the first aspect and any possible design of the first aspect, or executes the method described in the second aspect and any possible design of the second aspect, or executes the method described in the third aspect and any possible design of the third aspect.
[0043] In the ninth aspect, an embodiment of the present application provides a computing device cluster, comprising at least one computing device, each computing device comprising a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method described in the first aspect and any possible design of the first aspect, or executes the method described in the second aspect and any possible design of the second aspect, or executes the method described in the third aspect and any possible design of the third aspect.
[0044] The embodiments of the present application can be further combined to provide more implementations based on the implementations provided in the above aspects. For the beneficial effects of the fourth to ninth aspects, please refer to the description of the beneficial effects of the first to third aspects, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] FIG1 is a schematic diagram of the architecture of a heterogeneous computing system provided in an embodiment of the present application;
[0046] FIG2 is a schematic diagram of a processing flow of a weather forecast model;
[0047] FIG3 is a flow chart of a model reasoning and data reasoning method provided in an embodiment of the present application;
[0048] FIG4 is a schematic diagram showing the correspondence between different parameter relationships and selection methods provided in an embodiment of the present application;
[0049] FIG5 is a schematic diagram of a first candidate inference model and sampling time provided in an embodiment of the present application;
[0050] FIG6 is a schematic diagram of a second candidate inference model and sampling time provided in an embodiment of the present application;
[0051] FIG7 is a schematic diagram of a third candidate inference model and sampling time provided in an embodiment of the present application;
[0052] FIG8 is a schematic diagram of another candidate inference model and sampling time provided in an embodiment of the present application;
[0053] FIG9 is a schematic diagram of a scheduling method for data reasoning according to an embodiment of the present application;
[0054] FIG10 is a schematic diagram of a processing flow of a weather forecast model provided in an embodiment of the present application;
[0055] FIG11 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0056] FIG12 is a schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0057] FIG13 is a schematic diagram of a computing device cluster provided in an embodiment of the present application;
[0058] FIG14 is a schematic diagram of a computing device cluster connection method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solutions and advantages of the embodiments of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings. In the description of the embodiments of the present application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0060] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "more" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, or a, b and c, where a, b, c can be single or multiple.
[0061] With the continuous development of high-performance computing (HPC) and related applications, the demand for computing power has continued to rise. Relying solely on processors of a single computing type and architecture cannot meet existing computing power requirements. Heterogeneous computing refers to parallel computing performed on heterogeneous computing systems. Heterogeneous computing systems can include computing units with different instruction sets and architectures. Heterogeneous computing is widely used in cloud data centers, edge computing scenarios, and other scenarios. For example, heterogeneous computing can coordinate the computing power of multiple hardware such as CPUs, GPUs, FPGAs, and ASICs to meet application requirements in different scenarios, improve system computing power, reduce costs, and maximize computing efficiency. For example, with the development of artificial intelligence (AI) technology, heterogeneous computing power solutions and application scenarios that integrate HPC and AI have been further expanded.
[0062] Figure 1 is a schematic diagram of the architecture of a heterogeneous computing system provided in an embodiment of the present application. Referring to Figure 1, the heterogeneous computing system includes general-purpose chips and AI chips. Among them, the general-purpose chip can be, for example, a CPU, which is generally used in HPC computing scenarios; the AI chip can be, for example, a graphics processing unit (GPU), a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a neural network processing unit (NPU) and other acceleration chips, and the AI chip is generally used in AI computing scenarios.
[0063] The heterogeneous computing system shown in Figure 1 can be used for model inference and training. Model inference can be applied to time series forecasting models, which infer future numerical changes based on the observed values of the variables themselves and their patterns of change. For example, model inference can be applied to time series forecasting scenarios such as weather forecasting and traffic forecasting. The inference model used in model inference can be obtained by training the heterogeneous computing system based on a training dataset. The model training process can be the process of continuously adjusting model parameters based on sample data in the training dataset.
[0064] Optionally, the heterogeneous computing power system shown in FIG1 can be implemented by a computing device, such as the computing device can include at least one general-purpose chip (such as a CPU) and at least one AI chip (such as a GPU and AISC, etc.); or the heterogeneous computing power system shown in FIG1 can be implemented by a computing device cluster, which can include at least one computing device, each computing device can include at least one general-purpose chip and at least one AI chip, or some computing devices in the computing device cluster can be used to implement the model reasoning process performed by the general-purpose chip in the embodiment of the present application, and some computing devices are used to implement the model training process performed by the AI chip in the embodiment of the present application. The embodiment of the present application does not limit the division of labor of each computing device when the computing device cluster executes the data reasoning method and model training method provided by the embodiment of the present application. For ease of description, the following introduction takes the implementation of the heterogeneous computing power system by computing devices as an example.
[0065] When applying heterogeneous computing systems to model inference and training scenarios, since model training requires a large amount of AI computing resources and the inference process needs to be carried out quickly and stably, a common processing mode is to use AI chips for offline training models and general-purpose chips for online inference based on trained models.
[0066] When performing model inference and training based on the above-mentioned processing model, the model used for online inference on general-purpose chips is the model trained offline by the AI chip. The training data used when training this model lags behind the real-time data. Therefore, reasoning based on this model will affect the inference accuracy and effective range.
[0067] For example, the processing flow of model training and inference in heterogeneous computing systems is introduced by taking a weather forecast model as an example. Figure 2 is a schematic diagram of the processing flow of a weather forecast model. Referring to Figure 2, the AI chip in the computing device can be used to train a pre-trained model for inferring future weather conditions based on training data. The training data may include feature data and labeled data. For example, the feature data may be a numerical prediction value of the weather conditions over a period of time in the past, and the labeled data may be the observed true value of the weather conditions over a period of time in the past. The AI chip can use the feature data in the training data as input and the labeled data as output to train the pre-trained model to obtain an inference model. Referring to Figure 2, the model training process performed by the AI chip is an offline processing process. The model training process occurs before the actual inference process. For example, the training process in Figure 2 occupies the time span of the past N days before the -n moment, and the training results in a fixed offline model.
[0068] General-purpose chips can obtain a trained fixed offline model from the AI chip as an inference model. For example, at time 0, you can input a numerical forecast value for the weather conditions for the next 24 hours (0:00 to 24:00 on the current day) and obtain the AI forecast value for the weather conditions for the next 24 hours output by the inference model. Assuming the inference time interval is set to 3 hours, at time 03, you can input a numerical forecast value for the weather conditions for the next 24 hours (03:00 on the current day to 03:00 the next day) and obtain the AI forecast value for the weather conditions for the next 24 hours output by the inference model.
[0069] It is understandable that based on the above model training and inference methods, as time goes by, the effectiveness of the offline model as an inference model will be greatly weakened because the training data used by the offline model lags behind the real-time data, affecting the accuracy of real-time inference.
[0070] Based on the above problems, the embodiments of the present application provide a data inference method and a model training method to provide an efficient scheduling method for model inference and training, so that the computing device can dynamically obtain newer data to train the model, and perform inference based on the model trained using the newer data to improve the inference accuracy.
[0071] The data reasoning method and model training method provided in the embodiments of the present application are further introduced below in conjunction with the accompanying drawings.
[0072] The data inference method and model training method provided in the embodiments of the present application can be executed by a computing device having the heterogeneous computing system shown in Figure 1. The method can be used for training and inference of time series prediction models. A time series prediction model is a model that infers future numerical changes based on the observed values of the study variables themselves and their change patterns. For example, the model for predicting future weather conditions shown in Figure 2 is a time series prediction model.
[0073] In the data inference method and model training method provided in the embodiments of the present application, the computing device can simultaneously start the inference task and the training task. Each training task can train a newer candidate inference model based on the sample data collected at the current moment and a period of time before the current moment. In each inference task, a target inference model can be determined from at least one candidate inference model obtained through training. For example, the latest candidate inference model is determined as the target inference model, and the inference task is performed based on the target inference model, thereby realizing the dynamic update of the inference model through online training and online inference.
[0074] The following first introduces the model training method provided by the embodiment of the present application. Figure 3 is a flowchart of a model training and data inference method provided by the embodiment of the present application. The steps in Figure 3 can be executed by a computing device, and of course can also be executed by different processing chips in the computing device. The following description takes the execution of the first device as an example, and also describes which of the following steps can be executed by which processing chip. Referring to Figure 3, the method includes the following steps:
[0075] S301: The computing device determines that a first sampling time has arrived.
[0076] In an embodiment of the present application, the computing device can determine Z sampling moments from the initial sampling moment according to a preset sampling interval, where Z is a positive integer, the time difference between any two adjacent sampling moments is the sampling interval, and the first sampling moment can be any sampling moment among the Z sampling moments. The computing device can collect sample data once each time a sampling moment is reached. The sample data may include data sampled at the sampling moment reached and data sampled within a preset time period before the sampling moment. The sample data can be used for model training, for example, the sample data may include feature data and label data.
[0077] S302: The computing device trains the pre-trained model based on the first training data set to obtain a candidate inference model corresponding to the first sampling moment.
[0078] As described above, the first training data set here includes data sampled at a first sampling moment and data sampled within a preset time period before the first sampling moment.
[0079] Based on the above description, it can be understood that the training data sets used by the training tasks initiated by the computing device at different sampling moments will be different, and the candidate inference models obtained by training based on different training data sets will also be different, that is, the candidate inference models obtained by training at different sampling moments correspond to the sampling moments. After determining that the first sampling moment has arrived, the computing device can train the pre-trained model based on the first training data set to obtain the candidate inference model corresponding to the first sampling moment. Among them, the first training data set may include sample data collected at the first sampling moment and sample data collected within the first preset time period before the first sampling moment. For example, assuming that the first preset time period is 30 days and the first sampling moment is t1; the first training data set may include sample data collected by the computing device at t1, as well as sample data collected within 30 days before t1.
[0080] In one optional embodiment, when executing the training task corresponding to the first sampling moment, the computing device may perform multiple rounds of training on the pre-trained model based on the first training data set. In each round of training, the computing device may use the labeled data in the first training data set as the input of the pre-trained model, obtain the predicted value output by the pre-trained model, calculate the loss between the predicted value and the labeled data according to a preset loss function, and then adjust the model parameters of the pre-trained model based on the gradient descent method. Repeating multiple rounds of training, the computing device obtains a candidate inference model corresponding to the first sampling moment.
[0081] The candidate inference model corresponding to the first sampling moment obtained by the computing device can be used for inference tasks at the first moment and after the first moment, the first moment is after the first sampling moment, and the time difference between the first moment and the first sampling moment is greater than or equal to the preset training duration.
[0082] It is understandable that the model training method provided in the embodiment of the present application is a rolling training method, such as the computing device can start training the candidate inference model corresponding to t1 based on the training set D1 at sampling time t1, and start training the candidate inference model corresponding to t2 based on the training set D2 at the next sampling time t2 of t1, and so on. If the computing power of the computing device can support it, the computing device can execute multiple training tasks in parallel. Optionally, the computing device can execute at least two training tasks in sequence from front to back according to the sampling times corresponding to at least two training tasks. For example, when the number of candidate models that the computing device can train simultaneously is 2, if the training task corresponding to t1 has not ended when t2 is reached, the computing device can still start the training task corresponding to t2 at t2, thereby executing two training tasks at the same time. If the training task corresponding to t1 and the training task corresponding to t2 are not completed when t3, the computing device has no idle computing power available to execute the training task corresponding to t3, and the training task corresponding to t3 can be queued and wait for the computing device to allocate computing power. When the computing device has idle computing power, the computing device can execute the training tasks in sequence according to the sampling time corresponding to the queued training tasks from front to back.
[0083] In some embodiments, the computing device may start the first training task at the r-th sampling moment among the Z sampling moments. It should be noted that the first training task refers to a training task initiated by the computing device based on the data sampled at the r-th sampling moment and the sample data sampled within a preset time period before the r-th sampling moment. When at least one sampling moment before the r-th sampling moment is reached, the computing device may collect sample data, but may not start the training task, so that the computing device can reasonably allocate the training computing power and speed up the updating of the inference model. The specific implementation of this design can be found in the relevant introduction of the data inference method below, which will not be described in detail here.
[0084] Exemplarily, the above S301-S302 can be executed by the AI chip in the computing device in Figure 1.
[0085] S303: The computing device obtains first data at a first moment.
[0086] In one embodiment of the present application, the computing device may determine multiple inference moments based on a preset time interval starting from the initial inference moment, where the time difference between any two adjacent inference moments is the preset time interval, and the first moment is any one of the multiple inference moments, the first moment being after the first sampling moment in S301. The computing device may obtain real-time data at each inference moment and perform inference based on the inference model based on the real-time data. For example, assuming the preset time interval is 3 hours, the computing device may obtain real-time data for inference every 3 hours.
[0087] In an embodiment of the present application, a plurality of sampling moments can be sequentially assigned a time sequence number from 0 to w, where w is a positive integer. For example, a plurality of sampling moments can be sequentially assigned a time sequence number of 1, 2, 3, ..., w, etc., in a sequence from the beginning to the end of the plurality of sampling moments. Also, a plurality of inference moments can be sequentially assigned a time sequence number from 0 to q, where q is a positive integer. For example, a plurality of inference moments can be sequentially assigned a time sequence number of 1, 2, 3, ..., q, etc., in a sequence from the beginning to the end of the plurality of inference moments. The sampling moment with a time sequence number of 0 can be considered as the initial sampling moment, and the inference moment with a time sequence number of 0 can be considered as the initial inference moment. In an embodiment of the present application, the difference between the inference moment and the sampling moment with the same sequence number is less than a second preset threshold. For example, a sampling moment with a sequence number of 5 and the inference moment can be the same time, or can be close to each other. That is, the sampling moment and the inference moment with the same sequence number of 5 are theoretically at the same time point or a relatively close time point. This ensures that when different inference moments arrive, the target inference model can be more accurately obtained from the multiple candidate inference models that have been trained.
[0088] S304: The computing device obtains a target reasoning model from at least one candidate reasoning model.
[0089] As can be seen from the introduction of S301-S302, the computing device can start a model training when it is determined that the sampling moment has arrived to generate a new candidate inference model, and the candidate inference models trained at different sampling moments correspond to the sampling moments. When the computing device performs inference, a target inference model can be selected from at least one candidate inference model, the first sampling moment corresponding to the target inference model is before the first moment mentioned in S303, and the time difference between the first sampling moment corresponding to the target inference model and the first moment is less than a first preset threshold. The first preset threshold can be set to a smaller value, so that the selected target inference model can be the model with the smallest time difference between the sampling moment and the first moment among at least one candidate inference model.
[0090] Exemplarily, the above S303 - S304 may be executed by a general-purpose chip CPU in the computing device in FIG1 .
[0091] In an embodiment of the present application, when the computing device determines from at least one candidate inference model that there are at least two candidate inference models whose corresponding sampling moments are both before the first moment and the time difference between them and the first moment is less than a first preset threshold, the computing device can then use a corresponding method or algorithm to obtain a target inference model from at least two target candidate inference models.
[0092] For example, a computing device may randomly obtain a target inference model from at least two target candidate inference models. However, in order to more accurately obtain a target inference model from at least two target candidate inference models and thereby improve inference accuracy, this application proposes three different methods for obtaining a target inference model from at least two target candidate inference models, each of which will be described below.
[0093] Before describing the three methods for selecting the target inference model, some parameter definitions are explained.
[0094] Sequential numbers of sampling moments: sequentially assigning sequential numbers from 0 to w to multiple sampling moments in the order of the at least one sampling moment from front to back.
[0095] Model serial number corresponding to the candidate inference model: The computing device may assign model serial numbers from 0 to p to at least one candidate inference model in descending order of the sampling moments corresponding to the at least one candidate inference model, where p is a positive integer. It should be noted that the candidate inference model with model serial number 0 may correspond to the sampling moment with sampling moment serial number 0, the sampling moment with moment serial number 0 may be the initial sampling moment, the candidate inference model with model serial number 0 may be the initial inference model, and the initial inference model may be a model trained by the computing device based on a preset training data set before the initial sampling moment.
[0096] Moment sequence number of the reasoning moment: according to the order of the at least one reasoning moment from the front to the back, the multiple reasoning moments are sequentially assigned moment sequences from 0 to q.
[0097] The number of candidate inference models that a computing device can train simultaneously (N): During model training, a computing device can train N models in parallel. Here, N is the number of candidate inference models that the computing device can train simultaneously, and N is a positive integer. The value of N depends on the hardware performance of the computing device. For example, when a computing device's GPU chip is used as an AI chip for model training, N can be calculated based on the amount of training data and the performance parameters of the GPU chip.
[0098] The maximum allowed training time T for a computing device to train any candidate inference model train :The training of any candidate inference model by a computing device refers to the process in which the computing device trains the pre-trained model based on the training data set and obtains a candidate inference model. This process usually has a specified completion time and cannot be performed indefinitely. Here, the maximum time allowed to complete the process of model training is defined as T train Optional, T train This is a preset value. When the computing device trains any candidate inference model, it needs to complete the model training within this maximum allowed time.
[0099] Sampling interval Δt: The time difference between any two adjacent sampling moments is a sampling interval. For example, when there are multiple sampling moments such as t1, t2, t3, and so on, the time interval between any two adjacent sampling moments can be the same, which means that sampling can be periodic. Here, the interval between any two sampling moments is defined as the sampling interval.
[0100] First parameter n: The first parameter, maximum allowed training time, and sampling interval can satisfy the following relationship:
[0101] in, The first parameter n is a rounding-up operator. The first parameter n can indicate that the maximum allowed time for the computing device to execute a training task occupies the number n of sampling intervals. For example, when the maximum allowed time for executing a training task is 2.4 times the sampling interval, the value of n can be 3.
[0102] In the embodiment of the present application, based on the above-mentioned multiple parameters, different target reasoning model selection methods can be related to different parameters. Figure 4 is a schematic diagram of the relationship between different parameters and the selected target reasoning model provided by the embodiment of the present application. Referring to Figure 4, when T train When T is less than or equal to Δt, the computing device can select the target reasoning model according to the following selection method 1; when T trainWhen T is greater than Δt and the first parameter n is less than or equal to N, the computing device may select the target reasoning model according to the following selection method 2; when T train When Δt is greater than Δt and n is greater than N, the computing device may select the target inference model according to the following selection method 3. The three selection methods are introduced below.
[0103] Selection method 1: T train When it is less than or equal to Δt, Figure 5 is a schematic diagram of the relationship between the first candidate inference model and the sampling moment provided in an embodiment of the present application. Referring to Figure 5, assuming that the inference moment and the sampling moment with the same serial number are the same moment, at the first moment (that is, the inference moment and the sampling moment), the computing device has completed the training of the candidate inference model corresponding to the previous moment (that is, the inference moment and the sampling moment), then the computing device can obtain the candidate inference model corresponding to the previous moment as the target inference model at the first moment. In this case, the following conditions can be met between the moment serial number of the first moment and the model serial number of the target inference model: j=i-1 Condition 1
[0104] Wherein, j is the model number of the target inference model, and i is the moment number of the first moment.
[0105] For example, referring to Figure 5, assuming that the first moment is t2 and the moment number of the first moment is 2, the computing device can determine that the model number of the target reasoning model is 1 according to the above condition 1, then the computing device can obtain the candidate reasoning model m1 with model number 1 as the target reasoning model.
[0106] Option 2: When T train When Δt is greater than Δt and n is less than or equal to N, FIG6 is a schematic diagram showing the relationship between the second candidate inference model and the sampling time provided in the embodiment of the present application. train When n is greater than Δt, the computing device needs to allocate different computing resources to each training task when it receives one. When n is less than or equal to N, it means that the computing device has sufficient computing resources for model training and can start each training task promptly.
[0107] In this case, the time sequence number of the first moment and the model sequence number of the target inference model can satisfy the following condition: j = max(0, in) Condition 2
[0108] Wherein, j is the model number of the target inference model, and i is the moment number of the first moment.
[0109] Based on condition 2 above, if the computing device has not completed training for a candidate inference model during the first n inference moments, the most initial candidate inference model, i.e., the candidate inference model with serial number 0, can be selected. At and after the n+1th inference moment, the time difference between the sampling moment corresponding to the candidate inference model that the computing device has most recently completed training and the inference moment is n sampling intervals. The computing device can obtain a candidate inference model whose model serial number differs by n from the serial number of the inference moment, thereby ensuring that the target inference model obtained by the computing device is a complete inference model or an inference model trained based on the latest sampled data.
[0110] For example, referring to Figure 6, assume that n is 3 and N is 4. The first moment is t2, and the moment sequence number of the first moment is 2. At this time, the computing device can determine that the model sequence number of the target inference model is 0 based on the above condition 2, and the computing device can obtain the initial inference model as the target inference model. As can be seen from Figure 6, at t2, the computing device has not yet completed the training of the candidate inference model m1 with model sequence number 1, so the computing device needs to obtain the initial inference model as the target inference model.
[0111] For another example, assuming that n is 3, the first moment is t5, and the moment number of the first moment is 5, the computing device can determine that the model number corresponding to the target reasoning model is 2 according to the above condition 2, then the computing device can obtain the candidate reasoning model m2 with model number 2 as the target reasoning model.
[0112] Selection method 3: T train When Δt is greater than Δt, and n is greater than N, FIG7 is a schematic diagram of the third candidate inference model and sampling time provided by the embodiment of the present application. Referring to FIG7, when T train When n is greater than Δt, it means that the computing device requires more time to execute a model training than a sampling interval. Therefore, the computing device needs to allocate different computing power to each training task upon receiving it. When n is greater than N, the computing device's computing power resources can be immediately started upon receiving the first N training tasks, but subsequent training tasks must wait in queue for computing power to become available.
[0113] In some embodiments of the present application, the computing device may initiate model training based on sample data acquired in real time after a preset period of time following the initial sampling moment. In practice, the computing device may initiate the first training task at the rth sampling moment among the z sampling moments. During the s sampling moments after the initial sampling moment and before the rth sampling moment, the computing device may collect sample data but may not initiate a training task.
[0114] In this design, the sequence number of the first moment and the model sequence number of the target inference model can satisfy the following conditions:
[0115] Among them, j is the model number of the target inference model, i is the time number of the first moment, and k is any positive integer between 1-N, that is, is the floor operator. s is the preset value.
[0116] As described above, a computing device can allocate different computing resources to different training tasks. For example, if the same computing resources represent a training channel, and the computing device can simultaneously train N candidate inference models, then the computing device has N training channels. Based on Condition 3 above, k is a positive integer between 1 and N, and the most recently trained candidate inference model available on each training channel can be determined. Referring to Figure 7, when N is 2, a value of 1 for k can calculate the model number of the first candidate inference model with the smallest time difference between the sampling moment and the inference moment available on the first training channel. A value of 2 for k can calculate the model number of the second candidate inference model with the smallest time difference between the sampling moment and the inference moment available on the second training channel. The computing device selects the inference model with the largest number from the two determined model numbers and model number 0 as the target inference model. When this maximum number is 0, it indicates that the computing device has not yet completed training a candidate inference model, and the initial candidate inference model, i.e., the candidate inference model with number 0, can be selected. This ensures that the target inference model obtained by the computing device is a complete inference model or an inference model trained based on the latest sampled data.
[0117] For example, refer to FIG7 , which takes s=1, n=3, and N=2 as an example. After the computing device obtains data at time t1, according to the above condition 3, when k takes the value 1, When k is 2, So Then, it is determined that the model serial number of the target reasoning model is 0, and the computing device can obtain the initial reasoning model m0 as the target reasoning model.
[0118] After the computing device obtains data x2 at time t2, according to the above condition 3, when k takes the value 1, When k is 2, So The model number is determined to be 0, and the computing device can obtain the initial inference model m0 as the target inference model. In addition, the computing device obtains the labeled data y2 corresponding to x2, and trains the pre-trained model based on (x2, y2) and sample data obtained within a first preset time period before time t2 to obtain the candidate inference model m2.
[0119] For another example, suppose s=1, n=3, N=2. The first moment is t6, and the time sequence number of the first moment is 6. At this time, the computing device can, according to the above condition 3, take the value of k as 1. When k is 2, So It is then determined that the model number of the target reasoning model is 3, and the computing device can obtain the initial reasoning model m3 as the target reasoning model.
[0120] In the above-mentioned selection method 3, the computing device can also start model training based on the sample data obtained in real time at the sampling moment with the moment number 1, that is, s can directly take the value of 0. Then Figure 8 is a schematic diagram of another candidate inference model and sampling moment provided by an embodiment of the present application. In this case, the moment number of the first moment and the model number of the target inference model can meet the following conditions:
[0121] Among them, j is the model number of the target inference model, i is the time number of the first moment, and k is any positive integer between 1-N, that is, is the floor operator. It is understandable that when s is 0, condition 3 can be transformed into condition 4. Therefore, condition 4 can be regarded as a special case of condition 3. The specific implementation of the computing device determining the model number of the target inference model based on condition 4 can refer to the above-mentioned method of the computing device determining the model number of the target inference model based on condition 3. The repeated parts are not repeated here.
[0122] For example, referring to FIG8 , assuming that n is 3 and N is 2. The first moment is t2, and the moment number of the first moment is 2. At this time, the computing device can, according to the above condition 4, when k takes the value 1, When k is 2, Then j = max(0, -1, 0) = 0, and the model number of the target inference model is determined to be 0. The computing device can obtain the initial inference model as the target inference model. As shown in Figure 7, at time t2, the computing device has not yet completed the training of the candidate inference model with model number 1. The computing device needs to obtain the initial inference model as the target inference model.
[0123] For another example, suppose n is 3 and N is 2. The first moment is t6, and the time sequence number of the first moment is 6. At this time, the computing device can calculate the value of k according to the above condition 4. When k is 2, Then j=max(0,1,2)=2, and the model number of the target reasoning model is determined to be 2. The computing device can obtain the candidate reasoning model m2 with the model number 2 as the target reasoning model.
[0124] For another example, suppose n is 3 and N is 2. The first moment is t7, and the moment number of the first moment is 7. At this time, the computing device can calculate the value of k according to the above condition 4. When k is 2, Then j=max(0,3,2)=3, and the model number of the target reasoning model is determined to be 3. The computing device can obtain the candidate reasoning model m3 with the model number 3 as the target reasoning model.
[0125] By comparing the model numbers of the target inference models for the two cases where model training starts at time t1 (Figure 8) and model training starts at time t2 (Figure 7), we can see that when the computing device starts model training at time t2, the target inference model at time t4 changes from m1 to m0, and the accuracy at this time decreases. However, the target inference model at time t6 changes from m2 to m3, and the target inference model at time t9 changes from m4 to m5, and the accuracy at these times increases. This negative optimization leads to positive optimization at multiple subsequent times. Therefore, starting model training at the rth sampling time after the initial sampling time can further improve inference accuracy.
[0126] Exemplarily, the above S304 can be performed by a general-purpose chip in the computing device in Figure 1. Optionally, after determining the model serial number of the target inference model, the general-purpose chip can obtain the candidate inference model corresponding to the model serial number from the AI chip according to the model serial number, and use the candidate inference model sent by the AI chip as the target inference model.
[0127] S305: The computing device inputs the first data into the target reasoning model to obtain a first reasoning result.
[0128] After obtaining the target reasoning model, the computing device may input the first data into the target reasoning model and obtain the first reasoning result output by the target reasoning model, thereby completing a reasoning process.
[0129] Exemplarily, the above S305 may be executed by a general-purpose chip in the computing device in FIG1 .
[0130] By implementing the above method, the computing device can add the data acquired at the time of inference and the data acquired within a period of time before the time of inference to the training data set, and train the pre-trained model to obtain a new candidate inference model. This allows the candidate inference model to be dynamically updated during the inference process, ensuring the validity and accuracy of the inference. The specific model training method can be referred to the model training method shown in S301-S302 and will not be repeated here.
[0131] For ease of explanation, the embodiment shown in FIG3 of the present application introduces the training process of the candidate inference model corresponding to the first sampling moment and the process of performing inference at the first moment using the candidate inference model corresponding to the first sampling moment. However, this embodiment does not limit the steps performed by the computing device between the first sampling moment and the first moment. There may be one or more sampling moments between the first sampling moment and the first moment, and the computing device may respectively perform the training tasks corresponding to each sampling moment. For specific implementation, see S301-S302. When there may be multiple inference moments between the first sampling moment and the first moment, the computing device may respectively perform the inference tasks for each inference moment. For specific implementation, see S303-S305. Repetitions will not be repeated.
[0132] It can be understood that the computing device executing the model training method and data inference method in Figure 3 is only an example and not a limitation. In the specific implementation, the model training method provided in the embodiment of the present application can be executed separately. The implementation method can still refer to S301-S302 and will not be repeated here.
[0133] Based on the embodiment shown in FIG3 , FIG9 is a scheduling diagram of the data inference method provided by the embodiment of the present application. Referring to FIG9 , the computing device is at t i Get real-time data x at all times i After that, we can get the candidate inference model m j , and obtain the candidate inference model m j As t i The target reasoning model M at the moment i Among them, as shown in Figure 9, the candidate inference model m j It is based on t j Get real-time data x at all times j and x j The corresponding labeled data y j The computing device can also use t i Get real-time data x at all times i and x i The corresponding labeled data y i For training candidate inference model m i , thereby realizing the rolling training model, updating the inference model in a timely manner and improving the inference accuracy.
[0134] In addition, referring to Figure 9, the model training process can be executed by the AI chip of the computing device, and the model inference process can be executed by the general chip of the computing device, thereby improving the resource utilization of the AI chip without affecting the normal business of the general chip, thereby realizing the efficient operation of the heterogeneous computing power system.
[0135] By comparing the data inference method provided by the embodiment of the present application with the existing model training and inference method, since the existing solution adopts offline training and online inference, the offline model training has been completed before online inference, and there is no need to consider the training time. The total time required for the existing solution to perform S inference tasks is S*T test , where T test It represents the time required to perform an inference task. The inference accuracy of this solution is P. If offline training is directly transferred to online training, that is, the computing device does not perform model training tasks in the first s preset moments, and performs model training tasks at each preset moment after the sth preset moment. After obtaining a candidate inference model corresponding to a preset moment, reasoning is performed based on the candidate inference model corresponding to the preset moment. Then, the total time required to perform S inference tasks under this solution is S*(T train +T test )-s*T train , the reasoning accuracy of this solution is P+. When performing model reasoning based on the data reasoning method provided in the embodiment of this application, model training does not affect model reasoning, and the total time required to perform S reasoning tasks is S*T test , but the inference accuracy is P+. It can be seen that the data processing method provided by the embodiment of the present application is superior to the existing solution in terms of total training and inference time and accuracy.
[0136] In some embodiments, the data reasoning method provided in the embodiment of the present application can be applied to the training and reasoning of the weather forecast model. For example, Figure 10 is a schematic diagram of the processing flow of a weather forecast model provided in the embodiment of the present application. Referring to Figure 10, assuming that the training time is 30 days, the computing device can obtain the sample data at 0 o'clock 30 days ago, and then train the model based on the sample data at 0 o'clock 30 days ago and the sample data obtained within the preset time before 0 o'clock 30 days ago to obtain the candidate reasoning model m1. When the computing device needs to perform reasoning at time 0, the computing device can obtain the candidate reasoning model m1 as the target reasoning model, and the computing device can input the numerical prediction value of the weather conditions for the next 24 hours (0 o'clock on the same day - 24 o'clock on the same day) into the target reasoning model, and obtain the AI prediction value of the weather conditions for the next 24 hours output by the reasoning model. The computing device can also obtain the sample data at 3 o'clock 30 days ago, and then train the model based on the sample data at 3 o'clock 30 days ago and the sample data obtained within the preset time before 3 o'clock 30 days ago to obtain the candidate reasoning model m2. When the computing device needs to perform inference at time 3, it can obtain the candidate inference model m2 as the target inference model. The computing device can input the numerical forecast value of the weather conditions for the next 24 hours (3:00 a.m. today to 3:00 a.m. the next day) into the target inference model and obtain the AI forecast value of the weather conditions for the next 24 hours output by the inference model. Through this solution, the computing device can continuously train the model based on the obtained sample data, thereby updating the inference model and improving the inference accuracy.
[0137] In conjunction with the above method embodiments, embodiments of the present application also provide a computing device that can be used to execute the data inference method and model training method provided in the above embodiments. Figure 11 is a schematic diagram of the structure of a computing device 1200 provided in an embodiment of the present application. Referring to Figure 11, the computing device may include an acquisition module 1201, an inference module 1202, and may also include a collection module 1203 and a training module 1204.
[0138] The acquisition module 1201 can be used to acquire data. For example, the acquisition module 1201 can be used to execute S303 in the embodiment shown in FIG3 . The reasoning module 1202 can be used to perform a model reasoning task. For example, the reasoning module 1202 can acquire a target reasoning model from at least one candidate reasoning model. The target reasoning model is the model with the smallest time difference between the sampling moment of the training data and the first moment in the at least one candidate reasoning model. The reasoning module 1202 is also used to input the first data into the target reasoning model to obtain a first reasoning result. For example, the reasoning module 1202 can be used to execute S304-S305 in the embodiment shown in FIG3 .
[0139] The acquisition module 1203 may be configured to acquire sample data at each of Z sampling moments; Z is a positive integer.
[0140] The training module 1204 can be used to perform model training tasks. For example, the training module 1204 can use the sample data collected by the collection module 1203 at the sampling time as training data to train the pre-trained model and generate a candidate inference model. For example, the training module 1204 can be used to perform S301-S302 in the embodiment shown in Figure 3.
[0141] It should be noted that the division of functional modules in the embodiments of the present application is schematic and is merely a logical functional division. In actual implementation, other division methods may be used. Each functional module in the embodiments of the present application may be integrated into a processing functional module, or each functional module may exist physically separately. Alternatively, two or more functional modules may be integrated into a single functional module, such as the acquisition module 1201 and the acquisition module 1203 may be integrated into a single functional module. The aforementioned integrated functional modules may be implemented in either hardware or software functional modules.
[0142] If the integrated functional module is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0143] This application also provides a computing device 1300. As shown in Figure 12, computing device 1300 includes a bus 1302, a processor 1304, a memory 1306, and a communication interface 1308. Processor 1304, memory 1306, and communication interface 1308 communicate with each other via bus 1302. Computing device 1300 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in computing device 1300.
[0144] Bus 1302 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG12 shows a single line, but this does not imply a single bus or type of bus. Bus 1302 may include a path for transmitting information between various components of computing device 1300 (e.g., memory 1306, processor 1304, and communication interface 1308).
[0145] The processor 1304 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0146] The memory 1306 may include volatile memory, such as random access memory (RAM). The processor 1304 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0147] Memory 1306 stores executable program code, and processor 1304 executes the executable program code to implement the functions of the aforementioned acquisition module, reasoning module, acquisition module, and training module, thereby implementing the data reasoning method and model training method provided in the embodiments of the present application. In other words, memory 1306 stores instructions for executing the data reasoning method and model training method.
[0148] The communication interface 1308 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1300 and other devices or a communication network.
[0149] Embodiments of the present application also provide a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0150] As shown in Figure 13, the computing device cluster includes at least one computing device 1300. The memory 1306 in one or more computing devices 1300 in the computing device cluster may store the same instructions for executing the method of the embodiment of the present application.
[0151] In some possible implementations, the memory 1306 of one or more computing devices 1300 in the computing device cluster may also store partial instructions for executing the method of the embodiment of the present application. In other words, the combination of one or more computing devices 1300 can jointly execute the instructions for executing the method of the embodiment of the present application.
[0152] It should be noted that the memory 1306 in different computing devices 1300 in the computing device cluster may store different instructions, each for executing a portion of the functions performed by the computing device in the above method embodiment. In other words, the instructions stored in the memory 1306 in different computing devices 1300 may include the functions of one or more modules in the above computing devices.
[0153] In some possible implementations, one or more computing devices in a computing device cluster may be connected via a network. The network may be a wide area network or a local area network, etc. FIG14 shows a possible implementation. As shown in FIG14 , two computing devices 1300A and 1300B are connected via a network. Specifically, the connection to the network is made via a communication interface in each computing device. In this type of possible implementation, the memory 1306 in the computing device 1300A stores instructions for executing the functions of the acquisition module and the training module. At the same time, the memory 1306 in the computing device 1300B stores instructions for executing the functions of the acquisition module and the reasoning module.
[0154] The present application also provides another computing device cluster. The connection relationship between the computing devices in this computing device cluster can be similar to the connection method of the computing device cluster described in Figures 13 and 14. The difference is that the memory 1306 in one or more computing devices 1300 in this computing device cluster can store the same instructions for executing the data inference method and model training method.
[0155] In some possible implementations, the memory 1306 of one or more computing devices 1300 in the computing device cluster may also store partial instructions for executing the data reasoning method and the model training method. In other words, the combination of one or more computing devices 1300 can jointly execute instructions for executing the data reasoning method and the model training method.
[0156] Based on the above embodiments, the present application further provides a computer program, which, when executed on a computer, enables the computer to execute the methods described in the embodiments of the present application.
[0157] Based on the above embodiments, the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a computer, the computer executes the methods described in the embodiments of the present application.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the protection scope of the technical solutions of the various embodiments of the present invention.
[0159] An embodiment of the present application also relates to a processor, which is used to call a computer program or computer instruction stored in a memory so that the processor executes the above method embodiment.
[0160] The processor mentioned in any of the above may be a general-purpose central processing unit, a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits for controlling the execution of the program of the method in the embodiment shown in FIG8 . The memory mentioned in any of the above may be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM), etc.
[0161] It should be understood that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0162] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0163] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0164] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the scope of the embodiments of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application also intends to include such modifications and variations.
Claims
1. A data reasoning method, characterized in that: Applied to a computing device, the method comprises: Acquire first data, where the first data is data acquired at a first moment; Acquire a target inference model from at least one candidate inference model, wherein the at least one candidate inference model corresponds to different sampling moments respectively, and a first sampling moment corresponding to the target inference model is located before the first moment, and the time difference between the first moment and the first moment is less than a first preset threshold; the target training model is obtained by training a pre-trained model based on a first training data set, and the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time period before the first sampling moment; The first data is input into the target reasoning model to obtain a first reasoning result.
2. The method according to claim 1, characterized in that Obtaining a target inference model from at least one candidate inference model includes: Determine at least two target candidate inference models from at least one candidate inference model, wherein the sampling moments corresponding to each of the target candidate inference models are both before the first moment, and the time difference between each of the target candidate inference models and the first moment is less than the first preset threshold; A target inference model is obtained from the at least two target candidate inference models.
3. The method according to claim 2, characterized in that The model number corresponding to the target inference model and the time number corresponding to the first time meet the following conditions: j=i-1 j is the model number corresponding to the target inference model after the at least one candidate inference model is assigned a model number from 0 to p in sequence according to the sampling moments corresponding to the at least one candidate inference model from front to back; p is a positive integer; i is the time sequence number corresponding to the first time after the multiple reasoning moments are sequentially assigned time sequence numbers from 0 to q in the order from the front to the back of the multiple reasoning moments; q is a positive integer; And after assigning moment numbers from 0 to w to multiple sampling moments in sequence according to the order from front to back of the sampling moments corresponding to the at least one candidate inference model, the time difference between the inference moment and the sampling moment with the same number is less than a second preset threshold, and w is a positive integer.
4. The method according to claim 2, characterized in that The model number corresponding to the target inference model and the time number corresponding to the first time meet the following conditions: j=max(0,in); j is the model number corresponding to the target inference model after the at least one candidate inference model is assigned a model number from 0 to p in sequence according to the sampling moments corresponding to the at least one candidate inference model from front to back; p is a positive integer; i is the time sequence number corresponding to the first time after the multiple reasoning moments are sequentially assigned time sequence numbers from 0 to q in the order from the front to the back of the multiple reasoning moments; q is a positive integer; The T train is the maximum allowed training time for training any of the candidate inference models; Δt is the sampling interval, and the sampling interval is the time difference between any two adjacent sampling moments; And after assigning moment numbers from 0 to w to multiple sampling moments in sequence according to the order from front to back of the sampling moments corresponding to the at least one candidate inference model, the time difference between the inference moment and the sampling moment with the same number is less than a second preset threshold, and w is a positive integer.
5. The method according to claim 2, characterized in that The model serial number corresponding to the target inference model and the time serial number corresponding to the first time meet the following conditions: j is the model serial number corresponding to the target inference model; the model serial number of the at least one candidate inference model is the model serial number from 0 to p assigned to the at least one candidate inference model in sequence according to the sampling moments corresponding to the at least one candidate inference model from front to back; p is a positive integer; i is the time sequence number corresponding to the first time after the multiple reasoning moments are sequentially assigned time sequence numbers from 0 to q in the order from the front to the back of the multiple reasoning moments; q is a positive integer; The T train The maximum allowed training time for training any of the candidate inference models; The Δt is a sampling interval, which is the time difference between any two adjacent sampling moments; N is the number of candidate inference models that can be trained synchronously by the computing device; The s is a preset value; And after assigning moment numbers from 0 to w to multiple sampling moments in sequence according to the order from front to back of the sampling moments corresponding to the at least one candidate inference model, the time difference between the inference moment and the sampling moment with the same number is less than a second preset threshold, and w is a positive integer.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Determine the first moment as a second sampling moment; the second sampling moment is a sampling moment after the first sampling moment; Based on a second training data set, the pre-trained model is trained to obtain a candidate inference model corresponding to the second sampling moment; the second training data set includes the first data and sample data collected within a first preset time length before the first moment; the candidate inference model corresponding to the second sampling moment is used for inference tasks at and after the second moment, the second moment is after the first moment, and the time difference between the second moment and the first moment is greater than or equal to the preset training duration.
7. A model training method, characterized in that: Applied to a computing device, the method comprises: Determine that a first sampling time has arrived, where the first sampling time is any sampling time among Z sampling times; where Z is a positive integer; Based on a first training data set, a pre-trained model is trained to obtain a candidate inference model corresponding to the first sampling moment; the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time length before the first sampling moment, and the candidate inference model corresponding to the first sampling moment is used for inference tasks at and after the first moment, the first moment is after the first sampling moment, and the time difference between the first moment and the first sampling moment is greater than or equal to the preset training time length.
8. A model training method, characterized in that: Applied to a computing device, the method comprises: Determining that there are at least two training tasks, each of the training tasks is used to train a corresponding candidate inference model, and the at least two training tasks correspond to different sampling moments respectively; The at least two training tasks are executed in sequence according to the sampling moments corresponding to the at least two training tasks from front to back, and any one of the training tasks is trained based on the model training method according to claim 7.
9. The method according to claim 8, characterized in that The sampling moment corresponding to the first training task is the rth sampling moment after the multiple sampling moments are arranged in order from front to back, where r is a positive integer.
10. A computing device, characterized in that: include: An acquisition module, used to acquire first data, where the first data is data acquired at a first moment; An inference module is used to obtain a target inference model from at least one candidate inference model, wherein the at least one candidate inference model corresponds to different sampling moments respectively, and the first sampling moment corresponding to the target inference model is before the first moment, and the time difference between the first moment and the first moment is less than a first preset threshold; the target training model is obtained by training a pre-trained model based on a first training data set, and the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time before the first sampling moment; the first data is input into the target inference model to obtain a first inference result.
11. A computing device, characterized in that: The device comprises: A sampling module, used for acquiring sample data at each sampling moment among Z sampling moments; Z is a positive integer; A training module is used to determine the arrival of a first sampling moment, where the first sampling moment is any sampling moment among Z sampling moments; based on a first training data set, a pre-trained model is trained to obtain a candidate inference model corresponding to the first sampling moment; the first training data set includes sample data collected at the first sampling moment and sample data collected within a first preset time length before the first sampling moment, and the candidate inference model corresponding to the first sampling moment is used for inference tasks at and after the first moment, the first moment is located after the first sampling moment, and the time difference between the first moment and the first sampling moment is greater than or equal to the preset training time length.
12. A computing device, characterized in that: including a processor and a memory; The memory stores computer program instructions and stores at least one candidate reasoning model; The processor is configured to execute the computer program instructions stored in the memory so that the method according to any one of claims 1 to 6, or the method according to claim 7, or the method according to claim 8 or 9 is executed.
13. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1 to 6, or executes the method according to claim 7, or executes the method according to claim 8 or 9.
14. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 6, or executes the method according to claim 7, or executes the method according to claim 8 or 9.
15. A computer-readable storage medium, characterized in that: The method comprises computer program instructions. When the computer program instructions are executed by a computing device cluster, the computing device cluster executes the method according to any one of claims 1 to 6, or executes the method according to claim 7, or executes the method according to claim 8 or 9.
Citation Information
Patent Citations
Method and device for updating deep learning model, and system
CN107330522A
A network traffic prediction method and device
CN109873712A
Method and system for providing online prediction service by using machine learning model
CN110188910A
Time-phased traffic flow trend prediction method, system and device based on deep learning
CN111508230A
Cited By
Large model adaptive parallel training method capable of being used for heterogeneous cluster
CN119938327A