Time series analysis model training method, time series analysis method and related device
By fusing historical information and task instructions in a large language model, generating time-frequency fusion features, and using masks and classification modules to handle multi-tasks, the problem of multi-task learning in time series analysis of large models is solved, and the task compatibility and generalization capabilities of the model are improved.
Patent Information
- Application Number
- CN202510433869.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-07-11
AI Technical Summary
Existing large models lack multi-task learning ability in time series analysis, are difficult to efficiently adapt to multiple task requirements, and lack task generalization ability, so they cannot achieve feature sharing and efficient modeling in multi-task scenarios.
By inputting historical time series, task instructions, historical background information and historical statistical information into the feature fusion module of the large language model, time-frequency fusion features are generated, and the mask module and classification module are used to process prediction, interpolation, abnormal detection and classification tasks respectively, and iteratively update model parameters with loss information to realize multi-task understanding and feature sharing.
It improves task compatibility and generalization capabilities of the time series analysis model, reduces computational complexity, and enhances the understanding of prediction, imputation, anomaly detection and classification tasks.
Smart Images

Figure CN120296426A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular, to a method for training a time series analysis model, a time series analysis method, and related devices. Background Art
[0002] When existing large models perform time series analysis, they usually optimize for a single task and lack the ability of multi-task learning. As a result, existing large models are difficult to efficiently adapt to various task requirements in multi-task learning scenarios and significantly lack task generalization ability. Summary of the Invention
[0003] In view of this, the purpose of the present invention is to provide a method for training a time series analysis model, a time series analysis method, and related devices, which can improve the generalization ability of the time series analysis model and the time series analysis ability.
[0004] To achieve the above purpose, the technical solutions adopted in the embodiments of the present invention are as follows:
[0005] In the first aspect, the present invention provides a method for training a time series analysis model, and the method includes:
[0006] Input the historical time series, task instruction, historical background information, and historical statistical information into the feature fusion module of the large language model to obtain the time-frequency fusion feature; the historical background information is the summary information of the historical time series; the historical statistical information is the detailed information of the historical time series;
[0007] If there is at least one of a prediction task, an interpolation task, and an anomaly detection task in the task instruction, input the time-frequency fusion feature into the mask module of the large language model for analysis to obtain a mask result;
[0008] If there is a classification task in the task instruction, input the time-frequency fusion feature into the classification module of the large language model for analysis to obtain a classification result;
[0009] Input the mask result and the classification result into the output module of the large language model to obtain an analysis result;
[0010] Iteratively update the parameters of the large language model based on the loss information of the analysis result and the theoretical result corresponding to the historical time series to obtain a time series analysis model.
[0011] In an alternative embodiment, the feature fusion module includes a time series fusion module, a task fusion module, and a large language network; the step of inputting the historical time series, task instruction, historical background information, and historical statistical information into the feature fusion module of the large language model to obtain the time-frequency fusion feature includes:
[0012] Input the historical time series into the time series fusion module for feature extraction to obtain time domain features and frequency domain features, and fuse the time domain features and the frequency domain features to obtain time-frequency features;
[0013] Input the task instruction, historical background information, and historical statistical information into the task fusion module for feature extraction to obtain task features;
[0014] Fuse the time-frequency features and the task features and then input them into the large language network to obtain the time-frequency fusion features.
[0015] In an alternative embodiment, the step of inputting the historical time series into the time series fusion module for feature extraction to obtain time domain features and frequency domain features, and fusing the time domain features and the frequency domain features to obtain time-frequency features includes:
[0016] Use the time series fusion module to divide the historical time series into multiple short time slices to obtain the time domain features;
[0017] Perform a short-time Fourier transform on the historical time series to obtain a time-frequency matrix;
[0018] Perform a projection transformation based on the time-frequency matrix to obtain the frequency domain features;
[0019] Map the time domain features and the frequency domain features to a joint feature space to obtain the time-frequency features.
[0020] In an alternative embodiment, the step of inputting the task instruction, historical background information, and historical statistical information into the task fusion module for feature extraction to obtain task features includes:
[0021] Use the task fusion module to extract features from the task instruction to obtain instruction features;
[0022] Extract features from the historical background information to obtain background features;
[0023] Extract features from the historical statistical information to obtain statistical features;
[0024] Concatenate the instruction features, the background features, and the statistical features to obtain task features.
[0025] In an alternative embodiment, the step of inputting the time-frequency fusion features into the mask module of the large language model for analysis to obtain a mask result includes:
[0026] Use the mask module to perform an element-wise multiplication of the time-frequency fusion features and a mask matrix to obtain a mask fusion feature;
[0027] Iteratively infer based on the masked fusion feature to obtain a mask result.
[0028] In an optional embodiment, iteratively update the parameters of the large language model based on the loss information corresponding to the analysis result and the theoretical result of the historical time series to obtain a time series analysis model, including:
[0029] Obtain a time domain loss value according to the time domain feature of the analysis result and the time domain feature of the theoretical result;
[0030] Obtain a frequency domain loss value according to the frequency domain feature of the analysis result and the frequency domain feature of the theoretical result;
[0031] Obtain a balance loss value according to the time-frequency matrix of the analysis result and the time-frequency matrix of the theoretical result;
[0032] Obtain the loss information according to the time domain loss value, the frequency domain loss value, and the balance loss value;
[0033] Iteratively update the parameters of the large language model using the loss information to obtain a time series analysis model.
[0034] In a second aspect, the present invention provides a time series analysis method, the method including:
[0035] Receive a time series to be processed and a task to be processed;
[0036] Input the time series to be processed and the task to be processed into a pre-trained time series analysis model to obtain an analysis conclusion corresponding to the time series to be processed; the time series analysis model is trained according to the time series analysis model training method described in any one of the foregoing embodiments.
[0037] In a third aspect, the present invention provides a time series analysis model training device, the device including:
[0038] A processing module, configured to input a historical time series, a task instruction, historical background information, and historical statistical information into a feature fusion module of a large language model to obtain a time-frequency fusion feature; the historical background information is a summary information of the historical time series; the historical statistical information is detailed information of the historical time series;
[0039] An execution module, configured to, if there is at least one of a prediction task, an interpolation task, and an anomaly detection task in the task instruction, input the time-frequency fusion feature into a mask module of the large language model for analysis to obtain a mask result; if there is a classification task in the task instruction, input the time-frequency fusion feature into a classification module of the large language model for analysis to obtain a classification result;
[0040] An update module, configured to input the masked result and the classification result into an output module of the large language model to obtain an analysis result; and iteratively update parameters of the large language model based on loss information of the analysis result and a theoretical result corresponding to the historical time series, to obtain a time series analysis model.
[0041] In a fourth aspect, the present invention provides a time series analysis device, where the device includes:
[0042] A receiving module, configured to receive a time series to be processed and a task to be processed;
[0043] An analysis module, configured to input the time series to be processed and the task to be processed into a pre-trained time series analysis model, to obtain an analysis conclusion corresponding to the time series to be processed; the time series analysis model is trained according to the time series analysis model training method described in any one of the foregoing embodiments.
[0044] In a fifth aspect, the present invention provides an electronic device, including a processor and a memory, where the memory is configured to store a computer program, and the processor is configured to implement the time series analysis model training method described in any one of the foregoing embodiments and / or the time series analysis method described in the foregoing embodiments when executing the computer program.
[0045] The time series analysis model training method, time series analysis method and related device provided by the embodiments of the present invention improve the multi-task understanding ability of the time series analysis model for prediction tasks, imputation tasks, anomaly detection tasks and classification tasks through the fusion of task instructions, historical background information and historical statistical information. The masking module is used to perform fusion reasoning analysis on prediction tasks, imputation tasks and anomaly detection tasks, and the classification module is used to separately perform reasoning analysis on classification tasks, which not only improves the task compatibility of the time series analysis model, but also reduces conflicts between tasks through shared features of multi-task fusion, reduces the computational complexity of the time series analysis model, and thus improves the generalization ability and time series analysis ability of the model.
[0046] To make the above objects, features and advantages of the present invention more obvious and understandable, the following specifically enumerates preferred embodiments and, in conjunction with the accompanying drawings, makes a detailed description as follows. Description of the Drawings
[0047] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following will briefly introduce the drawings required to be used in the embodiments. It should be understood that the following drawings only show some embodiments of the present invention, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.
[0048] Figure 1 Shows a schematic flowchart of a time series analysis model training method provided by an embodiment of the present invention.
[0049] Figure 2 Shows another schematic flowchart of a time series analysis model training method provided by an embodiment of the present invention.
[0050] Figure 3 Shows a schematic diagram of a task instruction provided by an embodiment of the present invention.
[0051] Figure 4 Shows another schematic flowchart of a time series analysis model training method provided by an embodiment of the present invention.
[0052] Figure 5 Shows a schematic diagram of a multi-task framework provided by an embodiment of the present invention.
[0053] Figure 6 Shows a schematic diagram of time-frequency balance provided by an embodiment of the present invention.
[0054] Figure 7 Shows a schematic flowchart of a time series analysis method provided by an embodiment of the present invention.
[0055] Figure 8 Shows another schematic flowchart of a time series analysis method provided by an embodiment of the present invention.
[0056] Figure 9 Shows a schematic flowchart of time series analysis in the prior art.
[0057] Figure 10 Shows a block diagram of a time series analysis model training device provided by an embodiment of the present invention.
[0058] Figure 11 Shows a block diagram of a time series analysis device provided by an embodiment of the present invention.
[0059] Figure 12 Shows a block diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners
[0060] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Usually, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0061] Accordingly, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts fall within the scope of protection of the present invention.
[0062] It should be noted that relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variation thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.
[0063] Time series analysis is an important research area in data science and machine learning, and its application scenarios cover multiple fields such as energy management, traffic prediction, financial analysis, and medical monitoring. In these tasks, time series data usually exhibits complex dynamic change patterns, including periodicity, trendiness, and sudden anomalies. How to accurately capture these patterns and achieve tasks such as prediction, imputation, anomaly detection, and classification is the core challenge in time series analysis.
[0064] Existing time series analysis methods can be divided into traditional methods and deep learning-based methods. Traditional methods such as autoregressive integrated moving average model (ARIMA), exponential smoothing model, etc. mainly rely on the linear characteristics of time series and model by manually extracting features. However, these methods often show limited modeling capabilities when facing non-linear, multi-variable, and high-noise time series.
[0065] Deep learning-based models have made significant progress in recent years, such as recurrent neural network (RNN), long short-term memory network (LSTM), and Transformer model based on self-attention mechanism. These methods can capture the non-linear features of time series data and show strong capabilities in long sequence modeling.
[0066] The inventors have found through research that the above time series analysis methods still have the following limitations:
[0067] (1) Single-task optimization problem: Most existing models are optimized only for a single task (such as prediction, imputation), and cannot achieve feature sharing and efficient modeling in multi-task scenarios. This task isolation results in the lack of multi-task learning ability of the model, and the inability to share information between tasks, which leads to insufficient resource utilization, difficulty in efficiently processing multiple tasks under a unified framework, and increases the complexity and computational overhead of model deployment.
[0068] (2) Lack of joint modeling in the time domain and frequency domain: Existing models usually operate only in the time domain, ignoring the frequency characteristics of time series. Frequency domain analysis (such as Fourier transform) plays an important role in capturing periodicity and trends. The disconnection between time domain and frequency domain information limits the expressive power of the model, resulting in difficulty in fully capturing diverse dynamic change patterns in the data through single-domain feature modeling.
[0069] (3) Lack of unified task representation form: Traditional deep learning models cannot flexibly integrate prior knowledge, such as task descriptions or context information, making the model's performance less than ideal when adapting to multi-task scenarios.
[0070] (4) Lack of task generalization ability: Existing models are difficult to efficiently adapt to various task requirements in multi-task learning scenarios. Especially when facing cross-domain, multi-variable time series data, the model's transfer ability between tasks such as prediction, imputation, anomaly detection, and classification is insufficient.
[0071] With the breakthrough progress of large language models (LLMs) in the field of natural language processing, their powerful general capabilities and the ability to understand context information provide new solutions for time series analysis tasks. However, due to the large modal differences between time series data and natural language data, directly applying large language models to time series analysis will lead to a decline in the ability of large language models to capture time series patterns. In addition, existing large language models lack sufficient utilization of context information and are difficult to achieve accurate understanding of complex task instructions and data characteristics.
[0072] Based on this, the time series analysis model training method, time series analysis method, and related devices provided in the embodiments of the present invention improve the multi-task understanding ability of the time series analysis model for prediction tasks, imputation tasks, anomaly detection tasks, and classification tasks through the fusion of task instructions, historical background information, and historical statistical information. The mask module is used to perform fusion reasoning analysis on prediction tasks, imputation tasks, and anomaly detection tasks, and the classification module is used to perform separate reasoning analysis on classification tasks, which not only improves the task compatibility of the time series analysis model, but also reduces the conflicts between tasks through the shared features of multi-task fusion, reduces the computational complexity of the time series analysis model, and thus improves the model's strong generalization ability and time series analysis ability.
[0073] The following will describe each embodiment of the present invention in detail with reference to the accompanying drawings.
[0074] Please refer to Figure 1 , Figure 1 which shows a schematic flow diagram of a method for training a time series analysis model provided by an embodiment of the present invention. The method includes the following steps:
[0075] Step S100, input the historical time series, task instruction, historical background information, and historical statistical information into the feature fusion module of the large language model to obtain the time-frequency fusion feature; the historical background information is the summary information of the historical time series; the historical statistical information is the detailed information of the historical time series.
[0076] In the embodiment of the present invention, taking Figure 2 as an example to introduce the training process of the time series analysis model. When training the large language model, in addition to inputting the historical time series and task instruction, it is also necessary to input the historical background information and historical statistical information. The feature fusion module is used to perform feature fusion processing on the historical time series, task instruction, historical background information, and historical statistical information to obtain the time-frequency fusion feature.
[0077] Among them, the task instruction is also called a prompt word. Taking Figure 3 as an example for illustration, Figure 3 shows four prompt words for predicting the oil temperature of the transformer. The time-frequency fusion feature includes the time domain feature and frequency domain feature of the historical time series, as well as the time domain features of the task instruction, historical background information, and historical statistical information. The historical background information is the summary information of the historical time series, that is, the reason for the generation of the historical time series can be understood through the historical background information. Taking the weather as an example, the historical background information may include that due to the cold snap, the temperature dropped suddenly from the 1st to the 7th, and the highest temperature was not higher than 10 degrees.
[0078] The historical statistical information is the detailed information of the historical time series, that is, the statistical information of the historical time series at a finer granularity can be understood through the historical statistical information. Continuing with the weather example, assuming the historical time series includes 30 weather data, each weather data corresponding to the weather condition of one day, which may include multi-dimensional data (i.e., multi-variables) such as the average temperature, highest temperature, lowest temperature, air pressure, measurement height, geographical location, etc. of the day. In order to analyze the historical time series more accurately, the weather data of three time periods in a day, namely morning, noon, and afternoon, can be used as the historical statistical information of the historical time series. The historical background information and historical statistical information can be set according to the actual application scenario, and the present invention does not limit this.
[0079] Step S110, if there is at least one of the prediction task, imputation task, and anomaly detection task in the task instruction, input the time-frequency fusion feature into the mask module of the large language model for analysis to obtain the mask result.
[0080] In an embodiment of the present invention, Figure 2 The large language model includes a multi-task module, and the multi-task module includes a masking module and a classification module. The task instruction is the prompt word input to the large language model, that is, it instructs the large language model to analyze the historical time series according to the task instruction. The task types include prediction tasks, imputation tasks, anomaly detection tasks, and classification tasks, and the task instruction may include at least one of prediction tasks, imputation tasks, anomaly detection tasks, and classification tasks.
[0081] When the task instruction includes one or more of prediction tasks, imputation tasks, and anomaly detection tasks, the masking module is used to analyze the time-frequency fusion features to obtain a masking result. The masking result is used to represent the output features for predicting, imputing, and / or detecting anomalies in the time-frequency fusion features.
[0082] Step S120, if there is a classification task in the task instruction, input the time-frequency fusion features into the classification module of the large language model for analysis to obtain a classification result.
[0083] In an embodiment of the present invention, when the task instruction includes a classification task, the time-frequency fusion features are input into the classification module so that the classification module can obtain a category sequence, and the cross-attention mechanism is used to extract category features from the time-frequency fusion features based on the category sequence to obtain a classification result. The classification result is used to represent the output features for classifying the time-frequency fusion features, and the generation method of the classification result is shown as follows:
[0084] y cls = CrossAttention(E output , token)
[0085] where y cls is the classification result; E output is the time-frequency fusion feature; token is the category sequence; CrossAttention(·) is the cross-attention mechanism function.
[0086] Step S130, input the masking result and the classification result into the output module of the large language model to obtain an analysis result.
[0087] In an embodiment of the present invention, taking Figure 2 as an example, the output module to be trained includes a linear projection layer and a fully connected layer. Input the masking result and the classification result into the output module, use the fully connected layer to convert the classification result into the category scores corresponding to each category, and input the category scores into the Softmax function to obtain the prediction probability of each category.
[0088] The masked result is mapped to the data space of the historical time series using a linear projection layer, and reversible normalization is performed to obtain the mapped data to ensure that the numerical range is consistent with the real data. If there is a prediction task in the task instruction, the mapped data is used as the predicted data for future time points. If there is an interpolation task in the task instruction, the missing data in the historical time series is replaced with the mapped data to obtain the replacement data. If there is an anomaly detection task in the task instruction, the deviation between the mapped data and the historical time series is calculated, and the time points with deviations exceeding the preset threshold are marked as anomalies to obtain the anomaly data.
[0089] It should be noted that the analysis result includes at least one of the classification data (category and prediction probability) of the classification task, the predicted data of the prediction task, the replacement data of the interpolation task, and the anomaly data of the anomaly detection task. That is to say, if there is a prediction task in the task instruction, the analysis result includes the classification result, and the task instruction corresponds to the analysis result one by one.
[0090] Step S140, based on the loss information of the analysis result and the theoretical result corresponding to the historical time series, iteratively update the parameters of the large language model to obtain the time series analysis model.
[0091] In the embodiment of the present invention, by comparing the analysis result and the theoretical result of the historical time series, the loss information is obtained, and the parameters of the large language model are iteratively updated using the loss information until the acceptance conditions are met (for example, the number of tests reaches the preset number, and the loss information below the threshold reaches the preset quantity) to obtain the time series analysis model.
[0092] In summary, the time series analysis model training method provided by the embodiment of the present invention improves the multi-task understanding ability of the time series analysis model for prediction tasks, interpolation tasks, anomaly detection tasks, and classification tasks through the integration of task instructions, historical background information, and historical statistical information. The mask module is used to perform fusion reasoning analysis on prediction tasks, interpolation tasks, and anomaly detection tasks, and the classification module is used to perform separate reasoning analysis on classification tasks, which not only improves the task compatibility of the time series analysis model, but also reduces the conflict between tasks through the shared features of multi-task fusion, reduces the computational complexity of the time series analysis model, and thus improves the generalization ability and time series analysis ability of the model.
[0093] Optionally, the feature fusion module includes a time series fusion module, a task fusion module, and a large language network. For how to generate time-frequency fusion features, a possible implementation is provided below. Please refer to Figure 4 , Figure 1 The sub-steps of step S100 in can include:
[0094] Step S101: Input the historical time series into the time series fusion module for feature extraction to obtain time domain features and frequency domain features, and fuse the time domain features and frequency domain features to obtain time-frequency features.
[0095] In the embodiment of the present invention, continuing with Figure 2 as an example, use the time series fusion module to perform time domain encoding, reversible normalization, and feature embedding processing on the historical time series in the time domain to extract features and obtain time domain features, perform frequency domain encoding, reversible normalization, and feature embedding processing on the historical time series in the frequency domain to extract features and obtain frequency domain features, and then perform feature fusion based on the time domain features and frequency domain features to achieve time-frequency balance and obtain time-frequency features. Among them, the time-frequency features represent the feature vectors carrying the historical time series in the time domain and frequency domain.
[0096] Step S102: Input the task instruction, historical background information, and historical statistical information into the task fusion module for feature extraction to obtain task features.
[0097] Step S103: Input the fused time-frequency features and task features into the large language network to obtain time-frequency fusion features.
[0098] In the embodiment of the present invention, use the task fusion module to perform tokenization and feature embedding operations on the task instruction, historical background information, and historical statistical information to extract features and generate task features. Among them, the task features include the features of the task instruction, the features of the historical background information, and the features of the historical statistical information.
[0099] Use the multi-head attention mechanism to fuse the time-frequency features and task features to obtain the initial fusion features to achieve context modeling. The generation formula of the initial fusion features is as follows:
[0100] E input = MultiHeadArrention(P, E, E)
[0101] where E input is the initial fusion feature; P is the task feature; E is the time-frequency feature; MultiHeadArrention(·) is the multi-head attention mechanism function.
[0102] Input the initial fusion features into the large language network for feature encoding to enhance the context awareness ability and obtain time-frequency fusion features. Among them, the large language network includes a multi-head self-attention mechanism and a feed-forward network. The generation method of the time-frequency fusion features is expressed as follows:
[0103] E output = LLM(E input )
[0104] where E outputThe time-frequency fusion feature; LLM(·) is the large language network function.
[0105] As a possible implementation, taking Figure 5 as an example, the initial fusion feature is input into the large language network, and after being processed by the multi-head attention mechanism, residual and normalization processing are performed on the initial fusion feature, and then feed-forward processing is performed by the feed-forward network followed by residual and normalization processing to obtain the time-frequency fusion feature.
[0106] Optionally, for how to generate the time-frequency feature, a possible implementation is provided below. Figure 4 The sub-steps of step S101 in
[0107] The historical time series is divided into multiple short time slices by using the time series fusion module to obtain the time domain feature; the historical time series is subjected to short-time Fourier transform to obtain the time-frequency matrix; projection transformation is performed according to the time-frequency matrix to obtain the frequency domain feature; the time domain feature and the frequency domain feature are mapped to the joint feature space to obtain the time-frequency feature.
[0108] In the embodiments of the present invention, the historical time series is a multi-dimensional time series signal, which can be represented as a matrix of T×d, where T is the time step and d is the feature dimension. The essence of the time series is a discrete signal that changes over time, so it can be regarded as a set of data points observed at different time steps. These data points are stored on the time axis according to the sampling rate, so standard time series modeling methods can be used to process them.
[0109] In time domain analysis, we are mainly concerned with the local patterns and overall trends of time series data. To obtain the time domain feature, we first perform data standardization to eliminate the influence of different dimensional data scales. The historical time series is standardized by using the time series fusion module to obtain the standard time series. The calculation formula of the standard time series is:
[0110]
[0111] where, X ′ is the standard time series; X is the original time series; μ is the mean of the original time series; σ is the standard deviation of the original time series.
[0112] It should be noted that the standardized time series is more easily used for the training of the large language model, which can improve the convergence speed and generalization ability of the model. To extract the time domain feature, window segmentation is used to divide the standard time series into multiple short time slices to obtain the time domain feature. Among them, the length of each short time slice is N, which can be represented as a matrix of N×d, the number of windows is K, and the number of short time slices is K. The time domain feature can be expressed as:
[0113] XT = {A1, A2, …, A K ,}
[0114] where X T is a time-domain feature; A i is the i-th short time slice, which can be represented as an N×d matrix; N is the length of the short time slice; K is the number of windows, i.e., the number of short time slices.
[0115] The purpose of generating time-domain features by window segmentation is to enable large language models to learn local patterns and long-term dependencies in historical time series, such as short-term trends and periodic changes. However, although the representation in the time domain is intuitive, it may ignore the variations of signals at different frequencies. Therefore, the present invention transforms the historical time series into the frequency domain to obtain more frequency domain information.
[0116] To better analyze non-stationary time series, the present invention uses the short-time Fourier transform to extract the features of historical time series in the frequency domain. The short-time Fourier transform slides a window on the time axis and performs a Fourier transform within each window to obtain the frequency components of different time periods. The formula of the short-time Fourier transform is as follows:
[0117]
[0118] where A F (t, f) is the time-frequency matrix; X(n) is the data of the historical time series falling within the n-th window; w(n - t) is the window function for extracting local spectral information; N is the window length; f is the frequency index; t is the frame index.
[0119] To reduce the statistical distribution differences of different time slices, the time-frequency matrix obtained by the short-time Fourier transform is normalized. The normalization formula of the time-frequency matrix is as follows:
[0120]
[0121] where A F ∑ is the standard time-frequency matrix; A F is the time-frequency matrix; μ F is the mean of the time-frequency matrix; σ F is the standard deviation of the time-frequency matrix.
[0122] The frequency domain projector is used to extract features from the time-frequency matrix to obtain the frequency domain features. The generation formula of the frequency domain features is as follows:
[0123] X F = P F (A F ′ )
[0124] Among them, X F is the frequency-domain feature; P F is the frequency-domain projector.
[0125] Using linear projection to map time-domain features and frequency-domain features to the joint feature space to obtain time-frequency features, so as to achieve the fusion of time-domain features and frequency-domain features, thereby enhancing the overall modeling ability of time series tasks. The generation formula of time-frequency features is as follows:
[0126] E = α·W T X T + β·W F X F
[0127] Among them, E is the time-frequency feature; α is the time-domain feature weight; β is the frequency-domain feature weight; W T is the time-domain linear projection matrix; W F is the frequency-domain linear projection matrix.
[0128] It should be noted that the time-domain feature weight and the frequency-domain feature weight are dynamically learned and updated through the training of the large language model.
[0129] Optionally, for how to generate task features, a possible implementation method is provided below. Figure 4 The sub-steps of step S102 in
[0130] may include:
[0131] Using the task fusion module to extract features from the task instruction to obtain instruction features; extracting features from the historical background information to obtain background features; extracting features from the historical statistical information to obtain statistical features; concatenating the instruction features, background features and statistical features to obtain task features.
[0132] In the embodiments of the present invention, the task fusion module generates task-specific prompts for different tasks by combining task instructions, historical background information and historical statistical information. First, extract the features of the historical statistical information to obtain background features; extract the features of the task instruction to obtain instruction features; extract the features of the historical statistical information to obtain statistical features. Then, perform feature concatenation or feature fusion on the background features, instruction features and statistical features to obtain task features.
[0133] Optionally, a possible implementation of how to generate the masked result is provided below. Figure 1 The sub-steps of step S110 may include:
[0134] If there is at least one of a prediction task, an imputation task, and an anomaly detection task in the task instruction, use a masking module to perform an element-wise multiplication on the time-frequency fusion feature and the masking matrix to obtain a masked fusion feature; perform iterative inference based on the masked fusion feature to obtain the masked result.
[0135] In the embodiment of the present invention, after inputting the time-frequency fusion feature into the masking module, a masking matrix is obtained, and an element-wise multiplication operation is performed on the time-frequency fusion feature and the masking matrix to obtain a masked fusion feature. Then, iterative inference is performed based on the statistical law of the masked fusion feature to obtain the masked result. The generation formula of the masked fusion feature is as follows:
[0136] E masked = E output ⊙ M
[0137] where E masked is the masked fusion feature; M is a binary masking matrix representing the part that needs to be reconstructed; ⊙ is the element-wise multiplication operation of the matrix.
[0138] As a possible implementation, taking Figure 5 as an example, the time-frequency fusion feature output by the large language network is transmitted to the multi-task module, and the multi-head attention mechanism and the multi-layer perceptron are used to determine whether there are a prediction task, an imputation task, and an anomaly detection task. If so, the time-frequency fusion feature is passed to the masking module, a masked fusion feature is obtained based on the masking matrix and the time-frequency fusion feature, and then iterative inference of the statistical law of the masked fusion feature is performed using the multi-layer perceptron, linear, and fold to obtain the masked result.
[0139] Use the multi-head attention mechanism and the multi-layer perceptron to determine whether there is a classification task. If there is a classification task, pass the time-frequency fusion feature to the classification module, and use cross-attention and the multi-layer perceptron to perform inference based on the time-frequency fusion feature and the type sequence to obtain the classification result.
[0140] It can be seen that the embodiment of the present invention unifies the prediction task, the imputation task, and the anomaly detection task into the masking module for fusion processing, and at the same time separately processes the classification task through the classification module. This design not only improves the task compatibility of the trained time series analysis model, but also reduces the conflict between tasks by sharing features when processing the prediction task, the imputation task, and the anomaly detection task, and reduces the computational complexity of the model.
[0141] Optionally, a possible implementation of how to iteratively train the large language model using loss information is provided below. Figure 1The sub - steps of step S140 may include:
[0142] Obtain the time - domain loss value according to the time - domain characteristics of the analysis result and the time - domain characteristics of the theoretical result; obtain the frequency - domain loss value according to the frequency - domain characteristics of the analysis result and the frequency - domain characteristics of the theoretical result; obtain the balance loss value according to the time - frequency matrix of the analysis result and the time - frequency matrix of the theoretical result; obtain the loss information according to the time - domain loss value, the frequency - domain loss value and the balance loss value; use the loss information to iteratively update the parameters of the large - language model to obtain the time - series analysis model.
[0143] As a possible implementation, generate the time - domain characteristics, frequency - domain characteristics and time - frequency matrix corresponding to the analysis result according to the analysis result, and generate the time - domain characteristics, frequency - domain characteristics and time - frequency matrix corresponding to the theoretical result according to the theoretical result. Among them, the time - domain characteristics of the analysis result and the time - domain characteristics of the theoretical result have the same dimension, the frequency - domain characteristics of the analysis result and the frequency - domain characteristics of the theoretical result have the same dimension, and the time - frequency matrix of the analysis result and the time - frequency matrix of the theoretical result have the same dimension.
[0144] Calculate the mean - square error between the time - domain characteristics of the analysis result and the time - domain characteristics of the theoretical result to obtain the time - domain loss value. Calculate the mean - square error between the frequency - domain characteristics of the analysis result and the frequency - domain characteristics of the theoretical result to obtain the frequency - domain loss value. Calculate the mean - square error between the time - frequency matrix of the analysis result and the time - frequency matrix of the theoretical result to obtain the balance loss value.
[0145] Sum the product of the time - domain loss weight and the time - domain loss value, the product of the frequency - domain loss weight and the frequency - domain loss value, and the product of the balance loss weight and the balance loss value to obtain the loss information. The calculation formula is as follows:
[0146] L = λ T L T + λ F L F + λ B L B
[0147] Where L is the loss information; λ T is the time - domain loss weight; L T is the time - domain loss value; λ F is the frequency - domain loss weight; L F is the frequency - domain loss value; λ B is the balance loss weight; L B is the balance loss value.
[0148] As another possible implementation, loss information is determined based on prediction tasks, imputation tasks, anomaly detection tasks, and classification tasks. The analysis results include prediction data, replacement data, anomaly data, and classification data. For prediction tasks, imputation tasks, and anomaly detection tasks, the error value of the prediction task is calculated according to the prediction data in the analysis results and the prediction data in the theoretical results. The error value of the imputation task is calculated according to the replacement data in the analysis results and the replacement data in the theoretical results. The error value of the anomaly detection task is calculated according to the anomaly data in the analysis results and the anomaly data in the theoretical results. Then, the error loss is obtained based on the three error values. For example, the mean of the three error values is determined as the error loss value. The error value calculation formula is as follows:
[0149]
[0150] Where, L MSE is the error value; M is the number of values in the sequence; is the analysis value output by the large language model; x i is the corresponding theoretical value.
[0151] For the classification task, the cross-entropy loss value of the classification task is determined according to each category in the classification data and the predicted probability corresponding to the category. The cross-entropy loss value calculation formula is as follows:
[0152]
[0153] Where, L CE is the cross-entropy loss value; S is the number of categories; y i is the category value, p i is the predicted probability of y i .
[0154] The error loss value, the cross-entropy loss value, and the product of the balance loss weight and the balance loss value are summed to obtain the loss information.
[0155] L = L ERR + L CE + λ B L B
[0156] Where, L ERR is the error loss value.
[0157] As another possible implementation, taking Figure 6 as an example, the feature fusion module includes a time domain module and a frequency domain module. After the historical time series is input into the time domain module, first, the historical time series X is divided into multiple short time slices, and each short time slice is embedded into a contrast encoder E in the time domain TAmong them, after being processed by multi-head attention, residual & normalization, feed-forward network, and residual & normalization, the time-series focused data after processing is linearly projected to generate the embedding (i.e., feature) corresponding to each short time slice. This represents the embedding and representation of the short time slice in the time domain.
[0158] To enhance the representation ability of time-domain features, the time-domain module introduces a time-based enhancement mechanism library for generating an enhanced set of historical time series, that is, for each multivariate sample in the historical time series corresponds to a randomly generated enhanced sample Input each enhanced sample into the contrast encoder E in the time domain T Among them, obtain each corresponding Among them, and Since is generated by After being processed by E T After processing, the embedding of is close to the embedding of, but far from the embedding of another sample derived and The embeddings of have large differences from the embeddings of other different samples.
[0159] Specifically, we select the positive pair as The negative pair is and To maximize the similarity within the positive pair and minimize the similarity within the negative pair, for this purpose, the time-domain module adopts the normalized temperature-scaled cross-entropy loss (NT-Xent Loss) in contrastive learning. This loss function is widely used to measure the similarity between samples. Specifically, we define the loss function of the time-based contrast encoder with the sample as the unit as:
[0160]
[0161] Among them, L T1 is the contrastive loss in the time domain, sim(u,v) = u T v / ||u||||v|| represents the cosine similarity, is an indicator function that equals 0 when n = k and 1 otherwise, and τ is a time parameter that adjusts the scale. x k ∈D s represents different time series samples or their augmented samples.
[0162] Through this loss function, the contrast encoder E in the time domain TIt can generate more compact time-based embeddings for positive pairs while separating the embeddings of negative pairs from each other, thereby enhancing the model's representation ability in the time domain. This time-domain enhancement and encoding mechanism provides the model with a richer representation of time features, enabling it to better capture local dependencies in time series.
[0163] In the frequency-domain module, the spectrum is generated from by means of the Fast Fourier Transform (FFT). Subsequently, a frequency-domain enhancement library is applied to generate an enhanced set of spectrum samples. These enhancement methods include phase perturbation of the spectrum and addition or removal of frequency components. The main purpose is to introduce variations through random perturbations and further expand the diversity of training data. The key to the perturbation method is to ensure that the enhanced spectrum still retains the main frequency features of the original samples without completely disrupting the overall pattern of the time series.
[0164] Specifically, when removing frequency components, E frequency components are randomly selected and their amplitudes are set to 0; while when adding frequency components, E frequency components are selected from the frequency components with smaller amplitudes and their amplitudes are increased to a predefined coefficient a multiplied by the maximum amplitude of the spectrum. After processing the enhanced spectrum, the spectrum and the corresponding enhanced spectrum are respectively embedded into the frequency-domain encoder E F and, through processes such as linear, dot-product attention, concatenation, linear, residual & normalization, feed-forward, and residual & normalization, are mapped to the embedded representations in the frequency domain and Among them, and Similar to the time-domain processing, the frequency-domain module also adopts a contrastive learning method, taking the original spectrum and its perturbed version as positive sample pairs, and the spectra of other samples as negative sample pairs, aiming to maximize the similarity within positive pairs and minimize the similarity within negative pairs. The loss function of the frequency-domain module is defined as:
[0165]
[0166] where L F1 is the contrastive loss in the frequency domain.
[0167] Time-frequency balance aims to ensure the consistency of the embeddings learned from the time domain and the frequency domain in the joint time-frequency space through the consistency loss term L B1 For each input sample, we generate four embeddings: the time-based embedding as well as the frequency-based embeddings and To ensure the consistency of these embeddings in the joint time-frequency space, complement the information in the time domain and frequency domain in the joint space, and achieve effective feature fusion, its role is mainly reflected in enhancing information integrity and model adaptability: the time domain mainly captures local short-term changes and sudden anomalies, while the frequency domain focuses on global long-term trends and periodic patterns. The combination of the two avoids the bias of the model towards a single representation, thereby enhancing the overall feature expression. At the same time, time-frequency balance enables the model to better adapt to non-stationary multi-scale dependence structures and perform more stably in tasks such as prediction and anomaly detection. Through the balanced design in the joint time-frequency space, the model optimizes the interaction of the two types of information, reduces redundancy, and fully utilizes short-term and long-term features, making it have higher accuracy and robustness in multi-task time series analysis and showing significant advantages. We project respectively and map the time and frequency embeddings to the same time-frequency space.
[0168] The core idea of the consistency loss L B1 is to ensure that the distance between the time-based embedding and the frequency-based embedding in the joint time-frequency space is as small as possible. We use the distance metric to represent and the distance between. To further enhance this consistency, the model also ensures that the distance between time and frequency is smaller than that of negative samples by comparing the embedding distances between different augmented samples, such as and We design it as the consistency loss L term, where ε is a given constant, used to keep the distance between negative samples large enough. The time-frequency based contrast loss is: B1 where L
[0169]
[0170] is the consistency loss, that is, the balance loss value; N is the total number of samples; ε is a positive offset term, used to improve numerical stability, prevent the gradient from being too small or zero, and at the same time prevent the optimization from falling into saddle points or invalid regions. It also plays a certain role in "pulling the distance closer", making the model more inclined to reduce the distance between embeddings; B1 is the non-augmented embedding (i.e., feature) of the nth sample in the time-frequency domain; is the embedding after frequency domain augmentation of ; is the embedding after time domain augmentation of ; is the embedding after time domain and frequency domain augmentation of ; |·| is the distance metric; is the comparison representation related to the nth sample, and the values include
[0171] The loss information includes the time-domain contrast loss L T1 , the contrast loss L F1 in the frequency domain, and the consistency loss L B1 . The time-domain contrast loss prompts the model to learn embeddings that are robust to temporal augmentations. The frequency-domain contrast loss ensures that the embeddings are invariant to spectral augmentations, while the consistency loss guarantees the consistency between the temporal and frequency embeddings. Through time-frequency balance, meaningful features can be captured in both the time and frequency domains, while maintaining the embedding balance between the two domains, thereby improving the accuracy and robustness of time series analysis. The loss information L TFB has the following expression:
[0172] L TFB = λ(L T1 + L F1 ) + (1 - λ)L B1
[0173] where λ is a hyperparameter representing the relative weight of each loss, controlling the weight balance between the time and frequency losses and the balance loss, and is updated iteratively with the training of the large language model.
[0174] It should be noted that the calculation method of the loss information can be specified according to the actual application scenario, and the present invention does not limit this.
[0175] It can be seen that the embodiments of the present invention utilize the dual features of the time domain and the frequency domain to fully explore the time correlation and frequency characteristics in the time series, and achieve the balance between the time domain and the frequency domain through dynamic weight adjustment. Through the constraint of the balance loss value, the alignment of the time domain and frequency domain features in the joint space is ensured, significantly reducing information redundancy and improving the integrity of feature expression.
[0176] Next, the embodiments of time series analysis based on a pre-trained time series analysis model will be described. Please refer to Figure 7 , Figure 7 which shows a schematic flowchart of a time series analysis method provided by an embodiment of the present invention. The method includes the following steps:
[0177] Step S200, receiving the time series to be processed and the task to be processed.
[0178] Step S210, inputting the time series to be processed and the task to be processed into the pre-trained time series analysis model to obtain the analysis conclusion corresponding to the time series to be processed.
[0179] In an embodiment of the present invention, a time series to be processed and a task to be processed input by a user are received, and the time series to be processed and the task to be processed are input into a pre-trained time series analysis model, so that the time series analysis model uses the task to be processed as a constraint condition and performs inference analysis based on the time series to be processed to obtain an analysis conclusion corresponding to the time series to be processed.
[0180] In summary, for the time series analysis method provided by the embodiment of the present invention, since the time series analysis model improves the multi-task understanding ability of the model for prediction tasks, imputation tasks, anomaly detection tasks, and classification tasks through the fusion of task instructions, historical background information, and historical statistical information during training. By performing fusion inference analysis for prediction tasks, imputation tasks, and anomaly detection tasks, and performing separate inference analysis for classification tasks, the task compatibility of the model is gradually improved, and the computational complexity of the large language model can also be reduced. Therefore, performing time series analysis based on the pre-trained time series analysis model can obtain more accurate analysis conclusions.
[0181] To more clearly illustrate the time series analysis method provided by the embodiments of the present application, an exemplary illustration is made in combination with a comparison with the prior art.
[0182] As a possible implementation, taking Figure 8 as an example, a multi-variable time series is input into a pre-trained time series analysis model, time domain features are obtained through time domain encoding (i.e., feature extraction), frequency domain features are obtained through frequency domain encoding, and the time domain features and frequency domain features are fused based on time-frequency balance to obtain time-frequency features. The task features corresponding to the task instructions (i.e., prompt words) and the time-frequency features are fused and then input into a large language network to obtain time-frequency fusion features. Based on the time-frequency fusion features, at least one of the prediction task, imputation task, and anomaly detection task is analyzed, and the classification task is analyzed based on the time-frequency fusion features to complete the time series analysis.
[0183] However, when performing time series analysis, the large language model in the prior art can only perform time series encoding for a single variable in the time series, process the prompt words through text embedding, and perform one of the prediction task, imputation task, anomaly detection task, and classification task through the time series features and the prompt word features to obtain the time series analysis result, as Figure 9 shown.
[0184] It can be seen that, compared with the prior art which can only perform single-task time series analysis on a single variable in a time series, the time series analysis model provided by the embodiments of the present invention can use dual feature representations in the time domain and frequency domain for multivariate time series, fully exploit the time correlation and frequency characteristics in the time series, and improve the integrity of feature expression. By uniformly processing prediction tasks, imputation tasks, and anomaly detection tasks, and simultaneously realizing the separate processing of classification tasks, the task compatibility of the model is improved.
[0185] Based on the same inventive concept, the embodiments of the present invention also provide a time series analysis model training device and a time series analysis device. The basic principle and the technical effects produced are the same as those of the above embodiments. For the sake of brief description, for the parts not mentioned in this embodiment, reference may be made to the corresponding content in the above embodiments.
[0186] Please refer to Figure 10 , Figure 10 which shows a block diagram of a time series analysis model training device 300 provided by an embodiment of the present invention. The time series analysis model training device 300 includes a processing module 301, an execution module 302, and an update module 303.
[0187] The processing module 301 is configured to input historical time series, task instructions, historical background information, and historical statistical information into the feature fusion module of the large language model to obtain time-frequency fusion features; the historical background information is the summary information of the historical time series; the historical statistical information is the detailed information of the historical time series.
[0188] The execution module 302 is configured to, if there is at least one of a prediction task, an imputation task, and an anomaly detection task in the task instructions, input the time-frequency fusion features into the mask module of the large language model for analysis to obtain a mask result; if there is a classification task in the task instructions, input the time-frequency fusion features into the classification module of the large language model for analysis to obtain a classification result.
[0189] The update module 303 is configured to input the mask result and the classification result into the output module of the large language model to obtain an analysis result; based on the loss information between the analysis result and the theoretical result corresponding to the historical time series, iteratively update the parameters of the large language model to obtain a time series analysis model.
[0190] In summary, the time series analysis model training device provided by the embodiments of the present invention improves the multi-task understanding ability of the time series analysis model for prediction tasks, imputation tasks, anomaly detection tasks, and classification tasks through the integration of task instructions, historical background information, and historical statistical information. By using the mask module to perform fusion reasoning and analysis on prediction tasks, imputation tasks, and anomaly detection tasks, and using the classification module to separately reason and analyze classification tasks, it not only improves the task compatibility of the time series analysis model, but also reduces the conflicts between tasks through the shared features of multi-task fusion, reduces the computational complexity of the time series analysis model, and thus improves the generalization ability and time series analysis ability of the model.
[0191] Optionally, the feature fusion module includes a time series fusion module, a task fusion module, and a large language network; the processing module 301 is specifically configured to input the historical time series into the time series fusion module for feature extraction to obtain time domain features and frequency domain features, and fuse the time domain features and frequency domain features to obtain time-frequency features; input the task instructions, historical background information, and historical statistical information into the task fusion module for feature extraction to obtain task features; fuse the time-frequency features and task features and input them into the large language network to obtain time-frequency fusion features.
[0192] Optionally, the processing module 301 is specifically configured to use the time series fusion module to divide the historical time series into multiple short time slices to obtain time domain features; perform short-time Fourier transform on the historical time series to obtain a time-frequency matrix; perform projection transformation according to the time-frequency matrix to obtain frequency domain features; map the time domain features and frequency domain features to a joint feature space to obtain time-frequency features.
[0193] Optionally, the processing module 301 is specifically configured to use the task fusion module to extract features from the task instructions to obtain instruction features; extract features from the historical background information to obtain background features; extract features from the historical statistical information to obtain statistical features; splice the instruction features, background features, and statistical features to obtain task features.
[0194] Optionally, the execution module 302 is specifically configured to perform element-wise multiplication on the time-frequency fusion features and the mask matrix using the mask module to obtain mask fusion features; perform iterative reasoning according to the mask fusion features to obtain a mask result.
[0195] Optionally, the update module 303 is specifically configured to obtain a time domain loss value according to the time domain features of the analysis result and the time domain features of the theoretical result; obtain a frequency domain loss value according to the frequency domain features of the analysis result and the frequency domain features of the theoretical result; obtain a balance loss value according to the time-frequency matrix of the analysis result and the time-frequency matrix of the theoretical result; obtain loss information according to the time domain loss value, the frequency domain loss value, and the balance loss value; use the loss information to iteratively update the parameters of the large language model to obtain a time series analysis model.
[0196] Please refer to Figure 11 , Figure 11 which shows a block diagram of the time series analysis device 400 provided by an embodiment of the present invention. The time series analysis device 400 includes a receiving module 401 and an analysis module 402.
[0197] The receiving module 401 is configured to receive the time series to be processed and the task to be processed;
[0198] The analysis module 402 is configured to input the time series to be processed and the task to be processed into a pre-trained time series analysis model to obtain an analysis conclusion corresponding to the time series to be processed.
[0199] In summary, for the time series analysis device provided by the embodiment of the present invention, since the time series analysis model improves the multi-task understanding ability of the model for prediction tasks, interpolation tasks, anomaly detection tasks, and classification tasks through the fusion of task instructions, historical background information, and historical statistical information during training. By performing fusion reasoning analysis for prediction tasks, interpolation tasks, and anomaly detection tasks, and performing separate reasoning analysis for classification tasks, the task compatibility of the model is gradually improved, and the computational complexity of the large language model can also be reduced. Therefore, based on the pre-trained time series analysis model for time series analysis, more accurate analysis conclusions can be obtained.
[0200] Please refer to Figure 12 , Figure 12 which is a block diagram of an electronic device 500 provided by an embodiment of the present invention. The electronic device 500 includes a memory 510, a processor 520, and a communication module 530. Each element of the memory 510, the processor 520, and the communication module 530 is directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines.
[0201] Among them, the memory 510 is used to store programs or data. The memory 510 can be, but is not limited to, a random access memory (Random Access Memory, abbreviated as RAM), a read-only memory (Read Only Memory, abbreviated as ROM), a programmable read-only memory (Programmable Read-Only Memory, abbreviated as PROM), an erasable programmable read-only memory (Erasable Programmable Read-Only Memory, abbreviated as EPROM), an electrically erasable programmable read-only memory (Electric Erasable Programmable Read-Only Memory, abbreviated as EEPROM), etc.
[0202] The processor 520 is used to read / write the data or programs stored in the memory 510 and perform corresponding functions. For example, when the computer program stored in the memory 510 is executed by the processor 520, the time series analysis model training method or the time series analysis method disclosed in the above embodiments can be implemented.
[0203] The communication module 530 is used to establish a communication connection between the electronic device 500 and other communication terminals through a network, and is used to send and receive data through the network.
[0204] It should be understood that Figure 12 The structure shown is only a schematic diagram of the structure of the electronic device 500. The electronic device 500 may also include more or fewer components than those shown in Figure 12 or have a different configuration from that shown in Figure 12 The components shown in can be implemented using hardware, software, or a combination thereof. Figure 12 The components shown in can be implemented using hardware, software, or a combination thereof.
[0205] An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by the processor 520, the time series analysis model training method or the time series analysis method disclosed in the above embodiments is implemented.
[0206] An embodiment of the present invention also provides a program product. When the program product is executed by the processor 520, the time series analysis model training method or the time series analysis method disclosed in the above embodiments is implemented.
[0207] In several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order from that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
[0208] In addition, each functional module in various embodiments of the present invention may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
[0209] If the above-mentioned function 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 such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.
[0210] The foregoing are only the preferred embodiments of the present invention and are not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and changes. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for training a time series analysis model, characterized in that, The method includes: Input the historical time series, task instructions, historical background information, and historical statistical information into the feature fusion module of the large language model to obtain time-frequency fusion features; the historical background information is the summary information of the historical time series; the historical statistical information is the detailed information of the historical time series; If there is at least one of a prediction task, an imputation task, and an anomaly detection task in the task instructions, input the time-frequency fusion features into the masking module of the large language model for analysis to obtain a masking result; If there is a classification task in the task instructions, input the time-frequency fusion features into the classification module of the large language model for analysis to obtain a classification result; Input the masking result and the classification result into the output module of the large language model to obtain an analysis result; Based on the analysis result and the loss information of the theoretical result corresponding to the historical time series, iteratively update the parameters of the large language model to obtain a time series analysis model.
2. The time series analysis model training method according to claim 1, wherein The feature fusion module includes a time series fusion module, a task fusion module, and a large language network; the step of inputting the historical time series, task instructions, historical background information, and historical statistical information into the feature fusion module of the large language model to obtain time-frequency fusion features includes: Input the historical time series into the time series fusion module for feature extraction to obtain time domain features and frequency domain features, and fuse the time domain features and the frequency domain features to obtain time-frequency features; Input the task instructions, historical background information, and historical statistical information into the task fusion module for feature extraction to obtain task features; Fuse the time-frequency features and the task features and input them into the large language network to obtain the time-frequency fusion features.
3. The time series analysis model training method according to claim 2, wherein The step of inputting the historical time series into the time series fusion module for feature extraction to obtain time domain features and frequency domain features, and fusing the time domain features and the frequency domain features to obtain time-frequency features includes: Use the time series fusion module to divide the historical time series into multiple short time slices to obtain the time domain features; Perform a short-time Fourier transform on the historical time series to obtain a time-frequency matrix; Perform a projection transformation according to the time-frequency matrix to obtain the frequency domain features; Map the time domain features and the frequency domain features to a joint feature space to obtain the time-frequency features.
4. The time series analysis model training method according to claim 2, characterized in that The step of inputting the task instructions, historical background information, and historical statistical information into the task fusion module for feature extraction to obtain task features includes: Use the task fusion module to extract features from the task instructions to obtain instruction features; Extract features from the historical background information to obtain background features; Extract features from the historical statistical information to obtain statistical features; Concatenate the instruction features, the background features, and the statistical features to obtain task features.
5. The time series analysis model training method according to claim 1, wherein, The step of inputting the time-frequency fusion features into the masking module of the large language model for analysis to obtain a masking result includes: Use the masking module to perform an element-wise multiplication on the time-frequency fusion features and a masking matrix to obtain a masking fusion feature; Iteratively infer according to the masking fusion feature to obtain a masking result.
6. The time series analysis model training method according to claim 1, wherein Iteratively update the parameters of the large language model based on the loss information of the analysis result and the theoretical result corresponding to the historical time series to obtain a time series analysis model, including: Obtain a time domain loss value according to the time domain characteristics of the analysis result and the time domain characteristics of the theoretical result; Obtain a frequency domain loss value according to the frequency domain characteristics of the analysis result and the frequency domain characteristics of the theoretical result; Obtain a balance loss value according to the time-frequency matrix of the analysis result and the time-frequency matrix of the theoretical result; Obtain the loss information according to the time domain loss value, the frequency domain loss value, and the balance loss value; Iteratively update the parameters of the large language model using the loss information to obtain a time series analysis model.
7. A time series analysis method, characterized in that, The method includes: Receive a time series to be processed and a task to be processed; Input the time series to be processed and the task to be processed into a pre-trained time series analysis model to obtain an analysis conclusion corresponding to the time series to be processed; the time series analysis model is trained according to the time series analysis model training method described in any one of claims 1-6.
8. A time series analysis model training device, characterized in that, The device includes: A processing module, configured to input a historical time series, a task instruction, historical background information, and historical statistical information into a feature fusion module of a large language model to obtain a time-frequency fusion feature; the historical background information is a summary information of the historical time series; the historical statistical information is detailed information of the historical time series; An execution module, configured to, if there is at least one of a prediction task, an interpolation task, and an anomaly detection task in the task instruction, input the time-frequency fusion feature into a mask module of the large language model for analysis to obtain a mask result; if there is a classification task in the task instruction, input the time-frequency fusion feature into a classification module of the large language model for analysis to obtain a classification result; An update module, configured to input the mask result and the classification result into an output module of the large language model to obtain an analysis result; iteratively update the parameters of the large language model based on the loss information of the analysis result and the theoretical result corresponding to the historical time series to obtain a time series analysis model.
9. A time series analysis device, characterized in that, The device includes: A receiving module, configured to receive a time series to be processed and a task to be processed; An analysis module, configured to input the time series to be processed and the task to be processed into a pre-trained time series analysis model to obtain an analysis conclusion corresponding to the time series to be processed; the time series analysis model is trained according to the time series analysis model training method described in any one of claims 1-6.
10. An electronic device, characterized in that, Including a processor and a memory, the memory is used to store a computer program, and the processor is used to implement the time series analysis model training method described in any one of claims 1-6 and / or the time series analysis method described in claim 7 when executing the computer program.