Method, apparatus, and computer equipment for training a model underlying a future time series forecasting task
The transformer-based foundation model with channel-wise normalization and two-stage attention addresses inefficiencies in existing time series forecasting by capturing cross-domain patterns, enabling accurate zero-shot predictions.
Patent Information
- Application Number
- PCT/CN2024/072825
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2024-01-17
- Publication Date
- 2025-07-24
AI Technical Summary
Existing time series forecasting models, particularly multivariate time series forecasting, face challenges in efficiently capturing similar patterns across different time series and require extensive training on each dataset, leading to inefficiencies and poor performance in large-scale applications.
A foundation model architecture utilizing a transformer encoder with channel-wise instance normalization, patching, and two-stage self-attention to learn temporal and cross-channel correlations, enabling zero-shot forecasting without additional training on diverse domains.
The proposed model achieves accurate and efficient future time series predictions by mitigating distribution shifts and reducing computational complexity, outperforming existing models in zero-shot forecasting tasks across various domains.
Smart Images

Figure CN2024072825_24072025_PF_FP_ABST
Abstract
Description
METHOD, APPARATUS, AND COMPUTER EQUIPMENT FOR TRAINING A MODEL UNDERLYING A FUTURE TIME SERIES FORECASTING TASKTECHNICAL FIELD
[0001] This application relates to the field of machine learning, and in particular, to the field of time series forecasting, specially to a method, apparatus, and computer equipment for training a model underlying a future time series forecasting task.BACKGROUND
[0002] Multivariate time series (MTS) refer to a type of data that involve multiple variables or features recorded over time. MTS forecasting (MTSF) , one of the most important cases of time series analysis, is the task of predicting the future values of multiple variables simultaneously based on their historical values and other potentially relevant information. MTSF is widely used in abundant real-world applications such as weather variations, energy consumption, economics changes, etc.SUMMARY
[0003] This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is intended to be used as an aid in determining the scope of the claimed subject matter.
[0004] Based on this, this application discloses a method for training a model underlying a future time series forecasting task, comprising:
[0005] dividing the past time series into a plurality of sequence blocks at a channel level and linearly embedding of said plurality of sequence blocks;
[0006] adding positional embedding to the linear embedding of said plurality of sequence blocks;
[0007] inputting said embedded plurality of sequence blocks into an encoder;
[0008] outputting a predicted future time series based on said encoder.
[0009] Through the foregoing manner, a more accurate prediction of the future time series can be obtained from a limited number of past time series with zero sample (zero shot) training.
[0010] Further, wherein, before dividing the past time series into a plurality of sequence blocks at a channel level, further comprising:
[0011] performing instance level normalization and zero padding on said past time series.
[0012] According to the above approach, due to the prevalence of non-stationarity in the time series data, channel-wise instance normalization can largely mitigate the distribution shift problem between the training and testing data.
[0013] Further, wherein inputting said embedded plurality of sequence blocks into the encoder, comprising:
[0014] passing said plurality of sequence blocks through the processing of temporal attention and channel attention; wherein said temporal attention and said channel attention have the same weights.
[0015] In the above manner, temporal attention is used to learn the temporal correlation between different time series segments within a single channel (or single variable) ; and cross-channel attention is used to learn the correlation between different time series channels, thereby providing a subsequent more accurate prediction of the time series.
[0016] Further, wherein outputting a time series for predicting the future, according to said encoder, comprises:
[0017] outputting a time series according to said encoder;
[0018] obtaining said predicted time series by passing said time series through prediction header and the instance level denormalization.
[0019] In the above manner, it is possible to have a function of linear activation and a reduction of the time series on normalization, which ultimately results in an accurate predicted time series.
[0020] In addition, this application further discloses an apparatus for training a model underlying a future time series forecasting task, including:
[0021] a channel-wise sequence dividing module, configured to divide the past time series into a plurality of sequence blocks at channel level and linearly embedding of said plurality of sequence blocks;
[0022] a positional embedding module, configured to add positional embedding to the linear embedding of said plurality of sequence blocks;
[0023] an encoder module, configured to input said embedded plurality of sequence blocks into an encoder;
[0024] a time series output module, configured to output a predicted future time series based on said encoder.
[0025] This application further provides a computer device, including a memory and a processor, where the memory stores a computer program, and the processor, when executing the computer program, implements the foregoing method.
[0026] This application further provides a computer-readable storage medium, storing a computer program, where the computer program, when executed by a processor, implements the foregoing method.
[0027] This application further provides a computer program product, tangibly stored on a computer-readable medium and including computer-executable instructions, where the computer-executable instructions, when executed, cause at least one processor to perform the foregoing method.BRIEF DESCRIPTION OF THE DRAWINGS
[0028] In the accompanying drawings, implementations of the present disclosure are described herein in the form of examples and non-restriction, and the similar reference numerals in the accompanying drawings represent the same or similar components.
[0029] FIG. 1 is a schematic flowchart of a method for training a model underlying a future time series forecasting task according to an embodiment of this application;
[0030] FIG. 2 is a schematic diagram of an apparatus for training a model underlying a future time series forecasting task according to an embodiment of this application.
[0031] FIG. 3 is a schematic diagram of a computer device for training a model underlying a future time series forecasting task according to an embodiment of this application.
[0032] FIG. 4 is a schematic flowchart of a method for training a model underlying a future time series forecasting task according to an embodiment of this application.
[0033] FIG. 5 is a result diagram of a method for training a model underlying a future time series forecasting task according to an embodiment of this application.
[0034] List of reference numerals is as follows. S101-S104 Steps 200: Apparatus 201: Module 202: Module 203: Module 204: Module 300: Computer device 302: Processor 304: MemoryDETAILED DESCRIPTION
[0035] In the following specification, for the purpose of explanation, many specific details are provided. However, it may be understood that implementations of the present invention can be implemented without such specific details. In other examples, well-known circuits, structures, and technologies are not shown in detail so as not to obscure the understanding of the specification.
[0036] References throughout this specification to "one implementation, " "an implementation, " "an example implementation, " "some implementations, " "various implementations, " and the like represent that the described implementations of the present invention may include particular features, structures, or characteristics. However, not every implementation is required to include such specific features, structures, or characteristics. In addition, some implementations may have some, all, or none of the features described for another implementation.
[0037] With the rapid development of deep learning, numerous methods have been proposed for MTSF. Drawing inspiration from the recent achievements in natural language processing (NLP) and computer vision (CV) , transformer has been introduced to handle time series tasks, which shows great potential due to its exceptional ability to capture long-term dependencies.
[0038] Recently, there has been notable progress in the development of foundation models based on transformers in NLP, such as Generative Pre-Trained Transformers (GPTs) . The primary idea is to train a large model using a substantial amount of data. In this invention, there proposes a method for training foundation models tailored for MTSF. The model once being trained on a large-scale time series dataset which covers time series data from diverse domains, can be used for zero-shot MTSF, meaning that no further training needs to be done for even unseen time series data.
[0039] Futhermore, the mainstream of prior arts for time series forecasting in early age are local univariant models based on statistics, such as Autoregressive Integrated Moving Average Model (ARIMA) and exponential smoothing, which fit each time series individually in a dataset. However, these models exibit low efficiency when dealing with large-scale time series. Moreover, due to being trained on each time series independently, they fail to capture similar patterns that may exist across different time series.
[0040] Deep learning models, which have been successfully applied in NLP and CV, have also been introduced in time series forecasting and have shown superior performance compared to traditional statistical methods. For example, recurrent neural networks (RNNs) and convolutional neural networks (CNNs) have historically been widely utilized for time series forecasting applications.
[0041] More recently, transformers have demonstrated exceptional modeling capability for long-range dependencies and interactions in sequential data and thus are appealing to time series modeling. Several variants of transformer have been proposed to tackle challenges in time series modeling and have been successfully applied to various time series tasks including forecasting. The first category of variants is to design new attention modules. Examples include LogTrans, Informer, Pyraformer and FEDformer, all of which exploit sparsity inductive bias or low-rank approximation to remove noise and achieve a low computational complexity. The second category of variants focuses on normalizing time series data. To the best of our knowledge, Non-stationary Transformer is the only work that primarily concentrates on modifying the normalization mechanism. The third category of variants involves utilizing the bias for token input. Autoformer introduces a seasonal-trend decomposition architecture with an auto-correlation mechanism functioning as an attention module. PatchTST adopts a subseries-level patch design, dividing the time series into subseries-level patches that are served as input tokens to transformer. Crossformer proposes a transformer-based model with cross-dimension dependency for MTSF.
[0042] None of the above works serve as the foundation models for time series forecast, meaning that a model has to be trained for each task / dataset
[0043] This application discloses a method for training a model underlying a future time series forecasting task, comprising:
[0044] S101. dividing the past time series into a plurality of sequence blocks at channel level and linearly embedding of said plurality of sequence blocks.
[0045] Specifically, said past time series is current as well as past data, which can be represented as:given a set of multivariate time series samples with a look-back window T: (x1, …, xT) where each xt at time step t is a vector of dimension C. Dividing the past time series into a plurality of sequence blocks at channel level is that spliting an input multivariate time series into fixed-size patches channel-wise. In some embodiment, the terms of “channel level” could also be interepted as “channel wise” .
[0046] S102. adding positional embedding to the linear embedding of said plurality of sequence blocks.
[0047] Specifically, for each of the plurality of fixed-size sequence blocks obtained above, the positional embedding is added based on the linear embedding of the plurality of fixed-size sequence blocks.
[0048] S103. inputting said embedded plurality of sequence blocks into an encoder.
[0049] Specifically, the sequence block after the above position embedding is input to the encoder.
[0050] Further, wherein inputting said embedded plurality of sequence blocks into the encoder comprises:
[0051] passing said plurality of sequence blocks through the processing of temporal attention and channel attention; wherein said temporal attention and said channel attention have the same weights.
[0052] Specifically, after the sequence block is input to the encoder, it first undergoes temporal attention processing, then channel attention processing, and finally also undergoes Multi-Layer Perception (MLP) processing. In some embodiments, each of the time-attention, channel-attention, and multi-layer perception processing described above is preceded by Layer Norm processing.
[0053] Through above manner, the causal temporal attention is used to learn temporal correlations among different time series patches within a single channel, i.e., a single variate. The cross-channel attention is used to learn correlations among different time series channels, thereby providing a more accurate predicted time series subsequently.
[0054] S104. outputting a predicted future time series based on said encoder.
[0055] According to the above approach, a more accurate prediction of future time series can be obtained from a limited number of past time series with zero samples (or zero shot) for training, thus having an important predictive role in the field of linear time properties
[0056] Further, wherein outputting a time series for predicting the future, according to said encoder, comprises:
[0057] outputting a time series according to said encoder;
[0058] obtaining said predicted time series by passing said time series through prediction header and the instance level denormalization.
[0059] In some embodiments, said forecast head, which may also be referred to as a temporal head, which is a feed forward layer with linear activation.
[0060] With the above approach, it is possible to have a function of linear activation and a reduction of the time series on normalization, which ultimately results in an accurate predicted time series, thus, it is more inspiring for the field of time series forecasting base models.
[0061] Further, wherein, before dividing the past time series into a plurality of sequence blocks at a channel level, further comprising:
[0062] performing instance level normalization and zero padding on said past time series.
[0063] According to the above approach, due to the prevalence of non-stationarity in the time series data, instance normalization can largely alleviate the problem of distributional bias between the training data and the test data.
[0064] Specifically, in some embodiments, the present application further addresses the following issues: given a set of multivariate time series samples with a look-back window T: (x1, …, xT) where each xt at time step t is a vector of dimension C, we would like to forecast L future values (xT+1, …, xT+L) . The key technical feature in our invention is a foundation model achitecture tailored for cross-domain multivariate time series forecasting tasks as depicted in Figure 4. Specifically, we split an input multivariate time series into fixed-size patches channel-wise, linearly embed each of them, add position embeddings, and feed the resulting sequence of patches to the encoder. The encoder has an extra channel attention stage compared with the standard transformer, the temporal attention and channel attention share the same weights. We add a linear head to the last token to performance forecasting. During inference, we add Reversible Instance Normalization (RevIN) layers to normalize and denormalize time series channels and pad zeros in front of time series samples with less than T data points. In this way, no normalization is needed for input data before using our model which significantly improves the convenience of model usage during inference.
[0065] Basically, our model makes use of the transformer encoder as its core architecture, but there are several key distinctions in our foundation model architecture. We outline the key components which makes our proposed architecture suitable for training foundation models for time series forecasting:
[0066] Channel-wise instance normalization: we normalize each single time series instance to zero mean and unit variance across each dimension. Channel-wise instance normalization can largely mitigate the distribution shift problem between the training and testing data as none-stationarity widely exists in time series data.
[0067] Patching: we aggregate data in adjacent time steps to form a single patch-based token as the input of encoder. This is because a single time step does not have semantic meaning, however, aggregating time steps into patches can enrich semantic information of each input token. Moreover, patching can also reduce the complexity on time and space of the model, from T^2 to (T / P) ^2, where T is original time steps, P is the patch size.
[0068] Two-stage self-attention: we apply two attentions in each encoder layer, which are masked causal temporal attention and cross-channel attention without masking. Specifically, the masked causal temporal attention is used to learn temporal correlations among different time series patches within a single channel, i.e., a single variate. The cross-channel attention is used to learn correlations among different time series channels.
[0069] Experiments
[0070] We trained a foundation model using the proposed architecture on a large corpus of collected time series data. The model has 4 encoder layers, each layer has 6 attention heads and the embedding dimension is set to 384. We set the maximum input length (time steps) for the model to 1024, patch size to 64, max time series channels to 32. This results in about 7 million parameters to be trained.
[0071] We collected a large-scale time series dataset which contains 50 million time series data samples covering diverse domains including industrial sensing, environmental sensing, biology signals, transportation flows, financial data, and many more.
[0072] The foundation model trained on the collected data has shown excellent zero-shot forecasting abilities. Figure 5 illustrates some examples of zero-shot forecasting using our foundation model in different tasks.
[0073] We also compare forecasting accuracy in terms of mean absolute error with start-of-the-art time series forecasting models on the ETT public benchmark dataset, the results are given below:
[0074] Table 1 Experimental results for the public benchmark dataset
[0075] It should be understood that although the individual steps in the flowchart of FIG. 1 are shown sequentially as indicated by the arrows, these steps are not necessarily executed sequentially in the order indicated by the arrows. Unless expressly stated herein, there is no strict order limitation on the execution of these steps, and the steps may be executed in other orders. Moreover, at least a portion of the steps of FIG. 1 may include a plurality of steps or a plurality of stages, which are not necessarily executed to completion at the same moment, but may be executed at different moments, and the order in which these steps or stages are executed is not necessarily sequential, but may be executed in turn or alternately with at least a portion of other steps or steps or stages in other steps.
[0076] As can be seen from the table, zero-shot forecasting using our foundation models beats LSTM and Informer models on all scenarios, and beats other models in half of the scenarios. It is worthy to highlight that all the models except ours are trained on the benchmark datasets.
[0077] Differences between this application and the prior art: existing time series forecasting models need to be trained on the end-task dataset. The foundation model trained using our proposed architecture can do zero-shot forecasting. This advantage significantly improves the practice usage of our model due to better data and computing efficiency.
[0078] Checking whether the same or similar model structure is used can be done by checking whether the model of this application is applied.
[0079] FIG. 2 provides an apparatus 200 for training a model underlying a future time series forecasting task, comprising:
[0080] a channel-wise sequence dividing module 201, configured for dividing the past time series into a plurality of sequence blocks at channel level and linearly embedding of said plurality of sequence blocks;
[0081] a positional embedding module 202, configured for adding positional embedding to the linear embedding of said plurality of sequence blocks;
[0082] an encoder module 203, configured for inputting said embedded plurality of sequence blocks into an encoder;
[0083] a time series output module 204, configured for outputting a predicted future time series based on said encoder.
[0084] Further, wherein before the channel-wise sequence dividing module 201, comprising:
[0085] an instance level normalization module 205, configured for performing instance level normalization and zero padding on said past time series.
[0086] Further, wherein said encoder module 203, comprises:
[0087] a two-stage attention module 2031, configured for passing said plurality of sequence blocks through the processing of temporal attention and channel attention; wherein said temporal attention and said channel attention have the same weights;
[0088] a multi-layer perception module 2032, configured for passing said plurality of sequence blocks through a multi-layer perception process.
[0089] Further, said time sequence output module 204, comprising.
[0090] an encoder output module 2041, configured for outputting a time sequence according to said encoder;
[0091] a prediction and denormalization module 2042, configured for obtaining said predicted time series by passing said time series through prediction header and the instance level denormalization.
[0092] It should be noted that, the apparatus may include more or fewer modules to implement the described functions. For example, at least one module in FIG. 2 may be further divided into a plurality of different sub-modules, and each sub-module is configured to perform at least a part of operations described herein in combination with corresponding modules. In addition, in some examples, the apparatus 200 may further include additional modules configured to perform other operations that have been described in the specification. In addition, a person skilled in the art may understand that the exemplary apparatus 200 may be implemented in software, hardware, firmware, or any combination thereof.
[0093] FIG. 3 provides a computer device. According to an implementation, a computer device 300 may include a processor 302. The processor 302 executes a computer program stored in a memory 304. The computer program, when executed by the processor, implements the foregoing method.
[0094] A person skilled in the art may understand that, the structure shown in FIG. 3 is only a block diagram of a part of a structure related to a solution of this application and does not limit the computer device to which the solution of this application is applied. Specifically, the computer device may include more or fewer components than those in the drawings, or some components are combined, or a different component deployment is used.
[0095] A person of ordinary skill in the art may understand that all or some of procedures of the method in the foregoing implementations may be implemented by a computer program instructing relevant hardware. The computer program may be stored in a non-volatile computer-readable storage medium. When the computer program is executed, the procedures of the foregoing method implementations may be implemented. Any reference to a memory, a storage, a database, or another medium used in the manner provided in implementations of this application may include at least one of a non-volatile memory and a volatile memory. The non-volatile memory may include a read-only memory (ROM) , a magnetic tape, a floppy disk, a flash memory, an optical memory, and the like. The volatile memory may include a random access memory (RAM) or an external cache. For the purpose of description instead of limitation, the RAM is available in a plurality of forms, such as a static RAM (SRAM) or a dynamic RAM (DRAM) .
[0096] This application further provides a computer-readable storage medium, storing a computer program, the computer program, when executed by a processor, implementing the foregoing steps.
[0097] This application further provides a computer program product. The computer program product is tangibly stored on a computer-readable medium and includes computer-executable instructions, when executed, cause at least one processor to perform the method as described above.
[0098] Further, the computer program may be stored and run in the cloud to perform the method. Further, components of the program may be laid out on a plurality of devices and clouds. For example, corresponding steps can be laid out and run locally or on a local computer, or run on different cloud devices, and signals are transmitted through communication connections, or can be laid out and run locally or on a local computer. This application does not limit the manners or methods described. Corresponding technologies can be flexibly laid out and deployed, and devices and technologies such as cloud, big data, and supercomputing capabilities can be fully utilized to perform and complete the method.
[0099] Some implementations of the present disclosure may include products. The products may include a storage medium for storing logic. Examples of the storage medium may include one or more types of computer-readable storage media capable of storing electronic data, including a volatile memory or a nonvolatile memory, a removable memory or a non-removable memory, an erasable memory or a non-erasable memory, a writable memory or a rewritable memory, and the like. Examples of the logic may include various software units, such as software components, programs, applications, computer programs, application programs, system programs, machine programs, operating system software, middleware, firmware, software modules, routines, subroutines, functions, methods, procedures, software interfaces, application program interfaces (APIs) , instruction sets, computing code, computer code, code segments, computer code segments, words, values, symbols, or any combination thereof. In some implementations, for example, the product may store executable computer program instructions. The instructions, when executed by the processor, cause the processor to perform the methods and / or operations described in the specification. The executable computer program instructions may include any suitable type of code, such as source code, compiled code, interpreted code, executable code, static code, and dynamic code. The executable computer program instructions may be implemented based on a predefined computer language, manner, or syntax for commanding a computer to perform specific functions. The instructions may be implemented by using any suitable high-level, low-level, object-oriented, visual, compiled and / or interpreted programming language.
[0100] What has been described above includes examples of the disclosed architecture. Certainly, it is impossible to describe every conceivable combination of components and / or methods, but a person skilled in the art may understand that many other combinations and arrangements are possible. Therefore, the novel architecture is intended to cover all such alternatives, modifications, and variants falling within the spirit and protection scope of the appended claims.
Claims
1.A method for training a model underlying a future time series forecasting task, comprises:dividing the past time series into a plurality of sequence blocks at channel level and linearly embedding of said plurality of sequence blocks;adding positional embedding to the linear embedding of said plurality of sequence blocks;inputting said embedded plurality of sequence blocks into an encoder;outputting a predicted future time series based on said encoder.2.The method according to claim 1, wherein before dividing the past time series into a plurality of sequence blocks at a channel level, comprises:performing instance level normalization and zero padding on said past time series.3.The method according to claim 1, wherein inputting said embedded plurality of sequence blocks into the encoder, comprises:passing said plurality of sequence blocks through the processing of temporal attention and channel attention; wherein said temporal attention and said channel attention have the same weights.4.The method according to claim 1, outputting a time series for predicting the future, according to said encoder, comprises:outputting a time series according to said encoder;obtaining said predicted time series by passing said time series through prediction header and the instance level denormalization.5.An apparatus (200) for training a model underlying a future time series forecasting task, comprising:a channel-wise sequence dividing module (201) , configured for dividing the past time series into a plurality of sequence blocks at channel level and linearly embedding of said plurality of sequence blocks;a positional embedding module (202) , configured for adding positional embedding to the linear embedding of said plurality of sequence blocks;an encoder module (203) , configured for inputting said embedded plurality of sequence blocks into an encoder;a time series output module (204) , configured for outputting a predicted future time series based on said encoder.6.The apparatus (200) according to claim 5, wherein before the channel-wise sequence dividing module 201, comprises:an instance level normalization module 205 configured for performing instance level normalization and zero padding on said past time series.7.The apparatus (200) according to claim 5, wherein said encoder module (203) , comprises:a two-stage attention module (2031) , configured for passing said plurality of sequence blocks through the processing of temporal attention and channel attention; wherein said temporal attention and said channel attention have the same weights;a multi-layer perception module (2032) , configured for passing said plurality of sequence blocks through a multi-layer perception process.8.The apparatus (200) according to claim 5, said time sequence output module (204) , comprisingan encoder output module (2041) , configured for outputting a time sequence according to said encoder;a prediction and denormalization module (2042) , configured for said time series to go through prediction header and instance level denormalization to get said predicted future time series.9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor, when executing the computer program, implements the steps of the method according to any one of claims 1 to 4.10.A computer-readable storage medium, storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method according to any one of claims 1 to 4.11.A computer program product, tangibly stored on a computer-readable medium and comprising computer-executable instructions, wherein the computer-executable instructions, when executed, cause at least one processor to perform the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Systems and methods for learning and predicting time-series data using inertial auto-encoders
CN109844770A
Multivariate time sequence prediction method and system based on pre-training enhancement
CN115688871A
Wind power prediction method based on non-stationary Transform model
CN117154680A
Skills and tasks demand forecasting
US20220237635A1