A traffic state probability prediction method for multi-source spatio-temporal data fusion
By fusing multi-source spatiotemporal data and using a self-attention model, the problem of insufficient accuracy of existing traffic state prediction methods in irregular scenarios is solved, achieving high-precision and uncertainty characterization of traffic states.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG SUPCON INFORMATION TECH CO LTD
- Filing Date
- 2026-06-02
- Publication Date
- 2026-07-07
AI Technical Summary
Existing traffic condition prediction methods mainly rely on single spatiotemporal series data, which leads to a significant decrease in prediction accuracy in irregular scenarios such as sudden accidents and temporary traffic control.
A multi-source spatiotemporal data fusion method is adopted. By performing instance-level normalization and time window segmentation on traffic spatiotemporal sequence data, numerical tokens and semantic tokens are generated and fused into a one-dimensional spatiotemporal token sequence. This sequence is then input into a traffic spatiotemporal prediction model consisting of an attention layer, a decoder layer, and a hybrid distribution prediction head, and outputs a traffic state probability distribution.
It improves the accuracy and stability of traffic condition prediction, especially in the case of emergencies and complex traffic scenarios, and can effectively characterize the uncertainty of traffic conditions.
Smart Images

Figure CN122347871A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent transportation technology, and in particular to a method for predicting traffic state probabilistics based on multi-source spatiotemporal data fusion. Background Technology
[0002] In numerous fields such as modern urban traffic management, smart mobility services, and traffic infrastructure operation and maintenance, traffic condition prediction has become a crucial technical means to support refined scheduling and intelligent decision-making. With the development of sensing technology, the types of data available in traffic systems are becoming increasingly diverse. This includes not only spatiotemporal sequence data such as traffic flow, speed, and occupancy collected from roadside detectors, cameras, and floating cars, but also traffic event data with semantic information, such as traffic accidents, road construction, temporary traffic control, and weather changes. These multi-source heterogeneous data collectively reflect the dynamic evolution of the traffic system, providing a more comprehensive information foundation for traffic condition prediction. For example, patent application CN 121352153A (classification G06Q) provides an intelligent traffic flow prediction method based on multi-source data fusion; patent application CN120124794A (classification G06Q) provides a train delay prediction method based on multiple time scales; and patent application CN116596151A (classification G06Q) provides a traffic flow prediction method and computing device based on spatiotemporal graph attention.
[0003] However, most existing traffic condition prediction methods still primarily analyze single spatiotemporal series data, typically assuming that traffic data is continuous and exhibits a stable trend over time, and predicting future conditions by modeling historical sequences. However, this approach relies solely on numerical series data, leading to a significant decrease in prediction accuracy in irregular scenarios such as sudden accidents and temporary traffic control. Summary of the Invention
[0004] (a) Technical problems to be solved
[0005] In view of the above-mentioned shortcomings and deficiencies of the prior art, this application provides a traffic state probabilistic prediction method for multi-source spatiotemporal data fusion, which solves the technical problem of low traffic state prediction accuracy caused by relying only on a single numerical spatiotemporal sequence data for modeling in the prior art.
[0006] (II) Technical Solution
[0007] To achieve the above objectives, the main technical solutions adopted in this application include:
[0008] This application provides a method for probabilistic prediction of traffic state based on multi-source spatiotemporal data fusion, comprising: acquiring traffic spatiotemporal sequence data and its corresponding traffic event data; wherein, the traffic spatiotemporal sequence data includes traffic operation observation data collected by multiple spatial nodes at multiple time steps; the traffic event data includes traffic event records corresponding to each spatial node at different time points; after performing instance-level normalization on the traffic spatiotemporal sequence data, segmenting it according to a preset time window, extracting features from each segment to generate numerical tokens, and text-encoding each traffic event record in the traffic event data to generate semantic tokens, further fusing and concatenating the numerical tokens and semantic tokens to obtain... A one-dimensional spatiotemporal token sequence is generated; the one-dimensional spatiotemporal token sequence is input into a trained traffic spatiotemporal prediction model, and the predicted traffic state probability distribution of each spatial node at each future time step is output; wherein, the traffic spatiotemporal prediction model includes a self-attention layer, a decoder layer, and a hybrid distribution prediction head; the self-attention layer is used to generate a spatiotemporal fusion feature representation based on the one-dimensional spatiotemporal token sequence; the decoder layer is used to perform autoregressive multi-token prediction based on the spatiotemporal fusion feature representation to obtain a hidden representation sequence for multiple future time steps; the hybrid distribution prediction head is used to output the predicted traffic state probability distribution of each spatial node at each future time step based on the hidden representation sequence for multiple future time steps.
[0009] Optionally, in some embodiments of this application, the traffic spatiotemporal sequence data is subjected to instance-level normalization processing, including: dividing the traffic spatiotemporal sequence data according to the dimension of spatial nodes, so that each spatial node corresponds to an independent historical observation sequence; wherein, the historical observation sequence is the time series of traffic operation observation data collected at each historical time step of the spatial node; for each spatial node, the mean and variance are calculated based on its corresponding historical observation sequence; and the observation data of the corresponding spatial node are standardized based on the mean and variance to obtain normalized spatiotemporal numerical data.
[0010] Optionally, in some embodiments of this application, the process of generating a numerical token includes: dividing a continuous time series into multiple time segments based on normalized spatiotemporal numerical data according to a preset time window; extracting features from each time segment to obtain a feature representation that characterizes the local temporal change characteristics of the time segment; mapping the feature representation into a high-dimensional representation vector through a vector mapping function to generate a numerical token that corresponds one-to-one with each time segment, so that the numerical token has the information expression ability to characterize local spatiotemporal semantics.
[0011] Optionally, in some embodiments of this application, the process of generating semantic tokens includes: inputting the acquired traffic event data into a pre-trained text encoding model for semantic encoding, so as to convert each traffic event record into a corresponding semantic vector, and using each semantic vector as a text semantic token; wherein, the text encoding model is a semantic representation model based on deep learning, used to extract semantic feature information from traffic event records.
[0012] Optionally, in some embodiments of this application, the process of obtaining a one-dimensional spatiotemporal token sequence includes: associating text semantic tokens whose occurrence times are within the same preset time window with numerical tokens within the corresponding time window to complete time alignment; performing feature fusion on the time-aligned numerical tokens and text semantic tokens to generate fused tokens through vector concatenation; grouping the fused tokens corresponding to each spatial node according to a preset spatial node order; and arranging the corresponding fused tokens in chronological order within each spatial node.
[0013] The fusion tokens within each spatial node are concatenated sequentially according to the sorting order of the spatial nodes to obtain the one-dimensional spatiotemporal token sequence.
[0014] Optionally, in some embodiments of this application, the self-attention layer generates a spatiotemporal fusion feature representation based on the one-dimensional spatiotemporal token sequence, including: inputting the one-dimensional spatiotemporal token sequence into the self-attention layer and performing a linear transformation through a trainable linear projection matrix to obtain a query vector, a key vector, and a value vector; wherein, the trainable linear projection matrix includes: a query matrix, a key matrix, and a value matrix; wherein, the one-dimensional spatiotemporal token sequence is composed of fusion tokens corresponding to different spatial nodes at different time positions, the time index is used to represent the time to which the fusion token belongs, and the spatial node index is used to represent the spatial node to which the fusion token belongs; performing rotational position encoding processing on the query vector and key vector based on the time index to inject time position information into the query vector and key vector, obtaining query vector and key vector with time position information; calculating an attention score based on the inner product result of the query vector and key vector with time position information, and in conjunction with a learnable spatial topology bias parameter matrix B pre-set in the self-attention layer to characterize the association relationship between different spatial nodes, the formula for calculating the attention score is: ;in, This represents a fusion token with time index i and spatial node index m. This represents a fused token with time index j and spatial node index n. The rotation matrix is obtained by multiplying the fusion token with time index i and the fusion token with time index j. A query vector containing time and location information; A key vector containing time and location information; The parameters corresponding to spatial node indices m and n in the spatial topology bias parameter B are: The superscript T represents the transpose operator; the attention score is subjected to Softmax normalization to obtain the attention weights; the Value vector is weighted and summed based on the attention weights to obtain the spatiotemporal fusion feature representation.
[0015] Optionally, in some embodiments of this application, the spatial topology bias parameter matrix B is constructed as follows: an adjacency matrix A is constructed based on a preset set of spatial nodes, wherein the rows and columns of the adjacency matrix A are arranged in the order of the spatial nodes' serial numbers, and each row and each column of matrix A corresponds to a spatial node; for any element A(n, m) in the adjacency matrix A, when the nth spatial node and the mth spatial node have a direct connection relationship in the actual spatial topology, the value of element A(n, m) is set to 1; when the nth spatial node and the mth spatial node do not have a direct connection relationship, the value of element A(n, m) is set to 0; based on this, each element in the adjacency matrix A is multiplied by a weight w to obtain the spatial topology bias parameter matrix B.
[0016] Optionally, in some embodiments of this application, the decoder layer is a Transformer model containing only a decoder structure. The decoder layer performs autoregressive multi-token prediction based on the spatiotemporal fusion feature representation, including: inputting the spatiotemporal fusion feature representation into the decoder layer and generating a corresponding hidden state sequence through layer-by-layer calculation by the decoder layer; during the layer-by-layer calculation process of the decoder layer, a causal multi-head self-attention mechanism is adopted, and a preset causal mask is introduced to constrain the attention calculation process. After completing the layer-by-layer calculation through the causal multi-head self-attention mechanism, the target hidden state representation corresponding to the current time is obtained; based on the target hidden state representation, the target hidden state representation is mapped in parallel through multiple prediction mapping structures set at the output of the decoder layer to generate prediction hidden representations corresponding to different future time steps; the prediction hidden representations corresponding to each future time step are combined in chronological order to obtain a prediction hidden representation sequence corresponding to multiple future time steps; wherein, the decoder layer internally sets an RMSnorm normalization layer for normalizing intermediate hidden states, and the feedforward network of the decoder layer adopts the SwiGLU activation function.
[0017] Optionally, in some embodiments of this application, the hybrid distribution prediction head outputs the traffic state probability distribution prediction results of each spatial node at each future time step based on the future multi-time step hidden representation sequence, including: inputting the future multi-time step hidden representation sequence into the hybrid distribution prediction head, the future multi-time step hidden representation sequence corresponding to the spatiotemporal feature representation of each spatial node at each future time step; performing parameterized mapping on the hidden representation corresponding to each spatial node and each future time step through the hybrid distribution prediction head to generate a hybrid weight parameter and a distribution parameter set; wherein, the hybrid weight parameter is used to characterize the contribution ratio of each basic probability distribution in the final hybrid probability model, and the distribution parameter set is used to characterize the shape feature parameters of each basic probability distribution, the basic probability distribution including zero-inflated negative binomial distribution, Student's distribution, and log-normal distribution; weighting and combining each basic probability distribution based on the hybrid weight parameter to construct a traffic state hybrid probability distribution model corresponding to each spatial node at each future time step; and outputting the traffic state probability distribution prediction results of each spatial node at each future time step based on the hybrid probability distribution model.
[0018] Optionally, in some embodiments of this application, the trained traffic spatiotemporal prediction model is a model that has been pre-trained and converged based on a negative log-likelihood loss function with a mixture probability distribution; the negative log-likelihood loss function is: Where y represents the actual traffic condition observation value, This represents the mixture weight parameter corresponding to the k-th basic probability distribution. Let represent the probability density function of the k-th basic probability distribution; where k takes the values 1, 2, and 3, corresponding to the zero-inflated negative binomial distribution, the Student's distribution, and the log-normal distribution, respectively; when the negative log-likelihood loss function converges, the trained traffic spatiotemporal prediction model is obtained.
[0019] (III) Beneficial Effects
[0020] This application provides a traffic state probability prediction method for multi-source spatiotemporal data fusion. By performing instance-level normalization on traffic spatiotemporal sequence data and segmenting it according to a preset time window, traffic operation observation data from different spatial nodes and time steps are expressed at a unified scale, thereby reducing the feature shift caused by differences in data units. Furthermore, by extracting numerical tokens from the segmented spatiotemporal data and encoding traffic event data into semantic tokens, and then fusing and concatenating the numerical and semantic tokens to construct a one-dimensional spatiotemporal token sequence, a unified expression of traffic numerical information and event semantic information is achieved. This enables collaborative modeling of multi-source heterogeneous data within the same sequence space, thereby improving the completeness of feature representation.
[0021] Furthermore, by inputting the one-dimensional spatiotemporal token sequence into a traffic spatiotemporal prediction model containing a self-attention layer, the self-attention mechanism is used to model the dependencies between global tokens. This allows the model to simultaneously capture the relationships between spatial nodes and the dynamic evolution relationships across time steps, thereby enhancing the model's ability to model complex spatiotemporal dependency structures.
[0022] Furthermore, by performing autoregressive multi-token prediction on the spatiotemporal fusion feature representation through the decoder layer, a hidden representation sequence for multiple future time steps is obtained. This enables the model to continuously extrapolate future traffic states, improving the temporal consistency and stability of the prediction results. Further, by using a hybrid distribution prediction head to model the probability distribution of the hidden representation sequence, the predicted traffic state probability distribution for each spatial node at each future time step is output. This transforms the prediction result from a single deterministic output into a probabilistic expression, effectively characterizing the uncertainty of traffic states. Therefore, this application, through the aforementioned multi-source data fusion mechanism and prediction method based on self-attention and probability distribution modeling, can significantly improve the accuracy of traffic state prediction, especially demonstrating superior prediction performance in sudden events and complex traffic scenarios. Attached Figure Description
[0023] Figure 1 This is a flowchart illustrating a traffic state probability prediction method based on multi-source spatiotemporal data fusion according to an embodiment of this application.
[0024] Figure 2 This is a flowchart illustrating the process of obtaining a one-dimensional spatiotemporal token sequence according to an embodiment of this application. Detailed Implementation
[0025] To better explain and facilitate understanding of this application, the following detailed description of the application is provided in conjunction with the accompanying drawings and specific embodiments.
[0026] Among related technologies, traffic condition prediction methods can be mainly categorized as follows:
[0027] The first category is prediction methods based on single spatiotemporal series modeling. These methods typically utilize continuous observation data such as traffic flow, speed, and occupancy to construct time series models or deep learning models, and predict future traffic conditions by fitting historical time series data. While these methods can characterize the periodic changes in traffic operations, they rely primarily on numerical spatiotemporal series data for modeling, neglecting the impact of traffic events such as traffic accidents, road construction, and temporary traffic control. Therefore, in the event of emergencies or irregular traffic scenarios, they struggle to reflect the true changes in traffic conditions in a timely manner, resulting in poor robustness of the prediction results.
[0028] The second category is spatiotemporal prediction methods based on deep sequence models. These methods typically employ recurrent neural networks, graph neural networks, or Transformer structures to jointly model traffic data from multiple spatial nodes, thereby improving the ability to capture spatiotemporal dependencies. While these methods enhance the modeling ability of spatial correlations and temporal evolution to some extent, they generally remain primarily deterministic predictions, outputting a single traffic state prediction result. They lack the ability to model traffic state uncertainties and are prone to prediction bias when faced with significant traffic fluctuations or event-driven changes.
[0029] To address this, this application provides a traffic state probability prediction method for multi-source spatiotemporal data fusion. By performing instance-level normalization on traffic spatiotemporal sequence data and segmenting it according to a preset time window, traffic observation data from different spatial nodes and time steps are expressed at a unified scale, reducing the impact of biases between data of different dimensions. Simultaneously, the segmented numerical features are extracted into numerical tokens, and traffic event data is text-encoded to generate semantic tokens. Furthermore, the numerical tokens and semantic tokens are fused and concatenated to construct a one-dimensional spatiotemporal token sequence, thereby achieving unified representation and collaborative modeling of traffic operation data and event semantic information. Furthermore, by inputting the one-dimensional spatiotemporal token sequence into a traffic spatiotemporal prediction model comprising a self-attention layer, a decoder layer, and a hybrid distribution prediction head, the self-attention layer models the dependencies between global tokens, simultaneously capturing spatial relationships between multiple spatial nodes and dynamic evolutionary relationships across time steps. The decoder layer performs autoregressive multi-token prediction to obtain hidden representation sequences for future time steps, thereby achieving continuous modeling of future traffic states. The hybrid distribution prediction head models the probability distribution of the hidden representation sequences, outputting the probability distribution prediction results of traffic states for each spatial node at each future time step. Therefore, this application, through a unified tokenization fusion mechanism for multi-source traffic data and a probability prediction structure based on self-attention and hybrid distribution, effectively enhances the expressive and modeling capabilities for complex traffic scenarios. This not only improves the accuracy and stability of traffic state prediction but also strengthens the ability to characterize traffic state uncertainties, thereby enhancing the reliability and practicality of the overall prediction results.
[0030] To better understand the above technical solutions, exemplary embodiments of this application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of this application are shown in the drawings, it should be understood that this application can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this application can be understood more clearly and thoroughly, and that the scope of this application can be fully conveyed to those skilled in the art.
[0031] Figure 1 This is a flowchart illustrating a traffic state probability prediction method based on multi-source spatiotemporal data fusion according to an embodiment of this application. Figure 1 As shown, this traffic state probabilistic prediction method for multi-source spatiotemporal data fusion includes:
[0032] Acquire traffic spatiotemporal sequence data and its corresponding traffic event data; wherein, the traffic spatiotemporal sequence data includes traffic operation observation data collected by multiple spatial nodes at multiple time steps; the traffic event data includes traffic event records corresponding to each spatial node at different time points; the traffic operation observation data includes at least one of traffic flow, speed, or passenger flow data; the spatial nodes include at least one of road intersections, road segment detection points, rail transit stations, or passenger flow collection terminals;
[0033] After performing instance-level normalization on the traffic spatiotemporal sequence data, the data is segmented according to a preset time window, and features are extracted from each segment to generate numerical tokens. Additionally, text encoding is performed on each traffic event record in the traffic event data to generate semantic tokens. The numerical tokens and semantic tokens are then fused and spliced together to obtain a one-dimensional spatiotemporal token sequence.
[0034] The one-dimensional spatiotemporal token sequence is input into the trained traffic spatiotemporal prediction model, and the predicted result of the traffic state probability distribution of each spatial node at each future time step is output.
[0035] The traffic spatiotemporal prediction model includes a self-attention layer, a decoder layer, and a hybrid distribution prediction head. The self-attention layer is used to generate a spatiotemporal fusion feature representation based on the one-dimensional spatiotemporal token sequence. The decoder layer is used to perform autoregressive multi-token prediction based on the spatiotemporal fusion feature representation to obtain a hidden representation sequence for future multiple time steps. The hybrid distribution prediction head is used to output the traffic state probability distribution prediction results of each spatial node at each future time step based on the hidden representation sequence for future multiple time steps.
[0036] Specifically, in practical applications, the traffic state probability prediction method for multi-source spatiotemporal data fusion provided in this application can be applied to prediction scenarios of coordinated operation of urban road traffic and rail transit. For example, in the area connecting urban arterial roads and subway stations, multiple road intersections, road segment detection points, and subway stations are used as spatial nodes. Traffic flow, vehicle speed, and station passenger flow observation data are continuously collected through deployed detection equipment, and event records related to traffic operation are acquired simultaneously, such as traffic accidents on a certain road segment, traffic light adjustments, road construction, temporary subway flow restrictions, or abnormal passenger flow caused by weather. This constructs a traffic spatiotemporal sequence data containing multiple spatial nodes and multiple time steps, as well as corresponding traffic event data.
[0037] First, the traffic flow, speed, and passenger flow observation data collected from each spatial node are normalized at the instance level. For example, a unified scale mapping is applied to the flow differences between different intersections caused by different road scales, making the data from different nodes comparable within the same numerical range. Then, the continuous time-series data is segmented according to a preset time window (e.g., 5 minutes or 15 minutes). The traffic operation status within each time window is used as a basic analysis unit, and statistical and temporal features are extracted from each segment to generate numerical tokens. Simultaneously, traffic event data is text-encoded; for example, "a rear-end collision occurred on a certain road segment causing congestion" or "temporary flow control at a subway station" is converted into a semantic vector representation, forming semantic tokens. Further, the numerical tokens and semantic tokens are fused and concatenated to construct a one-dimensional spatiotemporal token sequence, ensuring that the traffic operation status information within each time window is aligned with the event semantic information at the corresponding time point. For example, if a traffic accident occurs on a certain road segment within a specific time window, the corresponding numerical token for that window not only includes information about decreased traffic flow and speed, but also incorporates the semantic token of "accident," thus fully expressing the event-driven process of traffic state changes. Subsequently, this one-dimensional spatiotemporal token sequence is input into a trained traffic spatiotemporal prediction model. A self-attention layer models the relationships between global tokens, such as identifying the propagation impact of "upstream road segment congestion" on "downstream intersection traffic flow changes," and the continuous impact of "accident events" on multiple time windows, thereby generating a unified spatiotemporal fusion feature representation. Based on this, an autoregressive multi-token prediction is performed through a decoder layer to progressively deduce the traffic state changes over multiple future time steps, such as predicting the evolution trend of each road segment's operating state within the next 15, 30, and 45 minutes, and generating corresponding hidden representation sequences.
[0038] Finally, a probability distribution model is performed on the future hidden representation using a hybrid distribution prediction head, and the probability distribution prediction results of traffic status for each spatial node at each future time step are output. For example, the probability of "congestion" at a certain intersection in the next 15 minutes is 0.7, the probability of "smooth traffic" is 0.2, and the probability of "severe congestion" is 0.1, thus forming a prediction output that is more consistent with the uncertainty of real traffic.
[0039] This application achieves a unified representation of data from different spatial nodes and time scales through instance-level normalization and time window segmentation, improving the comparability and stability of multi-source spatiotemporal data. Furthermore, by integrating numerical and semantic tokens, it realizes unified modeling of traffic operation data and traffic event semantic information, effectively enhancing the model's ability to perceive sudden events and complex traffic scenarios. Simultaneously, the spatiotemporal modeling approach based on self-attention and decoder structures fully captures dynamic dependencies across spatial nodes and time steps, improving the spatiotemporal consistency of the prediction process. Moreover, by outputting probability distribution results through a hybrid distribution prediction head, the prediction results reflect the uncertainty of traffic conditions, improving prediction accuracy compared to traditional deterministic prediction methods.
[0040] Optionally, in some embodiments of this application, instance-level normalization processing is performed on the traffic spatiotemporal sequence data, including:
[0041] The traffic spatiotemporal sequence data is divided according to the dimension of spatial nodes, so that each spatial node corresponds to an independent historical observation sequence; wherein, the historical observation sequence is the time series of traffic operation observation data collected at each historical time step of the spatial node.
[0042] For each spatial node, the mean and variance are calculated based on its corresponding historical observation sequence.
[0043] Based on the mean and variance, the observation data of the corresponding spatial nodes are standardized to obtain normalized spatiotemporal numerical data.
[0044] In this embodiment, the process of instance-level normalization of traffic spatiotemporal sequence data is specifically described using multi-detection point traffic data from urban roads. For example, in an urban arterial road network, sensors are deployed at multiple road intersections and road segment detection points to collect operational observation data such as traffic flow, vehicle speed, or occupancy rate at each spatial node over continuous time steps. Because different spatial nodes are located on roads with varying road grades and traffic capacities—for example, the flow rates at arterial road intersections and side road intersections differ significantly—directly applying a unified model to the raw data would result in large differences in data distribution between different nodes, thus affecting the model's learning performance.
[0045] In the specific processing, the traffic spatiotemporal sequence data is first divided according to the dimension of spatial nodes, so that each spatial node corresponds to an independent historical observation sequence. For example, the traffic flow data collected every 5 minutes over the past 24 hours for a certain intersection constitutes the historical observation sequence for that intersection, while another detection point on another road segment corresponds to another independent sequence, thus achieving decoupling processing of data from different spatial nodes. The purpose of this step is to ensure that the historical operating pattern of each node can be independently characterized, avoiding the distribution chaos caused by mixing data from different nodes.
[0046] Furthermore, for each spatial node, the mean and variance are calculated based on its corresponding historical observation sequence. For example, for the traffic flow sequence of a main intersection, the average traffic flow value and fluctuation degree within the historical time window are calculated; for a side intersection, the corresponding mean and variance are calculated respectively, thereby obtaining the statistical distribution characteristics of each spatial node.
[0047] Subsequently, the observation data of the corresponding spatial nodes are standardized based on the mean and variance, for example, by using a zero-mean, unit-variance transformation to convert the original observation data of each node into normalized data at a uniform scale. This process maps data that originally differed significantly in magnitude due to differences in road grade, traffic capacity, or passenger flow into a relatively consistent numerical space, thereby reducing scale bias between different spatial nodes.
[0048] Through the instance-level normalization process described above, the embodiments of this application can independently model the individual differences of different spatial nodes, effectively avoiding the weakening of local feature distribution by global normalization, and making the dynamic change patterns of each node more accurately preserved. On the other hand, through the standardization transformation based on mean and variance, traffic observation data of multiple spatial nodes can be expressed under a unified numerical scale, thereby improving the comparability and fusion effect between features of different nodes in the subsequent spatiotemporal modeling process.
[0049] Optionally, in some embodiments of this application, the process of generating a numerical token includes:
[0050] Based on the normalized spatiotemporal numerical data, the continuous time series is divided according to a preset time window to obtain multiple time segments;
[0051] Feature extraction is performed on each time segment to obtain a feature representation that characterizes the local temporal variation features of that time segment;
[0052] The feature representation is mapped to a high-dimensional representation vector by a vector mapping function, generating a numerical token that corresponds one-to-one with each time segment, so that the numerical token has the information expression ability to represent local spatiotemporal semantics.
[0053] Next, the process of generating numerical tokens will be explained in detail in the context of urban road network traffic flow prediction. For example, taking multiple intersections on a main road in a city as monitoring objects, after completing instance-level normalization, standardized traffic flow or vehicle speed data sequences for each spatial node at continuous time steps are obtained. In order to characterize the local variation patterns of traffic conditions, this continuous time series is divided according to a preset time window, such as 5 minutes or 10 minutes, dividing the continuous 24-hour data into several time segments, each time segment corresponding to the traffic operation status within a local time interval.
[0054] In the specific processing, for each time segment, such as the traffic flow sequence at a certain intersection within the 08:00–08:10 time window, feature extraction is first performed on the multi-time step data within that segment. This involves extracting statistical and temporal features such as average flow, maximum flow, slope of change, and short-term fluctuation amplitude, thereby forming a feature representation that can characterize the dynamic changes within that time segment. In this way, the original high-frequency sampled continuous data can be compressed into a structured feature vector with semantic expressive capabilities, enabling it to reflect the overall evolution trend of traffic conditions within that time window.
[0055] Furthermore, the feature representation is subjected to high-dimensional mapping processing through a vector mapping function, such as linear mapping or a multilayer perceptron (MLP) structure, to map the low-dimensional statistical features to a high-dimensional representation space, thereby generating numerical tokens that correspond one-to-one with each time segment. These numerical tokens not only retain the numerical variation information of the original traffic observation data but also enhance their expressive power in a high-dimensional space, enabling them to be better used for subsequent sequence modeling and cross-modal fusion.
[0056] For example, if traffic flow is detected to be continuously increasing and fluctuating significantly within a certain time segment, the corresponding numerical token will exhibit the characteristic of "congestion growth trend" in high-dimensional space; while during the low-flow and stable phase at night, the corresponding numerical token will show a more stable representation.
[0057] Through the above-described numerical token generation method, this embodiment of the application transforms continuous spatiotemporal sequences into discrete representation units with local semantic structures by segmenting based on time windows, thereby enhancing the model's ability to characterize local traffic dynamics. On the other hand, by performing feature extraction and high-dimensional mapping on time segments, the numerical tokens not only contain the original observed numerical information but also have the ability to express local spatiotemporal change patterns, thereby improving the modeling effect of subsequent self-attention models on complex traffic temporal structures.
[0058] Optionally, in some embodiments of this application, the process of generating a semantic token includes:
[0059] The acquired traffic incident data is input into a pre-trained text encoding model for semantic encoding, so as to convert each traffic incident record into a corresponding semantic vector, and each semantic vector is used as a text semantic token; wherein, the text encoding model is a semantic representation model based on deep learning, which is used to extract semantic feature information from traffic incident records.
[0060] Specifically, in this embodiment, the process of generating semantic tokens is explained in conjunction with the urban traffic event information processing scenario. For example, during urban traffic operation, the system continuously receives traffic event data from traffic management platforms or roadside sensing devices. This traffic event data may include text-based records of traffic events such as "a traffic accident occurred on a certain road section causing congestion," "a traffic light at a certain intersection was temporarily adjusted," "a section of an elevated bridge was closed due to construction," and "a subway station implemented flow control measures due to a sudden surge in passenger flow." This event information usually has strong semantic expression features, but it is difficult to directly use it for numerical modeling.
[0061] In the specific processing, the aforementioned traffic incident records are input into a pre-trained text encoding model for semantic encoding. For example, a deep learning-based semantic representation model is used to vectorize the text content, converting each traffic incident record into a corresponding semantic vector. For instance, "A traffic accident occurred on a certain road segment, causing congestion" can be represented as a high-dimensional semantic vector after encoding, reflecting semantic features such as "accident," "congestion," and "sudden impact." "Traffic light timing adjustment" will be mapped to another semantic vector to express semantic information related to "changes in control strategies." In this way, the originally unstructured text event information is converted into a computable continuous vector representation.
[0062] Furthermore, the semantic vectors are used as text semantic tokens to form a semantic token set that corresponds one-to-one with each traffic event record, enabling different types of traffic events to be expressed in a unified vector space. For example, "accident events" and "construction events" occurring within the same time window, although manifested differently, correspond to different but comparable vector representations in the semantic token space, thereby reflecting the semantic differences and potential relationships between events.
[0063] By using the aforementioned semantic token generation method, a pre-trained text encoding model is introduced to semantically encode traffic event data, transforming the originally unstructured traffic event records into structured vector representations. This enables the computational expression of event information and improves the model's ability to utilize traffic event information. On the other hand, semantic tokens can effectively extract key semantic features from traffic events, making different types of events comparable in a unified semantic space, thereby enhancing the model's ability to model the impact mechanisms of emergencies.
[0064] See Figure 2 In some embodiments of this application, the process of obtaining a one-dimensional spatiotemporal token sequence includes:
[0065] Associate text semantic tokens that occur within the same preset time window with numerical tokens within the corresponding time window to achieve time alignment;
[0066] The numerical tokens aligned with completion time and the textual semantic tokens are fused to generate a fused token by vector concatenation.
[0067] The fusion tokens corresponding to each spatial node are grouped according to the preset spatial node order.
[0068] Within each spatial node, the corresponding fusion tokens are arranged in chronological order.
[0069] The fusion tokens within each spatial node are concatenated sequentially according to the sorting order of the spatial nodes to obtain the one-dimensional spatiotemporal token sequence.
[0070] In detail, in the embodiments of this application, the process of obtaining a one-dimensional spatiotemporal token sequence is specifically explained in conjunction with the scenario of fusion of traffic events and operation data at multiple nodes in an urban road network. For example, in a city's main road network, multiple road intersections and road segment detection points are used as spatial nodes, and continuous traffic operation observation data and traffic event data are processed synchronously with a preset time window of 5 minutes. Within a certain time window, such as 08:00–08:05, a certain intersection collects numerical tokens such as a decrease in traffic flow and a decrease in speed, and at the same time, a semantic token of "a minor rear-end collision causing local congestion" is recorded within this time window; within another time window, there may be event semantic tokens such as "traffic light optimization and adjustment" and corresponding numerical tokens.
[0071] In the specific processing, the text semantic tokens that occur within the same preset time window are first associated with the corresponding numerical tokens within the same time window, thereby achieving strict alignment in the time dimension. For example, the numerical token of a certain intersection within the 08:00–08:05 time window is matched with the semantic token of a traffic accident that occurred within that time window, so that the traffic operation status and event semantic information within the same time period form a one-to-one correspondence, thus avoiding information mismatch problems caused by cross-time interference.
[0072] Furthermore, the time-aligned numerical tokens and textual semantic tokens undergo feature fusion processing, generating a fused token through vector concatenation. For example, the numerical token vector representing "decreased traffic flow and reduced speed" is concatenated with the semantic token vector representing "traffic accident" to form a fused representation that simultaneously includes operational status information and event semantic information, making the expression of traffic status within a single time window more complete.
[0073] Subsequently, the fusion tokens corresponding to each spatial node are grouped according to the preset spatial node order. For example, fusion tokens belonging to different intersections or different road segments are classified separately, so that each spatial node corresponds to a set of fusion tokens, thereby ensuring the structured organization in the spatial dimension.
[0074] Within each spatial node, the corresponding fusion tokens are further arranged in chronological order. For example, the fusion tokens corresponding to each time window between 08:00 and 09:00 at a certain intersection are sorted in chronological order to form a continuous expression sequence of the spatial node in the time dimension.
[0075] Finally, following the sorting order of the spatial nodes, the fused tokens within each spatial node are concatenated end-to-end to obtain a one-dimensional spatiotemporal token sequence. For example, the fused token sequence arranged in the time dimension at intersection A is taken as the starting segment, and then the fused token sequences corresponding to nodes such as intersection B and road segment C are concatenated to form a linear sequence structure along the "spatial node expansion + temporal sequence extension".
[0076] Through the above processing methods, this application uses time alignment and spatial sorting mechanisms to uniformly map multi-source heterogeneous data that were originally scattered across different time windows and spatial nodes into a single linear sequence structure, realizing the structural transformation from two-dimensional (space × time) to one-dimensional sequence, making the data expression more regular and easier for sequence models to process. On the other hand, by preserving the temporal order and spatial node order in the one-dimensional sequence, the model can simultaneously learn temporal evolution relationships and spatial propagation relationships in the unified token sequence, thereby enhancing the modeling ability for complex traffic spatiotemporal dependency structures. At the same time, this one-dimensional spatiotemporal token sequence unifies and integrates numerical tokens and semantic tokens, enabling traffic operation information and event semantic information to be distributed collaboratively in the same sequence space, effectively improving the fusion efficiency of multi-source spatiotemporal data and the input expression ability of subsequent prediction models, thereby improving the accuracy and stability of overall traffic state prediction.
[0077] Optionally, in some embodiments of this application, the self-attention layer generates a spatiotemporal fusion feature representation based on the one-dimensional spatiotemporal token sequence, including:
[0078] The one-dimensional spatiotemporal token sequence is input into the self-attention layer and linearly transformed using a trainable linear projection matrix to obtain the query vector, key vector, and value vector; wherein the trainable linear projection matrix includes: query matrix, key matrix, and value matrix;
[0079] For example, in a traffic network composed of multiple intersections and road segment detection points, a one-dimensional spatiotemporal token sequence is obtained after preprocessing, which is "sequentially spliced together in spatial node order and unfolded in temporal order." Each token corresponds to a specific spatial node and a specific time window, such as "Intersection A - 08:00–08:05," "Intersection A - 08:05–08:10," and "Intersection B - 08:00–08:05." This one-dimensional sequence structure unifies the originally two-dimensional distributed spatial-temporal information into a linear sequence, thus facilitating input into the self-attention model for global modeling. In the specific calculation process, the one-dimensional spatiotemporal token sequence is first input into the self-attention layer, and then linearly transformed using a trainable linear projection matrix to obtain the corresponding Query vector, Key vector, and Value vector. For example, for the fused token "Intersection A in the 08:00–08:05 time window," its corresponding numerical and semantic fusion representation is mapped into Query vector, Key vector, and Value vector, enabling the token to have computable attention representation capabilities in the high-dimensional feature space. Among them, the query matrix, key matrix, and value matrix are trainable parameters that are continuously optimized during model training to enhance the expressive power of different traffic state patterns.
[0080] The one-dimensional spatiotemporal token sequence is composed of fused tokens corresponding to different spatial nodes at different time positions. The time index is used to indicate the time to which the fused token belongs, and the spatial node index is used to indicate the spatial node to which the fused token belongs.
[0081] Based on the time index, the Query vector and Key vector are rotated and encoded to inject time position information into the Query vector and Key vector, resulting in Query vector and Key vector with time position information.
[0082] Since each token in this one-dimensional spatiotemporal token sequence contains a time index and a spatial node index, the query vector and key vector are rotated and encoded based on the time index before attention calculation, injecting time and position information into the vector representation. For example, although "08:00–08:05" and "08:05–08:10" belong to the same intersection, after rotation and encoding, their corresponding vectors will show a clear temporal sequence in the representation space, enabling the model to distinguish traffic state changes at different times.
[0083] The attention score is calculated based on the inner product of the query vector and the key vector with temporal location information, and in conjunction with the learnable spatial topology bias parameter matrix B pre-set in the self-attention layer to characterize the association between different spatial nodes. The formula for calculating the attention score is as follows: ;in, This represents a fusion token with time index i and spatial node index m. This represents a fused token with time index j and spatial node index n. The rotation matrix is obtained by multiplying the fusion token with time index i and the fusion token with time index j. A query vector containing time and location information; A key vector containing time and location information; This refers to the parameters corresponding to spatial node indices m and n in the spatial topology bias parameter B; the superscript T indicates the transpose operator.
[0084] It should be noted that when calculating the attention score, the result is based on the inner product of the Query vector and the Key vector with temporal and location information, and a spatial topology bias parameter matrix B is introduced to characterize the relationship between different spatial nodes. For example, when calculating the attention relationship between "intersection A" and "intersection B", not only is their feature similarity considered, but the topology bias parameter also reflects their spatial adjacency relationship in the road network structure. This makes the influence weight between adjacent intersections higher, while the influence weight of distant nodes is relatively reduced, thus better reflecting the actual traffic propagation pattern.
[0085] The attention scores are then subjected to Softmax normalization to obtain the attention weights.
[0086] The spatiotemporal fusion feature representation is obtained by weighting and summing the Value vector based on the attention weights.
[0087] By employing the self-attention computation method based on a one-dimensional spatiotemporal token sequence, this application expands a two-dimensional space-time structure into a one-dimensional sequence, enabling the self-attention mechanism to simultaneously model dependencies across spatial nodes and across time windows within a unified sequence space. This significantly enhances the expressive power for complex traffic spatiotemporal propagation patterns. Furthermore, by introducing temporal rotation position encoding, the model can explicitly perceive temporal order relationships, avoiding the loss of temporal information after one-dimensional expansion, thereby improving the accuracy of depicting traffic evolution. Simultaneously, by introducing the spatial topology bias parameter matrix B, the attention computation results can integrate prior information about the road network structure, making spatial correlation modeling more consistent with the propagation characteristics of real traffic networks. Moreover, this method integrates numerical tokens and semantic tokens into the self-attention computation framework, allowing traffic operation status and event information to interact and merge within the same attention mechanism, further improving the accuracy of traffic state modeling.
[0088] Optionally, in some embodiments of this application, the spatial topology bias parameter matrix B is constructed as follows:
[0089] An adjacency matrix A is constructed based on a preset set of spatial nodes, wherein the rows and columns of the adjacency matrix A are arranged in the order of the spatial node numbers, and each row and each column of matrix A corresponds to a spatial node.
[0090] For any element A(n, m) in the adjacency matrix A, when the nth spatial node and the mth spatial node have a direct connection in the actual spatial topology, the value of element A(n, m) is set to 1; when the nth spatial node and the mth spatial node do not have a direct connection, the value of element A(n, m) is set to 0.
[0091] Based on this, each element in the adjacency matrix A is multiplied by the weight w to obtain the spatial topology bias parameter matrix B.
[0092] In this embodiment, the construction method of the spatial topology bias parameter matrix B is specifically described in conjunction with the urban road traffic network structure. For example, in a traffic network consisting of multiple road intersections and road segment detection points, each spatial node is uniformly numbered according to a preset sequence number. For example, node 1 is the main road intersection A, node 2 is the adjacent intersection B, node 3 is the branch road intersection C, node 4 is the elevated road entrance D, etc., thus forming a preset set of spatial nodes. Based on this, an adjacency matrix A can be constructed based on the actual road connection relationship to represent the topological connection structure between each spatial node.
[0093] In the specific construction process, the rows and columns of the adjacency matrix A are arranged according to the spatial node index. Each element A(n, m) in the matrix indicates whether there is a direct spatial connection between the nth and mth spatial nodes. For example, when intersection A and intersection B are connected by a directly connected road, the corresponding positions A(1, 2) and A(2, 1) in the adjacency matrix are assigned a value of 1, indicating that they have a direct reachability relationship in the actual road topology. Conversely, when there is no direct road connection between intersection A and elevated road entrance D, the corresponding value A(1, 4) is 0, indicating that there is no direct spatial adjacency relationship between them. In this way, the spatial structure of the actual traffic network can be explicitly expressed in matrix form.
[0094] Furthermore, after obtaining the adjacency matrix A, each element is multiplied by a preset weight w to obtain the spatial topology bias parameter matrix B. For example, for a pair of nodes with a direct connection, the corresponding B(n, m) = w × 1; for a pair of nodes without a direct connection, B(n, m) = w × 0 = 0. In this way, the original binary adjacency relationship is further mapped into a topology bias parameter with weight adjustment capability, so that the spatial connection relationship not only reflects "whether they are connected" in subsequent model calculations, but also controls the intensity of spatial propagation influence through the weight parameter w.
[0095] For example, in a transportation network, the weights w can be set according to the road grade or traffic capacity, so that the connection between main roads has a higher weight, while the connection between branch roads has a relatively lower weight, so that the spatial topology bias matrix B can better reflect the actual traffic flow propagation characteristics.
[0096] By constructing the spatial topology bias parameter matrix B as described above, the connection relationships between spatial nodes are explicitly modeled based on the adjacency matrix A. This allows the spatial topology of the traffic network to be directly embedded into the model calculation process in a structured form, thereby enhancing the model's ability to express spatial dependencies. On the other hand, a weight w is introduced to adjust the adjacency relationship, enabling the spatial topology information to reflect not only whether nodes are connected but also differences in connection strength or importance, thus improving the refinement of spatial relationship modeling. Simultaneously, the spatial topology bias matrix B constrains and guides the attention score during the self-attention calculation process, allowing the model to fully integrate prior information about the real road network structure when modeling one-dimensional spatiotemporal token sequences. This effectively improves the ability to depict the spatial propagation patterns of traffic flow and enhances the accuracy and stability of prediction results.
[0097] Optionally, in some embodiments of this application, the decoder layer is a Transformer model containing only a decoder structure, and the decoder layer performs autoregressive multi-token prediction based on the spatiotemporal fusion feature representation, including:
[0098] The spatiotemporal fusion feature representation is input into the decoder layer, and the corresponding hidden state sequence is generated by calculating layer by layer through the decoder layer;
[0099] During the layer-by-layer calculation process of the decoder layer, a causal multi-head self-attention mechanism is adopted, and a preset causal mask is introduced to constrain the attention calculation process. After the layer-by-layer calculation is completed through the causal multi-head self-attention mechanism, the target hidden state representation corresponding to the current time is obtained.
[0100] For example, when predicting the k-th time step in the future, the model only allows the hidden states of the current time step and those preceding it to participate in the attention calculation, while prohibiting future information from participating in the current calculation, thus ensuring the temporal causal consistency of the prediction process. This mechanism enables the model to simulate the evolutionary process in real traffic systems where "future states can only be inferred from historical states." For instance, when predicting the "traffic state of intersection A in the next 10 minutes," the model only uses the fused features of the current and preceding time windows for reasoning, without using future time information, thereby avoiding information leakage and improving the realism and reliability of the prediction. After completing the layer-by-layer causal multi-head self-attention calculation, the target hidden state representation corresponding to the current moment is obtained, which has incorporated historical spatiotemporal dependencies and event impact information.
[0101] Based on the target hidden state representation, the target hidden state representation is mapped in parallel by multiple prediction mapping structures set at the output of the decoder layer to generate prediction hidden representations corresponding to different future time steps. For example, the same target hidden state can be mapped to prediction representations for multiple time steps such as "future 5 minutes", "future 10 minutes", and "future 15 minutes", enabling the model to achieve multi-step parallel prediction capability on the basis of a unified representation, rather than being generated step by step in sequence, thereby improving prediction efficiency.
[0102] The predicted hidden representations corresponding to each future time step are combined in chronological order to obtain a sequence of predicted hidden representations corresponding to multiple future time steps; thus, a traffic state evolution representation corresponding to multiple future time steps is obtained. For example, the prediction results of time steps "t+1", "t+2", "t+3", etc. are arranged in order so that the model can output a complete representation of the future traffic evolution trajectory.
[0103] The decoder layer includes an RMSnorm normalization layer to normalize intermediate hidden states, such as scaling hidden features at different time steps or spatial nodes. This avoids gradient instability or feature distribution shift, improving model training stability. The feedforward network of the decoder layer employs the SwiGLU activation function, enhancing the model's nonlinear expressive power.
[0104] Optionally, in some embodiments of this application, the hybrid distribution prediction head outputs the traffic state probability distribution prediction results of each spatial node at each future time step based on the future multi-time step hidden representation sequence, including: inputting the future multi-time step hidden representation sequence into the hybrid distribution prediction head, wherein the future multi-time step hidden representation sequence corresponds to the spatiotemporal feature representation of each spatial node at each future time step; and performing parameterized mapping on each spatial node and the hidden representation corresponding to each future time step through the hybrid distribution prediction head to generate a set of hybrid weight parameters and distribution parameters.
[0105] The mixed weight parameter is used to characterize the contribution ratio of each basic probability distribution in the final mixed probability model, and the distribution parameter set is used to characterize the shape feature parameters of each basic probability distribution. The basic probability distributions include the zero-inflated negative binomial distribution, the Student's distribution, and the log-normal distribution.
[0106] Based on the aforementioned mixed weight parameters, each basic probability distribution is weighted and combined to construct a mixed probability distribution model of traffic state corresponding to each spatial node at each future time step.
[0107] Based on the hybrid probability distribution model, the traffic state probability distribution prediction results for each spatial node at each future time step are output.
[0108] In this embodiment, the process of the hybrid distribution prediction head outputting the traffic state probability distribution prediction result is illustrated with an example of a specific traffic prediction scenario in a city's core business district road network. For instance, taking "Intersection A" in a city's business district as the research object, this intersection connects the main road with the entrance and exit of a commercial parking lot. During the evening peak hours (e.g., 18:00–19:00), the traffic state is affected by commuter traffic, shopping pedestrian flow, and occasional events (such as accidents or signal timing adjustments), resulting in significant uncertainty in its future traffic state.
[0109] In the specific prediction process, after processing by the pre-sequence decoder layer, a hidden representation of the future time step "intersection A at t+10 minutes" is obtained. This hidden representation incorporates historical traffic flow trends and information on possible event impacts. After inputting this hidden representation into the hybrid distribution prediction head, the vector is first parameterized to generate hybrid weight parameters and the corresponding set of distribution parameters. For example, three sets of basic distribution parameters may be output: the first set corresponds to a zero-inflated negative binomial distribution, used to characterize the sudden discrete change of "traffic status from smooth to congested"; the second set corresponds to the Student's distribution, used to characterize the heavy-tailed uncertainty of "vehicle speed or flow fluctuating significantly but still varying around the mean"; and the third set corresponds to a logarithmic normal distribution, used to characterize the "asymmetric distribution characteristics caused by the cumulative increase of traffic flow over time".
[0110] For example, in the prediction of "intersection A at t+10 minutes", the following mixed weight relationship might be learned: Under normal circumstances, the log-normal distribution has a higher weight, indicating that the traffic condition is mainly characterized by steady growth; when the system detects the risk of accident propagation in the upstream road segment, the weight of the zero-inflated negative binomial distribution increases, indicating that the probability of congestion increases significantly; while the Student's distribution is used to characterize the moderate-amplitude random fluctuations caused by changes in traffic light cycles or pedestrian flow. Subsequently, based on the above mixed weight parameters, the three basic probability distributions are weighted and combined to construct a mixed probability distribution model of "traffic condition of intersection A at t+10 minutes". For example, the final output of this model might be: smooth traffic probability 0.55, slow traffic probability 0.30, and congestion probability 0.15, thus forming a complete probability distribution prediction result, rather than a single deterministic value prediction.
[0111] This application introduces multiple basic probability distributions with different statistical properties and combines them with a hybrid weighted adaptive learning mechanism. This enables the model to finely characterize the complex traffic uncertainties of the same spatial node at different future time steps, thereby simultaneously expressing the stability, volatility, and sudden changes in traffic conditions. Compared with traditional prediction methods that only output a single value or a single category, this scheme can comprehensively reflect the uncertainty of traffic condition evolution in the form of probability distributions, improving the accuracy and reliability of prediction results in traffic congestion warning, signal optimization control, and travel decision support.
[0112] Optionally, in some embodiments of this application, the trained traffic spatiotemporal prediction model is a model that has been trained and converged beforehand based on a negative log-likelihood loss function with a mixed probability distribution.
[0113] The negative log-likelihood loss function is: Where y represents the actual traffic condition observation value, This represents the mixture weight parameter corresponding to the k-th basic probability distribution. Let represent the probability density function of the k-th basic probability distribution; where k takes the values 1, 2, and 3, corresponding to the zero-inflated negative binomial distribution, the Student's distribution, and the log-normal distribution, respectively.
[0114] When the negative log-likelihood loss function converges, a well-trained traffic spatiotemporal prediction model is obtained.
[0115] In the specific training process, for each training sample, such as the observation data y of "intersection A actually experiencing congestion at t+10 minutes", the model first outputs the probability density values of that observation under the three basic distributions based on the current parameters, and then combines them with the corresponding mixture weight parameters to obtain the overall likelihood probability of that sample under the mixture probability model. Subsequently, by taking the negative logarithm of this likelihood probability, a negative log-likelihood loss function is constructed, so that the model training objective is transformed into maximizing the probability of the actual observed data occurring under the mixture probability distribution.
[0116] For example, when the actual traffic state y corresponds to a "congestion" state, if the model's prediction results show low weights for the zero-inflated negative binomial distribution and low probability densities for the log-normal or Student's distribution, the overall likelihood probability is low, resulting in a large negative log-likelihood loss. The model will adjust the mixed weight parameters and distribution parameters through backpropagation to improve its ability to fit the probability density of the "congestion state" in similar traffic congestion samples. Conversely, when the model correctly learns that "congestion scenarios are more likely to be driven by sudden events," it will increase the weights of the zero-inflated negative binomial distribution in that sample, thereby reducing the loss function value.
[0117] As the training process iterates and optimizes, the model parameters gradually converge on a large number of historical traffic samples, enabling traffic state observations at different spatial nodes and time steps to achieve high likelihood interpretation within a mixed probability distribution framework. When the negative log-likelihood loss function converges, it indicates that the model has learned a stable traffic state probability distribution, thus yielding a well-trained spatiotemporal traffic prediction model.
[0118] In one specific embodiment of this application, the traffic spatiotemporal prediction model performs a cross-modal joint pre-training process before making formal predictions to establish a correlation mapping relationship between traffic numerical changes and textual semantic events. Specifically, cross-modal sample pairs are constructed during the training phase, including traffic spatiotemporal sequence data and corresponding traffic event text prompts. For example, in an urban arterial road traffic scenario, a training sample includes: traffic flow at a certain intersection increases from 1200 vehicles / hour to 2600 vehicles / hour during the morning rush hour, accompanied by the text description "A traffic accident occurred on this section of the road, occupying two lanes and causing congestion." The model receives both the numerical sequence and the textual semantic information during the training process. Through joint training, the model automatically learns the potential mapping relationship between "sudden increase in traffic flow + decrease in speed" and "accident event" during parameter updates. For example, in another sample without explicitly labeled accident information, even if only the numerical changes in traffic flow and speed are input, the model can still infer that it may correspond to an accident or sudden event type.
[0119] In one specific embodiment of this application, the decoder layer employs a multi-token parallel prediction mechanism to achieve synchronous prediction output for multiple future time steps. Specifically, multiple parallel prediction branch structures are set up at the model decoding end, with each branch corresponding to a future time step, such as t+5 minutes, t+10 minutes, and t+15 minutes. Each prediction branch shares the same hidden state input, but generates prediction results for different time steps through an independent parameter mapping layer. For example, in an urban ring road traffic prediction task, after inputting the current traffic state of an intersection, the model can simultaneously output the traffic congestion probabilities for the next 5, 10, and 15 minutes in a single forward propagation, which are 0.62, 0.71, and 0.78, respectively. Unlike traditional stepwise recursive prediction, this implementation does not suffer from the problem of errors from the previous time step propagating to the next time step.
[0120] In one specific embodiment of this application, reversible instance normalization is used not only for input standardization but also for inverse transformation recovery at the output. Specifically, after the model outputs the prediction result in the standardized space, the system calls the mean and variance parameters saved during the normalization stage to perform an inverse transformation on the prediction result, thereby restoring it to the original traffic physical quantity scale. For example, in a subway station passenger flow prediction scenario, if the model outputs a standardized value of 0.90, corresponding to historical statistical parameters of a mean of 3000 people and a variance of 500 people, then after the inverse transformation, it can be restored to an actual passenger flow prediction value of approximately 3450 people.
[0121] In this way, the model output not only has statistical significance, but can also be directly converted into real numerical values that can be used in engineering.
[0122] In one specific embodiment of this application, the traffic spatiotemporal prediction model possesses zero-shot generalization capability across topologies. Specifically, because the model uses a unified one-dimensional spatiotemporal token representation and models structural relationships through a spatial topology bias matrix, it can predict without retraining in the event of new nodes or topological changes. For example, when a new subway line is added to a city and a new station D is added, it is only necessary to convert the passenger flow data of that station into tokens and construct its topological relationship matrix with existing stations before directly inputting it into the model for prediction. The model can directly output the passenger flow trend of the new station over the next 30 minutes, for example, predicting a 20% increase, while also predicting an impact of approximately 5%-10% on passenger flow at neighboring stations.
[0123] In one specific embodiment of this application, a hybrid distribution prediction head is used to model and calibrate the uncertainty of traffic state prediction results. Specifically, the model output includes mixed weights and parameters of a zero-inflated negative binomial distribution, a Student's distribution, and a log-normal distribution, and dynamically adjusts the contribution ratio of each distribution according to the current traffic state. For example, under normal nighttime traffic conditions, the model may output a higher weight for the LogNormal distribution (approximately 0.7), indicating smaller traffic fluctuations; while under heavy rain or accident scenarios, the weight of the Student's distribution significantly increases to 0.8 to express the heavy-tailed uncertainty characteristics. The final model output is no longer a single predicted value, but a probability range, such as "the probability of congestion in the next 15 minutes is 0.65–0.90".
[0124] In other embodiments of this application, the numerical tokens undergo further multi-granularity spatiotemporal adaptive resampling processing before being input into the attention layer. Specifically, this includes: dynamically grouping numerical tokens from different spatial nodes according to the magnitude of traffic state changes; classifying drastically changing time segments into high-frequency update groups and smoothly changing time segments into low-frequency update groups; further subdividing the numerical tokens in the high-frequency update groups by shortening the time window to generate a finer-grained token sequence with higher temporal resolution; compressing the numerical tokens in the low-frequency update groups by merging adjacent time windows to generate a coarse-grained token sequence with lower temporal resolution; and reassembling the numerical tokens of different granularities according to the spatial node order to form an enhanced spatiotemporal token sequence containing multi-timescale information. In this embodiment, for example, in a morning rush hour scenario on an urban main road where traffic flow at a certain intersection changes drastically, the 5-minute window is further subdivided into 1-minute windows for modeling; while in a low-flow, stable nighttime scenario, multiple consecutive time windows are merged into a longer time segment for representation.
[0125] For example, in a mixed traffic network consisting of urban arterial roads and secondary roads, the numerical tokens of each spatial node are monitored and their changes are analyzed in real time. When a certain arterial road intersection experiences a rapid increase in traffic flow, a continuous decrease in vehicle speed, and significant fluctuations in queue length during the morning rush hour (e.g., 07:30–09:00), the numerical token sequence corresponding to that node is identified as a "high-frequency change state." In this case, instead of continuing to use the preset 5-minute time window, the time window is automatically further subdivided into higher time resolution sub-windows at the 1-minute or even 30-second level, thereby generating a denser, finer-grained numerical token sequence. For example, the process of "traffic flow increasing from 1200 vehicles / hour to 1800 vehicles / hour" within a 5-minute window is broken down into multiple continuous sub-intervals, enabling the model to capture the gradual process of congestion formation and its instantaneous acceleration characteristics. Conversely, in low-flow or stable traffic scenarios at night, such as urban side roads between 11:00 PM and 5:00 AM, traffic flow remains consistently low with minimal fluctuations. In these cases, the numerical tokens exhibit small changes, which the system identifies as "low-frequency change states." For these nodes, the system merges multiple adjacent time windows, for example, combining three consecutive 5-minute windows into a single 15-minute time segment. This generates coarse-grained numerical tokens with low temporal resolution but stable statistical characteristics, enabling the model to express long-term stable traffic states with higher computational efficiency. After subdividing the high-frequency group and compressing the low-frequency group, the system reassembles the numerical tokens of different granularities according to the topological order of the spatial nodes. This ensures that each spatial node simultaneously contains both a "fine-grained representation of rapidly changing segments" and a "coarse-grained representation of stable states," ultimately forming an enhanced one-dimensional spatiotemporal token sequence with multi-timescale information fusion capabilities.
[0126] Through the above implementation methods, this application introduces an adaptive time resampling mechanism driven by the magnitude of change, enabling the model to automatically select an appropriate time modeling granularity for different traffic states. This avoids the problems of information loss in rapidly changing scenarios or computational redundancy in stable scenarios caused by traditional fixed time window methods. On the other hand, this mechanism enables highly dynamic traffic events (such as sudden congestion, accident spread, etc.) to be finely characterized with higher time resolution, while low-dynamic scenarios are improved by compression to enhance modeling efficiency. This significantly improves the overall model's expressive power, prediction accuracy, and computational resource utilization efficiency in complex urban traffic environments.
[0127] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make modifications, alterations, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A traffic state probabilistic prediction method for multi-source spatiotemporal data fusion, characterized in that, include: Acquire traffic spatiotemporal sequence data and its corresponding traffic event data; wherein, the traffic spatiotemporal sequence data includes traffic operation observation data collected by multiple spatial nodes at multiple time steps; the traffic event data includes traffic event records corresponding to each spatial node at different time points; After performing instance-level normalization on the traffic spatiotemporal sequence data, the data is segmented according to a preset time window, and features are extracted from each segment to generate numerical tokens. Additionally, text encoding is performed on each traffic event record in the traffic event data to generate semantic tokens. The numerical tokens and semantic tokens are then fused and spliced together to obtain a one-dimensional spatiotemporal token sequence. The one-dimensional spatiotemporal token sequence is input into the trained traffic spatiotemporal prediction model, and the predicted traffic state probability distribution of each spatial node at each future time step is output. The traffic spatiotemporal prediction model includes a self-attention layer, a decoder layer, and a hybrid distribution prediction head. The self-attention layer is used to generate a spatiotemporal fusion feature representation based on the one-dimensional spatiotemporal token sequence. The decoder layer is used to perform autoregressive multi-token prediction based on the spatiotemporal fusion feature representation to obtain a hidden representation sequence for future multiple time steps. The hybrid distribution prediction head is used to output the traffic state probability distribution prediction results of each spatial node at each future time step based on the hidden representation sequence for future multiple time steps.
2. The traffic state probability prediction method based on multi-source spatiotemporal data fusion according to claim 1, characterized in that, The traffic spatiotemporal sequence data is subjected to instance-level normalization processing, including: The traffic spatiotemporal sequence data is divided according to the dimension of spatial nodes, so that each spatial node corresponds to an independent historical observation sequence; wherein, the historical observation sequence is the time series of traffic operation observation data collected at each historical time step of the spatial node. For each spatial node, the mean and variance are calculated based on its corresponding historical observation sequence. Based on the mean and variance, the observation data of the corresponding spatial nodes are standardized to obtain normalized spatiotemporal numerical data.
3. The traffic state probability prediction method based on multi-source spatiotemporal data fusion according to claim 2, characterized in that, The process of generating a numerical token includes: Based on the normalized spatiotemporal numerical data, the continuous time series is divided according to a preset time window to obtain multiple time segments; Feature extraction is performed on each time segment to obtain a feature representation that characterizes the local temporal variation features of that time segment; The feature representation is mapped to a high-dimensional representation vector by a vector mapping function, generating a numerical token that corresponds one-to-one with each time segment, so that the numerical token has the information expression ability to represent local spatiotemporal semantics.
4. The traffic state probabilistic prediction method based on multi-source spatiotemporal data fusion according to claim 3, characterized in that, The process of generating semantic tokens includes: The acquired traffic incident data is input into a pre-trained text encoding model for semantic encoding, so as to convert each traffic incident record into a corresponding semantic vector, and each semantic vector is used as a text semantic token; wherein, the text encoding model is a semantic representation model based on deep learning, which is used to extract semantic feature information from traffic incident records.
5. The traffic state probability prediction method for multi-source spatiotemporal data fusion according to claim 4, characterized in that, The process of obtaining a one-dimensional spacetime token sequence includes: Associate text semantic tokens that occur within the same preset time window with numerical tokens within the corresponding time window to achieve time alignment; The numerical tokens aligned with completion time and the textual semantic tokens are fused to generate a fused token by vector concatenation. The fusion tokens corresponding to each spatial node are grouped according to the preset spatial node order. Within each spatial node, the corresponding fusion tokens are arranged in chronological order. The fusion tokens within each spatial node are concatenated sequentially according to the sorting order of the spatial nodes to obtain the one-dimensional spatiotemporal token sequence.
6. The traffic state probabilistic prediction method for multi-source spatiotemporal data fusion according to claim 5, characterized in that, The self-attention layer generates a spatiotemporal fusion feature representation based on the one-dimensional spatiotemporal token sequence, including: The one-dimensional spatiotemporal token sequence is input into the self-attention layer and linearly transformed using a trainable linear projection matrix to obtain the query vector, key vector, and value vector; wherein the trainable linear projection matrix includes: query matrix, key matrix, and value matrix; The one-dimensional spatiotemporal token sequence is composed of fused tokens corresponding to different spatial nodes at different time positions. The time index is used to indicate the time to which the fused token belongs, and the spatial node index is used to indicate the spatial node to which the fused token belongs. Based on the time index, the Query vector and Key vector are rotated and encoded to inject time position information into the Query vector and Key vector, resulting in Query vector and Key vector with time position information. The attention score is calculated based on the inner product of the query vector and the key vector with temporal location information, and in conjunction with the learnable spatial topology bias parameter matrix B pre-set in the self-attention layer to characterize the association between different spatial nodes. The formula for calculating the attention score is as follows: ;in, This represents a fusion token with time index i and spatial node index m. This represents a fused token with time index j and spatial node index n. The rotation matrix is obtained by multiplying the fusion token with time index i and the fusion token with time index j. A query vector containing time and location information; A key vector containing time and location information; This refers to the parameters corresponding to spatial node indices m and n in the spatial topology bias parameter B; the superscript T indicates the transpose operator. The attention scores are then subjected to Softmax normalization to obtain the attention weights. The spatiotemporal fusion feature representation is obtained by weighting and summing the Value vector based on the attention weights.
7. The traffic state probabilistic prediction method for multi-source spatiotemporal data fusion according to claim 6, characterized in that, The spatial topology bias parameter matrix B is constructed as follows: An adjacency matrix A is constructed based on a preset set of spatial nodes, wherein the rows and columns of the adjacency matrix A are arranged in the order of the spatial node numbers, and each row and each column of matrix A corresponds to a spatial node. For any element A(n, m) in the adjacency matrix A, when the nth spatial node and the mth spatial node have a direct connection in the actual spatial topology, the value of element A(n, m) is set to 1; when the nth spatial node and the mth spatial node do not have a direct connection, the value of element A(n, m) is set to 0. Based on this, each element in the adjacency matrix A is multiplied by the weight w to obtain the spatial topology bias parameter matrix B.
8. The traffic state probabilistic prediction method for multi-source spatiotemporal data fusion according to claim 7, characterized in that, in, The decoder layer is a Transformer model containing only a decoder structure. The decoder layer performs autoregressive multi-token prediction based on the spatiotemporal fusion feature representation, including: The spatiotemporal fusion feature representation is input into the decoder layer, and the corresponding hidden state sequence is generated by calculating layer by layer through the decoder layer; During the layer-by-layer calculation process of the decoder layer, a causal multi-head self-attention mechanism is adopted, and a preset causal mask is introduced to constrain the attention calculation process. After the layer-by-layer calculation is completed through the causal multi-head self-attention mechanism, the target hidden state representation corresponding to the current time is obtained. Based on the target hidden state representation, the target hidden state representation is mapped in parallel by multiple prediction mapping structures set at the output of the decoder layer to generate prediction hidden representations corresponding to different future time steps; The predicted hidden representations corresponding to each future time step are combined in chronological order to obtain a sequence of predicted hidden representations corresponding to multiple future time steps. The decoder layer contains an RMSNorm normalization layer to normalize intermediate hidden states, and the feedforward network of the decoder layer uses the SwiGLU activation function.
9. The traffic state probabilistic prediction method for multi-source spatiotemporal data fusion according to claim 8, characterized in that, The hybrid distribution prediction head outputs the traffic state probability distribution prediction results of each spatial node at each future time step based on the future multi-time step hidden representation sequence, including: The future multi-time step hidden representation sequence is input into the hybrid distribution prediction head, and the future multi-time step hidden representation sequence corresponds to the spatiotemporal feature representation of each spatial node at each future time step; The hybrid distribution prediction head is used to parameterize the hidden representation corresponding to each spatial node and each future time step, generating a set of hybrid weight parameters and distribution parameters. The mixed weight parameter is used to characterize the contribution ratio of each basic probability distribution in the final mixed probability model, and the distribution parameter set is used to characterize the shape feature parameters of each basic probability distribution. The basic probability distributions include the zero-inflated negative binomial distribution, the Student's distribution, and the log-normal distribution. Based on the aforementioned mixed weight parameters, each basic probability distribution is weighted and combined to construct a mixed probability distribution model of traffic state corresponding to each spatial node at each future time step. Based on the hybrid probability distribution model, the traffic state probability distribution prediction results for each spatial node at each future time step are output.
10. The traffic state probabilistic prediction method based on multi-source spatiotemporal data fusion according to claim 9, characterized in that, The trained traffic spatiotemporal prediction model is a model that converges after being trained in advance based on a negative log-likelihood loss function with a mixed probability distribution. The negative log-likelihood loss function is: ; Where y represents the actual traffic condition observation value. This represents the mixture weight parameter corresponding to the k-th basic probability distribution. Let represent the probability density function of the k-th basic probability distribution; where k takes the values 1, 2, and 3, corresponding to the zero-inflated negative binomial distribution, the Student's distribution, and the log-normal distribution, respectively. When the negative log-likelihood loss function converges, a well-trained traffic spatiotemporal prediction model is obtained.