Search

CN-122024497-A - Traffic flow prediction method based on space-time knowledge graph and anchor soft prompt engineering

CN122024497ACN 122024497 ACN122024497 ACN 122024497ACN-122024497-A

Abstract

The invention discloses a traffic flow prediction method based on space-time knowledge graph and anchor soft prompt engineering, which is characterized in that a space-time knowledge graph, a convolution self-encoder and a pre-training language model are fused, firstly, unified space-time semantic representation is extracted from multi-source heterogeneous external space-time information and historical traffic data through the space-time knowledge graph encoder and the space-time convolution self-encoder respectively, then, an anchor soft prompt engineering mechanism is introduced, the unified space-time representation is used as a learnable soft prompt and fused with a natural language template prompt containing traffic semantics, so that language model input is formed, and the space-time dynamics of a pre-training language model modeling traffic sequence is guided accurately, so that multi-step traffic state prediction is realized. In the training stage, the modeling capability of the model on remote dependence and local dynamic characteristics is enhanced by combining the structured auxiliary loss function and a part of fine tuning strategy, and the long-range traffic flow prediction with high precision and high stability is realized. The intelligent traffic scheduling method is suitable for various application scenes such as intelligent traffic scheduling, path planning and anomaly detection.

Inventors

  • Guo Penglong
  • HE ZHIXIANG

Assignees

  • 北京工业大学

Dates

Publication Date
20260512
Application Date
20260128

Claims (9)

  1. 1. A traffic flow prediction method based on space-time knowledge graph and anchor soft prompt engineering is characterized by comprising the following three steps, Step 1, constructing a unified space-time characterization module; step 2, anchoring a soft prompt engineering mechanism; step 3, structuring an auxiliary PLM fine tuning strategy; in the step 1, the unified space-time characterization module includes: (1) A space-time knowledge-graph encoder; The weather mutation, holiday trip peak, sudden accident and peripheral POI external factors in the intelligent traffic system have obvious influence on the road traffic state, the space-time knowledge graph encoder STKGE integrates the multi-source heterogeneous space-time information which looks like the cleavage into a space-time knowledge graph, and finally refines the space-time knowledge graph into a low-dimensional vector to represent the embedding of external features as the auxiliary input of traffic flow prediction, the method is characterized in that All facts related to the space-time neighborhood of the object are quickly extracted, and then weighted aggregation is carried out by using an attention mechanism to generate external feature embedding; The STKGE coding process is divided into three layers, namely (1) a map construction layer, a learning layer is embedded, a uniform entity and relation embedding layer is learned based on TransE structure fusion space and time context information, and (3) a characteristic aggregation layer is used for carrying out weighted aggregation on related map facts in the neighborhood of the specific sensor-time slot position by using an attention mechanism to generate semantic external characteristic vectors, wherein the weather, holidays, POI, accident and space-time index information external information are uniformly coded into nodes and edges in the map to form a structured space-time five-tuple set; (2) A space-time convolutional self-encoder; To extract deep space-time features in traffic flow data, a space-time convolution self-encoder STCAE is introduced, and external space-time features extracted by a joint space-time knowledge-graph encoder are embedded into a matrix Mining space-time dependency relations in traffic sequences; in the step2, combining a learnable soft prompt and a structured template prompt, taking a natural language template prompt with traffic semantics as an anchor point and taking a trainable soft prompt as a supplement, and jointly guiding a model to complete complex traffic flow prediction; In the step 3, the soft prompt embedding and model predicting result is optimized by adopting the combination of the structured auxiliary loss function and the PFT strategy, and the language model under the prompt driving is finely tuned, so that the multi-step prediction of the traffic state is realized.
  2. 2. The traffic flow prediction method based on the space-time knowledge graph and the anchor soft prompt engineering according to claim 1, wherein the space-time knowledge graph encoder comprises the following specific implementation steps: (a) Map construction layer In the map construction layer STKGE, firstly, the external space-time information of the multisource isomerism is structured into a unified knowledge map, and a isomerism entity set needs to be defined Relationship set And a basic space-time quintuple structure in the atlas to support semantic reasoning across time and space; Entity collection Dividing the external space-time information into six major classes and seventeen subclasses of computable nodes, namely entities, and recording the set of all the entities as, ; Relationship set Letting facts possess direction and semantics for relationships; all sets of relationships are noted as being, ; Space-time quintuple set One fact record is a time-space snapshot, and each fact is expressed as a time-space quintuple Wherein Representing a set of all facts, Represents the head and tail entities of the device, The relationship is represented by a relationship of, Representing a discrete time slot in which the time slot is located, Representing sensor/road segment numbers; (b) Embedding learning layer In order to realize unified modeling of heterogeneous space-time entities, STKGE provides a space-time embedding scheme suitable for traffic scenes in a knowledge graph embedding learning layer on the basis of a knowledge graph embedding method TransE and combining a time embedding mechanism and a space embedding mechanism, and is oriented to a constructed five-tuple fact set The multi-dimensional information among the entities is embedded and expressed, so that the modeling capability of the traditional map embedded in the space-time dimension is enhanced, and the traditional map is more matched with the actual semantic structure of the traffic flow scene; Firstly, all entities and relations are discrete type information, and are represented by adopting a lookup table type embedded mode, wherein each head entity and each tail entity And each relation Corresponding learning embeddability is respectively 、 And ; Second, for time slots in five-tuple By using The algorithm performs sine position coding on the data so as to map discrete time into continuous vectors, and meanwhile, the periodic mode and the sequence information are reserved, and the method is specifically expressed as: ; for spatial information, i.e. sensor or road section numbering By using Algorithm generation spatial embedding To preserve the topological adjacency characteristics of the road network, specifically expressed as: ; executing a random walk strategy on a road network graph to sample each node with its set of contextual neighbors Based on skip-gram principle, the goal is to maximize the predictive probability of a node in context, namely:
  3. 3. Wherein the method comprises the steps of Represented at a given central node Is embedded with a predictive context node Can be realized by using softmax or negative sampling approximation, and the obtained space embedding matrix after training is as follows ∈ The embedding can compress the structural information of the original space nodes into a low-dimensional semantic space to be used as the space representation of the nodes in the map; The learnable weighting factors are introduced into the scoring function to realize the dynamic adjustment of entity, relation, time and space embedding contribution degree, and in combination, any five-tuple The confidence that this fact is true in the map is defined as: ; Wherein, the · In order to be an L2 norm, 、 、 And Respectively representing four embedded learnable weight factors; The scoring function follows TransE vector translation, each real fact in the space-time atlas is modeled as a vector translation structure of a head entity and a relation approximately equal to a tail entity, time and space embedding are introduced to jointly form a semantic translation path, the training target is the scoring of the maximum combination method quintuple, the negative sampling quintuple scoring is minimized, so that the discrimination capability of the embedding is enhanced, and the loss function is defined as: ; Wherein, the By randomly replacing the header entity Or tail entity A negative sample of the construction is made, Is a preset interval super parameter; (c) A feature aggregation layer; In the feature aggregation layer of STKGE, the model constructs a local association subgraph at the position of each space node-time slot, extracts related five-tuple facts from the time-space neighborhood graph, aggregates the semantic embedding of the five-tuple facts through an attention mechanism to form a final external feature vector representation as the semantic auxiliary input of a downstream prediction module, and for a given sensor Sum time slot From five-tuple set Screening all fact subsets related to the fact subsets to form a related subgraph: ; Wherein, the Is the allowed temporal neighborhood window size, Representation and node In time slot All map facts that are related nearby; for each of the facts of the graph Extracting its map embedding, including embedding head entity Relational embedding Time embedding In order to measure the influence of different facts on the current node state, attention mechanisms are introduced to allocate weights to each fact Attention weighting thereof Calculated from the following equation: ; Wherein the method comprises the steps of In order to activate the function, In order that the attention parameter vector may be learned, Representing vector splicing operation, finally, embedding tail entities corresponding to all facts in the subgraph Weighted summation is carried out to obtain a node In time slot External feature embedding of (a) : ; Wherein the method comprises the steps of = The representation remains consistent with the entity embedding dimension; integrating the external feature vectors of all nodes on all time slots to form an integral external feature embedded tensor Wherein Is the number of time slots in which the data is to be stored, Is the number of spatial nodes.
  4. 4. The traffic flow prediction method based on the space-time knowledge graph and the anchor soft prompt engineering according to claim 1 is characterized in that the space-time convolution self-encoder comprises the following specific implementation procedures: (a) Given that the input data is a multi-path segment traffic flow data sequence of a plurality of continuous time steps, the dimension is as follows: wherein Representing the length of the time step of the input history, In order to be the number of road segments, Representing the feature quantity of each road section at each time step; (b) In order to enhance the generalization adaptability of the model in real scenes of sensor faults and data loss, a random space-time shielding mechanism is introduced in the training process, namely a shielding matrix is generated by randomly Bernoulli shielding a plurality of road sections or time slices in Mask input data, and then the original input is shielded: ; Wherein the method comprises the steps of Representing an element-level multiplication of the number of elements, Is a masking matrix, each element Following Bernoulli distribution, masking probability Taking out Masked input Embedding with external features The splicing is carried out, ; Will be Sending the data into an encoder, extracting deep space-time characteristic representation of the data, and providing a more robust semantic basis for subsequent prediction; (c) The encoder consists of m-level space-time convolution blocks Stacked, each of Each of which consists of a spatial map convolution layer GCN and a temporal convolution layer TCN: ; Wherein the method comprises the steps of The method is a unified space-time characterization with potential semantics after compression; Specifically, first to the first Input data of layer GCN Is set for each time slice of (a) And (3) performing graph convolution processing: ; Wherein the method comprises the steps of Is an adjacency matrix of the road network graph, representing the connection relationship between the sensors or road segments, Representing an adjacency matrix after addition from the loop, wherein Is an identity matrix; the corresponding degree matrix is represented by a number of degrees, Represent the first Layer(s) The middle graph is rolled up to laminate the weight matrix, Representing Is the first of (2) The number of time slices per one time slice, Representing the last layer Output of characteristic representation A time slice, wherein, Is that The size of the characteristic dimension set by the intermediate layer, Represent the first The time slices pass through Node characteristic representation after layer GCN processing, then the graph convolution output of all time slices is spliced according to time dimension to obtain Then, performing one-dimensional causal convolution according to a time dimension, namely performing real-Time Convolution (TCN), wherein each TCN module comprises convolution operation, pooling and nonlinear activation function operation, introducing LayerNorm and Dropout after the TCN module for enhancing training stability, and retaining input characteristics through a residual structure: ; + ; Wherein, the Is the time sequence characteristic which is subjected to regularization treatment, Is at present Finally, the input features of the current are overlapped through residual connection to form the current Output of (2) ; (D) Decoder and reconstruction loss, decoder adopts multilayer perceptron For unified space-time characterization Reconstruction of the original input data is performed.
  5. 5. ; The reconstruction error uses a mean square error The loss function is defined as follows: ; Wherein, the As the original input value is to be used, The result is reconstructed for the decoder.
  6. 6. The traffic flow prediction method based on the spatiotemporal knowledge graph and the anchor soft prompt project according to claim 1, wherein the step 2 comprises: (1) Unified space-time characterization of traffic states Embedded as a trainable soft hint: ; for guiding the language model for task specification; (2) Meanwhile, structured prompting words are constructed, namely natural language template prompting words containing traffic semantics, and the prompting words are subjected to word segmentation to obtain corresponding word segmentation codes through a word segmentation device: The segmentation code is then mapped to a fixed anchor hint embedding: ; (3) Embedding soft cues And anchor hint embedding Anchor-lead soft hint embedding spliced into input PLM : ; Wherein the method comprises the steps of The length of the anchor soft prompt word sequence which is expressed and constructed, the length of the unified space-time representation which contains multi-source heterogeneous information and the length of the word segmentation sequence which is prompted by a natural language template, The embedded dimension is represented, aligning the dimension size of the pre-trained language model input.
  7. 7. The traffic flow prediction method based on the space-time knowledge graph and the anchor soft prompt engineering according to claim 1, wherein the specific implementation steps in the step 3 are as follows: (1) A predictive decoder; extracting implicit semantic embedding vectors by utilizing long-range dependency capacity of a pre-training language model to promote realization of traffic flow prediction, and specifically embedding prompt words Input device : ; Wherein, the The vectors are embedded for implicit semantics of the pre-training language model output, Representing the number of future time steps to be predicted, The pre-training language model outputs a hidden semantic embedded vector Then, mapping the two-layer MLP serving as a prediction decoder to obtain a target future prediction data tensor; ; (22); Wherein the method comprises the steps of For the future Step of time The traffic flow prediction results of the individual road segments, And Is the first The weights and bias terms of the layer perceptron, Is an activation function; (2) PLM fine tuning and training optimization; before freezing the pre-trained language model in the fine tuning stage Parameters of layers only for the last Layer Transformer updates, before PLM in training process Layer parameters freeze, only for the back The method comprises the steps of optimizing layer parameters, adopting PSLoss as an auxiliary optimization target, carrying out self-adaptive division on a predicted sequence and a real sequence according to a main frequency characteristic to form a plurality of structure segments, calculating the following three local structure alignment indexes on each segment, and carrying out weighted fusion to form a final local structured auxiliary loss: (3) Result evaluation mechanism.
  8. 8. The traffic flow prediction method based on space-time knowledge graph and anchor soft prompt engineering according to claim 5, wherein three local structure alignment indexes are as follows: (a) The correlation loss is that the consistency of the predicted patch and the real patch in the trend direction is measured, and the model is encouraged to keep the consistent structural change; ; Wherein, the Representing pearson correlation coefficients; And (3) with Respectively the first True and predicted values for the individual patch; (b) Variance loss, namely calculating the relative distribution difference of the internal fluctuation of the patch through Softmax mapping and KL divergence, and guiding the model to capture the local fluctuation intensity; ; Wherein the method comprises the steps of As a function of Softmax (r), Represents the Kullback-Leibler divergence; (c) Average value loss, namely measuring the average value deviation degree between the prediction and the real patch, and correcting the overall position deviation and improving the alignment capability of the prediction reference; ; Wherein, the 、 Respectively represent the first Real average and predicted average of the individual patch; And adopting a dynamic weighting mechanism for the three structural losses, and automatically adjusting weights according to the gradient amplitude of each loss term: ; Wherein the method comprises the steps of And For dynamically adjusting weights during training, particularly according to each gradient Setting a norm proportion, and carrying out fine adjustment by combining statistical distribution covariance of prediction and a true value to improve robustness and precision of a model in long-term trend prediction, wherein a final total loss function is updated into a three-layer structure: ; Wherein the method comprises the steps of 、 And Is a super parameter, determined by cross-validation, The reconstruction loss of the self-encoder defined for equation (4), The predictive loss as the primary supervision in the form of mean square error : ; Wherein, the The true value is predicted for the object and, Is a predicted value of a predictive decoder.
  9. 9. The traffic flow prediction method based on the space-time knowledge graph and the anchor soft prompt project according to claim 5, which is characterized in that in a result evaluation mechanism, the following three steps are adopted; (a) Extracting predicted sequence, extracting future from output layer after model reasoning A time step, A road section, Traffic state prediction tensor for dimensional features ; (B) An error measure; The predicted value is compared with the actual observed data point by adopting And Overall prediction accuracy is measured as an evaluation index: ; ; Wherein, the The model predictive value is represented by a model, Representing the corresponding real observed value; the penalty for larger deviations is emphasized, The whole absolute deviation is reflected, and the whole absolute deviation jointly describe the precision and the robustness of the model; (c) Judging the validity of the result; Setting an empirical threshold And If it is ; The prediction result is valid, otherwise, the prediction result is regarded as abnormal.

Description

Traffic flow prediction method based on space-time knowledge graph and anchor soft prompt engineering Technical Field The invention relates to the technical field of traffic flow prediction, in particular to a traffic flow prediction method of a space-time knowledge graph, convolution self-coding, anchor soft prompting engineering and a pre-training language model, which is suitable for traffic state dynamic flow prediction tasks of multiple time steps and multiple road sections in a complex urban road network. Background Along with the development of smart city construction, accurate traffic flow prediction plays a central role in scenes such as intelligent scheduling, path planning, traffic signal control and the like. Traditional machine learning-based methods (such as support vector machines) or neural networks (such as feedforward neural networks) have certain effects in short-term prediction. However, in a scenario where the prediction time span is long and the road network level multi-path segment coupling characteristics need to be modeled simultaneously, the conventional method shows a significant performance bottleneck due to limited linear or shallow nonlinear modeling capability. In recent years, the rising methods such as a graph neural network, a space-time graph convolutional network and a attention network are used for converting traffic flow prediction tasks into graph space-time sequence learning problems through explicitly embedding road topology and space-time dependence, so that modeling capability of traffic network space structures is improved to a certain extent, but the three aspects of the method still face significant challenges (1) the modeling capability of the existing research on multi-source heterogeneous space-time information such as weather, holidays, traffic accidents and interest point (PointofInterest, POI) distribution is limited, so that generalization performance of a model is restricted, (2) the modeling of structured traffic data and unstructured semantic features are difficult to cooperate, a unified semantic characterization mechanism is lacking, and the representation capability and prediction accuracy of the model are limited, and (3) the existing work generally adopts global loss functions such as mean square error (MeanSquareError, MSE) or average absolute error (MeanAbsoluteError, MAE), neglects local structure dynamic characteristics of traffic states in space-time dimension, and is difficult to capture long-distance space-time dependence, so that long-time prediction error accumulation is difficult, and robustness is reduced under a migration or fine tuning scene. At the same time, pre-trained language models (PretrainedLanguageModel, PLM) such as GPT, LLaMA, etc. have demonstrated powerful context modeling and generalization capabilities in natural language processing, code generation, and cross-modal learning tasks. The method is based on a transducer architecture of large-scale corpus training, and has remarkable potential in modeling time sequence dependence. However, the original traffic flow data is a high-dimensional structured numerical sequence, the language model cannot be directly input, and an effective prompt word engineering method is also lacking at present, so that the multi-source heterogeneous space-time information is converted into the understandable input of the language model. Therefore, a novel traffic flow prediction method capable of deeply fusing unified space-time characterization, anchor soft prompt engineering, structured auxiliary loss function and reasoning capacity of a pre-training language model of multi-source heterogeneous data is needed to improve accuracy and adaptability of traffic flow prediction of a complex urban road network. Disclosure of Invention The invention aims to solve the technical difficulties of (1) modeling high-dimensional structured traffic flow data and other heterogeneous space-time information into uniform low-dimensional space-time characterization, not only reserving local space-time correlation in original data, but also mapping the local space-time correlation to semantic space aligned with PLM, (2) designing an effective traffic domain specific prompting word construction method to generate prompting words with definite traffic semantic information and adaptation to PLM input format, and considering interpretation and modeling efficiency, (3) designing a loss function with local dynamic change and global structural constraint, so that the model fully utilizes the remote dependence capability of PLM while accurately capturing space-time non-stationary change and inhibiting error accumulation, and realizes robust long-range prediction and migration fine adjustment. The technical scheme adopted by the invention is a traffic flow prediction method based on space-time knowledge graph and anchor soft prompting engineering, which is characterized by comprising the following three steps, Step 1, cons