Limited space early warning method based on time sequence converter

By using a time-series transformer-based approach, combined with diffusion constraint matrix and sensor dependency matrix, a joint model of multi-scale time dependence and spatial structure is constructed, solving the problem of early anomaly pattern recognition in finite space monitoring systems and achieving efficient early warning of potential risks.

CN121640686APending Publication Date: 2026-03-10QINGQIAO SECURITY SERVICE (WUHAN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-04
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing confined space monitoring systems cannot effectively identify early abnormal patterns in multi-source environmental parameters with small-scale coordinated changes. They suffer from time bias and prediction deviation, lack characterization of the actual diffusion path, are difficult to capture short-term mutations and local fluctuations in anomaly precursor signals, have high computational costs, and are insufficient in the early identification of potential risks.

Method used

A time-series transformer-based approach is adopted. Through multivariate preprocessing with a unified time base, the introduction of diffusion constraint matrix and sensor dependency matrix, and the combination of hierarchical sparse attention and cross-layer linear transformation of improved Pyraformer, a joint model of multi-scale time dependence and spatial structure information is constructed. Anomaly-sensitive residuals are constructed and quantitative hazard indicators are generated.

Benefits of technology

It improves the accuracy and lead time of early warning in confined spaces, and enables the early identification and location of potential risks based on the restoration of multi-source data integrity and joint modeling of physical structure and time series characteristics, thus significantly improving the response capability of the monitoring system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121640686A_ABST
    Figure CN121640686A_ABST
Patent Text Reader

Abstract

The invention discloses a finite space early warning method based on a time sequence converter. The method comprises the following steps: S1, collecting a finite space multivariable environment time sequence and executing preprocessing; s2, constructing a pyramid type input sequence containing time position codes and sensor category codes; s3, generating a diffusion constraint matrix and a sensor dependence matrix, and marking a target early warning time step; s4, inputting the pyramid type input sequence into an improved Pyraformer model to execute hierarchical sparse attention calculation to generate hierarchical hidden representation; s5, executing cross-layer linear transformation according to the sensor dependency matrix and applying a preset weight to the target early warning time step; s6, constructing an abnormal sensitive residual error, performing superposition to generate a multi-scale hidden representation, and performing decoding to obtain a future environment parameter prediction sequence; and S7, generating a risk index, comparing the risk index with a threshold value, and outputting an early warning result. According to the invention, the accuracy and the advance of the early warning in the limited space are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of confined space environment monitoring and deep learning technology, and in particular to a confined space early warning method based on a time series converter. Background Technology

[0002] With the continuous growth in demand for confined space operations and the increasing requirements for personnel safety in industrial settings, technologies for continuous monitoring and early risk identification of multi-source environmental parameters such as gas concentration, temperature, humidity, oxygen content, pressure, and vibration within confined spaces have gained widespread attention. Existing confined space monitoring systems largely rely on single-sensor threshold alarms, simple linkage judgments of multi-channel environmental parameters, or trend identification methods based on fixed models. However, these systems commonly suffer from the following problems in practical applications:

[0003] Environmental parameter changes within confined spaces are characterized by suddenness, cumulativeity, and coupling. Most existing monitoring systems employ independent threshold judgment methods, which cannot identify early abnormal patterns when multiple environmental variables change in a small but coordinated manner. This is especially true in situations where ventilation paths are limited or local accumulation phenomena are significant, leading to a risk of missed detection by traditional threshold methods. Furthermore, multi-source sensors exhibit significant differences in deployment location, sampling frequency, and hardware characteristics. Existing data alignment and compensation techniques struggle to ensure strict synchronization between multi-dimensional time series, resulting in time skew in subsequent trend-based analyses and impacting the reliability of early risk identification. Confined spaces possess complex three-dimensional structures, obstacle distributions, and ventilation boundaries, meaning the diffusion process of environmental parameters is not uniform and linear. However, existing early warning models typically do not incorporate spatial topology into their calculations, lacking a depiction of the actual diffusion paths. Consequently, they fail to reflect the physical relationships between parameters during modeling, causing prediction bias. Simultaneously, traditional time series analysis methods such as ARIMA, moving averages, and simple deep learning models have limited ability to capture short-term abrupt changes, local fluctuations, and cross-scale trend changes in anomaly precursor signals, making it difficult to form effective anomaly-sensitive features and resulting in insensitivity of prediction models to early abnormal states.

[0004] Furthermore, while existing deep learning-based time series prediction methods can learn the correlations between multiple variables to some extent, most models employ global attention mechanisms or single-scale correlation analysis, resulting in high computational costs and insufficient preservation of the temporal dependencies of long series. In scenarios requiring continuous monitoring and long-term series input in confined spaces, it is difficult to balance accuracy and real-time performance. Simultaneously, existing models typically lack structured constraints on sensor placement, diffusion paths, and spatial obstruction during feature processing, causing attention weights to rely solely on statistical correlations, which can easily generate spurious correlations and mask the true source of risk. Regarding the characterization of anomaly precursor features, existing methods lack multi-scale sensitive processing for local differences and local fluctuations, failing to jointly model early anomaly fluctuations, the depth of mutations, and cumulative trends, leading to insufficient early identification capabilities for potential risks.

[0005] Therefore, how to provide a finite-space early warning method based on a time-series converter is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0006] One objective of this invention is to propose an early warning method for confined spaces based on a time-series transformer. This invention achieves joint modeling of multi-scale time dependence and spatial structure information by using multivariate preprocessing with a unified time base, introducing diffusion constraint matrices and sensor dependency matrices that reflect ventilation paths and sensor layouts in confined spaces, and combining hierarchical sparse attention and cross-layer linear transformation with an improved Pyraformer. By constructing anomaly-sensitive residuals to enhance precursor feature representation through local difference and local variance, and generating quantitative hazard indicators based on the predicted sequence, it can locate potential risk time steps in advance, thereby improving the accuracy and lead time of early warning for confined spaces.

[0007] A finite-space early warning method based on a time-series converter according to an embodiment of the present invention includes the following steps: S1. Collect multivariate environmental time series within a limited space, and perform time alignment, missing data completion, and outlier removal to form a preprocessed multivariate time series; S2. Divide the preprocessed multivariate time series according to a preset time scale, and construct a pyramid-shaped input sequence that includes time location coding and sensor category coding; S3. Construct a diffusion constraint matrix and a sensor dependency matrix based on the limited space structure and sensor layout, and mark the time steps of the target warning time range; S4. Input the pyramid-shaped input sequence into the improved Pyraformer model, and perform hierarchical sparse attention calculation in the attention layer of the pyramid structure according to the diffusion constraint matrix to obtain the hierarchical hidden representation of the pyramid structure. S5. Perform a linear transformation on the hidden representation of the previous pyramid layer based on the sensor dependency matrix between adjacent pyramid layers, input the linearly transformed hidden representation into the attention layer of the next pyramid layer, and apply a preset weight to the time step of the target warning time range. S6. Calculate the local difference and local variance for each layer of the pyramid structure according to the corresponding time window, construct the anomaly-sensitive residual, superimpose the anomaly-sensitive residual with the original residual to generate a multi-scale hidden representation, and decode it by the improved Pyraformer model to obtain the future environmental parameter prediction sequence. S7. Generate a hazard index based on the predicted sequence of future environmental parameters, compare the hazard index with a preset threshold, and output a warning result based on the comparison result.

[0008] Optionally, S1 includes: S11. Within a limited space, determine the monitoring area, and arrange gas concentration sensors, temperature sensors, humidity sensors, oxygen content sensors, pressure sensors, and vibration sensors. Set the sampling interval and timestamp recording method for each sensor. S12. Collect raw environmental parameter data according to the sampling interval of the sensors, and arrange the data of each sensor at the same or adjacent timestamps in chronological order to form a one-dimensional time series of each sensor. S13. Time-align the one-dimensional time series with a unified time reference by inserting records at missing time points and adjusting the record order to form a time-aligned multivariate time series. S14. Identify missing records in a time-aligned multivariate time series, and perform interpolation to fill the missing records based on the numerical difference and time difference of adjacent valid records; S15. Identify outliers in the multivariate time series after interpolation and filling. Calculate the magnitude and range of numerical changes within a preset sliding time window. When the value at a sampling moment exceeds the safe operating range of the sensor and the difference relative to adjacent sampling moments exceeds a preset change threshold, mark the corresponding sampling moment as an outlier and remove it from the series. S16. For time breakpoints caused by outlier removal, interpolation is performed based on the time difference and numerical difference between adjacent valid records. S17. Combine the sensor values ​​corresponding to each timestamp into a multidimensional record in a fixed order, arrange all multidimensional records in chronological order, and form a preprocessed multivariate time series.

[0009] Optionally, S2 includes: S21. Divide the preprocessed multivariate time series into multiple time windows according to the preset time scale; S22. Extract the multidimensional records corresponding to each sensor in chronological order within each time window, and arrange the multidimensional records within the time window into a continuous subsequence. S23. Generate a time position code for each time step in each subsequence, wherein the time position code is a fixed-length vector generated according to the order of the time steps in the subsequence; S24. Generate a sensor category code for each record in each subsequence, wherein the sensor category code is a fixed-length vector generated based on the physical attributes and arrangement of the sensors in the monitoring area in the record; S25. Combine the time location code and sensor category code into the multidimensional record of the corresponding time step in a fixed splicing order to form a subsequence containing dual codes; S26. Arrange all subsequences from the shortest time window to the longest time window according to the preset time scale to form a pyramid-shaped input sequence composed of multiple subsequences.

[0010] Optionally, S3 includes: S31. Generate a finite space structure model based on the three-dimensional boundary shape, entrance and exit positions, and internal obstacle positions of the finite space. The finite space structure model is a spatial representation that describes the spatial boundary and obstacle distribution in three-dimensional coordinates. S32. Generate a sensor location set based on the installation location of each sensor within the monitoring area. The sensor location set is a set that records the three-dimensional coordinates of each sensor. S33. Based on the finite space structure model and sensor location set, determine the spatial distance between sensors, ventilation path length and obstacle blocking relationship, and form spatial association data that records spatial connection relationship; S34. Construct a diffusion constraint matrix based on the spatial correlation data. The diffusion constraint matrix is ​​a weighted matrix that describes the strength of physical diffusion correlation between different time steps. The elements of the weighted matrix are generated based on the ventilation path length, the number of obstacles, and the spatial distance. S35. Construct a sensor dependency matrix based on spatial correlation data. The sensor dependency matrix is ​​a weighted matrix that describes the spatial dependency relationship between different sensors. The elements of the weighted matrix are generated based on the spatial distance between the sensors and the direction of gas or temperature propagation between the sensors. S36. Based on the preset target warning time range, record the time step positions that are consistent with the target warning time range in the pyramid-shaped input sequence, and create an index for the recorded time step positions.

[0011] Optionally, S4 includes: S41. Input the pyramid-shaped input sequence into the pyramid structure of the improved Pyraformer model in order from the shortest time scale to the longest time scale, with each time scale corresponding to a pyramid attention layer. S42. In each pyramid attention layer, the query vector and key vector of the input sequence are multiplied by a vector dot product. The vector dot product result is weighted according to the corresponding elements in the diffusion constraint matrix to obtain the weighted relevance result. S43. In each pyramid attention layer, perform sparse selection on the weighted correlation results according to the preset sparse strategy, and perform normalization calculation on the selected correlation results to form sparse attention weights. S44. In each pyramid attention layer, perform a weighted summation of the sparse attention weights and the numerical vector of the input sequence to generate the attention output representation of this layer. S45. In each pyramid attention layer, the attention output representation is combined with the output representation of the previous pyramid attention layer in a fixed splicing order to form a hierarchical hidden representation that includes the features of the current time scale and cross-layer features. S46. Arrange the hierarchical hidden representations obtained from each pyramid attention layer in chronological order to form a set of hierarchical hidden representations of the pyramid structure.

[0012] Optionally, S5 includes: S51. Perform a linear transformation on the hidden representation of the previous pyramid layer between adjacent pyramid layers based on the sensor dependency matrix. The linear transformation is achieved by performing matrix multiplication on the hidden representation with the sensor dependency matrix in a fixed order and generating a linear transformation result. S52. Insert the linear transformation result into the input sequence position of the next pyramid layer according to the time step order, and align it with the original input sequence of the next pyramid layer according to the time stamp correspondence to form the input sequence reference of the next pyramid layer. S53. In the next pyramid layer, perform index matching on the input sequence benchmark according to the time step position of the target warning time range to obtain the set of time steps corresponding to the target warning time range. S54. In the set of time steps, perform weight enhancement processing on the attention relevance value of each time step. The weight enhancement processing generates the enhanced relevance value by multiplying the attention relevance value of the time step by a fixed gain factor. S55. Combine the enhanced correlation values ​​with the unenhanced correlation values ​​in the original time step order to generate an attention correlation sequence containing target warning time range information; S56. Input the attention correlation sequence into the attention calculation process of the next pyramid layer. In the attention calculation process, use the query vector, key vector and value vector in sequence to calculate the hidden representation of the next pyramid layer, forming the hidden representation of the next pyramid layer containing linear transformation information and target warning time range information.

[0013] Optionally, S6 includes: S61. Within each layer of the pyramid structure, the hidden representation within the corresponding time window of that layer is divided into several consecutive recording segments in chronological order, and each recording segment contains a fixed number of time steps. S62. Within each recording segment, perform numerical difference on the hidden representations of adjacent time steps, subtract the hidden representation of the previous time step from the hidden representation of the next time step, and generate the difference sequence of the recording segment. S63. Within each recording segment, calculate the local difference of the recording segment based on the numerical range of the difference sequence. The local difference is the difference between the maximum and minimum values ​​of all values ​​in the difference sequence. S64. Within each recording segment, the variance of the deviation of all values ​​in the difference sequence is calculated. The variance is calculated by subtracting the average value of the difference sequence from each value in the difference sequence, squaring the result, and then averaging the result to generate the local variance. S65. Combine the local difference and local variance according to a fixed weighting coefficient to generate the anomaly-sensitive residuals of the corresponding record segments, and map the anomaly-sensitive residuals to the corresponding time step positions according to the record segment order. S66. In each layer of the pyramid structure, the abnormally sensitive residual is numerically added to the original residual of the current layer to generate an in-layer hidden representation containing abnormally sensitive information. S67. Combine the intra-layer hidden representations of each layer in order of time scale to form a multi-scale hidden representation. Input the multi-scale hidden representation into the decoding structure of the improved Pyraformer model to generate a future environmental parameter prediction sequence.

[0014] Optionally, S7 includes: S71. In the future environmental parameter prediction sequence, the predicted values ​​of gas concentration, temperature, humidity, oxygen content, pressure and vibration are extracted in time order, and the predicted values ​​of each time step are combined in a fixed order to form a prediction parameter vector. S72. Within each prediction parameter vector, calculate the difference between each predicted value and the upper and lower limits of the corresponding sensor's safe operating range to obtain the deviation of each predicted value from the boundary of the safe range. S73. Within each prediction parameter vector, the deviations are combined according to fixed weight coefficients to generate a risk score for that time step. The risk score is a quantitative result of the degree of deviation of each prediction value from the safe operating range. S74. Combine the risk scores into a risk score sequence according to the time step order, and perform a numerical comparison between each score in the risk score sequence and a preset threshold. S75. When the numerical comparison result meets the preset triggering condition, mark the time step that meets the triggering condition as the warning time step; S76. Output the early warning time steps in chronological order as early warning results for confined spaces.

[0015] The beneficial effects of this invention are: This invention deeply couples the three-dimensional structural features of a confined space, sensor arrangement relationships, and multi-scale time series modeling. Addressing issues such as time asynchrony, missing records, anomalous noise points, and non-uniform diffusion characteristics of multi-source environmental parameters at the acquisition end, it constructs a multivariate sequence with a unified time reference. High-completeness preprocessing of multi-source data is achieved using time alignment, sliding window interpolation, and outlier removal. In the input modeling stage, a pyramid-shaped input sequence containing time location encoding and sensor category encoding is constructed. A diffusion constraint matrix and a sensor dependency matrix reflecting the actual ventilation path, obstacle distribution, and spatial positional relationships of sensors within the confined space are introduced, thus integrating physical diffusion characteristics and spatial dependencies. This method employs an explicit embedding model structure. In the temporal feature extraction stage, a hierarchical sparse attention mechanism based on an improved Pyraformer is used to extract multi-scale features from long sequences. During cross-layer propagation, a linear transformation is performed based on the sensor dependency matrix, applying specific weights to the target warning time range. This allows the attention mechanism to highlight potential risk time periods during the modeling phase. In the anomaly precursor modeling stage, an anomaly-sensitive residual based on local difference and local variance is constructed. Multi-scale superposition enhances the model's responsiveness to sudden changes, cumulative fluctuations, and cross-scale trends. Finally, a quantitative hazard index is constructed based on the predicted sequence, and future risk time steps are located, enabling early identification of risk states in confined spaces. This method significantly improves multi-source data integrity recovery, joint modeling of physical structure and time-series features, construction of cross-scale anomaly sensitivity, and early risk assessment. It can output early warning results with time-localization capabilities in complex confined spatial environments, significantly improving the monitoring system's ability to respond to potential hazards in advance. Attached Figure Description

[0016] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0017] Figure 1 This is a schematic diagram of the overall process of a finite space early warning method based on a time-series converter proposed in this invention; Figure 2 This is a schematic diagram of the structure of the improved Pyraformer model in this invention; Figure 3 This is a schematic diagram illustrating the construction process of the diffusion constraint matrix and sensor dependency matrix in this invention. Detailed Implementation

[0018] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0019] refer to Figure 1-3 A finite-space early warning method based on a time-series converter includes the following steps: S1. Collect multivariate environmental time series within a limited space, and perform time alignment, missing data completion, and outlier removal to form a preprocessed multivariate time series; S2. Divide the preprocessed multivariate time series according to a preset time scale, and construct a pyramid-shaped input sequence that includes time location coding and sensor category coding; S3. Construct a diffusion constraint matrix and a sensor dependency matrix based on the limited space structure and sensor layout, and mark the time steps of the target warning time range; S4. Input the pyramid-shaped input sequence into the improved Pyraformer model, and perform hierarchical sparse attention calculation in the attention layer of the pyramid structure according to the diffusion constraint matrix to obtain the hierarchical hidden representation of the pyramid structure. S5. Perform a linear transformation on the hidden representation of the previous pyramid layer based on the sensor dependency matrix between adjacent pyramid layers, input the linearly transformed hidden representation into the attention layer of the next pyramid layer, and apply a preset weight to the time step of the target warning time range. S6. Calculate the local difference and local variance for each layer of the pyramid structure according to the corresponding time window, construct the anomaly-sensitive residual, superimpose the anomaly-sensitive residual with the original residual to generate a multi-scale hidden representation, and decode it by the improved Pyraformer model to obtain the future environmental parameter prediction sequence. S7. Generate a hazard index based on the predicted sequence of future environmental parameters, compare the hazard index with a preset threshold, and output a warning result based on the comparison result.

[0020] In this embodiment, S1 includes: S11. Within a limited space, determine the monitoring area, and arrange gas concentration sensors, temperature sensors, humidity sensors, oxygen content sensors, pressure sensors, and vibration sensors. Set the sampling interval and timestamp recording method for each sensor. S12. Collect raw environmental parameter data according to the sampling interval of the sensors, and arrange the data of each sensor at the same or adjacent timestamps in chronological order to form a one-dimensional time series of each sensor. S13. Time-align the one-dimensional time series with a unified time reference by inserting records at missing time points and adjusting the record order to form a time-aligned multivariate time series. S14. Identify missing records in a time-aligned multivariate time series, and perform interpolation to fill the missing records based on the numerical difference and time difference of adjacent valid records; S15. Identify outliers in the multivariate time series after interpolation and filling. Calculate the magnitude and range of numerical changes within a preset sliding time window. When the value at a sampling moment exceeds the safe operating range of the sensor and the difference relative to adjacent sampling moments exceeds a preset change threshold, mark the corresponding sampling moment as an outlier and remove it from the series. S16. For time breakpoints caused by outlier removal, interpolation is performed based on the time difference and numerical difference between adjacent valid records. S17. Combine the sensor values ​​corresponding to each timestamp into a multidimensional record in a fixed order, arrange all multidimensional records in chronological order, and form a preprocessed multivariate time series.

[0021] In this embodiment, S2 includes: S21. Divide the preprocessed multivariate time series into multiple time windows according to the preset time scale; S22. Extract the multidimensional records corresponding to each sensor in chronological order within each time window, and arrange the multidimensional records within the time window into a continuous subsequence. S23. Generate a time position code for each time step in each subsequence, wherein the time position code is a fixed-length vector generated according to the order of the time steps in the subsequence; S24. Generate a sensor category code for each record in each subsequence, wherein the sensor category code is a fixed-length vector generated based on the physical attributes and arrangement of the sensors in the monitoring area in the record; S25. Combine the time location code and sensor category code into the multidimensional record of the corresponding time step in a fixed splicing order to form a subsequence containing dual codes; S26. Arrange all subsequences from the shortest time window to the longest time window according to the preset time scale to form a pyramid-shaped input sequence composed of multiple subsequences.

[0022] In this embodiment, S3 includes: S31. Generate a finite space structure model based on the three-dimensional boundary shape, entrance and exit positions, and internal obstacle positions of the finite space. The finite space structure model is a spatial representation that describes the spatial boundary and obstacle distribution in three-dimensional coordinates. S32. Generate a sensor location set based on the installation location of each sensor within the monitoring area. The sensor location set is a set that records the three-dimensional coordinates of each sensor. S33. Based on the finite space structure model and sensor location set, determine the spatial distance between sensors, ventilation path length and obstacle blocking relationship, and form spatial association data that records spatial connection relationship; S34. Construct a diffusion constraint matrix based on the spatial correlation data. The diffusion constraint matrix is ​​a weighted matrix that describes the strength of physical diffusion correlation between different time steps. The elements of the weighted matrix are generated based on the ventilation path length, the number of obstacles, and the spatial distance. S35. Construct a sensor dependency matrix based on spatial correlation data. The sensor dependency matrix is ​​a weighted matrix that describes the spatial dependency relationship between different sensors. The elements of the weighted matrix are generated based on the spatial distance between the sensors and the direction of gas or temperature propagation between the sensors. S36. Based on the preset target warning time range, record the time step positions that are consistent with the target warning time range in the pyramid-shaped input sequence, and create an index for the recorded time step positions.

[0023] This invention constructs the diffusion constraint matrix and sensor dependency matrix by jointly modeling the three-dimensional boundary and obstacle layout of a finite space with the spatial coordinates of the sensors. This ensures that the correlation strength between time steps remains consistent with the actual diffusion path, avoiding spurious correlations caused by traditional time-series models relying on purely statistical features. Since the propagation of gas, temperature, and humidity within a finite space exhibits directionality, obstruction, and path dependence, this invention explicitly characterizes the transmission path and obstruction relationships through spatial correlation data, ensuring that the matrix weights correspond to the real physical environment. This provides structured constraints for subsequent attention calculations. This modeling method is feasible, as the required data can be obtained through conventional sensor arrangements. It is also significantly innovative because existing time-series transformers do not introduce a spatial structure mapping consistent with the three-dimensional physical environment, nor do they use the diffusion path as a source of attention constraints.

[0024] In this embodiment, S4 includes: S41. Input the pyramid-shaped input sequence into the pyramid structure of the improved Pyraformer model in order from the shortest time scale to the longest time scale, with each time scale corresponding to a pyramid attention layer. S42. In each pyramid attention layer, the query vector and key vector of the input sequence are multiplied by a vector dot product. The vector dot product result is weighted according to the corresponding elements in the diffusion constraint matrix to obtain the weighted relevance result. S43. In each pyramid attention layer, perform sparse selection on the weighted correlation results according to the preset sparse strategy, and perform normalization calculation on the selected correlation results to form sparse attention weights. S44. In each pyramid attention layer, perform a weighted summation of the sparse attention weights and the numerical vector of the input sequence to generate the attention output representation of this layer. S45. In each pyramid attention layer, the attention output representation is combined with the output representation of the previous pyramid attention layer in a fixed splicing order to form a hierarchical hidden representation that includes the features of the current time scale and cross-layer features. S46. Arrange the hierarchical hidden representations obtained from each pyramid attention layer in chronological order to form a set of hierarchical hidden representations of the pyramid structure.

[0025] This invention, in the process of hierarchical sparse attention computation, introduces a diffusion constraint weighting mechanism into the pyramid attention layers corresponding to each time scale. This ensures that the selection of attention weights is no longer solely based on vector correlation, but rather incorporates constraint information generated by the actual diffusion path within a limited space and physical barriers. This allows attention layers at different time scales to generate hierarchical hidden representations that conform to physical laws. The pyramid structure expands the time range progressively from bottom to top, and the correlation points retained by each layer under the sparse strategy are limited to a physically accessible range, thereby improving the effectiveness of multi-scale feature extraction. This approach provides the transformer with structured constraints when capturing both short-term changes and long-term trends, distinguishing it from existing temporal attention methods based on pure statistical correlation.

[0026] In this embodiment, S5 includes: S51. Perform a linear transformation on the hidden representation of the previous pyramid layer between adjacent pyramid layers based on the sensor dependency matrix. The linear transformation is achieved by performing matrix multiplication on the hidden representation with the sensor dependency matrix in a fixed order and generating a linear transformation result. S52. Insert the linear transformation result into the input sequence position of the next pyramid layer according to the time step order, and align it with the original input sequence of the next pyramid layer according to the time stamp correspondence to form the input sequence reference of the next pyramid layer. S53. In the next pyramid layer, perform index matching on the input sequence benchmark according to the time step position of the target warning time range to obtain the set of time steps corresponding to the target warning time range. S54. In the set of time steps, perform weight enhancement processing on the attention relevance value of each time step. The weight enhancement processing generates the enhanced relevance value by multiplying the attention relevance value of the time step by a fixed gain factor. S55. Combine the enhanced correlation values ​​with the unenhanced correlation values ​​in the original time step order to generate an attention correlation sequence containing target warning time range information; S56. Input the attention correlation sequence into the attention calculation process of the next pyramid layer. In the attention calculation process, use the query vector, key vector and value vector in sequence to calculate the hidden representation of the next pyramid layer, forming the hidden representation of the next pyramid layer containing linear transformation information and target warning time range information.

[0027] This invention introduces a linear transformation driven by a sensor dependency matrix between adjacent pyramid layers. This ensures that the information transmitted across layers not only includes differences in time scales but also reflects the spatial dependencies between sensors within a limited space, thereby guaranteeing that the input of each layer remains consistent with the actual physical layout. Furthermore, by applying enhanced weights to the time steps corresponding to the target warning time range, the attention mechanism can highlight time periods related to potential risks when calculating the relevance of the next pyramid layer, achieving selective enhancement of time slices that are about to change. This approach differs from traditional time series transformers that allocate attention solely based on the sequence's own characteristics; it combines spatial dependency constraints and warning time location information to generate cross-layer features with predictive sensitivity.

[0028] In this embodiment, S6 includes: S61. Within each layer of the pyramid structure, the hidden representation within the corresponding time window of that layer is divided into several consecutive recording segments in chronological order, and each recording segment contains a fixed number of time steps. S62. Within each recording segment, perform numerical difference on the hidden representations of adjacent time steps, subtract the hidden representation of the previous time step from the hidden representation of the next time step, and generate the difference sequence of the recording segment. S63. Within each recording segment, calculate the local difference of the recording segment based on the numerical range of the difference sequence. The local difference is the difference between the maximum and minimum values ​​of all values ​​in the difference sequence. S64. Within each recording segment, the variance of the deviation of all values ​​in the difference sequence is calculated. The variance is calculated by subtracting the average value of the difference sequence from each value in the difference sequence, squaring the result, and then averaging the result to generate the local variance. S65. Combine the local difference and local variance according to a fixed weighting coefficient to generate the anomaly-sensitive residuals of the corresponding record segments, and map the anomaly-sensitive residuals to the corresponding time step positions according to the record segment order. S66. In each layer of the pyramid structure, the abnormally sensitive residual is numerically added to the original residual of the current layer to generate an in-layer hidden representation containing abnormally sensitive information. S67. Combine the intra-layer hidden representations of each layer in order of time scale to form a multi-scale hidden representation. Input the multi-scale hidden representation into the decoding structure of the improved Pyraformer model to generate a future environmental parameter prediction sequence.

[0029] This invention, when constructing anomaly-sensitive residuals, performs differencing and variance operations on the hidden representations at each time scale. This allows the residuals to reflect not only the magnitude of changes between adjacent time steps but also the intensity of fluctuations within a local time window, thereby capturing the common characteristics of short-term drastic changes and cumulative anomalies in a limited spatial environment. The combination of differencing and variance creates a consistent anomaly sensitivity measure across different pyramid layers, ensuring comparability and hierarchical consistency in the fusion of multi-scale hidden representations. This approach significantly differs from traditional sequence models that rely solely on single-layer residuals or single statistical features. By constructing structured multi-scale residuals, it enhances the model's sensitivity to early anomaly signals, providing a stable information foundation with precursory features for subsequent predictions.

[0030] In this embodiment, S7 includes: S71. In the future environmental parameter prediction sequence, the predicted values ​​of gas concentration, temperature, humidity, oxygen content, pressure and vibration are extracted in time order, and the predicted values ​​of each time step are combined in a fixed order to form a prediction parameter vector. S72. Within each prediction parameter vector, calculate the difference between each predicted value and the upper and lower limits of the corresponding sensor's safe operating range to obtain the deviation of each predicted value from the boundary of the safe range. S73. Within each prediction parameter vector, the deviations are combined according to fixed weight coefficients to generate a risk score for that time step. The risk score is a quantitative result of the degree of deviation of each prediction value from the safe operating range. S74. Combine the risk scores into a risk score sequence according to the time step order, and perform a numerical comparison between each score in the risk score sequence and a preset threshold. S75. When the numerical comparison result meets the preset triggering condition, mark the time step that meets the triggering condition as the warning time step; S76. Output the early warning time steps in chronological order as early warning results for confined spaces.

[0031] This invention, when generating hazard indicators, quantitatively compares the predicted results of future multi-dimensional environmental parameters with their corresponding safe operating ranges. By combining deviations with weighting coefficients, the importance of different environmental parameters is expressed differently, enabling the hazard indicators to reflect the comprehensive risk level of a confined space at future moments. This method is more sensitive than traditional early warning models that rely on single-parameter thresholds, providing risk signals in advance when multiple parameters show slight but coordinated changes, thus achieving early warning based on multi-dimensional trends. By comparing the hazard indicators with thresholds hourly, potential hazard time steps can be located in the time dimension of the predicted sequence, ensuring the traceability and verifiability of the early warning output, forming a structured predictive capability for risks in confined spaces.

[0032] Example 1: To verify the feasibility and superiority of this invention in early warning within confined spaces, it was applied to the maintenance scenario of a sealed reactor in the raw material storage area of ​​a chemical enterprise. The reactor has a volume of approximately 10 cubic meters and is connected to the outside world only through a top access port, resulting in extremely limited internal airflow exchange. During normal shutdown preparation, slow leakage of volatile organic gases may occur inside the reactor, with concentration increases exhibiting characteristics of weakness, accumulation, lag, and spatial non-uniformity. Traditional detection methods rely on single-point gas detectors or handheld devices, which have low sampling frequencies, limited coverage, and are insensitive to initial changes, often triggering alerts only when the concentration approaches or reaches the alarm threshold, lacking early identification capabilities. This invention aims to solve this problem by achieving early warning through multi-source, multi-scale, and structured modeling.

[0033] In this embodiment, 18 environmental monitoring sensor nodes are arranged inside the reactor, including sensors for gas concentration, temperature, humidity, oxygen content, pressure, and vibration, collecting data every 5 seconds. The on-site operating condition is set to simulate a minor volatile gas leak, with the leak lasting approximately 40 minutes. The initial concentration rise is slow, reaching a maximum of approximately 13 ppm. The traditional threshold alarm line is set at 12 ppm. The early warning model of this invention forms stable input data through time alignment, interpolation completion, and outlier removal. Based on the three-dimensional structure inside the reactor, a diffusion constraint matrix and a sensor dependency matrix are generated, enabling the model to have a structured expression capability for the real diffusion path and spatial correlation. Subsequently, multi-scale feature extraction is performed through the pyramid structure of an improved Pyraformer, and the anomaly-sensitive residual constructed by local difference and local variance enhances the precursor signal, enabling this invention to achieve early identification when minor fluctuations of multiple variables occur simultaneously.

[0034] In actual testing, this invention inputs raw monitoring data from inside the reactor into the model to predict changes in gas concentration, temperature, and oxygen content over the next 20 minutes, and quantifies the risk trend using hazard indicators. To ensure a fair comparison, this embodiment records the first alarm time of the traditional threshold method, the first warning time of this invention, the lead time for both, and the predicted concentration and hazard indicators at each time point. The experimental results are shown in Table 1.

[0035] Table 1. Comparison of early warning methods of the present invention and conventional methods under the condition of leakage in the confined space of the reactor.

[0036] As shown in Table 1, the gas concentration at 14:18 was only 10.5 ppm, still significantly lower than the 12 ppm alarm threshold. However, early signs of synchronous changes in multivariate trends were already evident, such as a slow rise in temperature and an accelerated decline in oxygen content. The hazard index of this invention reached 0.36 at this time, exceeding the preset warning threshold of 0.30, triggering an alarm 17 minutes in advance. In contrast, the traditional threshold method only issued an alarm when the concentration exceeded 12 ppm at 14:35, completely failing to identify the early risks brought about by the cumulative weak trend. Compared to traditional methods, this invention significantly improves the lead time, and the predicted concentration trend in the early stage is highly consistent with the actual concentration trend, demonstrating good prediction accuracy. This reflects the advantages of this invention in confined space leakage scenarios: it can capture dangerous trends in the weak rising stage by utilizing the deep correlation between spatial structure and multi-source time series, improve the sensitivity to precursor signals through multi-scale differencing and variance enhancement mechanisms, and achieve early warning by constructing a quantitative hazard index through the predicted sequence. Test results show that, under real-world conditions, this invention provides risk warnings 15–20 minutes earlier than the traditional threshold method, offering more time for on-site handling and effectively reducing the risks in confined space operations.

[0037] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A time series transformer based limited space early warning method, characterized in that, The method comprises the following steps: S1, collecting a multivariate environment time series in a limited space, and performing time alignment, missing data completion and outlier removal to form a preprocessed multivariate time series; S2, dividing the preprocessed multivariate time series according to a preset time scale, and constructing a pyramid input sequence containing time position encoding and sensor category encoding; S3, constructing a diffusion constraint matrix and a sensor dependence matrix according to the structure of the limited space and the sensor layout, and marking the time steps of the target early warning time range; S4, inputting the pyramid input sequence into an improved Pyraformer model, and performing hierarchical sparse attention calculation in the attention layer of the pyramid structure according to the diffusion constraint matrix to obtain the hierarchical hidden representation of the pyramid structure; S5, performing linear transformation on the hidden representation of the previous pyramid layer according to the sensor dependence matrix between adjacent pyramid layers, inputting the linearly transformed hidden representation into the attention layer of the next pyramid layer, and applying a preset weight to the time steps of the target early warning time range; S6, calculating the local difference and local variance according to the corresponding time window at each layer of the pyramid structure, constructing an anomaly sensitive residual, superimposing the anomaly sensitive residual and the original residual, generating a multi-scale hidden representation, and decoding the future environment parameter prediction sequence from the improved Pyraformer model; S7, generating a hazard index according to the future environment parameter prediction sequence, comparing the hazard index with a preset threshold, and outputting an early warning result according to the comparison result.

2. A time transformer based limited space early warning method according to claim 1, characterized in that, The S1 comprises: S11, determining a monitoring area in the limited space, arranging gas concentration sensors, temperature sensors, humidity sensors, oxygen content sensors, pressure sensors and vibration sensors, and setting the sampling interval and time stamp recording method of each sensor; S12, collecting environment parameter raw data according to the sampling interval of the sensor, arranging the sensor data of the same time stamp or adjacent time stamp in time sequence to form a one-dimensional time series of each sensor; S13, time aligning the one-dimensional time series with a unified time reference, inserting records at missing time points and adjusting the order of records to form a multivariate time series aligned by time; S14, identifying missing records in the multivariate time series aligned by time, and performing interpolation filling on the missing records according to the numerical difference and time difference of adjacent valid records; S15, identifying outliers in the multivariate time series after interpolation filling, calculating the numerical change amplitude and numerical range in a preset sliding time window, when the numerical value at the sampling time simultaneously exceeds the safe working range of the sensor and the difference with respect to the adjacent sampling time exceeds the preset change threshold, marking the corresponding sampling time as an outlier and removing it from the sequence; S16, performing interpolation on the time breakpoints formed due to outlier removal according to the time difference and numerical difference of adjacent valid records; S17, combining the numerical values of each sensor corresponding to each time stamp into a multi-dimensional record in a fixed order, arranging all multi-dimensional records in time sequence to form a preprocessed multivariate time series.

3. A time transformer based limited space early warning method according to claim 1, characterized in that, The S2 comprises: S21, divide the preprocessed multivariate time series into multiple time windows according to a preset time scale; S22, extract the multi-dimensional records corresponding to each sensor in each time window in chronological order, and arrange the multi-dimensional records in the time window into a continuous sub-sequence; S23, generate a time position code for each time step in each sub-sequence, the time position code being a fixed-length vector generated according to the order of the time step in the sub-sequence; S24, generate a sensor category code for each record in each sub-sequence, the sensor category code being a fixed-length vector generated according to the physical properties and arrangement of the sensors in the monitoring area in the record; S25, combine the time position code and the sensor category code into the multi-dimensional record of the corresponding time step in a fixed splicing order to form a sub-sequence containing double encoding; S26, arrange all sub-sequences from the shortest time window to the longest time window according to the preset time scale to form a pyramid input sequence composed of multiple layers of sub-sequences.

4. A time transformer based limited space early warning method according to claim 1, characterized in that, The S3 comprises: S31, generate a limited space structure model according to the three-dimensional boundary shape, entrance and exit position and internal obstacle position of the limited space, the limited space structure model being a spatial representation describing the space boundary and obstacle distribution in three-dimensional coordinates; S32, generate a sensor position set according to the installation position of each sensor in the monitoring area, the sensor position set being a set of records of the three-dimensional coordinates of each sensor; S33, determine the spatial distance, ventilation path length and obstacle blocking relationship between the sensors according to the limited space structure model and the sensor position set, and form spatial correlation data recording the spatial connection relationship; S34, construct a diffusion constraint matrix according to the spatial correlation data, the diffusion constraint matrix being a weighted matrix describing the physical diffusion correlation strength between different time steps, the elements of the weighted matrix being generated according to the ventilation path length, the number of obstacle blocks and the spatial distance; S35, construct a sensor dependence matrix according to the spatial correlation data, the sensor dependence matrix being a weighted matrix describing the spatial dependence relationship between different sensors, the elements of the weighted matrix being generated according to the spatial distance between the sensors and the gas or temperature propagation direction between the sensors; S36, record the time step position consistent with the target early warning time range in the pyramid input sequence according to the preset target early warning time range, and establish an index for the recorded time step position.

5. A time transformer based limited space early warning method according to claim 1, characterized in that, The S4 comprises: S41, input the pyramid input sequence to the pyramid structure of the improved Pyraformer model in the order from the shortest time scale to the longest time scale, each time scale corresponding to a pyramid attention layer; S42, in each pyramid attention layer, perform vector inner product calculation on the query vector and the key vector of the input sequence, perform weighting processing on the vector inner product result according to the corresponding elements in the diffusion constraint matrix, and obtain the weighted correlation result; S43, perform sparse selection on the weighted correlation result in each pyramid attention layer according to a preset sparse strategy, and perform normalization calculation on the selected correlation result to form a sparse attention weight; S44, performing weighted summation of the sparse attention weights and the numerical vectors of the input sequence in each pyramid attention layer to generate an attention output representation of the current layer; S45, combining the attention output representation and the output representation of the previous pyramid attention layer according to a fixed splicing order in each pyramid attention layer to form a hierarchical hidden representation containing the current time scale feature and the cross-layer feature; S46, arranging the hierarchical hidden representations obtained by each pyramid attention layer in a time scale order to form a hierarchical hidden representation set with a pyramid structure.

6. A time transformer based limited space early warning method according to claim 1, characterized in that, The S5 includes: S51, performing linear transformation on the hidden representation of the previous pyramid layer according to the sensor dependence matrix between adjacent pyramid layers, and generating a linear transformation result by performing matrix multiplication on the hidden representation according to a fixed order and the sensor dependence matrix; S52, inserting the linear transformation result into the input sequence position of the next pyramid layer according to the time step order, aligning with the original input sequence of the next pyramid layer according to the timestamp correspondence, forming an input sequence reference of the next pyramid layer; S53, in the next pyramid layer, performing index matching on the input sequence reference according to the time step position of the target early warning time range to obtain a time step set corresponding to the target early warning time range; S54, in the time step set, performing weight enhancement processing on the attention correlation value of each time step, and generating an enhanced correlation value by multiplying the attention correlation value of the corresponding time step by a fixed gain factor according to the weight enhancement processing; S55, combining the enhanced correlation value and the unenhanced correlation value according to the original time step order to generate an attention correlation sequence containing the target early warning time range information; S56, inputting the attention correlation sequence into the attention calculation process of the next pyramid layer, and using the query vector, the key vector and the value vector in turn to calculate the hidden representation of the next pyramid layer in the attention calculation process to form the hidden representation of the next pyramid layer containing the linear transformation information and the target early warning time range information.

7. A time transformer based limited space early warning method according to claim 1, characterized in that, The S6 includes: S61, in each layer of the pyramid structure, dividing the hidden representation in the time window corresponding to the layer into a plurality of continuous recording segments in time order, each recording segment containing a fixed number of time steps; S62, in each recording segment, performing numerical differentiation on the hidden representations of adjacent time steps to generate a difference sequence of the recording segment by subtracting the hidden representation of the previous time step from the hidden representation of the next time step; S63, in each recording segment, calculating the local difference of the corresponding recording segment according to the numerical range of the difference sequence, the local difference being the difference between the maximum value and the minimum value of all numerical values in the difference sequence; S64, in each recording segment, performing variance calculation on the deviation degree of all numerical values in the difference sequence, the variance calculation generating a local variance by squaring and averaging the difference between each numerical value in the difference sequence and the average value of the difference sequence; S65, combining the local difference and the local variance according to a fixed weight coefficient set to generate an anomaly sensitive residual of the corresponding recording segment, and mapping the anomaly sensitive residual to the corresponding time step position in the recording segment order; S66, at each layer of the pyramid structure, performing numerical addition on the anomaly-sensitive residual and the original residual of the layer to generate an intra-layer hidden representation containing anomaly-sensitive information; S67, combining the intra-layer hidden representations of each layer in time scale order to form a multi-scale hidden representation, inputting the multi-scale hidden representation into the decoding structure of the improved Pyraformer model to generate a future environmental parameter prediction sequence.

8. A time transformer based limited space early warning method according to claim 1, characterized in that, The S7 comprises: S71, in the future environmental parameter prediction sequence, extracting the predicted values of gas concentration, temperature, humidity, oxygen content, pressure and vibration in time sequence, and combining the predicted values of each time step into a prediction parameter vector in a fixed order; S72, in each prediction parameter vector, performing difference calculation on each predicted value and the upper and lower limits of the corresponding sensor safe operation range to obtain the deviation of each predicted value from the safe range boundary; S73, in each prediction parameter vector, combining the deviations according to a fixed weight coefficient to generate a risk score corresponding to the time step, the risk score being a quantitative result of the deviation of each predicted value from the safe operation range; S74, combining the risk scores in time step order into a risk score sequence, and performing numerical comparison on each score in the risk score sequence and a preset threshold; S75, when the numerical comparison result meets a preset trigger condition, marking the time step meeting the trigger condition as an early warning time step; S76, outputting the early warning time steps in time sequence as the early warning result of the limited space.