Data reasoning method, model training method and equipment

By dynamically updating the model training in the heterogeneous computing power system, and using a combination of real-time data and historical data, the problem of model training data lag in the heterogeneous computing power system is solved, and the accuracy and effectiveness of inference are improved.

CN119226791APending Publication Date: 2024-12-31HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310809417.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-06-30
Publication Date
2024-12-31

AI Technical Summary

Technical Problem

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, affecting the effectiveness of inference. Sex and accuracy.

Method used

By dynamically obtaining newer data in computing devices for model training, and inference is performed based on the model trained by newer sampled data, ensuring the effectiveness of the target inference model, thereby improving the inference accuracy. The specific method includes in the heterogeneous computing power system, the computing device obtains real-time data at each inference moment, and updates the model training based on the data and the data in a previous period of time, and obtains the latest candidate inference model as the target inference model.

Benefits of technology

It realizes dynamic update of the inference model in a heterogeneous computing power system, improves the accuracy and effectiveness of inference, ensures the matching of the model with real-time data, and improves the accuracy of inference.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119226791A_ABST
    Figure CN119226791A_ABST
Patent Text Reader

Abstract

The invention provides a data reasoning method, a model training method and equipment. In the data reasoning method, a computing device obtains first data, and the first data is real-time data at a first moment. The computing device obtains a target inference model from the at least one candidate inference model, the time difference between a first collection moment corresponding to the target inference model and the first moment is smaller than a preset threshold value, and the target training model is obtained by training a pre-training model based on a first training data set; the first training data set comprises sample data collected at a first sampling moment and sample data collected within a preset duration before the first sampling moment. And the computing device inputs the first data into the target reasoning model to obtain a first reasoning result. Through the scheme, the target reasoning model used by the computing device during reasoning is the model obtained by training based on the new sampling data, so that the effectiveness of the target reasoning model can be ensured, and the reasoning accuracy is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a data reasoning method, a model training method and a device. Background Art

[0002] With the continuous development of high performance computing (HPC) and related applications, the demand for computing power has further increased. Processors with a single computing type and architecture cannot meet the existing computing power requirements. Heterogeneous computing refers to parallel computing on heterogeneous computing systems. Heterogeneous computing systems can include computing units with different types of instruction sets and different architectures. Heterogeneous computing is widely used in cloud data centers, edge computing scenarios, etc. For example, heterogeneous computing can coordinate multiple hardware computing powers such as CPU, GPU, FPGA, ASIC, etc., so as to meet the application requirements in different scenarios, improve system computing power and reduce costs, and maximize computing efficiency. For example, with the development of artificial intelligence (AI) technology, heterogeneous computing solutions and application scenarios integrating HPC and AI have also been further expanded.

[0003] A common heterogeneous computing system includes general-purpose chips and AI chips, where general-purpose chips are, for example, CPUs, and are generally used in HPC computing scenarios; AI chips are acceleration chips such as graphics processing units (GPUs), field programmable gate arrays (FPGAs), and application-specific integrated circuits (ASICs), and are generally used in AI computing scenarios. In the application of heterogeneous computing power to model reasoning and training scenarios, since model training requires large AI computing resources and the reasoning process needs to be fast and stable, the common processing mode is that AI chips are used for offline training models, and general-purpose chips are used for online reasoning based on trained models.

[0004] When performing model inference and training based on the above, the model used for online inference of general chips is the model trained offline by the AI ​​chip. Reasoning based on this model will affect the accuracy of reasoning. Summary of the invention

[0005] The present application provides a data reasoning method, a model training method and a device, which are used to provide an accurate model training method and reasoning method, thereby improving the reasoning accuracy.

[0006] In the first aspect, the present application provides a data reasoning 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, the first data is data obtained at a first moment; obtains a target reasoning model from at least one candidate reasoning model, the at least one candidate reasoning model corresponds to different sampling moments, the first sampling moment corresponding to the target reasoning 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, 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 reasoning model to obtain a first reasoning result.

[0007] In the above method, the target reasoning model used by the computing device during reasoning is a model trained based on newer sampling data, thereby ensuring the effectiveness of the target reasoning model and further improving the reasoning accuracy.

[0008] In one possible design, a target reasoning model is obtained from at least one candidate reasoning model, including: determining at least two target candidate reasoning models from at least one candidate reasoning model, wherein the sampling moments corresponding to each of the target candidate reasoning models are both before the first moment, and the time difference between each of the target candidate reasoning models and the first moment is less than the first preset threshold; and obtaining the target reasoning model from the at least two target candidate reasoning models.

[0009] Acquiring a target reasoning model from the at least two target candidate reasoning models includes but is not limited to the following three methods.

[0010] The first method: the model serial number corresponding to the target reasoning model and the time serial number corresponding to the first time can meet the following conditions:

[0011] j=i-1

[0012] The j is the model number corresponding to the target inference model after the at least one candidate inference model is sequentially assigned a model 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 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 number corresponding to the first moment after the multiple inference moments are sequentially assigned a moment number from 0 to q in accordance with the order of the multiple inference moments from front to back, for example, the moment 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 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 number is less than a 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.

[0013] 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 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 close to the previous moment as the target inference model.

[0014] In a second manner, the model serial number corresponding to the target inference model and the time serial number corresponding to the first time may also meet the following conditions:

[0015] j = max(0, in);

[0016]

[0017] 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 allowed training time for training any of the candidate inference models; Δt is the sampling interval, which 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.

[0018] Through this design, when the maximum allowable duration for the computing device to execute a training task is greater than a sampling interval, when an inference moment arrives, the computing device may not have completed the model training based on the previous moment of the inference moment or a moment close to the previous moment, then the computing device can determine that the maximum allowable duration for executing a training task occupies the 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. In the first n inference moments, if the computing device has not completed the training of a candidate inference model, the most initial candidate inference model, i.e., the candidate inference model with a sequence number of 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 candidate inference model recently completed by the computing device and the inference moment is n sampling intervals. The computing device can use the candidate inference model corresponding to the model sequence number with a difference of 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 latest sampling data.

[0019] In a third manner, the model serial number corresponding to the target inference model and the time serial number corresponding to the first time may also meet the following conditions:

[0020]

[0021]

[0022]

[0023] The 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 order from front to back of the sampling moments corresponding to the at least one candidate inference model; p is a positive integer; the i is the moment serial number corresponding to the first moment after the moment serial numbers from 0 to q are assigned to the multiple inference moments in order from front to back; q is a positive integer. Please refer to the description of the first method above for the definition and explanation of the j and i, which will not be repeated here.

[0024] 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.

[0025] It is important to note that N here is the number of the candidate inference models that the computing device can train synchronously; s is a preset value;

[0026] 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. Regarding 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 it will not be repeated here.

[0027] Through this design, when the maximum allowed 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 third method, k takes a positive integer from 1 to N, and the candidate inference model that has completed the training most recently and can be obtained on each training channel can be determined respectively. For example, when N is 2, k takes a value of 1, which can be used to calculate 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, and k takes a value of 2, which can be used to calculate 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, and 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 completed the training of a candidate inference model, and the most initial candidate inference model, that is, the candidate inference model with a serial number of 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.

[0028] 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 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.

[0029] Through this design, when the computing device determines that an inference time has arrived, if the inference time is also a sampling time set in the inference model training process, a training task can be started based on the data obtained at the inference time and the data obtained within a period of time before the inference time, so as to add the data obtained at the inference time and the data obtained within a period of time before the inference time 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.

[0030] 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; 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 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.

[0031] In the above method, the computing device can start a training task when it determines that the sampling time has arrived. The sample data obtained at the current sampling time and within the preset time 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, thereby realizing the dynamic update of the inference model and ensuring the effectiveness and accuracy of the model.

[0032] In the third 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 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 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 of the training tasks are trained based on the model training method described in the second aspect.

[0033] 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, so as to ensure that the model training is carried out in an orderly manner.

[0034] 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.

[0035] Through this design, the computing device performs model training based on the sample data obtained at the sampling moment 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 at the subsequent multiple inference moments, further improving the inference accuracy.

[0036] In a fourth aspect, the present application provides a computing device, which includes an acquisition module and an inference module. The acquisition module is used to acquire first data, and 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, and 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 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.

[0037] 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 of the sampling moments 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.

[0038] 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 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.

[0039] 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 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.

[0040] In one possible design, the training module is also used to: determine 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; 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 respectively, and train any one of the training tasks based on the model training method as described in claim 7.

[0041] 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 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 the seventh aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed by a computing device cluster, causes 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.

[0043] 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.

[0044] 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.

[0045] 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

[0046] Figure 1 A schematic diagram of the architecture of a heterogeneous computing system provided in an embodiment of the present application;

[0047] Figure 2 It is a schematic diagram of the processing flow of a weather forecast model;

[0048] Figure 3 A flowchart of a model reasoning and data reasoning method provided in an embodiment of the present application;

[0049] Figure 4 A schematic diagram of the correspondence between different parameter relationships and selection methods provided in an embodiment of the present application;

[0050] Figure 5 A schematic diagram of the first candidate inference model and sampling time provided in an embodiment of the present application;

[0051] Figure 6 A schematic diagram of a second candidate inference model and sampling time provided in an embodiment of the present application;

[0052] Figure 7 A schematic diagram of a third candidate inference model and sampling time provided in an embodiment of the present application;

[0053] Figure 8A schematic diagram of another candidate inference model and sampling time provided in an embodiment of the present application;

[0054] Fig. 9 A schematic diagram of the scheduling of the data reasoning method provided in the embodiment of the present application;

[0055] Fig.10 A schematic diagram of a processing flow of a weather forecast model provided in an embodiment of the present application;

[0056] Fig.11 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;

[0057] Fig.12 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;

[0058] Fig.13 A schematic diagram of a computing device cluster provided in an embodiment of the present application;

[0059] Fig.14 A schematic diagram of a computing device cluster connection method provided in an embodiment of the present application. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. Among them, in the description of the embodiments of the present application, the terms "first" and "second" are used only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.

[0061] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "plurality" 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: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after 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.

[0062] With the continuous development of high performance computing (HPC) and related applications, the demand for computing power has further increased. Processors with a single computing type and architecture cannot meet the existing computing power requirements. Heterogeneous computing refers to parallel computing on heterogeneous computing systems. Heterogeneous computing systems can include computing units with different types of instruction sets and different architectures. Heterogeneous computing is widely used in cloud data centers, edge computing scenarios, etc. For example, heterogeneous computing can coordinate multiple hardware computing powers such as CPU, GPU, FPGA, ASIC, etc., so as to meet the application requirements in different scenarios, improve system computing power and reduce costs, and maximize computing efficiency. For example, with the development of artificial intelligence (AI) technology, heterogeneous computing solutions and application scenarios integrating HPC and AI have also been further expanded.

[0063] Figure 1 A schematic diagram of the architecture of a heterogeneous computing system provided in an embodiment of the present application. Figure 1 The heterogeneous computing system includes general-purpose chips and AI chips. Among them, general-purpose chips can be, for example, CPUs, which are generally used in HPC computing scenarios; AI chips can be, for example, graphics processing units (GPUs), field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), neural-networks process units (NPUs) and other acceleration chips, which are generally used in AI computing scenarios.

[0064] Figure 1 The heterogeneous computing system shown can be applied to model reasoning and training, where model reasoning can be applied to time series prediction models, which are models that infer future numerical changes based on the observed values ​​of the research variables themselves and their change patterns. For example, model reasoning can be applied to time series prediction scenarios such as weather forecasting and traffic situation forecasting. The reasoning model used in model reasoning can be obtained by model training based on the training data set by the heterogeneous computing system, and the model training process can be a process of continuously adjusting model parameters based on sample data in the training data set.

[0065] Optionally, Figure 1The heterogeneous computing system shown 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 an AISC, etc.); or Figure 1 The heterogeneous computing system shown can be implemented by a computing device cluster, which may include at least one computing device, each computing device may 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 system by computing devices as an example.

[0066] When applying heterogeneous computing systems to model reasoning and training scenarios, since model training requires large amounts 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 training models and general-purpose chips for online reasoning based on trained models.

[0067] When model inference and training are performed based on the above-mentioned processing model, the model used for online inference of general chips is the model trained offline by the AI ​​chip. The training data used when training the model lags behind the real-time data. Inference based on this model will affect the inference accuracy and effective range.

[0068] For example, taking the weather forecast model as an example, the processing flow of model training and reasoning in heterogeneous computing systems is introduced. Figure 2 This is a schematic diagram of the processing flow of a weather forecast model. 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 label data. For example, the feature data may be a numerical prediction value of weather conditions over a period of time in the past, and the label data may be an observed true value of 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 label data as output to train the pre-trained model to obtain an inference model. Reference Figure 2 ,The model training process performed by the AI ​​chip is an offline ,process. The model training process occurs before the actual ,reasoning process, such as Figure 2 The training process occupies the time span of the past N days before the -n moment, and the training results in a fixed offline model.

[0069] The general chip can obtain a trained fixed offline model from the AI ​​chip as an inference model. For example, at time 0, the numerical forecast value of the weather conditions in the next 24 hours (0:00 on the current day - 24:00 on the current day) can be input, and the AI ​​forecast value of the weather conditions in the next 24 hours output by the inference model can be obtained. Assuming that the inference time interval is set to 3 hours, at time 03, the numerical forecast value of the weather conditions in the next 24 hours (03:00 on the current day - 03:00 the next day) can be input, and the AI ​​forecast value of the weather conditions in the next 24 hours output by the inference model can be obtained.

[0070] It is understandable that based on the above model training and reasoning methods, as time goes by, since the training data used by the offline model lags behind the real-time data, the effectiveness of the offline model as an inference model will be greatly weakened, affecting the accuracy of real-time reasoning.

[0071] 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.

[0072] 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.

[0073] The data inference method and model training method provided in the embodiments of the present application can be performed by Figure 1 The method can be used for training and reasoning of time series prediction models, which are models that predict future value changes based on the observed values ​​of the research variables themselves and their change patterns. For example, Figure 2 The model shown for predicting future weather conditions is a time series prediction model.

[0074] 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.

[0075] The following first introduces the model training method provided in the embodiment of the present application. Figure 3 A flowchart of a model training and data reasoning method provided in an embodiment of the present application, Figure 3 The steps in the above method 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 will be given by taking the first device as an example, and will also describe which of the following steps can be executed by which processing chip.

[0076] refer to Figure 3 , the method comprises the following steps:

[0077] S301: The computing device determines that a first sampling time has been reached.

[0078] In an embodiment of the present application, the computing device may 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 may be any sampling moment among the Z sampling moments. The computing device may 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 may be used for model training, such as sample data may include feature data and label data.

[0079] 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.

[0080] 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.

[0081] Based on the above description, it can be understood that the training data sets used by the training tasks started by the computing device at different sampling moments will be different, and the candidate inference models trained based on different training data sets will also be different, that is, the candidate inference models trained 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 a first preset time before the first sampling moment. For example, assuming that the first preset time 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 and sample data collected within 30 days before t1.

[0082] In an optional implementation, 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, and calculate the loss value 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, and repeat multiple rounds of training to obtain the candidate inference model corresponding to the first sampling moment.

[0083] 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.

[0084] It can be understood 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 reasoning model corresponding to t1 based on the training set D1 at sampling time t1, and start training the candidate reasoning 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 in the order of 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 next sampling time t3 of t2 is reached, the training task corresponding to t1 and the training task corresponding to t2 are not completed, and the computing device has no idle computing power available to execute the training task corresponding to t3, 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 times corresponding to the queued training tasks from front to back.

[0085] In some embodiments, the computing device may start the first training task at the rth 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 rth sampling moment and the sample data sampled within a preset time length before the rth sampling moment. When at least one sampling moment before the rth sampling moment is reached, the computing device can collect sample data, but the training task may not be initiated, so that the computing device can reasonably allocate 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 following data inference method, which will not be described in detail here.

[0086] Exemplarily, the above S301-S302 can be performed by Figure 1 The AI ​​chip in the computing device is executed.

[0087] S303: The computing device obtains first data at a first moment.

[0088] In one embodiment of the present application, the computing device may determine multiple reasoning moments from the initial reasoning moment according to a preset time interval, the time difference between any two adjacent reasoning moments is the preset time interval, the first moment is any one of the multiple reasoning moments, and the first moment is after the first sampling moment in S301. The computing device may obtain real-time data at each reasoning moment, and perform reasoning based on the reasoning model according to the real-time data. For example, assuming that the preset time interval is 3 hours, the computing device may obtain real-time data every 3 hours for reasoning.

[0089] In the embodiment of the present application, according to the order of the multiple sampling moments from front to back, the time sequence numbers from 0 to w can be assigned to the multiple sampling moments in sequence, w is a positive integer, for example, according to the order of the multiple sampling moments from front to back, the time sequence numbers 1, 2, 3...w, etc. are assigned to each sampling moment; and according to the order of the multiple reasoning moments from front to back, the time sequence numbers from 0 to q are assigned to the multiple reasoning moments in sequence, q is a positive integer, for example, according to the order of the multiple reasoning moments from front to back, the time sequence numbers 1, 2, 3...q, etc. are assigned to each reasoning moment. The sampling moment with the time sequence number 0 can be considered as the initial sampling moment, and the reasoning moment with the time sequence number 0 can be considered as the initial reasoning moment. In the embodiment of the present application, the difference between the reasoning moment and the sampling moment with the same sequence number is less than the second preset threshold value, such as the sampling moment and the reasoning moment with the sequence number 5 can be the same moment, or a close moment, that is, the sampling moment and the reasoning moment with the same sequence number 5 are theoretically the same time point or a relatively close time point, so as to ensure that when different reasoning moments arrive, the accurate target reasoning model can be more accurately obtained from the multiple candidate reasoning models that have been trained.

[0090] S304: The computing device obtains a target reasoning model from at least one candidate reasoning model.

[0091] Through the introduction of S301-S302, it can be known that the computing device can start a model training when it is determined that the sampling moment has arrived, 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 located 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, and 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 in at least one candidate inference model.

[0092] Exemplarily, the above S303-S304 can be performed by Figure 1 It is executed by the general-purpose chip CPU in the computing device.

[0093] 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 respective sampling moments are both before the first moment and whose time differences with the first moment are 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.

[0094] For example, the computing device may randomly obtain a target reasoning model from at least two target candidate reasoning models. However, in order to more accurately obtain a target reasoning model from at least two target candidate reasoning models to improve the accuracy of reasoning, the present application proposes three different methods to obtain a target reasoning model from at least two target candidate reasoning models, which will be described below.

[0095] Before describing the three ways to select the target inference model, some parameter definitions are explained.

[0096] Moment sequence number of the sampling moment: according to the order of the at least one sampling moment from front to back, the multiple sampling moments are sequentially assigned moment sequence numbers from 0 to w.

[0097] 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 order from front to back 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.

[0098] 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.

[0099] The number of candidate inference models that the computing device can train simultaneously: The computing device can train N models in parallel when training models. 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 the GPU chip of the computing device 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.

[0100] 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 certain completion time and cannot be performed indefinitely. Here, the maximum time allowed to complete a model training process 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 the maximum allowed time.

[0101] 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…tn, the time interval between any two adjacent sampling moments can be the same, that is, it can be periodic sampling. Here, the interval between any two sampling moments is defined as the sampling interval.

[0102] First parameter n: The first parameter and the maximum allowed training duration and sampling interval can satisfy the following relationship:

[0103]

[0104] in, The first parameter n is a rounding-up operator. The first parameter n may represent the maximum allowed duration for the computing device to execute a training task as a number of sampling intervals n. For example, when the maximum allowed duration for executing a training task is 2.4 times the sampling interval, the value of n may be 3.

[0105] In an embodiment of the present application, based on the above-mentioned multiple parameters, different target reasoning model selection methods may be associated with different parameters. Figure 4 A schematic diagram of the relationship between different parameters and the selected target reasoning model provided in the embodiment of the present application. Figure 4 , when Ttrain When T is less than or equal to Δt, the computing device may select the target reasoning model according to the following selection method 1; train When Δ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 reasoning model according to the following selection method 3. The following introduces the three selection methods respectively.

[0106] Selection method 1: T train When it is less than or equal to Δt, Figure 5 A schematic diagram of the relationship between the first candidate inference model and the sampling time provided in the embodiment of the present application. Figure 5 , assuming that the inference moment and the sampling moment with the same sequence 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 at the first moment as the target inference model. In this case, the sequence number of the first moment and the model sequence number of the target inference model can meet the following conditions:

[0107] j=i-1Condition 1

[0108] Among them, j is the model number of the target reasoning model, and i is the moment number of the first moment.

[0109] For example, refer 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 the model number 1 as the target reasoning model.

[0110] Selection method 2: When T train When is greater than Δt and n is less than or equal to N, Figure 6 A schematic diagram of the relationship between the second candidate inference model and the sampling time provided in the embodiment of the present application. Figure 6 , indicating T train When n is greater than Δt, the computing device needs to allocate different computing power to each training task when it receives the training task. When n is less than or equal to N, it means that the computing device has sufficient computing power resources for model training, and the computing device can start each training task in time.

[0111] 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 conditions:

[0112] j=max(0,in)Condition 2

[0113] Among them, j is the model number of the target reasoning model, and i is the moment number of the first moment.

[0114] Based on the above condition 2, if the computing device has not completed the training of a candidate inference model in the first n inference moments, the most initial candidate inference model, i.e., the candidate inference model with serial 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 candidate inference model that the computing device has recently completed training and the inference moment is n sampling intervals, and the computing device can obtain a candidate inference model with a model serial number and a time serial number difference of n at 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 sampling data.

[0115] For example, refer to Figure 6 , assuming that n is 3 and N is 4. The first moment is t2, and the moment number of the first moment is 2. At this time, the computing device can determine that the model number of the target reasoning model is 0 according to the above condition 2, and the computing device can obtain the initial reasoning model as the target reasoning model. Figure 6 It can be seen that at time t2, the computing device has not completed the training of the candidate inference model m1 with model number 1, so the computing device needs to obtain the initial inference model as the target inference model.

[0116] 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.

[0117] Selection method 3: T train When is greater than Δt, and n is greater than N, Figure 7 A schematic diagram of the third candidate inference model and sampling time provided in the embodiment of the present application. Figure 7 , when T train When it is greater than Δt, it means that the computing device needs to spend more time than a sampling interval to perform a model training. In this case, the computing device needs to allocate different computing power to each training task when receiving the training task. When n is greater than N, it means that the computing power resources of the computing device can be started immediately after receiving the first N training tasks, but the training tasks released later need to wait in line for the computing power to be idle.

[0118] In some embodiments of the present application, the computing device may start the process of model training based on the sample data acquired in real time after a preset time after the initial sampling moment. In implementation, the computing device may start the first training task at the rth sampling moment among the Z sampling moments, and at 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 start the training task.

[0119] In this design, the time sequence number of the first moment and the model sequence number of the target inference model can satisfy the following conditions:

[0120]

[0121]

[0122] 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 and N, that is, is the floor rounding operator. s is the preset value.

[0123] As described above, the computing device can allocate different computing resources for different training tasks. For example, if the same computing resources are used as a training channel, the number of candidate inference models that can be trained simultaneously by the computing device is N. Then the computing device has N training channels. Based on the above condition 3, k is a positive integer from 1 to N, and the candidate inference model that has completed the training most recently that can be obtained on each training channel can be determined respectively. Figure 7 , when N is 2, k takes the value of 1 to calculate the model number of the first 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, and k takes the value of 2 to calculate the model number of the second 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 inference model with the largest serial number from the two determined model serial numbers and model serial number 0 as the target inference model. When the maximum value is 0, it means that the computing device has not completed the training of a candidate inference model, and the most initial candidate inference model, that is, the candidate inference model with serial 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 sampling data.

[0124] For example, refer to Figure 7 , Figure 7 In this paper, s=1, n=3, N=2 are used as an example. After the computing device obtains the data at time t1, according to the above condition 3, when k takes the value 1, When k is 2, So j=0, and then the model number of the target reasoning model is determined to be 0, and the computing device can obtain the initial reasoning model m0 as the target reasoning model.

[0125] 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 j=0, the model number is determined to be 0, and the computing device can obtain the initial reasoning model m0 as the target reasoning 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 the sample data obtained within the first preset time before time t2 to obtain the candidate reasoning model m2.

[0126] For another example, suppose s=1, n=3, N=2. The first moment is t6, and the moment number of the first moment is 6. At this time, the computing device can, according to the above condition 3, when k takes the value 1, When k is 2, So j=2+1=3, and then the model number of the target reasoning model is determined to be 3, and the computing device can obtain the initial reasoning model m3 as the target reasoning model.

[0127] In the above-mentioned option 3, the computing device can also start model training based on the sample data acquired in real time at the sampling moment with the moment number 1, that is, s can directly take the value 0. Figure 8 A schematic diagram of another candidate inference model and sampling time provided in an embodiment of the present application. In this case, the time sequence number of the first time and the model sequence number of the target inference model can satisfy the following conditions:

[0128]

[0129] 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 and N, that is, It is understandable that when s is 0, condition 3 can be changed to condition 4, so 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 reasoning model based on condition 4 can refer to the method of determining the model number of the target reasoning model based on condition 3 mentioned above, and the repeated parts will not be repeated.

[0130] For example, refer to Figure 8 , assuming 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 calculate the value of k according to the above condition 4. When k is 2, Then j = max(0, -1, 0) = 0, and the model number of the target reasoning model is determined to be 0. The computing device can obtain the initial reasoning model as the target reasoning model. Figure 7 It can be seen that at time t2, the computing device has not completed the training of the candidate inference model with model number 1, and the computing device needs to obtain the initial inference model as the target inference model.

[0131] For another example, suppose n is 3 and N is 2. The first moment is t6, and the moment 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.

[0132] 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.

[0133] By comparison Figure 8 The model training starts from time t1 and Figure 7 The model numbers of the target inference models in two cases where model training starts from time t2 are shown. It can be seen that when the computing device starts model training from 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, and one negative optimization brings positive optimization at multiple moments later. Therefore, starting model training at the rth sampling time after the initial sampling time can further improve the inference accuracy.

[0134] Exemplarily, the above S304 may be performed by Figure 1 The general-purpose chip in the computing device is executed. Optionally, after determining the model serial number of the target reasoning model, the general-purpose chip can obtain the candidate reasoning model corresponding to the model serial number from the AI ​​chip according to the model serial number, and use the candidate reasoning model sent by the AI ​​chip as the target reasoning model.

[0135] S305: The computing device inputs the first data into the target reasoning model to obtain a first reasoning result.

[0136] After acquiring the target reasoning model, the computing device may input the first data into the target reasoning model and acquire the first reasoning result output by the target reasoning model to complete a reasoning process.

[0137] Exemplarily, the above S305 may be performed by Figure 1 It is executed by general-purpose chips in computing devices.

[0138] By implementing the above method, the computing device can add the data acquired at the time of reasoning and the data acquired within a period of time before the time of reasoning to the training data set, and train the pre-trained model to obtain a new candidate reasoning model, so that the candidate reasoning model can be dynamically updated during the reasoning process to ensure the validity and accuracy of the reasoning. The specific model training method can refer to the model training method shown in S301-S302, which will not be repeated here.

[0139] For ease of explanation, this application Figure 3 The illustrated embodiment introduces the training process of the candidate inference model corresponding to the first sampling moment and the process of inference at the first moment using the candidate inference model corresponding to the first sampling moment, but the 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 of each inference moment. For specific implementation, see S303-S305, and the repeated parts will not be repeated.

[0140] Understandably, Figure 3 The execution of the model training method and the data inference method by the computing device 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.

[0141] based on Figure 3 The embodiment shown, Fig. 9 A schematic diagram of the scheduling of the data reasoning method provided in the embodiment of the present application. Fig. 9 , the computing device is at t i Get real-time data x at all times i After that, the candidate inference model m can be obtained j , and obtain the candidate inference model m j As t i The target reasoning model M at the moment i Among them, Fig. 9 As shown inj 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 convert 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 and updating the inference model in a timely manner to improve the inference accuracy.

[0142] In addition, refer to Fig. 9 The model training process can be executed by the AI ​​chip of the computing device, and the model reasoning process can be executed by the general-purpose chip of the computing device, thereby improving the resource utilization of the AI ​​chip without affecting the normal business of the general-purpose chip, and realizing the efficient operation of the heterogeneous computing system.

[0143] By comparing the data inference method provided in the embodiment of the present application with the existing model training and inference method, since the existing offline training and online inference scheme has completed the offline model training before online inference, there is no need to consider the training time. The total time required for the existing scheme to perform S inference tasks is S*T test , where T test Indicates 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 at the first s preset moments, and first performs model training tasks at each preset moment after the sth preset moment, and then performs inference based on the candidate inference model corresponding to the preset moment after obtaining a 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 the model reasoning is performed based on the data reasoning method provided in the embodiment of the present 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 in the embodiment of the present application is superior to the existing solution in terms of total training and inference time and accuracy.

[0144] In some embodiments, the data reasoning method provided in the embodiments of the present application can be applied to the training and reasoning of a weather forecast model, for example, Fig.10 A schematic diagram of a processing flow of a weather forecast model provided in an embodiment of the present application. Fig.10, assuming that the training time is 30 days, the computing device can obtain 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 in the next 24 hours (0 o'clock on the day - 24 o'clock on the day) into the target reasoning model, and obtain the AI ​​prediction value of the weather conditions in the next 24 hours output by the reasoning model. The computing device can also obtain 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 reasoning at 3 o'clock, the computing device can obtain the candidate reasoning model m2 as the target reasoning model, and the computing device can input the numerical prediction value of the weather conditions in the next 24 hours (3 o'clock on the current day to 3 o'clock the next day) into the target reasoning model, and obtain the AI ​​prediction value of the weather conditions in the next 24 hours output by the reasoning model. Through this solution, the computing device can roll the training model based on the acquired sample data, thereby updating the reasoning model and improving the reasoning accuracy.

[0145] In combination with the above method embodiments, the 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. Fig.11 A schematic diagram of the structure of a computing device 1200 provided in an embodiment of the present application. Fig.11 The computing device may include an acquisition module 1201, a reasoning module 1202, and may also include a collection module 1203 and a training module 1204.

[0146] The acquisition module 1201 can be used to acquire data. For example, the acquisition module 1201 can be used to execute Figure 3 S303 in the illustrated embodiment. The reasoning module 1202 can be used to perform a model reasoning task. For example, the reasoning module 1202 can obtain a target reasoning model from at least one candidate reasoning model. The target reasoning model is a 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 perform Figure 3 S304-S305 in the illustrated embodiment.

[0147] The acquisition module 1203 may be configured to acquire sample data at each of Z sampling moments; Z is a positive integer.

[0148] 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. Figure 3 S301 - S302 in the illustrated embodiment.

[0149] It should be noted that the division of functional modules in the embodiments of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation. 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, or two or more functional modules may be integrated into one functional module, such as the acquisition module 1201 and the acquisition module 1203 may be integrated into one functional module. The above-mentioned integrated functional modules may be implemented in the form of hardware or in the form of software functional modules.

[0150] 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 to enable a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (processor) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.

[0151] The present application also provides a computing device 1300. Fig.12 As shown, the computing device 1300 includes: a bus 1302, a processor 1304, a memory 1306, and a communication interface 1308. The processor 1304, the memory 1306, and the communication interface 1308 communicate through the bus 1302. The computing device 1300 can be a server or a terminal device. It should be understood that the present application does not limit the number of processors and memories in the computing device 1300.

[0152] The bus 1302 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.12 The bus 1302 may include a path for transmitting information between various components of the computing device 1300 (eg, the memory 1306, the processor 1304, and the communication interface 1308).

[0153] The processor 1304 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).

[0154] The memory 1306 may include a volatile memory, such as a random access memory (RAM). The processor 1304 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).

[0155] The memory 1306 stores executable program codes, and the processor 1304 executes the executable program codes to respectively 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 embodiment of the present application. That is, the memory 106 stores instructions for executing the data reasoning method and the model training method.

[0156] 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 communication networks.

[0157] The embodiment of the present application also provides 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 smart phone.

[0158] like Fig.13 As shown, 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.

[0159] 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 instructions for executing the method of the embodiment of the present application.

[0160] It should be noted that the memory 1306 in different computing devices 1300 in the computing device cluster may store different instructions, which are respectively used to execute part of the functions performed by the computing devices in the above method embodiments. That is, 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.

[0161] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.14 A possible implementation is shown. Fig.14 As shown, two computing devices 1300A and 1300B are connected via a network. Specifically, the network is connected 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.

[0162] The present application embodiment also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to that of Fig.13 and Fig.14 The connection mode of the computing device cluster is different in that the memory 1306 in one or more computing devices 1300 in the computing device cluster may store the same instructions for executing the data reasoning method and the model training method.

[0163] 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.

[0164] Based on the above embodiments, the present application further provides a computer program. When the computer program is run on a computer, the computer is enabled to execute the methods described in the embodiments of the present application.

[0165] 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.

[0166] 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 cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of the present invention.

[0167] 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.

[0168] The processor mentioned in any of the above places can be a general-purpose central processing unit, a microprocessor, an application-specific integrated circuit (ASIC), or one or more processors for controlling the above Figure 8 The integrated circuit for executing the program of the method in the illustrated embodiment. The memory mentioned in any of the above places can be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, a random access memory (RAM), etc.

[0169] 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 complete hardware embodiments, complete software embodiments, or embodiments 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 disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0170] These computer program instructions may also be stored in a computer-readable memory capable of directing 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 an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0171] 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, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0172] 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 is also intended to include these 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 serial number corresponding to the target inference model and the time serial 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 serial number corresponding to the target inference model and the time serial 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.