Urban subway passenger flow volume prediction method and system based on large language model

By applying a large language model in urban subway passenger flow forecasting, combining sliding window technology, multi-head attention mechanism and prefix prompt design, the problem of insufficient accuracy and efficiency of passenger flow forecasting in the existing technology is solved, and more efficient passenger flow forecasting is achieved.

CN119761573APending Publication Date: 2025-04-04NANJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202411831217.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-12
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively predict urban subway passenger flow, especially when processing high-dimensional and complex spatiotemporal data, the generalization ability and adaptability of the model are insufficient.

Method used

The urban subway passenger flow prediction method based on a large language model is adopted, patch embedding vectors are generated through sliding window technology, and these vectors are fused using a multi-head attention mechanism, and combined with prefix prompt design to improve the multimodal expression ability and prediction accuracy of the model.

Benefits of technology

This method can better capture the spatial and temporal characteristics of the changes in guest flow, improve the accuracy and efficiency of prediction, and enhance the generalization ability and adaptability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119761573A_ABST
    Figure CN119761573A_ABST
Patent Text Reader

Abstract

The invention discloses an urban subway passenger flow prediction method and system based on a large language model. The method comprises the following steps: generating a patch embedding vector according to subway passenger flow time sequence data; fusing the patch embedding vectors by using a multi-head attention mechanism to obtain an attention mechanism patch embedding vector; constructing a prefix prompt according to the subway passenger flow time sequence data; and fusing the prefix prompt and the attention mechanism patch embedding vector to obtain an output projection. According to the method, complex characteristics of subway passenger flow volume data can be fully mined and utilized, so that the prediction accuracy and reliability are improved, effective decision support can be provided for urban subway operation management, and optimization of traffic scheduling and passenger service is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of large language models and deep learning, and in particular to a method and system for predicting urban subway passenger flow based on a large language model. Background Art

[0002] With the continuous advancement of urbanization, subways have become an important part of modern urban public transportation systems. Subways not only play a key role in alleviating traffic congestion and reducing carbon emissions, but also provide citizens with an efficient and convenient way to travel. However, with the expansion of subway lines and the increase in passenger flow, the operation and management of subway systems are facing increasingly severe challenges. Accurately predicting urban subway passenger flow is of great practical significance for transportation management departments to optimize operation plans, flow management, and personal travel planning.

[0003] Urban subway passenger flow prediction is a complex task that requires comprehensive consideration of historical passenger flow data, holiday effects, weather changes, and major urban events. At present, most prediction methods rely on analyzing and modeling external factors such as subway station inflow and outflow data, network topology, and weather to predict future passenger flow changes. Traditional subway passenger flow prediction mainly relies on mathematical statistics methods (such as ARIMA) to analyze passenger flow change trends, but these methods are difficult to adapt to sudden changes in passenger flow data caused by the external environment, and it is also difficult to capture the complex spatiotemporal dependencies in the data. Although machine learning methods represented by dynamic Bayes have improved the accuracy of subway passenger flow prediction, they still have certain limitations when processing high-dimensional and complex spatiotemporal data. With the continuous expansion of the scale of subway passenger flow data and the rapid development of deep learning, many studies have been devoted to subway passenger flow prediction based on deep learning, such as convolutional memory network (GCMN) and ResLSTM. These deep learning models usually require elaborate design of specific network structures to handle the spatiotemporal complexity of subway data. However, although these designs can improve the accuracy of predictions, they also limit the generalization ability of the model and its adaptability to the lack of labeled data in the real world to a certain extent. Summary of the invention

[0004] Purpose of the invention: In order to overcome the deficiencies in the prior art, the present invention provides a method for predicting urban subway passenger flow based on a large language model. The method uses a sliding window technology to divide the subway passenger flow time series data into time periods of fixed length to generate a series of continuous patch embedding vectors. These patch embedding vectors retain the short-term and long-term fluctuation characteristics in the data, so that the model can better understand the temporal dynamics of passenger flow. The generated patch embedding vectors contain both high-frequency (short-term fluctuations) and low-frequency (long-term trends) features in the time series, providing rich temporal input data for subsequent prediction models, which helps to capture the passenger flow change pattern more comprehensively. In addition, the multi-head attention mechanism enables the model to capture the multi-level correlation of passenger flow data from different dimensions and time windows through multiple parallel attention heads. This mechanism helps the model identify potential correlations in the data and better understand the important factors affecting passenger flow changes within a specific time window. When fusing patch embedding vectors, the multi-head attention mechanism aligns the data features of subway passenger flow data and language modalities, so that the model can simultaneously understand the features in passenger flow time series and language prompts, thereby improving the multimodal expression ability of prediction. The prefix hint generates clear context hints for the language model, enabling it to focus on the key features of passenger flow prediction during the prediction process. Our invention has made beneficial explorations and innovations to address the deficiencies of existing technologies, and provides a new technical solution for improving the accuracy and efficiency of urban subway flow prediction.

[0005] Technical solution: To achieve the above purpose, the technical solution adopted by the present invention is:

[0006] A method for predicting urban subway passenger flow based on a large language model comprises the following steps:

[0007] Step 1: Generate patch embedding vectors based on subway passenger flow time series data.

[0008] Step 2: Use the multi-head attention mechanism to fuse the patch embedding vectors to obtain the attention mechanism patch embedding vector.

[0009] Step 3: Construct prefix prompts based on subway passenger flow time series data.

[0010] Step 4: fuse the prefix hint and the attention mechanism patch embedding vector to get the output projection.

[0011] The present invention generates patch embedding vectors based on urban subway passenger flow data to capture the spatiotemporal characteristics of passenger flow. Then, a multi-head attention mechanism is used to fuse these patch embedding vectors to achieve more comprehensive information integration. In addition, prefix hints are designed to enhance the model's contextual understanding ability and ensure that it performs more accurately in specific tasks. Finally, the fused prefix hints are projected with the output of the patch embedding to generate the final prediction result.

[0012] Preferred: The method for generating the patch embedding vector in step 1:

[0013] The subway passenger flow time series data is divided into time periods of fixed length by the sliding window method to generate a series of continuous patches; the length of each patch is P, and the sliding step is S, so the subway passenger flow time series data is divided into N patches, where Then each patch P is obtained i The embedding vector It can be expressed as:

[0014]

[0015] Where T represents the time length, x[i:i+P] represents each patch, represents the patch embedding vector with added position information, W1 is the weight matrix of the linear layer mapping the patch vector, which maps the patch vector to the embedding space, P i is the i-th patch vector, b1 is the patch vector mapping bias vector, is the position encoding vector.

[0016] Preferred: The method of fusing patch embedding vectors using multi-head attention mechanism in step 2: reprogram the patch embedding vectors into the source data representation space to align subway passenger flow data and natural language modalities to activate the time series understanding and reasoning capabilities of the large language model. Use pre-trained word embeddings To reprogram the patch embed Where V is the size of the vocabulary and D is the embedding dimension. A small set of text prototypes is maintained by linear probing E, denoted as Where V′<<V, E′ represents linear detection, V′ represents text prototype, Represents a text prototype with dimension D. Text prototype learning captures the characteristics of time series by connecting language clues and combines these clues to represent local patch information.

[0017] Preferred: In the multi-head attention mechanism in step 2, for each head k = {1, ..., K}, K represents the number of attention heads, define the query matrix Key Value Matrix and the value matrix in, represents the query weight matrix, represents the key weight matrix, represents the value weight matrix, In particular, D represents the hidden dimension of the model, and Reprogram the time series patch in each attention mechanism head. The specific calculation formula is as follows:

[0018]

[0019] in, Represents the embedding vector, ATTENTION represents the attention mechanism, and SOFTMAX represents the normalization calculation.

[0020] By aggregating the output in each head get Next, a linear projection is performed to align the hidden dimension with the backbone model to generate the output attention mechanism patch embedding vector

[0021] Preferred: Step 3 is a method for constructing prefix prompts based on subway passenger flow time series data: by adding prompt information before the subway passenger flow time series data, guiding the reprogramming of subway passenger flow time series data patches, improving the model's understanding and processing of time series, thereby generating higher quality natural language descriptions.

[0022] Preferably: in step 3, the prefix prompt includes dataset context, task instructions and statistical information. The dataset context provides LLM with basic background information about the input subway passenger flow time series. The task instructions play a key role in guiding LLM in patch embedding conversion of specific tasks. The statistical information is used to enrich the input subway passenger flow time series to facilitate pattern recognition and reasoning.

[0023] Preferred: The method of fusing the prefix hint and the attention mechanism patch embedding vector in step 4: embedding the prefix hint and the attention mechanism patch embedding vector through the frozen large language model After packing and feedforwarding, the prefix part is discarded to obtain the output projection.

[0024] Preferred: In step 4, the formula for fusing the prefix hint and the attention mechanism patch embedding vector to obtain the output projection is:

[0025]

[0026] in, represents the final prediction output of the model, W2 is the weight of the linear layer after flattening, Flattened represents the flattening operation, reshape represents the reshaping, O (i) is the attention mechanism patch embedding vector, and b2 is the flattened vector mapping bias.

[0027] Another object of the present invention is to provide a city subway passenger flow prediction system based on a large language model, which adopts the city subway passenger flow prediction method based on a large language model, including an input unit, a patch embedding vector generation unit, a multi-head attention unit, a prefix prompt construction unit, a fusion unit, and an output unit, wherein:

[0028] The input unit is used to input subway passenger flow time series data.

[0029] The patch embedding vector generating unit is used to generate a patch embedding vector according to subway passenger flow time series data.

[0030] The multi-head attention unit is used to fuse the patch embedding vectors using the multi-head attention mechanism to obtain the attention mechanism patch embedding vector.

[0031] The prefix prompt construction unit is used to construct a prefix prompt according to subway passenger flow time series data.

[0032] The fusion unit is used to fuse the prefix hint and the attention mechanism patch embedding vector to obtain the output projection.

[0033] The output unit is used to output the projection.

[0034] Another object of the present invention is to provide an electronic device, comprising: at least one processor, at least one memory and a communication interface. The processor, memory and communication interface communicate with each other. The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the urban subway passenger flow prediction method based on the large language model.

[0035] Compared with the prior art, the present invention has the following beneficial effects:

[0036] 1. Patch embedding generation based on urban subway passenger flow data. The subway passenger flow time series data is divided into time periods of fixed length through sliding window technology and linear projection to generate a series of continuous patch embedding vectors. These patch embedding vectors retain the short-term and long-term fluctuation characteristics in urban subway passenger flow data, enabling the model to better understand the temporal dynamics of passenger flow. The generated patch embedding vectors contain high-frequency (short-term fluctuations) and low-frequency (long-term trends) features in the time series, providing rich temporal input data for subsequent prediction models, which helps to capture the passenger flow change pattern more comprehensively.

[0037] 2. Patch embedding vector fusion based on multi-head attention mechanism, through multiple parallel attention heads, enables the model to capture the multi-level correlation of passenger flow data from different dimensions and time windows. This mechanism helps the model identify potential correlations in the data, so that it can better understand the important factors that affect passenger flow changes in a specific time window. When fusing patch embedding vectors, the multi-head attention mechanism aligns the data features of subway passenger flow data and language modality, so that the model can simultaneously understand the features in passenger flow time series and language prompts, and improve the multimodal expression ability of prediction.

[0038] 3. Prefix prompt design: by adding a description and statistical data containing key background information or guiding content before the main task prompt, the model can better use contextual information in the subsequent reasoning or prediction tasks. This prefix is ​​equivalent to "leading information", which instills some knowledge or guides the model's thinking so that it can handle the task more accurately.

[0039] 4. Fusion prefix hint and patch embedding output projection. This method extracts key features from large language model embeddings by packing and discarding the prefix part, reducing input redundancy and retaining more effective information for prediction, thereby improving the accuracy and efficiency of the model. The embedding representation is flattened into a one-dimensional vector to achieve dimensionality reduction, reduce computational complexity, and accelerate subsequent prediction calculations. It is suitable for high-dimensional embedding scenarios. The flattened vector is mapped to the prediction dimension through a linear layer to simplify the model structure, making it easier to understand and optimize, while also having good interpretability. Finally, through linear projection and bias adjustment, the output is made to fit the target prediction value more closely, improving prediction accuracy.

[0040] In summary, the present invention achieves modal alignment of time series data and natural text language, and generates output representation in combination with prefix prompts, thereby enhancing the ability of LLM in time series reasoning. At the same time, it improves the timing understanding ability, data correlation recognition ability, multimodal expression ability, prediction accuracy and computational efficiency of the large language model in urban subway passenger flow prediction. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 This is an overall framework diagram of the urban subway passenger flow prediction method based on a large language model provided by the present invention.

[0042] Figure 2 A schematic diagram of generating patch embedding vectors based on urban subway passenger flow data described in the urban subway passenger flow prediction method based on a large language model of the present invention.

[0043] Figure 3 A schematic diagram of patch embedding vector fusion based on a multi-head attention mechanism described in the urban subway passenger flow prediction method based on a large language model of the present invention.

[0044] Figure 4 This is a schematic diagram of the prefix prompt design described in the urban subway passenger flow prediction method based on a large language model of the present invention.

[0045] Figure 5 A schematic diagram of output projection of the fused prefix prompt and patch embedding described in the urban subway passenger flow prediction method based on a large language model of the present invention.

[0046] Figure 6 This is a comparison of MAE of different models and time intervals on the Hangzhou subway dataset described in the urban subway passenger flow prediction method based on a large language model of the present invention.

[0047] Figure 7 The MAE comparison of different models and time intervals on the Shanghai subway dataset described in the urban subway passenger flow prediction method based on a large language model of the present invention.

[0048] Figure 8 This is a comparison of MAE at different time intervals in the ablation experiment on the Hangzhou subway dataset described in the urban subway passenger flow prediction method based on a large language model of the present invention.

[0049] Fig. 9 This is a comparison of MAE at different time intervals in the ablation experiment on the Shanghai subway dataset described in the urban subway passenger flow prediction method based on a large language model of the present invention. DETAILED DESCRIPTION

[0050] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these examples are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.

[0051] Example 1

[0052] This example provides a method for predicting urban subway passenger flow based on a large language model. Figure 1 As shown in the figure, the core of the method is to improve the accuracy and efficiency of prediction through patch embedding vector generation, fusion and prefix prompt design. Specifically, patch embedding vectors are first generated based on urban subway passenger flow data to capture the spatiotemporal characteristics of passenger flow. Then, these patch embedding vectors are fused using a multi-head attention mechanism to more comprehensively integrate information from different modalities. In addition, the introduction of prefix prompt design helps to enhance the model's contextual understanding ability and make it more accurate in the prediction process. Finally, by fusing the output projection of prefix prompts and patch embeddings, the model can generate more detailed and accurate passenger flow prediction results. It specifically includes the following steps:

[0053] Step 1: Generate patch embedding vectors based on subway passenger flow time series data.

[0054] like Figure 2 As shown, the method to generate the patch embedding vector is as follows:

[0055] Each input subway passenger flow time series data X (i) First, each instance is normalized individually by Reversible Instance Normalization (RevIN) to ensure zero mean and unit standard deviation, thereby mitigating time series distribution drift. Then, the subway passenger flow time series data is segmented into time periods of fixed length by a sliding window method to generate a series of continuous patches. We take the i-th time series X (i) Divide into multiple fixed-length patches and introduce overlap using sliding window technology. Assuming that the length of each patch is P, the sliding step is S, and the time length is T, the railway passenger flow time series data can be divided into N patches, where Next, we map each patch vector to a fixed-size embedding dimension d through a linear layer (fully connected layer) m , the weight matrix size of the linear layer is d m ×P, the formula is:

[0056] e i =W1·p i +b1

[0057] Among them, e i is the embedding vector of the ith patch, of size d m . W1 is the weight matrix of the linear layer, size d m ×P, and b1 is the bias vector, size d m .

[0058] In order to preserve the temporal information in the time series, we add position information to each patch. The position encoding is usually a fixed vector, which is added to each patch embedding vector by addition, and the formula is expressed as:

[0059]

[0060] in, is the position encoding vector. Then each patch P is obtained i The embedding vector It can be expressed as:

[0061]

[0062] Among them, x[i:i+P] represents each patch, represents the patch embedding vector with added position information, W1 is the weight matrix of the linear layer mapping the patch vector, which maps the patch vector to the embedding space, P i is the i-th patch vector, b1 is the patch vector mapping bias vector, is the position encoding vector.

[0063] Finally, by adding the patch embedding vector with position information We get the patch embedding matrix There are two purposes for this: (1) by dividing the time series into smaller patches, each patch can capture local temporal dependencies and features, thereby helping the model better understand and learn patterns in subway passenger flow data, especially when the time series contains complex nonlinear relationships; (2) the size of the patches after segmentation is relatively small, which helps to improve computational and memory efficiency. In particular, when using GPU acceleration, smaller patches can more effectively utilize GPU resources, thereby improving computational efficiency.

[0064] Step 2: Use the multi-head attention mechanism to fuse the patch embedding vectors to obtain the attention mechanism patch embedding vector.

[0065] refer to Figure 3 As shown in Figure 2, the method of fusing patch embedding vectors using the multi-head attention mechanism is as follows:

[0066] We reprogram patch embeddings into the source data representation space to align subway passenger flow data and natural language modalities to activate the time series understanding and reasoning capabilities of large language models. A common technique is to learn a form of "noise" to enable the pre-trained source model to produce the desired target output on the target input samples without updating the model parameters. This approach is technically feasible when processing the same or similar data modalities, such as reusing vision models to process images across domains. In these cases, the transformation between the source and target data is explicit and learnable. However, subway passenger flow data can neither be directly edited nor losslessly expressed in natural language, which poses a significant challenge to directly launching LLM to understand time series data.

[0067] To address this problem, the patch embedding vectors are reprogrammed into the source data representation space to align subway passenger flow data and natural language modalities to activate the time series understanding and reasoning capabilities of large language models. To reprogram the patch embed where V is the size of the vocabulary and D is the embedding dimension. However, since there is no prior knowledge about which source tokens are directly related to the actual sequence data, we maintain a small set of text prototypes via linear probing E, denoted as Where V′<<V, E′ represents linear detection, V′ represents text prototype, Represents a text prototype with dimension D. Text prototype learning captures the characteristics of time series by connecting language clues and combines these clues to represent local patch information.

[0068] Text prototype learning captures the characteristics of time series by connecting language clues, such as "long stability" and "short rise", and combines these clues to represent local patch information. This method can effectively represent in the space of language model pre-training, thereby maintaining the intrinsic structure and context of the language model. Its efficiency is reflected in the ability to adaptively select the source information of subway passenger flow data, thereby optimizing the model's understanding and processing of local patch information.

[0069] In the multi-head attention mechanism, for each head k = {1, ..., K}, K represents the number of attention heads, the query matrix is ​​defined Key Value Matrix and the value matrix in, represents the query weight matrix, represents the key weight matrix, represents the value weight matrix, In particular, D represents the hidden dimension of the model, and

[0070] Then, the time series patch is reprogrammed in each attention mechanism head. The specific calculation formula is as follows:

[0071]

[0072] in, Represents the embedding vector, ATTENTION represents the attention mechanism, and SOFTMAX represents the normalization calculation.

[0073] By aggregating the output in each head get Next, a linear projection is performed to align the hidden dimension with the backbone model to generate the output attention mechanism patch embedding vector

[0074] Step 3: Construct prefix prompts based on subway passenger flow time series data.

[0075] As a direct and effective method, prompts are often used to activate large language models (LLMs) to perform specific tasks. In order to better adapt large language models to subway passenger flow time series data, a new method is proposed: prompts are used as prefixes to enrich the input context and guide the reprogramming of time series (subway passenger flow) patches. Specifically, by adding appropriate prompt information before the subway passenger flow time series data, the model's understanding and processing of time series are improved, thereby generating higher quality natural language descriptions. Therefore, a method for constructing prefix prompts based on subway passenger flow time series data is proposed: by adding prompt information before the subway passenger flow time series data, the reprogramming of subway passenger flow time series data patches is guided, the model's understanding and processing of time series are improved, thereby generating higher quality natural language descriptions.

[0076] The prefix hints include dataset context, task instructions and statistical information. The dataset context provides LLM with basic background information about the input subway passenger flow time series. The task instructions play a key role in guiding LLM in the patch embedding transformation of specific tasks. The statistical information includes trends and lags, maximum and minimum values, etc. The statistical information is used to enrich the input subway passenger flow time series to facilitate pattern recognition and reasoning. Among them, the first 5 lags of the time series are calculated, the autocorrelation is calculated by using fast Fourier transform, and the 5 lags with the highest correlation values ​​are selected for identification.

[0077] On this basis, the process of prefix hint word segmentation embedding effectively combines these three components. First, the task instructions and statistical information are converted into a format suitable for model understanding through word segmentation, and then embedding vectors are generated to capture the semantic characteristics of this information. Finally, these embedding vectors are fused with other input features to form a rich input representation, further improving the performance of the model in subway passenger flow prediction.

[0078] Step 4: fuse the prefix hint and the attention mechanism patch embedding vector to get the output projection.

[0079] The method of fusing prefix hints and attention mechanism patch embedding vectors, when the frozen LLM and feed-forward hints and patch embeddings O (i) Output projection is a key step when making predictions. The prefix hint embedding and attention mechanism patch embedding vectors are embedded by the frozen large language model. After packing and feedforward, the prefix part is discarded to obtain the output projection Here is a detailed description of the process:

[0080] 4.1) Frozen Large Oracle Models and Prefix Hints: A frozen large language model refers to a pre-trained language model that does not update model parameters during training. This model can take advantage of its rich semantic representation capabilities without retraining all parameters. Feedforward hints refer to adding specific hints on the input data to help the model understand and process the input data.

[0081] 4.2) Patch Embedding Vector Generation and Prefix Hint: Patch Embedding (i) After the time series data is split into multiple patches, each patch is embedded through a linear layer. This process has been completed in the previous step, and each patch is embedded as O (i) . After getting the patch embedded in O (i) Finally, in order to obtain the output representation, the prefix part needs to be discarded. This step is to remove the prefix information that may be useless for the final prediction and only retain the important feature information.

[0082] 4.3) Flattening: After discarding the prefix part, the remaining embedding representation is first flattened, and the embedding representation is O (i) , whose shape is (N, d m ), where N is the number of patches, d m is the embedding dimension, and the flattening operation converts it into a one-dimensional vector, as follows:

[0083] Flattened(O (i) )=reshape(O (i) ,-1)

[0084] Among them, Flattened means flattening operation, and reshape means reshaping.

[0085] 4.4) Linear projection and output prediction: A linear layer is used to map the flattened vector to the prediction dimension, and the linear projection is expressed as:

[0086]

[0087] Right now:

[0088]

[0089] in, represents the final predicted output of the model, that is, the output projection, W2 is the linear layer weight of the flattened vector mapping, and b2 is the bias of the flattened vector mapping.

[0090] Example 2

[0091] This embodiment provides a city subway passenger flow prediction system based on a large language model, which adopts the city subway passenger flow prediction method based on a large language model, including an input unit, a patch embedding vector generation unit, a multi-head attention unit, a prefix prompt construction unit, a fusion unit, and an output unit, wherein:

[0092] The input unit is used to input subway passenger flow time series data.

[0093] The patch embedding vector generating unit is used to generate a patch embedding vector according to subway passenger flow time series data.

[0094] The multi-head attention unit is used to fuse the patch embedding vectors using the multi-head attention mechanism to obtain the attention mechanism patch embedding vector.

[0095] The prefix prompt construction unit is used to construct a prefix prompt according to subway passenger flow time series data.

[0096] The fusion unit is used to fuse the prefix hint and the attention mechanism patch embedding vector to obtain the output projection.

[0097] The output unit is used to output the projection.

[0098] Example 3

[0099] This embodiment provides an electronic device, including: at least one processor, at least one memory and a communication interface. The processor, memory and communication interface communicate with each other. The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the urban subway passenger flow prediction method based on the large language model.

[0100] Example 4

[0101] Reference Figure 6 , which is an example of the present invention, provides a method for predicting urban subway passenger flow based on a large language model. In order to verify its beneficial effects, comparison results of multiple schemes are provided.

[0102] The example dataset of the present invention is constructed based on the subway systems in Shanghai and Hangzhou, China, covering the Shanghai subway data from July 1, 2016 to September 2016 and the Hangzhou subway data from January 2019. During this period, the Shanghai subway system operated 288 subway stations, connected 958 physical edges, processed an average of 8.82 million passenger traffic per day, and collected 811.8 million transaction records. Each record contains the passenger ID, entry and exit stations, and corresponding timestamp information, and calculates the entry and exit traffic of each station at intervals of 15 minutes. The dataset is divided into a training set (passenger volume data for the first two months and the last three weeks), a validation set (passenger volume data for the remaining dates), and a test set. The Hangzhou subway system includes 80 operating stations and 248 physical edges, processing 2.35 million traffic per day, and the time interval of the dataset is also 15 minutes. The Hangzhou dataset is also divided into a training set (January 1 to January 18), a validation set (January 19 to January 20), and a test set (January 21 to January 25) in chronological order.

[0103] We use the training set to train the model, the validation set to verify it, and the test set to test the model. We compare our invention with several existing subway passenger flow prediction models. Figure 6 and Figure 7 It can be seen that our invented method performs better on the test set than the existing urban subway passenger flow prediction methods, and achieves the lowest MAE value in all time intervals. This shows that our invented method has better prediction accuracy and generalization ability.

[0104] from Figure 8 and Fig. 9 It can be seen that for each prediction interval (15 minutes, 30 minutes, 45 minutes, and 60 minutes), the complete method achieves the best performance in terms of MAE value. This highlights the necessity of each module in capturing the complex temporal patterns of subway passenger flow. The patch embedding module effectively captures the temporal features, leading to more accurate predictions. The patch reprogramming module plays a key role in reprogramming the temporal data into a more structured format, enabling the proposed method to better understand complex flow patterns. Similarly, the prefix hint mechanism improves the model's understanding ability, but its impact on prediction accuracy is small. Finally, replacing the LLM with a basic linear layer leads to a sharp drop in performance on both datasets, which confirms the importance of the LLM's advanced learning capabilities in capturing the complex temporal dynamics of subway flow data. This result highlights the indispensable role of the LLM in ensuring the overall effectiveness of the present invention.

[0105] The present invention combines patch embedding vector generation, multi-head attention mechanism, prefix prompt design and other methods to fully explore and utilize the complex characteristics of subway passenger flow data, thereby improving the accuracy and reliability of prediction. This method provides effective decision support for urban subway operation management and helps optimize traffic scheduling and passenger services.

[0106] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for predicting urban subway passenger flow based on a large language model, characterized in that: The following steps are involved: Step 1: Generate patch embedding vectors based on subway passenger flow time series data; Step 2: Use the multi-head attention mechanism to fuse the patch embedding vectors to obtain the attention mechanism patch embedding vector; Step 3, construct prefix prompts based on subway passenger flow time series data; Step 4: fuse the prefix hint and the attention mechanism patch embedding vector to get the output projection.

2. The method for predicting urban subway passenger flow based on a large language model according to claim 1 is characterized by: Method to generate patch embedding vector in step 1: The subway passenger flow time series data is divided into time periods of fixed length by the sliding window method to generate a series of continuous patches; the length of each patch is P, and the sliding step is S, so the subway passenger flow time series data is divided into N patches, where Then each patch P is obtained i The embedding vector It is expressed as: Where T represents the time length, x[i:i+P] represents each patch, represents the patch embedding vector with added position information, W1 is the weight matrix of the linear layer mapping the patch vector, which maps the patch vector to the embedding space, P i is the i-th patch vector, b1 is the patch vector mapping bias vector, is the position encoding vector; by adding the patch embedding vector with position information Get patch embed 3. The method for predicting urban subway passenger flow based on a large language model according to claim 2 is characterized in that: The method of fusing patch embedding vectors using the multi-head attention mechanism in step 2: reprogramming the patch embedding vectors into the source data representation space to align subway passenger flow data and natural language modalities to activate the time series understanding and reasoning capabilities of the large language model; using pre-trained word embeddings To reprogram the patch embed Where V is the size of the vocabulary and D is the embedding dimension. A small set of text prototypes is maintained by linear probing E, where V′<<V, E′ represents linear probing, V′ represents text prototype, Represents a text prototype with dimension D; text prototype learning captures the characteristics of time series by connecting language clues and combines these clues to represent local patch information.

4. The method for predicting urban subway passenger flow based on a large language model according to claim 3 is characterized by: In the multi-head attention mechanism in step 2, for each head k = {1, ..., K}, K represents the number of attention heads, define the query matrix Key Value Matrix and the value matrix in, represents the query weight matrix, represents the key weight matrix, represents the value weight matrix, In particular, D represents the hidden dimension of the model, and Reprogram the time series patch in each attention mechanism head. The specific calculation formula is as follows: in, represents the embedding vector, ATTENTION represents the attention mechanism, and SOFTMAX represents the normalization calculation; by aggregating the output of each head get Next, a linear projection is performed to align the hidden dimension with the backbone model to generate the output attention mechanism patch embedding vector 5. The method for predicting urban subway passenger flow based on a large language model according to claim 4 is characterized by: Step 3: A method for constructing prefix prompts based on subway passenger flow time series data: By adding prompt information before the subway passenger flow time series data, the reprogramming of subway passenger flow time series data patches is guided, and the model's understanding and processing of time series is improved, thereby generating higher quality natural language descriptions.

6. The method for predicting urban subway passenger flow based on a large language model according to claim 5 is characterized by: In step 3, the prefix hint includes dataset context, task instructions and statistical information. The dataset context provides LLM with basic background information about the input subway passenger flow time series. The task instructions play a key role in guiding LLM in the patch embedding conversion of specific tasks. The statistical information is used to enrich the input subway passenger flow time series to facilitate pattern recognition and reasoning.

7. The method for predicting urban subway passenger flow based on a large language model according to claim 6 is characterized by: Method for fusing prefix hint and attention mechanism patch embedding vectors in step 4: embedding prefix hint and attention mechanism patch embedding vectors through frozen large language model After packing and feedforwarding, the prefix part is discarded to obtain the output projection.

8. The method for predicting urban subway passenger flow based on a large language model according to claim 7 is characterized by: In step 4, the formula for fusing the prefix hint and the attention mechanism patch embedding vector to get the output projection is: in, represents the final prediction output of the model, W2 is the weight of the linear layer after flattening, Flattened represents the flattening operation, reshape represents the reshaping, O (i) is the attention mechanism patch embedding vector, and b2 is the flattened vector mapping bias.

9. A city subway passenger flow prediction system based on a large language model, characterized in that: The method for predicting urban subway passenger flow based on a large language model according to any one of claims 1 to 8 comprises an input unit, a patch embedding vector generation unit, a multi-head attention unit, a prefix prompt construction unit, a fusion unit, and an output unit, wherein: The input unit is used to input subway passenger flow time series data; The patch embedding vector generating unit is used to generate a patch embedding vector according to subway passenger flow time series data; The multi-head attention unit is used to fuse the patch embedding vectors using the multi-head attention mechanism to obtain the attention mechanism patch embedding vector; The prefix prompt construction unit is used to construct a prefix prompt according to the subway passenger flow time series data; The fusion unit is used to fuse the prefix hint and the attention mechanism patch embedding vector to obtain the output projection; The output unit is used to output the projection.

10. An electronic device, characterized in that: include: at least one processor, at least one memory, and a communication interface; The processor, memory and communication interface communicate with each other; The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the urban subway passenger flow prediction method based on a large language model as described in any one of claims 1-8.

Citation Information

Patent Citations

  • Traffic flow prediction method based on time window division modeling dynamic space-time correlation

    CN117351710A

  • Big language model-based customs named entity recognition method

    CN118798200A

  • Airport short-term load prediction method based on large language model migration

    CN118966422A

  • Electric vehicle charging station load orderly regulation and control method and system based on large language model

    CN119047784A

Cited By

  • Expressway carbon emission analysis method based on dynamic Bayesian network, storage medium and computer terminal equipment

    CN120046875A

  • Jacket structure safety diagnosis system and method based on time sequence large language model

    CN120494813A

  • Multivariable time sequence prediction method and device based on spatio-temporal feature fusion

    CN120910514A

  • Metro passenger flow construction environment feature analysis method based on large language model ensemble learning

    CN122242981A